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
function ampforwp_remove_default_canonical() {
[500] Fix | Delete
return false;
[501] Fix | Delete
}
[502] Fix | Delete
}
[503] Fix | Delete
[504] Fix | Delete
// 2. Custom Design
[505] Fix | Delete
[506] Fix | Delete
// Add Homepage AMP file code
[507] Fix | Delete
add_filter( 'amp_post_template_file', 'ampforwp_custom_template', 10, 3 );
[508] Fix | Delete
function ampforwp_custom_template( $file, $type, $post ) {
[509] Fix | Delete
global $redux_builder_amp;
[510] Fix | Delete
// Custom Homepage and Archive file
[511] Fix | Delete
$slug = array();
[512] Fix | Delete
$current_url_in_pieces = array();
[513] Fix | Delete
$ampforwp_custom_post_page = ampforwp_custom_post_page();
[514] Fix | Delete
[515] Fix | Delete
if ( 'single' === $type ) {
[516] Fix | Delete
// Homepage and FrontPage
[517] Fix | Delete
if ( is_home() || ( true == $redux_builder_amp['ampforwp-amp-takeover'] && is_front_page() ) ) {
[518] Fix | Delete
[519] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php';
[520] Fix | Delete
}
[521] Fix | Delete
if ( ampforwp_is_blog() ) {
[522] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/index.php';
[523] Fix | Delete
}
[524] Fix | Delete
[525] Fix | Delete
$mob_pres_link = false;
[526] Fix | Delete
if(function_exists('ampforwp_mobile_redirect_preseve_link')){
[527] Fix | Delete
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
[528] Fix | Delete
}
[529] Fix | Delete
if ( ampforwp_is_front_page() || ( (true == ampforwp_get_setting('ampforwp-amp-takeover') || $mob_pres_link == true) && is_front_page() && ampforwp_get_setting('amp-frontpage-select-option')) ) {
[530] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php';
[531] Fix | Delete
}
[532] Fix | Delete
[533] Fix | Delete
// Archive Pages
[534] Fix | Delete
if ( is_archive() && $redux_builder_amp['ampforwp-archive-support'] && 'single' === $type ) {
[535] Fix | Delete
[536] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/archive.php';
[537] Fix | Delete
}
[538] Fix | Delete
// Search pages
[539] Fix | Delete
if ( is_search() ) {
[540] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/search.php';
[541] Fix | Delete
}
[542] Fix | Delete
// 404 Pages #2042
[543] Fix | Delete
if ( is_404() && 'single' === $type ) {
[544] Fix | Delete
add_filter('ampforwp_modify_rel_url','ampforwp_404_canonical');
[545] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/404.php';
[546] Fix | Delete
}
[547] Fix | Delete
}
[548] Fix | Delete
[549] Fix | Delete
// Polylang compatibility
[550] Fix | Delete
// For Frontpage
[551] Fix | Delete
if ( 'single' === $type && ampforwp_polylang_front_page() && true == $redux_builder_amp['amp-frontpage-select-option'] ) {
[552] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/frontpage.php';
[553] Fix | Delete
}
[554] Fix | Delete
return $file;
[555] Fix | Delete
}
[556] Fix | Delete
[557] Fix | Delete
add_filter('amp_post_template_dir','ampforwp_new_dir');
[558] Fix | Delete
function ampforwp_new_dir( $dir ) {
[559] Fix | Delete
global $redux_builder_amp;
[560] Fix | Delete
if ( 1 == $redux_builder_amp['amp-design-selector'] || 2 == $redux_builder_amp['amp-design-selector'] || 3 == $redux_builder_amp['amp-design-selector'] ) {
[561] Fix | Delete
$dir = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector();
[562] Fix | Delete
}
[563] Fix | Delete
else {
[564] Fix | Delete
$dir = AMPFORWP_CUSTOM_THEME;
[565] Fix | Delete
}
[566] Fix | Delete
return $dir;
[567] Fix | Delete
}
[568] Fix | Delete
[569] Fix | Delete
//3.5
[570] Fix | Delete
add_filter( 'amp_post_template_file', 'ampforwp_empty_filter', 10, 3 );
[571] Fix | Delete
function ampforwp_empty_filter( $file, $type, $post ) {
[572] Fix | Delete
if ( 'empty-filter' === $type ) {
[573] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
[574] Fix | Delete
}
[575] Fix | Delete
return $file;
[576] Fix | Delete
}
[577] Fix | Delete
[578] Fix | Delete
// 4. Custom Header files
[579] Fix | Delete
add_filter( 'amp_post_template_file', 'ampforwp_custom_header', 10, 3 );
[580] Fix | Delete
function ampforwp_custom_header( $file, $type, $post ) {
[581] Fix | Delete
if ( 'header-bar' === $type ) {
[582] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/design-'. ampforwp_design_selector() .'/header-bar.php';
[583] Fix | Delete
}
[584] Fix | Delete
return $file;
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
// 4.1 Custom Meta-Author files
[588] Fix | Delete
add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_author', 10, 3 );
[589] Fix | Delete
function ampforwp_set_custom_meta_author( $file, $type, $post ) {
[590] Fix | Delete
if ( 'meta-author' === $type ) {
[591] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . '/templates/design-manager/empty-filter.php';
[592] Fix | Delete
}
[593] Fix | Delete
return $file;
[594] Fix | Delete
}
[595] Fix | Delete
// 4.2 Custom Meta-Taxonomy files
[596] Fix | Delete
add_filter( 'amp_post_template_file', 'ampforwp_set_custom_meta_taxonomy', 10, 3 );
[597] Fix | Delete
function ampforwp_set_custom_meta_taxonomy( $file, $type, $post ) {
[598] Fix | Delete
if ( 'meta-taxonomy' === $type ) {
[599] Fix | Delete
$file = AMPFORWP_PLUGIN_DIR . 'templates/design-manager/empty-filter.php';
[600] Fix | Delete
}
[601] Fix | Delete
return $file;
[602] Fix | Delete
}
[603] Fix | Delete
[604] Fix | Delete
// 5. Customize with Width of the site
[605] Fix | Delete
add_filter( 'amp_content_max_width', 'ampforwp_change_content_width' );
[606] Fix | Delete
function ampforwp_change_content_width( $content_max_width ) {
[607] Fix | Delete
return 1000;
[608] Fix | Delete
}
[609] Fix | Delete
[610] Fix | Delete
// 6. Add required Javascripts for extra AMP features
[611] Fix | Delete
// Code updated and added the JS proper way #336
[612] Fix | Delete
add_filter('amp_post_template_data','ampforwp_add_amp_social_share_script', 20);
[613] Fix | Delete
function ampforwp_add_amp_social_share_script( $data ){
[614] Fix | Delete
global $redux_builder_amp;
[615] Fix | Delete
$social_check = $social_check_page = false;
[616] Fix | Delete
if ( is_page() && isset($redux_builder_amp['ampforwp-page-social']) && $redux_builder_amp['ampforwp-page-social'] ) {
[617] Fix | Delete
$social_check_page = true;
[618] Fix | Delete
}
[619] Fix | Delete
if ( 4 == ampforwp_get_setting('amp-design-selector') ) {
[620] Fix | Delete
$social_check = true;
[621] Fix | Delete
}
[622] Fix | Delete
if ( '4' !== ampforwp_get_setting('amp-design-selector') && defined('AMPFORWP_DM_SOCIAL_CHECK') && 'true' === AMPFORWP_DM_SOCIAL_CHECK ) {
[623] Fix | Delete
$social_check = true;
[624] Fix | Delete
}
[625] Fix | Delete
if( ampforwp_get_setting('enable-single-social-icons') == true || defined('AMPFORWP_DM_SOCIAL_CHECK') && AMPFORWP_DM_SOCIAL_CHECK === 'true' ) {
[626] Fix | Delete
if( (is_singular() || $social_check_page ) && is_socialshare_or_socialsticky_enabled_in_ampforwp() ) {
[627] Fix | Delete
if ( empty( $data['amp_component_scripts']['amp-social-share'] ) ) {
[628] Fix | Delete
$data['amp_component_scripts']['amp-social-share'] = 'https://cdn.ampproject.org/v0/amp-social-share-0.1.js';
[629] Fix | Delete
}
[630] Fix | Delete
}
[631] Fix | Delete
}
[632] Fix | Delete
[633] Fix | Delete
// Facebook Like Script
[634] Fix | Delete
$fb_like = false;
[635] Fix | Delete
$isBBPress = (function_exists('is_bbpress') ? is_bbpress() : false );
[636] Fix | Delete
if ( true == ampforwp_get_setting('ampforwp-facebook-like-button') ){
[637] Fix | Delete
if ( is_single() && ( true == ampforwp_get_setting('enable-single-social-icons') || (true == ampforwp_get_setting('ampforwp-social-share') && $social_check) ) && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) && !$isBBPress) {
[638] Fix | Delete
$fb_like = true;
[639] Fix | Delete
}
[640] Fix | Delete
if ( is_page() && ( true == ampforwp_get_setting('ampforwp-page-sticky-social') || ( $social_check_page && !checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) ) ) ) {
[641] Fix | Delete
$fb_like = true;
[642] Fix | Delete
}
[643] Fix | Delete
if ( true == ampforwp_get_setting('enable-single-social-icons') && checkAMPforPageBuilderStatus(ampforwp_get_the_ID()) && is_singular()) {
[644] Fix | Delete
$fb_like = true;
[645] Fix | Delete
}
[646] Fix | Delete
}
[647] Fix | Delete
if ( true == $fb_like ) {
[648] Fix | Delete
if(empty($data['amp_component_scripts']['amp-facebook-like'])){
[649] Fix | Delete
$data['amp_component_scripts']['amp-facebook-like'] = 'https://cdn.ampproject.org/v0/amp-facebook-like-0.1.js';
[650] Fix | Delete
}
[651] Fix | Delete
}
[652] Fix | Delete
return $data;
[653] Fix | Delete
}
[654] Fix | Delete
[655] Fix | Delete
add_filter( 'amp_post_template_data', 'ampforwp_add_amp_related_scripts', 20 );
[656] Fix | Delete
function ampforwp_add_amp_related_scripts( $data ) {
[657] Fix | Delete
global $redux_builder_amp;
[658] Fix | Delete
// Adding Sidebar Script
[659] Fix | Delete
if ( isset($redux_builder_amp['ampforwp-amp-menu']) && $redux_builder_amp['ampforwp-amp-menu'] && 4 != $redux_builder_amp['amp-design-selector'] ) {
[660] Fix | Delete
if ( empty( $data['amp_component_scripts']['amp-sidebar'] ) ) {
[661] Fix | Delete
$data['amp_component_scripts']['amp-sidebar'] = 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js';
[662] Fix | Delete
}
[663] Fix | Delete
}
[664] Fix | Delete
return $data;
[665] Fix | Delete
}
[666] Fix | Delete
[667] Fix | Delete
// 8. Add Main tag as a Wrapper
[668] Fix | Delete
// Removed this code after moving to design manager
[669] Fix | Delete
[670] Fix | Delete
// 9. Advertisement code
[671] Fix | Delete
// Moved to ads-functions.php
[672] Fix | Delete
// 10. Analytics Area
[673] Fix | Delete
// Moved to analytics-functions.php
[674] Fix | Delete
// 11. Strip unwanted codes and tags from the_content
[675] Fix | Delete
add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content');
[676] Fix | Delete
function ampforwp_strip_invalid_content() {
[677] Fix | Delete
add_filter( 'the_content', 'ampforwp_the_content_filter', 2 );
[678] Fix | Delete
}
[679] Fix | Delete
function ampforwp_the_content_filter( $content ) {
[680] Fix | Delete
$content = preg_replace('/property=[^>]*/', '', $content);
[681] Fix | Delete
$content = preg_replace('/vocab=[^>]*/', '', $content);
[682] Fix | Delete
$content = preg_replace('/noshade=[^>]*/', '', $content);
[683] Fix | Delete
$content = preg_replace('/contenteditable=[^>]*/', '', $content);
[684] Fix | Delete
$content = preg_replace('/non-refundable=[^>]*/', '', $content);
[685] Fix | Delete
$content = preg_replace('/security=[^>]*/', '', $content);
[686] Fix | Delete
$content = preg_replace('/deposit=[^>]*/', '', $content);
[687] Fix | Delete
$content = preg_replace('/nowrap="nowrap"/', '', $content);
[688] Fix | Delete
$content = preg_replace('#<comments-count.*?>(.*?)</comments-count>#i', '', $content);
[689] Fix | Delete
$content = preg_replace('#<badge.*?>(.*?)</badge>#i', '', $content);
[690] Fix | Delete
$content = preg_replace('#<plusone.*?>(.*?)</plusone>#i', '', $content);
[691] Fix | Delete
$content = preg_replace('#<col.*?>#i', '', $content);
[692] Fix | Delete
//Removed because class is being removed from table #2699
[693] Fix | Delete
$content = preg_replace('/href="javascript:void*/', ' ', $content);
[694] Fix | Delete
// Convert the Wistia embed into URL to build amp-wistia-player and remove unnecesarry wistia code
[695] Fix | Delete
$content = preg_replace('/<script src="(https?).*(\/\/fast|support)(\.wistia\.com\/)(embed\/medias\/)([0-9|\w]+)(.*?)<\/script>/', "$1:$2$3$4$5\n", $content);
[696] Fix | Delete
$content = preg_replace('/<div class="wistia_responsive_padding" (.*?)>/', "", $content);
[697] Fix | Delete
$content = preg_replace('/<div class="wistia_responsive_wrapper" (.*?)>/', "", $content);
[698] Fix | Delete
$content = preg_replace('/<div class="wistia_embed (.*?)>/', "", $content);
[699] Fix | Delete
$content = preg_replace('/<div class="wistia_swatch" (.*?)>/', "", $content);
[700] Fix | Delete
$content = preg_replace('/<img(.*?)src="https:\/\/fast.wistia.com\/embed\/(.*?)"(.*?)\/>/', "", $content);
[701] Fix | Delete
[702] Fix | Delete
$content = preg_replace('/<script[^>]*>.*?<\/script>/i', '', $content);
[703] Fix | Delete
//for removing attributes within html tags
[704] Fix | Delete
$content = preg_replace('/(<[^>]+) onclick=".*?"/', '$1', $content);
[705] Fix | Delete
// Remove alt attribute from the div tag #2093
[706] Fix | Delete
$content = preg_replace('/<div(.*?) alt=".*?"(.*?)/', '<div $1', $content);
[707] Fix | Delete
$content = preg_replace('/(<[^>]+) ref=".*?"/', '$1', $content);
[708] Fix | Delete
$content = preg_replace('/(<[^>]+) imap=".*?"/', '$1', $content);
[709] Fix | Delete
$content = preg_replace('/(<[^>]+) spellcheck/', '$1', $content);
[710] Fix | Delete
$content = preg_replace('/<font(.*?)>(.*?)<\/font>/', '$2', $content);
[711] Fix | Delete
$content = preg_replace('/<script[^>]*>.*?<\/script>/i', '', $content);
[712] Fix | Delete
/// simpy add more elements to simply strip tag but not the content as so
[713] Fix | Delete
/// Array ("p","font");
[714] Fix | Delete
$tags_to_strip = Array("thrive_headline","type","place","state","city" );
[715] Fix | Delete
$tags_to_strip = apply_filters('ampforwp_strip_bad_tags', $tags_to_strip);
[716] Fix | Delete
foreach ($tags_to_strip as $tag)
[717] Fix | Delete
{
[718] Fix | Delete
$content = preg_replace("/<\\/?" . $tag . "(.|\\s)*?>/",'',$content);
[719] Fix | Delete
}
[720] Fix | Delete
// regex on steroids from here on
[721] Fix | Delete
$content = preg_replace('/<like\s(.*?)>(.*)<\/like>/i', '', $content);
[722] Fix | Delete
$content = preg_replace('/<g:plusone\s(.*?)>(.*)<\/g:plusone>/i', '', $content);
[723] Fix | Delete
$content = preg_replace('/imageanchor="1"/i', '', $content);
[724] Fix | Delete
$content = preg_replace('/<plusone\s(.*?)>(.*?)<\/plusone>/', '', $content);
[725] Fix | Delete
$content = preg_replace('/xml:lang=[^>]*/', '', $content);
[726] Fix | Delete
// Removing the type attribute from the <ul> (Improved after 0.9.63)
[727] Fix | Delete
$content = preg_replace('/<ul(.*?)\btype=".*?"(.*?)/','<ul $1',$content);
[728] Fix | Delete
//Convert the Twitter embed into url for better sanitization #1010
[729] Fix | Delete
$content = preg_replace("/<blockquote(\s)class=\"twitter-(.*?)\"[^>](.*?)<a href=\"(https:\/\/twitter.com\/([a-zA-Z0-9_]{1,20})\/status\/)(.*?)\">(.*?)<\/blockquote>/si", "\n$4$6", $content);
[730] Fix | Delete
// Convert the Soundcloud embed into URL to build amp-soundcloud
[731] Fix | Delete
$content = preg_replace('/<iframe .*(https?).*(\/\/api\.soundcloud\.com\/tracks\/)([0-9]+)(.*)<\/iframe>/', "$1:$2$3", $content);
[732] Fix | Delete
// for readability attibute in div tag
[733] Fix | Delete
$content = preg_replace('/readability=[^>]*/', '', $content);
[734] Fix | Delete
// removing sl-processed attribute
[735] Fix | Delete
$content = preg_replace('/(<[^>]+) sl-processed=".*?"/', '$1', $content);
[736] Fix | Delete
// ga-on
[737] Fix | Delete
$content = preg_replace('/(<[^>]+) ga-on=".*?"/', '$1', $content);
[738] Fix | Delete
// ga-event-category
[739] Fix | Delete
$content = preg_replace('/(<[^>]+) ga-event-category=".*?"/', '$1', $content);
[740] Fix | Delete
// aria-current
[741] Fix | Delete
$content = preg_replace('/(<[^>]+) aria-current=".*?"/', '$1', $content);
[742] Fix | Delete
// Gallery Break fix
[743] Fix | Delete
$content = preg_replace('/[^\[]\[gallery(.*?)ids=(.*?)\]/', '</p>[gallery$1ids=$2]</p>', $content);
[744] Fix | Delete
// value attribute from anchor tag #2262
[745] Fix | Delete
$content = preg_replace('/<a(.*?)(value=".*?")(.*?)>/', '<a$1$3>', $content);
[746] Fix | Delete
//Compatibility with Cloudflare stream. #3230
[747] Fix | Delete
$content = preg_replace('/<stream[^>]* src="(.*?)"><\/stream>/', '<amp-iframe width="175" height="100" sandbox="allow-scripts allow-same-origin" layout="responsive" allowfullscreen src="https://iframe.cloudflarestream.com/$1"></amp-iframe>', $content);
[748] Fix | Delete
//Compatibility with amp-connatix-player #3524
[749] Fix | Delete
$content = preg_replace('/<script id="(.*?)">(.*?)playerId:\s\'(.*?)\'(.*?)mediaId:\s\'(.*?)\'(.*?)<\/script>/s', '<amp-connatix-player data-player-id="$3" data-media-id = "$5" layout="responsive" width="16" height="9"></amp-connatix-player>', $content);
[750] Fix | Delete
// Fixed CSS syntax error when redgifs iframe is embedded # 4422
[751] Fix | Delete
if(preg_match("/<div\s+style='(.*?)\)'><iframe(.*?)redgifs\.com(.*?)<\/iframe>/", $content)){
[752] Fix | Delete
$content = preg_replace("/<div\s+style='(.*?)\)'><iframe(.*?)redgifs\.com(.*?)<\/iframe>/", "<div style='$1'><iframe$2redgifs.com$3</iframe>", $content);
[753] Fix | Delete
}
[754] Fix | Delete
[755] Fix | Delete
return $content;
[756] Fix | Delete
}
[757] Fix | Delete
[758] Fix | Delete
// TODO: Remove this function if it's not in use
[759] Fix | Delete
// 11.1 Strip unwanted codes and tags from wp_footer for better compatibility with Plugins
[760] Fix | Delete
if ( ! is_customize_preview() && ! ampforwp_is_non_amp("non_amp_check_convert") ) {
[761] Fix | Delete
add_action( 'pre_amp_render_post','ampforwp_strip_invalid_content_footer');
[762] Fix | Delete
}
[763] Fix | Delete
function ampforwp_strip_invalid_content_footer() {
[764] Fix | Delete
add_filter( 'wp_footer', 'ampforwp_the_content_filter_footer', 1 );
[765] Fix | Delete
}
[766] Fix | Delete
function ampforwp_the_content_filter_footer( $content ) {
[767] Fix | Delete
remove_all_actions('wp_footer');
[768] Fix | Delete
return $content;
[769] Fix | Delete
}
[770] Fix | Delete
[771] Fix | Delete
// 12. Add Logo URL in the structured metadata
[772] Fix | Delete
// Moved to structured-data-functions.php
[773] Fix | Delete
[774] Fix | Delete
// 13. Add Custom Placeholder Image for Structured Data.
[775] Fix | Delete
// if there is no image in the post, then use this image to validate Structured Data.
[776] Fix | Delete
// Moved to structured-data-functions.php
[777] Fix | Delete
[778] Fix | Delete
// 14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
[779] Fix | Delete
/**
[780] Fix | Delete
* Adds a meta box to the post editing screen for AMP on-off on specific pages
[781] Fix | Delete
*/
[782] Fix | Delete
function ampforwp_title_custom_meta() {
[783] Fix | Delete
global $redux_builder_amp;
[784] Fix | Delete
global $post_id;
[785] Fix | Delete
$post_types = ampforwp_get_all_post_types();
[786] Fix | Delete
[787] Fix | Delete
if ( $post_types && (ampforwp_role_based_access_options() == true && ( current_user_can('edit_posts') || current_user_can('edit_pages') ) ) ) { // If there are any custom public post types.
[788] Fix | Delete
[789] Fix | Delete
foreach ( $post_types as $post_type ) {
[790] Fix | Delete
[791] Fix | Delete
if( $post_type == 'amp-cta' || $post_type == 'amp-optin' ) {
[792] Fix | Delete
continue;
[793] Fix | Delete
}
[794] Fix | Delete
// Posts
[795] Fix | Delete
if( ampforwp_get_setting('amp-on-off-for-all-posts') && $post_type == 'post' ) {
[796] Fix | Delete
add_meta_box( 'ampforwp_title_meta', esc_html__( 'Show AMP for Current Post?','accelerated-mobile-pages' ), 'ampforwp_title_callback', 'post','side' );
[797] Fix | Delete
}
[798] Fix | Delete
// Pages
[799] Fix | Delete
$frontpage_id = ampforwp_get_the_ID();
[800] Fix | Delete
$page_for_posts = intval(get_option( 'page_for_posts' ));
[801] Fix | Delete
if( ampforwp_get_setting('amp-on-off-for-all-pages') && $post_type == 'page' || ( true == ampforwp_get_setting('amp-frontpage-select-option') && $post_id == $frontpage_id ) || ($post_id == $page_for_posts)) {
[802] Fix | Delete
add_meta_box( 'ampforwp_title_meta', esc_html__( 'Show AMP for Current Page?' ,'accelerated-mobile-pages'), 'ampforwp_title_callback','page','side' );
[803] Fix | Delete
}
[804] Fix | Delete
// Custom Post Types
[805] Fix | Delete
if( $post_type !== 'page' && $post_type !== 'post' ) {
[806] Fix | Delete
add_meta_box( 'ampforwp_title_meta', esc_html__( 'Show AMP for Current Page?','accelerated-mobile-pages' ), 'ampforwp_title_callback', $post_type,'side' );
[807] Fix | Delete
}
[808] Fix | Delete
[809] Fix | Delete
}
[810] Fix | Delete
[811] Fix | Delete
}
[812] Fix | Delete
}
[813] Fix | Delete
[814] Fix | Delete
add_action( 'add_meta_boxes', 'ampforwp_title_custom_meta' );
[815] Fix | Delete
[816] Fix | Delete
/**
[817] Fix | Delete
* Outputs the content of the meta box for AMP on-off on specific pages
[818] Fix | Delete
*/
[819] Fix | Delete
function ampforwp_title_callback( $post ) {
[820] Fix | Delete
global $redux_builder_amp;
[821] Fix | Delete
wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' );
[822] Fix | Delete
$ampforwp_stored_meta = get_post_meta( $post->ID );
[823] Fix | Delete
$hide_show = '';
[824] Fix | Delete
if(isset($ampforwp_stored_meta['ampforwp-amp-on-off'])){
[825] Fix | Delete
$hide_show = $ampforwp_stored_meta['ampforwp-amp-on-off'];
[826] Fix | Delete
}else{
[827] Fix | Delete
$hide_show = ampforwp_get_setting('amp-pages-meta-default');
[828] Fix | Delete
}
[829] Fix | Delete
if(!isset($ampforwp_stored_meta['ampforwp-amp-on-off'])){
[830] Fix | Delete
$ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'default';
[831] Fix | Delete
}
[832] Fix | Delete
$preview_query_args = array();
[833] Fix | Delete
$preview_link = $list_of_posts = $skip_this_post = '';
[834] Fix | Delete
$preview_query_args = array(AMPFORWP_AMP_QUERY_VAR => 1);
[835] Fix | Delete
$preview_link = get_preview_post_link($post, $preview_query_args );
[836] Fix | Delete
$exclude_post_value = array();
[837] Fix | Delete
if ( ampforwp_posts_to_remove() && $post->post_type == 'post' ) {
[838] Fix | Delete
$ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'hide-amp';
[839] Fix | Delete
}
[840] Fix | Delete
$exclude_post_value = ampforwp_exclude_posts();
[841] Fix | Delete
// if hide-amp is selected, add it in the $exclude_post_value
[842] Fix | Delete
if ( 'hide-amp' == ( isset($ampforwp_stored_meta['ampforwp-amp-on-off'][0]) && $ampforwp_stored_meta['ampforwp-amp-on-off'][0] ) && 'page' != $post->post_type ) {
[843] Fix | Delete
if ( ! in_array($post->ID, $exclude_post_value) ) {
[844] Fix | Delete
$exclude_post_value[] = $post->ID;
[845] Fix | Delete
set_transient('ampforwp_exclude_post_transient', $exclude_post_value);
[846] Fix | Delete
}
[847] Fix | Delete
}
[848] Fix | Delete
if ( ( 'default' == ( isset($ampforwp_stored_meta['ampforwp-amp-on-off'][0]) && $ampforwp_stored_meta['ampforwp-amp-on-off'][0] ) || !isset($ampforwp_stored_meta['ampforwp-amp-on-off'][0]) ) && 'page' != $post->post_type ) {
[849] Fix | Delete
if ( in_array($post->ID, $exclude_post_value) ) {
[850] Fix | Delete
$exclude_post_value = array_flip($exclude_post_value);
[851] Fix | Delete
unset($exclude_post_value[$post->ID] );
[852] Fix | Delete
$exclude_post_value = array_flip($exclude_post_value);
[853] Fix | Delete
set_transient('ampforwp_exclude_post_transient', $exclude_post_value);
[854] Fix | Delete
}
[855] Fix | Delete
}
[856] Fix | Delete
if ($post->post_type == 'page' && ampforwp_get_setting('amp-pages-meta-default') == 'hide' && ($hide_show=='hide' || $hide_show=='hide-amp')) {
[857] Fix | Delete
$ampforwp_stored_meta['ampforwp-amp-on-off'][0] = 'hide-amp';
[858] Fix | Delete
}?>
[859] Fix | Delete
<p>
[860] Fix | Delete
<div class="prfx-row-content">
[861] Fix | Delete
<label class="meta-radio-two" for="ampforwp-on-off-meta-radio-one">
[862] Fix | Delete
<input type="radio" name="ampforwp-amp-on-off" id="ampforwp-on-off-meta-radio-one" value="default" checked="checked" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-amp-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-amp-on-off'][0], 'default' ); ?>>
[863] Fix | Delete
<?php esc_html_e( 'Show', 'accelerated-mobile-pages' )?>
[864] Fix | Delete
</label>
[865] Fix | Delete
<label class="meta-radio-two" for="ampforwp-on-off-meta-radio-two">
[866] Fix | Delete
<input type="radio" name="ampforwp-amp-on-off" id="ampforwp-on-off-meta-radio-two" value="hide-amp" <?php if ( isset ( $ampforwp_stored_meta['ampforwp-amp-on-off'] ) ) checked( $ampforwp_stored_meta['ampforwp-amp-on-off'][0], 'hide-amp' ); ?>>
[867] Fix | Delete
<?php esc_html_e( 'Hide', 'accelerated-mobile-pages' )?>
[868] Fix | Delete
</label>
[869] Fix | Delete
<?php
[870] Fix | Delete
if($post->post_status == 'publish') {
[871] Fix | Delete
add_thickbox(); ?>
[872] Fix | Delete
<div class="ampforwp-preview-button-container">
[873] Fix | Delete
<input alt="#TB_inline?height=1135&amp;width=718&amp;inlineId=ampforwp_preview" title="AMP Mobile Preview" class="thickbox ampforwp-preview-button preview button amp-preview-button" type="button" value="Preview AMP" />
[874] Fix | Delete
</div>
[875] Fix | Delete
<?php } ?>
[876] Fix | Delete
</div>
[877] Fix | Delete
</p>
[878] Fix | Delete
<!-- AMP Preview -->
[879] Fix | Delete
<div id="ampforwp_preview" style="display:none">
[880] Fix | Delete
<div id="ampforwp-preview-format">
[881] Fix | Delete
<div class="row">
[882] Fix | Delete
<div class="col-sm-12 margin-top-bottom text-center">
[883] Fix | Delete
<div class="ampforwp-preview-phone-frame-wrapper">
[884] Fix | Delete
<div class="ampforwp-preview-phone-frame">
[885] Fix | Delete
<div class="ampforwp-preview-container" id="amp-preview-iframe" data-src="<?php echo $preview_link; ?>">
[886] Fix | Delete
</div>
[887] Fix | Delete
</div>
[888] Fix | Delete
</div>
[889] Fix | Delete
</div>
[890] Fix | Delete
</div>
[891] Fix | Delete
</div>
[892] Fix | Delete
</div>
[893] Fix | Delete
<?php
[894] Fix | Delete
if ( get_option('page_on_front') == $post->ID && false == $redux_builder_amp['amp-frontpage-select-option'] ) {
[895] Fix | Delete
echo sprintf(('<p class="afp"><b> %s </b> <a class="" target= "_blank" href="%s">%s</a></p>'), esc_html__('We have detected that you have not setup the FrontPage for AMP,','accelerated-mobile-pages'),admin_url("admin.php?page=amp_options&tabid=opt-text-subsection#redux_builder_amp-ampforwp-homepage-on-off-support"),esc_html__('Click here to setup','accelerated-mobile-pages'));
[896] Fix | Delete
}
[897] Fix | Delete
if ( true == $redux_builder_amp['amp-frontpage-select-option'] && $post->ID == $redux_builder_amp['amp-frontpage-select-option-pages'] ) {
[898] Fix | Delete
echo sprintf('<p>%s</p>', esc_html__('AMP FrontPage'));
[899] Fix | Delete
}
[900] Fix | Delete
}
[901] Fix | Delete
[902] Fix | Delete
/**
[903] Fix | Delete
* Adds a meta box to the post editing screen for Mobile Redirection on-off on specific pages
[904] Fix | Delete
*/
[905] Fix | Delete
[906] Fix | Delete
function ampforwp_mobile_redirection() {
[907] Fix | Delete
global $redux_builder_amp;
[908] Fix | Delete
$post_types = ampforwp_get_all_post_types();
[909] Fix | Delete
[910] Fix | Delete
if ( $post_types && ampforwp_role_based_access_options() == true ) { // If there are any custom public post types.
[911] Fix | Delete
[912] Fix | Delete
foreach ( $post_types as $post_type ) {
[913] Fix | Delete
[914] Fix | Delete
if( $post_type == 'amp-cta' || $post_type == 'amp-optin' ) {
[915] Fix | Delete
continue;
[916] Fix | Delete
}
[917] Fix | Delete
// Posts
[918] Fix | Delete
if( ampforwp_get_setting('amp-on-off-for-all-posts') && $post_type == 'post' ) {
[919] Fix | Delete
if ( ampforwp_get_setting('amp-mobile-redirection') ) {
[920] Fix | Delete
add_meta_box( 'ampforwp_title_meta_redir', esc_html__( 'Mobile Redirection for Current Page?','accelerated-mobile-pages' ), 'ampforwp_title_callback_redirection', 'post','side' );
[921] Fix | Delete
}
[922] Fix | Delete
}
[923] Fix | Delete
// Pages
[924] Fix | Delete
if( ampforwp_get_setting('amp-on-off-for-all-pages') && $post_type == 'page' ) {
[925] Fix | Delete
if ( ampforwp_get_setting('amp-mobile-redirection') ) {
[926] Fix | Delete
add_meta_box( 'ampforwp_title_meta_redir', esc_html__( 'Mobile Redirection for Current Page?' ,'accelerated-mobile-pages'), 'ampforwp_title_callback_redirection','page','side' );
[927] Fix | Delete
}
[928] Fix | Delete
}
[929] Fix | Delete
// Custom Post Types
[930] Fix | Delete
if( $post_type !== 'page' && $post_type !== 'post' ) {
[931] Fix | Delete
if (ampforwp_get_setting('amp-mobile-redirection') ) {
[932] Fix | Delete
add_meta_box( 'ampforwp_title_meta_redir', esc_html__( 'Mobile Redirection for Current Page?','accelerated-mobile-pages' ), 'ampforwp_title_callback_redirection', $post_type,'side' );
[933] Fix | Delete
}
[934] Fix | Delete
}
[935] Fix | Delete
}
[936] Fix | Delete
[937] Fix | Delete
}
[938] Fix | Delete
}
[939] Fix | Delete
[940] Fix | Delete
add_action( 'add_meta_boxes', 'ampforwp_mobile_redirection' );
[941] Fix | Delete
[942] Fix | Delete
/**
[943] Fix | Delete
* Outputs the content of the meta box for Mobile Redirection on-off on specific pages
[944] Fix | Delete
*/
[945] Fix | Delete
function ampforwp_title_callback_redirection( $post ) {
[946] Fix | Delete
wp_nonce_field( basename( __FILE__ ), 'ampforwp_title_nonce' );
[947] Fix | Delete
$ampforwp_redirection_stored_meta = get_post_meta( $post->ID );?>
[948] Fix | Delete
<p>
[949] Fix | Delete
<div class="prfx-row-content">
[950] Fix | Delete
<label for="meta-redirection-radio-one">
[951] Fix | Delete
<input type="radio" name="ampforwp-redirection-on-off" id="meta-redirection-radio-one" value="enable" checked="checked" <?php if ( isset ( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'] ) ) checked( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'][0], 'enable' ); ?>>
[952] Fix | Delete
<?php esc_html_e( 'Enable', 'accelerated-mobile-pages' )?>
[953] Fix | Delete
</label>
[954] Fix | Delete
<label for="meta-redirection-radio-two">
[955] Fix | Delete
<input type="radio" name="ampforwp-redirection-on-off" id="meta-redirection-radio-two" value="disable" <?php if ( isset ( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'] ) ) checked( $ampforwp_redirection_stored_meta['ampforwp-redirection-on-off'][0], 'disable' ); ?>>
[956] Fix | Delete
<?php esc_html_e( 'Disable', 'accelerated-mobile-pages' )?>
[957] Fix | Delete
</label>
[958] Fix | Delete
</div>
[959] Fix | Delete
</p>
[960] Fix | Delete
[961] Fix | Delete
<?php
[962] Fix | Delete
}
[963] Fix | Delete
[964] Fix | Delete
function ampforwp_meta_redirection_status(){
[965] Fix | Delete
global $post;
[966] Fix | Delete
$ampforwp_redirection_post_on_off_meta = '';
[967] Fix | Delete
[968] Fix | Delete
if ( (! is_404() && ampforwp_is_search_has_results() ) && (is_singular() || ampforwp_is_front_page()) ) {
[969] Fix | Delete
$ampforwp_redirection_post_on_off_meta = get_post_meta( $post->ID,'ampforwp-redirection-on-off',true);
[970] Fix | Delete
}
[971] Fix | Delete
[972] Fix | Delete
if ( empty( $ampforwp_redirection_post_on_off_meta ) ) {
[973] Fix | Delete
$ampforwp_redirection_post_on_off_meta = 'enable';
[974] Fix | Delete
}
[975] Fix | Delete
$ampforwp_redirection_post_on_off_meta = apply_filters('ampforwp_disable_mobile_redirection', $ampforwp_redirection_post_on_off_meta);
[976] Fix | Delete
return $ampforwp_redirection_post_on_off_meta;
[977] Fix | Delete
[978] Fix | Delete
}
[979] Fix | Delete
[980] Fix | Delete
// Added the check to see if any search results exists
[981] Fix | Delete
function ampforwp_is_search_has_results() {
[982] Fix | Delete
return 0 != $GLOBALS['wp_query']->found_posts;
[983] Fix | Delete
}
[984] Fix | Delete
[985] Fix | Delete
/**
[986] Fix | Delete
* Saves the custom meta input for AMP on-off on specific pages
[987] Fix | Delete
*/
[988] Fix | Delete
function ampforwp_title_meta_save( $post_id ) {
[989] Fix | Delete
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
[990] Fix | Delete
return ;
[991] Fix | Delete
}
[992] Fix | Delete
$ampforwp_amp_status = '';
[993] Fix | Delete
[994] Fix | Delete
// Checks save status
[995] Fix | Delete
$is_autosave = wp_is_post_autosave( $post_id );
[996] Fix | Delete
$is_revision = wp_is_post_revision( $post_id );
[997] Fix | Delete
$is_valid_nonce = ( isset( $_POST[ 'ampforwp_title_nonce' ] ) && wp_verify_nonce( $_POST[ 'ampforwp_title_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
[998] Fix | Delete
$is_valid_nonce_ia = ( isset( $_POST[ 'ampforwp_ia_nonce' ] ) && wp_verify_nonce( $_POST[ 'ampforwp_ia_nonce' ], basename( __FILE__ ) ) ) ? 'true' : 'false';
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function