From 397477f2e3dbd69520d64d592d771a316583c2e2 Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Mon, 25 Jan 2021 15:35:06 +0200 Subject: [PATCH 1/2] various fixes --- .../widget-product-categories-with-icon.php | 377 +++++++++--------- the-hanger-extender.php | 65 +-- 2 files changed, 209 insertions(+), 233 deletions(-) diff --git a/includes/widgets/widget-product-categories-with-icon.php b/includes/widgets/widget-product-categories-with-icon.php index 278d7b8..e23ba8d 100644 --- a/includes/widgets/widget-product-categories-with-icon.php +++ b/includes/widgets/widget-product-categories-with-icon.php @@ -18,245 +18,242 @@ ); }); -add_action( 'plugins_loaded', 'gbt_th_wc_widget' ); -function gbt_th_wc_widget() { - if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { +if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) { - if( !class_exists('WC_Product_Cat_List_With_Icon_Walker') ) { - class WC_Product_Cat_List_With_Icon_Walker extends Walker { + if( !class_exists('WC_Product_Cat_List_With_Icon_Walker') ) { + class WC_Product_Cat_List_With_Icon_Walker extends Walker { - public $tree_type = 'product_cat'; + public $tree_type = 'product_cat'; - 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"; + } - $output .= '
  • term_id; - if ( $args['has_children'] ) { - $output .= ' cat-parent'; - $drop_icon = ''; - } else { - $drop_icon = ''; - } + if ( $args['current_category'] == $cat->term_id ) { + $output .= ' current-cat'; + } - if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat->term_id, $args['current_category_ancestors'] ) ) { - $output .= ' active current-cat-parent'; - } + if ( $args['has_children'] ) { + $output .= ' cat-parent'; + $drop_icon = ''; + } else { + $drop_icon = ''; + } - if ( $depth == 0 ) { - $cat_link_classes = 'site-secondary-font'; - } else { - $cat_link_classes = ''; - } + if ( $args['current_category_ancestors'] && $args['current_category'] && in_array( $cat->term_id, $args['current_category_ancestors'] ) ) { + $output .= ' active current-cat-parent'; + } - if ($args['expand_all'] == 1) { - $output .= ' active'; - } + if ( $depth == 0 ) { + $cat_link_classes = 'site-secondary-font'; + } else { + $cat_link_classes = ''; + } - $icon_type = get_term_meta( $cat->term_id, 'getbowtied_icon_type', true ); - $category_icon= ''; + if ($args['expand_all'] == 1) { + $output .= ' active'; + } - 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 = ''; - } + $icon_type = get_term_meta( $cat->term_id, 'getbowtied_icon_type', 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 == '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 (empty($icon_type)) { - $icon = 'thehanger-icons-alignment_align-all-1'; - $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( $args['hide_icon'] ) ) { - $category_icon = ''; - } + if (empty($icon_type)) { + $icon = 'thehanger-icons-alignment_align-all-1'; + $category_icon = ''; + } - $output .= '">' . $category_icon . sprintf(_x( '%s', 'product category name', 'woocommerce' ), $cat->name) . ''; + if ( ! empty( $args['hide_icon'] ) ) { + $category_icon = ''; + } - if ( $args['show_count'] ) { - $output .= ' ' . $cat->count . ''; - } + $output .= '">' . $category_icon . sprintf(_x( '%s', 'product category name', 'woocommerce' ), $cat->name) . ''; - $output .= $drop_icon; + if ( $args['show_count'] ) { + $output .= ' ' . $cat->count . ''; } - public function end_el( &$output, $cat, $depth = 0, $args = array() ) { - $output .= "
  • \n"; - } + $output .= $drop_icon; + } - 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 ); + 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 ); } } + } - 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' ), + 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' ), ), - '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' ), - ), - ); + ), + '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(); - } + 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'; - } + 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(); + // 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 th_register_custom_product_categories_widget() { - register_widget( 'WC_Widget_Custom_Product_Categories' ); - } - - add_action( 'widgets_init', 'th_register_custom_product_categories_widget' ); + function th_register_custom_product_categories_widget() { + register_widget( 'WC_Widget_Custom_Product_Categories' ); } + + add_action( 'widgets_init', 'th_register_custom_product_categories_widget' ); } diff --git a/the-hanger-extender.php b/the-hanger-extender.php index 46de3b0..13fbb0e 100755 --- a/the-hanger-extender.php +++ b/the-hanger-extender.php @@ -75,56 +75,33 @@ public function __construct() { // Add Shortcodes to VC if ( defined( 'WPB_VC_VERSION' ) ) { - add_action( 'init', function() { - - // Add new WP shortcodes to VC - include_once( dirname( __FILE__ ) . '/includes/shortcodes/vc/wp/slider.php' ); - include_once( dirname( __FILE__ ) . '/includes/shortcodes/vc/wp/blog-posts.php' ); - include_once( dirname( __FILE__ ) . '/includes/shortcodes/vc/wp/custom-button.php' ); - }); + // Add new WP shortcodes to VC + include_once( dirname( __FILE__ ) . '/includes/shortcodes/vc/wp/slider.php' ); + include_once( dirname( __FILE__ ) . '/includes/shortcodes/vc/wp/blog-posts.php' ); + include_once( dirname( __FILE__ ) . '/includes/shortcodes/vc/wp/custom-button.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( dirname( __FILE__ ) . '/includes/widgets/widget-ecommerce-info.php' ); - include_once( dirname( __FILE__ ) . '/includes/widgets/widget-product-categories-with-icon.php' ); - } - - if( $theme->template == 'the-hanger' && ( $theme->version >= '1.5.2' || ( !empty($parent_theme) && $parent_theme->version >= '1.5.2' ) ) ) { - - // Customizer - include_once( dirname( __FILE__ ) . '/includes/customizer/repeater/class-th-ext-repeater-control.php' ); - include_once( dirname( __FILE__ ) . '/includes/customizer/toggle/class-control-toggle.php' ); + // Blocks + include_once( dirname( __FILE__ ) . '/includes/gbt-blocks/index.php' ); - // Addons - include_once( dirname( __FILE__ ) . '/includes/addons/woocommerce-category-header.php' ); - include_once( dirname( __FILE__ ) . '/includes/addons/woocommerce-category-icon.php' ); + // Widgets + include_once( dirname( __FILE__ ) . '/includes/widgets/widget-ecommerce-info.php' ); + include_once( dirname( __FILE__ ) . '/includes/widgets/widget-product-categories-with-icon.php' ); - // Social Media - include_once( dirname( __FILE__ ) . '/includes/social-media/class-social-media.php' ); + // Customizer + include_once( dirname( __FILE__ ) . '/includes/customizer/repeater/class-th-ext-repeater-control.php' ); + include_once( dirname( __FILE__ ) . '/includes/customizer/toggle/class-control-toggle.php' ); - // Social Sharing - include_once( dirname( __FILE__ ) . '/includes/social-sharing/class-social-sharing.php' ); - } - } + // Addons + include_once( dirname( __FILE__ ) . '/includes/addons/woocommerce-category-header.php' ); + include_once( dirname( __FILE__ ) . '/includes/addons/woocommerce-category-icon.php' ); - /** - * Loads Gutenberg blocks - * - * @return void - */ - public function gbt_th_gutenberg_blocks() { + // Social Media + include_once( dirname( __FILE__ ) . '/includes/social-media/class-social-media.php' ); - if( is_plugin_active( 'gutenberg/gutenberg.php' ) || is_wp_version('>=', '5.0') ) { - include_once( dirname( __FILE__ ) . '/includes/gbt-blocks/index.php' ); - } else { - add_action( 'admin_notices', 'gbt_th_theme_warning' ); - } + // Social Sharing + include_once( dirname( __FILE__ ) . '/includes/social-sharing/class-social-sharing.php' ); } /** @@ -141,4 +118,6 @@ public static function instance() { } endif; -$thehanger_extender = new TheHangerExtender; +add_action( 'after_setup_theme', function() { + $thehanger_extender = new TheHangerExtender; +} ); From 0cbc59fdd734371a1f5e62986c0fe321141fdc86 Mon Sep 17 00:00:00 2001 From: Vanesa Reinerth Date: Mon, 25 Jan 2021 15:36:12 +0200 Subject: [PATCH 2/2] v.1.7.1 --- README.txt | 5 ++++- core/updater/assets/plugin.json | 6 +++--- the-hanger-extender.php | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.txt b/README.txt index 5614dc4..77de572 100644 --- a/README.txt +++ b/README.txt @@ -3,7 +3,7 @@ Contributors: getbowtied, vanesareinerth, adrianlbs, traians Tags: gutenberg, blocks Requires at least: 5.0 Tested up to: 5.6 -Stable tag: 1.7.0 +Stable tag: 1.7.1 Requires PHP: 5.5.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -37,6 +37,9 @@ Companion plugin for the **The Hanger** theme. Extends the functionality by addi == Changelog == += 1.7.1 = +- Small maintenance updates + = 1.7.0 = - Small maintenance updates diff --git a/core/updater/assets/plugin.json b/core/updater/assets/plugin.json index 114f7fb..340a52d 100755 --- a/core/updater/assets/plugin.json +++ b/core/updater/assets/plugin.json @@ -1,19 +1,19 @@ { "name": "The Hanger Extender", - "version": "1.7.0", + "version": "1.7.1", "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.6", - "last_updated": "2020-12-17 12:00:00", + "last_updated": "2021-01-25 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:

    WPBakery Page Builder Elements:

    Widgets:

    Features:

    ", - "changelog": "

    1.7.0

    1.6.9

    1.6.8

    1.6.7

    1.6.6

    1.6.5

    1.6.4

    1.6.3

    1.6.2

    1.6.1

    1.6.0

    1.5.9

    1.5.8

    1.5.7

    1.5.6

    1.5.5

    1.5.4

    1.5.3

    1.5.2

    1.5.1

    1.5

    1.4

    1.3

    1.2

    1.1

    1.0

    " + "changelog": "

    1.7.1

    1.7.0

    1.6.9

    1.6.8

    1.6.7

    1.6.6

    1.6.5

    1.6.4

    1.6.3

    1.6.2

    1.6.1

    1.6.0

    1.5.9

    1.5.8

    1.5.7

    1.5.6

    1.5.5

    1.5.4

    1.5.3

    1.5.2

    1.5.1

    1.5

    1.4

    1.3

    1.2

    1.1

    1.0

    " }, "icons" : { diff --git a/the-hanger-extender.php b/the-hanger-extender.php index 13fbb0e..b85f5f7 100755 --- a/the-hanger-extender.php +++ b/the-hanger-extender.php @@ -3,7 +3,7 @@ * 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.7.0 + * Version: 1.7.1 * Author: GetBowtied * Author URI: https://getbowtied.com * Requires at least: 5.0