: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
namespace NetworkPosts\Components;
class NetsPostsShortcodeContainer {
private static $DEFAULT_VALUES = array(
'number_latest_x_posts_excluded' => 0,
'taxonomy_offset_names' => '',
'taxonomy_offset_type' => 'category', // category|tag|any
'show_categories' => false,
'include_link_title' => false,
'exclude_link_title_posts' => '',
'link_open_new_window' => false,
'default_thumbnail' => null,
'title_length_characters' => 999,
'taxonomy_type' => 'category,tag',
'show_all_taxonomies' => false,
'show_all_taxonomy_types' => false,
'exclude_taxonomy' => '',
'excerpt_length' => null,
'excerpt_letters_length' => 400,
'filter_excerpt' => false,
'filter_excerpt_shortcodes' => true,
'use_shortcode_in_excerpt' => false,
'image_class' => 'post-thumbnail',
'date_format' => 'n/j/Y',
'prev' => '« Previous',
'next' => 'Next »',
'title_color' => '#000000',
'text_color' => '#000000',
'wrap_title_start' => '',
'wrap_custom_title_start' => '',
'wrap_custom_title_end' => '',
'wrap_image_start' => '',
'wrap_price_start' => '',
'wrap_content_start' => '',
'wrap_content_end' => '',
'manual_excerpt_length' => null,
'manual_excerpt_letters_length' => null,
'use_layout' => 'default', //there can be 2 values. if we use "default" then views/post_layout_default.php will
//be used otherwise if we use "inline" - views/post_layout_inline.php will be used
'align_thumbnail' => 'left', //this attribute can be "left" or "right",
'wrap_excerpt_start' => '',
'wrap_excerpt_end' => '',
'show_before_date' => '',
'exclude_all_past_events' => '',
'show_past_events' => '',
'include_post_meta' => '',
'show_meta_label' => true,
'include_acf_fields' => false,
'hide_acf_labels' => false,
'taxonomy_offsets' => [],
'must_include_categories' => false,
'must_be_in_taxonomies_only' => false,
'filter_by_title_keywords' => false,
'domain_mapping' => 'site_url',
'page_has_no_child' => false,
'order_post_by_acf_date' => false,
'acf_date_format' => false,
'add_link_to_acf' => false,
'add_link_to_date' => false,
'show_category_icon' => false,
'show_tag_icon' => false,
'remove_blog_prefix' => false,
'show_custom_taxonomies' => false,
'show_custom_taxonomy_icon' => false,
'load_posts_dynamically' => false,
'posts_preloader_icon' => '',
'show_preloader_icon' => true,
'show_only_after_x_days_old' => null,
'exclude_read_more_link' => '',
'strip_excerpt_tags' => true,
'hide_password_protected_posts' => true,
'img_link_open_new_window' => false,
'show_author_avatar' => false,
'author_avatar_size' => 96,
'hide_post_date_meta_info' => false,
'wrap_post_date_start' => '',
'wrap_post_date_end' => '',
private $attributes = array();
public function get_shortcode_attributes() {
return $this->attributes;
public function set_shortcode_attributes( $atts ) {
$this->attributes = shortcode_atts( self::$DEFAULT_VALUES, $atts );
public function add_attributes( $atts ) {
$this->attributes = array_merge( $this->attributes, $this->prepare_array( $atts ) );
public function has_value( $name ) {
return isset( $this->attributes[ $name ] ) && ! empty( $this->attributes[ $name ] );
public function get( $name ) {
return $this->attributes[ $name ];
public function get_boolean( $name ) {
if( $this->has_value( $name ) ){
$value = $this->get( $name );
if( is_numeric( $value ) ){
if( is_string( $value ) ) {
return strtolower( $value ) == 'true';
public function is_match( $name, $pattern ) {
$has_value = $this->has_value( $name );
$value = $this->get( $name );
return preg_match( $pattern, $value );
public function split_array( $name, $pattern ) {
$value = $this->get( $name );
return array_map( function($str){ return trim($str); }, mb_split( $pattern, $value ) );
public static function newInstance( $atts ) {
$mgr = new NetsPostsShortcodeContainer();
$mgr->set_shortcode_attributes( $atts );
private function prepare_array( $data ) {
foreach ( $data as $key => $value ) {
$new_data[ $key ] = esc_sql( $value );
public function get_int( string $attribute ): int {
return intval( $this->get( $attribute ) );
public function get_html( string $name ): string {
$value = $this->get( $name );
$value = html_entity_decode( $value );
return str_replace( '</p>', '', $value );