: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$output .= '<div class="saswp_faq_tiny_content">'.esc_html($value['answer']).'</div>';
add_action('pre_amp_render_post', 'amp_3d_viewer_comp');
function amp_3d_viewer_comp(){
if ( function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
remove_shortcode('3d_viewer', ['Shortcode', 'bp3dviewer_cpt_content_func']);
add_shortcode( '3d_viewer', 'amp_3dviewer_content_func' );
function amp_3dviewer_content_func( $atts ){
extract( shortcode_atts( array(
'auto_rotate' => 'auto-rotate',
'camera_controls' =>'camera-controls',
), $atts ) ); ob_start();
$modeview_3d = get_post_meta( $id, '_bp3dimages_', true );
if( class_exists( 'BP3D' ) && $modeview_3d && is_array($modeview_3d) ) {
//https://playground.amp.dev/static/samples/glTF/DamagedHelmet.glb
$src = BP3D\Helper\Utils::isset2($modeview_3d, 'bp_3d_src', 'url', 'i-do-not-exist.glb');
$src = str_replace('http', 'https', $src);
$width = BP3D\Helper\Utils::isset2($modeview_3d, 'bp_3d_width', 'width', '100').BP3D\Helper\Utils::isset2($modeview_3d, 'bp_3d_width', 'unit', '%');
$height = BP3D\Helper\Utils::isset2($modeview_3d, 'bp_3d_height', 'height', '300').BP3D\Helper\Utils::isset2($modeview_3d, 'bp_3d_height', 'unit', 'px');
$camera_controls = $modeview_3d['bp_camera_control'] == 1 ? 'camera-controls' : '';
$alt = !empty($modeview_3d['bp_3d_src']['url']) ? $modeview_3d['bp_3d_src']['title'] : '';
$auto_rotate = $modeview_3d['bp_3d_rotate'] === '1' ? 'auto-rotate' : '';
$zooming_3d = $modeview_3d['bp_3d_zooming'] === '1' ? '' : 'disable-zoom';
$loading = isset ($modeview_3d['bp_3d_loading']) ? $modeview_3d['bp_3d_loading'] : '';
$attribute = apply_filters('bp3d_model_attribute', [], $id, false);
<div class="bp_grand wrapper_<?php echo esc_attr($id) ?>">
<div class="bp_model_parent">
<amp-3d-gltf class="model" id="bp_model_id_<?php echo esc_attr($id); ?>" src="<?php echo esc_url($src); ?>" alt="<?php echo esc_attr($alt); ?>" layout="fixed" width="320" height="240"></amp-3d-gltf>
$output = ob_get_clean(); return $output;
add_action('wp','ampforwp_jetpack_defer_js_comp');
function ampforwp_jetpack_defer_js_comp(){
if( (function_exists( 'ampforwp_is_amp_endpoint' ) && ampforwp_is_amp_endpoint()) || (function_exists( 'is_amp_endpoint' ) && is_amp_endpoint()) ){
add_filter( 'jetpack_boost_should_defer_js', '__return_false' );
add_filter('the_content','ampforwp_newsp_td_get_css', 12);
function ampforwp_newsp_td_get_css($content){
$the_ID = function_exists('ampforwp_get_the_ID') ? ampforwp_get_the_ID() : get_the_ID();
$tdc_status = get_post_meta( $the_ID, 'tdc_content', true);
global $amp_td_custom_css;
preg_match_all('/<style>(.*?)<\/style>/s', $content, $matches);
foreach ($matches[1] as $key => $value) {
$amp_td_custom_css .= $value;
$content = preg_replace('/data-img-url="(.*?)"/', 'data-img-url="$1" style="background-image:url($1)"', $content);
add_action('amp_post_template_css','ampforwp_newsp_td_render_css');
function ampforwp_newsp_td_render_css(){
$tdc_status = get_post_meta( ampforwp_get_the_ID(), 'tdc_content', true);
global $amp_td_custom_css;
$cssData = $newspaper_css = '';
$newspaper_css_url[] = get_template_directory_uri().'/style.css';
$newspaper_css_url[] = TDC_URL_LEGACY . '/assets/css/td_legacy_main.css';
foreach ($newspaper_css_url as $key => $urlValue) {
$cssData = ampforwp_get_remote_content($urlValue);
$cssData = preg_replace("/\/\*(.*?)\*\//si", "", $cssData);
$newspaper_css = preg_replace_callback('/url[(](.*?)[)]/', function($matches)use($urlValue){
$matches[1] = str_replace(array('"', "'"), array('', ''), $matches[1]);
if(!wp_http_validate_url($matches[1]) && strpos($matches[1],"data:")===false){
$urlExploded = explode("/", $urlValue);
$parentUrl = str_replace(end($urlExploded), "", $urlValue);
return 'url('.$parentUrl.$matches[1].")";
if(method_exists('td_block', 'get_common_css') && method_exists('td_util', 'remove_style_tag')){
echo td_util::remove_style_tag(td_block::get_common_css());
* Ampforwp_compatibility_filter_tags_for_wordproof_plugin function
* @param mixed|string $amp_post_template_data
function ampforwp_compatibility_filter_tags_for_wordproof_plugin( $amp_post_template_data )
if(is_single() && isset($post->ID) && !empty($post->ID)){
$results = $wpdb->get_results(
"SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id = %d AND meta_key LIKE %s",array( $post->ID,'_wordproof_hash_input_%' )),
$schema_data = reset($results);
if(isset($schema_data[0])){
$schema_data = unserialize($schema_data[0]);
if(empty($schema_data)) { return $amp_post_template_data; }
$content = $amp_post_template_data['post_amp_content'];
// for w-certificate-button
if( false !== strpos($content, "<w-certificate-button") ) {
add_action( 'amp_post_template_css', 'amp_wordproof_compatibility_css' );
$findRegExforTag = '~<(w-certificate-button)(.*) text="(.*)"?>(.*)<\/\1>~mi';
$content = preg_replace( $findRegExforTag, "<button on='tap:w-certificate-button'>$3</button>", $content);
$lightbox_content = '<amp-lightbox id="w-certificate-button" layout="nodisplay" scrollable>';
$lightbox_content.='<div class="amp_wordproof_lightbox" role="button" tabindex="0" on="tap:w-certificate-button.close">';
$lightbox_content.='<svg xmlns="http://www.w3.org/2000/svg" class="shield"><use xlink:href="#shield"></use><symbol id="shield" viewBox="0 0 44 58"><path d="M21.799.018c1.463-.176 3.371 1.017 4.736 1.475 4.102 1.375 8.177 2.9 12.235 4.405 1.344.5 4.237.945 4.939 2.296.513.989.191 2.694.191 3.783v8.875c0 8.06.633 16.427-3.742 23.623-1.15 1.889-2.563 3.55-4.151 5.088-1.867 1.807-4.078 3.306-6.315 4.621a81.965 81.965 0 01-5.13 2.788c-.766.38-1.626.968-2.5 1.025-.857.055-1.763-.595-2.5-.96-2.019-1.002-4.003-2.057-5.92-3.24-2.533-1.565-4.924-3.364-6.961-5.537C-.563 40.532.091 30.113.091 20.33v-8.353c0-1.066-.301-2.682.192-3.654.77-1.517 3.831-2.007 5.334-2.525 3.657-1.26 7.287-2.627 10.92-3.96 1.643-.602 3.516-1.61 5.262-1.82m0 3.817c-1.708.222-3.526 1.221-5.131 1.822-2.834 1.06-5.737 1.947-8.552 3.057-.936.37-3.805.823-4.262 1.752-.37.754-.08 2.244-.08 3.077v7.309c0 8.573-.77 17.4 5.19 24.406 1.563 1.837 3.498 3.303 5.467 4.68 1.675 1.17 3.484 2.1 5.263 3.095.63.352 1.62 1.068 2.368 1.021.745-.047 1.602-.686 2.236-1.04 1.46-.817 2.917-1.598 4.342-2.48a30.632 30.632 0 005.915-4.754c6.455-6.7 5.662-15.868 5.662-24.406v-7.7c0-.864.306-2.428-.08-3.208-.424-.86-3.243-1.385-4.13-1.71-3.282-1.204-6.588-2.346-9.867-3.559-1.192-.441-3.056-1.53-4.341-1.362m-1.053 32.417h-.132l-6.183-6.134c-.48-.476-2.081-1.63-2.078-2.35.004-.827 1.785-2.058 2.341-2.61 1.521 1.098 2.898 2.683 4.188 4.042.408.43 1.209 1.572 1.864 1.564.814-.01 2.082-1.798 2.631-2.342l6.447-6.395c.518-.515 1.588-2.044 2.368-2.064.793-.02 2.65 2.02 2.187 2.716-1.094 1.638-3.023 3.048-4.424 4.438z" fill="currentColor"></path></symbol></svg>';
if(isset($schema_data->dateCreated)){
$datetime = new DateTime($schema_data->dateCreated);
$lightbox_content.= '<h5>Last edited '.esc_attr($datetime->format('F j, Y at h:i A')) .' </h5>';
$lightbox_content.= '<h4>This information did not change since the last timestamp</h4><p>This is important, because it proves that the content has not been tampered with and it can be trusted.<p>';
$lightbox_content.= '</div></amp-lightbox>';
if( false !== strpos($content, "<w-certificate") ) {
$findRegExforTag = '~<(w-certificate)(.*)?>(.*)<\/\1>~mi';
$content = preg_replace( $findRegExforTag, $lightbox_content, $content);
$amp_post_template_data['post_amp_content'] = $content;
return $amp_post_template_data;
function amp_wordproof_compatibility_css(){
echo '.amp_wordproof_lightbox{background:rgba(0,0,0,.8);width:100%;height:100%;position:absolute;display:flex;flex-wrap:wrap;color:#fff;justify-content:center;align-content:center;align-items:center}.amp_wordproof_lightbox h4,.amp_wordproof_lightbox h5,.amp_wordproof_lightbox p{padding:0 10px}';
* ampforwp_compatibility_for_opensea_plugin function
* @param mixed|string $amp_post_template_data
function ampforwp_compatibility_for_opensea_plugin( $amp_post_template_data )
$content = $amp_post_template_data['post_amp_content'];
if( false !== strpos($content, "<nft-card") ) {
add_action( 'amp_post_template_css', 'ampforwp_opensea_compatibility_css' );
$findRegExforTag = '~<(nft-card) tokenaddress="(.*)" tokenid="(.*)">?>(.*)<\/\1>~mi';
$content = preg_replace_callback($findRegExforTag, 'ampforwp_compatibility_for_opensea_callback', $content);
$amp_post_template_data['post_amp_content'] = $content;
return $amp_post_template_data;
function ampforwp_opensea_compatibility_css(){
echo '.ampforwp_opensea_card .asset-detail-type a {border: 1px solid;border-radius: 20px;display: flex;flex-direction: row;align-items: center;}.ampforwp_opensea_card .asset-detail-type img {width:25px;border-radius:50%;padding:5px;}.ampforwp_opensea_card{background-color:#fff;font-family:Roboto,sans-serif;-webkit-font-smoothing:antialiased;font-style:normal;font-weight:400;line-height:normal;border-radius:5px;perspective:1000px;margin:auto;width:80vw;height:210px;min-height:200px;max-width:670px}.ampforwp_opensea_card .card-inner{position:relative;width:100%;height:100%;text-align:center;transition:transform .6s;transform-style:preserve-3d;box-shadow:0 1px 6px rgba(0,0,0,.25);border-radius:5px}.ampforwp_opensea_card a{text-decoration:none;color:inherit}.ampforwp_opensea_card .card-front{backface-visibility:hidden;background:#fff;border-radius:5px;display:grid;grid-template-columns:1fr 2fr;position:relative;width:100%;height:100%;transform:translateY(0);overflow:hidden}.ampforwp_opensea_card .card-front p{margin:0;padding:0 10px;}.ampforwp_opensea_card .asset-image-container{border-right:1px solid #e2e6ef;background-size:cover;box-sizing:border-box}.ampforwp_opensea_card .asset-image{background-size:contain;background-position:50%;background-repeat:no-repeat;height:100%;box-sizing:border-box}.ampforwp_opensea_card .asset-details-container{display:grid;grid-template-rows:auto;grid-template-columns:1fr 1fr;padding:20px;align-items:center}.ampforwp_opensea_card .asset-detail{display:flex}.ampforwp_opensea_card .asset-detail .asset-detail-type{height:35px;font-size:12px;margin-right:10px}.ampforwp_opensea_card .asset-detail .asset-detail-badge{width:54px;height:30px;font-size:12px}.ampforwp_opensea_card .asset-detail-name{font-weight:400;text-align:left}.ampforwp_opensea_card .asset-detail-price{align-items:flex-end;font-size:18px;font-weight:400;display:flex;flex-flow:row;justify-content:flex-end;line-height:15px;text-align:right;padding:6px 0}.ampforwp_opensea_card .asset-detail-price img{margin:0 4px}.ampforwp_opensea_card .asset-detail-price-current img{width:15px}.ampforwp_opensea_card .asset-detail-price-previous{font-size:14px;color:#828282;line-height:10px}.ampforwp_opensea_card .asset-detail-price-previous img{width:1ex}.ampforwp_opensea_card .asset-detail-price .value{margin-left:5px}.ampforwp_opensea_card .asset-detail-price .previous-value{font-size:14px;color:#828282}.ampforwp_opensea_card .asset-action-buy{grid-column-start:1;grid-column-end:3}.ampforwp_opensea_card .asset-action-buy button{width:100%;background:#3291e9;border-radius:5px;height:35px;color:#fff;font-weight:700;letter-spacing:.5px;cursor:pointer;transition:.2s;outline:0;border-style:none;text-transform:uppercase}.ampforwp_opensea_card .asset-action-buy button:hover{background:#153d62}.ampforwp_opensea_card .asset-link{text-decoration:none;}';
function ampforwp_compatibility_for_opensea_callback($matches){
if(isset($matches[2]) && !empty($matches[2]) && isset($matches[3]) && !empty($matches[3])){
$response = wp_remote_get( 'https://api.opensea.io/api/v1/asset/'.$matches[2].'/'.$matches[3].'/?',
array('headers'=>array('X-API-KEY'=>'e4e7b08f1807492e91301de85728ce2e',
'accept' => 'application/json'
if ( is_array( $response ) && ! is_wp_error( $response ) ) {
$body = $response['body']; // use the content
$nft_data = json_decode($body,true);
if(isset($nft_data['token_id']) && isset($nft_data['image_url']) && isset($nft_data['name']) && isset($nft_data['permalink']) && isset($nft_data['asset_contract']['name']) && isset($nft_data['asset_contract']['image_url']) && isset($nft_data['collection']['slug'])){
<div class='ampforwp_opensea_card'>
<div class='asset-image-container'>
<a target='_blank' href='".esc_url($nft_data['permalink'])."'>
<div class='asset-image' style='background-image: url("".esc_url($nft_data['image_url']).""); background-size: contain;'></div>
<div class='asset-details-container'>
<div class='asset-detail'>
<div class='asset-detail-type'>
<a class='asset-link' target='_blank' href='https://opensea.io/assets/".esc_url($nft_data['collection']['slug'])."'>
<img alt='' src='".esc_url($nft_data['asset_contract']['image_url'])."'>
<p>".esc_attr($nft_data['asset_contract']['name'])."</p>
<div class='spacer'></div>
<div class='asset-detail-name'>
<a class='asset-link' target='_blank' href='".esc_url($nft_data['permalink'])."'>".esc_attr($nft_data['name'])."</a>
<a class='asset-link' target='_blank' href='".esc_url($nft_data['permalink'])."'>
<div class='asset-detail-price asset-detail-price-previous'>
<div class='previous-value'>Prev. </div>
<img alt='' src='https://openseauserdata.com/files/6f8e2979d428180222796ff4a33ab929.svg'>
<div class='asset-detail-price-value'>
if(isset($nft_data['last_sale']['total_price'])){
$price_to_show=round($nft_data['last_sale']['total_price']/1000000000000000000,3);
$nft_card_html.= esc_attr($price_to_show);
<div class='asset-action-buy'>
<a class='asset-link' target='_blank' href='".esc_url($nft_data['permalink'])."'> buy this item > </a>
if(isset($response['response']['code']) && $response['response']['message'] ){
$default_return = '<center><small> Opensea Error - '.esc_attr($response['response']['code']).' : '.esc_attr($response['response']['message']).'</small></center>' ;
* ampforwp_add_target_attribute_in_form_tags function
* @param mixed|string $amp_post_template_data
function ampforwp_add_target_attribute_in_form_tags( $amp_post_template_data )
$content = $amp_post_template_data['post_amp_content'];
$pattern = '~<form(?![^>]*\btarget=)[^<]*>~im';
if( preg_match_all( $pattern, $content, $matches ) )
if( 0 < count( $matches[0] ) )
$matchesUnique = array_unique( $matches[0] );
foreach( $matchesUnique as $match )
$matchStr = trim( str_replace( '>', '', $match ) );
$content = str_replace( $matchStr, $matchStr . ' target="_top"', $content );
$amp_post_template_data['post_amp_content'] = $content;
return $amp_post_template_data;
add_filter('the_content','ampforwp_heista_pro_frontpage_section');
function ampforwp_heista_pro_frontpage_section($content){
global $redux_builder_amp;
$ampforwp_frontpage = $redux_builder_amp['amp-frontpage-select-option-pages']?intval($redux_builder_amp['amp-frontpage-select-option-pages']):0;
if ( (is_home() || is_page($ampforwp_frontpage)) && function_exists('hestia_run')) {
if ( $redux_builder_amp['amp-frontpage-select-option'] == 1 && class_exists('Hestia_Defaults_Models')) {
$slider_default = Hestia_Defaults_Models::instance()->get_slider_default();
$slider_content = get_theme_mod( 'hestia_slider_content',wp_json_encode($slider_default));
$slider_content = json_decode( $slider_content );
if ( !empty( $slider_content ) ) {
$amp_html='<div class="ampforwp-carousel-cont" >
<amp-carousel width="500" height="300" layout="responsive" type="slides" aria-label="Hestia Header carousel">';
foreach ( $slider_content as $slider_item ) {
$title = ! empty( $slider_item->title ) ? apply_filters( 'hestia_translate_single_string', $slider_item->title, 'Slider section' ) : '';
$subtitle = ! empty( $slider_item->subtitle ) ? apply_filters( 'hestia_translate_single_string', $slider_item->subtitle, 'Slider section' ) : '';
$button = ! empty( $slider_item->text ) ? apply_filters( 'hestia_translate_single_string', $slider_item->text, 'Slider section' ) : '';
$link = ! empty( $slider_item->link ) ? apply_filters( 'hestia_translate_single_string', $slider_item->link, 'Slider section' ) : '';
$button2 = ! empty( $slider_item->text2 ) ? apply_filters( 'hestia_translate_single_string', $slider_item->text2, 'Slider section' ) : '';
$link2 = ! empty( $slider_item->link2 ) ? apply_filters( 'hestia_translate_single_string', $slider_item->link2, 'Slider section' ) : '';
$slider_type = get_theme_mod( 'hestia_slider_type', apply_filters( 'hestia_slider_type_default', 'image' ) );
$image_url_bg = ! empty( $slider_item->image_url ) && $slider_type=='image' ? apply_filters( 'hestia_translate_single_string', $slider_item->image_url, 'Slider section' ) : '';
$amp_html.='<div class="ampforwp-carousel-wrapper">';
$amp_html.='<div class="ampforwp-carousel-img-wrapper" ><amp-img src="'.esc_url($image_url_bg).'" width="1200" height="800" layout="fill"></amp-img></div>';
$amp_html.='<div class="ampforwp-carousel-content">';
$amp_html.= '<h1>'.esc_attr( $title ).'</h1>';
$amp_html.= '<p>'.esc_attr( $subtitle ).'</p>';
$amp_html.= '<a href="'.esc_url($link).'" title="'.esc_attr( $button ).'"><button>'.esc_attr( $button ).'</button></a>';
$amp_html.= '<a href="'.esc_url($link2).'" title="'.esc_attr( $button2 ).'"><button>'.esc_attr( $button2 ).'</button></a>';
$amp_html.='</amp-carousel></div>';
$content = $amp_html.$content;
add_action('amp_post_template_css','ampforwp_heista_pro_frontpage_section_css');
function ampforwp_heista_pro_frontpage_section_css(){
global $redux_builder_amp;
$ampforwp_frontpage = $redux_builder_amp['amp-frontpage-select-option-pages']?intval($redux_builder_amp['amp-frontpage-select-option-pages']):0;
if ( (is_home() || is_page($ampforwp_frontpage)) && function_exists('hestia_run')) {
echo '.ampforwp-carousel-cont amp-carousel{height:400px} .ampforwp-carousel-wrapper{position:relative;width:100%;} .ampforwp-carousel-img-wrapper img{filter: brightness(50%);} .ampforwp-carousel-content h1 , .ampforwp-carousel-content p{width:90%;padding: 0px 10px;border-radius:8px} .ampforwp-carousel-content{position:absolute;top:0;bottom:0;right:0;left:0;text-align:center;display: flex;flex-direction: column;align-items: center;justify-content: center;color:#fff;}';
* To fix validation error attribute a may not appear in a tag
* Issue is due to WPBakery Page Builder plugin which is adding a attribute in anchor tag
add_filter( 'vc_gitem_post_data_get_link_real_link','ampforwp_fix_a_attr_in_anchor_tag',99,1);
function ampforwp_fix_a_attr_in_anchor_tag($target_link){
if ( function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint() ) {
if(preg_match('/a (.*?)/', $target_link)){
$target_link = preg_replace('/a (.*?)/', '$1', $target_link);
//ftc theme compatibility
add_action( 'admin_init', 'ampforwp_fTC_theme_remove_scripts');
function ampforwp_fTC_theme_remove_scripts() {
if ( isset ( $_GET['page'] ) && $_GET['page'] == 'amp_options' ) {
remove_action('admin_enqueue_scripts', 'ftc_register_admin_scripts');
//Remove Poll maker to solve validation error
add_action('wp','ampforwp_poll_maker_remove_html');
function ampforwp_poll_maker_remove_html(){
if((function_exists('ampforwp_is_amp_endpoint') && ampforwp_is_amp_endpoint()) || (function_exists('is_amp_endpoint') && is_amp_endpoint())){
$plugin_name = 'poll-maker-ays';
if (defined('POLL_MAKER_AYS_VERSION')) {
$version = POLL_MAKER_AYS_VERSION;
if(class_exists('Poll_Maker_Ays_Public')){
$new = new Poll_Maker_Ays_Public($plugin_name, $version);
remove_shortcode('ays_poll', array($new, 'ays_poll_generate_shortcode'));
add_shortcode('ays_poll', 'ampforwp_ays_poll_remove_shortcode');
function ampforwp_ays_poll_remove_shortcode($atts){
* Adding compatiblity for Amazon Auto Links Plugin
add_filter('the_content','ampforwp_aal_content_fix', 9);
function ampforwp_aal_content_fix($content){
if(is_amp_endpoint() && class_exists('AmazonAutoLinks_Registry_Base')){
// get all post ids with post_type aal_auto_insert and are published. Only need to fetch ids not the whole post
$posts = get_posts(array(
'post_type' => 'aal_auto_insert',
'post_status' => 'publish',
// if there are no posts then return the content as it is
foreach($posts as $post){
$unit_ids = get_post_meta( $post, 'unit_ids', true );
$status = get_post_meta( $post, 'status', true );
$position = get_post_meta( $post, 'position', true );
$enable_post_ids = get_post_meta( $post, 'enable_post_ids', true );
$enable_page_types = get_post_meta( $post, 'enable_page_types', true );
$enable_post_types = get_post_meta( $post, 'enable_post_types', true );
$diable_post_ids = get_post_meta( $post, 'diable_post_ids', true );
$disable_page_types = get_post_meta( $post, 'disable_page_types', true );
$disable_post_types = get_post_meta( $post, 'disable_post_types', true );
$pages_types = ['is_singular'=>is_singular(),'is_home'=>is_home(),'is_archive'=>is_archive(),'is_404'=>is_404(),'is_search'=>is_search()];
$get_current_post_type = get_post_type();
$get_current_post_id = get_the_ID();
$enable_post_types_values = array_filter(array_unique(array_values($enable_post_types)));
$disable_post_types_values = array_filter(array_unique(array_values($disable_post_types)));
$enable_pages_types_values = array_filter(array_unique(array_values($enable_page_types)));
$disable_pages_types_values = array_filter(array_unique(array_values($disable_page_types)));
$diable_post_ids = array_filter(explode(',',$diable_post_ids));
$enable_post_ids = array_filter(explode(',',$enable_post_ids));
if($status == '1' && (empty($enable_post_ids) || (!empty($enable_post_ids) &&in_array($get_current_post_id, $enable_post_ids))) && (!in_array('1', $enable_post_types_values) || (in_array('1', $enable_post_types_values) && isset($enable_post_types[$get_current_post_type]) && $enable_post_types[$get_current_post_type] == 1)) && !in_array($get_current_post_id, $diable_post_ids) && (!in_array('1', $disable_post_types) ||( in_array('1', $disable_post_types_values) && isset($disable_post_types[$get_current_post_type]) && $disable_post_types[$get_current_post_type] == 0)) && ((!in_array('1', $enable_pages_types_values) || (in_array('1', $enable_pages_types_values) && ampforwp_aal_check_pages_types($pages_types,$enable_page_types)) ))&& ((!in_array('1', $disable_pages_types_values) || (in_array('1', $disable_pages_types_values) && ampforwp_aal_check_pages_types($pages_types,$disable_page_types)) )))
$auto_insert .= apply_filters( 'aal_filter_output', '', array('id'=>implode(',',$unit_ids)));
if($position == 'above'){
$content = $auto_insert.$content;
}else if($position == 'both'){
$content = $auto_insert.$content.$auto_insert;
$content = $content.$auto_insert;
function ampforwp_aal_check_pages_types($pages_types, $enabled_or_not) {
foreach ($pages_types as $key => $value) {
if ($value && $enabled_or_not[$key] == '1') {
add_action('amp_post_template_css','ampforwp_aal_css');
function ampforwp_aal_css(){
if (is_amp_endpoint() && class_exists('AmazonAutoLinks_Registry_Base')) {
echo '.amazon-products-container-list{overflow-y:auto;overflow-x:hidden;width:100%}.amazon-products-container-list *{-webkit-box-sizing:border-box;box-sizing:border-box}.amazon-products-container-list a{color:inherit;text-decoration:none}.amazon-products-container-list .amazon-product-container{width:100%;display:block;clear:both;margin-bottom:1.4em}.amazon-products-container-list .amazon-product-title{margin:.1em 0 1em}.amazon-products-container-list .amazon-product-thumbnail-container{width:100%}.amazon-products-container-list .amazon-product-thumbnail{display:table;margin:auto;text-align:center;padding:1em}.amazon-products-container-list .amazon-product-thumbnail a{display:inline-block;background-color:#fff;padding:.8em;border:none;border-radius:4%;-webkit-box-shadow:none;box-shadow:none}.amazon-products-container-list .amazon-product-thumbnail a:focus,.amazon-products-container-list .amazon-product-thumbnail a:hover{-webkit-box-shadow:none;box-shadow:none}.amazon-products-container-list .amazon-product-thumbnail img{max-width:100%;margin-left:auto;margin-right:auto}.amazon-products-container-list .amazon-auto-links-product-body{display:inline-block;width:65.8%}.amazon-products-container-list .crIFrameNumCustReviews{display:inline-block;vertical-align:top;height:auto}.amazon-products-container-list .crAvgStars{white-space:nowrap}.amazon-products-container-list span.crAvgStars a{font-size:inherit}.amazon-products-container-list .amazon-customer-rating-stars{display:inline-block;margin:0 .2em 0 0;vertical-align:middle;line-height:1.6;font-size:88%}.amazon-products-container-list .amazon-customer-rating-stars .review-stars{display:inline;vertical-align:text-bottom;margin-right:.44em;line-height:1}.amazon-products-container-list .amazon-customer-rating-stars .review-stars svg{top:-2px}.amazon-products-container-list .amazon-customer-rating-stars .review-count{margin-top:2px;margin-left:-2px;display:inline}.amazon-products-container-list .pricing-disclaimer a.amazon-disclaimer-tooltip{outline:0}.amazon-products-container-list .pricing-disclaimer a.amazon-disclaimer-tooltip>span.amazon-disclaimer-tooltip-content>.amazon-disclaimer-tooltip-content-text{z-index:999;display:none;padding:14px 20px;margin-top:-30px;margin-left:28px;width:300px;line-height:16px;border-radius:4px;-webkit-box-shadow:5px 5px 8px #ccc;box-shadow:5px 5px 8px #ccc}.amazon-products-container-list .pricing-disclaimer a.amazon-disclaimer-tooltip:hover{text-decoration:none}.amazon-products-container-list .pricing-disclaimer a.amazon-disclaimer-tooltip:hover>span.amazon-disclaimer-tooltip-content{display:inline;position:relative}.amazon-products-container-list .pricing-disclaimer a.amazon-disclaimer-tooltip:hover>span.amazon-disclaimer-tooltip-content>.amazon-disclaimer-tooltip-content-text{display:inline;float:right;position:absolute;color:#111;border:1px solid #dca;background:#fffaf0;margin-left:-100px;margin-top:-140px}.amazon-products-container-list .amazon-auto-links-product-image{vertical-align:top;display:inline-block;width:32%;margin-right:1%;font-size:80%}.amazon-products-container-list .amazon-prices{margin-right:.2em;line-height:1.6;font-size:88%;display:inline-block;vertical-align:middle}.amazon-products-container-list .amazon-prices .offered-price{display:inline}.amazon-products-container-list span.offered-price{color:#b12704;font-weight:700}@media only screen and (max-width:520px){.amazon-products-container-list .amazon-auto-links-product-image{width:100%;margin-bottom:1em}.amazon-products-container-list .amazon-auto-links-product-body{font-size:88%;width:100%}}.amazon-product-thumbnail .amp-wp-enforced-sizes {width:100px;height:100px;}';
add_filter('amp_post_template_data','ampforwp_aal_compatibility');
function ampforwp_aal_compatibility( $amp_post_template_data )
if (is_amp_endpoint() && class_exists('AmazonAutoLinks_Registry_Base')) {
$content = $amp_post_template_data['post_amp_content'];
if (strpos($content, '<div class="amazon-customer-rating-stars">') !== false) {
// Perform the replacement within <span class="review-stars">
$content = preg_replace('/(<span class="review-stars">.*?<a [^>]*>).*?<svg[^>]*><title>([^<]*)<\/title>.*?<\/svg>(.*?<\/a>.*?<\/span>)/s', '$1$2$3', $content);
$amp_post_template_data['post_amp_content'] = $content;