';
$content = str_replace($placeholder, $scriptTag, $content);
}
}
}
return $content;
}//Perfmatters Compatibility
add_filter('ez_toc_pro_inline_css','ez_toc_perfmatters_touch_css');
function ez_toc_perfmatters_touch_css($css){
if('css' == ezTOC_Option::get( 'toc_loading' ) && class_exists('Perfmatters\Config') && !empty(Perfmatters\Config::$options['assets']['delay_js']) && !empty(Perfmatters\Config::$options['assets']['fastclick'])) {
$css .= 'label > * { pointer-events:none; }';
}
return $css;
}
/**
* Woodmart + WPbakery Gallery compatibility
* @since 2.0.58
*/
function ez_toc_woodmart_gallery_fix(){
if(function_exists('woodmart_load_classes') && class_exists('Vc_Manager')){
if(!wp_style_is('el-section-title')){
wp_register_style( 'el-section-title', WOODMART_THEME_DIR.'/css/parts/el-section-title.min.css', array() ,ezTOC::VERSION );
wp_enqueue_style( 'el-section-title' );
}
if(!wp_style_is('wd-section-title-style-simple-and-brd')){
wp_register_style( 'wd-section-title-style-simple-and-brd', WOODMART_THEME_DIR.'/css/parts/el-section-title-style-simple-and-brd.min.css', array() ,ezTOC::VERSION);
wp_enqueue_style( 'wd-section-title-style-simple-and-brd' );
}
if(!wp_style_is('wd-owl-carousel')){
wp_register_style( 'wd-owl-carousel', WOODMART_THEME_DIR.'/css/parts/lib-owl-carousel.min.css', array() ,ezTOC::VERSION);
wp_enqueue_style( 'wd-owl-carousel' );
}
if(!wp_style_is('wd-image-gallery')){
wp_register_style( 'wd-image-gallery', WOODMART_THEME_DIR.'/css/parts/el-gallery.min.css', array() ,ezTOC::VERSION);
wp_enqueue_style( 'wd-image-gallery' );
}if(!wp_style_is('wd-accordion')){
wp_register_style( 'wd-accordion', WOODMART_THEME_DIR.'/css/parts/el-accordion.min.css', array() ,ezTOC::VERSION);
wp_enqueue_style( 'wd-accordion' );
}
if(!wp_style_is('wd-tabs')){
wp_register_style( 'wd-tabs', WOODMART_THEME_DIR.'/css/parts/el-tabs.min.css', array() ,ezTOC::VERSION);
wp_enqueue_style( 'wd-tabs' );
}if(!wp_style_is('wd-team-member')){
wp_register_style( 'wd-team-member', WOODMART_THEME_DIR.'/css/parts/el-team-member.min.css', array() ,ezTOC::VERSION);
wp_enqueue_style( 'wd-team-member' );
}
}
}
add_action('wp_enqueue_scripts', 'ez_toc_woodmart_gallery_fix');/**
* Ad inserter plugin compatibility
* url : https://wordpress.org/plugins/ad-inserter/
* When toc shortcode being added inside ad inserter block, it runs infinite loop. Below code is the solution for it.
* @since 2.0.62
* return boolean
*/
add_filter('ez_toc_apply_filter_status_manually', 'ez_toc_adinserter_block_has_toc_shortcode',10,1);function ez_toc_adinserter_block_has_toc_shortcode($status){
if ( in_array( 'ad-inserter/ad-inserter.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
global $block_object;
for ($block = 0; $block <= 96; $block ++) {
if(isset($block_object [$block])){
$obj = $block_object [$block];
if(is_object($obj) && is_array($obj->wp_options)){
if(has_shortcode( $obj->wp_options['code'] , 'ez-toc' ) || has_shortcode( $obj->wp_options['code'] , 'toc' )){
$status = false;
break;
}
}
}
}}
return $status;
}/**
* Current Year, Symbols and IP Shortcode compatibility
* shortcode were not being parse for heading title in elementor
* plugin url : https://wordpress.org/plugins/current-year-shortcode/
* @since 2.0.62
*/
add_filter('ez_toc_table_heading_title_anchor', 'ez_toc_parse_curreny_year_shortcode',10,1);
add_filter('ez_toc_content_heading_title', 'ez_toc_parse_curreny_year_shortcode',10,1);
add_filter('ez_toc_content_heading_title_anchor', 'ez_toc_parse_curreny_year_shortcode',10,1);function ez_toc_parse_curreny_year_shortcode($content){
if ( in_array( 'current-year-shortcode/year-kgm.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) )) {
$content = do_shortcode($content);
}
return $content;
}/** Pressbook theme Compatiblity
* @since 2.0.63
* @param bool $status The current status of applying the TOC filter.
* @return bool The updated status of applying the TOC filter.
*/
add_filter('ez_toc_apply_filter_status_manually', 'ez_toc_press_books_theme_compatibility',10,1);
function ez_toc_press_books_theme_compatibility($status){
if(function_exists('wp_get_theme')){
$active_theme = wp_get_theme();
if(!empty($active_theme) && $active_theme->get( 'Name' ) == 'McLuhan'){
$status = false;
}
}
return $status;
}/**
* Divi Builder Compatibility
* @since 2.0.64
*/
add_filter(
'ez_toc_strip_shortcodes_with_inner_content',
function( $tags_to_remove ) {
$shortcodes = array (
'et_pb_text'
);
$tags_to_remove = array_merge( $tags_to_remove, $shortcodes );
return $tags_to_remove;
});/**
* To fix icon issue in TOC for the woo category page description
* @param mixed $allowed_tags
* @return mixed
*/
function eztoc_woo_category_toc_fix($allowed_tags) {
if( function_exists('is_product_category') && is_product_category() && true == ezTOC_Option::get( '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;
}
add_filter('wp_kses_allowed_html', 'eztoc_woo_category_toc_fix', 10, 2);/*
*Compatibility for Customize Post Categories for WPBakery Page Builder plugin
*@see https://github.com/ahmedkaludi/easy-table-of-contents/issues/843
*//**
* Custom post categories for Customize Post Categories for WPBakery Page Builder plugin
* @param string $content
* @return string
*/
add_filter('ez_toc_modify_process_page_content', 'ez_toc_post_categories_for_wpbakery_page_builder', 10, 1);function ez_toc_post_categories_for_wpbakery_page_builder($content) {
if (function_exists('Vc_Manager') && function_exists('POST_CATEGORY_WPBAKERY_PAGE_BUILDER\plugin_init') && is_category( ) ) {
global $wpdb;
$template_id = ez_toc_wpbakery_get_template_id();
if($template_id){
$content = get_post_field('post_content', $template_id);
}
}
return $content;
}/**
* Start buffer for Customize Post Categories for WPBakery Page Builder plugin
*/
add_action('template_redirect', 'ez_toc_start_buffer_for_wpbakery_category');
function ez_toc_start_buffer_for_wpbakery_category() {
if (function_exists('Vc_Manager') && is_category() && function_exists('POST_CATEGORY_WPBAKERY_PAGE_BUILDER\plugin_init')) {
ob_start('ez_toc_modify_wpbakery_category_template');
}
}/**
* Modify the category template for WPBakery Page Builder with Post Categories plugin
* @param string $buffer
* @return string
*/
function ez_toc_modify_wpbakery_category_template($buffer) {
$template_id =ez_toc_wpbakery_get_template_id();
if($template_id){
$post = ezTOC::get( $template_id );
if($post){
$find = $post->getHeadings();
$replace = $post->getHeadingsWithAnchors();
if ( !empty( $find ) && !empty( $replace ) && !empty( $buffer ) ){
return mb_find_replace($find, $replace, $buffer);
}
}
}return $buffer;
}/**
* Get template id for Customize Post Categories for WPBakery Page Builder plugin
* @return mixed
*/
function ez_toc_wpbakery_get_template_id(){
global $wpdb;
$template_id = false ;
$category_id = get_queried_object_id();
$template_id = get_term_meta($category_id, 'mst_post_cat_template', true);
if( $template_id && $template_id != 'active'){
return $template_id;
}else{
$template_id = $wpdb->get_var( $wpdb->prepare("
SELECT p.ID
FROM {$wpdb->posts} p
INNER JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id
WHERE p.post_type = %s
AND p.post_status = %s
AND pm.meta_key = %s
AND pm.meta_value = %s
LIMIT 1
",
'category_wpb',
'publish',
'mst_active',
'1'
));}return $template_id;
}/**
* Add js backup fix for Customize Post Categories for WPBakery Page Builder plugin
*/
add_action('wp_footer', 'ez_toc_js_to_footer_for_wpbakery_category');
function ez_toc_js_to_footer_for_wpbakery_category() {
$js_fallback_fix = false;if (function_exists('Vc_Manager') && is_category() && function_exists('POST_CATEGORY_WPBAKERY_PAGE_BUILDER\plugin_init')) {
$template_id = ez_toc_wpbakery_get_template_id();
if ($template_id) {
$post = ezTOC::get($template_id);
if ($post) {
$find = $post->getHeadings();
$replace = $post->getHeadingsWithAnchors();
if (!empty($find) && !empty($replace)) {
$js_fallback_fix = '
document.addEventListener("DOMContentLoaded", function () {
function eztocfindAndReplaceContent(findArray, replaceArray) {
if (!Array.isArray(findArray) || !Array.isArray(replaceArray) || findArray.length !== replaceArray.length) {
console.error("The find and replace arrays must be of the same length.");
return;
}let bodyContent = document.body.innerHTML;
findArray.forEach((findText, index) => {
const replaceText = replaceArray[index];
const regex = new RegExp(findText, "g");
bodyContent = bodyContent.replace(regex, replaceText);
});document.body.innerHTML = bodyContent;
}const findArray = ' . wp_json_encode($find) . ';
const replaceArray = ' . wp_json_encode($replace) . ';
eztocfindAndReplaceContent(findArray, replaceArray);
});
';
}
}
}
} elseif (class_exists('Publisher') && is_singular()) {
$post = ezTOC::get(get_the_ID());
if ($post) {
$find = $post->getHeadings();
$replace = $post->getHeadingsWithAnchors();
if (!empty($find)) {
$js_fallback_fix = '
document.addEventListener("DOMContentLoaded", function () {function eztocExtractHeadingTexts(inputArray) {
return inputArray.map((input) => {
if (input.length <= 6) {
return "";
}
return input.substring(1, input.length - 5);
});
}
function eztocStripTags(input) {
return input.replace(/<[^>]*>.*?<\/[^>]*>/gis, \'\');
}const findArray = eztocExtractHeadingTexts(' . wp_json_encode($find) . ');
const replaceArray = eztocExtractHeadingTexts(' . wp_json_encode($replace) . ');
const elements = document.querySelectorAll(\'h1:not(:has(span.ez-toc-section)), h2:not(:has(span.ez-toc-section)), h3:not(:has(span.ez-toc-section)), h4:not(:has(span.ez-toc-section)), h5:not(:has(span.ez-toc-section)), h6:not(:has(span.ez-toc-section))\');
if(elements.length){
elements.forEach(function(item, index){
let heading_inner = item.innerHTML;
let heading_txt = eztocStripTags(heading_inner);
const find_index = findArray.indexOf(heading_txt.trim());
if (find_index !== -1){
heading_inner = heading_inner.replace(findArray[find_index],replaceArray[find_index]);
item.innerHTML = heading_inner;
}
});
}});
';
}
}
}if ($js_fallback_fix) {
?>
شركة جلي وتلميع الرخام بالمكائن الإيطالية في دبي - شركة admsco -شركة معتمدة من بلدية دبي