From 1d333ee38ddc6cf834ea779490d6cf16fb00dcb1 Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Mon, 27 May 2019 12:16:39 +0300 Subject: [PATCH 1/8] widgets --- includes/widgets/widget-ecommerce-info.php | 90 +++++++ .../widget-product-categories-with-icon.php | 243 ++++++++++++++++++ 2 files changed, 333 insertions(+) create mode 100644 includes/widgets/widget-ecommerce-info.php create mode 100644 includes/widgets/widget-product-categories-with-icon.php diff --git a/includes/widgets/widget-ecommerce-info.php b/includes/widgets/widget-ecommerce-info.php new file mode 100644 index 0000000..9ee60b0 --- /dev/null +++ b/includes/widgets/widget-ecommerce-info.php @@ -0,0 +1,90 @@ + __( 'A widget that displays eCommerce Infos', 'the-hanger' ), ) // Args + ); + } + + public function widget( $args, $instance ) { + $icon = apply_filters( 'widget_icon', $instance['icon'] ); + $title = apply_filters( 'widget_title', $instance['title'] ); + $subtitle = apply_filters( 'widget_subtitle', $instance['subtitle'] ); + + print $args['before_widget']; + + + echo '
'; + + if ( ! empty( $title ) ) echo '
' . $args['before_title'] . $title . $args['after_title'] . '
'; + + if ( ! empty( $subtitle ) ) echo '
' . $subtitle .'
'; + + echo '
'; + + print $args['after_widget']; + } + + public function form( $instance ) { + + if ( isset( $instance[ 'icon' ] ) ) { + $icon = $instance[ 'icon' ]; + } else { + $icon = "thehanger-icons-alignment_align-all-1"; + } + + if ( isset( $instance[ 'title' ] ) ) { + $title = $instance[ 'title' ]; + } else { + $title = __( 'eCommerce Info Title', 'the-hanger' ); + } + + if ( isset( $instance[ 'subtitle' ] ) ) { + $subtitle = $instance[ 'subtitle' ]; + } else { + $subtitle = __( 'eCommerce Info Subtitle', 'the-hanger' ); + } + + ?> + +

+ +

+

+ +

+ + +

+ +

+ + +

