Advertisement
bokisha

Smart Recent Posts Widget - Cross Site Scripting (XSS) FIX

Jul 2nd, 2025
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 33.19 KB | Source Code | 0 0
  1. <?php
  2.  
  3. /**
  4.  * The custom recent posts widget.
  5.  * This widget gives total control over the output to the user.
  6.  */
  7. class SMART_RECENT_POSTS_WIDGET extends WP_Widget {
  8.  
  9.     /**
  10.      * Sets up the widgets.
  11.      */
  12.     public function __construct() {
  13.  
  14.         // Set up the widget options.
  15.         $widget_options = array(
  16.             'classname'   => 'widget_smart_recent_entries smart_recent_posts',
  17.             'description' => __('An advanced widget that gives you total control over the output of your site’s most recent Posts.', 'smart-recent-posts-widget'),
  18.             'customize_selective_refresh' => true
  19.         );
  20.  
  21.         $control_options = array(
  22.             'width'  => 450
  23.         );
  24.  
  25.         // Create the widget.
  26.         parent::__construct(
  27.             'srpw_widget',                                         // $this->id_base
  28.             __('Smart Recent Posts', 'smart-recent-posts-widget'), // $this->name
  29.             $widget_options,                                       // $this->widget_options
  30.             $control_options                                       // $this->control_options
  31.         );
  32.  
  33.         $this->alt_option_name = 'widget_smart_recent_entries';
  34.     }
  35.  
  36.     /**
  37.      * Outputs the widget based on the arguments input through the widget controls.
  38.      */
  39.     public function widget($args, $instance) {
  40.         if (!isset($args['widget_id'])) {
  41.             $args['widget_id'] = $this->id;
  42.         }
  43.  
  44.         // Get the recent posts
  45.         $recent = srpw_get_recent_posts($instance);
  46.  
  47.         if ($recent) {
  48.  
  49.             // Output the theme's $before_widget wrapper.
  50.             echo $args['before_widget'];
  51.  
  52.             // If both title and title url is not empty, display it.
  53.             if (!empty($instance['title_url']) && !empty($instance['title'])) {
  54.                 echo $args['before_title'] . '<a href="' . esc_url($instance['title_url']) . '" title="' . esc_attr($instance['title']) . '">' . apply_filters('widget_title',  $instance['title'], $instance, $this->id_base) . '</a>' . $args['after_title'];
  55.  
  56.                 // If the title not empty, display it.
  57.             } elseif (!empty($instance['title'])) {
  58.                 echo $args['before_title'] . apply_filters('widget_title',  $instance['title'], $instance, $this->id_base) . $args['after_title'];
  59.             }
  60.  
  61.             // Get the recent posts query.
  62.             echo $recent;
  63.  
  64.             // Close the theme's widget wrapper.
  65.             echo $args['after_widget'];
  66.         }
  67.     }
  68.  
  69.     /**
  70.      * Updates the widget control options for the particular instance of the widget.
  71.      */
  72.     public function update($new_instance, $old_instance) {
  73.  
  74.         // Validate post_type submissions
  75.         $name = get_post_types(array('public' => true), 'names');
  76.         $types = array();
  77.         if (isset($new_instance['post_type']) && is_array($new_instance['post_type'])) {
  78.             foreach ($new_instance['post_type'] as $type) {
  79.                 if (in_array($type, $name)) {
  80.                     $types[] = sanitize_text_field($type);
  81.                 }
  82.             }
  83.         }
  84.         if (empty($types)) {
  85.             $types[] = 'post';
  86.         }
  87.  
  88.         $instance                     = $old_instance;
  89.  
  90.         // General tab
  91.         $instance['title']            = sanitize_text_field($new_instance['title']);
  92.         $instance['title_url']        = esc_url_raw($new_instance['title_url']);
  93.         if (current_user_can('unfiltered_html')) {
  94.             $instance['before'] = $new_instance['before'];
  95.         } else {
  96.             $instance['before'] = wp_kses_post($new_instance['before']);
  97.         }
  98.         if (current_user_can('unfiltered_html')) {
  99.             $instance['after'] = $new_instance['after'];
  100.         } else {
  101.             $instance['after'] = wp_kses_post($new_instance['after']);
  102.         }
  103.         $instance['css_class']        = sanitize_html_class($new_instance['css_class']);
  104.  
  105.         // Posts tab
  106.         $instance['ignore_sticky']    = isset($new_instance['ignore_sticky']) ? (bool) $new_instance['ignore_sticky'] : false;
  107.         $instance['exclude_current']  = isset($new_instance['exclude_current']) ? (bool) $new_instance['exclude_current'] : false;
  108.         $instance['limit']            = intval($new_instance['limit']);
  109.         $instance['offset']           = intval($new_instance['offset']);
  110.         $instance['order']            = sanitize_text_field($new_instance['order']);
  111.         $instance['orderby']          = sanitize_text_field($new_instance['orderby']);
  112.         $instance['post_type']        = $types;
  113.         $instance['post_status']      = sanitize_text_field($new_instance['post_status']);
  114.  
  115.         // Taxonomy tab
  116.         $instance['cat']              = array_map('intval', (array) $new_instance['cat']);
  117.         $instance['tag']              = array_map('intval', (array) $new_instance['tag']);
  118.         $instance['cat_exclude']      = array_map('intval', (array) $new_instance['cat_exclude']);
  119.         $instance['tag_exclude']      = array_map('intval', (array) $new_instance['tag_exclude']);
  120.  
  121.         // Thumbnail tab
  122.         $instance['thumbnail']        = isset($new_instance['thumbnail']) ? (bool) $new_instance['thumbnail'] : false;
  123.         $instance['thumbnail_size']   = sanitize_text_field($new_instance['thumbnail_size']);
  124.         $instance['thumbnail_default'] = esc_url_raw($new_instance['thumbnail_default']);
  125.         $instance['thumbnail_align']  = sanitize_text_field($new_instance['thumbnail_align']);
  126.  
  127.         // Excerpt tab
  128.         $instance['excerpt']          = isset($new_instance['excerpt']) ? (bool) $new_instance['excerpt'] : false;
  129.         $instance['length']           = intval($new_instance['length']);
  130.         $instance['readmore']         = isset($new_instance['readmore']) ? (bool) $new_instance['readmore'] : false;
  131.         $instance['readmore_text']    = sanitize_text_field($new_instance['readmore_text']);
  132.  
  133.         // Display tab
  134.         $instance['post_title']       = isset($new_instance['post_title']) ? (bool) $new_instance['post_title'] : false;
  135.         $instance['date']             = isset($new_instance['date']) ? (bool) $new_instance['date'] : false;
  136.         $instance['date_relative']    = isset($new_instance['date_relative']) ? (bool) $new_instance['date_relative'] : false;
  137.         $instance['date_modified']    = isset($new_instance['date_modified']) ? (bool) $new_instance['date_modified'] : false;
  138.         $instance['comment_count']    = isset($new_instance['comment_count']) ? (bool) $new_instance['comment_count'] : false;
  139.         $instance['author']           = isset($new_instance['author']) ? (bool) $new_instance['author'] : false;
  140.  
  141.         // Appearance tab
  142.         $instance['style']            = sanitize_text_field($new_instance['style']);
  143.         $instance['new_tab']          = isset($new_instance['new_tab']) ? (bool) $new_instance['new_tab'] : false;
  144.         $instance['css']              = wp_strip_all_tags($new_instance['css']);
  145.  
  146.         return $instance;
  147.     }
  148.  
  149.     /**
  150.      * Displays the widget control options in the Widgets admin screen.
  151.      */
  152.     public function form($instance) {
  153.  
  154.         // Merge the user-selected arguments with the defaults.
  155.         $instance = wp_parse_args((array) $instance, srpw_get_default_args());
  156.  
  157.         // Extract the array to allow easy use of variables.
  158.         extract($instance); ?>
  159.  
  160.         <div class="srpw-options">
  161.  
  162.             <div class="srpw-options__wrapper">
  163.  
  164.                 <div class="srpw-options__option">
  165.  
  166.                     <p>
  167.                         <label for="<?php echo $this->get_field_id('title'); ?>">
  168.                             <?php esc_html_e('Title', 'smart-recent-posts-widget'); ?>
  169.                         </label>
  170.                         <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($instance['title']); ?>" />
  171.                     </p>
  172.  
  173.                     <p>
  174.                         <label for="<?php echo $this->get_field_id('title_url'); ?>">
  175.                             <?php esc_html_e('Title URL', 'smart-recent-posts-widget'); ?>
  176.                         </label>
  177.                         <input class="widefat" id="<?php echo $this->get_field_id('title_url'); ?>" name="<?php echo $this->get_field_name('title_url'); ?>" type="url" value="<?php echo esc_url($instance['title_url']); ?>" />
  178.                     </p>
  179.  
  180.                     <p>
  181.                         <label for="<?php echo $this->get_field_id('css_class'); ?>">
  182.                             <?php esc_html_e('CSS Class', 'smart-recent-posts-widget'); ?>
  183.                         </label>
  184.                         <input class="widefat" id="<?php echo $this->get_field_id('css_class'); ?>" name="<?php echo $this->get_field_name('css_class'); ?>" type="text" value="<?php echo sanitize_html_class($instance['css_class']); ?>" />
  185.                     </p>
  186.  
  187.                                         <p>
  188.                         <label for="<?php echo esc_attr( $this->get_field_id('before') ); ?>">
  189.                             <?php esc_html_e('HTML or text before the recent posts', 'smart-recent-posts-widget'); ?>
  190.                         </label>
  191.                         <textarea
  192.                             class="widefat"
  193.                             id="<?php echo esc_attr( $this->get_field_id('before') ); ?>"
  194.                             name="<?php echo esc_attr( $this->get_field_name('before') ); ?>"
  195.                             rows="5"
  196.                         ><?php echo esc_textarea( $instance['before'] ); ?></textarea>
  197.                     </p>
  198.  
  199.                                         <p>
  200.                         <label for="<?php echo esc_attr( $this->get_field_id('after') ); ?>">
  201.                             <?php esc_html_e('HTML or text after the recent posts', 'smart-recent-posts-widget'); ?>
  202.                         </label>
  203.                         <textarea
  204.                             class="widefat"
  205.                             id="<?php echo esc_attr( $this->get_field_id('after') ); ?>"
  206.                             name="<?php echo esc_attr( $this->get_field_name('after') ); ?>"
  207.                             rows="5"
  208.                         ><?php echo esc_textarea( $instance['after'] ); ?></textarea>
  209.                     </p>
  210.  
  211.                 </div>
  212.  
  213.                 <div class="srpw-options__option">
  214.  
  215.                     <p>
  216.                         <input class="checkbox" type="checkbox" <?php checked($instance['ignore_sticky'], 1); ?> id="<?php echo $this->get_field_id('ignore_sticky'); ?>" name="<?php echo $this->get_field_name('ignore_sticky'); ?>" />
  217.                         <label for="<?php echo $this->get_field_id('ignore_sticky'); ?>">
  218.                             <?php esc_html_e('Ignore sticky posts', 'smart-recent-posts-widget'); ?>
  219.                         </label>
  220.                     </p>
  221.  
  222.                     <p>
  223.                         <input class="checkbox" type="checkbox" <?php checked($instance['exclude_current'], 1); ?> id="<?php echo $this->get_field_id('exclude_current'); ?>" name="<?php echo $this->get_field_name('exclude_current'); ?>" />
  224.                         <label for="<?php echo $this->get_field_id('exclude_current'); ?>">
  225.                             <?php esc_html_e('Exclude current post', 'smart-recent-posts-widget'); ?>
  226.                         </label>
  227.                     </p>
  228.  
  229.                     <p>
  230.                         <label for="<?php echo $this->get_field_id('limit'); ?>">
  231.                             <?php esc_html_e('Number of posts to show', 'smart-recent-posts-widget'); ?>
  232.                         </label>
  233.                         <input class="widefat" id="<?php echo $this->get_field_id('limit'); ?>" name="<?php echo $this->get_field_name('limit'); ?>" type="number" step="1" min="-1" value="<?php echo (int)($instance['limit']); ?>" />
  234.                     </p>
  235.  
  236.                     <p>
  237.                         <label for="<?php echo $this->get_field_id('offset'); ?>">
  238.                             <?php esc_html_e('Offset', 'smart-recent-posts-widget'); ?>
  239.                         </label>
  240.                         <input class="widefat" id="<?php echo $this->get_field_id('offset'); ?>" name="<?php echo $this->get_field_name('offset'); ?>" type="number" step="1" min="0" value="<?php echo (int)($instance['offset']); ?>" />
  241.                         <small><?php esc_html_e('The number of posts to skip', 'smart-recent-posts-widget'); ?></small>
  242.                     </p>
  243.  
  244.                     <div class="srpw-multiple-check-form">
  245.                         <label>
  246.                             <?php esc_html_e('Post Types', 'smart-recent-posts-widget'); ?>
  247.                         </label>
  248.                         <?php foreach (get_post_types(array('public' => true), 'objects') as $type) : ?>
  249.                             <p>
  250.                                 <input type="checkbox" value="<?php echo esc_attr($type->name); ?>" id="<?php echo $this->get_field_id('post_type') . '-' . $type->name; ?>" name="<?php echo $this->get_field_name('post_type'); ?>[]" <?php checked(is_array($instance['post_type']) && in_array($type->name, $instance['post_type'])); ?> />
  251.                                 <label for="<?php echo $this->get_field_id('post_type') . '-' . $type->name; ?>">
  252.                                     <?php echo esc_html($type->labels->name); ?>
  253.                                 </label>
  254.                             </p>
  255.                         <?php endforeach; ?>
  256.                         <small><?php esc_html_e('Please note, Media post type is not supported by this plugin yet.', 'smart-recent-posts-widget') ?></small>
  257.                     </div>
  258.  
  259.                     <p>
  260.                         <label for="<?php echo $this->get_field_id('post_status'); ?>">
  261.                             <?php esc_html_e('Post Status', 'smart-recent-posts-widget'); ?>
  262.                         </label>
  263.                         <select class="widefat" id="<?php echo $this->get_field_id('post_status'); ?>" name="<?php echo $this->get_field_name('post_status'); ?>" style="width:100%;">
  264.                             <?php foreach (array_keys(get_object_vars(wp_count_posts('post'))) as $status_value => $status_label) { ?>
  265.                                 <option value="<?php echo esc_attr($status_label); ?>" <?php selected($instance['post_status'], $status_label); ?>><?php echo esc_html(ucfirst($status_label)); ?></option>
  266.                             <?php } ?>
  267.                         </select>
  268.                     </p>
  269.  
  270.                     <p>
  271.                         <label for="<?php echo $this->get_field_id('order'); ?>">
  272.                             <?php esc_html_e('Order', 'smart-recent-posts-widget'); ?>
  273.                         </label>
  274.                         <select class="widefat" id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>" style="width:100%;">
  275.                             <option value="DESC" <?php selected($instance['order'], 'DESC'); ?>><?php esc_html_e('Descending', 'srpw') ?></option>
  276.                             <option value="ASC" <?php selected($instance['order'], 'ASC'); ?>><?php esc_html_e('Ascending', 'srpw') ?></option>
  277.                         </select>
  278.                     </p>
  279.  
  280.                     <p>
  281.                         <label for="<?php echo $this->get_field_id('orderby'); ?>">
  282.                             <?php esc_html_e('Orderby', 'smart-recent-posts-widget'); ?>
  283.                         </label>
  284.                         <select class="widefat" id="<?php echo $this->get_field_id('orderby'); ?>" name="<?php echo $this->get_field_name('orderby'); ?>" style="width:100%;">
  285.                             <option value="ID" <?php selected($instance['orderby'], 'ID'); ?>><?php esc_html_e('ID', 'srpw') ?></option>
  286.                             <option value="author" <?php selected($instance['orderby'], 'author'); ?>><?php esc_html_e('Author', 'srpw') ?></option>
  287.                             <option value="title" <?php selected($instance['orderby'], 'title'); ?>><?php esc_html_e('Title', 'srpw') ?></option>
  288.                             <option value="date" <?php selected($instance['orderby'], 'date'); ?>><?php esc_html_e('Date', 'srpw') ?></option>
  289.                             <option value="modified" <?php selected($instance['orderby'], 'modified'); ?>><?php esc_html_e('Modified', 'srpw') ?></option>
  290.                             <option value="rand" <?php selected($instance['orderby'], 'rand'); ?>><?php esc_html_e('Random', 'srpw') ?></option>
  291.                             <option value="comment_count" <?php selected($instance['orderby'], 'comment_count'); ?>><?php esc_html_e('Comment Count', 'srpw') ?></option>
  292.                             <option value="menu_order" <?php selected($instance['orderby'], 'menu_order'); ?>><?php esc_html_e('Menu Order', 'srpw') ?></option>
  293.                         </select>
  294.                     </p>
  295.  
  296.                 </div>
  297.  
  298.                 <div class="srpw-options__option">
  299.  
  300.                     <div class="horizontal-tabs">
  301.  
  302.                         <div id="include" class="tax-tab-content">
  303.  
  304.                             <div class="srpw-multiple-check-form">
  305.                                 <label>
  306.                                     <?php esc_html_e('Limit to categories', 'smart-recent-posts-widget'); ?>
  307.                                 </label>
  308.                                 <?php foreach (srpw_taxonomy_list('category') as $category) : ?>
  309.                                     <p>
  310.                                         <input type="checkbox" value="<?php echo (int) $category->term_id; ?>" id="<?php echo $this->get_field_id('cat') . '-' . (int) $category->term_id; ?>" name="<?php echo $this->get_field_name('cat'); ?>[]" <?php checked(is_array($instance['cat']) && in_array($category->term_id, $instance['cat'])); ?> />
  311.                                         <label for="<?php echo $this->get_field_id('cat') . '-' . (int) $category->term_id; ?>">
  312.                                             <?php echo esc_html($category->name); ?>
  313.                                         </label>
  314.                                     </p>
  315.                                 <?php endforeach; ?>
  316.                             </div>
  317.  
  318.                             <div class="srpw-multiple-check-form">
  319.                                 <label>
  320.                                     <?php esc_html_e('Limit to tags', 'smart-recent-posts-widget'); ?>
  321.                                 </label>
  322.                                 <?php foreach (srpw_taxonomy_list() as $post_tag) : ?>
  323.                                     <p>
  324.                                         <input type="checkbox" value="<?php echo (int) $post_tag->term_id; ?>" id="<?php echo $this->get_field_id('tag') . '-' . (int) $post_tag->term_id; ?>" name="<?php echo $this->get_field_name('tag'); ?>[]" <?php checked(is_array($instance['tag']) && in_array($post_tag->term_id, $instance['tag'])); ?> />
  325.                                         <label for="<?php echo $this->get_field_id('tag') . '-' . (int) $post_tag->term_id; ?>">
  326.                                             <?php echo esc_html($post_tag->name); ?>
  327.                                         </label>
  328.                                     </p>
  329.                                 <?php endforeach; ?>
  330.                             </div>
  331.  
  332.                         </div><!-- #include -->
  333.  
  334.                         <div id="exclude" class="tax-tab-content">
  335.  
  336.                             <div class="srpw-multiple-check-form">
  337.                                 <label>
  338.                                     <?php esc_html_e('Exclude categories', 'smart-recent-posts-widget'); ?>
  339.                                 </label>
  340.                                 <?php foreach (srpw_taxonomy_list('category') as $category) : ?>
  341.                                     <p>
  342.                                         <input type="checkbox" value="<?php echo (int) $category->term_id; ?>" id="<?php echo $this->get_field_id('cat_exclude') . '-' . (int) $category->term_id; ?>" name="<?php echo $this->get_field_name('cat_exclude'); ?>[]" <?php checked(is_array($instance['cat_exclude']) && in_array($category->term_id, $instance['cat_exclude'])); ?> />
  343.                                         <label for="<?php echo $this->get_field_id('cat_exclude') . '-' . (int) $category->term_id; ?>">
  344.                                             <?php echo esc_html($category->name); ?>
  345.                                         </label>
  346.                                     </p>
  347.                                 <?php endforeach; ?>
  348.                             </div>
  349.  
  350.                             <div class="srpw-multiple-check-form">
  351.                                 <label>
  352.                                     <?php esc_html_e('Exclude tags', 'smart-recent-posts-widget'); ?>
  353.                                 </label>
  354.                                 <?php foreach (srpw_taxonomy_list() as $post_tag) : ?>
  355.                                     <p>
  356.                                         <input type="checkbox" value="<?php echo (int) $post_tag->term_id; ?>" id="<?php echo $this->get_field_id('tag_exclude') . '-' . (int) $post_tag->term_id; ?>" name="<?php echo $this->get_field_name('tag_exclude'); ?>[]" <?php checked(is_array($instance['tag_exclude']) && in_array($post_tag->term_id, $instance['tag_exclude'])); ?> />
  357.                                         <label for="<?php echo $this->get_field_id('tag_exclude') . '-' . (int) $post_tag->term_id; ?>">
  358.                                             <?php echo esc_html($post_tag->name); ?>
  359.                                         </label>
  360.                                     </p>
  361.                                 <?php endforeach; ?>
  362.                             </div>
  363.  
  364.                         </div><!-- #exclude -->
  365.  
  366.                     </div>
  367.  
  368.                 </div>
  369.  
  370.                 <div class="srpw-options__option">
  371.  
  372.                     <?php if (current_theme_supports('post-thumbnails')) { ?>
  373.  
  374.                         <p>
  375.                             <input id="<?php echo $this->get_field_id('thumbnail'); ?>" name="<?php echo $this->get_field_name('thumbnail'); ?>" type="checkbox" <?php checked($instance['thumbnail']); ?> />
  376.                             <label for="<?php echo $this->get_field_id('thumbnail'); ?>">
  377.                                 <?php esc_html_e('Display Thumbnail', 'smart-recent-posts-widget'); ?>
  378.                             </label>
  379.                         </p>
  380.  
  381.                         <p>
  382.                             <label for="<?php echo $this->get_field_id('thumbnail_size'); ?>">
  383.                                 <?php esc_html_e('Thumbnail Size ', 'smart-recent-posts-widget'); ?>
  384.                             </label>
  385.                             <select class="widefat" id="<?php echo $this->get_field_id('thumbnail_size'); ?>" name="<?php echo $this->get_field_name('thumbnail_size'); ?>" style="width:100%;">
  386.                                 <?php foreach (get_intermediate_image_sizes() as $size) { ?>
  387.                                     <option value="<?php echo esc_attr($size); ?>" <?php selected($instance['thumbnail_size'], $size); ?>><?php echo esc_html($size); ?></option>
  388.                                 <?php }    ?>
  389.                             </select>
  390.                         </p>
  391.  
  392.                         <p>
  393.                             <label class="srpw-block" for="<?php echo $this->get_field_id('thumbnail_align'); ?>">
  394.                                 <?php esc_html_e('Thumbnail Alignment', 'smart-recent-posts-widget'); ?>
  395.                             </label>
  396.                             <select class="widefat" id="<?php echo $this->get_field_id('thumbnail_align'); ?>" name="<?php echo $this->get_field_name('thumbnail_align'); ?>">
  397.                                 <option value="srpw-alignleft" <?php selected($instance['thumbnail_align'], 'srpw-alignleft'); ?>><?php esc_html_e('Left', 'smart-recent-posts-widget') ?></option>
  398.                                 <option value="srpw-alignright" <?php selected($instance['thumbnail_align'], 'srpw-alignright'); ?>><?php esc_html_e('Right', 'smart-recent-posts-widget') ?></option>
  399.                                 <option value="srpw-aligncenter" <?php selected($instance['thumbnail_align'], 'srpw-aligncenter'); ?>><?php esc_html_e('Center', 'smart-recent-posts-widget') ?></option>
  400.                             </select>
  401.                         </p>
  402.  
  403.                                             <p>
  404.                         <label for="<?php echo esc_attr( $this->get_field_id('thumbnail_default') ); ?>">
  405.                             <?php esc_html_e('Default Thumbnail', 'smart-recent-posts-widget'); ?>
  406.                         </label>
  407.                         <input
  408.                             class="widefat"
  409.                             id="<?php echo esc_attr( $this->get_field_id('thumbnail_default') ); ?>"
  410.                             name="<?php echo esc_attr( $this->get_field_name('thumbnail_default') ); ?>"
  411.                             type="text"
  412.                             value="<?php echo esc_attr( $instance['thumbnail_default'] ); ?>"
  413.                         />
  414.                         <small><?php esc_html_e('Leave it blank to disable.', 'smart-recent-posts-widget'); ?></small>
  415.                     </p>
  416.  
  417.                     <?php } ?>
  418.  
  419.                 </div>
  420.  
  421.                 <div class="srpw-options__option">
  422.  
  423.                     <p>
  424.                         <input id="<?php echo $this->get_field_id('excerpt'); ?>" name="<?php echo $this->get_field_name('excerpt'); ?>" type="checkbox" <?php checked($instance['excerpt']); ?> />
  425.                         <label for="<?php echo $this->get_field_id('excerpt'); ?>">
  426.                             <?php esc_html_e('Display Excerpt', 'smart-recent-posts-widget'); ?>
  427.                         </label>
  428.                     </p>
  429.  
  430.                     <p>
  431.                         <label for="<?php echo $this->get_field_id('length'); ?>">
  432.                             <?php esc_html_e('Excerpt Length', 'smart-recent-posts-widget'); ?>
  433.                         </label>
  434.                         <input class="widefat" id="<?php echo $this->get_field_id('length'); ?>" name="<?php echo $this->get_field_name('length'); ?>" type="number" step="1" min="0" value="<?php echo (int)($instance['length']); ?>" />
  435.                     </p>
  436.  
  437.                     <p>
  438.                         <input id="<?php echo $this->get_field_id('readmore'); ?>" name="<?php echo $this->get_field_name('readmore'); ?>" type="checkbox" <?php checked($instance['readmore']); ?> />
  439.                         <label for="<?php echo $this->get_field_id('readmore'); ?>">
  440.                             <?php esc_html_e('Display Readmore', 'smart-recent-posts-widget'); ?>
  441.                         </label>
  442.                     </p>
  443.  
  444.                     <p>
  445.                         <label for="<?php echo $this->get_field_id('readmore_text'); ?>">
  446.                             <?php esc_html_e('Readmore Text', 'smart-recent-posts-widget'); ?>
  447.                         </label>
  448.                         <input class="widefat" id="<?php echo $this->get_field_id('readmore_text'); ?>" name="<?php echo $this->get_field_name('readmore_text'); ?>" type="text" value="<?php echo strip_tags($instance['readmore_text']); ?>" />
  449.                     </p>
  450.  
  451.                 </div>
  452.  
  453.                 <div class="srpw-options__option">
  454.  
  455.                     <p>
  456.                         <input id="<?php echo $this->get_field_id('post_title'); ?>" name="<?php echo $this->get_field_name('post_title'); ?>" type="checkbox" <?php checked($instance['post_title']); ?> />
  457.                         <label for="<?php echo $this->get_field_id('post_title'); ?>">
  458.                             <?php esc_html_e('Display Title', 'smart-recent-posts-widget'); ?>
  459.                         </label>
  460.                     </p>
  461.  
  462.                     <p>
  463.                         <input id="<?php echo $this->get_field_id('date'); ?>" name="<?php echo $this->get_field_name('date'); ?>" type="checkbox" <?php checked($instance['date']); ?> />
  464.                         <label for="<?php echo $this->get_field_id('date'); ?>">
  465.                             <?php esc_html_e('Display Date', 'smart-recent-posts-widget'); ?>
  466.                         </label>
  467.                     </p>
  468.  
  469.                     <p>
  470.                         <input id="<?php echo $this->get_field_id('comment_count'); ?>" name="<?php echo $this->get_field_name('comment_count'); ?>" type="checkbox" <?php checked($instance['comment_count']); ?> />
  471.                         <label for="<?php echo $this->get_field_id('comment_count'); ?>">
  472.                             <?php esc_html_e('Display Comment Count', 'smart-recent-posts-widget'); ?>
  473.                         </label>
  474.                     </p>
  475.  
  476.                     <p>
  477.                         <input id="<?php echo $this->get_field_id('author'); ?>" name="<?php echo $this->get_field_name('author'); ?>" type="checkbox" <?php checked($instance['author']); ?> />
  478.                         <label for="<?php echo $this->get_field_id('author'); ?>">
  479.                             <?php esc_html_e('Display Author', 'smart-recent-posts-widget'); ?>
  480.                         </label>
  481.                     </p>
  482.  
  483.                     <p>
  484.                         <input id="<?php echo $this->get_field_id('date_modified'); ?>" name="<?php echo $this->get_field_name('date_modified'); ?>" type="checkbox" <?php checked($instance['date_modified']); ?> />
  485.                         <label for="<?php echo $this->get_field_id('date_modified'); ?>">
  486.                             <?php esc_html_e('Display Modification Date', 'smart-recent-posts-widget'); ?>
  487.                         </label>
  488.                     </p>
  489.  
  490.                     <p>
  491.                         <input id="<?php echo $this->get_field_id('date_relative'); ?>" name="<?php echo $this->get_field_name('date_relative'); ?>" type="checkbox" <?php checked($instance['date_relative']); ?> />
  492.                         <label for="<?php echo $this->get_field_id('date_relative'); ?>">
  493.                             <?php esc_html_e('Use Relative Date. eg: 5 days ago', 'smart-recent-posts-widget'); ?>
  494.                         </label>
  495.                     </p>
  496.  
  497.                 </div>
  498.  
  499.                 <div class="srpw-options__option">
  500.  
  501.                     <p>
  502.                         <label for="<?php echo $this->get_field_id('style'); ?>">
  503.                             <?php esc_html_e('Style', 'smart-recent-posts-widget'); ?>
  504.                         </label>
  505.                         <select class="widefat" id="<?php echo $this->get_field_id('style'); ?>" name="<?php echo $this->get_field_name('style'); ?>" style="width:100%;">
  506.                             <option value="default" <?php selected($instance['style'], 'default'); ?>><?php esc_html_e('Default', 'srpw') ?></option>
  507.                             <option value="classic" <?php selected($instance['style'], 'classic'); ?>><?php esc_html_e('Classic', 'srpw') ?></option>
  508.                             <option value="modern" <?php selected($instance['style'], 'modern'); ?>><?php esc_html_e('Modern', 'srpw') ?></option>
  509.                         </select>
  510.                         <small><?php printf(esc_html__('Please follow %1$sthis guidelines%2$s to get the best result.', 'smart-recent-posts-widget'), '<a href="https://wordpress.org/plugins/smart-recent-posts-widget" target="_blank">', '</a>'); ?></small>
  511.                     </p>
  512.  
  513.                     <p>
  514.                         <input id="<?php echo $this->get_field_id('new_tab'); ?>" name="<?php echo $this->get_field_name('new_tab'); ?>" type="checkbox" <?php checked($instance['new_tab']); ?> />
  515.                         <label for="<?php echo $this->get_field_id('new_tab'); ?>">
  516.                             <?php esc_html_e('Open link in new tab', 'smart-recent-posts-widget'); ?>
  517.                         </label>
  518.                     </p>
  519.  
  520.                                         <p>
  521.                         <label for="<?php echo esc_attr( $this->get_field_id('css') ); ?>">
  522.                             <?php esc_html_e('Custom CSS', 'smart-recent-posts-widget'); ?>
  523.                         </label>
  524.                         <textarea
  525.                             class="widefat"
  526.                             id="<?php echo esc_attr( $this->get_field_id('css') ); ?>"
  527.                             name="<?php echo esc_attr( $this->get_field_name('css') ); ?>"
  528.                             style="height:180px;"
  529.                         ><?php echo esc_textarea( $instance['css'] ); ?></textarea>
  530.                     </p>
  531.  
  532.                 </div>
  533.  
  534.                 <div class="srpw-options__option srpw-info">
  535.  
  536.                     <p>Thank you for using this plugin, I hope you enjoy it and don't forget to <a href="https://wordpress.org/support/plugin/smart-recent-posts-widget/reviews/" target="_blank" rel="noopener noreferrer">leave a 5 star review</a>.</p>
  537.                     <p>If you want to support me, please donate through <a href="https://paypal.me/satrya" target="_blank" rel="noopener noreferrer">this page</a>.</p>
  538.  
  539.                 </div>
  540.  
  541.             </div><!-- .srpw-options__wrapper -->
  542.  
  543.         </div><!-- .srpw-options -->
  544.  
  545. <?php
  546.     }
  547. }
  548.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement