Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/accelera.../template...
File: features.php
}
[8000] Fix | Delete
else{
[8001] Fix | Delete
update_post_meta( $post_id, 'amp-page-builder', $meta );
[8002] Fix | Delete
}
[8003] Fix | Delete
}
[8004] Fix | Delete
// Storing a revision of the meta field when a post is saved
[8005] Fix | Delete
function ampforwp_meta_revi_save_post( $post_id, $post ) {
[8006] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[8007] Fix | Delete
return;
[8008] Fix | Delete
}
[8009] Fix | Delete
if ( $parent_id = wp_is_post_revision( $post_id ) ) {
[8010] Fix | Delete
$parent = get_post( $parent_id );
[8011] Fix | Delete
$pb_meta = get_post_meta( $parent->ID, 'amp-page-builder', true );
[8012] Fix | Delete
if ( false !== $pb_meta ){
[8013] Fix | Delete
add_metadata( 'post', $post_id, 'amp-page-builder', $pb_meta );
[8014] Fix | Delete
}
[8015] Fix | Delete
}
[8016] Fix | Delete
}
[8017] Fix | Delete
// Post Meta Revisions #3548 -- end here --
[8018] Fix | Delete
[8019] Fix | Delete
[8020] Fix | Delete
// FOR ADMIN MENU BAR
[8021] Fix | Delete
add_action( 'pre_amp_render_post', 'ampforwp_front_admin_menu_bar' );
[8022] Fix | Delete
function ampforwp_front_admin_menu_bar(){
[8023] Fix | Delete
if( is_user_logged_in() ){
[8024] Fix | Delete
$pref = get_user_option( "show_admin_bar_front", get_current_user_id() );
[8025] Fix | Delete
if($pref==="true"){
[8026] Fix | Delete
if(class_exists('QM_Plugin') && class_exists('QM_Dispatchers') && ampforwp_get_setting('ampforwp-query-monitor')){
[8027] Fix | Delete
$dis = QM_Dispatchers::get( 'html' );
[8028] Fix | Delete
if(is_object($dis) && $dis->did_footer==false){
[8029] Fix | Delete
$dis->did_footer = true;
[8030] Fix | Delete
add_action( 'amp_post_template_head', 'ampforwp_query_monitor_script' );
[8031] Fix | Delete
add_action( 'amp_post_template_head', 'ampforwp_manual_qm_script', 11 );
[8032] Fix | Delete
}
[8033] Fix | Delete
}
[8034] Fix | Delete
add_action("ampforwp_admin_menu_bar_front", function(){
[8035] Fix | Delete
add_action('wp_before_admin_bar_render','ampforwp_add_admin_menu_front');
[8036] Fix | Delete
wp_admin_bar_render();
[8037] Fix | Delete
});
[8038] Fix | Delete
add_action( 'admin_bar_init', 'ampforwp_init_admin_bar');
[8039] Fix | Delete
add_action( 'wp_before_admin_bar_render','ampforwp_remove_before_admin_bar_redner',9);
[8040] Fix | Delete
add_action( 'admin_bar_menu', 'ampforwp_remove_admin_menu_front',999);
[8041] Fix | Delete
add_action('amp_post_template_css', 'ampforwp_head_css');
[8042] Fix | Delete
[8043] Fix | Delete
}
[8044] Fix | Delete
}
[8045] Fix | Delete
}
[8046] Fix | Delete
function ampforwp_remove_before_admin_bar_redner(){
[8047] Fix | Delete
remove_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
[8048] Fix | Delete
}
[8049] Fix | Delete
function ampforwp_init_admin_bar(){
[8050] Fix | Delete
remove_action( 'wp_head', '_admin_bar_bump_cb' );
[8051] Fix | Delete
remove_action( 'wp_head', 'wp_admin_bar_header' );
[8052] Fix | Delete
}
[8053] Fix | Delete
global $wp_filesystem;
[8054] Fix | Delete
function ampforwp_head_css(){
[8055] Fix | Delete
global $ampforwpTemplate, $redux_builder_amp, $wp_filesystem;
[8056] Fix | Delete
$css = "";
[8057] Fix | Delete
if( is_user_logged_in() ){
[8058] Fix | Delete
$pref = get_user_option( "show_admin_bar_front", get_current_user_id() );
[8059] Fix | Delete
if($pref==="true"){
[8060] Fix | Delete
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
[8061] Fix | Delete
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
[8062] Fix | Delete
$wp_filesystem = new WP_Filesystem_Direct( array() );
[8063] Fix | Delete
if(ampforwp_get_setting('ampforwp_css_tree_shaking')==1){
[8064] Fix | Delete
if(ampforwp_is_home()){
[8065] Fix | Delete
$tscss = "home";
[8066] Fix | Delete
}elseif(ampforwp_is_blog()){
[8067] Fix | Delete
$tscss = "blog";
[8068] Fix | Delete
}elseif(ampforwp_is_front_page()){
[8069] Fix | Delete
$tscss = "post-".ampforwp_get_frontpage_id();
[8070] Fix | Delete
}elseif(is_singular()){
[8071] Fix | Delete
$tscss = "post-".ampforwp_get_the_ID();
[8072] Fix | Delete
}elseif(is_archive()){
[8073] Fix | Delete
$page_id = get_queried_object_id();
[8074] Fix | Delete
$tscss = "archive-".intval($page_id);
[8075] Fix | Delete
}
[8076] Fix | Delete
$tscss = $tscss.'-admin';
[8077] Fix | Delete
$upload_dir = wp_upload_dir();
[8078] Fix | Delete
$ts_file = esc_attr($upload_dir['basedir']) . '/' . 'ampforwp-tree-shaking/_transient_'.esc_attr($tscss).".css";
[8079] Fix | Delete
if(file_exists($ts_file)){
[8080] Fix | Delete
$css = $wp_filesystem->get_contents($ts_file);
[8081] Fix | Delete
if(preg_match("/#wpadminbar/", $css)==0){
[8082] Fix | Delete
$user_dirname = $upload_dir['basedir'] . '/' . 'ampforwp-tree-shaking';
[8083] Fix | Delete
if(file_exists($user_dirname)){
[8084] Fix | Delete
$files = glob($user_dirname . '/*');
[8085] Fix | Delete
foreach($files as $file){
[8086] Fix | Delete
if(is_file($file) && strpos($file, '_transient')!==false ){
[8087] Fix | Delete
unlink($file);
[8088] Fix | Delete
}
[8089] Fix | Delete
}
[8090] Fix | Delete
}
[8091] Fix | Delete
}
[8092] Fix | Delete
}
[8093] Fix | Delete
}
[8094] Fix | Delete
$css = $wp_filesystem->get_contents(AMPFORWP_PLUGIN_DIR."/templates/template-mode/admin-bar.css");
[8095] Fix | Delete
$incurl = includes_url();
[8096] Fix | Delete
$incurl = trailingslashit($incurl) .'fonts/dashicons.ttf?50db0456fde2a241f005968eede3f987';
[8097] Fix | Delete
$css.='@font-face{font-family:dashicons;src:url('.$incurl.'/fonts/dashicons.ttf?50db0456fde2a241f005968eede3f987) format("truetype");
[8098] Fix | Delete
font-weight:400;font-style:normal}
[8099] Fix | Delete
#wp-admin-bar-my-account .avatar{float:right;margin-top:7px;margin-left:5px;height:18px;width:18px;border:1px solid #82878c}#wp-admin-bar-wpseo-notifications .yoast-issue-counter{float:right}@media(max-width:782px){#wpadminbar~header #headerwrap{top:46px}}';
[8100] Fix | Delete
if(ampforwp_get_setting('amp-design-selector')!=3){
[8101] Fix | Delete
$css.='#wpadminbar~header{margin-top:32px}@media(max-width:782px){#wpadminbar~header{margin-top:46px}}';
[8102] Fix | Delete
}else{
[8103] Fix | Delete
$css.='#wpadminbar~header #headerwrap{top:32px}@media(max-width:782px){#wpadminbar~header #headerwrap{margin-top:46px}}';
[8104] Fix | Delete
}
[8105] Fix | Delete
echo ampforwp_css_sanitizer($css);
[8106] Fix | Delete
}
[8107] Fix | Delete
}
[8108] Fix | Delete
}
[8109] Fix | Delete
function ampforwp_css_sanitizer($css){
[8110] Fix | Delete
$css = preg_replace( '/\s*!important/', '', $css, -1, $important_count );
[8111] Fix | Delete
$css = preg_replace( '/overflow(-[xy])?\s*:\s*(auto|scroll)\s*;?\s*/', '', $css, -1, $overlow_count );
[8112] Fix | Delete
$css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
[8113] Fix | Delete
$css = str_replace(array (chr(10), ' {', '{ ', ' }', '} ', '( ', ' )', ' :', ': ', ' ;', '; ', ' ,', ', ', ';}', '::-' ), array('', '{', '{', '}', '}', '(', ')', ':', ':', ';', ';', ',', ', ', '}', ' ::-'), $css);
[8114] Fix | Delete
return $css;
[8115] Fix | Delete
}
[8116] Fix | Delete
function ampforwp_get_remote_content($src){
[8117] Fix | Delete
if($src){
[8118] Fix | Delete
$arg = array( "sslverify" => false, "timeout" => 60 ) ;
[8119] Fix | Delete
$response = wp_remote_get( $src, $arg );
[8120] Fix | Delete
if ( wp_remote_retrieve_response_code($response) == 200 && is_array( $response ) ) {
[8121] Fix | Delete
$header = wp_remote_retrieve_headers($response); // array of http header lines
[8122] Fix | Delete
$contentData = wp_remote_retrieve_body($response); // use the content
[8123] Fix | Delete
return $contentData;
[8124] Fix | Delete
}
[8125] Fix | Delete
}else{
[8126] Fix | Delete
return $contentData = file_get_contents( $src );
[8127] Fix | Delete
}
[8128] Fix | Delete
return '';
[8129] Fix | Delete
}
[8130] Fix | Delete
function ampforwp_add_admin_menu_front(){
[8131] Fix | Delete
global $wp_admin_bar;
[8132] Fix | Delete
$dom = new DOMDocument();
[8133] Fix | Delete
$my_account = $wp_admin_bar->get_node('my-account');
[8134] Fix | Delete
$title = '';
[8135] Fix | Delete
if(is_object($my_account)){
[8136] Fix | Delete
$title = ampforwp_content_sanitizer($my_account->title);
[8137] Fix | Delete
}
[8138] Fix | Delete
$wp_admin_bar->add_menu( array(
[8139] Fix | Delete
'id' => 'my-account',
[8140] Fix | Delete
'title' => $title
[8141] Fix | Delete
) );
[8142] Fix | Delete
$user_info = $wp_admin_bar->get_node('user-info');
[8143] Fix | Delete
if(is_object($user_info)){
[8144] Fix | Delete
$title = $user_info->title;
[8145] Fix | Delete
}
[8146] Fix | Delete
if($title){
[8147] Fix | Delete
// To Suppress Warnings
[8148] Fix | Delete
libxml_use_internal_errors(true);
[8149] Fix | Delete
$dom->loadHTML($title);
[8150] Fix | Delete
libxml_use_internal_errors(false);
[8151] Fix | Delete
$anchors = $dom -> getElementsByTagName('img');
[8152] Fix | Delete
$src="";
[8153] Fix | Delete
foreach($anchors as $im){
[8154] Fix | Delete
$src = $im->getAttribute('src');
[8155] Fix | Delete
}
[8156] Fix | Delete
$authname = get_the_author_meta('nickname');
[8157] Fix | Delete
$title = '<span style="background: url('.esc_url($src).');background-repeat: no-repeat;height: 64px;position: absolute;width: 100px;top: 13px;left: -70px;" class="display-name"></span><span class="display-name">'.esc_html__($authname,'accelerated-mobile-pages').'<span>';
[8158] Fix | Delete
$wp_admin_bar->add_menu( array(
[8159] Fix | Delete
'id' => 'user-info',
[8160] Fix | Delete
'title' => $title
[8161] Fix | Delete
) );
[8162] Fix | Delete
if(class_exists('WPSEO_Options')){
[8163] Fix | Delete
$wp_admin_bar->add_menu( array(
[8164] Fix | Delete
'id' => 'wpseo-menu',
[8165] Fix | Delete
'title' => "SEO"
[8166] Fix | Delete
) );
[8167] Fix | Delete
}
[8168] Fix | Delete
$wp_admin_bar->remove_menu( 'ampforwp-view-amp' );
[8169] Fix | Delete
if(function_exists('autoptimize_autoload')){
[8170] Fix | Delete
$wp_admin_bar->remove_menu( 'autoptimize' );
[8171] Fix | Delete
}
[8172] Fix | Delete
if (is_preview()) {
[8173] Fix | Delete
$url = get_preview_post_link();
[8174] Fix | Delete
$wp_admin_bar->add_node(array(
[8175] Fix | Delete
'id' => 'ampforwp-view-non-amp',
[8176] Fix | Delete
'title' => 'View Non-AMP',
[8177] Fix | Delete
'href' => esc_url($url)
[8178] Fix | Delete
));
[8179] Fix | Delete
}
[8180] Fix | Delete
else{
[8181] Fix | Delete
$url = ampforwp_get_non_amp_url();
[8182] Fix | Delete
$wp_admin_bar->add_node(array(
[8183] Fix | Delete
'id' => 'ampforwp-view-non-amp',
[8184] Fix | Delete
'title' => 'View Non-AMP' ,
[8185] Fix | Delete
'href' => esc_url($url)
[8186] Fix | Delete
));
[8187] Fix | Delete
}
[8188] Fix | Delete
}
[8189] Fix | Delete
}
[8190] Fix | Delete
[8191] Fix | Delete
function ampforwp_remove_admin_menu_front($wp){
[8192] Fix | Delete
$node_arr = ['search','admin-bar-likes-widget'];
[8193] Fix | Delete
for($i=0;$i<count($node_arr);$i++){
[8194] Fix | Delete
$wp->remove_node($node_arr[$i]);
[8195] Fix | Delete
}
[8196] Fix | Delete
}
[8197] Fix | Delete
function ampforwp_manual_qm_script() {
[8198] Fix | Delete
wp_print_scripts( array(
[8199] Fix | Delete
'query-monitor',
[8200] Fix | Delete
) );
[8201] Fix | Delete
wp_print_styles( array(
[8202] Fix | Delete
'query-monitor',
[8203] Fix | Delete
) );
[8204] Fix | Delete
}
[8205] Fix | Delete
function ampforwp_query_monitor_script() {
[8206] Fix | Delete
global $wp_locale;
[8207] Fix | Delete
$qm = plugins_url();
[8208] Fix | Delete
$deps = array(
[8209] Fix | Delete
'jquery',
[8210] Fix | Delete
);
[8211] Fix | Delete
[8212] Fix | Delete
if ( defined( 'QM_NO_JQUERY' ) && QM_NO_JQUERY ) {
[8213] Fix | Delete
$deps = array();
[8214] Fix | Delete
}
[8215] Fix | Delete
[8216] Fix | Delete
$css = 'query-monitor';
[8217] Fix | Delete
if ( method_exists( 'Dark_Mode', 'is_using_dark_mode' ) && is_user_logged_in() ) {
[8218] Fix | Delete
if ( Dark_Mode::is_using_dark_mode() ) {
[8219] Fix | Delete
$css .= '-dark';
[8220] Fix | Delete
}
[8221] Fix | Delete
} elseif ( defined( 'QM_DARK_MODE' ) && QM_DARK_MODE ) {
[8222] Fix | Delete
$css .= '-dark';
[8223] Fix | Delete
}
[8224] Fix | Delete
[8225] Fix | Delete
wp_enqueue_style(
[8226] Fix | Delete
'query-monitor',
[8227] Fix | Delete
esc_attr($qm)."/query-monitor/assets/{$css}.css",
[8228] Fix | Delete
array( 'dashicons' )
[8229] Fix | Delete
);
[8230] Fix | Delete
wp_enqueue_script(
[8231] Fix | Delete
'query-monitor',
[8232] Fix | Delete
esc_attr($qm).'/query-monitor/assets/query-monitor.js',
[8233] Fix | Delete
$deps,
[8234] Fix | Delete
false
[8235] Fix | Delete
);
[8236] Fix | Delete
wp_localize_script(
[8237] Fix | Delete
'query-monitor',
[8238] Fix | Delete
'qm_number_format',
[8239] Fix | Delete
$wp_locale->number_format
[8240] Fix | Delete
);
[8241] Fix | Delete
wp_localize_script(
[8242] Fix | Delete
'query-monitor',
[8243] Fix | Delete
'qm_l10n',
[8244] Fix | Delete
array(
[8245] Fix | Delete
'ajax_error' => __( 'PHP Errors in Ajax Response', 'query-monitor' ),
[8246] Fix | Delete
'ajaxurl' => admin_url( 'admin-ajax.php' ),
[8247] Fix | Delete
'auth_nonce' => array(
[8248] Fix | Delete
'on' => wp_create_nonce( 'qm-auth-on' ),
[8249] Fix | Delete
'off' => wp_create_nonce( 'qm-auth-off' ),
[8250] Fix | Delete
'editor-set' => wp_create_nonce( 'qm-editor-set' ),
[8251] Fix | Delete
),
[8252] Fix | Delete
)
[8253] Fix | Delete
);
[8254] Fix | Delete
}
[8255] Fix | Delete
function ampforwp_get_non_amp_url(){
[8256] Fix | Delete
global $post, $wp;
[8257] Fix | Delete
$nofollow = $page = $amp_url = $non_amp_url = '';
[8258] Fix | Delete
if( true == ampforwp_get_setting('ampforwp-nofollow-view-nonamp') ){
[8259] Fix | Delete
$nofollow = 'rel=nofollow';
[8260] Fix | Delete
}
[8261] Fix | Delete
$amp_url = untrailingslashit( home_url( $wp->request ) );
[8262] Fix | Delete
$amp_url = explode('/', $amp_url);
[8263] Fix | Delete
$amp_url = array_flip($amp_url);
[8264] Fix | Delete
unset($amp_url[AMPFORWP_AMP_QUERY_VAR]);
[8265] Fix | Delete
$non_amp_url = array_flip($amp_url);
[8266] Fix | Delete
$non_amp_url = implode('/', $non_amp_url);
[8267] Fix | Delete
$query_arg_array = $wp->query_vars;
[8268] Fix | Delete
[8269] Fix | Delete
if( array_key_exists( "page" , $query_arg_array ) ) {
[8270] Fix | Delete
$page = $wp->query_vars['page'];
[8271] Fix | Delete
}
[8272] Fix | Delete
if ( $page >= '2') {
[8273] Fix | Delete
$non_amp_url = trailingslashit( $non_amp_url . '?page=' . $page);
[8274] Fix | Delete
}
[8275] Fix | Delete
if ( ampforwp_get_setting('amp-mobile-redirection') == true && ampforwp_get_setting('amp-mob-redirection-pres-link') == false) {
[8276] Fix | Delete
$non_amp_url = add_query_arg('nonamp','1',$non_amp_url);
[8277] Fix | Delete
}
[8278] Fix | Delete
else
[8279] Fix | Delete
$non_amp_url = user_trailingslashit($non_amp_url);
[8280] Fix | Delete
$mob_pres_link = false;
[8281] Fix | Delete
if(function_exists('ampforwp_mobile_redirect_preseve_link')){
[8282] Fix | Delete
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
[8283] Fix | Delete
}
[8284] Fix | Delete
if ( true == ampforwp_get_setting('ampforwp-amp-takeover') || $mob_pres_link == true) {
[8285] Fix | Delete
$non_amp_url = '';
[8286] Fix | Delete
}
[8287] Fix | Delete
if ( $non_amp_url ) {
[8288] Fix | Delete
return apply_filters('ampforwp_view_nonamp_url', $non_amp_url);
[8289] Fix | Delete
}
[8290] Fix | Delete
}
[8291] Fix | Delete
add_action( 'wp_ajax_ampforwp_set_option_panel_view', 'ampforwp_set_option_panel_view' );
[8292] Fix | Delete
function ampforwp_set_option_panel_view(){
[8293] Fix | Delete
if(!is_admin() && !current_user_can('manage_options')){
[8294] Fix | Delete
return ;
[8295] Fix | Delete
}
[8296] Fix | Delete
if(!wp_verify_nonce($_POST['verify_nonce'],'ampforwp-verify-request') ){
[8297] Fix | Delete
echo wp_json_encode(array('status'=>403,'message'=>esc_html__('user request is not allowed','accelerated-mobile-pages'))) ;
[8298] Fix | Delete
die;
[8299] Fix | Delete
}
[8300] Fix | Delete
$opt_type = intval($_POST['option_type']);
[8301] Fix | Delete
if($opt_type==1 || $opt_type==2){
[8302] Fix | Delete
$opt = get_option("ampforwp_option_panel_view_type");
[8303] Fix | Delete
if($opt){
[8304] Fix | Delete
update_option("ampforwp_option_panel_view_type", $opt_type, false);
[8305] Fix | Delete
}else{
[8306] Fix | Delete
add_option("ampforwp_option_panel_view_type", $opt_type);
[8307] Fix | Delete
}
[8308] Fix | Delete
}
[8309] Fix | Delete
}
[8310] Fix | Delete
add_action('admin_head', 'ampforwp_remove_admin_help');
[8311] Fix | Delete
if(!function_exists('ampforwp_remove_admin_help')){
[8312] Fix | Delete
function ampforwp_remove_admin_help(){
[8313] Fix | Delete
if(!is_admin() && !current_user_can('manage_options')){
[8314] Fix | Delete
return ;
[8315] Fix | Delete
}
[8316] Fix | Delete
$screen = get_current_screen();
[8317] Fix | Delete
if ( 'toplevel_page_amp_options' == $screen->base ) {
[8318] Fix | Delete
$screen->remove_help_tabs();
[8319] Fix | Delete
}
[8320] Fix | Delete
}
[8321] Fix | Delete
}
[8322] Fix | Delete
[8323] Fix | Delete
if(!function_exists('ampforwp_sassy_icon_style')){
[8324] Fix | Delete
function ampforwp_sassy_icon_style(){
[8325] Fix | Delete
global $wp_filesystem;
[8326] Fix | Delete
$css = get_transient('ampforwp_sassy_css');
[8327] Fix | Delete
if($css == false){
[8328] Fix | Delete
if(!is_object($wp_filesystem)){
[8329] Fix | Delete
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php';
[8330] Fix | Delete
require_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php';
[8331] Fix | Delete
$wp_filesystem = new WP_Filesystem_Direct( array() );
[8332] Fix | Delete
}
[8333] Fix | Delete
$css = $wp_filesystem->get_contents(AMPFORWP_PLUGIN_DIR."/includes/sassy-style.css");
[8334] Fix | Delete
set_transient('ampforwp_sassy_css', $css);
[8335] Fix | Delete
}
[8336] Fix | Delete
echo ampforwp_css_sanitizer($css);
[8337] Fix | Delete
}
[8338] Fix | Delete
}
[8339] Fix | Delete
if(function_exists('heateor_sss_run')){
[8340] Fix | Delete
add_action('amp_post_template_css', 'ampforwp_sassy_icon_style');
[8341] Fix | Delete
}
[8342] Fix | Delete
function ampforwp_nofollow_cta_header_link(){
[8343] Fix | Delete
if(true == ampforwp_get_setting('ampforwp-header-cta-link-nofollow')){
[8344] Fix | Delete
echo 'rel=nofollow';
[8345] Fix | Delete
return;
[8346] Fix | Delete
}
[8347] Fix | Delete
return false;
[8348] Fix | Delete
}
[8349] Fix | Delete
[8350] Fix | Delete
// Generating canonical url when FlexMLS plugin is active.
[8351] Fix | Delete
if(class_exists('flexmlsConnectPageSearchResults')){
[8352] Fix | Delete
add_action('pre_amp_render_post','ampforwp_flexmls_canonical');
[8353] Fix | Delete
}
[8354] Fix | Delete
function ampforwp_flexmls_canonical(){
[8355] Fix | Delete
add_filter('wpseo_canonical','ampforwp_flexmls_generate_canonical_url',99,2);
[8356] Fix | Delete
}
[8357] Fix | Delete
[8358] Fix | Delete
function ampforwp_flexmls_generate_canonical_url($canonical,$object){
[8359] Fix | Delete
$canonical = $object->model->permalink;
[8360] Fix | Delete
return esc_url($canonical);
[8361] Fix | Delete
}
[8362] Fix | Delete
// Font Selector
[8363] Fix | Delete
if( ! function_exists('ampforwp_font_selector') ) {
[8364] Fix | Delete
function ampforwp_font_selector( $container ) {
[8365] Fix | Delete
global $redux_builder_amp;
[8366] Fix | Delete
$fontFamily = '';
[8367] Fix | Delete
if(1==ampforwp_get_setting('ampforwp-google-font-switch')){
[8368] Fix | Delete
return sanitize_text_field($fontFamily);
[8369] Fix | Delete
}
[8370] Fix | Delete
if(empty($container)) {
[8371] Fix | Delete
$container = 'body';
[8372] Fix | Delete
}
[8373] Fix | Delete
if ( 'content' == $container && ampforwp_get_setting('amp_font_selector_content_single') && 1 != ampforwp_get_setting('amp_font_selector_content_single') ) {
[8374] Fix | Delete
$fontFamily = "font-family: '".ampforwp_get_setting('amp_font_selector_content_single')."';";
[8375] Fix | Delete
}
[8376] Fix | Delete
if ( 'body' == $container && ampforwp_get_setting('amp_font_selector') && 1 != ampforwp_get_setting('amp_font_selector') ) {
[8377] Fix | Delete
$fontFamily = "font-family: '".ampforwp_get_setting('amp_font_selector')."'";
[8378] Fix | Delete
}
[8379] Fix | Delete
return sanitize_text_field($fontFamily);
[8380] Fix | Delete
}
[8381] Fix | Delete
}
[8382] Fix | Delete
if(class_exists('WPSEO_Options')){
[8383] Fix | Delete
add_filter('ampforwp_the_content_last_filter','ampforwp_remove_duplicate_canonical',25);
[8384] Fix | Delete
}
[8385] Fix | Delete
function ampforwp_remove_duplicate_canonical($content){
[8386] Fix | Delete
if( class_exists( 'DOMDocument' ) && ! empty( $content ) && is_string( $content ) ){
[8387] Fix | Delete
$comp_dom = new DOMDocument();
[8388] Fix | Delete
@$comp_dom->loadHTML($content);
[8389] Fix | Delete
$xpath = new DOMXPath( $comp_dom );
[8390] Fix | Delete
$count = 0;
[8391] Fix | Delete
$nodes = $xpath->query('//link[@rel="canonical"]');
[8392] Fix | Delete
$con = '';
[8393] Fix | Delete
foreach ($nodes as $node) {
[8394] Fix | Delete
$count++;
[8395] Fix | Delete
}
[8396] Fix | Delete
if($count>1){
[8397] Fix | Delete
if(preg_match("/<link\b[^>]*?\brel=[\'\"]canonical[\'\"][^>]*>/", $content, $matches, PREG_OFFSET_CAPTURE)){
[8398] Fix | Delete
$content = preg_replace("/<link\b[^>]*?\brel=[\'\"]canonical[\'\"][^>]*>/", "", $content);
[8399] Fix | Delete
$content = substr_replace($content, $matches[0][0], $matches[0][1], 0);
[8400] Fix | Delete
}
[8401] Fix | Delete
}
[8402] Fix | Delete
}
[8403] Fix | Delete
return $content;
[8404] Fix | Delete
}
[8405] Fix | Delete
// Font URL controller
[8406] Fix | Delete
if ( ! function_exists('ampforwp_font_url') ) {
[8407] Fix | Delete
function ampforwp_font_url($font_url){
[8408] Fix | Delete
return apply_filters('ampforwp_font_url', $font_url);
[8409] Fix | Delete
}
[8410] Fix | Delete
}
[8411] Fix | Delete
//Need to add full short pixel plugin compatibility #3782
[8412] Fix | Delete
if(class_exists('ShortPixelAPI')){
[8413] Fix | Delete
add_filter( 'ampforwp_the_content_last_filter','ampforwp_short_pixel_cdn');
[8414] Fix | Delete
}
[8415] Fix | Delete
function ampforwp_short_pixel_cdn($content){
[8416] Fix | Delete
$api_url = get_option('spai_settings_api_url');
[8417] Fix | Delete
$compress_level = get_option('spai_settings_compress_level');
[8418] Fix | Delete
if('0'== $compress_level){
[8419] Fix | Delete
$compress_level = '+q_lossless';
[8420] Fix | Delete
}
[8421] Fix | Delete
if('1'== $compress_level){
[8422] Fix | Delete
$compress_level = '+q_lossy';
[8423] Fix | Delete
}
[8424] Fix | Delete
if('2'== $compress_level){
[8425] Fix | Delete
$compress_level = '+q_glossy';
[8426] Fix | Delete
}
[8427] Fix | Delete
$compress_level .= '+ret_img+to_webp/';
[8428] Fix | Delete
if(!empty($api_url)){
[8429] Fix | Delete
$content = preg_replace('/<amp-img(.*?)src="([^"]*)"(.*?)width="([^"]*)" height="([^"]*)"([^>]*)>/','<amp-img$1 src="'.$api_url.'/w_$4'.$compress_level.'$2"$3 width="$4" height="$5"$6>',$content);
[8430] Fix | Delete
}
[8431] Fix | Delete
return $content;
[8432] Fix | Delete
}
[8433] Fix | Delete
if(ampforwp_get_setting('ampforwp_css_tree_shaking') == true && ampforwp_is_gutenberg_active()){
[8434] Fix | Delete
add_action('amp_post_template_css','ampforwp_gutenberg_block_styles');
[8435] Fix | Delete
}
[8436] Fix | Delete
if(!function_exists('ampforwp_gutenberg_block_styles')){
[8437] Fix | Delete
function ampforwp_gutenberg_block_styles(){
[8438] Fix | Delete
$gutenberg_styles = $block_css = '';
[8439] Fix | Delete
ob_start();
[8440] Fix | Delete
wp_print_styles('wp-block-library');
[8441] Fix | Delete
$block_css .= ob_get_contents();
[8442] Fix | Delete
ob_end_clean();
[8443] Fix | Delete
preg_match("/href='(.*?)'/", $block_css, $matches);
[8444] Fix | Delete
$style_path = explode('?', $matches[1]);
[8445] Fix | Delete
$gutenberg_styles = get_transient('ampforwp_gutenberg_styles');
[8446] Fix | Delete
if($gutenberg_styles == false){
[8447] Fix | Delete
$response = wp_remote_get( $style_path[0] );
[8448] Fix | Delete
if( is_array( $response ) && ! is_wp_error( $response ) ){
[8449] Fix | Delete
set_transient('ampforwp_gutenberg_styles', $response['body'], 24 * HOUR_IN_SECONDS );
[8450] Fix | Delete
}
[8451] Fix | Delete
}
[8452] Fix | Delete
echo ampforwp_css_sanitizer($gutenberg_styles);
[8453] Fix | Delete
}
[8454] Fix | Delete
}
[8455] Fix | Delete
[8456] Fix | Delete
function ampforwp_is_gutenberg_active() {
[8457] Fix | Delete
$gutenberg = false;
[8458] Fix | Delete
$block_editor = false;
[8459] Fix | Delete
$use_block_editor = '';
[8460] Fix | Delete
if ( has_filter( 'replace_editor', 'gutenberg_init' ) ) {
[8461] Fix | Delete
$gutenberg = true;
[8462] Fix | Delete
}
[8463] Fix | Delete
if ( version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ) ) {
[8464] Fix | Delete
$block_editor = true;
[8465] Fix | Delete
}
[8466] Fix | Delete
if ( ! $gutenberg && ! $block_editor ) {
[8467] Fix | Delete
return false;
[8468] Fix | Delete
}
[8469] Fix | Delete
if ( !class_exists('Classic_Editor') ) {
[8470] Fix | Delete
return true;
[8471] Fix | Delete
}
[8472] Fix | Delete
$use_block_editor = ( get_option( 'classic-editor-replace' ) === 'no-replace' );
[8473] Fix | Delete
return $use_block_editor;
[8474] Fix | Delete
}
[8475] Fix | Delete
[8476] Fix | Delete
add_filter( 'amp_post_template_data', 'ampforwp_pblayout_head_scripts');
[8477] Fix | Delete
$pb_remove_script = array();
[8478] Fix | Delete
function ampforwp_pblayout_head_scripts($data){
[8479] Fix | Delete
$postId = ampforwp_get_the_ID();
[8480] Fix | Delete
$ampforwp_pagebuilder_enable = get_post_meta($postId,'ampforwp_page_builder_enable', true);
[8481] Fix | Delete
if(isset($ampforwp_pagebuilder_enable) && $ampforwp_pagebuilder_enable=="yes"){
[8482] Fix | Delete
$previousData = get_post_meta($postId,'amp-page-builder');
[8483] Fix | Delete
$previousData = isset($previousData[0])? $previousData[0]: null;
[8484] Fix | Delete
$previousData = (str_replace("'", "&apos;", $previousData));
[8485] Fix | Delete
$totalRows = 1;
[8486] Fix | Delete
$totalmodules = 1;
[8487] Fix | Delete
if(!empty($previousData)){
[8488] Fix | Delete
$jsonData = json_decode($previousData,true);
[8489] Fix | Delete
if(isset($jsonData['rows']) && count($jsonData['rows'])>0){
[8490] Fix | Delete
$totalRows = $jsonData['totalrows'];
[8491] Fix | Delete
$totalmodules = $jsonData['totalmodules'];
[8492] Fix | Delete
$previousData = wp_json_encode($jsonData);
[8493] Fix | Delete
}else{
[8494] Fix | Delete
$jsonData['rows'] = array();
[8495] Fix | Delete
$jsonData['totalrows']=1;
[8496] Fix | Delete
$jsonData['totalmodules'] = 1;
[8497] Fix | Delete
$previousData = wp_json_encode($jsonData);
[8498] Fix | Delete
}
[8499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function