'widget_recent_albums widget_recent_cpt', 'description' => esc_html__( 'Your most recent added albums', 'apollo13-framework-extensions' ) ); parent::__construct( 'recent-albums', esc_html__( 'Apollo13Themes', 'apollo13-framework-extensions' ) . ' - ' . esc_html__( 'Recent Albums', 'apollo13-framework-extensions' ), $widget_ops ); $this->alt_option_name = 'widget_recent_albums'; add_action( 'save_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'deleted_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'switch_theme', array( &$this, 'flush_midget_cache' ) ); } function widget( $args, $instance ) { $before_widget = $after_widget = $before_title = $after_title = ''; $cache = wp_cache_get( 'widget_recent_albums', 'widget' ); if ( ! is_array( $cache ) ) { $cache = array(); } if ( isset( $cache[ $args['widget_id'] ] ) ) { print $cache[ $args['widget_id'] ]; return; } ob_start(); extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? esc_html__( 'Recent Albums', 'apollo13-framework-extensions' ) : $instance['title'], $instance, $this->id_base ); if ( ! $number = absint( $instance['number'] ) ) { $number = 10; } $r = new WP_Query( array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_type' => defined( 'A13FRAMEWORK_CUSTOM_POST_TYPE_ALBUM' ) ? A13FRAMEWORK_CUSTOM_POST_TYPE_ALBUM : 'album', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'orderby' => 'date' ) ); if ( $r->have_posts() ) : print $before_widget; if ( $title ) { print $before_title . $title . $after_title; } echo '
'widget_recent_works widget_recent_cpt', 'description' => esc_html__( 'Your most recent added works', 'apollo13-framework-extensions' ) ); parent::__construct( 'recent-works', esc_html__( 'Apollo13Themes', 'apollo13-framework-extensions' ) . ' - ' . esc_html__( 'Recent Works', 'apollo13-framework-extensions' ), $widget_ops ); $this->alt_option_name = 'widget_recent_works'; add_action( 'save_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'deleted_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'switch_theme', array( &$this, 'flush_midget_cache' ) ); } function widget( $args, $instance ) { $before_widget = $after_widget = $before_title = $after_title = ''; $cache = wp_cache_get( 'widget_recent_works', 'widget' ); if ( ! is_array( $cache ) ) { $cache = array(); } if ( isset( $cache[ $args['widget_id'] ] ) ) { print $cache[ $args['widget_id'] ]; return; } ob_start(); extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? esc_html__( 'Recent Works', 'apollo13-framework-extensions' ) : $instance['title'], $instance, $this->id_base ); if ( ! $number = absint( $instance['number'] ) ) { $number = 10; } $r = new WP_Query( array( 'posts_per_page' => $number, 'no_found_rows' => true, 'post_type' => defined( 'A13FRAMEWORK_CUSTOM_POST_TYPE_WORK' ) ? A13FRAMEWORK_CUSTOM_POST_TYPE_WORK : 'work', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'orderby' => 'date' ) ); if ( $r->have_posts() ) : print $before_widget; if ( $title ) { print $before_title . $title . $after_title; } echo '
'widget_filter', 'description' => esc_html__( 'Filter Albums, Works or Posts by categories.', 'apollo13-framework-extensions' ) ); parent::__construct( 'filter', esc_html__( 'Apollo13Themes', 'apollo13-framework-extensions' ) . ' - ' . esc_html__( 'Filter', 'apollo13-framework-extensions' ), $widget_ops ); $this->alt_option_name = 'widget_contact_info'; add_action( 'save_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'deleted_post', array( &$this, 'flush_midget_cache' ) ); add_action( 'switch_theme', array( &$this, 'flush_midget_cache' ) ); } function widget( $args, $instance ) { $before_widget = $after_widget = $before_title = $after_title = ''; $cache = wp_cache_get( 'widget_contact_info', 'widget' ); if ( ! is_array( $cache ) ) { $cache = array(); } if ( isset( $cache[ $args['widget_id'] ] ) ) { print $cache[ $args['widget_id'] ]; return; } ob_start(); extract( $args ); $page_type = apollo13framework_what_page_type_is_it(); //get field $filter = $instance['filter']; $albums_list = $filter === 'albums' && $page_type['albums_list']; $works_list = $filter === 'works' && $page_type['works_list']; $posts_list = $filter === 'blog' && $page_type['blog_type']; if($page_type['search']){ //we don't display filter on search reasult page return; } //filter will be usable here? if ( $albums_list || $works_list || $posts_list ) { $terms = array(); //albums if ( $albums_list ) { $category_template = defined( 'A13FRAMEWORK_ALBUM_GENRE_TEMPLATE' ); //prepare filter $query_args = array( 'taxonomy' => A13FRAMEWORK_CPT_ALBUM_TAXONOMY, 'hide_empty' => true, 'parent' => 0, ); if ( $category_template === true ) { $term_slug = get_query_var( 'term' ); if ( ! empty( $term_slug ) ) { $term_obj = get_term_by( 'slug', $term_slug, A13FRAMEWORK_CPT_ALBUM_TAXONOMY ); $term_id = $term_obj->term_id; $query_args['parent'] = $term_id; } } $terms = get_terms( $query_args ); } //works if ( $works_list ) { $category_template = defined( 'A13FRAMEWORK_WORK_GENRE_TEMPLATE' ); //prepare filter $query_args = array( 'taxonomy' => A13FRAMEWORK_CPT_WORK_TAXONOMY, 'hide_empty' => true, 'parent' => 0, ); if ( $category_template === true ) { $term_slug = get_query_var( 'term' ); if ( ! empty( $term_slug ) ) { $term_obj = get_term_by( 'slug', $term_slug, A13FRAMEWORK_CPT_WORK_TAXONOMY ); $term_id = $term_obj->term_id; $query_args['parent'] = $term_id; } } $terms = get_terms( $query_args ); } //blog elseif ( $posts_list ) { $category_template = is_category(); $query_args = array( 'hide_empty' => true, 'parent' => 0, ); if ( $category_template === true ) { $term_id = get_query_var( 'cat' ); if ( ! empty( $term_id ) ) { $query_args['parent'] = $term_id; } } $terms = get_categories( $query_args ); } if ( count( $terms ) ): $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? esc_html__( 'Filter', 'apollo13-framework-extensions' ) : $instance['title'], $instance, $this->id_base ); print $before_widget; if ( $title ) { print $before_title . $title . $after_title; } echo '
:
$name ) { echo ''; } ?>