'rocksite-last-articles-widget', 'description' => __( "The most recent posts on your site (extended contorls)", 'canvi' ) ); parent::__construct( 'rocksite-recent-posts', __( 'canvi Extended Recent Posts', 'canvi' ), $widget_ops ); $this->alt_option_name = 'widget_recent_entries_Smartlib'; add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); } function widget( $args, $instance ) { $cache = wp_cache_get( 'rocksite-recent-posts', 'widget' ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Posts', 'canvi' ) : $instance['title'], $instance, $this->id_base ); if ( empty( $instance['number'] ) || ! $number = absint( $instance['number'] ) ) { $number = 10; } $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : FALSE; $show_post_thumbnail = isset( $instance['show_post_thumbnail'] ) ? $instance['show_post_thumbnail'] : FALSE; $show_post_author = isset( $instance['show_post_author'] ) ? $instance['show_post_author'] : FALSE; $r = new WP_Query( apply_filters( 'widget_posts_args', array( 'posts_per_page' => $number, 'no_found_rows' => TRUE, 'post_status' => 'publish', 'ignore_sticky_posts' => TRUE ) ) ); ?>
flush_widget_cache(); $alloptions = wp_cache_get( 'alloptions', 'options' ); if ( isset( $alloptions['widget_recent_entries'] ) ) { delete_option( 'widget_recent_entries' ); } return $instance; } function flush_widget_cache() { wp_cache_delete( 'widget_recent_posts', 'widget' ); } function form( $instance ) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : FALSE; $show_post_thumbnail = isset( $instance['show_post_thumbnail'] ) ? (bool) $instance['show_post_thumbnail'] : TRUE; $show_post_author = isset( $instance['show_post_author'] ) ? (bool) $instance['show_post_author'] : TRUE; ?>
id="get_field_id( 'show_date' ); ?>" name="get_field_name( 'show_date' ); ?>"/>
id="get_field_id( 'show_post_thumbnail' ); ?>" name="get_field_name( 'show_post_thumbnail', 'canvi' ); ?>"/>
id="get_field_id( 'show_post_author' ); ?>" name="get_field_name( 'show_post_author' ); ?>"/>