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.../template...
File: features.php
<?php
[0] Fix | Delete
use AMPforWP\AMPVendor\AMP_Content;
[1] Fix | Delete
// Exit if accessed directly
[2] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[3] Fix | Delete
exit;
[4] Fix | Delete
}
[5] Fix | Delete
/* This file will contain all the Extra FEATURES.
[6] Fix | Delete
0.9. AMP Design Manager Files
[7] Fix | Delete
1. Add Home REL canonical
[8] Fix | Delete
2. Custom Design
[9] Fix | Delete
3. Custom Style files
[10] Fix | Delete
4. Custom Header files
[11] Fix | Delete
4.1 Custom Meta-Author files
[12] Fix | Delete
4.2 Custom Meta-Taxonomy files
[13] Fix | Delete
4.5 Added hook to add more layout.
[14] Fix | Delete
5. Customize with Width of the site
[15] Fix | Delete
6. Add required Javascripts for extra AMP features
[16] Fix | Delete
6.1 Adding Analytics Scripts
[17] Fix | Delete
7. Footer for AMP Pages
[18] Fix | Delete
8. Add Main tag as a Wrapper ( removed in 0.8.9 )
[19] Fix | Delete
9. Advertisement code
[20] Fix | Delete
10. Analytics Area
[21] Fix | Delete
10.1 Analytics Support added for Google Analytics
[22] Fix | Delete
10.2 Analytics Support added for segment.com
[23] Fix | Delete
10.3 Analytics Support added for Piwik
[24] Fix | Delete
10.4 Analytics Support added for quantcast
[25] Fix | Delete
10.5 Analytics Support added for comscore
[26] Fix | Delete
10.6 Analytics Support added for Effective Measure
[27] Fix | Delete
10.7 Analytics Support added for StatCounter
[28] Fix | Delete
10.8 Analytics Support added for Histats Analytics
[29] Fix | Delete
10.9 Analytics Support added for Yandex Metrika
[30] Fix | Delete
10.10 Analytics Support added for Chartbeat Analytics
[31] Fix | Delete
10.11 Analytics Support added for Alexa Metrics
[32] Fix | Delete
11. Strip unwanted codes and tags from the_content
[33] Fix | Delete
12. Add Logo URL in the structured metadata
[34] Fix | Delete
13. Add Custom Placeholder Image for Structured Data.
[35] Fix | Delete
14. Adds a meta box to the post editing screen for AMP on-off on specific pages.
[36] Fix | Delete
15. Disable New Relic's extra script that its adds in AMP pages.
[37] Fix | Delete
16. Remove Unwanted Scripts
[38] Fix | Delete
17. Archives Canonical in AMP version
[39] Fix | Delete
18. Custom Canonical for Homepage
[40] Fix | Delete
19. Remove Canonical tags
[41] Fix | Delete
20. Remove the default Google font for performance ( removed in 0.8.9 )
[42] Fix | Delete
21. Remove Schema data from All In One Schema.org Rich Snippets Plugin
[43] Fix | Delete
22. Removing author links from comments Issue #180
[44] Fix | Delete
23. The analytics tag appears more than once in the document. This will soon be an error
[45] Fix | Delete
24. Seperate Sticky Single Social Icons
[46] Fix | Delete
25. Yoast meta Support
[47] Fix | Delete
26. Extending Title Tagand De-Hooking the Standard one from AMP
[48] Fix | Delete
27. Fixing the defer tag issue [Finally!]
[49] Fix | Delete
28. Properly removes AMP if turned off from Post panel
[50] Fix | Delete
29. Remove analytics code if Already added by Glue or Yoast SEO
[51] Fix | Delete
30. TagDiv menu issue removed
[52] Fix | Delete
31. removing scripts added by cleantalk
[53] Fix | Delete
32. various lazy loading plugins Support
[54] Fix | Delete
33. Google tag manager support added
[55] Fix | Delete
34. social share boost compatibility Ticket #387
[56] Fix | Delete
35. Disqus Comments Support
[57] Fix | Delete
36. remove photon support in AMP
[58] Fix | Delete
37. compatibility with wp-html-compression
[59] Fix | Delete
38. #529 editable archives
[60] Fix | Delete
39. #560 Header and Footer Editable html enabled script area
[61] Fix | Delete
40. Meta Robots
[62] Fix | Delete
41. Rewrite URL only on save #511
[63] Fix | Delete
42. registeing AMP sidebars
[64] Fix | Delete
43. custom actions for widgets output
[65] Fix | Delete
44. auto adding /amp for the menu
[66] Fix | Delete
45. search,frontpage,homepage structured data
[67] Fix | Delete
46. search search search everywhere #615
[68] Fix | Delete
47. social js properly adding when required
[69] Fix | Delete
48. Remove all unwanted scripts on search pages
[70] Fix | Delete
49. Properly adding ad Script the AMP way
[71] Fix | Delete
50. Properly adding noditification Scritps the AMP way
[72] Fix | Delete
51. Adding Digg Digg compatibility with AMP
[73] Fix | Delete
52. Adding a generalized sanitizer function for purifiying normal html to amp-html
[74] Fix | Delete
53. Removed AMP-WooCommerce Code and added it in AMP-WooCommerce #929
[75] Fix | Delete
54. Change the default values of post meta for AMP pages.
[76] Fix | Delete
55. Call Now Button Feature added
[77] Fix | Delete
56. Multi Translation Feature #540
[78] Fix | Delete
57. Adding Updated date at in the Content
[79] Fix | Delete
58. YouTube Shortcode compatablity with AMP #557
[80] Fix | Delete
59. Comment Button URL
[81] Fix | Delete
60. Remove Category Layout modification code added by TagDiv #842 and #796
[82] Fix | Delete
61. Add Gist Support
[83] Fix | Delete
62. Adding Meta viewport via hook instead of direct #878
[84] Fix | Delete
63. Frontpage Comments #682
[85] Fix | Delete
64. PageBuilder
[86] Fix | Delete
65. Remove Filters code added through Class by other plugins
[87] Fix | Delete
66. Make AMP compatible with Squirrly SEO
[88] Fix | Delete
69. Post Pagination #834 #857
[89] Fix | Delete
70. Hide AMP by specific Categories #872
[90] Fix | Delete
71. Alt tag for thumbnails #1013 and For Post ID in Body tag #1006
[91] Fix | Delete
72. Blacklist Sanitizer Added back #1024
[92] Fix | Delete
73. View AMP Site below View Site In Dashboard #1076
[93] Fix | Delete
74. Featured Image check from Custom Fields
[94] Fix | Delete
75. Dev Mode in AMP
[95] Fix | Delete
76. Body Class for AMP pages
[96] Fix | Delete
77. AMP Blog Details
[97] Fix | Delete
78. Saved Custom Post Types for AMP in Options for Structured Data
[98] Fix | Delete
79. Favicon for AMP
[99] Fix | Delete
80. Mobile Preview styling
[100] Fix | Delete
81. Duplicate Featured Image Support
[101] Fix | Delete
82. Grab Featured Image from The Content
[102] Fix | Delete
83. Advance Analytics(Google Analytics)
[103] Fix | Delete
84. Inline Related Posts
[104] Fix | Delete
85. Caption for Gallery Images
[105] Fix | Delete
86. minify the content of pages
[106] Fix | Delete
87. Post Thumbnail
[107] Fix | Delete
88. Author Details
[108] Fix | Delete
89. Facebook Pixel
[109] Fix | Delete
90. Set Header last modified information
[110] Fix | Delete
91. Comment Author Gravatar URL
[111] Fix | Delete
92. View AMP in Admin Bar
[112] Fix | Delete
93. added AMP url purifire for amphtml
[113] Fix | Delete
94. OneSignal Push Notifications
[114] Fix | Delete
95. Modify menu link attributes for SiteNavigationElement Schema Markup #1229 #1345
[115] Fix | Delete
96. ampforwp_is_front_page() ampforwp_is_home() and ampforwp_is_blog is created
[116] Fix | Delete
97. Change the format of the post date on Loops #1384
[117] Fix | Delete
98. Create Dynamic url of amp according to the permalink structure #1318
[118] Fix | Delete
99. Merriweather Font Management
[119] Fix | Delete
100. Flags compatibility in Menu
[120] Fix | Delete
101. Function for Logo attributes
[121] Fix | Delete
102. SD Feature Image Guidlines #2838
[122] Fix | Delete
*/
[123] Fix | Delete
// AMP Components
[124] Fix | Delete
// AMP LOGO
[125] Fix | Delete
add_amp_theme_support('AMP-logo');
[126] Fix | Delete
// AMP Loop
[127] Fix | Delete
add_amp_theme_support('AMP-loop');
[128] Fix | Delete
// GDPR
[129] Fix | Delete
if(ampforwp_get_setting('amp-gdpr-compliance-switch')) {
[130] Fix | Delete
add_amp_theme_support('AMP-gdpr');
[131] Fix | Delete
}
[132] Fix | Delete
// Menu
[133] Fix | Delete
add_amp_theme_support('AMP-menu');
[134] Fix | Delete
// Adding AMP-related things to the main theme
[135] Fix | Delete
global $redux_builder_amp;
[136] Fix | Delete
[137] Fix | Delete
// 0.9. AMP Design Manager Files
[138] Fix | Delete
require AMPFORWP_PLUGIN_DIR .'templates/design-manager.php';
[139] Fix | Delete
// Custom Frontpage items
[140] Fix | Delete
require AMPFORWP_PLUGIN_DIR .'templates/frontpage-elements.php';
[141] Fix | Delete
require AMPFORWP_PLUGIN_DIR . '/classes/class-ampforwp-youtube-embed.php' ;
[142] Fix | Delete
// Custom Post Types
[143] Fix | Delete
require AMPFORWP_PLUGIN_DIR .'templates/ampforwp-custom-post-type.php';
[144] Fix | Delete
[145] Fix | Delete
// TODO: Update this function
[146] Fix | Delete
function ampforwp_include_customizer_files(){
[147] Fix | Delete
global $redux_builder_amp;
[148] Fix | Delete
$amp_plugin_data;
[149] Fix | Delete
$amp_plugin_activation_check;
[150] Fix | Delete
[151] Fix | Delete
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
[152] Fix | Delete
$amp_plugin_activation_check = is_plugin_active( 'amp/amp.php' );
[153] Fix | Delete
if ( isset ($redux_builder_amp['amp-design-selector']) && 4 != $redux_builder_amp['amp-design-selector'] ) {
[154] Fix | Delete
return require AMPFORWP_PLUGIN_DIR .'templates/customizer/customizer.php' ;
[155] Fix | Delete
}
[156] Fix | Delete
}
[157] Fix | Delete
ampforwp_include_customizer_files();
[158] Fix | Delete
//0.
[159] Fix | Delete
[160] Fix | Delete
define('AMPFORWP_COMMENTS_PER_PAGE', ampforwp_define_comments_number() );
[161] Fix | Delete
// Define number of comments
[162] Fix | Delete
function ampforwp_define_comments_number(){
[163] Fix | Delete
global $redux_builder_amp;
[164] Fix | Delete
$number_of_comments = '';
[165] Fix | Delete
if(isset($redux_builder_amp['ampforwp-number-of-comments'])){
[166] Fix | Delete
$number_of_comments = $redux_builder_amp['ampforwp-number-of-comments'];
[167] Fix | Delete
}
[168] Fix | Delete
return $number_of_comments;
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
// 1. Add Home REL canonical
[172] Fix | Delete
// Add AMP rel-canonical for home and archive pages
[173] Fix | Delete
[174] Fix | Delete
add_action('amp_init','ampforwp_allow_homepage');
[175] Fix | Delete
function ampforwp_allow_homepage() {
[176] Fix | Delete
add_action( 'wp', 'ampforwp_add_endpoint_actions' );
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
[180] Fix | Delete
function ampforwp_add_endpoint_actions() {
[181] Fix | Delete
[182] Fix | Delete
$ampforwp_is_amp_endpoint = ampforwp_is_amp_endpoint();
[183] Fix | Delete
[184] Fix | Delete
if ( $ampforwp_is_amp_endpoint ) {
[185] Fix | Delete
AMPforWP\AMPVendor\amp_prepare_render();
[186] Fix | Delete
} else {
[187] Fix | Delete
add_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
$cpage_var = get_query_var('cpage');
[191] Fix | Delete
[192] Fix | Delete
if ( $cpage_var >= 1) :
[193] Fix | Delete
remove_action( 'wp_head', 'ampforwp_home_archive_rel_canonical', 1 );
[194] Fix | Delete
endif;
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
function ampforwp_amphtml_generator(){
[198] Fix | Delete
global $redux_builder_amp;
[199] Fix | Delete
global $wp, $post;
[200] Fix | Delete
$post_id = '';
[201] Fix | Delete
$endpoint_check = false;
[202] Fix | Delete
$endpoint_check = ampforwp_get_setting('amp-core-end-point');
[203] Fix | Delete
if( is_attachment() ) {
[204] Fix | Delete
return;
[205] Fix | Delete
}
[206] Fix | Delete
if(get_query_var('paged') && true == ampforwp_get_setting('amp-paginated-pages-indexing')) {
[207] Fix | Delete
return;
[208] Fix | Delete
}
[209] Fix | Delete
if( is_home() && is_front_page() && !ampforwp_get_setting('ampforwp-homepage-on-off-support') ) {
[210] Fix | Delete
return;
[211] Fix | Delete
}
[212] Fix | Delete
if( is_front_page() && ! ampforwp_get_setting('ampforwp-homepage-on-off-support') ) {
[213] Fix | Delete
return;
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
// HIDE/SHOW TAG AND CATEGORY #4326
[217] Fix | Delete
if(is_tag() || is_category() || is_tax()){
[218] Fix | Delete
$amp_queried_object = get_queried_object();
[219] Fix | Delete
if (is_object($amp_queried_object) && property_exists($amp_queried_object, 'term_id'))
[220] Fix | Delete
{
[221] Fix | Delete
$term_id = $amp_queried_object->term_id;
[222] Fix | Delete
$tax_status = ampforwp_get_taxonomy_meta($term_id,'status');
[223] Fix | Delete
if($tax_status==false){
[224] Fix | Delete
return;
[225] Fix | Delete
}
[226] Fix | Delete
}else{
[227] Fix | Delete
return;
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
}else if(is_single()){
[231] Fix | Delete
$tax_status = ampforwp_get_taxonomy_meta('','post_status');
[232] Fix | Delete
if($tax_status==false){
[233] Fix | Delete
return;
[234] Fix | Delete
}
[235] Fix | Delete
}
[236] Fix | Delete
[237] Fix | Delete
// Skip this condition for woocommerce product archive and shop pages.
[238] Fix | Delete
if( function_exists('amp_woocommerce_pro_add_woocommerce_support') && (function_exists('is_product_category') && !is_product_category()) && (function_exists('is_product_tag') && !is_product_tag()) && (function_exists('is_shop') && !is_shop() ) ){
[239] Fix | Delete
if( is_archive() && ( !ampforwp_get_setting('ampforwp-archive-support') || ( is_category() && !ampforwp_get_setting('ampforwp-archive-support-cat') ) || ( is_tag() && !ampforwp_get_setting('ampforwp-archive-support-tag') ))){
[240] Fix | Delete
return;
[241] Fix | Delete
}
[242] Fix | Delete
}
[243] Fix | Delete
[244] Fix | Delete
// When amp woocommerce pro plugin is not active.
[245] Fix | Delete
if ( is_archive() && !function_exists('amp_woocommerce_pro_add_woocommerce_support') ) {
[246] Fix | Delete
if(!ampforwp_get_setting('ampforwp-archive-support')){
[247] Fix | Delete
return;
[248] Fix | Delete
}
[249] Fix | Delete
if( is_category() && !ampforwp_get_setting('ampforwp-archive-support-cat') ){
[250] Fix | Delete
return;
[251] Fix | Delete
}
[252] Fix | Delete
if( is_tag() && !ampforwp_get_setting('ampforwp-archive-support-tag') ){
[253] Fix | Delete
return;
[254] Fix | Delete
}
[255] Fix | Delete
}
[256] Fix | Delete
// #1192 Password Protected posts exclusion
[257] Fix | Delete
if(post_password_required( $post )){
[258] Fix | Delete
return;
[259] Fix | Delete
}
[260] Fix | Delete
// #2018 404 exclusion
[261] Fix | Delete
if(is_404()){
[262] Fix | Delete
return;
[263] Fix | Delete
}
[264] Fix | Delete
// #1443 AMP should be skip on the check out page
[265] Fix | Delete
if(class_exists( 'WooCommerce' )){
[266] Fix | Delete
if(function_exists('is_checkout') && is_checkout()){
[267] Fix | Delete
return;
[268] Fix | Delete
}
[269] Fix | Delete
if(function_exists('is_account_page') && is_account_page()){
[270] Fix | Delete
return;
[271] Fix | Delete
}
[272] Fix | Delete
}
[273] Fix | Delete
// Search results on/off option #3786
[274] Fix | Delete
if(is_search() && 0 == ampforwp_get_setting('amp-redirection-search')){
[275] Fix | Delete
return;
[276] Fix | Delete
}
[277] Fix | Delete
if(function_exists('yith_wishlist_constructor')){
[278] Fix | Delete
$class = get_body_class();
[279] Fix | Delete
if(in_array("woocommerce-wishlist", $class)){
[280] Fix | Delete
return;
[281] Fix | Delete
}
[282] Fix | Delete
}
[283] Fix | Delete
// #872 no-amphtml if selected as hide from settings
[284] Fix | Delete
if ( is_category_amp_disabled() ) {
[285] Fix | Delete
return;
[286] Fix | Delete
}
[287] Fix | Delete
if ( is_page() && ! ampforwp_get_setting('amp-on-off-for-all-pages') && ! is_home() && ! is_front_page() ) {
[288] Fix | Delete
return;
[289] Fix | Delete
}
[290] Fix | Delete
if ( is_home() && ! ampforwp_is_blog() && !ampforwp_get_setting('ampforwp-homepage-on-off-support') ) {
[291] Fix | Delete
return;
[292] Fix | Delete
}
[293] Fix | Delete
if(is_author()){
[294] Fix | Delete
$amp_auth_url = ampforwp_get_author_page_url();
[295] Fix | Delete
return esc_url_raw($amp_auth_url);
[296] Fix | Delete
}
[297] Fix | Delete
if (!ampforwp_is_home() && !ampforwp_is_front_page() && !ampforwp_is_blog() && !is_category() && !is_tag() && !is_singular( array('page', 'attachment', 'post')) && !function_exists('amp_woocommerce_pro_add_woocommerce_support')){
[298] Fix | Delete
global $post_type;
[299] Fix | Delete
if (empty(ampforwp_get_setting('ampforwp-custom-type'))) {
[300] Fix | Delete
return;
[301] Fix | Delete
}
[302] Fix | Delete
}
[303] Fix | Delete
$page_for_posts = intval(get_option( 'page_for_posts' ));
[304] Fix | Delete
$post_id = ampforwp_get_the_ID();
[305] Fix | Delete
if ( ampforwp_is_blog() && ! ampforwp_get_setting('amp-on-off-for-all-pages') && ($page_for_posts != $post_id ) ) {
[306] Fix | Delete
return;
[307] Fix | Delete
}
[308] Fix | Delete
$query_arg_array = $wp->query_vars;
[309] Fix | Delete
if( in_array( "cpage" , $query_arg_array ) ) {
[310] Fix | Delete
if( is_front_page() && $wp->query_vars['cpage'] >= '2' ) {
[311] Fix | Delete
return;
[312] Fix | Delete
}
[313] Fix | Delete
if( is_singular() && $wp->query_vars['cpage'] >= '2' ) {
[314] Fix | Delete
return;
[315] Fix | Delete
}
[316] Fix | Delete
}
[317] Fix | Delete
[318] Fix | Delete
if ( is_home() || is_front_page() || is_archive() ){
[319] Fix | Delete
global $wp;
[320] Fix | Delete
$current_archive_url = home_url( $wp->request );
[321] Fix | Delete
// If its custom permalink with /index.php/ #3279
[322] Fix | Delete
if ( is_archive() && false !== strpos($wp->matched_rule, 'index.php') && false === strpos($current_archive_url, 'index.php') ) {
[323] Fix | Delete
$current_archive_url = home_url( 'index.php/' . $wp->request );
[324] Fix | Delete
}
[325] Fix | Delete
$amp_url = trailingslashit($current_archive_url);
[326] Fix | Delete
if ($endpoint_check && (is_tax() || is_post_type_archive())) {
[327] Fix | Delete
$amp_url = ampforwp_url_controller($amp_url);
[328] Fix | Delete
}
[329] Fix | Delete
} else {
[330] Fix | Delete
$amp_url = AMPforWP\AMPVendor\amp_get_permalink( get_queried_object_id() );
[331] Fix | Delete
}
[332] Fix | Delete
global $post;
[333] Fix | Delete
if ( is_singular() ) {
[334] Fix | Delete
$post_id = get_the_ID();
[335] Fix | Delete
[336] Fix | Delete
}
[337] Fix | Delete
if ( ampforwp_is_blog() ) {
[338] Fix | Delete
$post_id = ampforwp_get_blog_details('id');
[339] Fix | Delete
}
[340] Fix | Delete
$ampforwp_amp_post_on_off_meta = get_post_meta( $post_id,'ampforwp-amp-on-off',true);
[341] Fix | Delete
if ( ( is_singular() || ampforwp_is_blog() ) && $ampforwp_amp_post_on_off_meta === 'hide-amp' ) {
[342] Fix | Delete
//dont Echo anything
[343] Fix | Delete
} else {
[344] Fix | Delete
$supported_types = ampforwp_get_all_post_types();
[345] Fix | Delete
if(isset($supported_types['web-story'])){
[346] Fix | Delete
$supported_types['web-story'] = '';
[347] Fix | Delete
}
[348] Fix | Delete
$supported_types = apply_filters('get_amp_supported_post_types',$supported_types);
[349] Fix | Delete
[350] Fix | Delete
$type = get_post_type();
[351] Fix | Delete
if(is_home() || is_front_page()){
[352] Fix | Delete
if( ampforwp_get_setting('ampforwp-homepage-on-off-support') == 1
[353] Fix | Delete
&& ampforwp_get_setting('amp-on-off-for-all-posts') == 0
[354] Fix | Delete
&& ampforwp_get_setting('amp-on-off-for-all-pages') == 0 ){
[355] Fix | Delete
[356] Fix | Delete
$supported_types['post'] = 'post';
[357] Fix | Delete
}
[358] Fix | Delete
}
[359] Fix | Delete
$supported_amp_post_types = in_array( $type , $supported_types );
[360] Fix | Delete
[361] Fix | Delete
$query_arg_array = $wp->query_vars;
[362] Fix | Delete
if( array_key_exists( 'paged' , $query_arg_array ) ) {
[363] Fix | Delete
if ( (is_home() || is_archive()) && $wp->query_vars['paged'] >= '2' ) {
[364] Fix | Delete
$new_url = home_url('/');
[365] Fix | Delete
// If its custom permalink with /index.php/ #3537
[366] Fix | Delete
if ( (is_home() || is_archive()) && false !== strpos($wp->matched_rule, 'index.php') && false === strpos( home_url( $wp->request ), 'index.php') ) {
[367] Fix | Delete
$new_url = home_url( 'index.php' );
[368] Fix | Delete
$o_url = home_url();
[369] Fix | Delete
$new_url = str_replace($o_url, $new_url, $amp_url);
[370] Fix | Delete
$new_url = user_trailingslashit($new_url);
[371] Fix | Delete
$amp_url = $new_url;
[372] Fix | Delete
}
[373] Fix | Delete
$category_path = $wp->request;
[374] Fix | Delete
if ( null != $category_path && true != $endpoint_check) {
[375] Fix | Delete
$explode_path = explode("/",$category_path);
[376] Fix | Delete
$inserted = array(AMPFORWP_AMP_QUERY_VAR);
[377] Fix | Delete
array_splice( $explode_path, -2, 0, $inserted );
[378] Fix | Delete
$impode_url = implode('/', $explode_path);
[379] Fix | Delete
$amp_url = $new_url . $impode_url ;
[380] Fix | Delete
}
[381] Fix | Delete
}
[382] Fix | Delete
if( is_search() && $wp->query_vars['paged'] >= '2' ) {
[383] Fix | Delete
$current_search_url =trailingslashit(get_home_url()) . $wp->request .'/'."?amp=1&s=".get_search_query();
[384] Fix | Delete
}
[385] Fix | Delete
}
[386] Fix | Delete
if (!$endpoint_check) {
[387] Fix | Delete
$amp_url = user_trailingslashit($amp_url);
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
if( is_search() ) {
[391] Fix | Delete
$current_search_url =trailingslashit(get_home_url())."?amp=1&s=".get_search_query();
[392] Fix | Delete
$amp_url = untrailingslashit($current_search_url);
[393] Fix | Delete
}
[394] Fix | Delete
// URL Purifier
[395] Fix | Delete
if(!ampforwp_get_setting('amp-core-end-point') && !ampforwp_get_setting('ampforwp-amp-takeover')){
[396] Fix | Delete
$amp_url = ampforwp_url_purifier($amp_url);
[397] Fix | Delete
}
[398] Fix | Delete
if(true == ampforwp_get_setting('amp-core-end-point') && (!is_home() && !is_front_page() && !is_archive())){
[399] Fix | Delete
$amp_url = add_query_arg( 'amp', '', get_the_permalink() );
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
[403] Fix | Delete
if( $supported_amp_post_types || ampforwp_is_front_page() ) {
[404] Fix | Delete
if(true == ampforwp_get_setting('amp-core-end-point')){
[405] Fix | Delete
if( class_exists('SitePress') ){
[406] Fix | Delete
if( get_option('permalink_structure') ){
[407] Fix | Delete
global $sitepress_settings, $wp;
[408] Fix | Delete
$wpml_lang_checker = false;
[409] Fix | Delete
if($sitepress_settings[ 'language_negotiation_type' ] == 3){
[410] Fix | Delete
$amp_url = esc_url($amp_url);
[411] Fix | Delete
$active_langs = $sitepress_settings['active_languages'];
[412] Fix | Delete
foreach ($active_langs as $active_lang) {
[413] Fix | Delete
if (preg_match('/\?lang='.$active_lang.'/', $amp_url)){
[414] Fix | Delete
$amp_url = preg_replace('/&#038;amp=1/', '', $amp_url);
[415] Fix | Delete
$amp_url = preg_replace('/#038;amp/', '', $amp_url);
[416] Fix | Delete
$amp_url = str_replace('?lang='.$active_lang, '?amp=1', $amp_url);
[417] Fix | Delete
$amp_url = add_query_arg( 'lang',$active_lang, $amp_url);
[418] Fix | Delete
}
[419] Fix | Delete
}
[420] Fix | Delete
}
[421] Fix | Delete
}
[422] Fix | Delete
}
[423] Fix | Delete
}
[424] Fix | Delete
if (is_category() && class_exists('WPSEO_Options') && method_exists('WPSEO_Options', 'get') && WPSEO_Options::get( 'stripcategorybase' ) == true && false == ampforwp_get_setting('ampforwp-category-base-removel-link')) {
[425] Fix | Delete
return;
[426] Fix | Delete
}
[427] Fix | Delete
if (is_category() && class_exists('RankMath') && RankMath\Helper::get_settings( 'general.strip_category_base' ) == true && false == ampforwp_get_setting('ampforwp-category-base-removel-link')) {
[428] Fix | Delete
return;
[429] Fix | Delete
}
[430] Fix | Delete
if (is_preview()) {
[431] Fix | Delete
$amp_url = preg_replace('/(.*?)&(.*?)/', '$1&amp&$2', $amp_url);
[432] Fix | Delete
}
[433] Fix | Delete
if(ampforwp_get_setting('amp-core-end-point') && ampforwp_get_setting('ampforwp-amp-takeover') && is_singular()){
[434] Fix | Delete
$amp_url = get_the_permalink();
[435] Fix | Delete
}else if(ampforwp_get_setting('amp-core-end-point') && (ampforwp_is_home() || ampforwp_is_front_page() || ampforwp_is_blog() || is_category() || is_tag() || is_front_page())){
[436] Fix | Delete
$amp_url = ampforwp_url_controller($amp_url);
[437] Fix | Delete
}
[438] Fix | Delete
$amp_url = apply_filters('ampforwp_modify_rel_canonical',$amp_url);
[439] Fix | Delete
return esc_url_raw($amp_url);
[440] Fix | Delete
}
[441] Fix | Delete
}
[442] Fix | Delete
return;
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
// AMPHTML when using custom page and then creating a blog page
[446] Fix | Delete
add_action('amp_init','ampforwp_allow_homepage_as_blog');
[447] Fix | Delete
function ampforwp_allow_homepage_as_blog() {
[448] Fix | Delete
if(function_exists('mfn_opts_setup')){
[449] Fix | Delete
remove_action( 'pre_get_posts', 'mfn_search' );
[450] Fix | Delete
}
[451] Fix | Delete
add_action( 'wp', 'ampforwp_static_blog' , 11 );
[452] Fix | Delete
}
[453] Fix | Delete
function ampforwp_static_blog(){
[454] Fix | Delete
global $page;
[455] Fix | Delete
$modify_canonical = ampforwp_is_front_page();
[456] Fix | Delete
$get_front_page_reading_settings = get_option('page_on_front');
[457] Fix | Delete
// Homepage support on
[458] Fix | Delete
$get_amp_homepage_support = ampforwp_get_setting('ampforwp-homepage-on-off-support');
[459] Fix | Delete
if ( 'page' == get_option( 'show_on_front') && is_front_page() && $get_front_page_reading_settings && $get_amp_homepage_support ){
[460] Fix | Delete
$modify_canonical = true;
[461] Fix | Delete
}
[462] Fix | Delete
if ( true == $modify_canonical && $page >= 2 && is_page() && false == ampforwp_get_setting('amp-core-end-point') ) {
[463] Fix | Delete
add_filter('ampforwp_modify_rel_canonical','ampforwp_modify_amphtml_static_blog');
[464] Fix | Delete
}
[465] Fix | Delete
}
[466] Fix | Delete
[467] Fix | Delete
function ampforwp_modify_amphtml_static_blog($amp_url) {
[468] Fix | Delete
$explode_url = $amp_endpoint = $offset = "";
[469] Fix | Delete
[470] Fix | Delete
$explode_url = explode('/', $amp_url);
[471] Fix | Delete
$explode_url = array_flip($explode_url);
[472] Fix | Delete
unset($explode_url[AMPFORWP_AMP_QUERY_VAR]);
[473] Fix | Delete
$explode_url = array_flip($explode_url);
[474] Fix | Delete
$amp_endpoint = array(AMPFORWP_AMP_QUERY_VAR);
[475] Fix | Delete
$offset = count($explode_url) - 2;
[476] Fix | Delete
array_splice( $explode_url, $offset, 0, $amp_endpoint );
[477] Fix | Delete
$amp_url = implode('/', $explode_url);
[478] Fix | Delete
return $amp_url;
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
function ampforwp_home_archive_rel_canonical() {
[482] Fix | Delete
[483] Fix | Delete
$amp_url = "";
[484] Fix | Delete
[485] Fix | Delete
$amp_url = ampforwp_amphtml_generator();
[486] Fix | Delete
[487] Fix | Delete
if ( $amp_url ) {
[488] Fix | Delete
printf('<link rel="amphtml" href="%s" />', esc_url($amp_url));
[489] Fix | Delete
if(false==ampforwp_get_setting('hide-amp-version-from-source')){
[490] Fix | Delete
printf('<meta name="generator" content="%s %s"/>', esc_html__('AMP for WP'), esc_attr(AMPFORWP_VERSION) );
[491] Fix | Delete
}
[492] Fix | Delete
}
[493] Fix | Delete
[494] Fix | Delete
} //end of ampforwp_home_archive_rel_canonical()
[495] Fix | Delete
[496] Fix | Delete
// Remove default wordpress rel canonical
[497] Fix | Delete
add_filter('amp_frontend_show_canonical','ampforwp_remove_default_canonical');
[498] Fix | Delete
if (! function_exists('ampforwp_remove_default_canonical') ) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function