+ + 'parent', + 'id' => 'term_id', + 'slug' => 'slug', + ); + + public function start_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat( "\t", $depth ); + $output .= "$indent\n"; + } + + public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) { + + $output .= '
  • '; + } else { + $drop_icon = ''; + } + + if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat->term_id, $args['current_category_ancestors'] ) ) { + $output .= ' active current-cat-parent'; + } + + if ( $depth == 0 ) { + $cat_link_classes = 'site-secondary-font'; + } else { + $cat_link_classes = ''; + } + + if ($args['expand_all'] == 1) { + $output .= ' active'; + } + + $icon_type = get_term_meta( $cat->term_id, 'getbowtied_icon_type', true ); + $category_icon= ''; + + if ( ($icon_type == 'theme_default') || ($icon_type != 'custom_icon' && get_term_meta( $cat->term_id, 'icon_id', true )) ) { + $icon = get_term_meta( $cat->term_id, 'icon_id', true ); + $category_icon = ''; + } + + if ($icon_type == 'custom_icon') { + $thumbnail_id = get_term_meta( $cat->term_id, 'icon_img_id', true ); + if ($thumbnail_id) + $image = wp_get_attachment_thumb_url( $thumbnail_id ); + else + $image = wc_placeholder_img_src(); + // Prevent esc_url from breaking spaces in urls for image embeds + // Ref: https://core.trac.wordpress.org/ticket/23605 + $image = str_replace( ' ', '%20', $image ); + $category_icon = ''; + } + + if (empty($icon_type)) { + $icon = 'thehanger-icons-alignment_align-all-1'; + $category_icon = ''; + } + + if ( ! empty( $args['hide_icon'] ) ) { + $category_icon = ''; + } + + $output .= '">' . $category_icon . sprintf(_x( '%s', 'product category name', 'woocommerce' ), $cat->name) . ''; + + if ( $args['show_count'] ) { + $output .= ' ' . $cat->count . ''; + } + + $output .= $drop_icon; + } + + public function end_el( &$output, $cat, $depth = 0, $args = array() ) { + $output .= "
  • \n"; + } + + public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { + if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) { + return; + } + parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); + } + } + + class WC_Widget_Custom_Product_Categories extends WC_Widget { + + public $cat_ancestors; + public $current_cat; + + public function __construct() { + $this->widget_cssclass = 'woocommerce widget_product_categories_with_icon'; + $this->widget_description = __( 'A list of product categories.', 'the-hanger' ); + $this->widget_id = 'woocommerce_product_categories_with_icon'; + $this->widget_name = __( 'WooCommerce product categories with icon', 'the-hanger' ); + $this->settings = array( + 'orderby' => array( + 'type' => 'select', + 'std' => 'name', + 'label' => __( 'Order by', 'the-hanger' ), + 'options' => array( + 'order' => __( 'Category order', 'the-hanger' ), + 'name' => __( 'Name', 'the-hanger' ), + ), + ), + 'count' => array( + 'type' => 'checkbox', + 'std' => 1, + 'label' => __( 'Show product counts', 'the-hanger' ), + ), + 'hide_empty' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Hide empty categories', 'the-hanger' ), + ), + 'hide_icon' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Hide category icon', 'the-hanger' ), + ), + 'expand_all' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Expand All', 'the-hanger' ), + ), + ); + + parent::__construct(); + } + + public function widget( $args, $instance ) { + global $wp_query, $post; + + $count = isset( $instance['count'] ) ? $instance['count'] : $this->settings['count']['std']; + $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : $this->settings['orderby']['std']; + $hide_empty = isset( $instance['hide_empty'] ) ? $instance['hide_empty'] : $this->settings['hide_empty']['std']; + $hide_icon = isset( $instance['hide_icon'] ) ? $instance['hide_icon'] : $this->settings['hide_icon']['std']; + $expand_all = isset( $instance['expand_all'] ) ? $instance['expand_all'] : $this->settings['expand_all']['std']; + $list_args = array( 'show_count' => $count, 'taxonomy' => 'product_cat', 'hide_empty' => $hide_empty, 'hide_icon' => $hide_icon, 'expand_all' => $expand_all ); + + // Menu Order + $list_args['menu_order'] = false; + if ( 'order' === $orderby ) { + $list_args['menu_order'] = 'asc'; + } else { + $list_args['orderby'] = 'title'; + } + + // Setup Current Category + $this->current_cat = false; + $this->cat_ancestors = array(); + + if ( is_tax( 'product_cat' ) ) { + + $this->current_cat = $wp_query->queried_object; + $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); + + } elseif ( is_singular( 'product' ) ) { + + $product_category = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( 'orderby' => 'parent' ) ) ); + + if ( ! empty( $product_category ) ) { + $this->current_cat = end( $product_category ); + $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); + } + } + + $this->widget_start( $args, $instance ); + + $list_args['walker'] = new WC_Product_Cat_List_With_Icon_Walker; + $list_args['title_li'] = ''; + $list_args['pad_counts'] = 1; + $list_args['show_option_none'] = __( 'No product categories exist.', 'the-hanger' ); + $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; + $list_args['current_category_ancestors'] = $this->cat_ancestors; + + echo ''; + + $this->widget_end( $args ); + } + } + + function register_custom_product_categories_widget() { + register_widget( 'WC_Widget_Custom_Product_Categories' ); + } + + add_action( 'widgets_init', 'register_custom_product_categories_widget' ); + } +} \ No newline at end of file From 698a53cf51af20750dc70b5564ec47ed897ddb34 Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Mon, 27 May 2019 12:16:48 +0300 Subject: [PATCH 2/8] the hanger extender class --- includes/helpers/helpers.php | 23 ++++++ the-hanger-extender.php | 144 ++++++++++++++++++++--------------- 2 files changed, 104 insertions(+), 63 deletions(-) create mode 100644 includes/helpers/helpers.php diff --git a/includes/helpers/helpers.php b/includes/helpers/helpers.php new file mode 100644 index 0000000..1a60a6f --- /dev/null +++ b/includes/helpers/helpers.php @@ -0,0 +1,23 @@ + + +
    +

    The Hanger Extender plugin couldn't find the Block Editor (Gutenberg) on this site. It requires WordPress 5+ or Gutenberg installed as a plugin.

    +
    + + template == 'the-hanger') { - include_once( 'includes/shortcodes/wp/socials.php' ); - include_once( 'includes/shortcodes/wp/slider.php' ); - include_once( 'includes/shortcodes/wp/blog-posts.php' ); - include_once( 'includes/shortcodes/wp/custom-button.php' ); - include_once( 'includes/shortcodes/wc/woocommerce_products_user_bought.php' ); - - /******************************************************************************/ - /* Add Shortcodes to VC *******************************************************/ - /******************************************************************************/ - - if ( defined( 'WPB_VC_VERSION' ) ) { - - add_action( 'init', 'getbowtied_visual_composer_shortcodes' ); - function getbowtied_visual_composer_shortcodes() { - - // Add new WP shortcodes to VC - - include_once( 'includes/shortcodes/vc/wp/slider.php' ); - include_once( 'includes/shortcodes/vc/wp/blog-posts.php' ); - include_once( 'includes/shortcodes/vc/wp/custom-button.php' ); - + /** + * TheHangerExtender class. + */ + class TheHangerExtender { + + /** + * The single instance of the class. + * + * @var TheHangerExtender + */ + protected static $_instance = null; + + /** + * TheHangerExtender constructor. + * + */ + public function __construct() { + + $theme = wp_get_theme(); + $parent_theme = $theme->parent(); + + // Helpers + include_once( 'includes/helpers/helpers.php' ); + + if ( $theme->template == 'the-hanger') { + include_once( 'includes/shortcodes/wp/socials.php' ); + include_once( 'includes/shortcodes/wp/slider.php' ); + include_once( 'includes/shortcodes/wp/blog-posts.php' ); + include_once( 'includes/shortcodes/wp/custom-button.php' ); + include_once( 'includes/shortcodes/wc/woocommerce_products_user_bought.php' ); + + // Add Shortcodes to VC + if ( defined( 'WPB_VC_VERSION' ) ) { + + add_action( 'init', function() { + + // Add new WP shortcodes to VC + include_once( 'includes/shortcodes/vc/wp/slider.php' ); + include_once( 'includes/shortcodes/vc/wp/blog-posts.php' ); + include_once( 'includes/shortcodes/vc/wp/custom-button.php' ); + }); + } + + include_once( 'includes/functions/actions.php' ); + } + + // Gutenberg Blocks + add_action( 'init', array( $this, 'gbt_th_gutenberg_blocks' ) ); + + if( $theme->template == 'the-hanger' && ( $theme->version >= '1.5.1' || ( !empty($parent_theme) && $parent_theme->version >= '1.5.1' ) ) ) { + + // Widgets + include_once( 'includes/widgets/widget-ecommerce-info.php' ); + include_once( 'includes/widgets/widget-product-categories-with-icon.php' ); + } } - } - - include_once( 'includes/functions/actions.php' ); -} -/******************************************************************************/ -/* Add Gutenberg Blocks *******************************************************/ -/******************************************************************************/ - -add_action( 'init', 'gbt_th_gutenberg_blocks' ); -if(!function_exists('gbt_th_gutenberg_blocks')) { - function gbt_th_gutenberg_blocks() { - - if( is_plugin_active( 'gutenberg/gutenberg.php' ) || is_wp_version('>=', '5.0') ) { - include_once 'includes/gbt-blocks/index.php'; - } else { - add_action( 'admin_notices', 'gbt_th_theme_warning' ); + /** + * Loads Gutenberg blocks + * + * @return void + */ + public function gbt_th_gutenberg_blocks() { + + if( is_plugin_active( 'gutenberg/gutenberg.php' ) || is_wp_version('>=', '5.0') ) { + include_once 'includes/gbt-blocks/index.php'; + } else { + add_action( 'admin_notices', 'gbt_th_theme_warning' ); + } } - } -} - -if( !function_exists('gbt_th_theme_warning') ) { - function gbt_th_theme_warning() { - - ?> -
    -

    The Hanger Extender plugin couldn't find the Block Editor (Gutenberg) on this site. It requires WordPress 5+ or Gutenberg installed as a plugin.

    -
    - - ', $version = '4.0' ) { - - global $wp_version; +endif; - return version_compare( $wp_version, $version, $operator ); - } -} +$thehanger_extender = new TheHangerExtender; \ No newline at end of file From 7b03d3a5b13b0baafe79572de5c3fbd92680399e Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Tue, 28 May 2019 10:10:31 +0300 Subject: [PATCH 3/8] widgets --- includes/widgets/widget-ecommerce-info.php | 12 +-- .../widget-product-categories-with-icon.php | 20 ++--- languages/the-hanger-extender.pot | 88 +++++++++++++++++-- 3 files changed, 95 insertions(+), 25 deletions(-) diff --git a/includes/widgets/widget-ecommerce-info.php b/includes/widgets/widget-ecommerce-info.php index 9ee60b0..8b93408 100644 --- a/includes/widgets/widget-ecommerce-info.php +++ b/includes/widgets/widget-ecommerce-info.php @@ -9,8 +9,8 @@ class eCommerce_Info_Widget extends WP_Widget { public function __construct() { parent::__construct( 'theme_ecommerce_info', // Base ID - __('eCommerce Info', 'the-hanger'), // Name - array( 'description' => __( 'A widget that displays eCommerce Infos', 'the-hanger' ), ) // Args + __('eCommerce Info', 'the-hanger-extender'), // Name + array( 'description' => __( 'A widget that displays eCommerce Infos', 'the-hanger-extender' ), ) // Args ); } @@ -44,13 +44,13 @@ public function form( $instance ) { if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; } else { - $title = __( 'eCommerce Info Title', 'the-hanger' ); + $title = __( 'eCommerce Info Title', 'the-hanger-extender' ); } if ( isset( $instance[ 'subtitle' ] ) ) { $subtitle = $instance[ 'subtitle' ]; } else { - $subtitle = __( 'eCommerce Info Subtitle', 'the-hanger' ); + $subtitle = __( 'eCommerce Info Subtitle', 'the-hanger-extender' ); } ?> @@ -61,12 +61,12 @@ public function form( $instance ) {

    - +

    - +

    diff --git a/includes/widgets/widget-product-categories-with-icon.php b/includes/widgets/widget-product-categories-with-icon.php index 644c9e6..697420a 100644 --- a/includes/widgets/widget-product-categories-with-icon.php +++ b/includes/widgets/widget-product-categories-with-icon.php @@ -115,38 +115,38 @@ class WC_Widget_Custom_Product_Categories extends WC_Widget { public function __construct() { $this->widget_cssclass = 'woocommerce widget_product_categories_with_icon'; - $this->widget_description = __( 'A list of product categories.', 'the-hanger' ); + $this->widget_description = __( 'A list of product categories.', 'the-hanger-extender' ); $this->widget_id = 'woocommerce_product_categories_with_icon'; - $this->widget_name = __( 'WooCommerce product categories with icon', 'the-hanger' ); + $this->widget_name = __( 'WooCommerce product categories with icon', 'the-hanger-extender' ); $this->settings = array( 'orderby' => array( 'type' => 'select', 'std' => 'name', - 'label' => __( 'Order by', 'the-hanger' ), + 'label' => __( 'Order by', 'the-hanger-extender' ), 'options' => array( - 'order' => __( 'Category order', 'the-hanger' ), - 'name' => __( 'Name', 'the-hanger' ), + 'order' => __( 'Category order', 'the-hanger-extender' ), + 'name' => __( 'Name', 'the-hanger-extender' ), ), ), 'count' => array( 'type' => 'checkbox', 'std' => 1, - 'label' => __( 'Show product counts', 'the-hanger' ), + 'label' => __( 'Show product counts', 'the-hanger-extender' ), ), 'hide_empty' => array( 'type' => 'checkbox', 'std' => 0, - 'label' => __( 'Hide empty categories', 'the-hanger' ), + 'label' => __( 'Hide empty categories', 'the-hanger-extender' ), ), 'hide_icon' => array( 'type' => 'checkbox', 'std' => 0, - 'label' => __( 'Hide category icon', 'the-hanger' ), + 'label' => __( 'Hide category icon', 'the-hanger-extender' ), ), 'expand_all' => array( 'type' => 'checkbox', 'std' => 0, - 'label' => __( 'Expand All', 'the-hanger' ), + 'label' => __( 'Expand All', 'the-hanger-extender' ), ), ); @@ -195,7 +195,7 @@ public function widget( $args, $instance ) { $list_args['walker'] = new WC_Product_Cat_List_With_Icon_Walker; $list_args['title_li'] = ''; $list_args['pad_counts'] = 1; - $list_args['show_option_none'] = __( 'No product categories exist.', 'the-hanger' ); + $list_args['show_option_none'] = __( 'No product categories exist.', 'the-hanger-extender' ); $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; $list_args['current_category_ancestors'] = $this->cat_ancestors; diff --git a/languages/the-hanger-extender.pot b/languages/the-hanger-extender.pot index c940c51..b6ee12b 100644 --- a/languages/the-hanger-extender.pot +++ b/languages/the-hanger-extender.pot @@ -15,46 +15,46 @@ msgstr "" "PO-Revision-Date: \n" "Last-Translator: \n" "Language-Team: \n" -"X-Generator: Poedit 2.2.1\n" +"X-Generator: Poedit 2.2.3\n" "X-Poedit-SearchPath-0: .\n" -#: core/updater/Puc/v4p5/Plugin/Ui.php:54 +#: core/updater/Puc/v4p6/Plugin/Ui.php:54 msgid "View details" msgstr "" -#: core/updater/Puc/v4p5/Plugin/Ui.php:77 +#: core/updater/Puc/v4p6/Plugin/Ui.php:77 #, php-format msgid "More information about %s" msgstr "" -#: core/updater/Puc/v4p5/Plugin/Ui.php:128 +#: core/updater/Puc/v4p6/Plugin/Ui.php:128 msgid "Check for updates" msgstr "" -#: core/updater/Puc/v4p5/Plugin/Ui.php:213 +#: core/updater/Puc/v4p6/Plugin/Ui.php:213 #, php-format msgctxt "the plugin title" msgid "The %s plugin is up to date." msgstr "" -#: core/updater/Puc/v4p5/Plugin/Ui.php:215 +#: core/updater/Puc/v4p6/Plugin/Ui.php:215 #, php-format msgctxt "the plugin title" msgid "A new version of the %s plugin is available." msgstr "" -#: core/updater/Puc/v4p5/Plugin/Ui.php:217 +#: core/updater/Puc/v4p6/Plugin/Ui.php:217 #, php-format msgctxt "the plugin title" msgid "Could not determine if updates are available for %s." msgstr "" -#: core/updater/Puc/v4p5/Plugin/Ui.php:223 +#: core/updater/Puc/v4p6/Plugin/Ui.php:223 #, php-format msgid "Unknown update checker status \"%s\"" msgstr "" -#: core/updater/Puc/v4p5/Vcs/PluginUpdateChecker.php:98 +#: core/updater/Puc/v4p6/Vcs/PluginUpdateChecker.php:98 msgid "There is no changelog available." msgstr "" @@ -205,3 +205,73 @@ msgstr "" #, php-format msgid "%s" msgstr "" + +#: includes/widgets/widget-ecommerce-info.php:12 +msgid "eCommerce Info" +msgstr "" + +#: includes/widgets/widget-ecommerce-info.php:13 +msgid "A widget that displays eCommerce Infos" +msgstr "" + +#: includes/widgets/widget-ecommerce-info.php:47 +msgid "eCommerce Info Title" +msgstr "" + +#: includes/widgets/widget-ecommerce-info.php:53 +msgid "eCommerce Info Subtitle" +msgstr "" + +#: includes/widgets/widget-ecommerce-info.php:64 +msgid "Title:" +msgstr "" + +#: includes/widgets/widget-ecommerce-info.php:69 +msgid "Subtitle:" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:90 +#, php-format +msgctxt "product category name" +msgid "%s" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:118 +msgid "A list of product categories." +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:120 +msgid "WooCommerce product categories with icon" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:125 +msgid "Order by" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:127 +msgid "Category order" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:128 +msgid "Name" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:134 +msgid "Show product counts" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:139 +msgid "Hide empty categories" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:144 +msgid "Hide category icon" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:149 +msgid "Expand All" +msgstr "" + +#: includes/widgets/widget-product-categories-with-icon.php:198 +msgid "No product categories exist." +msgstr "" From edcafbcb55a02cc7426aafcdf789b933df4f38dd Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Tue, 28 May 2019 10:53:58 +0300 Subject: [PATCH 4/8] widgets assets --- .../assets/css/widget-ecommerce-info.css | 19 ++ .../widget-product-categories-with-icon.css | 93 ++++++++++ .../js/widget-product-categories-with-icon.js | 41 +++++ .../assets/scss/widget-ecommerce-info.scss | 31 ++++ .../widget-product-categories-with-icon.scss | 166 ++++++++++++++++++ includes/widgets/widget-ecommerce-info.php | 11 ++ .../widget-product-categories-with-icon.php | 15 +- 7 files changed, 375 insertions(+), 1 deletion(-) create mode 100644 includes/widgets/assets/css/widget-ecommerce-info.css create mode 100644 includes/widgets/assets/css/widget-product-categories-with-icon.css create mode 100644 includes/widgets/assets/js/widget-product-categories-with-icon.js create mode 100644 includes/widgets/assets/scss/widget-ecommerce-info.scss create mode 100644 includes/widgets/assets/scss/widget-product-categories-with-icon.scss diff --git a/includes/widgets/assets/css/widget-ecommerce-info.css b/includes/widgets/assets/css/widget-ecommerce-info.css new file mode 100644 index 0000000..6c41c50 --- /dev/null +++ b/includes/widgets/assets/css/widget-ecommerce-info.css @@ -0,0 +1,19 @@ +.widget_theme_ecommerce_info { + display: -webkit-box; + display: -ms-flexbox; + display: flex; } + .widget_theme_ecommerce_info .ecommerce-info-widget-txt-wrapper .ecommerce-info-widget-title { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; } + .widget_theme_ecommerce_info .ecommerce-info-widget-txt-wrapper .ecommerce-info-widget-title .ecommerce-info-widget-icon { + font-size: 24px; + margin-right: 16px; + line-height: 1; } + .widget_theme_ecommerce_info .ecommerce-info-widget-txt-wrapper .ecommerce-info-widget-title .widget-title { + margin-bottom: 4px; } + .widget_theme_ecommerce_info .ecommerce-info-widget-txt-wrapper .ecommerce-info-widget-subtitle { + padding-left: 2.5rem; } diff --git a/includes/widgets/assets/css/widget-product-categories-with-icon.css b/includes/widgets/assets/css/widget-product-categories-with-icon.css new file mode 100644 index 0000000..c264ed5 --- /dev/null +++ b/includes/widgets/assets/css/widget-product-categories-with-icon.css @@ -0,0 +1,93 @@ +.widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li { + border-bottom: 1px solid; + margin: 0; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + cursor: pointer; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li:last-child { + border-bottom: 0; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li .dropdown_icon:before { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: end; + -ms-flex-pack: end; + justify-content: flex-end; + -webkit-transition: -webkit-transform .7s; + transition: -webkit-transform .7s; + -o-transition: transform .7s; + transition: transform .7s; + transition: transform .7s, -webkit-transform .7s; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li.active-item .dropdown_icon:before { + -webkit-transform: rotateX(180deg) rotateY(0deg) rotateZ(0deg); + transform: rotateX(180deg) rotateY(0deg) rotateZ(0deg); } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > ul.children { + margin: 0px 0.5rem 1rem 2.5rem; + width: 100%; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > ul.children.add_scroll { + max-height: 200px; + overflow-y: scroll; + margin-bottom: 1.5rem; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > ul.children.add_scroll::-webkit-scrollbar-track { + border-radius: 3px; + background: rgba(0, 0, 0, 0.1); } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > ul.children.add_scroll::-webkit-scrollbar { + width: 2px; + background: rgba(0, 0, 0, 0.1); } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > ul.children.add_scroll::-webkit-scrollbar-thumb { + border-radius: 3px; + background: rgba(0, 0, 0, 0.1); } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > ul.children li [class^="thehanger-icons-"], + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > ul.children li [class*=" thehanger-icons-"] { + display: none; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > a { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + min-height: 4.5em; + padding-top: 1.2em; + padding-bottom: 1.2em; + max-width: 70%; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > a i { + font-size: 1.5rem; + padding-right: 0.9375rem; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li > a img { + width: 1.5rem; + margin-right: 0.9375rem; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > li .count { + margin-left: 0.1875rem; } + +.widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > .cat-parent { + position: relative; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > .cat-parent.no-icon > .children { + margin-left: 1.25rem; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > .cat-parent.current-cat-parent.active ul.children { + display: block; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > .cat-parent .dropdown_icon { + -webkit-transition: all .3s ease-in-out; + -o-transition: all .3s ease-in-out; + transition: all .3s ease-in-out; + padding: 0.25rem; + font-size: 0.5rem; + -webkit-box-flex: 1; + -ms-flex-positive: 1; + flex-grow: 1; + -webkit-box-pack: end; + -ms-flex-pack: end; + justify-content: flex-end; + text-align: right; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > .cat-parent .cat-item { + margin-bottom: 0.3125rem; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > .cat-parent > .children { + display: none; } + .widget.woocommerce.widget_product_categories_with_icon .product-categories-with-icon > .cat-parent > .children li ul.children { + margin: 0.5rem 0.5rem 0px 1.25rem; } diff --git a/includes/widgets/assets/js/widget-product-categories-with-icon.js b/includes/widgets/assets/js/widget-product-categories-with-icon.js new file mode 100644 index 0000000..a2fa401 --- /dev/null +++ b/includes/widgets/assets/js/widget-product-categories-with-icon.js @@ -0,0 +1,41 @@ +jQuery(function($) { + + "use strict"; + + $('.product-categories-with-icon').on('click', '.cat-parent .dropdown_icon', function() { + $(this).parent().toggleClass('active-item'); + $(this).siblings("ul.children").slideToggle('300', function() { + }); + }); + + // If there is more than 8 categories than add scroll class + // If the user is inside the category, keep the widget category open + + $('.product-categories-with-icon .cat-item').each(function() { + + var max_subcategory_nr = 8 + var subcategory_nr = $(this).find("ul.children").find('li').length; + + if ( subcategory_nr > max_subcategory_nr ) { + $(this).find("ul.children").addClass('add_scroll'); + } + + if ( $(this).hasClass('current-cat') ) { + $(this).addClass('active-item'); + $(this).find("ul.children").show(); + } + + if ( $(this).hasClass('current-cat-parent') ) { + $(this).addClass('active-item'); + $(this).find("ul.children").show(); + } + + if ( $(this).hasClass('cat-parent') ) { + if ( ! $(this).find('i').length ) { + $(this).addClass('no-icon'); + } + } + + }); + +}); \ No newline at end of file diff --git a/includes/widgets/assets/scss/widget-ecommerce-info.scss b/includes/widgets/assets/scss/widget-ecommerce-info.scss new file mode 100644 index 0000000..5bed5e0 --- /dev/null +++ b/includes/widgets/assets/scss/widget-ecommerce-info.scss @@ -0,0 +1,31 @@ +.widget_theme_ecommerce_info +{ + display: flex; + + .ecommerce-info-widget-txt-wrapper + { + .ecommerce-info-widget-title + { + display: flex; + align-items: center; + + .ecommerce-info-widget-icon + { + font-size: 24px; + margin-right: 16px; + line-height: 1; + } + + .widget-title + { + margin-bottom: 4px; + } + } + + .ecommerce-info-widget-subtitle + { + padding-left: 2.5rem; + } + } + +} \ No newline at end of file diff --git a/includes/widgets/assets/scss/widget-product-categories-with-icon.scss b/includes/widgets/assets/scss/widget-product-categories-with-icon.scss new file mode 100644 index 0000000..4721d86 --- /dev/null +++ b/includes/widgets/assets/scss/widget-product-categories-with-icon.scss @@ -0,0 +1,166 @@ +.widget.woocommerce.widget_product_categories_with_icon +{ + .product-categories-with-icon + { + > li + { + border-bottom: 1px solid; + margin: 0; + display: flex; + align-items: center; + flex-wrap: wrap; + cursor: pointer; + + &:last-child + { + border-bottom: 0; + } + + .dropdown_icon + { + &:before + { + display: flex; + justify-content: flex-end; + transition: transform .7s; + } + } + + &.active-item + { + .dropdown_icon + { + &:before + { + transform: rotateX(180deg) rotateY(0deg) rotateZ(0deg); + } + } + } + + > ul + { + &.children + { + margin: 0px 0.5rem 1rem 2.5rem; + width: 100%; + + &.add_scroll + { + max-height: 200px; + overflow-y: scroll; + margin-bottom: 1.5rem; + + &::-webkit-scrollbar-track + { + border-radius: 3px; + background: rgba(#000,.1); + } + + &::-webkit-scrollbar + { + width: 2px; + background: rgba(#000,.1); + } + + &::-webkit-scrollbar-thumb + { + border-radius: 3px; + background: rgba(#000,.1); + } + } + + li + { + [class^="thehanger-icons-"], + [class*=" thehanger-icons-"] + { + display: none; + } + + } + } + } + + > a + { + display: flex; + align-items: center; + min-height: 4.5em; + padding-top: 1.2em; + padding-bottom: 1.2em; + max-width: 70%; + + i + { + font-size: 1.5rem; + padding-right: 0.9375rem; + } + + img + { + width: 1.5rem; + margin-right: 0.9375rem; + } + } + + .count + { + margin-left: 0.1875rem; + } + + } + + > .cat-parent + { + position: relative; + + &.no-icon + { + > .children + { + margin-left: 1.25rem; + } + } + + &.current-cat-parent + { + &.active + { + ul.children + { + display: block; + } + } + } + + .dropdown_icon + { + transition: all .3s ease-in-out; + padding: 0.25rem; + font-size: 0.5rem; + flex-grow: 1; + justify-content: flex-end; + text-align: right; + } + + .cat-item + { + margin-bottom: 0.3125rem; + } + + > .children + { + display: none; + + li + { + ul.children + { + margin: 0.5rem 0.5rem 0px 1.25rem; + } + } + } + + } + } +} \ No newline at end of file diff --git a/includes/widgets/widget-ecommerce-info.php b/includes/widgets/widget-ecommerce-info.php index 8b93408..e2bd8aa 100644 --- a/includes/widgets/widget-ecommerce-info.php +++ b/includes/widgets/widget-ecommerce-info.php @@ -7,6 +7,7 @@ class eCommerce_Info_Widget extends WP_Widget { public function __construct() { + $this->enqueue_scripts(); parent::__construct( 'theme_ecommerce_info', // Base ID __('eCommerce Info', 'the-hanger-extender'), // Name @@ -14,6 +15,16 @@ public function __construct() { ); } + public function enqueue_scripts() { + add_action( 'wp_enqueue_scripts', function() { + wp_enqueue_style( + 'getbowtied-th-ecommerce-widget-styles', + plugins_url( 'assets/css/widget-ecommerce-info.css', __FILE__ ), + array() + ); + }); + } + public function widget( $args, $instance ) { $icon = apply_filters( 'widget_icon', $instance['icon'] ); $title = apply_filters( 'widget_title', $instance['title'] ); diff --git a/includes/widgets/widget-product-categories-with-icon.php b/includes/widgets/widget-product-categories-with-icon.php index 697420a..40ee606 100644 --- a/includes/widgets/widget-product-categories-with-icon.php +++ b/includes/widgets/widget-product-categories-with-icon.php @@ -4,8 +4,21 @@ exit; } -add_action( 'plugins_loaded', 'gbt_th_wc_widget' ); +add_action( 'wp_enqueue_scripts', function() { + wp_enqueue_style( + 'getbowtied-th-widget-styles', + plugins_url( 'assets/css/widget-product-categories-with-icon.css', __FILE__ ), + array() + ); + + wp_enqueue_script( + 'getbowtied-th-widget-scripts', + plugins_url( 'assets/js/widget-product-categories-with-icon.js', __FILE__ ), + array( 'jquery' ) + ); +}); +add_action( 'plugins_loaded', 'gbt_th_wc_widget' ); function gbt_th_wc_widget() { if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { From db526eb55d77354e08cfafbeb33db5aaae6bbcb7 Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Wed, 29 May 2019 14:43:46 +0300 Subject: [PATCH 5/8] ... --- includes/widgets/widget-ecommerce-info.php | 8 ++++---- .../widgets/widget-product-categories-with-icon.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/widgets/widget-ecommerce-info.php b/includes/widgets/widget-ecommerce-info.php index e2bd8aa..0ed29bf 100644 --- a/includes/widgets/widget-ecommerce-info.php +++ b/includes/widgets/widget-ecommerce-info.php @@ -4,7 +4,7 @@ exit; } -class eCommerce_Info_Widget extends WP_Widget { +class TheHanger_eCommerce_Info_Widget extends WP_Widget { public function __construct() { $this->enqueue_scripts(); @@ -95,7 +95,7 @@ public function update( $new_instance, $old_instance ) { } -function register_ecommerce_info_widget() { - register_widget( 'eCommerce_Info_Widget' ); +function th_register_ecommerce_info_widget() { + register_widget( 'TheHanger_eCommerce_Info_Widget' ); } -add_action( 'widgets_init', 'register_ecommerce_info_widget' ); +add_action( 'widgets_init', 'th_register_ecommerce_info_widget' ); diff --git a/includes/widgets/widget-product-categories-with-icon.php b/includes/widgets/widget-product-categories-with-icon.php index 40ee606..fc0a724 100644 --- a/includes/widgets/widget-product-categories-with-icon.php +++ b/includes/widgets/widget-product-categories-with-icon.php @@ -22,7 +22,7 @@ function gbt_th_wc_widget() { if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { - class WC_Product_Cat_List_With_Icon_Walker extends Walker { + class TheHanger_WC_Product_Cat_List_With_Icon_Walker extends Walker { public $tree_type = 'product_cat'; @@ -121,7 +121,7 @@ public function display_element( $element, &$children_elements, $max_depth, $dep } } - class WC_Widget_Custom_Product_Categories extends WC_Widget { + class TheHanger_WC_Widget_Custom_Product_Categories extends WC_Widget { public $cat_ancestors; public $current_cat; @@ -205,7 +205,7 @@ public function widget( $args, $instance ) { $this->widget_start( $args, $instance ); - $list_args['walker'] = new WC_Product_Cat_List_With_Icon_Walker; + $list_args['walker'] = new TheHanger_WC_Product_Cat_List_With_Icon_Walker; $list_args['title_li'] = ''; $list_args['pad_counts'] = 1; $list_args['show_option_none'] = __( 'No product categories exist.', 'the-hanger-extender' ); @@ -247,10 +247,10 @@ public function widget( $args, $instance ) { } } - function register_custom_product_categories_widget() { - register_widget( 'WC_Widget_Custom_Product_Categories' ); + function th_register_custom_product_categories_widget() { + register_widget( 'TheHanger_WC_Widget_Custom_Product_Categories' ); } - add_action( 'widgets_init', 'register_custom_product_categories_widget' ); + add_action( 'widgets_init', 'th_register_custom_product_categories_widget' ); } } \ No newline at end of file From f594c0475030a9172f2d365bb71012e490639157 Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Wed, 29 May 2019 14:49:17 +0300 Subject: [PATCH 6/8] v.1.5.6 --- README.txt | 13 ++++++++++--- core/updater/assets/plugin.json | 10 +++++----- the-hanger-extender.php | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.txt b/README.txt index f970ea4..26e53b1 100644 --- a/README.txt +++ b/README.txt @@ -2,12 +2,12 @@ Contributors: getbowtied, vanesareinerth, adrianlbs, traians Tags: gutenberg, blocks Requires at least: 5.0 -Tested up to: 5.2 -Stable tag: 1.5.5 +Tested up to: 5.2.1 +Stable tag: 1.5.6 Requires PHP: 5.5.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html -~Current Version:1.5.5~ +~Current Version:1.5.6~ Extends the functionality of The Hanger theme by adding theme specific features. @@ -25,12 +25,19 @@ Companion plugin for the **The Hanger** theme. Extends the functionality by addi - Blog Posts - Custom Button +**Widgets:** +- eCommerce Info +- Product Categories with Icon + **Features:** - Adds social sharing options for the product page - Display recently purchased products in My Account / Dashboard == Changelog == += 1.5.6 = +- Adds: Theme-specific custom widgets: eCommerce Info and Product Categories with Icon + = 1.5.5 = - PHP 7.3 compatibility updates diff --git a/core/updater/assets/plugin.json b/core/updater/assets/plugin.json index 31a361c..af68995 100755 --- a/core/updater/assets/plugin.json +++ b/core/updater/assets/plugin.json @@ -1,19 +1,19 @@ { "name": "The Hanger Extender", - "version": "1.5.5", + "version": "1.5.6", "download_url": "https://github.com/getbowtied/the-hanger-extender/zipball/master", "homepage": "https://themeforest.net/item/the-hanger-modern-classic-woocommerce-theme/21753302", "requires": "5.0", - "tested": "5.2", - "last_updated": "2019-05-21 12:00:00", + "tested": "5.2.1", + "last_updated": "2019-05-29 15:00:00", "author": "GetBowtied", "author_homepage": "https://getbowtied.com/", "sections": { - "description": "

    Companion plugin for the The Hanger theme. Extends the functionality by adding theme specific features.

    Gutenberg Blocks:

    • Image Slider
    • Blog Posts
    • Social Media Profiles

    WPBakery Page Builder Elements:

    • Slider
    • Blog Posts
    • Custom Button

    Features:

    • Adds social sharing options for the product page
    • Display recently purchased products in My Account / Dashboard
    ", - "changelog": "

    1.5.5

    • Fixed: PHP 7.3 compatibility updates

    1.5.4

    • Fixed: Localization issues

    1.5.3

    • WordPress 5.1 compatibility improvements

    1.5.2

    • Various bug fixes

    1.5.1

    • Fixed: Columns Block displaying issue
    • Fixed: Yoast SEO compatibiity issue

    1.5

    • WordPress 5+ compatibility improvements
    • Improved styles for theme neutrality
    • Localization issues with the Posts Grid Block

    1.4

    • WordPress 5+ compatibility improvements

    1.3

    • Gutenberg Slider Block Fixes

    1.2

    • Gutenberg Compatibility
    • Gutenberg Custom Blocks: Slider, Latest Posts Grid, Social Media Profiles

    1.1

    • Various Fixes

    1.0

    • Initial Version
    " + "description": "

    Companion plugin for the The Hanger theme. Extends the functionality by adding theme specific features.

    Gutenberg Blocks:

    • Image Slider
    • Blog Posts
    • Social Media Profiles

    WPBakery Page Builder Elements:

    • Slider
    • Blog Posts
    • Custom Button

    Widgets:

    • eCommerce Info
    • Product Categories with Icon

    Features:

    • Adds social sharing options for the product page
    • Display recently purchased products in My Account / Dashboard
    ", + "changelog": "

    1.5.6

    • Adds: Theme-specific custom widgets: eCommerce Info and Product Categories with Icon

    1.5.5

    • Fixed: PHP 7.3 compatibility updates

    1.5.4

    • Fixed: Localization issues

    1.5.3

    • WordPress 5.1 compatibility improvements

    1.5.2

    • Various bug fixes

    1.5.1

    • Fixed: Columns Block displaying issue
    • Fixed: Yoast SEO compatibiity issue

    1.5

    • WordPress 5+ compatibility improvements
    • Improved styles for theme neutrality
    • Localization issues with the Posts Grid Block

    1.4

    • WordPress 5+ compatibility improvements

    1.3

    • Gutenberg Slider Block Fixes

    1.2

    • Gutenberg Compatibility
    • Gutenberg Custom Blocks: Slider, Latest Posts Grid, Social Media Profiles

    1.1

    • Various Fixes

    1.0

    • Initial Version
    " }, "icons" : { diff --git a/the-hanger-extender.php b/the-hanger-extender.php index dba7540..b212c69 100755 --- a/the-hanger-extender.php +++ b/the-hanger-extender.php @@ -3,11 +3,11 @@ * Plugin Name: The Hanger Extender * Plugin URI: https://thehanger.wp-theme.design/ * Description: Extends the functionality of The Hanger with theme specific shortcodes and page builder elements. - * Version: 1.5.5 + * Version: 1.5.6 * Author: GetBowtied * Author URI: https://getbowtied.com * Requires at least: 5.0 - * Tested up to: 5.2 + * Tested up to: 5.2.1 * * @package The Hanger Extender * @author GetBowtied From 3eb39145a58b5c99bea3d8158f35b9cefa34e87d Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Wed, 29 May 2019 15:22:11 +0300 Subject: [PATCH 7/8] Revert "..." This reverts commit db526eb55d77354e08cfafbeb33db5aaae6bbcb7. --- includes/widgets/widget-ecommerce-info.php | 8 ++++---- .../widgets/widget-product-categories-with-icon.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/includes/widgets/widget-ecommerce-info.php b/includes/widgets/widget-ecommerce-info.php index 0ed29bf..e2bd8aa 100644 --- a/includes/widgets/widget-ecommerce-info.php +++ b/includes/widgets/widget-ecommerce-info.php @@ -4,7 +4,7 @@ exit; } -class TheHanger_eCommerce_Info_Widget extends WP_Widget { +class eCommerce_Info_Widget extends WP_Widget { public function __construct() { $this->enqueue_scripts(); @@ -95,7 +95,7 @@ public function update( $new_instance, $old_instance ) { } -function th_register_ecommerce_info_widget() { - register_widget( 'TheHanger_eCommerce_Info_Widget' ); +function register_ecommerce_info_widget() { + register_widget( 'eCommerce_Info_Widget' ); } -add_action( 'widgets_init', 'th_register_ecommerce_info_widget' ); +add_action( 'widgets_init', 'register_ecommerce_info_widget' ); diff --git a/includes/widgets/widget-product-categories-with-icon.php b/includes/widgets/widget-product-categories-with-icon.php index fc0a724..40ee606 100644 --- a/includes/widgets/widget-product-categories-with-icon.php +++ b/includes/widgets/widget-product-categories-with-icon.php @@ -22,7 +22,7 @@ function gbt_th_wc_widget() { if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { - class TheHanger_WC_Product_Cat_List_With_Icon_Walker extends Walker { + class WC_Product_Cat_List_With_Icon_Walker extends Walker { public $tree_type = 'product_cat'; @@ -121,7 +121,7 @@ public function display_element( $element, &$children_elements, $max_depth, $dep } } - class TheHanger_WC_Widget_Custom_Product_Categories extends WC_Widget { + class WC_Widget_Custom_Product_Categories extends WC_Widget { public $cat_ancestors; public $current_cat; @@ -205,7 +205,7 @@ public function widget( $args, $instance ) { $this->widget_start( $args, $instance ); - $list_args['walker'] = new TheHanger_WC_Product_Cat_List_With_Icon_Walker; + $list_args['walker'] = new WC_Product_Cat_List_With_Icon_Walker; $list_args['title_li'] = ''; $list_args['pad_counts'] = 1; $list_args['show_option_none'] = __( 'No product categories exist.', 'the-hanger-extender' ); @@ -247,10 +247,10 @@ public function widget( $args, $instance ) { } } - function th_register_custom_product_categories_widget() { - register_widget( 'TheHanger_WC_Widget_Custom_Product_Categories' ); + function register_custom_product_categories_widget() { + register_widget( 'WC_Widget_Custom_Product_Categories' ); } - add_action( 'widgets_init', 'th_register_custom_product_categories_widget' ); + add_action( 'widgets_init', 'register_custom_product_categories_widget' ); } } \ No newline at end of file From 8c2b8ff0e5148741e9bb867c490013d23afbb6bd Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Wed, 29 May 2019 15:32:28 +0300 Subject: [PATCH 8/8] ... --- includes/widgets/widget-ecommerce-info.php | 156 ++++---- .../widget-product-categories-with-icon.php | 360 +++++++++--------- 2 files changed, 261 insertions(+), 255 deletions(-) diff --git a/includes/widgets/widget-ecommerce-info.php b/includes/widgets/widget-ecommerce-info.php index e2bd8aa..5354adc 100644 --- a/includes/widgets/widget-ecommerce-info.php +++ b/includes/widgets/widget-ecommerce-info.php @@ -4,98 +4,100 @@ exit; } -class eCommerce_Info_Widget extends WP_Widget { - - public function __construct() { - $this->enqueue_scripts(); - parent::__construct( - 'theme_ecommerce_info', // Base ID - __('eCommerce Info', 'the-hanger-extender'), // Name - array( 'description' => __( 'A widget that displays eCommerce Infos', 'the-hanger-extender' ), ) // Args - ); - } - - public function enqueue_scripts() { - add_action( 'wp_enqueue_scripts', function() { - wp_enqueue_style( - 'getbowtied-th-ecommerce-widget-styles', - plugins_url( 'assets/css/widget-ecommerce-info.css', __FILE__ ), - array() +if( !class_exists('eCommerce_Info_Widget') ) { + class eCommerce_Info_Widget extends WP_Widget { + + public function __construct() { + $this->enqueue_scripts(); + parent::__construct( + 'theme_ecommerce_info', // Base ID + __('eCommerce Info', 'the-hanger-extender'), // Name + array( 'description' => __( 'A widget that displays eCommerce Infos', 'the-hanger-extender' ), ) // Args ); - }); - } - - public function widget( $args, $instance ) { - $icon = apply_filters( 'widget_icon', $instance['icon'] ); - $title = apply_filters( 'widget_title', $instance['title'] ); - $subtitle = apply_filters( 'widget_subtitle', $instance['subtitle'] ); + } - print $args['before_widget']; + public function enqueue_scripts() { + add_action( 'wp_enqueue_scripts', function() { + wp_enqueue_style( + 'getbowtied-th-ecommerce-widget-styles', + plugins_url( 'assets/css/widget-ecommerce-info.css', __FILE__ ), + array() + ); + }); + } + public function widget( $args, $instance ) { + $icon = apply_filters( 'widget_icon', $instance['icon'] ); + $title = apply_filters( 'widget_title', $instance['title'] ); + $subtitle = apply_filters( 'widget_subtitle', $instance['subtitle'] ); - echo '
    '; - - if ( ! empty( $title ) ) echo '
    ' . $args['before_title'] . $title . $args['after_title'] . '
    '; - - if ( ! empty( $subtitle ) ) echo '
    ' . $subtitle .'
    '; + print $args['before_widget']; - echo '
    '; - - print $args['after_widget']; - } - public function form( $instance ) { + echo '
    '; + + if ( ! empty( $title ) ) echo '
    ' . $args['before_title'] . $title . $args['after_title'] . '
    '; + + if ( ! empty( $subtitle ) ) echo '
    ' . $subtitle .'
    '; - if ( isset( $instance[ 'icon' ] ) ) { - $icon = $instance[ 'icon' ]; - } else { - $icon = "thehanger-icons-alignment_align-all-1"; - } - - if ( isset( $instance[ 'title' ] ) ) { - $title = $instance[ 'title' ]; - } else { - $title = __( 'eCommerce Info Title', 'the-hanger-extender' ); + echo '
    '; + + print $args['after_widget']; } - if ( isset( $instance[ 'subtitle' ] ) ) { - $subtitle = $instance[ 'subtitle' ]; - } else { - $subtitle = __( 'eCommerce Info Subtitle', 'the-hanger-extender' ); + public function form( $instance ) { + + if ( isset( $instance[ 'icon' ] ) ) { + $icon = $instance[ 'icon' ]; + } else { + $icon = "thehanger-icons-alignment_align-all-1"; + } + + if ( isset( $instance[ 'title' ] ) ) { + $title = $instance[ 'title' ]; + } else { + $title = __( 'eCommerce Info Title', 'the-hanger-extender' ); + } + + if ( isset( $instance[ 'subtitle' ] ) ) { + $subtitle = $instance[ 'subtitle' ]; + } else { + $subtitle = __( 'eCommerce Info Subtitle', 'the-hanger-extender' ); + } + + ?> + +

    + +

    +

    + +

    + + +

    + +

    + + +

    + + - -

    - -

    -

    - -

    - - -

    - -

    - - -

    - - 'parent', - 'id' => 'term_id', - 'slug' => 'slug', - ); + public $db_fields = array( + 'parent' => 'parent', + 'id' => 'term_id', + 'slug' => 'slug', + ); - public function start_lvl( &$output, $depth = 0, $args = array() ) { - $indent = str_repeat( "\t", $depth ); - $output .= "$indent
      \n"; - } + public function start_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat( "\t", $depth ); + $output .= "$indent
        \n"; + } - public function end_lvl( &$output, $depth = 0, $args = array() ) { - $indent = str_repeat( "\t", $depth ); - $output .= "$indent
      \n"; - } + public function end_lvl( &$output, $depth = 0, $args = array() ) { + $indent = str_repeat( "\t", $depth ); + $output .= "$indent
    \n"; + } - public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) { + public function start_el( &$output, $cat, $depth = 0, $args = array(), $current_object_id = 0 ) { - $output .= '
  • term_id; - if ( $args['current_category'] == $cat->term_id ) { - $output .= ' current-cat'; - } + if ( $args['current_category'] == $cat->term_id ) { + $output .= ' current-cat'; + } - if ( $args['has_children'] ) { - $output .= ' cat-parent'; - $drop_icon = ''; - } else { - $drop_icon = ''; - } + if ( $args['has_children'] ) { + $output .= ' cat-parent'; + $drop_icon = ''; + } else { + $drop_icon = ''; + } - if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat->term_id, $args['current_category_ancestors'] ) ) { - $output .= ' active current-cat-parent'; - } + if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat->term_id, $args['current_category_ancestors'] ) ) { + $output .= ' active current-cat-parent'; + } - if ( $depth == 0 ) { - $cat_link_classes = 'site-secondary-font'; - } else { - $cat_link_classes = ''; - } + if ( $depth == 0 ) { + $cat_link_classes = 'site-secondary-font'; + } else { + $cat_link_classes = ''; + } - if ($args['expand_all'] == 1) { - $output .= ' active'; - } + if ($args['expand_all'] == 1) { + $output .= ' active'; + } - $icon_type = get_term_meta( $cat->term_id, 'getbowtied_icon_type', true ); - $category_icon= ''; + $icon_type = get_term_meta( $cat->term_id, 'getbowtied_icon_type', true ); + $category_icon= ''; - if ( ($icon_type == 'theme_default') || ($icon_type != 'custom_icon' && get_term_meta( $cat->term_id, 'icon_id', true )) ) { - $icon = get_term_meta( $cat->term_id, 'icon_id', true ); - $category_icon = ''; - } + if ( ($icon_type == 'theme_default') || ($icon_type != 'custom_icon' && get_term_meta( $cat->term_id, 'icon_id', true )) ) { + $icon = get_term_meta( $cat->term_id, 'icon_id', true ); + $category_icon = ''; + } - if ($icon_type == 'custom_icon') { - $thumbnail_id = get_term_meta( $cat->term_id, 'icon_img_id', true ); - if ($thumbnail_id) - $image = wp_get_attachment_thumb_url( $thumbnail_id ); - else - $image = wc_placeholder_img_src(); - // Prevent esc_url from breaking spaces in urls for image embeds - // Ref: https://core.trac.wordpress.org/ticket/23605 - $image = str_replace( ' ', '%20', $image ); - $category_icon = ''; - } + if ($icon_type == 'custom_icon') { + $thumbnail_id = get_term_meta( $cat->term_id, 'icon_img_id', true ); + if ($thumbnail_id) + $image = wp_get_attachment_thumb_url( $thumbnail_id ); + else + $image = wc_placeholder_img_src(); + // Prevent esc_url from breaking spaces in urls for image embeds + // Ref: https://core.trac.wordpress.org/ticket/23605 + $image = str_replace( ' ', '%20', $image ); + $category_icon = ''; + } - if (empty($icon_type)) { - $icon = 'thehanger-icons-alignment_align-all-1'; - $category_icon = ''; - } + if (empty($icon_type)) { + $icon = 'thehanger-icons-alignment_align-all-1'; + $category_icon = ''; + } - if ( ! empty( $args['hide_icon'] ) ) { - $category_icon = ''; - } + if ( ! empty( $args['hide_icon'] ) ) { + $category_icon = ''; + } - $output .= '">' . $category_icon . sprintf(_x( '%s', 'product category name', 'woocommerce' ), $cat->name) . ''; + $output .= '">' . $category_icon . sprintf(_x( '%s', 'product category name', 'woocommerce' ), $cat->name) . ''; - if ( $args['show_count'] ) { - $output .= ' ' . $cat->count . ''; - } + if ( $args['show_count'] ) { + $output .= ' ' . $cat->count . ''; + } - $output .= $drop_icon; - } + $output .= $drop_icon; + } - public function end_el( &$output, $cat, $depth = 0, $args = array() ) { - $output .= "
  • \n"; - } + public function end_el( &$output, $cat, $depth = 0, $args = array() ) { + $output .= "\n"; + } - public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { - if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) { - return; + public function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) { + if ( ! $element || ( 0 === $element->count && ! empty( $args[0]['hide_empty'] ) ) ) { + return; + } + parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } - parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); } } - class WC_Widget_Custom_Product_Categories extends WC_Widget { - - public $cat_ancestors; - public $current_cat; - - public function __construct() { - $this->widget_cssclass = 'woocommerce widget_product_categories_with_icon'; - $this->widget_description = __( 'A list of product categories.', 'the-hanger-extender' ); - $this->widget_id = 'woocommerce_product_categories_with_icon'; - $this->widget_name = __( 'WooCommerce product categories with icon', 'the-hanger-extender' ); - $this->settings = array( - 'orderby' => array( - 'type' => 'select', - 'std' => 'name', - 'label' => __( 'Order by', 'the-hanger-extender' ), - 'options' => array( - 'order' => __( 'Category order', 'the-hanger-extender' ), - 'name' => __( 'Name', 'the-hanger-extender' ), + if( !class_exists('WC_Widget_Custom_Product_Categories') ) { + class WC_Widget_Custom_Product_Categories extends WC_Widget { + + public $cat_ancestors; + public $current_cat; + + public function __construct() { + $this->widget_cssclass = 'woocommerce widget_product_categories_with_icon'; + $this->widget_description = __( 'A list of product categories.', 'the-hanger-extender' ); + $this->widget_id = 'woocommerce_product_categories_with_icon'; + $this->widget_name = __( 'WooCommerce product categories with icon', 'the-hanger-extender' ); + $this->settings = array( + 'orderby' => array( + 'type' => 'select', + 'std' => 'name', + 'label' => __( 'Order by', 'the-hanger-extender' ), + 'options' => array( + 'order' => __( 'Category order', 'the-hanger-extender' ), + 'name' => __( 'Name', 'the-hanger-extender' ), + ), ), - ), - 'count' => array( - 'type' => 'checkbox', - 'std' => 1, - 'label' => __( 'Show product counts', 'the-hanger-extender' ), - ), - 'hide_empty' => array( - 'type' => 'checkbox', - 'std' => 0, - 'label' => __( 'Hide empty categories', 'the-hanger-extender' ), - ), - 'hide_icon' => array( - 'type' => 'checkbox', - 'std' => 0, - 'label' => __( 'Hide category icon', 'the-hanger-extender' ), - ), - 'expand_all' => array( - 'type' => 'checkbox', - 'std' => 0, - 'label' => __( 'Expand All', 'the-hanger-extender' ), - ), - ); - - parent::__construct(); - } + 'count' => array( + 'type' => 'checkbox', + 'std' => 1, + 'label' => __( 'Show product counts', 'the-hanger-extender' ), + ), + 'hide_empty' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Hide empty categories', 'the-hanger-extender' ), + ), + 'hide_icon' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Hide category icon', 'the-hanger-extender' ), + ), + 'expand_all' => array( + 'type' => 'checkbox', + 'std' => 0, + 'label' => __( 'Expand All', 'the-hanger-extender' ), + ), + ); - public function widget( $args, $instance ) { - global $wp_query, $post; - - $count = isset( $instance['count'] ) ? $instance['count'] : $this->settings['count']['std']; - $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : $this->settings['orderby']['std']; - $hide_empty = isset( $instance['hide_empty'] ) ? $instance['hide_empty'] : $this->settings['hide_empty']['std']; - $hide_icon = isset( $instance['hide_icon'] ) ? $instance['hide_icon'] : $this->settings['hide_icon']['std']; - $expand_all = isset( $instance['expand_all'] ) ? $instance['expand_all'] : $this->settings['expand_all']['std']; - $list_args = array( 'show_count' => $count, 'taxonomy' => 'product_cat', 'hide_empty' => $hide_empty, 'hide_icon' => $hide_icon, 'expand_all' => $expand_all ); - - // Menu Order - $list_args['menu_order'] = false; - if ( 'order' === $orderby ) { - $list_args['menu_order'] = 'asc'; - } else { - $list_args['orderby'] = 'title'; + parent::__construct(); } - // Setup Current Category - $this->current_cat = false; - $this->cat_ancestors = array(); + public function widget( $args, $instance ) { + global $wp_query, $post; + + $count = isset( $instance['count'] ) ? $instance['count'] : $this->settings['count']['std']; + $orderby = isset( $instance['orderby'] ) ? $instance['orderby'] : $this->settings['orderby']['std']; + $hide_empty = isset( $instance['hide_empty'] ) ? $instance['hide_empty'] : $this->settings['hide_empty']['std']; + $hide_icon = isset( $instance['hide_icon'] ) ? $instance['hide_icon'] : $this->settings['hide_icon']['std']; + $expand_all = isset( $instance['expand_all'] ) ? $instance['expand_all'] : $this->settings['expand_all']['std']; + $list_args = array( 'show_count' => $count, 'taxonomy' => 'product_cat', 'hide_empty' => $hide_empty, 'hide_icon' => $hide_icon, 'expand_all' => $expand_all ); + + // Menu Order + $list_args['menu_order'] = false; + if ( 'order' === $orderby ) { + $list_args['menu_order'] = 'asc'; + } else { + $list_args['orderby'] = 'title'; + } + + // Setup Current Category + $this->current_cat = false; + $this->cat_ancestors = array(); - if ( is_tax( 'product_cat' ) ) { + if ( is_tax( 'product_cat' ) ) { - $this->current_cat = $wp_query->queried_object; - $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); + $this->current_cat = $wp_query->queried_object; + $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); - } elseif ( is_singular( 'product' ) ) { + } elseif ( is_singular( 'product' ) ) { - $product_category = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( 'orderby' => 'parent' ) ) ); + $product_category = wc_get_product_terms( $post->ID, 'product_cat', apply_filters( 'woocommerce_product_categories_widget_product_terms_args', array( 'orderby' => 'parent' ) ) ); - if ( ! empty( $product_category ) ) { - $this->current_cat = end( $product_category ); - $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); + if ( ! empty( $product_category ) ) { + $this->current_cat = end( $product_category ); + $this->cat_ancestors = get_ancestors( $this->current_cat->term_id, 'product_cat' ); + } } - } - $this->widget_start( $args, $instance ); + $this->widget_start( $args, $instance ); - $list_args['walker'] = new WC_Product_Cat_List_With_Icon_Walker; - $list_args['title_li'] = ''; - $list_args['pad_counts'] = 1; - $list_args['show_option_none'] = __( 'No product categories exist.', 'the-hanger-extender' ); - $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; - $list_args['current_category_ancestors'] = $this->cat_ancestors; + $list_args['walker'] = new WC_Product_Cat_List_With_Icon_Walker; + $list_args['title_li'] = ''; + $list_args['pad_counts'] = 1; + $list_args['show_option_none'] = __( 'No product categories exist.', 'the-hanger-extender' ); + $list_args['current_category'] = ( $this->current_cat ) ? $this->current_cat->term_id : ''; + $list_args['current_category_ancestors'] = $this->cat_ancestors; - echo ''; - $this->widget_end( $args ); + $this->widget_end( $args ); + } } } - function register_custom_product_categories_widget() { + function th_register_custom_product_categories_widget() { register_widget( 'WC_Widget_Custom_Product_Categories' ); } - add_action( 'widgets_init', 'register_custom_product_categories_widget' ); + add_action( 'widgets_init', 'th_register_custom_product_categories_widget' ); } } \ No newline at end of file