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
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/accelera.../includes/features
File: functions.php
<?php
[0] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[1] Fix | Delete
exit;
[2] Fix | Delete
}
[3] Fix | Delete
if(ampforwp_get_setting('amp-gdpr-compliance-switch')) {
[4] Fix | Delete
add_amp_theme_support('AMP-gdpr');
[5] Fix | Delete
}
[6] Fix | Delete
// Custom AMP Content
[7] Fix | Delete
require AMPFORWP_PLUGIN_DIR .'templates/custom-amp-content.php';
[8] Fix | Delete
// Custom AMPFORWP Sanitizers
[9] Fix | Delete
require AMPFORWP_PLUGIN_DIR .'templates/custom-sanitizer.php';
[10] Fix | Delete
// Load aq resizer only in AMP mode
[11] Fix | Delete
add_action('pre_amp_render_post','ampforwp_include_aqresizer');
[12] Fix | Delete
function ampforwp_include_aqresizer(){
[13] Fix | Delete
//Removed Jetpack Mobile theme option #2584
[14] Fix | Delete
remove_action('option_stylesheet', 'jetpack_mobile_stylesheet');
[15] Fix | Delete
require AMPFORWP_PLUGIN_DIR .'includes/vendor/aq_resizer.php';
[16] Fix | Delete
/*
[17] Fix | Delete
Enable Treeshaking
[18] Fix | Delete
*/
[19] Fix | Delete
if( ampforwp_get_setting('ampforwp_css_tree_shaking') ){
[20] Fix | Delete
add_filter('ampforwp_the_content_last_filter','ampforwp_tree_shaking_purify_amphtml',11);
[21] Fix | Delete
}
[22] Fix | Delete
}
[23] Fix | Delete
// Some Extra Styling for Admin area
[24] Fix | Delete
[25] Fix | Delete
add_action( 'admin_enqueue_scripts', 'ampforwp_add_admin_styling_amp' );
[26] Fix | Delete
function ampforwp_add_admin_styling_amp($hook_suffix){
[27] Fix | Delete
global $pagenow,$redux_builder_amp;
[28] Fix | Delete
if ('plugins.php' == $pagenow) {
[29] Fix | Delete
add_action('admin_notices', 'ampforwp_tpd_notice' );
[30] Fix | Delete
}
[31] Fix | Delete
if($hook_suffix!='toplevel_page_amp_options' ){
[32] Fix | Delete
$redux_data['frontpage']='';
[33] Fix | Delete
if( current_user_can("manage_options") && $pagenow == 'options-reading.php' && 0 == $redux_builder_amp['amp-frontpage-select-option']) {
[34] Fix | Delete
$redux_data['frontpage'] = 'false';
[35] Fix | Delete
$redux_data['admin_url'] = esc_url(admin_url("admin.php?page=amp_options&tabid=opt-text-subsection#redux_builder_amp-ampforwp-homepage-on-off-support"));
[36] Fix | Delete
}
[37] Fix | Delete
$redux_data['ampforwp-amp-takeover'] = ampforwp_get_setting('ampforwp-amp-takeover');
[38] Fix | Delete
wp_register_style( 'ampforwp_admin_css', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-style-global.css', false, AMPFORWP_VERSION );
[39] Fix | Delete
wp_enqueue_style( 'ampforwp_admin_css' );
[40] Fix | Delete
wp_register_script( 'ampforwp_admin_js', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-script-global.js', array('wp-color-picker'), AMPFORWP_VERSION );
[41] Fix | Delete
wp_localize_script( 'ampforwp_admin_js', 'ampforwp_nonce',
[42] Fix | Delete
array(
[43] Fix | Delete
'security' => wp_create_nonce( 'ampforwp-verify-request' )
[44] Fix | Delete
)
[45] Fix | Delete
);
[46] Fix | Delete
[47] Fix | Delete
$redux_data = apply_filters("ampforwp_custom_localize_data", $redux_data);
[48] Fix | Delete
wp_localize_script( 'ampforwp_admin_js', 'redux_data', $redux_data );
[49] Fix | Delete
wp_enqueue_script( 'wp-color-picker' );
[50] Fix | Delete
wp_enqueue_script( 'ampforwp_admin_js' );
[51] Fix | Delete
}
[52] Fix | Delete
}
[53] Fix | Delete
add_action( 'redux/page/redux_builder_amp/enqueue', 'ampforwp_add_admin_styling' );
[54] Fix | Delete
function ampforwp_add_admin_styling($hook_suffix){
[55] Fix | Delete
global $redux_builder_amp, $amp_ux_fields;
[56] Fix | Delete
// Style file to add or modify css inside admin area
[57] Fix | Delete
wp_register_style( 'ampforwp_admin_css', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-style.css', false, AMPFORWP_VERSION );
[58] Fix | Delete
wp_enqueue_style( 'ampforwp_admin_css' );
[59] Fix | Delete
// Admin area scripts file
[60] Fix | Delete
$dep = array('wp-color-picker');
[61] Fix | Delete
$dep = apply_filters('ampforwp_modify_script_dependency', $dep);
[62] Fix | Delete
wp_register_script( 'ampforwp_admin_js', untrailingslashit(AMPFORWP_PLUGIN_DIR_URI) . '/includes/admin-script.js', $dep , AMPFORWP_VERSION );
[63] Fix | Delete
[64] Fix | Delete
// Localize the script with new data
[65] Fix | Delete
$redux_data = array();
[66] Fix | Delete
global $pagenow;
[67] Fix | Delete
// if ('plugins.php' == $pagenow) {
[68] Fix | Delete
// add_action('admin_notices', 'ampforwp_tpd_notice' );
[69] Fix | Delete
// }
[70] Fix | Delete
if( current_user_can("manage_options")){
[71] Fix | Delete
$redux_data = $redux_builder_amp;
[72] Fix | Delete
wp_dequeue_script( 'insert-post-adschart-admin' );
[73] Fix | Delete
if(function_exists('brokers_page_template_redirect')){
[74] Fix | Delete
wp_dequeue_script( 'broker-js' );
[75] Fix | Delete
wp_dequeue_script( 'broker-min-js' );
[76] Fix | Delete
}
[77] Fix | Delete
if(function_exists('html5blank_header_scripts')){
[78] Fix | Delete
wp_dequeue_script( 'jquery-js' );
[79] Fix | Delete
}
[80] Fix | Delete
if(function_exists('megashop_setup')){
[81] Fix | Delete
wp_dequeue_script( 'adminjs' );
[82] Fix | Delete
}
[83] Fix | Delete
remove_all_actions('admin_notices');
[84] Fix | Delete
remove_all_actions('all_admin_notices');
[85] Fix | Delete
if(class_exists('WC_Ecpay_Apple_Pay')){
[86] Fix | Delete
remove_all_actions('admin_footer');
[87] Fix | Delete
}
[88] Fix | Delete
if (function_exists('wps_pf_pr_filter_register')) {
[89] Fix | Delete
wp_dequeue_script('wpspf-main-js-3');
[90] Fix | Delete
}
[91] Fix | Delete
if (function_exists('aeccglobal_setup')) {
[92] Fix | Delete
remove_action( 'admin_footer', 'js_update_show_in_slider' );
[93] Fix | Delete
}
[94] Fix | Delete
if (function_exists('appsero_init_tracker_tour_booking_manager')) {
[95] Fix | Delete
add_action( 'wp_print_scripts', 'ampforwp_dequeue_tour_booking_script', 100 );
[96] Fix | Delete
}
[97] Fix | Delete
add_action('admin_notices', 'ampforwp_dev_mode_notice');
[98] Fix | Delete
add_action('admin_notices', 'ampforwp_plugins_manager_notice');
[99] Fix | Delete
add_action('admin_notices', 'ampforwp_ampwptheme_notice');
[100] Fix | Delete
add_action('admin_notices', 'ampforwp_automattic_activation' );
[101] Fix | Delete
add_action('admin_notices', 'ampforwp_admin_notices' );
[102] Fix | Delete
add_action('admin_notices', 'ampforwp_seo_selection_notice' );
[103] Fix | Delete
add_action('admin_notices', 'ampforwp_mobile_redirection_notice' );
[104] Fix | Delete
add_action('admin_notices', 'ampforwp_category_base_remove_notice' );
[105] Fix | Delete
add_action('admin_notices', 'ampforwp_internal_feedback_notice' );
[106] Fix | Delete
add_action('admin_notices', 'ampforwp_tpd_notice' );
[107] Fix | Delete
if ( defined('AMPFORWPPRO_PLUGIN_DIR') ) {
[108] Fix | Delete
$license_info = get_option( 'ampforwppro_license_info');
[109] Fix | Delete
if (!$license_info) {
[110] Fix | Delete
add_action('admin_notices', 'ampforwp_pro_extension_manager_notice' );
[111] Fix | Delete
}
[112] Fix | Delete
}
[113] Fix | Delete
$setup_ids = array(
[114] Fix | Delete
'ampforwp-ux-website-type-section',
[115] Fix | Delete
'ampforwp-ux-need-type-section',
[116] Fix | Delete
'ampforwp-ux-analytics-section'
[117] Fix | Delete
);
[118] Fix | Delete
for($sid = 0; $sid < count($setup_ids); $sid++ ){
[119] Fix | Delete
$check = ampforwp_get_setup_info($setup_ids[$sid]);
[120] Fix | Delete
if($check == ""){
[121] Fix | Delete
add_action('admin_notices', 'ampforwp_incomplate_setup_notice' );
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
}else{
[125] Fix | Delete
$redux_data['ampforwp-amp-takeover'] = ampforwp_get_setting('ampforwp-amp-takeover');
[126] Fix | Delete
}
[127] Fix | Delete
if( current_user_can("manage_options") && $hook_suffix == 'options-reading.php' && 0 == $redux_builder_amp['amp-frontpage-select-option']) {
[128] Fix | Delete
$redux_data['frontpage'] = 'false';
[129] Fix | Delete
$redux_data['admin_url'] = esc_url(admin_url("admin.php?page=amp_options&tabid=opt-text-subsection#redux_builder_amp-ampforwp-homepage-on-off-support"));
[130] Fix | Delete
}
[131] Fix | Delete
$amp_fields = wp_json_encode($amp_ux_fields, true);
[132] Fix | Delete
$screen = get_current_screen();
[133] Fix | Delete
if ( 'toplevel_page_amp_options' == $screen->base ) {
[134] Fix | Delete
$opt = get_option("ampforwp_option_panel_view_type");
[135] Fix | Delete
wp_localize_script( 'ampforwp_admin_js', 'amp_option_panel_view', array($opt));
[136] Fix | Delete
}else{
[137] Fix | Delete
$opt = get_option("ampforwp_option_panel_view_type");
[138] Fix | Delete
if($opt==1 || $opt==2){
[139] Fix | Delete
$opt="3".intval($opt);
[140] Fix | Delete
}else{
[141] Fix | Delete
$opt = "31";
[142] Fix | Delete
}
[143] Fix | Delete
wp_localize_script( 'ampforwp_admin_js', 'amp_option_panel_view', array($opt));
[144] Fix | Delete
}
[145] Fix | Delete
wp_localize_script( 'ampforwp_admin_js', 'amp_fields', array($amp_fields));
[146] Fix | Delete
$redux_data = apply_filters("ampforwp_custom_localize_data", $redux_data);
[147] Fix | Delete
wp_localize_script( 'ampforwp_admin_js', 'redux_data', $redux_data );
[148] Fix | Delete
wp_localize_script( 'ampforwp_admin_js', 'ampforwp_nonce',
[149] Fix | Delete
array(
[150] Fix | Delete
'security' => wp_create_nonce( 'ampforwp-verify-request' )
[151] Fix | Delete
)
[152] Fix | Delete
);
[153] Fix | Delete
wp_enqueue_script( 'wp-color-picker' );
[154] Fix | Delete
wp_enqueue_script( 'ampforwp_admin_js' );
[155] Fix | Delete
}
[156] Fix | Delete
function ampforwp_dequeue_tour_booking_script() {
[157] Fix | Delete
wp_dequeue_script( 'ttbm_mp_script' );
[158] Fix | Delete
}
[159] Fix | Delete
// 96. ampforwp_is_front_page() ampforwp_is_home() and ampforwp_is_blog is created
[160] Fix | Delete
function ampforwp_is_front_page(){
[161] Fix | Delete
global $redux_builder_amp;
[162] Fix | Delete
$front_page = false;
[163] Fix | Delete
// Reading settings me frontpage set
[164] Fix | Delete
$get_front_page_reading_settings = get_option('page_on_front');
[165] Fix | Delete
[166] Fix | Delete
// Homepage support on
[167] Fix | Delete
$get_amp_homepage_settings = ampforwp_get_setting('ampforwp-homepage-on-off-support');
[168] Fix | Delete
[169] Fix | Delete
// AMP Custom front page from AMP panel
[170] Fix | Delete
$get_custom_frontpage_settings = ampforwp_get_setting('amp-frontpage-select-option');
[171] Fix | Delete
[172] Fix | Delete
// Frontpage id should be assigned
[173] Fix | Delete
if ( ampforwp_get_setting('amp-frontpage-select-option-pages') ) {
[174] Fix | Delete
$get_amp_custom_frontpage_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
[175] Fix | Delete
}
[176] Fix | Delete
// Passing Frontpage id true for polylang static pages
[177] Fix | Delete
if ( (class_exists('polylang') || class_exists('Polylang_Pro')) && function_exists('poly_archive_url') ) {
[178] Fix | Delete
if( !ampforwp_get_setting('amp-frontpage-select-option-pages') && $get_custom_frontpage_settings && 'page' === get_option( 'show_on_front' )){
[179] Fix | Delete
$get_amp_custom_frontpage_id = true;
[180] Fix | Delete
}
[181] Fix | Delete
}
[182] Fix | Delete
// TRUE: When we have "Your latest posts" in reading settings and custom frontpage in amp
[183] Fix | Delete
if ( 'posts' == get_option( 'show_on_front') && is_home() && $get_amp_homepage_settings && $get_custom_frontpage_settings)
[184] Fix | Delete
$front_page = true;
[185] Fix | Delete
[186] Fix | Delete
// TRUE: When we have " A static page" in reading settings and custom frontpage in amp
[187] Fix | Delete
if ( 'page' == get_option( 'show_on_front') && (is_home() || is_front_page()) && $get_front_page_reading_settings && $get_amp_homepage_settings && $get_custom_frontpage_settings && !empty($get_amp_custom_frontpage_id)) {
[188] Fix | Delete
[189] Fix | Delete
$front_page = true;
[190] Fix | Delete
[191] Fix | Delete
$current_page = get_queried_object();
[192] Fix | Delete
if ( $current_page ) {
[193] Fix | Delete
$current_page = $current_page->ID;
[194] Fix | Delete
}
[195] Fix | Delete
if ( get_option( 'page_for_posts') == $current_page ) {
[196] Fix | Delete
$front_page = false ;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
$front_page = apply_filters('ampforwp_is_front_page', $front_page);
[202] Fix | Delete
return $front_page;
[203] Fix | Delete
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
function ampforwp_is_home(){
[207] Fix | Delete
global $redux_builder_amp;
[208] Fix | Delete
[209] Fix | Delete
$output = false;
[210] Fix | Delete
if ( ampforwp_is_front_page() == false && ampforwp_is_blog () == false && is_home() ) {
[211] Fix | Delete
$output = true;
[212] Fix | Delete
}
[213] Fix | Delete
return $output;
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
function ampforwp_is_blog(){
[217] Fix | Delete
$get_blog_details = "";
[218] Fix | Delete
$get_blog_details = ampforwp_get_blog_details();
[219] Fix | Delete
[220] Fix | Delete
return $get_blog_details ;
[221] Fix | Delete
}
[222] Fix | Delete
// Polylang frontpage
[223] Fix | Delete
function ampforwp_polylang_front_page() {
[224] Fix | Delete
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
[225] Fix | Delete
if( is_plugin_active( 'polylang/polylang.php' ) || is_plugin_active( 'polylang-pro/polylang.php' ) ){
[226] Fix | Delete
global $polylang;
[227] Fix | Delete
$page_id = $polylang->curlang->page_on_front;
[228] Fix | Delete
$frontpage_id = get_option('page_on_front');
[229] Fix | Delete
// is_front_page is not working here so had to do this way
[230] Fix | Delete
// Check current page id with translated page id
[231] Fix | Delete
if ( function_exists('pll_get_post') && $page_id == pll_get_post($frontpage_id) && ! is_page() && ! is_single() && ! is_archive() && ! is_search() && ! ampforwp_is_blog() ){
[232] Fix | Delete
return true;
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
return false;
[236] Fix | Delete
}
[237] Fix | Delete
// Get The ID for AMP #2867
[238] Fix | Delete
function ampforwp_get_the_ID($post_id=''){
[239] Fix | Delete
$post_id = get_the_ID();
[240] Fix | Delete
if(ampforwp_is_front_page()){
[241] Fix | Delete
$post_id = ampforwp_get_frontpage_id();
[242] Fix | Delete
}
[243] Fix | Delete
if(ampforwp_is_blog()){
[244] Fix | Delete
$post_id = ampforwp_get_blog_details('id');
[245] Fix | Delete
}
[246] Fix | Delete
return $post_id;
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
// Backward Compatibility
[250] Fix | Delete
function ampforwp_correct_frontpage() {
[251] Fix | Delete
return ampforwp_get_frontpage_id();
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
//Common function to get frontpageID
[255] Fix | Delete
function ampforwp_get_frontpage_id() {
[256] Fix | Delete
$post_id = '';
[257] Fix | Delete
if ( ampforwp_is_front_page() ) {
[258] Fix | Delete
$post_id = ampforwp_get_setting('amp-frontpage-select-option-pages');
[259] Fix | Delete
}
[260] Fix | Delete
$post_id = apply_filters('ampforwp_modify_frontpage_id', $post_id);
[261] Fix | Delete
return $post_id;
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
// 27. Clean the Defer issue
[265] Fix | Delete
// TODO : Get back to this issue. #407
[266] Fix | Delete
function ampforwp_the_content_filter_full( $content_buffer ) {
[267] Fix | Delete
if ((!is_plugin_active('amp/amp.php') && function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() )
[268] Fix | Delete
||
[269] Fix | Delete
(function_exists('amp_activate') && function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() )) {
[270] Fix | Delete
$content_buffer = preg_replace("/' defer='defer/", "", $content_buffer);
[271] Fix | Delete
$content_buffer = preg_replace("/' defer onload='/", "", $content_buffer);
[272] Fix | Delete
$content_buffer = preg_replace("/' defer /", "", $content_buffer);
[273] Fix | Delete
$content_buffer = preg_replace("/onclick=[^>]*/", "", $content_buffer);
[274] Fix | Delete
$content_buffer = preg_replace("/<\\/?thrive_headline(.|\\s)*?>/",'',$content_buffer);
[275] Fix | Delete
// Remove Extra styling added by other Themes/ Plugins
[276] Fix | Delete
preg_match('/(<style(.*?)>(.*?)<\/style>)<!doctype html>/', $content_buffer, $m1);
[277] Fix | Delete
if($m1){
[278] Fix | Delete
$content_buffer = preg_replace('/(<style(.*?)>(.*?)<\/style>)<!doctype html>/','<!doctype html>',$content_buffer);
[279] Fix | Delete
}
[280] Fix | Delete
preg_match('/(<style(.*?)>(.*?)<\/style>)(\/\*)/', $content_buffer, $m2);
[281] Fix | Delete
if($m2){
[282] Fix | Delete
$content_buffer = preg_replace('/(<style(.*?)>(.*?)<\/style>)(\/\*)/','$4',$content_buffer);
[283] Fix | Delete
}
[284] Fix | Delete
$content_buffer = preg_replace("/<\\/?g(.|\\s)*?>/",'',$content_buffer);
[285] Fix | Delete
$content_buffer = preg_replace('/(<[^>]+) spellcheck="false"/', '$1', $content_buffer);
[286] Fix | Delete
$content_buffer = preg_replace('/(<[^>]+) spellcheck="true"/', '$1', $content_buffer);
[287] Fix | Delete
$content_buffer = preg_replace("/about:blank/", "#", $content_buffer);
[288] Fix | Delete
$content_buffer = preg_replace("/<script data-cfasync[^>]*>.*?<\/script>/", "", $content_buffer);
[289] Fix | Delete
$content_buffer = preg_replace('/<font(.*?)>(.*?)<\/font>/', '$2', $content_buffer);
[290] Fix | Delete
$content_buffer = preg_replace('/<ta([^a-z]*|\s(.*?))>(.*?)<\/ta>/', '$3', $content_buffer);
[291] Fix | Delete
//$content_buffer = preg_replace('/<style type=(.*?)>|\[.*?\]\s\{(.*)\}|<\/style>(?!(<\/noscript>)|(\n<\/head>)|(<noscript>))/','',$content_buffer);
[292] Fix | Delete
[293] Fix | Delete
// xlink attribute causes Validatation Issues #1149
[294] Fix | Delete
$content_buffer = preg_replace('/xlink="href"/','',$content_buffer);
[295] Fix | Delete
$content_buffer = preg_replace('/!important/', '' , $content_buffer);
[296] Fix | Delete
$content_buffer = preg_replace('/<area(.*?)>/', '', $content_buffer);
[297] Fix | Delete
// Compatibility with the footnotes plugin. #2447
[298] Fix | Delete
if(class_exists('MCI_Footnotes')){
[299] Fix | Delete
$footnote_collapse_link = '';
[300] Fix | Delete
$footnote_collapse = false;
[301] Fix | Delete
if (method_exists('MCI_Footnotes_Convert', 'toBool')) {
[302] Fix | Delete
$footnote_collapse = MCI_Footnotes_Convert::toBool(MCI_Footnotes_Settings::instance()->get(MCI_Footnotes_Settings::C_BOOL_REFERENCE_CONTAINER_COLLAPSE));
[303] Fix | Delete
}
[304] Fix | Delete
if( $footnote_collapse == true ){
[305] Fix | Delete
$footnote_collapse_link = 'on="tap:footnote_references_container.show" role="click" tabindex="1" ';
[306] Fix | Delete
$content_buffer = preg_replace( '/<div id=(.*?)footnote_references_container(.*?)\s/m','<div id=$1footnote_references_container$2 hidden ',$content_buffer);
[307] Fix | Delete
$content_buffer = preg_replace( '/<div\s(.*?)<a\s(.*?)\+(.*)/m','<div $1 <a on="tap:footnote_references_container.show" $2 + <span on="tap:footnote_references_container.hide" id="fn_span" role="click" tabindex="2" > - </span> $3',$content_buffer);
[308] Fix | Delete
}
[309] Fix | Delete
$content_buffer = preg_replace( '/<sup(.*?)id="footnote_plugin_tooltip_(.*?)"(.*?)class="footnote_plugin_tooltip_text"(.*?)>(.*?)<\/sup>/m', '
[310] Fix | Delete
<sup$1id="footnote_plugin_tooltip_$2" '.$footnote_collapse_link.' $3class="footnote_plugin_tooltip_text"$4><a href="#footnote_plugin_reference_$2" id="fn_plugin_refer" >$5</a></sup>', $content_buffer);
[311] Fix | Delete
}
[312] Fix | Delete
$content_buffer = apply_filters('ampforwp_the_content_last_filter', $content_buffer);
[313] Fix | Delete
[314] Fix | Delete
}
[315] Fix | Delete
if(function_exists('ampforwp_amp_nonamp_convert') && ampforwp_amp_nonamp_convert("", "check")){
[316] Fix | Delete
$content_buffer = ampforwp_amp_nonamp_convert($content_buffer, "filter");
[317] Fix | Delete
}
[318] Fix | Delete
return $content_buffer;
[319] Fix | Delete
}
[320] Fix | Delete
add_action('wp', function(){ ob_start('ampforwp_the_content_filter_full'); }, 999);
[321] Fix | Delete
[322] Fix | Delete
[323] Fix | Delete
// 74. Featured Image check from Custom Fields
[324] Fix | Delete
function ampforwp_is_custom_field_featured_image(){
[325] Fix | Delete
global $redux_builder_amp, $post;
[326] Fix | Delete
if(isset($redux_builder_amp['ampforwp-custom-fields-featured-image-switch'], $redux_builder_amp['ampforwp-custom-fields-featured-image']) && $redux_builder_amp['ampforwp-custom-fields-featured-image-switch'] && $redux_builder_amp['ampforwp-custom-fields-featured-image']){
[327] Fix | Delete
return true;
[328] Fix | Delete
}
[329] Fix | Delete
else
[330] Fix | Delete
return false;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
//Meta description #1013
[334] Fix | Delete
function ampforwp_generate_meta_desc($json=""){
[335] Fix | Delete
global $post, $redux_builder_amp;
[336] Fix | Delete
$desc = $post_id = '';
[337] Fix | Delete
$post_id = ampforwp_get_the_ID();
[338] Fix | Delete
if ( true == ampforwp_get_setting('ampforwp-seo-meta-desc') || !empty($json) ) {
[339] Fix | Delete
if ( ampforwp_is_home() || ampforwp_is_blog() ) {
[340] Fix | Delete
$desc = addslashes( strip_tags( get_bloginfo( 'description' ) ) );
[341] Fix | Delete
}
[342] Fix | Delete
if ( is_archive() ) {
[343] Fix | Delete
$desc = addslashes( strip_tags( get_the_archive_description() ) );
[344] Fix | Delete
}
[345] Fix | Delete
if ( is_single() || is_page() || ampforwp_is_front_page()) {
[346] Fix | Delete
if ( has_excerpt() ) {
[347] Fix | Delete
$desc = get_the_excerpt();
[348] Fix | Delete
} else {
[349] Fix | Delete
$id = ampforwp_get_the_ID();
[350] Fix | Delete
$desc = $post->post_content;
[351] Fix | Delete
}
[352] Fix | Delete
$desc = preg_replace('/\[(.*?)\]/',' ', $desc);
[353] Fix | Delete
$desc = addslashes( wp_trim_words( strip_tags( $desc ) , 15 ) );
[354] Fix | Delete
}
[355] Fix | Delete
if ( is_search() ) {
[356] Fix | Delete
$desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
[357] Fix | Delete
}
[358] Fix | Delete
// Yoast
[359] Fix | Delete
if ( class_exists('WPSEO_Frontend') && ('yoast' == ampforwp_get_setting('ampforwp-seo-selection') || 1 == ampforwp_get_setting('ampforwp-seo-selection')) && !class_exists('Yoast\\WP\\SEO\\Integrations\\Front_End_Integration')) {
[360] Fix | Delete
$front = $yoast_desc = '';
[361] Fix | Delete
$front = WPSEO_Frontend::get_instance();
[362] Fix | Delete
$yoast_desc = addslashes( strip_tags( $front->metadesc( false ) ) );
[363] Fix | Delete
// Static front page
[364] Fix | Delete
if ( ampforwp_is_front_page() ) {
[365] Fix | Delete
$post_id = ampforwp_get_frontpage_id();
[366] Fix | Delete
if ( class_exists('WPSEO_Meta') ) {
[367] Fix | Delete
$yoast_desc = addslashes( strip_tags( WPSEO_Meta::get_value('metadesc', $post_id ) ) );
[368] Fix | Delete
}
[369] Fix | Delete
}
[370] Fix | Delete
// for search
[371] Fix | Delete
if ( is_search() ) {
[372] Fix | Delete
$yoast_desc = addslashes( ampforwp_translation($redux_builder_amp['amp-translator-search-text'], 'You searched for:') . ' ' . get_search_query() );
[373] Fix | Delete
}
[374] Fix | Delete
if ( $json && false == $redux_builder_amp['ampforwp-seo-yoast-description'] ) {
[375] Fix | Delete
$yoast_desc = '';
[376] Fix | Delete
}
[377] Fix | Delete
if ( $yoast_desc ) {
[378] Fix | Delete
$desc = $yoast_desc;
[379] Fix | Delete
}
[380] Fix | Delete
}
[381] Fix | Delete
[382] Fix | Delete
// All in One SEO
[383] Fix | Delete
if ( class_exists('All_in_One_SEO_Pack') && ( 'aioseo' == ampforwp_get_setting('ampforwp-seo-selection') || 2 == ampforwp_get_setting('ampforwp-seo-selection'))) {
[384] Fix | Delete
$aisop_class = $aisop_desc = $opts = '';
[385] Fix | Delete
$aisop_class = new All_in_One_SEO_Pack();
[386] Fix | Delete
if ( ampforwp_is_home() ) {
[387] Fix | Delete
$post_id = ampforwp_get_blog_details('id');
[388] Fix | Delete
$post = get_post($post_id);
[389] Fix | Delete
}
[390] Fix | Delete
$aisop_desc = $aisop_class->get_aioseop_description($post);
[391] Fix | Delete
$opts = $aisop_class->get_current_options( array(), 'aiosp' );
[392] Fix | Delete
if ( (is_category() || is_tax() || is_tag()) && $aisop_class->show_page_description() ) {
[393] Fix | Delete
$aisop_desc = $opts['aiosp_description'];
[394] Fix | Delete
}
[395] Fix | Delete
if ( ampforwp_is_front_page() ) {
[396] Fix | Delete
$post_id = ampforwp_get_frontpage_id();
[397] Fix | Delete
$post = get_post($post_id);
[398] Fix | Delete
$aisop_desc = $aisop_class->get_post_description( $post );
[399] Fix | Delete
}
[400] Fix | Delete
if ( $aisop_desc ) {
[401] Fix | Delete
$desc = $aisop_desc;
[402] Fix | Delete
}
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
//Genesis #1013
[406] Fix | Delete
if ( function_exists('genesis_get_seo_meta_description') && 'genesis' == ampforwp_get_setting('ampforwp-seo-selection') ) {
[407] Fix | Delete
$genesis_description = '';
[408] Fix | Delete
if ( is_home() && is_front_page() && ! ampforwp_get_setting('amp-frontpage-select-option') ) {
[409] Fix | Delete
$genesis_description = genesis_get_seo_option( 'home_description' ) ? genesis_get_seo_option( 'home_description' ) : get_bloginfo( 'description' );
[410] Fix | Delete
}
[411] Fix | Delete
elseif(ampforwp_is_front_page()){
[412] Fix | Delete
$genesis_description = strip_tags(genesis_get_custom_field( '_genesis_description', intval($post_id) ));
[413] Fix | Delete
}
[414] Fix | Delete
elseif ( is_home() && get_option( 'page_for_posts' ) && get_queried_object_id() ) {
[415] Fix | Delete
$post_id = get_option( 'page_for_posts' );
[416] Fix | Delete
if ( null !== $post_id || is_singular() ) {
[417] Fix | Delete
if ( genesis_get_custom_field( '_genesis_description', intval($post_id) ) ) {
[418] Fix | Delete
$genesis_description = strip_tags(genesis_get_custom_field( '_genesis_description', intval($post_id) ));
[419] Fix | Delete
if ( $genesis_description ) {
[420] Fix | Delete
$desc = $genesis_description;
[421] Fix | Delete
}
[422] Fix | Delete
}
[423] Fix | Delete
}
[424] Fix | Delete
}
[425] Fix | Delete
elseif ( is_home() && ampforwp_get_setting('amp-frontpage-select-option') && get_option( 'page_on_front' ) ) {
[426] Fix | Delete
$post_id = get_option('page_on_front');
[427] Fix | Delete
if ( null !== $post_id || is_singular() ) {
[428] Fix | Delete
if ( genesis_get_custom_field( '_genesis_description', intval($post_id) ) ) {
[429] Fix | Delete
$genesis_description = strip_tags(genesis_get_custom_field( '_genesis_description', intval($post_id) ));
[430] Fix | Delete
}
[431] Fix | Delete
}
[432] Fix | Delete
}
[433] Fix | Delete
else {
[434] Fix | Delete
$genesis_description = genesis_get_seo_meta_description();
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
if ( $genesis_description ) {
[438] Fix | Delete
$desc = esc_html($genesis_description);
[439] Fix | Delete
}
[440] Fix | Delete
}
[441] Fix | Delete
// SEOPress #1589
[442] Fix | Delete
if ( is_plugin_active('wp-seopress/seopress.php') && 'seopress' == ampforwp_get_setting('ampforwp-seo-selection') ) {
[443] Fix | Delete
$seopress_description = $seopress_options = '';
[444] Fix | Delete
$seopress_options = get_option("seopress_titles_option_name");
[445] Fix | Delete
if ( get_post_meta($post_id,'_seopress_titles_desc',true) ) {
[446] Fix | Delete
$seopress_description = get_post_meta($post_id,'_seopress_titles_desc',true);
[447] Fix | Delete
}
[448] Fix | Delete
if ( ampforwp_is_home() || ampforwp_is_blog() ) {
[449] Fix | Delete
$seopress_variables_array = array('%%sitetitle%%','%%tagline%%');
[450] Fix | Delete
$seopress_replace_array = array( get_bloginfo('name'), get_bloginfo('description') );
[451] Fix | Delete
$seopress_description = $seopress_options['seopress_titles_home_site_desc'];
[452] Fix | Delete
$seopress_description = str_replace($seopress_variables_array, $seopress_replace_array, $seopress_description);
[453] Fix | Delete
[454] Fix | Delete
}
[455] Fix | Delete
if ( is_archive() ) {
[456] Fix | Delete
$seopress_description = get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_desc',true);
[457] Fix | Delete
}
[458] Fix | Delete
if ( $seopress_description ) {
[459] Fix | Delete
$desc = $seopress_description;
[460] Fix | Delete
}
[461] Fix | Delete
}
[462] Fix | Delete
// Rank Math SEO #2701
[463] Fix | Delete
if ( defined( 'RANK_MATH_FILE' ) && 'rank_math' == ampforwp_get_setting('ampforwp-seo-selection') ) {
[464] Fix | Delete
$rank_math_desc = RankMath\Post::get_meta( 'description', $post_id );
[465] Fix | Delete
if (ampforwp_is_home()) {
[466] Fix | Delete
$rank_math_desc = $desc;
[467] Fix | Delete
}
[468] Fix | Delete
$desc = $rank_math_desc ? $rank_math_desc : $desc;
[469] Fix | Delete
}
[470] Fix | Delete
//Bridge Qode SEO Compatibility #2538
[471] Fix | Delete
if ( function_exists('qode_header_meta') && 'bridge' == ampforwp_get_setting('ampforwp-seo-selection')){
[472] Fix | Delete
$desc = get_post_meta($post_id, "qode_seo_description", true);
[473] Fix | Delete
}
[474] Fix | Delete
// The SEO Framework
[475] Fix | Delete
if ( function_exists( 'the_seo_framework' ) && 'seo_framework' == ampforwp_get_setting('ampforwp-seo-selection') ) {
[476] Fix | Delete
$tsf_desc = $ampforwp_tsf = '';
[477] Fix | Delete
$ampforwp_tsf = \the_seo_framework();
[478] Fix | Delete
$tsf_desc = $ampforwp_tsf->get_description();
[479] Fix | Delete
if ( $tsf_desc ) {
[480] Fix | Delete
$desc = $tsf_desc;
[481] Fix | Delete
}
[482] Fix | Delete
}
[483] Fix | Delete
// strip_shortcodes strategy not working here so had to do this way
[484] Fix | Delete
// strips shortcodes
[485] Fix | Delete
$desc = preg_replace('/\[(.*?)\]/','', $desc);
[486] Fix | Delete
}
[487] Fix | Delete
return $desc;
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
// 77. AMP Blog Details
[491] Fix | Delete
if( !function_exists('ampforwp_get_blog_details') ) {
[492] Fix | Delete
function ampforwp_get_blog_details( $param = "" ) {
[493] Fix | Delete
global $redux_builder_amp;
[494] Fix | Delete
$current_url = '';
[495] Fix | Delete
$output = '';
[496] Fix | Delete
$slug = '';
[497] Fix | Delete
$title = '';
[498] Fix | Delete
$blog_id = '';
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function