: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Gets the dynamic content fields related to Product post type.
function et_builder_get_product_dynamic_content_fields() {
'product_breadcrumb' => array(
'label' => esc_html__( 'Product Breadcrumb', 'et_builder' ),
'product_price' => array(
'label' => esc_html__( 'Product Price', 'et_builder' ),
'product_description' => array(
'label' => esc_html__( 'Product Description', 'et_builder' ),
'product_short_description' => array(
'label' => esc_html__( 'Product Short Description', 'et_builder' ),
'product_reviews_count' => array(
'label' => esc_html__( 'Product Reviews Count', 'et_builder' ),
'label' => esc_html__( 'Product SKU', 'et_builder' ),
'product_reviews' => array(
'label' => esc_html__( 'Product Reviews', 'et_builder' ),
'product_additional_information' => array(
'label' => esc_html__( 'Product Additional Information', 'et_builder' ),
'product_reviews_tab' => array(
'label' => esc_html__( 'Product Reviews', 'et_builder' ),
* Get built-in dynamic content fields.
* @param integer $post_id
function et_builder_get_built_in_dynamic_content_fields( $post_id ) {
$cache_key = 'et_builder_get_built_in_dynamic_content_fields';
if ( et_core_cache_has( $cache_key ) ) {
return et_core_cache_get( $cache_key );
$post_type = get_post_type( $post_id );
$post_type = $post_type ? $post_type : 'post';
$post_type_object = get_post_type_object( $post_type );
$post_type_label = $post_type_object->labels->singular_name;
$post_taxonomy_types = et_builder_get_taxonomy_types( $post_type );
$tag_taxonomy_post_type = $post_type;
$before_after_field_types = array( 'text', 'any' );
if ( et_theme_builder_is_layout_post_type( $post_type ) ) {
$post_type_label = esc_html__( 'Post', 'et_builder' );
$tag_taxonomy_post_type = 'post';
$public_post_types = array_keys( et_builder_get_public_post_types() );
foreach ( $public_post_types as $public_post_type ) {
$post_taxonomy_types = array_merge(
et_builder_get_taxonomy_types( $public_post_type )
$default_category_type = 'post' === $post_type ? 'category' : "${post_type}_category";
if ( ! isset( $post_taxonomy_types[ $default_category_type ] ) ) {
$default_category_type = 'category';
if ( ! empty( $post_taxonomy_types ) ) {
// Use the 1st available taxonomy as the default value.
$default_category_type = array_keys( $post_taxonomy_types );
$default_category_type = $default_category_type[0];
$date_format_options = array(
'default' => et_builder_i18n( 'Default' ),
'M j, Y' => esc_html__( 'Aug 6, 1999 (M j, Y)', 'et_builder' ),
'F d, Y' => esc_html__( 'August 06, 1999 (F d, Y)', 'et_builder' ),
'm/d/Y' => esc_html__( '08/06/1999 (m/d/Y)', 'et_builder' ),
'm.d.Y' => esc_html__( '08.06.1999 (m.d.Y)', 'et_builder' ),
'j M, Y' => esc_html__( '6 Aug, 1999 (j M, Y)', 'et_builder' ),
'l, M d' => esc_html__( 'Tuesday, Aug 06 (l, M d)', 'et_builder' ),
'custom' => esc_html__( 'Custom', 'et_builder' ),
$fields['post_title'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s/Archive Title', 'et_builder' ), $post_type_label ) ),
$fields['post_excerpt'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Excerpt', 'et_builder' ), $post_type_label ) ),
'label' => esc_html__( 'Number of Words', 'et_builder' ),
'read_more_label' => array(
'label' => esc_html__( 'Read More Text', 'et_builder' ),
$fields['post_date'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Publish Date', 'et_builder' ), $post_type_label ) ),
'label' => esc_html__( 'Date Format', 'et_builder' ),
'options' => $date_format_options,
'custom_date_format' => array(
'label' => esc_html__( 'Custom Date Format', 'et_builder' ),
'date_format' => 'custom',
$fields['post_comment_count'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Comment Count', 'et_builder' ), $post_type_label ) ),
'link_to_comments_page' => array(
'label' => esc_html__( 'Link to Comments Area', 'et_builder' ),
'type' => 'yes_no_button',
'on' => et_builder_i18n( 'Yes' ),
'off' => et_builder_i18n( 'No' ),
if ( ! empty( $post_taxonomy_types ) ) {
$fields['post_categories'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Categories', 'et_builder' ), $post_type_label ) ),
'link_to_term_page' => array(
'label' => esc_html__( 'Link to Category Index Pages', 'et_builder' ),
'type' => 'yes_no_button',
'on' => et_builder_i18n( 'Yes' ),
'off' => et_builder_i18n( 'No' ),
'label' => esc_html__( 'Categories Separator', 'et_builder' ),
'category_type' => array(
'label' => esc_html__( 'Category Type', 'et_builder' ),
'options' => $post_taxonomy_types,
'default' => $default_category_type,
// Fill in tag taxonomies.
if ( isset( $post_taxonomy_types["{$tag_taxonomy_post_type}_tag"] ) ) {
$fields['post_tags'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Tags', 'et_builder' ), $post_type_label ) ),
'link_to_term_page' => array(
'label' => esc_html__( 'Link to Tag Index Pages', 'et_builder' ),
'type' => 'yes_no_button',
'on' => et_builder_i18n( 'Yes' ),
'off' => et_builder_i18n( 'No' ),
'label' => esc_html__( 'Tags Separator', 'et_builder' ),
'category_type' => array(
'label' => esc_html__( 'Category Type', 'et_builder' ),
'options' => $post_taxonomy_types,
'default' => "{$tag_taxonomy_post_type}_tag",
$fields['post_link'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Link', 'et_builder' ), $post_type_label ) ),
'label' => esc_html__( 'Link Text', 'et_builder' ),
// Translators: %1$s: Post type name
'post_title' => esc_html( sprintf( __( '%1$s Title', 'et_builder' ), $post_type_label ) ),
'custom' => esc_html__( 'Custom', 'et_builder' ),
'default' => 'post_title',
'label' => esc_html__( 'Custom Link Text', 'et_builder' ),
$fields['post_author'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Author', 'et_builder' ), $post_type_label ) ),
'label' => esc_html__( 'Name Format', 'et_builder' ),
'display_name' => esc_html__( 'Public Display Name', 'et_builder' ),
'first_last_name' => esc_html__( 'First & Last Name', 'et_builder' ),
'last_first_name' => esc_html__( 'Last, First Name', 'et_builder' ),
'first_name' => esc_html__( 'First Name', 'et_builder' ),
'last_name' => esc_html__( 'Last Name', 'et_builder' ),
'nickname' => esc_html__( 'Nickname', 'et_builder' ),
'username' => esc_html__( 'Username', 'et_builder' ),
'default' => 'display_name',
'label' => esc_html__( 'Link Name', 'et_builder' ),
'type' => 'yes_no_button',
'on' => et_builder_i18n( 'Yes' ),
'off' => et_builder_i18n( 'No' ),
'link_destination' => array(
'label' => esc_html__( 'Link Destination', 'et_builder' ),
'author_archive' => esc_html__( 'Author Archive Page', 'et_builder' ),
'author_website' => esc_html__( 'Author Website', 'et_builder' ),
'default' => 'author_archive',
$fields['post_author_bio'] = array(
'label' => esc_html__( 'Author Bio', 'et_builder' ),
if ( et_builder_tb_enabled() ) {
$fields['term_description'] = array(
'label' => esc_html__( 'Category Description', 'et_builder' ),
$fields['site_title'] = array(
'label' => esc_html__( 'Site Title', 'et_builder' ),
$fields['site_tagline'] = array(
'label' => esc_html__( 'Site Tagline', 'et_builder' ),
$fields['current_date'] = array(
'label' => esc_html__( 'Current Date', 'et_builder' ),
'label' => esc_html__( 'Date Format', 'et_builder' ),
'options' => $date_format_options,
'custom_date_format' => array(
'label' => esc_html__( 'Custom Date Format', 'et_builder' ),
'date_format' => 'custom',
$fields['post_link_url'] = array(
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( 'Current %1$s Link', 'et_builder' ), $post_type_label ) ),
$fields['post_author_url'] = array(
'label' => esc_html__( 'Author Page Link', 'et_builder' ),
$fields['home_url'] = array(
'label' => esc_html__( 'Homepage Link', 'et_builder' ),
// Fill in post type URL options.
$post_types = et_builder_get_public_post_types();
foreach ( $post_types as $public_post_type ) {
$public_post_type_label = $public_post_type->labels->singular_name;
$key = 'post_link_url_' . $public_post_type->name;
// Translators: %1$s: Post type name
'label' => esc_html( sprintf( __( '%1$s Link', 'et_builder' ), $public_post_type_label ) ),
'label' => $public_post_type_label,
'post_type' => $public_post_type->name,
$fields['post_featured_image'] = array(
'label' => esc_html__( 'Featured Image', 'et_builder' ),
$fields['post_author_profile_picture'] = array(
// Translators: %1$s: Post type name
'label' => esc_html__( 'Author Profile Picture', 'et_builder' ),
$fields['site_logo'] = array(
'label' => esc_html__( 'Site Logo', 'et_builder' ),
if ( et_builder_tb_enabled() ) {
$fields['post_meta_key'] = array(
'label' => esc_html__( 'Manual Custom Field Name', 'et_builder' ),
'group' => esc_html__( 'Custom Fields', 'et_builder' ),
'label' => esc_html__( 'Field Name', 'et_builder' ),
if ( current_user_can( 'unfiltered_html' ) ) {
$fields['post_meta_key']['fields']['enable_html'] = array(
'label' => esc_html__( 'Enable raw HTML', 'et_builder' ),
'type' => 'yes_no_button',
'on' => et_builder_i18n( 'Yes' ),
'off' => et_builder_i18n( 'No' ),
* Include Product dynamic fields on Product post type.
* This is enforced based on the discussion at
* @see https://github.com/elegantthemes/Divi/issues/15921#issuecomment-512707471
if ( et_is_woocommerce_plugin_active() && ( 'product' === $post_type || et_theme_builder_is_layout_post_type( $post_type ) ) ) {
$fields = array_merge( $fields, et_builder_get_product_dynamic_content_fields() );
foreach ( $fields as $key => $field ) {
$fields[ $key ]['custom'] = false;
$fields[ $key ]['group'] = et_()->array_get( $fields, "{$key}.group", 'Default' );
if ( in_array( $field['type'], $before_after_field_types, true ) ) {
$settings = isset( $field['fields'] ) ? $field['fields'] : array();
$settings = array_merge( array(
'label' => et_builder_i18n( 'Before' ),
'label' => et_builder_i18n( 'After' ),
$fields[ $key ]['fields'] = $settings;
et_core_cache_add( $cache_key, $fields );
* Clear dynamic content fields cache whenever a custom post type is registered.
function et_builder_clear_get_built_in_dynamic_content_fields_cache() {
et_core_cache_delete( 'et_builder_get_built_in_dynamic_content_fields' );
add_action( 'registered_post_type', 'et_builder_clear_get_built_in_dynamic_content_fields_cache' );
* Get all public taxonomies associated with a given post type.
* @param string $post_type
function et_builder_get_taxonomy_types( $post_type ) {
$taxonomies = get_object_taxonomies( $post_type, 'object' );
if ( empty( $taxonomies ) ) {
foreach ( $taxonomies as $taxonomy ) {
if ( ! empty( $taxonomy ) && $taxonomy->public && $taxonomy->show_ui ) {
$list[ $taxonomy->name ] = $taxonomy->label;