and as they interfere with us remove_filter('the_content', 'wpautop'); // No need to add curly codes to the content remove_filter('the_content', 'wptexturize'); pagelayer_load_shortcodes(); // Load global colors and fonts pagelayer_load_global_palette(); $pagelayer->cache['enqueue_frontend'] = true; // Load the global styles add_action('wp_head', 'pagelayer_global_js', 2); $premium_js = apply_filters('pagelayer_add_give_js', ''); $premium_css = apply_filters('pagelayer_add_give_css', ''); // Load this For audio widget do_action('pagelayer_load_audio_widget', $is_audio); if(pagelayer_enable_giver()){ $write = ''; // Dev mode - Dynamic JS and CSS if(defined('PAGELAYER_DEV') && !empty(PAGELAYER_DEV)){ $write = '&write=1'; } // Enqueue our Editor's Frontend JS wp_register_script('pagelayer-frontend', PAGELAYER_JS.'/givejs.php?give=pagelayer-frontend.js,nivo-lightbox.min.js,wow.min.js,jquery-numerator.js,simpleParallax.min.js,owl.carousel.min.js'.$premium_js.$write, array('jquery'), PAGELAYER_VERSION); // Get list of enabled icons $icons_css = ''; $icons = pagelayer_enabled_icons(); foreach($icons as $icon){ $icons_css .= ','.$icon.'.min.css'; } wp_register_style('pagelayer-frontend', PAGELAYER_CSS.'/givecss.php?give=pagelayer-frontend.css,nivo-lightbox.css,animate.min.css,owl.carousel.min.css,owl.theme.default.min.css'.$icons_css.$premium_css.$write, array(), PAGELAYER_VERSION); // Static Files }else{ wp_register_script('pagelayer-frontend', (empty($premium_js) ? PAGELAYER_JS : PAGELAYER_PRO_JS).'/combined.js', array('jquery'), PAGELAYER_VERSION); wp_register_style('pagelayer-frontend', PAGELAYER_CSS.'/combined'.(!empty($premium_css) ? '.premium' : '').'.css', array(), PAGELAYER_VERSION); } wp_enqueue_script('pagelayer-frontend'); wp_enqueue_style('pagelayer-frontend'); // Load the global styles add_action('wp_head', 'pagelayer_global_styles', 5); add_filter('body_class', 'pagelayer_body_class', 10, 2); // Load the global styles for gutenberg if(pagelayer_is_gutenberg_editor()){ add_action('admin_print_scripts', 'pagelayer_global_styles', 5); } // Load custom widgets do_action('pagelayer_custom_frontend_enqueue'); } } // Load the google and custom fonts add_action('wp_footer', 'pagelayer_enqueue_fonts', 5); function pagelayer_enqueue_fonts($suffix = '-header'){ global $pagelayer; if(empty($pagelayer->cache['enqueue_frontend'])){ return; } $url = []; $cst = []; foreach($pagelayer->css as $k => $set){ $font_family = pagelayer_isset($set, 'font-family'); if(empty($font_family)){ $key = str_replace(['_mobile', '_tablet'], '', $k); $font_family = isset($pagelayer->css[$key]['font-family'])? $pagelayer->css[$key]['font-family']: ''; } // Fetch body font if given if(!empty($font_family)){ pagelayer_load_font_family($font_family, pagelayer_isset($set, 'font-weight'), pagelayer_isset($set, 'font-style')); } } foreach($pagelayer->runtime_fonts as $font => $weights){ if(in_array($font, $pagelayer->system_fonts)){ continue; } if(strpos($font, '_plf')){ if(!in_array($font, $pagelayer->fonts_sent)){ $pagelayer->fonts_sent[] = $font; $cst[] = preg_replace('/_plf$/is', '', $font); } }else{ $v = $font.':'.implode(',', $weights); if(!in_array($v, $pagelayer->fonts_sent)){ $url[] = $v; $pagelayer->fonts_sent[] = $v; } } } // If no fonts are to be set, then we dont set if(!empty($url)){ $fonts_url = 'https://fonts.googleapis.com/css?family='.rawurlencode(implode('|', $url)); $fonts_url = apply_filters('pagelayer_google_fonts_url', $fonts_url); wp_register_style('pagelayer-google-font'.$suffix, $fonts_url, array(), PAGELAYER_VERSION); wp_enqueue_style('pagelayer-google-font'.$suffix); echo ''; } if(empty($cst)){ return; } $args = [ 'post_type' => PAGELAYER_FONT_POST_TYPE, 'status' => 'publish', 'post_name__in' => $cst ]; //var_dump($args); $query = get_posts($args); //var_dump($query); if(empty($query)){ return; } foreach($query as $font){ $meta_box_value = get_post_meta($font->ID, 'pagelayer_font_link', true); if(empty($meta_box_value)){ continue; } echo ''; } } // Load any header we have function pagelayer_global_js(){ global $pagelayer; $pagelayer_recaptch_lang = get_option('pagelayer_google_captcha_lang'); echo ''; } // We need to handle global styles function pagelayer_load_global_css(){ global $pagelayer; // Load CSS settings foreach($pagelayer->css_settings as $k => $params){ $tmp_desk = ''; foreach($pagelayer->screens as $sk => $sv){ $suffix = (!empty($sv) ? '_'.$sv : ''); $setting = empty($params['key']) ? 'pagelayer_'.$k.'_css' : $params['key']; $tmp = get_option($setting.$suffix); if($sk == 'desktop'){ $tmp_desk = $tmp; } $tmp = pagelayer_sanitize_global_style($tmp, $tmp_desk, $sk); if(empty($tmp)){ continue; } $pagelayer->css[$k.$suffix] = $tmp; } } // Backward compat for colors if(!empty($pagelayer->settings['color']['background']) && empty($pagelayer->css['body']['background-color'])){ $pagelayer->css['body']['background-color'] = $pagelayer->settings['color']['background']; } if(!empty($pagelayer->settings['color']['text']) && empty($pagelayer->css['body']['color'])){ $pagelayer->css['body']['color'] = $pagelayer->settings['color']['text']; } // Link Color if(!empty($pagelayer->settings['color']['link']) && empty($pagelayer->css['a']['color'])){ $pagelayer->css['a']['color'] = $pagelayer->settings['color']['link']; } // Link Hover Color if(!empty($pagelayer->settings['color']['link-hover']) && empty($pagelayer->css['a-hover']['color'])){ $pagelayer->css['a-hover']['color'] = $pagelayer->settings['color']['link-hover']; } // Headings Color if(!empty($pagelayer->settings['color']['heading'])){ $htmp = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']; foreach($htmp as $k => $v){ if(empty($pagelayer->css[$v]['color'])){ $pagelayer->css[$v]['color'] = $pagelayer->settings['color']['heading']; } } } // Backward compat for body font if(!empty($pagelayer->settings['body_font'])){ $pagelayer->settings['body']['font-family'] = $pagelayer->settings['body_font']; } } // We need to handle global styles function pagelayer_global_styles(){ global $pagelayer, $post; // Load css from settings pagelayer_load_global_css(); $styles = ' '; // Lets just build a temporary list of fonts so that we can add prefetch ! pagelayer_enqueue_fonts(); if(!empty($pagelayer->runtime_fonts)){ echo ' '; } echo $styles; } function pagelayer_body_class($classes, $class){ $classes[] = 'pagelayer-body'; return $classes; } // Load the live editor if needed // Changed this hook wp_enqueue_scripts to Template_include to make block theme compatibility add_action('template_include', 'pagelayer_load_live'); function pagelayer_load_live($template){ global $post, $pagelayer; $pagelayer->load_live_errors = array(); // If its not live editing then stop if(!pagelayer_is_live_iframe($pagelayer->load_live_errors)){ // Is it the live mode then lets throw an error ? if(pagelayer_optreq('pagelayer-iframe')){ add_action('wp_head', 'pagelayer_load_live_errors', 999); } return $template; } // Are you allowed to edit ? if(!pagelayer_user_can_edit($post->ID)){ return $template; } // Load the editor class include_once(PAGELAYER_DIR.'/main/live.php'); // Call the constructor $pl_editor = new PageLayer_LiveEditor(); return $template; } // Show the live errors if any function pagelayer_load_live_errors(){ global $post, $pagelayer; // Any errors ? if(empty($pagelayer->load_live_errors)){ return; } echo ''; } // If we are doing ajax and its a pagelayer ajax if(wp_doing_ajax()){ include_once(PAGELAYER_DIR.'/main/ajax.php'); } // Show the backend editor options add_action('edit_form_after_title', 'pagelayer_after_title', 10); function pagelayer_after_title(){ global $post; // Get the current screen $current_screen = get_current_screen(); // For gutenberg if(method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor()){ // Add the code in the footer add_action('admin_footer', 'pagelayer_gutenberg_after_title'); return; } // Is pagelayer supposed to edit this ? if(!pagelayer_user_can_edit($post)){ return; } $link = pagelayer_shortlink($post->ID).'&pagelayer-live=1'; echo '