: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
require_once ABSPATH . WPINC . '/category.php';
add_filter('ampforwp_content_module_args','ampforwp_content_module_pagination',10,2);
function ampforwp_content_module_pagination($args, $fieldValues){
if(isset($fieldValues['pagination']) && $fieldValues['pagination'] == 1 ){
if( isset($_GET['pageno']) && $_GET['pageno']!=''){
$paged = intval($_GET['pageno']);
$offset = ( $paged - 1 ) * $args['posts_per_page'] + $args['offset'];
$args['offset'] = $offset;
$output = '{{if_condition_content_layout_type==1}}
<div {{if_id}}id="{{id}}"{{ifend_id}} class="pb_mod cm {{user_class}}">
{{if_content_title}}<h4>{{content_title}}</h4> {{ifend_content_title}}
<div id="cat-jump{{id}}" class="wrap"><ul>{{category_selection}}</ul></div>
{{ifend_condition_content_layout_type_1}}
{{if_condition_content_layout_type==1}}
.wrap{width:100%;display:inline-block;margin-top:10px;}
grid-template-columns:1fr 1fr 1fr;
{{module-class}} .cm ul li {
{{module-class}} .cm .cml{
{{module-class}} .cm {margin:{{margin_css}};padding:{{padding_css}};}
{{module-class}} .cm h4{border-bottom: 2px solid #eee;padding-bottom: 8px;margin-bottom: 5px;font-size:18px;color: #191919;font-weight: 600;}
{{module-class}} .cm .cmr{display:flex;flex-direction: column;margin-top: 6px;}
{{module-class}} .cm .cmr a{font-size: 16px;line-height: 1.3;font-weight: 500;color: #000;margin: 0px 0px 5px 0px;}
{{module-class}} .cm .cmr p{color: #555;font-size: 13px;line-height: 20px;letter-spacing: 0.10px;margin-bottom:0;}
{{module-class}} .cm .cml{width:100%;}
{{module-class}} .cmp a {
transition: background-color .3s;
{{module-class}} .cmp a.active {
background-color: dodgerblue;
{{module-class}} .cmp a:hover:not(.active) {background-color: #ddd;}
margin: 30px 0px 0px 0px;
{{module-class}} .cm .cmr p a{
grid-template-columns:1fr;
{{module-class}} .cm ul li{
{{module-class}} .cml amp-img{width:100%;}
{{module-class}} .cm .cml{
{{module-class}} .cm .cmr{
@media (max-width: 480px){
{{module-class}} .cm ul li{
{{module-class}} .cm .cml{
{{module-class}} .cm .cmr{
{{ifend_condition_content_layout_type_1}}
if(ampforwp_get_setting('amp-design-selector') == 3 || ampforwp_get_setting('amp-design-selector') == 2){
$frontCss .= '@media (max-width: 480px){
$options = '<option value="recent_option">Recent Posts</option>';
$categoriesArray = array();
$post_types = get_post_types(array('public'=>true));
$post_types = get_option('ampforwp_cpt_generated_post_types');
$post_types['post'] = 'Post';
$categories = get_categories( array(
$categoriesArray = array('recent_option'=>'Recent Posts');
foreach($categories as $category){
$categoryName = htmlspecialchars(esc_html($category->name), ENT_QUOTES);
$categoriesArray[$category->term_id] = $categoryName;
$options.= '<option value="'.esc_attr($category->term_id).'">'.esc_html($categoryName).'</option>';
'default_tab'=> 'customizer',
'container_css'=>'Design',
'type' =>'layout-image-picker',
'name' =>"content_layout_type",
'label' =>"Select Layout",
'options_details'=>array(
'demo_image'=> AMPFORWP_PLUGIN_DIR_URI.'/images/cat-dg-1.png'
'name' =>"content_title",
'label' =>'Category Block',
'name' =>"ampforwp_pb_cat_pagination_next",
'label' =>'Pagination For Next Label',
'required' => array('pagination'=>'1'),
'name' =>"ampforwp_pb_cat_pagination_last",
'label' =>'Pagination For Last Label',
'required' => array('pagination'=>'1'),
'name' =>"post_type_selection",
'label' =>"Select Post Type",
'options' => $post_types,
'options_details'=>$post_types ,
'ajax_dep' => 'taxonomy_selection',
'ajax_action' => 'ampforwp_pb_taxonomy'
'name' =>"taxonomy_selection",
'label' => esc_html__("Select Taxonomy","accelerated-mobile-pages"),
'options_details'=>$categoriesArray ,
'ajax_dep' => 'category_selection',
'ajax_action' => 'ampforwp_pb_cats'
'name' =>"category_selection",
'label' =>"Select Category",
'default' =>'recent_option',
'options_details'=>$categoriesArray ,
'name' =>"show_total_posts",
'label' =>'No. of Posts per Page',
'label' => esc_html__('Offset','accelerated-mobile-pages'),
'name' =>"ampforwp_show_excerpt",
'options' => '<option value="yes">Yes</option><option value="no">No</option>',
'options_details'=>array('yes'=>'Yes', 'no'=>'No'),
'name' =>"ampforwp_excerpt_length",
'label' =>"Excerpt Length",
'required' => array('ampforwp_show_excerpt' => 'yes'),
'name' =>"ampforwp_read_more",
'label' =>esc_html__("Read More Text","accelerated-mobile-pages"),
'required' => array('ampforwp_show_excerpt' => 'yes'),
'required' => array('content_layout_type' => 1),
'label' =>'Image Height',
'required' => array('content_layout_type' => 1),
'type' =>'checkbox_bool',
'name' =>"show_no_page_links",
'label' =>'No. of PageLinks to Show',
'required' => array('pagination' => 1),
'front_template'=> $output,
'front_loop_content'=>' {{if_condition_content_layout_type==1}}
<a href="{{ampforwp_post_url}}">
{{if_image}}<amp-img class="ampforwp_wc_shortcode_img" src="{{image}}" width="{{width}}" height="{{height}}" srcset="{{image_srcset}}" layout="responsive" alt="{{image_alt}}"> </amp-img>{{ifend_image}}</a>
<a href="{{ampforwp_post_url}}">{{title}}</a>
{{ifend_condition_content_layout_type_1}}
function ampforwp_contentHtml($the_query,$fieldValues,$loopHtml){
$ampforwp_show_excerpt = (isset($fieldValues['ampforwp_show_excerpt'])? $fieldValues['ampforwp_show_excerpt']: 'yes');
$ampforwp_excerpt_length = (isset($fieldValues['ampforwp_excerpt_length'])? $fieldValues['ampforwp_excerpt_length']: 15);
$ampforwp_excerpt_length = (int) $ampforwp_excerpt_length;
if(function_exists('ampforwp_mobile_redirect_preseve_link')){
$mob_pres_link = ampforwp_mobile_redirect_preseve_link();
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$ampforwp_post_url = get_permalink();
if(ampforwp_get_setting('ampforwp-amp-takeover') == true || $mob_pres_link == true){
$ampforwp_post_url = user_trailingslashit($ampforwp_post_url);
}else if(true == ampforwp_get_setting('amp-core-end-point')){
$ampforwp_post_url = user_trailingslashit($ampforwp_post_url);
$ampforwp_post_url = add_query_arg( 'amp', '', $ampforwp_post_url);
$ampforwp_post_url = user_trailingslashit($ampforwp_post_url) . AMPFORWP_AMP_QUERY_VAR;
$ampforwp_post_url = user_trailingslashit($ampforwp_post_url);
$image = $height = $width = $image_alt = $image_srcset = "";
if ( has_post_thumbnail() ) {
$thumb_id = get_post_thumbnail_id();
$image_alt = get_post_meta( $thumb_id, '_wp_attachment_image_alt', true);
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
$image_srcset = wp_get_attachment_image_srcset( $thumb_id, 'full');
$image = $thumb_url_array[0];
$width = $thumb_url_array[1];
$height = $thumb_url_array[2];
if(ampforwp_is_custom_field_featured_image() && ampforwp_cf_featured_image_src()){
$image = ampforwp_cf_featured_image_src();
$width = ampforwp_cf_featured_image_src('width');
$height = ampforwp_cf_featured_image_src('height');
if(!empty($image) && !empty($width) && !empty($height)){
switch($fieldValues['content_layout_type']){
$width = $fieldValues['img-width-1'];
$height = $fieldValues['img-height-1'];
$width = $fieldValues['img-width-2'];
$height = $fieldValues['img-height-2'];
$width = $fieldValues['img-width-3'];
$height = $fieldValues['img-height-3'];
$width = $fieldValues['img-width-4'];
$height = $fieldValues['img-height-4'];
$width = $fieldValues['img-width-5'];
$height = $fieldValues['img-height-5'];
$pb_content_width_height = apply_filters("ampforwp_pb_content_mod_set_height_width", $width, $height, $fieldValues);
if(is_array($pb_content_width_height)){
list($new_width, $new_height) = $pb_content_width_height;
if ( !empty($new_width) && !empty($new_height) ) {
if ( ampforwp_get_setting('ampforwp-retina-images') ) {
if(ampforwp_get_setting('ampforwp-retina-images-res')){
$resolution = ampforwp_get_setting('ampforwp-retina-images-res');
$width = $width * $resolution;
$height = $height * $resolution;
if(!is_numeric($width) && !is_numeric($height)){
if( $ampforwp_show_excerpt == 'yes' ) {
$content = get_the_excerpt();
$content = get_the_content();
if(isset($fieldValues['ampforwp_read_more']) && !empty($fieldValues['ampforwp_read_more']) ){
$readMore = $fieldValues['ampforwp_read_more'];
$read_more_link = '<a href="'.esc_url($ampforwp_post_url).'" > '.esc_html($readMore).'</a>';
$excerptContent = '<p>'.wp_trim_words( strip_tags( strip_shortcodes( $content ) ) , (int) $ampforwp_excerpt_length ).$read_more_link.'</p>';
$loopdate = human_time_diff(
get_the_time('U', get_the_ID() ),
current_time('timestamp') ) .' '. ampforwp_translation( ampforwp_get_setting('amp-translator-ago-date-text'),
$loopdate = apply_filters('ampforwp_modify_post_date',$loopdate);
$loopdate = '<p>'.esc_html($loopdate).'</p>';
$title = get_the_title();
$author = get_the_author();
if(is_array($tags) && count($tags) > 0){
// get_the_author_meta( string $field = '', int $user_id = false );
$postdate = get_the_date( ' F j, Y', $postid );