Plugin Directory

Changeset 2851804


Ignore:
Timestamp:
01/20/2023 11:18:35 AM (3 years ago)
Author:
toddhalfpenny
Message:

v1.7 WordPress Vsn Test,Securtity Fix

Location:
widgets-on-pages/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • widgets-on-pages/trunk/public/class-widgets-on-pages-public.php

    r1776688 r2851804  
    11<?php
    2 
    32/**
    43 * The public-facing functionality of the plugin.
     
    109 * @subpackage Widgets_On_Pages/public
    1110 */
     11
    1212/**
    1313 * The public-facing functionality of the plugin.
     
    2020 * @author     Todd Halfpenny <todd@toddhalfpenny.com>
    2121 */
    22 class Widgets_On_Pages_Public
    23 {
    24     /**
    25      * The ID of this plugin.
    26      *
    27      * @since    1.0.0
    28      * @access   private
    29      * @var      string    $plugin_name    The ID of this plugin.
    30      */
    31     private  $plugin_name ;
    32     /**
    33      * The version of this plugin.
    34      *
    35      * @since    1.0.0
    36      * @access   private
    37      * @var      string    $version    The current version of this plugin.
    38      */
    39     private  $version ;
    40     /**
    41      * Initialize the class and set its properties.
    42      *
    43      * @since    1.0.0
    44      * @param string $plugin_name       The name of the plugin.
    45      * @param string $version    The version of this plugin.
    46      */
    47     public function __construct( $plugin_name, $version )
    48     {
    49         $this->plugin_name = $plugin_name;
    50         $this->version = $version;
    51         $this->widgets_on_template();
    52         add_shortcode( 'widgets_on_pages', array( $this, 'widgets_on_page' ) );
    53     }
    54    
    55     /**
    56      * Our lovely shortcode.
    57      *
    58      * @param array $atts Should contain '$id' that should match to Turbo Sidebar.
    59      * @since    1.0.0
    60      */
    61     public static function widgets_on_page( $atts )
    62     {
    63         extract( shortcode_atts( array(
    64             'id'     => '1',
    65             'tiny'   => '1',
    66             'small'  => '1',
    67             'medium' => '1',
    68             'large'  => '1',
    69             'wide'   => '1',
    70         ), $atts ) );
    71         $str = "<div id='" . str_replace( ' ', '_', $id ) . "' class='widgets_on_page wop_tiny" . $tiny . '  wop_small' . $small . '  wop_medium' . $medium . '  wop_large' . $large . '  wop_wide' . $wide . "'>\n\t\t\t<ul>";
    72         // Legacy bullshit.
    73         if ( is_numeric( $id ) ) {
    74             $id = 'wop-' . $id;
    75         }
    76         ob_start();
    77        
    78         if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( $id ) ) {
    79             $my_str = ob_get_contents();
    80         } else {
    81             // Ouput somethign nice to the source.
    82             $my_str = '<!-- ERROR NO TURBO SIDEBAR FOUND WITH ID ' . $id . '-->';
    83         }
    84        
    85         ob_end_clean();
    86         $str .= $my_str;
    87         $str .= '</ul></div><!-- widgets_on_page -->';
    88         return $str;
    89     }
    90    
    91     /**
    92      * Our lovely template tage handler.
    93      *
    94      * @param string $id Id that should match the ID of our Turbo Sidebar.
    95      * @since    1.0.0
    96      */
    97     public static function widgets_on_template( $id = '1' )
    98     {
    99         $arr = array(
    100             'id' => $id,
    101         );
    102         return Widgets_On_Pages_Public::widgets_on_page( $arr );
    103     }
    104    
    105     /**
    106      * Register the stylesheets for the public-facing side of the site.
    107      *
    108      * @since    1.0.0
    109      */
    110     public function enqueue_styles()
    111     {
    112         /**
    113          * This function is provided for demonstration purposes only.
    114          *
    115          * An instance of this class should be passed to the run() function
    116          * defined in Widgets_On_Pages_Loader as all of the hooks are defined
    117          * in that particular class.
    118          *
    119          * The Widgets_On_Pages_Loader will then create the relationship
    120          * between the defined hooks and the functions defined in this
    121          * class.
    122          */
    123         $options = get_option( 'wop_options_field' );
    124         if ( !is_array( $options ) ) {
    125             $options = array();
    126         }
    127        
    128         if ( array_key_exists( 'enable_css', $options ) ) {
    129             $tmp = get_option( 'wop_options_field' );
    130             $enable_css = $tmp['enable_css'];
    131             if ( $enable_css ) {
    132                 wp_enqueue_style(
    133                     $this->plugin_name,
    134                     plugin_dir_url( __FILE__ ) . 'css/widgets-on-pages-public.css',
    135                     array(),
    136                     $this->version,
    137                     'all'
    138                 );
    139             }
    140         }
    141    
    142     }
    143    
    144     /**
    145      * Register the JavaScript for the public-facing side of the site.
    146      *
    147      * @since    1.0.0
    148      */
    149     public function enqueue_scripts()
    150     {
    151     }
    152 
     22class Widgets_On_Pages_Public {
     23
     24    /**
     25     * The ID of this plugin.
     26     *
     27     * @since    1.0.0
     28     * @access   private
     29     * @var      string    $plugin_name    The ID of this plugin.
     30     */
     31    private $plugin_name;
     32
     33    /**
     34     * The version of this plugin.
     35     *
     36     * @since    1.0.0
     37     * @access   private
     38     * @var      string    $version    The current version of this plugin.
     39     */
     40    private $version;
     41
     42    /**
     43     * Initialize the class and set its properties.
     44     *
     45     * @since    1.0.0
     46     * @param string $plugin_name       The name of the plugin.
     47     * @param string $version    The version of this plugin.
     48     */
     49    public function __construct( $plugin_name, $version ) {
     50
     51        $this->plugin_name = $plugin_name;
     52        $this->version = $version;
     53
     54        $this->widgets_on_template();
     55
     56        add_shortcode( 'widgets_on_pages', array( $this, 'widgets_on_page' ) );
     57
     58        if ( wop_fs()->is__premium_only() ) {
     59            add_filter( 'the_content', array( $this, 'maybe_insert_with_content__premium_only' ) );
     60            add_filter( 'custom-header', array( $this, 'maybe_insert_with_header__premium_only' ) );
     61        }
     62    }
     63
     64
     65    /**
     66     * Our lovely shortcode.
     67     *
     68     * @param array $atts Should contain '$id' that should match to Turbo Sidebar.
     69     * @since    1.0.0
     70     */
     71    public static function widgets_on_page( $atts ) {
     72        foreach ($atts as &$value) {
     73            $value = esc_js($value);
     74        }
     75        extract( shortcode_atts( array( 'id' => '1', 'tiny' => '1', 'small' => '1', 'medium' => '1', 'large' => '1', 'wide' => '1' ), $atts ) );
     76        $str = "<div id='" . str_replace( ' ', '_', $id ) . "' class='widgets_on_page wop_tiny" . $tiny . '  wop_small' . $small . '  wop_medium' . $medium . '  wop_large' . $large . '  wop_wide' . $wide  ."'>
     77            <ul>";
     78
     79        // Legacy bullshit.
     80        if ( is_numeric( $id ) ) {
     81            $id = 'wop-' . $id;
     82        }
     83
     84        ob_start();
     85        if ( function_exists( 'dynamic_sidebar' ) && dynamic_sidebar( $id ) ) {
     86            $my_str = ob_get_contents();
     87        } else {
     88            // Ouput somethign nice to the source.
     89            $my_str = '<!-- ERROR NO TURBO SIDEBAR FOUND WITH ID ' . $id . '-->';
     90        }
     91        ob_end_clean();
     92        $str .= $my_str;
     93        $str .= '</ul></div><!-- widgets_on_page -->';
     94        return $str;
     95    }
     96
     97
     98    /**
     99     * Our lovely template tage handler.
     100     *
     101     * @param string $id Id that should match the ID of our Turbo Sidebar.
     102     * @since    1.0.0
     103     */
     104    public static function widgets_on_template( $id = '1' ) {
     105        $arr = array( 'id' => $id );
     106        return Widgets_On_Pages_Public::widgets_on_page( $arr );
     107    }
     108
     109    /**
     110     * Our filter to maybe add our sidebar(s) before/after the content
     111     *
     112     * @param  string $content The content of our post.
     113     * @return string $content the content maybe with our sidebar(s) in.
     114     */
     115    public function maybe_insert_with_content__premium_only( $content ) {
     116        if ( ! in_the_loop() || ! is_main_query() || ! is_singular() ) {
     117            return $content;
     118        }
     119
     120        $args = array(
     121            'post_type' => 'turbo-sidebar-cpt',
     122            'posts_per_page' => 50,
     123            'meta_query' => array(
     124                'relation' => 'AND',
     125                array(
     126                    'key' => '_wop_auto_insert',
     127                    'value' => 0,
     128                ),
     129                array(
     130                    'key' => '_wop_before_after',
     131                    'value' => array( '0', '1' ), // Before content, after content.
     132                    'compare' => 'IN',
     133                ),
     134            ),
     135        );
     136        $potential_turbo_sidebars = get_posts( $args );
     137
     138        if ( empty( $potential_turbo_sidebars ) ) {
     139            return $content;
     140        }
     141
     142        $pst_id = get_the_ID();
     143        // Check if we should exclude for this post_id.
     144        $pst_exclude = get_post_meta( $pst_id, '_wop_exclude', true );
     145        if ( $pst_exclude ) {
     146            return $content;
     147        }
     148
     149        // Check if we should show for this post type.
     150        $valid_post_types = $potential_turbo_sidebars[0]->_wop_valid_post_types;
     151        if ( 'all' == $valid_post_types ) {
     152            $valid_post_type = true;
     153        } else {
     154            $pst_type = get_post_type( $pst_id );
     155            if ( $pst_type == $valid_post_types ) {
     156                $valid_post_type = true;
     157            } else {
     158                $valid_post_type = false;
     159            }
     160        }
     161
     162        if ( $valid_post_type ) {
     163            $arr = array(
     164                'id' => $potential_turbo_sidebars[0]->post_title,
     165                'small' => $potential_turbo_sidebars[0]->_wop_cols_small,
     166                'medium' => $potential_turbo_sidebars[0]->_wop_cols_medium,
     167                'large' => $potential_turbo_sidebars[0]->_wop_cols_large,
     168                'wide' => $potential_turbo_sidebars[0]->_wop_cols_wide,
     169                );
     170            if ( 1 == $potential_turbo_sidebars[0]->_wop_before_after ) {
     171                return $content . $this->widgets_on_page( $arr );
     172            } else {
     173                return $this->widgets_on_page( $arr ) . $content;
     174            }
     175        } else {
     176            return $content;
     177        }
     178    }
     179
     180    /**
     181     * Register the stylesheets for the public-facing side of the site.
     182     *
     183     * @since    1.0.0
     184     */
     185    public function enqueue_styles() {
     186        /**
     187         * This function is provided for demonstration purposes only.
     188         *
     189         * An instance of this class should be passed to the run() function
     190         * defined in Widgets_On_Pages_Loader as all of the hooks are defined
     191         * in that particular class.
     192         *
     193         * The Widgets_On_Pages_Loader will then create the relationship
     194         * between the defined hooks and the functions defined in this
     195         * class.
     196         */
     197
     198        $options = get_option( 'wop_options_field' );
     199        if ( ! is_array( $options ) ) {
     200            $options = array();
     201        }
     202        if ( array_key_exists( 'enable_css', $options ) ) {
     203            $tmp = get_option( 'wop_options_field' );
     204            $enable_css = $tmp['enable_css'];
     205            // $enable_css = $options["enable_css"];
     206            if ( wop_fs()->is__premium_only() ) {
     207                wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widgets-on-pages-public__premium_only.css', array(), $this->version, 'all' );
     208            } else {
     209                if ( $enable_css ) {
     210                    wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/widgets-on-pages-public.css', array(), $this->version, 'all' );
     211                }
     212            }
     213        }
     214
     215    }
     216
     217    /**
     218     * Register the JavaScript for the public-facing side of the site.
     219     *
     220     * @since    1.0.0
     221     */
     222    public function enqueue_scripts() {
     223
     224        /**
     225         * This function is provided for demonstration purposes only.
     226         *
     227         * An instance of this class should be passed to the run() function
     228         * defined in Widgets_On_Pages_Loader as all of the hooks are defined
     229         * in that particular class.
     230         *
     231         * The Widgets_On_Pages_Loader will then create the relationship
     232         * between the defined hooks and the functions defined in this
     233         * class.
     234         */
     235
     236        if ( wop_fs()->is__premium_only() ) {
     237            if ( in_the_loop() || is_main_query() || is_singular() ) {
     238                global $post;
     239                // Check to see if we have any TurboSidebars that have auto_include into headers/footers.
     240                $args = array(
     241                    'post_type' => 'turbo-sidebar-cpt',
     242                    'posts_per_page' => 50,
     243                    'meta_query' => array(
     244                array(
     245                            'key' => '_wop_before_after',
     246                            'value' => array( '2', '3', '4', '5' ), // Before header, afetr header, before footer, after footer.
     247                            'compare' => 'IN',
     248                ),
     249                    ),
     250                );
     251                $potential_turbo_sidebars = get_posts( $args );
     252
     253                if ( ! empty( $potential_turbo_sidebars ) ) {
     254                    wp_enqueue_script( $this->plugin_name . '_prem', plugin_dir_url( __FILE__ ) . 'js/wop-public__premium_only.js', array( 'jquery' ), $this->version, true );
     255                    // Make our current $post->ID available to our JS.
     256                    wp_localize_script( $this->plugin_name . '_prem', 'wop_vars', array( 'post_id' => $post->ID, 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
     257                }
     258            }
     259        }
     260    }
    153261}
  • widgets-on-pages/trunk/readme.txt

    r2690006 r2851804  
    44Tags: widgets, widgets in page, widgets in post, sidebar, pages, post, shortcode, inline, widgetise, widgetize, theme
    55Requires at least: 2.8
    6 Tested up to: 5.9.1
    7 Stable tag: 1.6
    8 
    9 The easiest and highest rated way to Add Widgets or Sidebars to Posts and Pages using Visual editor, shortcodes or template tags.
     6Tested up to: 6.1.1
     7Stable tag: 1.7
     8
     9The easiest and highest rated way to Add Widgets or Sidebars to Posts and Pages using Visual editor,  shortcodes or template tags.
    1010
    1111== Description ==
     
    2323> With the [PRO](https://datamad.co.uk/wordpress-plugins/widgets-on-pages/) version the widgets can be inserted simply with clicks-not-code using a wizard in the visual editor. This version also includes layout options to easily set the widgets in columns/grid presentation.
    2424>
    25 > Pro version also supports the configurable option to automatically add widgets to all your posts and/or pages. Choose the layout options and whether to add the sidebar and widgets before or after the content. Ideal for adding lists of related posts to the end of every post. Each post and page can also be individually excluded from the auto-inclusion of the widgets.
     25> Pro version also supports the configurable option to automatically add widgets to all your posts and/or pages. Choose the layout options and whether to add the sidebar and widgets before or after the content. Ideal for adding lists of related posts to the end of every post. Each post and page can also be individually excluded from the auto-inclsion of the widgets.
    2626>
    2727> [Pro version](https://datamad.co.uk/wordpress-plugins/widgets-on-pages/) key features
     
    4444**Current Features Include**
    4545
    46 * Highest Rating - 136 5* Reviews
     46* Highest Rating - 122 5* Reviews
    4747* No Coding needed
    4848* Create unlimited sidebars
     
    100100
    101101== Changelog ==
     102= 1.7 =
     103
     1041. Dep bump - Security Fix
    102105
    103106= 1.6 =
    104107
    105 1. Dependancy library update - security fix
    106 
    107 = 1.5 =
    108 
    109 1. Dependancy library update - security fix
    110 
     1081. Dep bump - Security Fix
    111109
    112110= 1.4 =
  • widgets-on-pages/trunk/widgets_on_pages.php

    r2689994 r2851804  
    1212 * Plugin URI:        https://datamad.co.uk/wordpress-plugins/widgets-on-pages/
    1313 * Description:       The easiest way to Add Widgets or Sidebars to Posts and Pages using shortcodes or template tags.
    14  * Version:           1.6.0
     14 * Version:           1.7.0
    1515 * Author:            Todd Halfpenny
    1616 * Author URI:        http://toddhalfpenny.com/
Note: See TracChangeset for help on using the changeset viewer.