: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if ( ! defined( 'ABSPATH' ) ) {
function amp_archive_title(){
global $redux_builder_amp;
$author_name = esc_attr(get_query_var('author_name'));
$author = esc_attr(get_query_var('author'));
$curauth = (get_query_var('author_name')) ? get_user_by('slug', $author_name) : get_userdata($author);
//added code for guest author compatibility for plugin coauthors
if(!$curauth && function_exists('get_the_coauthor_meta') )
$thumb_url=ampforwp_get_coauthor_meta('avatar_url');
$display_name=ampforwp_get_coauthor_meta('display_name');
<div class="amp-wp-content author-img">
<amp-img src="<?php echo esc_url($thumb_url); ?>" width="90" height="90" layout="responsive" alt="<?php echo esc_html($display_name); ?>"></amp-img>
if( true == ampforwp_gravatar_checker($curauth->user_email) ){
$curauth_url = get_avatar_url( $curauth->user_email, array('size'=>180) );
<div class="amp-wp-content author-img">
<amp-img src="<?php echo esc_url($curauth_url); ?>" width="90" height="90" layout="responsive" alt="<?php echo esc_html(get_the_author()); ?>"></amp-img>
$description = $sanitizer = $arch_desc = '';
if(ampforwp_default_logo()){
the_archive_title( '<h1 class="amp-archive-title">', '</h1>' );
the_archive_title( '<h2 class="amp-archive-title">', '</h2>' );
if(function_exists('ampforwp_category_image_compatibility')){
ampforwp_category_image_compatibility('echo','amp-archive-image');
$description = get_the_archive_description();
$sanitizer = new AMPFORWP_Content( $description, array(),
apply_filters( 'ampforwp_content_sanitizers',
'AMP_Style_Sanitizer' => array(),
'AMP_Blacklist_Sanitizer' => array(),
'AMP_Img_Sanitizer' => array(),
'AMP_Video_Sanitizer' => array(),
'AMP_Audio_Sanitizer' => array(),
'AMP_Iframe_Sanitizer' => array(
'add_placeholder' => true,
$arch_desc = $sanitizer->get_amp_content();
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var('paged');
} elseif ( get_query_var( 'page' ) ) {
$paged = get_query_var('page');
if($paged <= '1' && ampforwp_get_setting('ampforwp-cat-description')) {?>
<div class="amp-archive-desc">
<?php echo do_shortcode($arch_desc);// amphtml content, no kses ?>
if( is_category() && 1 == $redux_builder_amp['ampforwp-sub-categories-support'] ){
$parent_cat_id = get_queried_object_id();
$cat_childs = get_terms( array(
'taxonomy' => get_queried_object()->taxonomy,
'parent' => $parent_cat_id )
if( !empty( $cat_childs ) ){
echo "<div class='amp-sub-archives'><ul>";
foreach ($cat_childs as $cat_child ) {
$cat_child_url = get_term_link( $cat_child );
if(true == ampforwp_get_setting('convert-internal-nonamplinks-to-amp')){
$cat_child_url = ampforwp_url_controller($cat_child_url);
echo '<li><a href="' . esc_url($cat_child_url) . '">' . esc_attr($cat_child->name) . '</a></li>';
$label = 'You searched for:';
if(function_exists('ampforwp_translation')){
$label = ampforwp_translation( $redux_builder_amp['amp-translator-search-text'], 'You searched for:');
if(ampforwp_default_logo()){
echo '<h1 class="amp-loop-label">'.$label . ' ' . get_search_query().'</h1>';
echo '<h2 class="amp-loop-label">'.$label . ' ' . get_search_query().'</h2>';
function call_loops_standard($data=array()){
$post_type = get_post_type();
if (get_query_var( 'paged' ) ) {
$paged = get_query_var('paged');
} elseif ( get_query_var( 'page' ) ) {
$paged = get_query_var('page');
$qobj_taxonomy = $qobj_term_id = "";
$exclude_ids = ampforwp_exclude_posts();
$qobj = get_queried_object();
'post_type' => $post_type,
'ignore_sticky_posts' => 1,
'paged' => esc_attr($paged),
'post__not_in' => $exclude_ids,
'has_password' => false ,
'post_status'=> 'publish'
if ( is_category() || ( isset($qobj->taxonomy) && taxonomy_exists($qobj->taxonomy)) ) {
$args['tax_query'] = array(
'taxonomy' => $qobj->taxonomy,
'terms' => $qobj->term_id,
$year = get_query_var('year');
$monthnum = get_query_var('monthnum');
$week = get_query_var('week');
$day = get_query_var('day');
array('year' => esc_attr($year))
'paged' => esc_attr($paged),
'post__not_in' => $exclude_ids,
'has_password' => false ,
'post_status' => 'publish',
$args['date_query'][0]['month'] = esc_attr($monthnum);
$args['date_query'][0]['week'] = esc_attr($week);
$args['date_query'][0]['day'] = esc_attr($day);
$exclude_ids = ampforwp_exclude_posts();
'paged' => esc_attr($paged),
'post__not_in' => $exclude_ids,
'has_password' => false ,
'post_status' => 'publish'
$exclude_ids = ampforwp_exclude_posts();
's' => get_search_query() ,
'ignore_sticky_posts' => 1,
'paged' => esc_attr($paged),
'post__not_in' => $exclude_ids,
'has_password' => false ,
'post_status' => 'publish',
$exclude_ids = ampforwp_exclude_posts();
$author_name = esc_attr(get_query_var( 'author_name' ));
'author_name' => $author_name,
'ignore_sticky_posts' => 1,
'paged' => esc_attr($paged),
'post__not_in' => $exclude_ids,
'has_password' => false ,
'post_status' => 'publish',
$exclude_ids = ampforwp_exclude_posts();
$exclude_ids[] = $post->ID;
'post_type' => get_post_type($post),
'ignore_sticky_posts' => 1,
'paged' => esc_attr($paged),
'post__not_in' => $exclude_ids,
'has_password' => false ,
'post_status' => 'publish'
if( isset( $data['post_to_show'] ) && $data['post_to_show']>0 ){
$args['posts_per_page'] = $data['post_to_show'];
if( isset( $data['offset'] ) && $data['offset']>0 ){
$args['offset'] = $data['offset'];
if( isset( $data['posts_per_page'] ) && $data['posts_per_page']>0 ){
$args['posts_per_page'] = $data['posts_per_page'];
$filtered_args = apply_filters('ampforwp_query_args', $args);
$amp_q = new WP_Query( $filtered_args );
// If Relevanssi is available and this is a search, pass the query to Relevanssi
// for improved search results. 2018-07-03 Mikko Saari (mikko@mikkosaari.fi)
if ( is_search() && function_exists( 'relevanssi_do_query' ) ) {
relevanssi_do_query( $amp_q );
//call_loops_standered();
//add_action("init", 'call_loops_standered');
function amp_loop($selection,$data=array()){
if(empty($amp_q) || is_null($amp_q)){
call_loops_standard($data);
echo "<div class='loop-wrapper'>";
if ( false == $amp_q->have_posts() ) {
if ( !isset($ampLoopData['no_data']) ) :
else : // If no posts exist.
function amp_start_loop(){
$post_status = $amp_q->have_posts();
do_action('ampforwp_between_loop',$count);
function amp_reset_loop(){
function amp_pagination($args =array()) {
global $amp_q, $wp_query, $redux_builder_amp;
if (get_query_var( 'paged' ) ) {
$paged = get_query_var('paged');
} elseif ( get_query_var( 'page' ) ) {
$paged = get_query_var('page');
$paged = esc_attr($paged);
if(!isset($args['previous_text']) || $args['previous_text']==''){
$args['previous_text'] = 'Show previous Posts';
if(!isset($args['next_text']) || $args['next_text']==''){
$args['next_text'] = 'Show more Posts';
<div class="loop-pagination"><?php
if (function_exists('wp_pagenavi')) {
if ( get_next_posts_link( $args['next_text'], $amp_q->max_num_pages ) ) {
$next_link = '<div class="right">'. apply_filters('ampforwp_next_posts_link',get_next_posts_link( ampforwp_translation($redux_builder_amp['amp-translator-show-more-posts-text'] , $args['next_text']), $amp_q->max_num_pages ), $paged) .'</div>';
echo $next_link; // escaped above
if ( get_previous_posts_link() ) {
$pre_link = '<div class="left">'.apply_filters('ampforwp_previous_posts_link',get_previous_posts_link( ampforwp_translation($redux_builder_amp['amp-translator-show-previous-posts-text'], $args['previous_text'] ) ), $paged ) .'</div>';
echo $pre_link; // escaped above
<div class="clearfix"></div>
* Arguments: $data = array('class' => 'new-class test-class', 'data-attr-test'=> 'data-val');
* Usage : amp_loop_title($data);
function amp_loop_title($data=array()){
$data = array_filter($data);
if ( is_archive() || is_search() ) {
if(ampforwp_default_logo()){
if(isset($data['tag']) && $data['tag']!=""){
// if $data is in key & value pair
$data_val = $data_attr = $attr_val = '';
foreach ($data as $key => $value) {
if( $key != 'attributes' && $key != 'tag' ){
$value .= ' '.esc_html('loop-title');
$data_val .= "".esc_attr($key)."='".esc_html($value)."' ";
// if $data key is attributes & tag
if(!isset($data['attributes'])){
if( (isset($data_attr) && false !== strpos($data_attr,'attributes')) || empty($data_attr) ){
$attributes = 'class="loop-title"';
if(isset($data['attributes']) && $data['attributes']!=""){
$attributes = $data['attributes'];
$attributes = explode('"', $attributes);
$attributes = str_replace('=','', $attributes);
for($i=0; $i < count($attributes); $i=$i+2) {
if( !empty($attributes[$i]) && !empty($attributes[$i+1]) ){
if( $attributes[$i] == 'class' && $attributes[$i+1] != 'loop-title'){
$attributes[$i+1] .= ' '.esc_html('loop-title');
$attr_val .= "".esc_attr($attributes[$i])."='".esc_html($attributes[$i+1])."'";
echo '<'.esc_attr($tag).' '.$attr_val.' '.$data_val.'>';
if(!isset($data['link']) ){
echo '<a href="'. esc_url(amp_loop_permalink(true)) .'">';
echo the_title('','',false);
if(!isset($data['link']) ){
echo '</'.esc_attr($tag).'>';
function amp_loop_date($args=array()){
global $redux_builder_amp;
if ( 2 == $redux_builder_amp['ampforwp-post-date-format'] ) {
$args['format'] = 'traditional';
if(isset($args['format']) && $args['format']=='traditional'){
$post_date = get_the_date();
$post_date = human_time_diff(
get_the_time('U', get_the_ID() ),
current_time('timestamp') ) .' '. ampforwp_translation( $redux_builder_amp['amp-translator-ago-date-text'],
$post_date = apply_filters('ampforwp_modify_post_date',$post_date);
echo '<div class="loop-date">'.esc_html($post_date).'</div>';
function amp_loop_excerpt($excerpt_length = 15,$tag = 'p', $class = ''){
global $post,$redux_builder_amp;
$excerpt_length = (int) $excerpt_length;
$content = get_the_excerpt();
$content = get_the_content();
$content = strip_shortcodes( $content );
if ( ampforwp_is_home() ){
$content = apply_filters('ampforwp_modify_index_content', $content, $excerpt_length );
$content = apply_filters('ampforwp_modify_archive_content', $content, $excerpt_length );
if( ampforwp_get_setting('ampforwp-homepage-loop-readmore-link') == 1 ) {
echo ('<'.esc_attr($tag).' class="'.esc_attr($class).'">'. wp_trim_words( $content, $excerpt_length ) .' '.'<a href="'. ampforwp_url_controller(get_permalink($post->ID)) . '">'. ampforwp_translation($redux_builder_amp['amp-translator-read-more'],'Read More') . '</a></'.esc_attr($tag).'>');
echo ('<'.esc_attr($tag).' class="'.esc_attr($class).'">'. wp_trim_words( $content, $excerpt_length ) .'</'.esc_attr($tag).'>');
function amp_loop_all_content($tag = 'p'){
$fullContent = strip_shortcodes( get_the_content() );
echo ('<'.$tag.'>'. $fullContent .'</'.$tag.'>');
function amp_loop_permalink($return = ''){
if (is_single() && ampforwp_get_setting('ampforwp-single-related-posts-link')) {
$url = ampforwp_url_controller( get_permalink() ) ;
$url = apply_filters('ampforwp_loop_permalink_update',$url);
if (! function_exists('amp_loop_get_permalink')){
function amp_loop_get_permalink(){
return amp_loop_permalink();
if (! function_exists('amp_loop_the_permalink')){
function amp_loop_the_permalink(){
echo amp_loop_get_permalink();
function amp_loop_image( $data=array() ) {
global $ampLoopData, $counterOffset, $redux_builder_amp;
if (ampforwp_has_post_thumbnail() ) {
$imageSize = 'thumbnail';
if ( isset($data['tag']) && $data['tag'] != "" ) {
if ( isset($data['responsive']) && ( $data['responsive'] == "responsive" || $data['responsive'] == 'true' ) ) {
$layout_responsive = 'layout=responsive';
}elseif (isset($data['responsive']) && $data['responsive'] == "fill" ) {
$layout_responsive = 'layout=fill';
if ( isset($data['tag_class']) && $data['tag_class'] != "" ) {
$tag_class = $data['tag_class'];
if ( isset($data['image_class']) && $data['image_class'] != "" ) {
$imageClass = $data['image_class'];
if ( isset($data['image_size']) && $data['image_size'] != "" ) {
$imageSize = $data['image_size'];
$thumb_url = ampforwp_get_post_thumbnail('url', $imageSize);
$thumb_width = ampforwp_get_post_thumbnail('width', $imageSize);
$thumb_height = ampforwp_get_post_thumbnail('height', $imageSize);
if ( isset($data['image_crop']) && $data['image_crop'] != "" ) {
$width = $data['image_crop_width'];