'athemes_portfolio_widget', 'description' => __( 'Display your projects in a grid.', 'talon') ); parent::__construct(false, $name = __('Talon: Portfolio', 'talon'), $widget_ops); $this->alt_option_name = 'athemes_portfolio_widget'; } public function widget( $args, $instance ) { $title = ( ! empty( $instance['title'] ) ) ? $instance['title'] : ''; $number = ( ! empty( $instance['number'] ) ) ? intval( $instance['number'] ) : -1; if ( ! $number ) { $number = -1; } $includes = isset($instance['includes']) ? esc_html( $instance['includes'] ) : 0; $show_filter = isset( $instance['show_filter'] ) ? (bool) $instance['show_filter'] : false; $show_all_text = isset( $instance['show_all_text'] ) ? esc_html( $instance['show_all_text'] ) : ''; $options = array( 'filter' => $show_filter, 'show_all_text' => ! empty( $show_all_text ) ? $show_all_text : __('Show all', 'talon') ); $r = new WP_Query( array( 'no_found_rows' => true, 'post_status' => 'publish', 'post_type' => 'projects', 'posts_per_page' => $number, 'category_name' => $includes ) ); echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } if ($r->have_posts()) : ?>
term_id; $included_ids[] = $term_id; } } $id_string = implode( ',', $included_ids ); $terms = get_terms( 'category', array( 'include' => $id_string ) ); ?>
have_posts() ): $r->the_post(); global $post; $id = $post->ID; $termsArray = get_the_terms( $id, 'category' ); $termsString = ""; if ( $termsArray) { foreach ( $termsArray as $term ) { $termsString .= $term->slug.' '; } } if ( has_post_thumbnail() ) { $project_url = get_post_meta( get_the_ID(), 'wpcf-project-link', true ); if ( $project_url ) { $url = $project_url; } else { $url = get_the_permalink(); } ?>

' . sprintf( _x('Info: you have not created any projects. Make sure you have installed the %1$s plugin and then create some projects %2$s', 'no posts info', 'talon'), 'aThemes Toolbox', '' . __('here', 'talon') . '' ) . ''; endif; echo $args['after_widget']; } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = sanitize_text_field($new_instance['title']); $instance['number'] = intval($new_instance['number']); $instance['includes'] = sanitize_text_field($new_instance['includes']); $instance['show_filter'] = isset( $new_instance['show_filter'] ) ? (bool) $new_instance['show_filter'] : false; $instance['show_all_text'] = sanitize_text_field($new_instance['show_all_text']); return $instance; } function form($instance) { $title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? intval( $instance['number'] ) : -1; $includes = isset( $instance['includes'] ) ? esc_attr($instance['includes']) : ''; $show_filter = isset( $instance['show_filter'] ) ? (bool) $instance['show_filter'] : true; $show_all_text = isset( $instance['show_all_text'] ) ? esc_html($instance['show_all_text']) : __('Show all', 'talon'); ?>

id="get_field_id( 'show_filter' ); ?>" name="get_field_name( 'show_filter' ); ?>" />