process_content( $description ); } } } return $description; } /** * Filter WooCommerce product category description. * * @param string $description * @param object $term * @return string */ public static function filter_woo_category_description( $description, $term ) { if ( ! is_admin() && ! empty( $description ) && Helper::get_option( 'include_product_category', false ) ) { $module = \WPEXtra\Modules\Common\TOC::instance(); if ( $module ) { return $module->process_content( $description ); } } return $description; } /** * WooCommerce: Allow SVG tags in category descriptions. * * @param array $allowed_tags * @param string $context * @return array */ public static function allow_svg_in_category_description( $allowed_tags, $context = '' ) { if ( function_exists( 'is_product_category' ) && is_product_category() && Helper::get_option( 'include_product_category', false ) ) { $allowed_tags['svg'] = array( 'width' => true, 'height' => true, 'viewbox' => true, 'xmlns' => true, 'fill' => true, 'stroke' => true, 'style' => true, 'class' => true, ); $allowed_tags['path'] = array( 'd' => true, 'fill' => true, 'stroke' => true, ); $allowed_tags['span']['style'] = true; } return $allowed_tags; } /** * Rank Math SEO TOC plugin declaration. * * @param array $toc_plugins * @return array */ public static function rank_math_compat( $toc_plugins ) { $plugin_basename = defined( 'WPEX_BASENAME' ) ? WPEX_BASENAME : 'wp-extra-pro/wp-extra.php'; $toc_plugins[ $plugin_basename ] = 'WP Extra TOC'; return $toc_plugins; } /** * Elementor compatibility. */ public static function init_elementor() { if ( class_exists( '\Elementor\Plugin' ) ) { add_action( 'elementor/frontend/after_enqueue_scripts', function() { if ( Helper::get_option( 'smooth_scroll', true ) ) { wp_enqueue_script( 'wptoc-scroll-scriptjs' ); } } ); } } /** * Divi builder excluded shortcodes. * * @param array $shortcodes * @return array */ public static function divi_excluded_shortcodes( $shortcodes ) { $shortcodes[] = 'toc'; $shortcodes[] = 'wp-toc'; return $shortcodes; } /** * Gutenberg Reusable Blocks compatibility. * * @param string $content * @return string */ public static function gutenberg_reusable_blocks( $content ) { if ( function_exists( 'do_blocks' ) ) { if ( has_block( 'easytoc/toc' ) ) { $content = str_replace( '', 'wptoctempblock', $content ); $content = do_blocks( $content ); $content = str_replace( 'wptoctempblock', '', $content ); } else { $content = do_blocks( $content ); } } return $content; } }