: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
array($imageWidth,$imageWidth),
$moduleFrontHtml = ampforwp_replaceIfContentConditional('image_width', $imageWidth, $moduleFrontHtml);
$moduleFrontHtml = str_replace(
array('{{image_height}}','{{image_height_'.$field['name'].'}}'),
array($imageHeight,$imageHeight),
$moduleFrontHtml = ampforwp_replaceIfContentConditional('image_height', $imageHeight, $moduleFrontHtml);
$moduleFrontHtml = str_replace(
'{{image_alt_'.$field['name'].'}}'
$moduleFrontHtml = str_replace(
array('{{image_srcset}}',
'{{image_srcset_'.$field['name'].'}}'
$moduleFrontHtml = ampforwp_replaceIfContentConditional('image_srcset', $image_srcset, $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional('image_alt', $image_alt, $moduleFrontHtml);
$moduleFrontHtml = str_replace(
array('{{image_caption}}',
'{{image_caption_'.$field['name'].'}}'
$moduleFrontHtml = ampforwp_replaceIfContentConditional('image_caption', $image_caption, $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional($field['name'], $imageUrl, $moduleFrontHtml);
$moduleFrontHtml = str_replace('{{'.$field['name'].'}}', esc_html( $replace), $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional($field['name'], esc_html( $replace), $moduleFrontHtml);
/*if(count($contentArray[$field['name']])>0){*/
foreach ($contentArray[$field['name']] as $key => $userValue) {
if(count($contentArray[$field['name']])==1){
$moduleFrontHtml = str_replace('{{'.$field['name'].'}}', $userValue, $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional($field['name'], $userValue, $moduleFrontHtml);
$moduleFrontHtml = str_replace('{{'.$field['name'].$key.'}}', $userValue, $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional($field['name'].$key, $userValue, $moduleFrontHtml);
$moduleFrontHtml = str_replace('{{'.$field['name'].'}}', "", $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional($field['name'], "", $moduleFrontHtml);
$moduleFrontHtml = str_replace('{{'.$field['name'].'}}', "", $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional($field['name'], "", $moduleFrontHtml);
}//If Closed content type html
$moduleFrontHtml = str_replace('{{unique_cell_id}}', $contentArray['cell_id'], $moduleFrontHtml);
if(isset($repeaterUniqueId)){
$moduleFrontHtml = str_replace('{{repeater_max_count}}', $repeaterUniqueId, $moduleFrontHtml);
$moduleFrontHtml = ampforwp_replaceIfContentConditional('repeater_max_count', $repeaterUniqueId, $moduleFrontHtml);
if($contentArray['type'] == 'accordion-mod'){
$contentArray['type'] = str_replace('accordion-mod', 'apac', $contentArray['type']);
$html .= "<div class='amp_mod ap_m_".$contentArray['cell_id'].' '.$contentArray['type']."'>".$moduleFrontHtml;
/*if($contentArray['type']=="text"){
$html .= "<p class='col-wrapper'>".$contentArray['value']."</div>";
$html .= $contentArray['value'];
$html = htmlspecialchars_decode($html);
function ampforwp_pagebuilder_module_style(){
$custom_css = ampforwp_get_setting('css_editor');
$sanitized_css = ampforwp_sanitize_i_amphtml($custom_css);
echo $sanitized_css; //sanitize above
function sortByIndex($contentArray){
$completeSortedArray = array();
if(count($contentArray)>0){
foreach ($contentArray as $key => $singleContent) {
if(!isset($completeSortedArray[$singleContent['index']])){
$completeSortedArray[$singleContent['index']] = $singleContent;
$completeSortedArray[] = $singleContent;
ksort($completeSortedArray);
return $completeSortedArray;
function ampforwp_get_attachment_id( $url , $imagetype='full') {
if(filter_var($url, FILTER_VALIDATE_URL) === FALSE){
// Is URL in uploads directory?
if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) {
$file = basename( $url );
'post_type' => 'attachment',
'post_status' => 'inherit',
'key' => '_wp_attachment_metadata',
$query_args = apply_filters('ampforwp_attachment_id_query_args' , $query_args );
$query = new WP_Query( $query_args );
if ( $query->have_posts() ) {
foreach ( $query->posts as $post_id ) {
$meta = wp_get_attachment_metadata( $post_id );
$original_file = basename( $meta['file'] );
$cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
$attachment_id = $post_id;
$imageDetails = wp_get_attachment_image_src($attachment_id, $imagetype, false);
$image = get_post($attachment_id);
$caption = $image->post_excerpt;
$imageDetails['alt'] = get_post_meta($attachment_id,'_wp_attachment_image_alt', true);
$imageDetails['caption'] = $caption;
function ampforwp_replaceIfContentConditional($byReplace, $replaceWith, $string){
preg_match_all("{{if_condition_".$byReplace."==(.*?)}}", $string,$matches);
if(isset($matches[1]) && count($matches[1])>0){
$matches[1] = array_unique($matches[1]);
foreach ($matches[1] as $key => $matchValue) {
if(trim($matchValue) != trim($replaceWith)){
$string = str_replace(array("{{if_condition_".$byReplace."==".$matchValue."}}","{{ifend_condition_".$byReplace."_".$matchValue."}}"), array("<amp-condition>","</amp-condition>"), $string);
$string = preg_replace_callback('/(<amp-condition>)(.*?)(<\/amp-condition>)/s', function($match){
$string = str_replace(array("{{if_condition_".$byReplace."==".$matchValue."}}","{{ifend_condition_".$byReplace."_".$matchValue."}}"), array("",""), $string);
if(strpos($string,'{{if_'.$byReplace.'}}')!==false){
$string = str_replace(array('{{if_'.$byReplace.'}}','{{ifend_'.$byReplace.'}}',), array("<amp-condition>","</amp-condition>"), $string);
if($replaceWith=="" && trim($replaceWith)==""){
$string = preg_replace("/<amp-condition>(.*)<\/amp-condition>/i", "", $string);
$string = preg_replace("/<amp-condition>(.*)<\/amp-condition>/s", "", $string);
$string = str_replace(array('<amp-condition>','</amp-condition>'), array("",""), $string);
* Required Key $requiredKey
* Set of field array $moduleTemplate[$contentArray['type']]['fields']
function getdefaultValue($requiredKey, $fieldArray){
foreach ($fieldArray as $fieldKey => $fieldvalue) {
if($fieldvalue['name'] == $requiredKey){
return $fieldvalue['default'];