| '; echo strip_tags($redux_builder_amp['amp-notification-text'],$allowed_tags); ?>
';
$output .= '';
$output .= '';
$output .= '';
$output .= '';
$output .= '';
$output .= ''.esc_attr($redux_builder_amp['ampforwp-ads-sponsorship-label']).'';
}
}
// Ads Optimize For Viewability
if( !function_exists('ampforwp_ad_optimize')){
function ampforwp_ad_optimize(){
global $redux_builder_amp;
$optimized_code = '';
if( true == ampforwp_get_setting('ampforwp-ads-data-loading-strategy')){
$optimized_code = 'data-loading-strategy=prefer-viewability-over-views';
}
return $optimized_code;
}
}
// 10. Analytics Area
add_action('amp_post_template_footer','ampforwp_analytics',11);
function ampforwp_analytics() {
// 10.1 Analytics Support added for Google Analytics
global $redux_builder_amp;
if( false == ampforwp_get_setting('amp-use-gtm-option')) {
if ( true == ampforwp_get_setting('ampforwp-ga-switch')){
$ga_fields = array();
$ampforwp_ga_fields = array();
$ga_account = '';
$ga_account = ampforwp_get_setting('ga-feild');
$ga_account = str_replace(' ', '', $ga_account);
$ga_fields = array(
'vars'=>array(
'account'=>$ga_account,
),
'triggers'=> array(
'trackPageview'=> array(
'on'=>'visible',
'request'=>'pageview'
)
)
);
if ( true == ampforwp_get_setting('ampforwp-ga-field-anonymizeIP')) {
$ga_fields['vars']['anonymizeIP'] = 'set';
}
$ampforwp_ga_fields = json_encode( $ga_fields);
$ampforwp_ga_fields = apply_filters('ampforwp_advance_google_analytics', $ampforwp_ga_fields ); ?>
data-block-on-consent type="googleanalytics" id="analytics1">
array(
'writeKey'=>$segment,
'name'=>get_the_title()
),
);
$ampforwp_segment_fields = apply_filters('ampforwp_segment_analytics', $ampforwp_segment_fields );
$ampforwp_segment_fields = json_encode( $segment_fields);
?>
data-block-on-consent type="segment">
data-block-on-consent src="">
array(
'pcode'=>$quantcast,
'labels'=> array("AMPProject")
),
);
$ampforwp_quantcast_fields = apply_filters('ampforwp_quantcast_analytics', $ampforwp_quantcast_fields );
$ampforwp_quantcast_fields = json_encode( $quantcast_fields);
?>
data-block-on-consent type="quantcast">
array(
'c1'=>$comscore_c1,
'c2'=>$comscore_c2
),
);
$ampforwp_comscore_fields = apply_filters('ampforwp_comscore_analytics', $ampforwp_comscore_fields );
$ampforwp_comscore_fields = json_encode( $comscore_fields);
?> data-block-on-consent type="comscore">
data-block-on-consent src="" >
data-block-on-consent src="" >
data-block-on-consent src="//sstatic1.histats.com/0.gif?&101" >
array(
'counterId'=>$yandex,
),
'triggers'=> array(
'notBounce'=> array(
'on'=>'timer',
'timerSpec'=> array(
'immediate'=>'false',
'interval'=>'15',
'maxTimerLength'=>'16',
),
'request'=>'notBounce'
)
)
);
$ampforwp_yandex_fields = apply_filters('ampforwp_yandex_analytics', $ampforwp_yandex_fields );
$ampforwp_yandex_fields = json_encode( $yandex_fields);
?>
data-block-on-consent type="metrika">
array(
'accountId'=>$chartbeat,
'title'=>get_the_title(),
'authors'=>get_the_author_meta('display_name'),
'dashboardDomain'=>site_url()
),
);
$ampforwp_chartbeat_fields = apply_filters('ampforwp_chartbeat_analytics', $ampforwp_chartbeat_fields );
$ampforwp_chartbeat_fields = json_encode( $chartbeat_fields);
?>
data-block-on-consent type="chartbeat">
array(
'atrk_acct'=>$alexa,
'domain'=>$domain
),
);
$ampforwp_alexa_fields = apply_filters('ampforwp_alexa_analytics', $ampforwp_alexa_fields );
$ampforwp_alexa_fields = json_encode( $alexa_fields);
?>
data-block-on-consent type="alexametrics">
99999)
$afs_server = 'www1';
if ($afs_account > 199999)
$afs_server = 'www2';
if ($afs_account > 299999)
$afs_server = 'www3';
if ($afs_account > 399999)
$afs_server = 'www4';
if ($afs_account > 499999)
$afs_server = 'www5';
if ($afs_account > 599999)
$afs_server = 'www6';
if ($afs_account > 699999)
$afs_server = 'www7';
if ($afs_account > 799999)
$afs_server = 'www8';
if ($afs_account > 899999)
$afs_server = 'www9';
if ($afs_account > 999999)
$afs_server = 'www10';
$afs_fields = array(
'vars'=>array(
'server'=>$afs_server,
'websiteid'=>$afs_account,
'title'=>get_the_title(),
'url'=>site_url()
),
);
$ampforwp_afs_fields = apply_filters('ampforwp_afs_analytics', $ampforwp_afs_fields );
$ampforwp_afs_fields = json_encode( $afs_fields);
?>
data-block-on-consent type="afsanalytics">
]*/', '', $content);
$content = preg_replace('/vocab=[^>]*/', '', $content);
$content = preg_replace('/(<[^>]+) value=[^>]*/', '$1', $content);
$content = preg_replace('/noshade=[^>]*/', '', $content);
$content = preg_replace('/contenteditable=[^>]*/', '', $content);
$content = preg_replace('/non-refundable=[^>]*/', '', $content);
$content = preg_replace('/security=[^>]*/', '', $content);
$content = preg_replace('/deposit=[^>]*/', '', $content);
$content = preg_replace('/for=[^>]*/', '', $content);
$content = preg_replace('/nowrap="nowrap"/', '', $content);
$content = preg_replace('#(.*?)#i', '', $content);
$content = preg_replace('#(.*?)#i', '', $content);
$content = preg_replace('#(.*?)#i', '', $content);
$content = preg_replace('##i', '', $content);
//Removed because class is being removed from table #2699
$content = preg_replace('/href="javascript:void*/', ' ', $content);
// Convert the Wistia embed into URL to build amp-wistia-player and remove unnecesarry wistia code
$content = preg_replace('/
';
}
return $output;
}
}
//AMP to WP Theme Analytics
add_action('wp_footer','ampforwp_nonamp_analytics');
if ( ! function_exists('ampforwp_nonamp_analytics') ) {
function ampforwp_nonamp_analytics() {
global $redux_builder_amp;
$ga_account = $redux_builder_amp['ga-feild'];
if ( ampforwp_is_non_amp("non_amp_check_convert") ) {
echo "
";
}
}
}
// Coauthors Compatibility #1895
add_filter('coauthors_posts_link', 'ampforwp_coauthors_links');
function ampforwp_coauthors_links($args){
global $redux_builder_amp;
if ( function_exists('ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint() && true == $redux_builder_amp['ampforwp-archive-support']) {
$args['href'] = ampforwp_url_controller($args['href']);
}
return $args;
}
// amp-image-lightbox #1892
if ( ! function_exists('ampforwp_amp_img_lightbox') ) {
function ampforwp_amp_img_lightbox(){
echo '';
}
}
// New Image attributes for amp-image-lightbox #1892
add_filter('amp_img_attributes', 'ampforwp_img_new_attrs');
function ampforwp_img_new_attrs($attributes) {
global $redux_builder_amp;
if ( isset($redux_builder_amp['ampforwp-amp-img-lightbox']) && $redux_builder_amp['ampforwp-amp-img-lightbox'] ) {
$attributes['on'] = 'tap:amp-img-lightbox';
$attributes['role'] = 'button';
$attributes['tabindex'] = '0';
}
return $attributes;
}
// Facebook Comments script for AMP2WP
add_action('ampforwp_body_beginning', 'ampforwp_amp2wp_fb');
if ( ! function_exists('ampforwp_amp2wp_fb') ) {
function ampforwp_amp2wp_fb(){
global $redux_builder_amp;
if( ampforwp_is_non_amp() && isset($redux_builder_amp['ampforwp-amp-convert-to-wp']) && $redux_builder_amp['ampforwp-amp-convert-to-wp'] && ($redux_builder_amp['ampforwp-facebook-comments-support'] || $redux_builder_amp['ampforwp-facebook-like-button']) ) {
echo '
';
}
}
}
// Backward Compatibility
function ampforwp_correct_frontpage() {
return ampforwp_get_frontpage_id();
}
//Common function to get frontpageID
function ampforwp_get_frontpage_id() {
global $redux_builder_amp;
$post_id = '';
//$post_id = get_the_ID();
if ( ampforwp_is_front_page() && $redux_builder_amp['amp-frontpage-select-option']==1
&& isset( $redux_builder_amp['amp-frontpage-select-option-pages'] )
) {
$post_id = $redux_builder_amp['amp-frontpage-select-option-pages'];
}
$post_id = apply_filters('ampforwp_modify_frontpage_id', $post_id);
return $post_id;
}
// Removing AMPHTML Added by Facebook's Instant Article's Plugin #2043
add_action( 'wp', 'ampforwp_remove_instant_articles_amp_markup' );
function ampforwp_remove_instant_articles_amp_markup(){
if(class_exists('Instant_Articles_AMP_Markup')){
remove_action( 'wp_head', array('Instant_Articles_AMP_Markup', 'inject_link_rel') );
}
}
// #2042
function ampforwp_404_canonical(){
global $wp;
return home_url( $wp->request );
}
// #2001 removing unused JS from the Paginated Posts
add_filter('ampforwp_post_content_filter', 'ampforwp_paginated_post_content');
function ampforwp_paginated_post_content($content){
global $numpages;
if(is_singular()){
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var('paged');
} elseif ( get_query_var( 'page' ) ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
if( $numpages >= 2 && true == ampforwp_get_setting('amp-pagination') ){
return get_the_content();
}
}
return $content;
}
// GDPR Compliancy #2040
add_action('amp_init', 'ampforwp_gdpr_init');
if ( ! function_exists('ampforwp_gdpr_init') ) {
function ampforwp_gdpr_init() {
if ( ampforwp_get_setting('amp-gdpr-compliance-switch') ) {
// gdpr component
add_action('amp_footer_link' , 'amp_gdpr' );
}
}
}
// #1696
add_action('wp','ampforwp_remove_squirly_js');
function ampforwp_remove_squirly_js(){
if(function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint()){
if(class_exists('SQ_Classes_ObjController')){
$SQ_Classes_ObjController = new SQ_Classes_ObjController();
$sq_analytics_class_obj = $SQ_Classes_ObjController::getClass('SQ_Models_Services_Analytics');
}
}
}
// Thrive Leads Compatibility #2067
add_filter('thrive_leads_skip_request', 'ampforwp_skip_thrive_leads');
if ( ! function_exists('ampforwp_skip_thrive_leads') ) {
function ampforwp_skip_thrive_leads($skip) {
// Skip thrive leads on AMP
if ( function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
return true;
}
return $skip;
}
}
// Re-save permalink once the post value changed in Redading Settings #2190
add_action( 'update_option', 'ampforwp_resave_permalink', 10, 3 );
function ampforwp_resave_permalink( $option, $old_value, $value ){
if('posts_per_page' === $option){
if($old_value != $value){
delete_transient( 'ampforwp_current_version_check' );
}
}
}
// Canonical From Yoast #2118 and All in One SEO #1720
function ampforwp_generate_canonical(){
global $redux_builder_amp;
$canonical = '';
$canonical = $WPSEO_Frontend = $All_in_One_SEO_Pack = $opts = '';
if ( isset($redux_builder_amp['ampforwp-seo-yoast-canonical']) && true == $redux_builder_amp['ampforwp-seo-yoast-canonical'] && class_exists('WPSEO_Frontend') ) {
$WPSEO_Frontend = WPSEO_Frontend::get_instance();
$canonical = $WPSEO_Frontend->canonical(false);
}
elseif ( isset($redux_builder_amp['ampforwp-seo-aioseo-canonical']) && true == $redux_builder_amp['ampforwp-seo-aioseo-canonical'] && class_exists('All_in_One_SEO_Pack') ) {
$All_in_One_SEO_Pack = new All_in_One_SEO_Pack();
$opts = $All_in_One_SEO_Pack->get_current_options( array(), 'aiosp' );
$canonical = $opts['aiosp_custom_link'];
}
elseif (defined( 'RANK_MATH_FILE' ) && 'rank_math' == ampforwp_get_setting('ampforwp-seo-selection') ) {
$canonical = rank_math()->head->canonical( false );
}
return $canonical;
}
add_filter('amp_post_template_data', 'ampforwp_modified_canonical', 85);
function ampforwp_modified_canonical( $data ) {
$canonical = '';
$canonical = ampforwp_generate_canonical();
if ( !empty($canonical) ) {
$data['canonical_url'] = $canonical;
}
return $data;
}
function ampforwp_get_data_consent(){
global $redux_builder_amp;
$dboc = false;
$is_dboc = '';
if(isset($redux_builder_amp['amp-gdpr-compliance-switch']) && $redux_builder_amp['amp-gdpr-compliance-switch'] ){
$dboc = true;
}
return $dboc;
}
function ampforwp_amp_consent_check($attrs){
if( ampforwp_get_data_consent() ){
$attrs['data-block-on-consent'] = '';
}
$attrs = apply_filters( 'ampforwp_embedd_attrs_handler', $attrs );
return $attrs;
}
// #2220 Remove Space Shortcode by Pro Theme from THEMCO
add_action('pre_amp_render_post','ampforwp_remove_space_shortcodes');
function ampforwp_remove_space_shortcodes(){
add_filter('the_content','ampforwp_remove_pro_theme_space_shortcodes');
}
function ampforwp_remove_pro_theme_space_shortcodes($content){
if(has_shortcode( $content, 'gap' )){
remove_shortcode( 'gap' );
// to remove the useless shortcode from the AMP Content
add_shortcode( 'gap', 'ampforwp_return_no_gap' );
}
return $content;
}
function ampforwp_return_no_gap(){
return;
}
/*
#2229 Function to check the option for comments to display on post, page or both.
*/
function ampforwp_get_comments_status(){
global $redux_builder_amp;
$display_comments_on = "";
if ( false == ampforwp_get_setting('ampforwp-display-on-pages') && true == ampforwp_get_setting('ampforwp-display-on-posts') ) {
$display_comments_on = is_single();
}
if ( true == ampforwp_get_setting('ampforwp-display-on-pages') && false == ampforwp_get_setting('ampforwp-display-on-posts') ) {
$display_comments_on = is_page();
}
if ( true == ampforwp_get_setting('ampforwp-display-on-pages') && true == ampforwp_get_setting('ampforwp-display-on-posts')) {
$display_comments_on = is_singular();
if ( ampforwp_is_front_page() ) {
$display_comments_on = ampforwp_is_front_page();
}
}
$display_comments_on = apply_filters('ampforwp_comments_visibility', $display_comments_on);
return $display_comments_on;
}
// Vuukle Comments Support #2075
add_action('ampforwp_post_after_design_elements','ampforwp_vuukle_comments_support');
function ampforwp_vuukle_comments_support() {
global $redux_builder_amp;
if ( 4 != $redux_builder_amp['amp-design-selector']
&& isset($redux_builder_amp['ampforwp-vuukle-comments-support'])
&& $redux_builder_amp['ampforwp-vuukle-comments-support']==1
&& comments_open()
) {
echo ampforwp_vuukle_comments_markup();
}
}
function ampforwp_vuukle_comments_markup() {
global $redux_builder_amp;
$apiKey = $locale = '';
if( isset($redux_builder_amp['ampforwp-vuukle-comments-apiKey']) && $redux_builder_amp['ampforwp-vuukle-comments-apiKey'] !== ""){
$apiKey = $redux_builder_amp['ampforwp-vuukle-comments-apiKey'];
}
$display_comments_on = false;
$display_comments_on = ampforwp_get_comments_status();
$siteUrl = trim(site_url(), '/');
if (!preg_match('#^http(s)?://#', $siteUrl)) {
$siteUrl = 'http://' . $siteUrl;
}
$urlParts = parse_url($siteUrl);
$siteUrl = preg_replace('/^www\./', '', $urlParts['host']);// remove www
$srcUrl = 'https://cdn.vuukle.com/amp.html?';
$srcUrl = add_query_arg('url' ,get_permalink(), $srcUrl);
$srcUrl = add_query_arg('host' ,$siteUrl, $srcUrl);
$srcUrl = add_query_arg('id' , $post->ID, $srcUrl);
$srcUrl = add_query_arg('apiKey' , $apiKey, $srcUrl);
$srcUrl = add_query_arg('title' , urlencode($post->post_title), $srcUrl);
$vuukle_html ='';
if ( $display_comments_on ) {
$vuukle_html .= '
Show comments ';
}
return $vuukle_html;
}
add_filter( 'amp_post_template_data', 'ampforwp_add_vuukle_scripts' );
function ampforwp_add_vuukle_scripts( $data ) {
global $redux_builder_amp;
$display_comments_on = "";
$display_comments_on = ampforwp_get_comments_status();
if ( ampforwp_get_setting('ampforwp-vuukle-comments-support') && $display_comments_on) {
if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) {
$data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
}
if ($redux_builder_amp['ampforwp-vuukle-Ads-before-comments']==1
&& empty( $data['amp_component_scripts']['amp-ad'] ) ) {
$data['amp_component_scripts']['amp-ad'] = 'https://cdn.ampproject.org/v0/amp-ad-0.1.js';
}
}
return $data;
}
//spotim #2076
add_action('ampforwp_post_after_design_elements','ampforwp_spotim_comments_support');
function ampforwp_spotim_comments_support() {
global $redux_builder_amp;
if ( 4 != $redux_builder_amp['amp-design-selector']
&& isset($redux_builder_amp['ampforwp-spotim-comments-support'])
&& $redux_builder_amp['ampforwp-spotim-comments-support']==1
) {
echo ampforwp_spotim_comments_markup();
}
}
function ampforwp_spotim_comments_markup() {
global $post, $redux_builder_amp;
$display_comments_on = false;
$display_comments_on = ampforwp_get_comments_status();
if (! $display_comments_on ) {
return '';
}
$spotId ='';
if( isset($redux_builder_amp['ampforwp-spotim-comments-apiKey']) && $redux_builder_amp['ampforwp-spotim-comments-apiKey'] !== ""){
$spotId = $redux_builder_amp['ampforwp-spotim-comments-apiKey'];
}
$srcUrl = 'https://amp.spot.im/production.html?';
$srcUrl = add_query_arg('spotId' ,get_permalink(), $srcUrl);
$srcUrl = add_query_arg('postId' , $post->ID, $srcUrl);
$spotim_html = '
Load more...
';
return $spotim_html;
}
//spotim script
add_filter( 'amp_post_template_data', 'ampforwp_add_spotim_scripts' );
function ampforwp_add_spotim_scripts( $data ) {
global $redux_builder_amp;
$display_comments_on = "";
$display_comments_on = ampforwp_get_comments_status();
if ( 4 != $redux_builder_amp['amp-design-selector']
&& isset($redux_builder_amp['ampforwp-spotim-comments-support'])
&& $redux_builder_amp['ampforwp-spotim-comments-support']
&& $display_comments_on && comments_open()
) {
if ( empty( $data['amp_component_scripts']['amp-iframe'] ) ) {
$data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js';
}
}
return $data;
}
//spotim css
add_action('amp_post_template_css','ampforwp_spotim_vuukle_styling',60);
function ampforwp_spotim_vuukle_styling(){
global $redux_builder_amp;
$display_comments_on = "";
$display_comments_on = ampforwp_get_comments_status();
if ( isset($redux_builder_amp['ampforwp-spotim-comments-support'])
&& $redux_builder_amp['ampforwp-spotim-comments-support']
&& $display_comments_on && comments_open() ) {
?>.spot-im-amp-overflow {
background: white;
font-size: 15px;
padding: 15px 0;
text-align: center;
font-family: Helvetica, Arial, sans-serif;
color: #307fe2;
}
.afwp-vuukle-support{
display: block;text-align: center;background: #1f87e5;color: #fff;border-radius: 4px;
}
';
}
}
// Function to check if the query and the post name are same #2361
function ampforwp_is_query_post_same($haystack = '' , $needle = ''){
$result = '';
if(!empty($haystack) && !empty($needle)){
$result = strpos($haystack ,$needle);
}
if( ($result != false || is_int($result)) && !empty($result) ){
return true;
}
return false;
}
// rel="next" & rel="prev" pagination meta tags #2343
add_action( 'amp_post_template_head', 'ampforwp_rel_next_prev' );
function ampforwp_rel_next_prev(){
global $paged;
if ( get_previous_posts_link() ) { ?>
' . $content . '';
$content = $content . '';
$content = $content . '';
return $content;
}
// Content Sneak Peek Scripts css
function ampforwp_sneak_peek_css(){
global $redux_builder_amp;
$height = $txt_color = $btn_color = '';
$height = $redux_builder_amp['content-sneak-peek-height'];
$btn_color = $redux_builder_amp['content-sneak-peek-btn-color']['color'];
$txt_color = $redux_builder_amp['content-sneak-peek-txt-color']['color'];?>
.fd-h{height: ;overflow: hidden;}
.fd-b-c{text-align: center;}
.fd-b-c .fd-b {border: 1px solid #93abbc;border-radius: 5px;color: ;font-size: 16px;font-weight: 700;line-height: 24px;padding: 8px 5px;width: 250px;background-color: ; }
array(),
'AMP_Blacklist_Sanitizer' => array(),
'AMP_Style_Sanitizer' => array(),
'AMP_Video_Sanitizer' => array(),
'AMP_Audio_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
),
)
)
);
$content = $sanitizer_obj->get_amp_content();
return $content;
}
// Instant Articles Meta Box
add_action( 'add_meta_boxes', 'ampforwp_ia_meta_box' );
if ( ! function_exists('ampforwp_ia_meta_box') ) {
function ampforwp_ia_meta_box() {
global $redux_builder_amp, $post;
$user_level = '';
$user_level = current_user_can( 'manage_options' );
if ( isset( $redux_builder_amp['amp-meta-permissions'] ) && $redux_builder_amp['amp-meta-permissions'] == 'all' ) {
$user_level = true;
}
if ( $user_level ) {
if( true == $redux_builder_amp['fb-instant-article-switch'] && $post->post_type == 'post' ) {
add_meta_box( 'ampforwp_ia_meta', esc_html__( 'Show Instant Article for Current Post?','accelerated-mobile-pages' ), 'ampforwp_ia_meta_callback', 'post','side' );
}
}
}
}
// Callback function for Instant Articles Meta Box.
function ampforwp_ia_meta_callback( $post ) {
global $redux_builder_amp;
wp_nonce_field( basename( __FILE__ ), 'ampforwp_ia_nonce' );
$ampforwp_stored_meta = get_post_meta( $post->ID );
if ( ! isset($ampforwp_stored_meta['ampforwp-ia-on-off'][0]) || $ampforwp_stored_meta['ampforwp-ia-on-off'][0] == 'hide-ia') {
$exclude_post_value = get_option('ampforwp_ia_exclude_post');
if ( $exclude_post_value == null ) {
$exclude_post_value[] = 0;
}
if ( $exclude_post_value ) {
if ( ! in_array( $post->ID, $exclude_post_value ) ) {
$exclude_post_value[] = $post->ID;
update_option('ampforwp_ia_exclude_post', $exclude_post_value);
}
}
} else {
$exclude_post_value = get_option('ampforwp_ia_exclude_post');
if ( $exclude_post_value == null ) {
$exclude_post_value[] = 0;
}
if ( $exclude_post_value ) {
if ( in_array( $post->ID, $exclude_post_value ) ) {
$exclude_ids = array_diff($exclude_post_value, array($post->ID) );
update_option('ampforwp_ia_exclude_post', $exclude_ids);
}
}
} ?>
$value) {
$allowed_atts[$att] = true;
}
foreach ($allowed_amp_tags as $amp_tag => $values ) {
$allowed_amp_tags[$amp_tag] = $allowed_atts;
}
}
$allowed_html = array_merge_recursive($allowed_normal_html, $allowed_amp_tags);
if( $allowed_html ) {
foreach ( $allowed_html as $tag => $atts ) {
if ( is_array($atts) ){
unset($allowed_html[$tag]['style']);
}
if ( 'a' == $tag ) {
$allowed_html[$tag]['data-toggle'] = true;
}
if ( 'label' == $tag ) {
$allowed_html[$tag]['aria-label'] = true;
}
if ( 'amp-img' == $tag ) {
$allowed_html[$tag] = array('width'=>true,'height'=>true,'src'=>true,'layout'=>true,'alt'=>true,'on'=>true,'role'=>true,'tabindex'=>true);
}
}
$allowed_html['input'] = array('class'=>true,'type'=>true,'id'=>true,'placeholder'=>true,'value'=>true,'name'=>true);
}
return $allowed_html;
}
function ampforwp_wp_kses($data){
$allowed_html = ampforwp_wp_kses_allowed_html();
$data = wp_kses( stripslashes( $data ), $allowed_html );
return $data;
}
// Removing Marfeel plugin which was blocking internal pages of AMP #2423
add_action('wp','ampforwp_remove_marfeel',9);
function ampforwp_remove_marfeel(){
remove_action('wp', 'render_marfeel_amp_content' );
}
// Total Plus compatibility #2511
add_action('current_screen', 'ampforwp_totalplus_comp_admin');
function ampforwp_totalplus_comp_admin() {
$screen = get_current_screen();
if ( 'toplevel_page_amp_options' == $screen->base ) {
remove_action('admin_enqueue_scripts', 'total_plus_admin_scripts', 100);
}
}
// uploading the images with SVG format #2431
function ampforwp_upload_svg($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_action('upload_mimes', 'ampforwp_upload_svg');
// Ajax functions
add_action( 'wp_ajax_ampforwp_categories', 'ampforwp_ajax_cats' );
function ampforwp_ajax_cats(){
if(!wp_verify_nonce($_GET['security'],'ampforwp-verify-request') ){
echo json_encode(array('status'=>403,'message'=>'user request is not allowed')) ;
die;
}
$return = array();
$categories = get_categories(array('search'=> esc_html($_GET['q']),'number'=>500));
$categories_array = array();
if ( $categories ) :
foreach ($categories as $cat ) {
$return[] = array($cat->cat_ID,$cat->name);// array( Cat ID, Cat Name )
}
endif;
wp_send_json( $return );
}
add_action( 'wp_ajax_ampforwp_tags', 'ampforwp_ajax_tags' );
function ampforwp_ajax_tags(){
if(!wp_verify_nonce($_GET['security'],'ampforwp-verify-request') ){
echo json_encode(array('status'=>403,'message'=>'user request is not allowed')) ;
die;
}
$return = array();
$tags = get_tags(array('search'=> esc_html($_GET['q']),'number'=>500));
if ( $tags ) :
foreach ($tags as $tag ) {
$return[] = array($tag->term_id,$tag->name);// array( Tag ID, tag Name )
}
endif;
wp_send_json( $return );
}
add_filter( 'amp_post_template_data', 'ampforwp_backtotop' );
function ampforwp_backtotop( $data ) {
global $redux_builder_amp;
if(true == ampforwp_get_setting('ampforwp-footer-top')){
if ( empty( $data['amp_component_scripts']['amp-position-observer'] ) ) {
$data['amp_component_scripts']['amp-position-observer'] = 'https://cdn.ampproject.org/v0/amp-position-observer-0.1.js';
}
if ( empty( $data['amp_component_scripts']['amp-animation'] ) ) {
$data['amp_component_scripts']['amp-animation'] = 'https://cdn.ampproject.org/v0/amp-animation-0.1.js';
}
}
return $data;
}
// Jannah Theme Subtitle Support #2732
add_action('ampforwp_below_the_title','ampforwp_jannah_subtitle');
function ampforwp_jannah_subtitle(){
if (function_exists('jannah_theme_name') && function_exists('tie_get_postdata')){?>
.wp-block-button { color: #fff}
.wp-block-button a {background-color: #32373c;border-radius: 28px;color: inherit;display: inline-block;padding: 12px 24px;}
$postID,
'status' => 'approve' //Change this to the type of comments to be displayed
) );
foreach ($comments as $comment) {
$comment_text = get_comment_text($comment->comment_ID);
$comment_text = wpautop( $comment_text );
$sanitizer = new AMPforWP_Content( $comment_text, apply_filters( 'amp_content_embed_handlers', array(
'AMP_Twitter_Embed_Handler' => array(),
'AMP_YouTube_Embed_Handler' => array(),
'AMP_DailyMotion_Embed_Handler' => array(),
'AMP_Vimeo_Embed_Handler' => array(),
'AMP_SoundCloud_Embed_Handler' => array(),
'AMP_Instagram_Embed_Handler' => array(),
'AMP_Vine_Embed_Handler' => array(),
'AMP_Facebook_Embed_Handler' => array(),
'AMP_Pinterest_Embed_Handler' => array(),
'AMP_Gallery_Embed_Handler' => array(),
) ), apply_filters( 'amp_sidebar_sanitizers', array(
'AMP_Style_Sanitizer' => array(),
'AMP_Blacklist_Sanitizer' => array(),
'AMP_Img_Sanitizer' => array(),
'AMP_Video_Sanitizer' => array(),
'AMP_Audio_Sanitizer' => array(),
'AMP_Playbuzz_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
),
) ) );
if ( $sanitizer ) {
$sanitizer_scripts = $sanitizer->get_amp_scripts();
if ( $sanitizer_scripts ){
$comments_scripts = array_merge($comments_scripts, $sanitizer_scripts);
}
}
}
if ( $comments_scripts ) {
$ampforwp_data['comments']['scripts'] = $comments_scripts;
}
}
}
// AMPforWP Global Scripts
add_filter('amp_post_template_data','ampforwp_add_global_scripts');
function ampforwp_add_global_scripts($data){
global $ampforwp_data;
$comments_scripts = array();
// Add Comments Scripts #2827
if ( $comments_scripts ) {
$comments_scripts = $ampforwp_data['comments']['scripts'];
}
if ( !empty($comments_scripts) ) {
foreach ($comments_scripts as $key => $value ) {
if( empty( $data['amp_component_scripts'][$key] ) ){
$data['amp_component_scripts'][$key] = $value;
}
}
}
return $data;
}
if ( ! function_exists('ampforwp_get_weglot_url') ) {
function ampforwp_get_weglot_url(){
$url = weglot_get_full_url_no_language();
$current_lang = weglot_get_current_and_original_language();
$original_lang = $current_lang['original'];
$current_lang = $current_lang['current'];
if($current_lang == $original_lang ){
return $url;
}else{
$url = trailingslashit($url) . $current_lang;
return esc_url(user_trailingslashit($url));
}
}
}
// Rank Math SEO Compatibility #2701
// og tags and Schema
add_action('amp_post_template_head','ampforwp_rank_math');
if ( ! function_exists('ampforwp_rank_math') ) {
function ampforwp_rank_math(){
do_action( 'rank_math/head' );
}
}
#1160 Embedly Sanitizer
add_filter( 'amp_content_sanitizers', 'ampforwp_embedly_sanitizer', 10, 1 );
function ampforwp_embedly_sanitizer( $sanitizer_classes ) {
if ( class_exists('WP_Embedly') ) {
require_once( AMPFORWP_PLUGIN_DIR. 'classes/class-ampforwp-embedly-sanitizer.php' );
$sanitizer_classes[ 'AMPforWP_Embedly_Sanitizer' ] = array();
}
return $sanitizer_classes;
} |
|---|