__('A widget that shows quick contact information', 'buzzstore') )); } private function widget_fields() { $fields = array( 'buzzstore_quick_contact_title' => array( 'buzzstore_widgets_name' => 'buzzstore_quick_contact_title', 'buzzstore_widgets_title' => __('Title', 'buzzstore'), 'buzzstore_widgets_field_type' => 'title', ), 'buzzstore_quick_address' => array( 'buzzstore_widgets_name' => 'buzzstore_quick_address', 'buzzstore_widgets_title' => __('Contact Address', 'buzzstore'), 'buzzstore_widgets_field_type' => 'textarea', ), 'buzzstore_quick_phone' => array( 'buzzstore_widgets_name' => 'buzzstore_quick_phone', 'buzzstore_widgets_title' => __('Contact Number', 'buzzstore'), 'buzzstore_widgets_field_type' => 'text', ), 'buzzstore_quick_email' => array( 'buzzstore_widgets_name' => 'buzzstore_quick_email', 'buzzstore_widgets_title' => __('Contact Email Address', 'buzzstore'), 'buzzstore_widgets_field_type' => 'text', ), 'buzzstore_opening_time' => array( 'buzzstore_widgets_name' => 'buzzstore_opening_time', 'buzzstore_widgets_title' => __('Store Opening Time', 'buzzstore'), 'buzzstore_widgets_field_type' => 'textarea', ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); $title = $instance['buzzstore_quick_contact_title']; $contact_address = $instance['buzzstore_quick_address']; $contact_number = $instance['buzzstore_quick_phone']; $contact_email = $instance['buzzstore_quick_email']; $opening_time = $instance['buzzstore_opening_time']; echo $before_widget; if(!empty($title)) { echo ''; } ?> widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? esc_attr($instance[$buzzstore_widgets_name]) : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } } /** ** Adds buzzstore_aboutus_info widget. **/ add_action('widgets_init', 'buzzstore_aboutus_info'); function buzzstore_aboutus_info() { register_widget('buzzstore_aboutus_info_area'); } class buzzstore_aboutus_info_area extends WP_Widget { /** * Register widget with WordPress. **/ public function __construct() { parent::__construct( 'buzzstore_aboutus_info_area', 'Buzz: About Us Information', array( 'description' => __('A widget that shows About Us information', 'buzzstore') )); } private function widget_fields() { $fields = array( 'buzzstore_about_logo' => array( 'buzzstore_widgets_name' => 'buzzstore_about_logo', 'buzzstore_widgets_title' => __('Upload Logo Image', 'buzzstore'), 'buzzstore_widgets_field_type' => 'upload', ), 'buzzstore_about_short_desc' => array( 'buzzstore_widgets_name' => 'buzzstore_about_short_desc', 'buzzstore_widgets_title' => __('Short Description', 'buzzstore'), 'buzzstore_widgets_field_type' => 'textarea', 'buzzstore_widgets_row' => '3' ), 'buzzstore_facebook_url' => array( 'buzzstore_widgets_name' => 'buzzstore_facebook_url', 'buzzstore_widgets_title' => __('Facebook Url', 'buzzstore'), 'buzzstore_widgets_field_type' => 'url', ), 'buzzstore_twitter_url' => array( 'buzzstore_widgets_name' => 'buzzstore_twitter_url', 'buzzstore_widgets_title' => __('Twitter Url', 'buzzstore'), 'buzzstore_widgets_field_type' => 'url', ), 'buzzstore_googleplus_url' => array( 'buzzstore_widgets_name' => 'buzzstore_googleplus_url', 'buzzstore_widgets_title' => __('Google Plus Url', 'buzzstore'), 'buzzstore_widgets_field_type' => 'url', ), 'buzzstore_youtube_url' => array( 'buzzstore_widgets_name' => 'buzzstore_youtube_url', 'buzzstore_widgets_title' => __('Youtube Url', 'buzzstore'), 'buzzstore_widgets_field_type' => 'url', ), 'buzzstore_instagram_url' => array( 'buzzstore_widgets_name' => 'buzzstore_instagram_url', 'buzzstore_widgets_title' => __('Instagram Url', 'buzzstore'), 'buzzstore_widgets_field_type' => 'url', ), 'buzzstore_pinterest_url' => array( 'buzzstore_widgets_name' => 'buzzstore_pinterest_url', 'buzzstore_widgets_title' => __('Pinterest Url', 'buzzstore'), 'buzzstore_widgets_field_type' => 'url', ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); $logo = $instance['buzzstore_about_logo']; $shor_desc = $instance['buzzstore_about_short_desc']; $facebook = $instance['buzzstore_facebook_url']; $twitter = $instance['buzzstore_twitter_url']; $googleplus = $instance['buzzstore_googleplus_url']; $youtube = $instance['buzzstore_youtube_url']; $instagram = $instance['buzzstore_instagram_url']; $pinterest = $instance['buzzstore_pinterest_url']; echo $before_widget; ?> widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? esc_attr($instance[$buzzstore_widgets_name]) : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } } /** ** Adds buzzstore_blog_widget widget. **/ add_action('widgets_init', 'buzzstore_blog_widget'); function buzzstore_blog_widget() { register_widget('buzzstore_blog_widget_area'); } class buzzstore_blog_widget_area extends WP_Widget { /** * Register widget with WordPress. **/ public function __construct() { parent::__construct( 'buzzstore_blog_widget_area', 'Buzz: Blogs Widget', array( 'description' => __('A widget that latest three posts', 'buzzstore') )); } private function widget_fields() { $args = array( 'type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'taxonomy' => 'category', ); $categories = get_categories( $args ); $cat_lists = array(); foreach( $categories as $category ) { $cat_lists[$category->term_id] = $category->name; } $fields = array( 'buzzstore_blogs_title' => array( 'buzzstore_widgets_name' => 'buzzstore_blogs_title', 'buzzstore_widgets_title' => __('Blogs Title', 'buzzstore'), 'buzzstore_widgets_field_type' => 'title', ), 'blogs_category_list' => array( 'buzzstore_widgets_name' => 'blogs_category_list', 'buzzstore_mulicheckbox_title' => __('Select Blogs Category', 'buzzstore'), 'buzzstore_widgets_field_type' => 'multicheckboxes', 'buzzstore_widgets_field_options' => $cat_lists ), 'blogs_posts_display_order' => array( 'buzzstore_widgets_name' => 'blogs_posts_display_order', 'buzzstore_widgets_title' => __('Display Posts Order', 'buzzstore'), 'buzzstore_widgets_field_type' => 'select', 'buzzstore_widgets_field_options' => array( 'ASC' => 'Accessing Order', 'DESC' => 'Deaccessing Order' ) ) ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** ** wp query for first block **/ $blog_post_title = $instance['buzzstore_blogs_title']; $blogs_category_list = $instance['blogs_category_list']; $blogs_posts_display_order = $instance['blogs_posts_display_order']; $blogs_cat_id = array(); if(!empty($blogs_category_list)){ $blogs_cat_id = array_keys($blogs_category_list); } $blogs_posts = new WP_Query( array( 'posts_per_page' => 3, 'post_type' => 'post', 'cat' => $blogs_cat_id, 'order' => $blogs_posts_display_order )); echo $before_widget; ?>

have_posts() ) : while( $blogs_posts->have_posts() ) : $blogs_posts->the_post(); ?>
widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? $instance[$buzzstore_widgets_name] : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } } /** ** Adds buzzstore_testimonial_widget widget. **/ add_action('widgets_init', 'buzzstore_testimonial_widget'); function buzzstore_testimonial_widget() { register_widget('buzzstore_testimonial_widget_area'); } class buzzstore_testimonial_widget_area extends WP_Widget { /** * Register widget with WordPress. **/ public function __construct() { parent::__construct( 'buzzstore_testimonial_widget_area', 'Buzz: Testimonial Widget Section', array( 'description' => __('A widget that shows client testimonial posts', 'buzzstore') )); } private function widget_fields() { $args = array( 'type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'taxonomy' => 'category', ); $categories = get_categories( $args ); $cat_lists = array(); foreach( $categories as $category ) { $cat_lists[$category->term_id] = $category->name; } $fields = array( 'buzzstore_testimonial_top_title' => array( 'buzzstore_widgets_name' => 'buzzstore_testimonial_top_title', 'buzzstore_widgets_title' => __('Testimonial Top Title', 'buzzstore'), 'buzzstore_widgets_field_type' => 'title', ), 'testimonial_category_list' => array( 'buzzstore_widgets_name' => 'testimonial_category_list', 'buzzstore_mulicheckbox_title' => __('Select Blogs Category', 'buzzstore'), 'buzzstore_widgets_field_type' => 'multicheckboxes', 'buzzstore_widgets_field_options' => $cat_lists ) ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** ** wp query for first block **/ $testimonial_top_title = $instance['buzzstore_testimonial_top_title']; $testimonial_category_list = $instance['testimonial_category_list']; $testimonial_cat_id = array(); if(!empty($testimonial_category_list)){ $blogs_cat_id = array_keys($testimonial_category_list); } $testimonial_posts = new WP_Query( array( 'posts_per_page' => 5, 'post_type' => 'post', 'cat' => $testimonial_cat_id, )); echo $before_widget; ?>

    have_posts() ) : while( $testimonial_posts->have_posts() ) : $testimonial_posts->the_post(); ?>
widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? $instance[$buzzstore_widgets_name] : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } } if (is_woocommerce_activated()) { /** ** Adds buzzstore_category_product_widget widget. **/ add_action('widgets_init', 'buzzstore_category_product_widget'); function buzzstore_category_product_widget() { register_widget('buzzstore_category_product_widget_area'); } class buzzstore_category_product_widget_area extends WP_Widget { /** * Register widget with WordPress. **/ public function __construct() { parent::__construct( 'buzzstore_category_product_widget_area', 'Buzz: Woo Category Product Area', array( 'description' => __('A widget that shows woocommerce related category products.', 'buzzstore') )); } private function widget_fields() { $taxonomy = 'product_cat'; $empty = 1; $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 for no $title = ''; $empty = 0; $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty ); $woocommerce_categories = array(); $woocommerce_categories_obj = get_categories($args); foreach ($woocommerce_categories_obj as $category) { $woocommerce_categories[$category->term_id] = $category->name; } $fields = array( 'buzzstore_product_title' => array( 'buzzstore_widgets_name' => 'buzzstore_product_title', 'buzzstore_widgets_title' => __('Title', 'buzzstore'), 'buzzstore_widgets_field_type' => 'title', ), 'buzzstore_product_short_desc' => array( 'buzzstore_widgets_name' => 'buzzstore_product_short_desc', 'buzzstore_widgets_title' => __('Very Short Description', 'buzzstore'), 'buzzstore_widgets_field_type' => 'textarea', 'buzzstore_widgets_row' => '3' ), 'buzzstore_category_product_type' => array( 'buzzstore_widgets_name' => 'buzzstore_category_product_type', 'buzzstore_mulicheckbox_title' => __('Select Products Categorys', 'buzzstore'), 'buzzstore_widgets_field_type' => 'multicheckboxes', 'buzzstore_widgets_field_options' => $woocommerce_categories ), 'buzzstore_product_number' => array( 'buzzstore_widgets_name' => 'buzzstore_product_number', 'buzzstore_widgets_title' => __('Enter Number of Products Show', 'buzzstore'), 'buzzstore_widgets_field_type' => 'number', ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** ** wp query for first block **/ $title = esc_attr( $instance['buzzstore_product_title'] ); $shot_desc = esc_textarea( $instance['buzzstore_product_short_desc'] ); $categories = $instance['buzzstore_category_product_type']; $product_number = intval( $instance['buzzstore_product_number'] ); $product_args = ''; global $product_label_custom; echo $before_widget; ?>

"; if (!empty($categories)) { echo '
  • ' . __('All Products', 'buzzstore') . '
  • '; } foreach ($categories as $key => $category) { $term = get_term_by( 'id', $key, 'product_cat'); echo '
  • slug ) . '>' . esc_attr( $term->name ) . '
  • '; } echo ""; } ?>
    $term_list) { $term = get_term_by( 'id', $term_key, 'product_cat'); $term_id = $term->term_id; $product_args = array( 'post_type' => 'product', 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $term_id )), 'posts_per_page' => $product_number ); $query = new WP_Query($product_args); if($query->have_posts()) { while($query->have_posts()) { $query->the_post(); $buzzterms = wp_get_post_terms(get_the_ID(),'product_cat', array("fields" => "all")); $term_slugs = array(); foreach ($buzzterms as $buzzterm) { $term_slugs[] = $buzzterm->slug; } $term_slugs = join(' ', $term_slugs); ?>
    widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? $instance[$buzzstore_widgets_name] : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } } /** ** Adds buzzstore_product_widget widget. **/ add_action('widgets_init', 'buzzstore_product_widget'); function buzzstore_product_widget() { register_widget('buzzstore_product_widget_area'); } class buzzstore_product_widget_area extends WP_Widget { /** * Register widget with WordPress. **/ public function __construct() { parent::__construct( 'buzzstore_product_widget_area', 'Buzz: Woo Product Area', array( 'description' => __('A widget that shows woocommerce all type product (Latest, Feature, On Sale, Up Sale) and selected category products', 'buzzstore') )); } private function widget_fields() { $prod_type = array( 'category' => __('Category', 'buzzstore'), 'latest_product' => __('Latest Product', 'buzzstore'), 'upsell_product' => __('UpSell Product', 'buzzstore'), 'feature_product' => __('Feature Product', 'buzzstore'), 'on_sale' => __('On Sale Product', 'buzzstore'), ); $taxonomy = 'product_cat'; $empty = 1; $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 for no $title = ''; $empty = 0; $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty ); $woocommerce_categories = array(); $woocommerce_categories_obj = get_categories($args); $woocommerce_categories[''] = 'Select Product Category'; foreach ($woocommerce_categories_obj as $category) { $woocommerce_categories[$category->term_id] = $category->name; } $fields = array( 'buzzstore_product_title' => array( 'buzzstore_widgets_name' => 'buzzstore_product_title', 'buzzstore_widgets_title' => __('Title', 'buzzstore'), 'buzzstore_widgets_field_type' => 'title', ), 'buzzstore_product_short_desc' => array( 'buzzstore_widgets_name' => 'buzzstore_product_short_desc', 'buzzstore_widgets_title' => __('Very Short Description', 'buzzstore'), 'buzzstore_widgets_field_type' => 'textarea', 'buzzstore_widgets_row' => '3' ), 'buzzstore_product_type' => array( 'buzzstore_widgets_name' => 'buzzstore_product_type', 'buzzstore_widgets_title' => __('Select Product Type', 'buzzstore'), 'buzzstore_widgets_field_type' => 'select', 'buzzstore_widgets_field_options' => $prod_type ), 'buzzstore_woo_category' => array( 'buzzstore_widgets_name' => 'buzzstore_woo_category', 'buzzstore_widgets_title' => __('Select Category', 'buzzstore'), 'buzzstore_widgets_field_type' => 'select', 'buzzstore_widgets_field_options' => $woocommerce_categories ), 'buzzstore_product_number' => array( 'buzzstore_widgets_name' => 'buzzstore_product_number', 'buzzstore_widgets_title' => __('Enter Number of Products Show', 'buzzstore'), 'buzzstore_widgets_field_type' => 'number', ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** ** wp query for first block **/ $title = esc_attr( $instance['buzzstore_product_title'] ); $shot_desc = esc_textarea( $instance['buzzstore_product_short_desc'] ); $product_type = esc_attr( $instance['buzzstore_product_type'] ); $product_category = intval( $instance['buzzstore_woo_category'] ); $product_number = intval( $instance['buzzstore_product_number'] ); $product_args = ''; global $product_label_custom; if($product_type == 'category'){ $product_args = array( 'post_type' => 'product', 'tax_query' => array( array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $product_category ) ), 'posts_per_page' => $product_number ); } elseif($product_type == 'latest_product'){ $product_label_custom = __('New', 'buzzstore'); $product_args = array( 'post_type' => 'product', 'tax_query' => array( array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $product_category ) ), 'posts_per_page' => $product_number ); } elseif($product_type == 'upsell_product'){ $product_args = array( 'post_type' => 'product', 'posts_per_page' => 10, 'meta_key' => 'total_sales', 'orderby' => 'meta_value_num', 'posts_per_page' => $product_number ); } elseif($product_type == 'feature_product'){ $product_args = array( 'post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'tax_query' => array( array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $product_category ) ), 'posts_per_page' => $product_number ); } elseif($product_type == 'on_sale'){ $product_args = array( 'post_type' => 'product', 'posts_per_page' => $product_number, 'meta_query' => array( 'relation' => 'OR', array( // Simple products type 'key' => '_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ), array( // Variable products type 'key' => '_min_variation_sale_price', 'value' => 0, 'compare' => '>', 'type' => 'numeric' ) )); } echo $before_widget; ?>

    widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? $instance[$buzzstore_widgets_name] : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } } /** ** Adds buzzstore_cat_widget widget. **/ add_action('widgets_init', 'buzzstore_cat_widget'); function buzzstore_cat_widget() { register_widget('buzzstore_cat_widget_area'); } class buzzstore_cat_widget_area extends WP_Widget { /** * Register widget with WordPress. **/ public function __construct() { parent::__construct( 'buzzstore_cat_widget_area', 'Buzz: Woo Category Section', array( 'description' => __('A widget that shows woocommerce category', 'buzzstore') )); } private function widget_fields() { $taxonomy = 'product_cat'; $empty = 1; $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 for no $title = ''; $empty = 0; $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts, 'hierarchical' => $hierarchical, 'title_li' => $title, 'hide_empty' => $empty ); $woocommerce_categories = array(); $woocommerce_categories_obj = get_categories($args); foreach ($woocommerce_categories_obj as $category) { $woocommerce_categories[$category->term_id] = $category->name; } $fields = array( 'buzzstore_main_cat_title' => array( 'buzzstore_widgets_name' => 'buzzstore_main_cat_title', 'buzzstore_widgets_title' => __('Title', 'buzzstore'), 'buzzstore_widgets_field_type' => 'title', ), 'buzzstore_cat_short_desc' => array( 'buzzstore_widgets_name' => 'buzzstore_cat_short_desc', 'buzzstore_widgets_title' => __('Very Short Description', 'buzzstore'), 'buzzstore_widgets_field_type' => 'textarea', 'buzzstore_widgets_row' => '3' ), 'buzzstore_select_category' => array( 'buzzstore_widgets_name' => 'buzzstore_select_category', 'buzzstore_mulicheckbox_title' => __('Select Category', 'buzzstore'), 'buzzstore_widgets_field_type' => 'multicheckboxes', 'buzzstore_widgets_field_options' => $woocommerce_categories ), ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); /** ** wp query for first block **/ $title = esc_attr( $instance['buzzstore_main_cat_title'] ); $shot_desc = esc_textarea( $instance['buzzstore_cat_short_desc'] ); $buzz_store_cat_id = $instance['buzzstore_select_category']; echo $before_widget; ?>

    widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzzstore_widgets_name] = buzzstore_widgets_updated_field_value($widget_field, $new_instance[$buzzstore_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzzstore_widgets_field_value = !empty($instance[$buzzstore_widgets_name]) ? $instance[$buzzstore_widgets_name] : ''; buzzstore_widgets_show_widget_field($this, $widget_field, $buzzstore_widgets_field_value); } } } } /** ** Buzz Store Field Functional file * @package Buzz_Store **/ function buzzstore_widgets_show_widget_field($instance = '', $widget_field = '', $buzzstore_field_value = '') { //list category list in array $buzzstore_category_list[0] = array( 'value' => 0, 'label' => 'Select Categories' ); $buzzstore_posts = get_categories(); foreach ($buzzstore_posts as $buzzstore_post) : $buzzstore_category_list[$buzzstore_post->term_id] = array( 'value' => $buzzstore_post->term_id, 'label' => $buzzstore_post->name ); endforeach; extract($widget_field); switch ($buzzstore_widgets_field_type) { // Standard text field case 'text' : ?>




    />

    '; foreach ($buzzstore_widgets_field_options as $buzzstore_option_name => $buzzstore_option_title) { ?> />





    '; foreach ( $buzzstore_widgets_field_options as $buzzstore_option_name => $buzzstore_option_title) { if( isset( $buzzstore_field_value[$buzzstore_option_name] ) ) { $buzzstore_field_value[$buzzstore_option_name] = 1; }else{ $buzzstore_field_value[$buzzstore_option_name] = 0; } ?>

    />

    '; if (isset($buzzstore_widgets_description)) { ?> get_field_id($buzzstore_widgets_name); $class = ''; $int = ''; $value = $buzzstore_field_value; $name = $instance->get_field_name($buzzstore_widgets_name); if ($value) { $class = ' has-file'; } $output .= '
    '; $output .= '
    '; $output .= '' . "\n"; if (function_exists('wp_enqueue_media')) { if (( $value == '')) { $output .= '' . "\n"; } else { $output .= '' . "\n"; } } else { $output .= '

    ' . __('Upgrade your version of WordPress for full media support.', 'buzzstore') . '

    '; } $output .= '
    ' . "\n"; if ($value != '') { $remove = 'Remove'; $image = preg_match('/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value); if ($image) { $output .= '' . $remove; } else { $parts = explode("/", $value); for ($i = 0; $i < sizeof($parts); ++$i) { $title = $parts[$i]; } $output .= ''; $title = __('View File', 'buzzstore'); $output .= ''; } } $output .= '
    ' . "\n"; echo $output; break; } } function buzzstore_widgets_updated_field_value($widget_field, $new_field_value) { extract($widget_field); if ($buzzstore_widgets_field_type == 'number') { return absint($new_field_value); } elseif ($buzzstore_widgets_field_type == 'textarea') { if (!isset($buzzstore_widgets_allowed_tags)) { $buzzstore_widgets_allowed_tags = '

    '; } return strip_tags($new_field_value, $buzzstore_widgets_allowed_tags); } elseif ($buzzstore_widgets_field_type == 'url') { return esc_url_raw($new_field_value); } elseif ($buzzstore_widgets_field_type == 'title') { return wp_kses_post($new_field_value); } elseif ($buzzstore_widgets_field_type == 'multicheckboxes') { return wp_kses_post($new_field_value); } else { return strip_tags($new_field_value); } } /** ** Enqueue scripts for file uploader **/ if ( ! function_exists( 'buzzstore_media_scripts' ) ) { function buzzstore_media_scripts($hook) { if (function_exists('wp_enqueue_media')) wp_enqueue_media(); wp_register_script('buzzstore-media-uploader', get_template_directory_uri() . '/js/buzzstore-admin.js', array('jquery') ); wp_enqueue_script('buzzstore-media-uploader'); wp_localize_script('buzzstore-media-uploader', 'buzzstore_l10n', array( 'upload' => __('Upload', 'buzzstore'), 'remove' => __('Remove', 'buzzstore') )); wp_enqueue_style( 'buzzstore-style-admin', get_template_directory_uri() . '/css/buzzstore-admin.css'); } } add_action('admin_enqueue_scripts', 'buzzstore_media_scripts');