File manager - Edit - /home/verseaumee/TF89388/wp-content/plugins/noisa-toolkit/includes/widgets/class-widget-recent-posts.php
Back
<?php /** * Rascals Recent Posts Widget * * Displays recent posts with images * * @author Rascals Themes * @category Widgets * @package NoisaToolkit/Widgets * @version 1.0.0 * @extends WP_Widget */ class RascalsRecentPostsWidget extends WP_Widget { /** * Constructor */ function __construct() { /* Widget settings */ $widget_ops = array( 'classname' => 'widget_noisa_recent_posts', 'description' => esc_html__( 'Display recent posts containing featured image.', 'noisa-toolkit' ) ); /* Create the widget */ parent::__construct( 'r-recent-posts-widget', esc_html__( 'Recent Posts (RT)', 'noisa-toolkit' ), $widget_ops ); } /** * Widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget( $args, $instance ) { extract( $args ); global $wp_query, $post; extract( $args ); $title = ( isset( $instance['title'] ) ) ? sanitize_text_field( $instance['title'] ) : ''; $title = apply_filters( 'widget_title', $title ); $limit = ( isset( $instance['limit'] ) ) ? absint( $instance['limit'] ) : 5; $classes = ( isset( $instance['classes'] ) ) ? sanitize_text_field( $instance['classes'] ) : ''; // Date format $date_format = get_option( 'date_format' ); echo wp_kses_post( $args['before_widget'] ); // Title if ( ! empty( $title ) ) { echo wp_kses_post( $before_title ) . esc_attr( $title) . wp_kses_post( $after_title ); } // Post backup if ( isset( $post ) ) { $backup = $post; } // Loop Args. $loop_args = array( 'showposts' => (int)$limit ); // Number words to show $words_number = 10; $recent_posts_widget = new WP_Query(); $recent_posts_widget->query( $loop_args ); // Begin Loop if ( $recent_posts_widget->have_posts() ) { echo '<ul class="rp-list ' . esc_attr( $classes ) . '">'; while ( $recent_posts_widget->have_posts() ) { $recent_posts_widget->the_post(); if ( has_post_thumbnail() ) { echo '<li>'; echo '<div class="rp-post-thumb">'; echo get_the_post_thumbnail( $post->ID, 'thumbnail' ); echo '</div>'; echo '<div class="rp-caption">'; echo '<h4><a href="' . get_permalink() . '" title="' . esc_attr( get_the_title() ) . '">' . get_the_title() . '</a></h4>'; echo '<span class="rp-date">' . get_the_time( $date_format ) . '</span>'; echo '</div>'; echo '</li>'; } } echo '</ul>'; } if ( isset( $post ) ) { $post = $backup; } echo wp_kses_post( $after_widget ); } /** * Update function. * * @see WP_Widget->update * @access public * @param array $new_instance * @param array $old_instance * @return array */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = sanitize_text_field( $new_instance['title'] ); $instance['limit'] = absint( $new_instance['limit'] ); $instance['classes'] = sanitize_text_field( $new_instance['classes'] ); return $instance; } /** * Form function. * * @see WP_Widget->form * @access public * @param array $instance * @return void */ function form( $instance ) { global $wpdb; $defaults = array( 'title' => esc_html__( 'Recent Posts', 'noisa-toolkit' ), 'limit' => '6', 'excerpt' => '', 'classes' => '' ); $instance = wp_parse_args( (array ) $instance, $defaults ); // Get acces to RascalsWidgets Class -> Fields $RW = new RascalsWidgets(); // Tabs $RW->tabsStart( array( esc_html__( 'General', 'noisa-toolkit' ), esc_html__( 'Advanced', 'noisa-toolkit' ) ) ); // ----------------------- Tab 01 $RW->tabStart(1); // Title $RW->input_e( array( 'label' => esc_html__( 'Title:', 'noisa-toolkit' ), 'value' => $instance['title'], 'id' => $this->get_field_id( 'title' ), 'name' => $this->get_field_name( 'title' ), 'desc' => '' )); // Limit $RW->number_e( array( 'label' => esc_html__( 'Limit', 'noisa-toolkit' ), 'value' => $instance['limit'], 'id' => $this->get_field_id( 'limit' ), 'min' => '1', 'max' => '100', 'units' => esc_html__( 'posts', 'noisa-toolkit' ), 'name' => $this->get_field_name( 'limit' ), 'desc' => esc_html__( 'Number of thumbnails to show. Limit of 10 thumbnails.', 'noisa-toolkit' ) )); $RW->tabEnd(); // ----------------------- Tab 02 $RW->tabStart(2); // Classes $RW->input_e( array( 'label' => esc_html__( 'Classes', 'noisa-toolkit' ), 'value' => $instance['classes'], 'id' => $this->get_field_id( 'classes' ), 'name' => $this->get_field_name( 'classes' ), 'desc' => esc_html__( 'Style particular content element differently - add a class name and refer to it in custom CSS', 'noisa-toolkit' ) )); $RW->tabEnd(); $RW->tabsEnd(); } }
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings