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/wp-conte.../plugins/accelera.../includes/features/analytic...
File: analytics-functions.php
}else{
[500] Fix | Delete
$adobe_fields = array(
[501] Fix | Delete
[502] Fix | Delete
'vars' => array(
[503] Fix | Delete
'host'=> $hostname,
[504] Fix | Delete
'reportSuiteId' => $ReportSuiteId
[505] Fix | Delete
),
[506] Fix | Delete
'triggers' => array(
[507] Fix | Delete
'pageLoad' => array(
[508] Fix | Delete
'on' => 'visible',
[509] Fix | Delete
'request' => 'pageView'
[510] Fix | Delete
),
[511] Fix | Delete
[512] Fix | Delete
),
[513] Fix | Delete
[514] Fix | Delete
);
[515] Fix | Delete
[516] Fix | Delete
$adobe_fields = apply_filters('ampforwp-adobe-analytics', $adobe_fields);?>
[517] Fix | Delete
[518] Fix | Delete
<amp-analytics <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?> type="adobeanalytics">
[519] Fix | Delete
[520] Fix | Delete
<script type="application/json">
[521] Fix | Delete
[522] Fix | Delete
<?php echo wp_json_encode( $adobe_fields,JSON_UNESCAPED_SLASHES); ?>
[523] Fix | Delete
[524] Fix | Delete
</script>
[525] Fix | Delete
[526] Fix | Delete
</amp-analytics>
[527] Fix | Delete
[528] Fix | Delete
[529] Fix | Delete
[530] Fix | Delete
[531] Fix | Delete
<?php
[532] Fix | Delete
[533] Fix | Delete
}
[534] Fix | Delete
[535] Fix | Delete
[536] Fix | Delete
[537] Fix | Delete
}
[538] Fix | Delete
[539] Fix | Delete
[540] Fix | Delete
if ( true == ampforwp_get_setting('ampforwp-Piwik-Pro-switch')) {
[541] Fix | Delete
$ppas_host = ampforwp_get_setting('ppas-host');
[542] Fix | Delete
$ppas_id = ampforwp_get_setting('ppas-website-id');
[543] Fix | Delete
$ppas_hash = ampforwp_get_setting('ppas-website-hash');
[544] Fix | Delete
$ppas_tracking = ampforwp_get_setting('ppas-advanced-tracking');
[545] Fix | Delete
$ppas_custom_code = ampforwp_get_setting('ppas-advanced-tracking-code');
[546] Fix | Delete
if($ppas_tracking && !empty($ppas_custom_code))
[547] Fix | Delete
{
[548] Fix | Delete
$ppas_fields = str_replace(array('##instance_domain##','##app_id##','##tracker_hash##'),array($ppas_host,$ppas_id,$ppas_hash),$ppas_custom_code);
[549] Fix | Delete
}else {
[550] Fix | Delete
$ppas_fields = array(
[551] Fix | Delete
'vars'=>array(
[552] Fix | Delete
'host'=>$ppas_host,
[553] Fix | Delete
'website_id'=> $ppas_id,
[554] Fix | Delete
'website_hash'=> $ppas_hash
[555] Fix | Delete
),
[556] Fix | Delete
);
[557] Fix | Delete
$ppas_fields = wp_json_encode( $ppas_fields);
[558] Fix | Delete
[559] Fix | Delete
}
[560] Fix | Delete
[561] Fix | Delete
$ppas_fields = apply_filters('ampforwp_piwikpro_analytics', $ppas_fields );?>
[562] Fix | Delete
<amp-analytics <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?> type="ppasanalytics">
[563] Fix | Delete
<script type="application/json">
[564] Fix | Delete
<?php echo $ppas_fields; ?>
[565] Fix | Delete
</script>
[566] Fix | Delete
</amp-analytics>
[567] Fix | Delete
<?php
[568] Fix | Delete
}
[569] Fix | Delete
[570] Fix | Delete
if( true == ampforwp_get_setting('ampforwp-plausible-switch')) {
[571] Fix | Delete
$site_url = site_url();?>
[572] Fix | Delete
<amp-analytics>
[573] Fix | Delete
<script type="application/json">
[574] Fix | Delete
{
[575] Fix | Delete
"vars": {
[576] Fix | Delete
"dataDomain": "<?php echo esc_attr($site_url);?>"
[577] Fix | Delete
},
[578] Fix | Delete
"requests": {
[579] Fix | Delete
"event": "https://plausible.io/api/event"
[580] Fix | Delete
},
[581] Fix | Delete
"triggers": {
[582] Fix | Delete
"trackPageview": {
[583] Fix | Delete
"on": "visible",
[584] Fix | Delete
"request": "event",
[585] Fix | Delete
"extraUrlParams": {
[586] Fix | Delete
"n": "pageview"
[587] Fix | Delete
}
[588] Fix | Delete
}
[589] Fix | Delete
},
[590] Fix | Delete
"transport": {
[591] Fix | Delete
"beacon": true,
[592] Fix | Delete
"xhrpost": true,
[593] Fix | Delete
"image": false,
[594] Fix | Delete
"useBody": true
[595] Fix | Delete
}
[596] Fix | Delete
}
[597] Fix | Delete
</script>
[598] Fix | Delete
</amp-analytics>
[599] Fix | Delete
<?php }
[600] Fix | Delete
if( true == ampforwp_get_setting('amp-atinternet-switch')) {
[601] Fix | Delete
$site_id = $site_url = $title = '';
[602] Fix | Delete
$site_id = ampforwp_get_setting('amp-atinternet-site-id');
[603] Fix | Delete
$site_url = site_url();
[604] Fix | Delete
$title = get_the_title(ampforwp_get_the_ID());
[605] Fix | Delete
if (!empty($site_id)) {?>
[606] Fix | Delete
<amp-analytics type="atinternet" id="atinternet">
[607] Fix | Delete
<script type="application/json">
[608] Fix | Delete
{
[609] Fix | Delete
"vars": {
[610] Fix | Delete
"site": "<?php echo esc_attr($site_id);?>",
[611] Fix | Delete
"log": "logs",
[612] Fix | Delete
"domain": "<?php echo esc_attr($site_url);?>",
[613] Fix | Delete
"title": "<?php echo esc_attr($title);?>",
[614] Fix | Delete
"level2": "10"
[615] Fix | Delete
},
[616] Fix | Delete
"triggers": {
[617] Fix | Delete
"defaultPageview": {
[618] Fix | Delete
"on": "visible",
[619] Fix | Delete
"request": "pageview"
[620] Fix | Delete
}
[621] Fix | Delete
}
[622] Fix | Delete
}
[623] Fix | Delete
</script>
[624] Fix | Delete
</amp-analytics>
[625] Fix | Delete
<?php } }
[626] Fix | Delete
//Publytics
[627] Fix | Delete
if(function_exists('ampforwp_get_setting') && true == ampforwp_get_setting('ampforwp-publytics-switch')) {
[628] Fix | Delete
$title = $track_code = '';
[629] Fix | Delete
$title = get_the_title(ampforwp_get_the_ID());
[630] Fix | Delete
$track_code = ampforwp_get_setting('ampforwp-publytics-track-code');
[631] Fix | Delete
if (!empty($track_code)) { ?>
[632] Fix | Delete
<amp-analytics>
[633] Fix | Delete
<script type="application/json">
[634] Fix | Delete
{
[635] Fix | Delete
"requests": {
[636] Fix | Delete
"event": "https://api.publytics.net/events"
[637] Fix | Delete
},
[638] Fix | Delete
"extraUrlParams": {
[639] Fix | Delete
"r": "${documentReferrer}",
[640] Fix | Delete
"u": "SOURCE_URL",
[641] Fix | Delete
"w": 400,
[642] Fix | Delete
"d": "<?php echo esc_attr($track_code);?>"
[643] Fix | Delete
},
[644] Fix | Delete
"triggers": {
[645] Fix | Delete
"trackPageview": {
[646] Fix | Delete
"on": "visible",
[647] Fix | Delete
"request": "event",
[648] Fix | Delete
"extraUrlParams": {
[649] Fix | Delete
"n": "pageview",
[650] Fix | Delete
"p": {
[651] Fix | Delete
"amp":true,
[652] Fix | Delete
"article_title": "<?php echo esc_attr($title);?>"
[653] Fix | Delete
}
[654] Fix | Delete
}
[655] Fix | Delete
},
[656] Fix | Delete
"trackScrollThrough":{
[657] Fix | Delete
"on":"amp-next-page-scroll",
[658] Fix | Delete
"useInitialPageSize": true,
[659] Fix | Delete
"request":"event",
[660] Fix | Delete
"extraUrlParams": {
[661] Fix | Delete
"n": "amp_next_page_pageview"
[662] Fix | Delete
}
[663] Fix | Delete
},
[664] Fix | Delete
"trackClickThrough":{
[665] Fix | Delete
"on":"amp-next-page-click",
[666] Fix | Delete
"useInitialPageSize": true,
[667] Fix | Delete
"request":"event",
[668] Fix | Delete
"extraUrlParams": {
[669] Fix | Delete
"n": "amp_next_page_pageview"
[670] Fix | Delete
}
[671] Fix | Delete
}
[672] Fix | Delete
},
[673] Fix | Delete
"transport": {
[674] Fix | Delete
"beacon": true,
[675] Fix | Delete
"xhrpost": true,
[676] Fix | Delete
"image": false,
[677] Fix | Delete
"useBody": true
[678] Fix | Delete
}
[679] Fix | Delete
}
[680] Fix | Delete
</script>
[681] Fix | Delete
</amp-analytics>
[682] Fix | Delete
<?php } }
[683] Fix | Delete
// Marfeel Analytics
[684] Fix | Delete
if(true == ampforwp_get_setting('amp-marfeel-pixel')){
[685] Fix | Delete
$account_id = ampforwp_get_setting('amp-marfeel-account-id'); ?>
[686] Fix | Delete
<amp-analytics config="https://events.newsroom.bi/amp.v1.json" data-credentials="include">
[687] Fix | Delete
<script type="application/json" >
[688] Fix | Delete
{
[689] Fix | Delete
"vars" : {
[690] Fix | Delete
"accountId": "<?php echo esc_attr($account_id);?>"
[691] Fix | Delete
}
[692] Fix | Delete
}
[693] Fix | Delete
</script>
[694] Fix | Delete
</amp-analytics><?php
[695] Fix | Delete
}
[696] Fix | Delete
[697] Fix | Delete
if( true == ampforwp_get_setting('ampforwp-iotech-switch')) {
[698] Fix | Delete
$project_id = $id = $title = $author = $categories = $cat_names = '';
[699] Fix | Delete
$project_id = ampforwp_get_setting('ampforwp-iotech-projectid');
[700] Fix | Delete
if(!empty($project_id)){
[701] Fix | Delete
$id = ampforwp_get_the_ID();
[702] Fix | Delete
$title = get_the_title($id);
[703] Fix | Delete
$lang = get_locale();
[704] Fix | Delete
$author = get_the_author_meta('display_name');
[705] Fix | Delete
$categories = get_the_terms( $id, 'category' );
[706] Fix | Delete
foreach ($categories as $key=>$cat ) {
[707] Fix | Delete
$cat_names .= '|' . $cat->name ;
[708] Fix | Delete
}
[709] Fix | Delete
$cat_names = substr($cat_names, 1);
[710] Fix | Delete
$content = get_post_field( 'post_content', $id );
[711] Fix | Delete
$word_count = str_word_count( strip_tags( $content ) );
[712] Fix | Delete
$date = get_post_time('F d, Y g:i a');
[713] Fix | Delete
?>
[714] Fix | Delete
<amp-analytics>
[715] Fix | Delete
<script type="application/json">
[716] Fix | Delete
{
[717] Fix | Delete
"requests": {
[718] Fix | Delete
"pageview": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:pageviews[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
[719] Fix | Delete
"read_top": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_top[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
[720] Fix | Delete
"read_middle": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_middle[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
[721] Fix | Delete
"read_bottom": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_bottom[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
[722] Fix | Delete
"read_finished": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:read_finished[user_id:${clientId(_io_un)},author:${article_authors},referrer_uri:${documentReferrer},url:${canonicalPath},domain:${canonicalHostname},user_agent:${userAgent},page:${page_title},platform:amp,language:${page_language},category:${article_categories},type_article:${article_type},word_count:${article_word_count},pub_date:${article_publication_date},page_type:${page_type}]",
[723] Fix | Delete
"time": "https://tt.onthe.io/?k[]=<?php echo esc_attr($project_id); ?>:time[platform:amp,url:${canonicalPath}]"
[724] Fix | Delete
},
[725] Fix | Delete
"vars": {
[726] Fix | Delete
"page_title": "$<?php echo esc_attr($title) ?>",
[727] Fix | Delete
"page_type": "article",
[728] Fix | Delete
"page_language": "<?php echo esc_attr($lang) ?>",
[729] Fix | Delete
"article_authors": "<?php echo esc_attr($author) ?>",
[730] Fix | Delete
"article_categories": "<?php echo esc_attr($cat_names) ?>",
[731] Fix | Delete
"article_type": "longread",
[732] Fix | Delete
"article_word_count": "<?php echo esc_attr($word_count) ?>",
[733] Fix | Delete
"article_publication_date": "<?php echo esc_attr($date) ?>"
[734] Fix | Delete
},
[735] Fix | Delete
"triggers": {
[736] Fix | Delete
"trackPageview": {
[737] Fix | Delete
"on": "visible",
[738] Fix | Delete
"request": "pageview"
[739] Fix | Delete
},
[740] Fix | Delete
"trackReadTop" : {
[741] Fix | Delete
"on" : "scroll",
[742] Fix | Delete
"scrollSpec": {
[743] Fix | Delete
"verticalBoundaries": [25]
[744] Fix | Delete
},
[745] Fix | Delete
"request": "read_top"
[746] Fix | Delete
},
[747] Fix | Delete
"trackReadMiddle" : {
[748] Fix | Delete
"on" : "scroll",
[749] Fix | Delete
"scrollSpec": {
[750] Fix | Delete
"verticalBoundaries": [50]
[751] Fix | Delete
},
[752] Fix | Delete
"request": "read_middle"
[753] Fix | Delete
},
[754] Fix | Delete
"trackReadBottom" : {
[755] Fix | Delete
"on" : "scroll",
[756] Fix | Delete
"scrollSpec": {
[757] Fix | Delete
"verticalBoundaries": [75]
[758] Fix | Delete
},
[759] Fix | Delete
"request": "read_bottom"
[760] Fix | Delete
},
[761] Fix | Delete
"trackReadFinished" : {
[762] Fix | Delete
"on" : "scroll",
[763] Fix | Delete
"scrollSpec": {
[764] Fix | Delete
"verticalBoundaries": [90]
[765] Fix | Delete
},
[766] Fix | Delete
"request": "read_finished"
[767] Fix | Delete
},
[768] Fix | Delete
"pageTimer": {
[769] Fix | Delete
"on": "timer",
[770] Fix | Delete
"timerSpec": {
[771] Fix | Delete
"interval": 10
[772] Fix | Delete
},
[773] Fix | Delete
"request": "time"
[774] Fix | Delete
}
[775] Fix | Delete
},
[776] Fix | Delete
"transport": {
[777] Fix | Delete
"beacon": false,
[778] Fix | Delete
"xhrpost": false,
[779] Fix | Delete
"image": true
[780] Fix | Delete
}
[781] Fix | Delete
}
[782] Fix | Delete
</script>
[783] Fix | Delete
</amp-analytics>
[784] Fix | Delete
<?php } }
[785] Fix | Delete
}
[786] Fix | Delete
// 89. Facebook Pixel
[787] Fix | Delete
add_action('amp_post_template_footer','ampforwp_facebook_pixel',11);
[788] Fix | Delete
function ampforwp_facebook_pixel() {
[789] Fix | Delete
global $redux_builder_amp;
[790] Fix | Delete
if( ampforwp_get_setting('amp-fb-pixel') ){
[791] Fix | Delete
$amp_pixel = '<amp-pixel ';
[792] Fix | Delete
if(ampforwp_get_data_consent()){
[793] Fix | Delete
$amp_pixel .= 'data-block-on-consent';
[794] Fix | Delete
}
[795] Fix | Delete
$amp_pixel .= ' src="https://www.facebook.com/tr?id='.esc_attr(ampforwp_get_setting('amp-fb-pixel-id')).'&ev=PageView&noscript=1"></amp-pixel>';
[796] Fix | Delete
echo $amp_pixel; // escaped above
[797] Fix | Delete
}
[798] Fix | Delete
}
[799] Fix | Delete
// For Setting up Google AMP Client ID API
[800] Fix | Delete
add_action( 'amp_post_template_head' , 'ampforwp_analytics_clientid_api' );
[801] Fix | Delete
if( ! function_exists( ' ampforwp_analytics_clientid_api ' ) ) {
[802] Fix | Delete
function ampforwp_analytics_clientid_api() {
[803] Fix | Delete
global $redux_builder_amp;
[804] Fix | Delete
if ( true == ampforwp_get_setting('ampforwp-ga-switch') || true == ampforwp_get_setting('amp-use-gtm-option')){ ?>
[805] Fix | Delete
<meta name="amp-google-client-id-api" content="googleanalytics">
[806] Fix | Delete
<?php }
[807] Fix | Delete
}
[808] Fix | Delete
}
[809] Fix | Delete
[810] Fix | Delete
if ( ! function_exists('amp_activate') ) {
[811] Fix | Delete
add_action('amp_init', 'amp_gtm_remove_analytics_code');
[812] Fix | Delete
function amp_gtm_remove_analytics_code() {
[813] Fix | Delete
global $redux_builder_amp;
[814] Fix | Delete
if( isset($redux_builder_amp['amp-use-gtm-option']) && $redux_builder_amp['amp-use-gtm-option'] ) {
[815] Fix | Delete
[816] Fix | Delete
//Add GTM Analytics code right after the body tag
[817] Fix | Delete
add_action('ampforwp_body_beginning','AMPforWP\\AMPVendor\\amp_post_template_add_analytics_data',10);
[818] Fix | Delete
}
[819] Fix | Delete
}
[820] Fix | Delete
//Remove other analytics if GTM is enable
[821] Fix | Delete
add_action('amp_post_template_footer','ampforwp_gtm_support', 9);
[822] Fix | Delete
function ampforwp_gtm_support(){
[823] Fix | Delete
global $redux_builder_amp;
[824] Fix | Delete
if( isset($redux_builder_amp['amp-use-gtm-option']) && $redux_builder_amp['amp-use-gtm-option'] ) {
[825] Fix | Delete
remove_action( 'amp_post_template_footer', 'AMPforWP\\AMPVendor\\amp_post_template_add_analytics_data' );
[826] Fix | Delete
}
[827] Fix | Delete
}
[828] Fix | Delete
}
[829] Fix | Delete
// Create GTM support
[830] Fix | Delete
[831] Fix | Delete
add_action( 'ampforwp_body_beginning', 'ampforwp_add_advance_gtm_fields' );
[832] Fix | Delete
function ampforwp_add_advance_gtm_fields( $ampforwp_adv_gtm_fields ) {
[833] Fix | Delete
if(true == ampforwp_get_setting('amp-use-gtm-option')){
[834] Fix | Delete
$gtm_id = ampforwp_get_setting('amp-gtm-id');
[835] Fix | Delete
$gtm_analytics = ampforwp_get_setting('amp-gtm-analytics-code');
[836] Fix | Delete
if(true == ampforwp_get_setting('ampforwp-gtm-field-advance-switch') ){
[837] Fix | Delete
$ampforwp_adv_gtm_fields = "";
[838] Fix | Delete
$ampforwp_adv_gtm_fields = ampforwp_get_setting('ampforwp-gtm-field-advance');
[839] Fix | Delete
$ampforwp_adv_gtm_fields = preg_replace('!/\*.*?\*/!s', '', $ampforwp_adv_gtm_fields);
[840] Fix | Delete
$ampforwp_adv_gtm_fields = preg_replace('/\n\s*\n/', '', $ampforwp_adv_gtm_fields);
[841] Fix | Delete
$ampforwp_adv_gtm_fields = preg_replace('/\/\/(.*?)\s(.*)/m', '$2', $ampforwp_adv_gtm_fields);
[842] Fix | Delete
[843] Fix | Delete
$id = ampforwp_get_the_ID();
[844] Fix | Delete
$title = get_the_title($id);
[845] Fix | Delete
$category_detail = get_the_category($id);//$post->ID
[846] Fix | Delete
$category_name = '';
[847] Fix | Delete
if ( ! empty( $category_detail ) ) {
[848] Fix | Delete
foreach($category_detail as $cd){
[849] Fix | Delete
$category_name_array[] = $cd->cat_name;
[850] Fix | Delete
}
[851] Fix | Delete
$category_name = implode( ', ', $category_name_array );
[852] Fix | Delete
}
[853] Fix | Delete
$url = get_the_permalink();
[854] Fix | Delete
$author_id = get_post_field( 'post_author', $id );
[855] Fix | Delete
$author_name = get_the_author_meta( 'display_name' , $author_id );
[856] Fix | Delete
$published_at = get_the_date( 'F j, Y' , $id );
[857] Fix | Delete
$tags = get_the_tags( $id );
[858] Fix | Delete
$tagNames = '';
[859] Fix | Delete
if( !empty($tags) ){
[860] Fix | Delete
foreach( $tags as $tag ) {
[861] Fix | Delete
$tag_names[] = $tag->name;
[862] Fix | Delete
}
[863] Fix | Delete
$tagNames = implode( ', ', $tag_names );
[864] Fix | Delete
}
[865] Fix | Delete
[866] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{url}', $url, $ampforwp_adv_gtm_fields);
[867] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{id}', $id, $ampforwp_adv_gtm_fields);
[868] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{title}', $title, $ampforwp_adv_gtm_fields);
[869] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{author_id}', $author_id, $ampforwp_adv_gtm_fields);
[870] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{author_name}', $author_name, $ampforwp_adv_gtm_fields);
[871] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{category}', $category_name, $ampforwp_adv_gtm_fields);
[872] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{published_at}', $published_at, $ampforwp_adv_gtm_fields);
[873] Fix | Delete
$ampforwp_adv_gtm_fields = str_replace('{tags}', $tagNames, $ampforwp_adv_gtm_fields);
[874] Fix | Delete
[875] Fix | Delete
if($gtm_id!=""){?>
[876] Fix | Delete
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo esc_attr($gtm_id);?>" <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?>><script type="application/json"><?php echo sanitize_text_field($ampforwp_adv_gtm_fields) ?></script></amp-analytics> <?php
[877] Fix | Delete
}
[878] Fix | Delete
}else{
[879] Fix | Delete
if($gtm_id!="" && empty($gtm_analytics)){ ?>
[880] Fix | Delete
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo esc_attr($gtm_id);?>" <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?>></amp-analytics> <?php
[881] Fix | Delete
}
[882] Fix | Delete
if($gtm_id!="" && !empty($gtm_analytics)){ ?>
[883] Fix | Delete
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo esc_attr($gtm_id);?>" <?php if(ampforwp_get_data_consent()){?>data-block-on-consent <?php } ?>data-credentials="include"><script type="application/json">{ "vars": { "account": "<?php echo esc_html($gtm_analytics);?>"} }</script></amp-analytics>
[884] Fix | Delete
<?php }
[885] Fix | Delete
}
[886] Fix | Delete
}
[887] Fix | Delete
}
[888] Fix | Delete
[889] Fix | Delete
[890] Fix | Delete
// 83. Advance Analytics(Google Analytics)
[891] Fix | Delete
add_filter('ampforwp_advance_google_analytics','ampforwp_add_advance_ga_fields');
[892] Fix | Delete
function ampforwp_add_advance_ga_fields($ga_fields){
[893] Fix | Delete
global $redux_builder_amp, $post;
[894] Fix | Delete
$url = $title = $id = $author_id = $author_name = '';
[895] Fix | Delete
$url = get_the_permalink();
[896] Fix | Delete
$tag_names = array();
[897] Fix | Delete
if(!is_object($post)){ return $ga_fields; }
[898] Fix | Delete
$id = ampforwp_get_the_ID();
[899] Fix | Delete
$title = get_the_title($id);
[900] Fix | Delete
$category_detail = get_the_category($id);//$post->ID
[901] Fix | Delete
$category_name = '';
[902] Fix | Delete
if ( ! empty( $category_detail ) ) {
[903] Fix | Delete
foreach($category_detail as $cd){
[904] Fix | Delete
$category_name_array[] = $cd->cat_name;
[905] Fix | Delete
}
[906] Fix | Delete
$category_name = implode( ', ', $category_name_array );
[907] Fix | Delete
}
[908] Fix | Delete
$tags = get_the_tags( $id );
[909] Fix | Delete
$focusKeyword = '';
[910] Fix | Delete
$seoScore = '';
[911] Fix | Delete
if( defined('WPSEO_FILE')){
[912] Fix | Delete
$focusKeyword = get_post_meta($id, '_yoast_wpseo_focuskw', true);
[913] Fix | Delete
$seoScore = get_post_meta($id, '_yoast_wpseo_content_score', true);
[914] Fix | Delete
}
[915] Fix | Delete
[916] Fix | Delete
$tagNames = '';
[917] Fix | Delete
if( !empty($tags) ){
[918] Fix | Delete
foreach( $tags as $tag ) {
[919] Fix | Delete
$tag_names[] = $tag->name;
[920] Fix | Delete
}
[921] Fix | Delete
$tagNames = implode( ', ', $tag_names );
[922] Fix | Delete
}
[923] Fix | Delete
$author_id = get_post_field( 'post_author', $id );
[924] Fix | Delete
$author_name = get_the_author_meta( 'display_name' , $author_id );
[925] Fix | Delete
$published_at = get_the_date( 'F j, Y' , $id );
[926] Fix | Delete
$ampforwp_adv_ga_fields = array();
[927] Fix | Delete
$ampforwp_adv_ga_fields = ampforwp_get_setting('ampforwp-ga-field-advance');
[928] Fix | Delete
if($ampforwp_adv_ga_fields) {
[929] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{url}', $url, $ampforwp_adv_ga_fields);
[930] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{id}', $id, $ampforwp_adv_ga_fields);
[931] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{title}', $title, $ampforwp_adv_ga_fields);
[932] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{author_id}', $author_id, $ampforwp_adv_ga_fields);
[933] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{author_name}', $author_name, $ampforwp_adv_ga_fields);
[934] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{category}', $category_name, $ampforwp_adv_ga_fields);
[935] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{published_at}', $published_at, $ampforwp_adv_ga_fields);
[936] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{tags}', $tagNames, $ampforwp_adv_ga_fields);
[937] Fix | Delete
if( defined('WPSEO_FILE')){
[938] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{seo_score}', $seoScore, $ampforwp_adv_ga_fields);
[939] Fix | Delete
$ampforwp_adv_ga_fields = str_replace('{focus_keyword}', $focusKeyword, $ampforwp_adv_ga_fields);
[940] Fix | Delete
}
[941] Fix | Delete
return $ampforwp_adv_ga_fields;
[942] Fix | Delete
}
[943] Fix | Delete
return $ga_fields;
[944] Fix | Delete
}
[945] Fix | Delete
[946] Fix | Delete
//Advance Analytics(Google Analytics 4)
[947] Fix | Delete
add_filter('ampforwp_advance_google_analytics4','ampforwp_add_advance_ga4_fields');
[948] Fix | Delete
function ampforwp_add_advance_ga4_fields($ga4_fields){
[949] Fix | Delete
global $redux_builder_amp, $post;
[950] Fix | Delete
$url = $title = $id = $author_id = $author_name = '';
[951] Fix | Delete
$url = get_the_permalink();
[952] Fix | Delete
$tag_names = array();
[953] Fix | Delete
if(!is_object($post)){ return $ga4_fields; }
[954] Fix | Delete
$id = ampforwp_get_the_ID();
[955] Fix | Delete
$title = get_the_title($id);
[956] Fix | Delete
$category_detail = get_the_category($id);//$post->ID
[957] Fix | Delete
$category_name = '';
[958] Fix | Delete
if ( ! empty( $category_detail ) ) {
[959] Fix | Delete
foreach($category_detail as $cd){
[960] Fix | Delete
$category_name_array[] = $cd->cat_name;
[961] Fix | Delete
}
[962] Fix | Delete
$category_name = implode( ', ', $category_name_array );
[963] Fix | Delete
}
[964] Fix | Delete
$tags = get_the_tags( $id );
[965] Fix | Delete
$focusKeyword = '';
[966] Fix | Delete
$seoScore = '';
[967] Fix | Delete
if( defined('WPSEO_FILE')){
[968] Fix | Delete
$focusKeyword = get_post_meta($id, '_yoast_wpseo_focuskw', true);
[969] Fix | Delete
$seoScore = get_post_meta($id, '_yoast_wpseo_content_score', true);
[970] Fix | Delete
}
[971] Fix | Delete
[972] Fix | Delete
$tagNames = '';
[973] Fix | Delete
if( !empty($tags) ){
[974] Fix | Delete
foreach( $tags as $tag ) {
[975] Fix | Delete
$tag_names[] = $tag->name;
[976] Fix | Delete
}
[977] Fix | Delete
$tagNames = implode( ', ', $tag_names );
[978] Fix | Delete
}
[979] Fix | Delete
$author_id = get_post_field( 'post_author', $id );
[980] Fix | Delete
$author_name = get_the_author_meta( 'display_name' , $author_id );
[981] Fix | Delete
$published_at = get_the_date( 'F j, Y' , $id );
[982] Fix | Delete
$ampforwp_adv_ga4_fields = array();
[983] Fix | Delete
$ampforwp_adv_ga4_fields = ampforwp_get_setting('ampforwp-ga4-field-advance');
[984] Fix | Delete
if($ampforwp_adv_ga4_fields) {
[985] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{url}', $url, $ampforwp_adv_ga4_fields);
[986] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{id}', $id, $ampforwp_adv_ga4_fields);
[987] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{title}', $title, $ampforwp_adv_ga4_fields);
[988] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{author_id}', $author_id, $ampforwp_adv_ga4_fields);
[989] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{author_name}', $author_name, $ampforwp_adv_ga4_fields);
[990] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{category}', $category_name, $ampforwp_adv_ga4_fields);
[991] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{published_at}', $published_at, $ampforwp_adv_ga4_fields);
[992] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{tags}', $tagNames, $ampforwp_adv_ga4_fields);
[993] Fix | Delete
if( defined('WPSEO_FILE')){
[994] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{seo_score}', $seoScore, $ampforwp_adv_ga4_fields);
[995] Fix | Delete
$ampforwp_adv_ga4_fields = str_replace('{focus_keyword}', $focusKeyword, $ampforwp_adv_ga4_fields);
[996] Fix | Delete
}
[997] Fix | Delete
return $ampforwp_adv_ga4_fields;
[998] Fix | Delete
}
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function