0 ) { $text = self::limit_str( $text, intval( $max_length ) ); } if ( empty( $text ) ) { $text = $fallback; } $text = $attr['dc']['beforeText'] . $text . $attr['dc']['afterText']; if ( ( $link_enabled && $link_src ) ) { $url = self::get_link( $post_id, $link_src ); } return array( $text, $url ); } /** * Get Html of Dynamic Content for Blocks * * @since 4.1.1 * * @param array $attr * * @return string */ public static function get_dc_content_for_block( &$attr, $dcContent ) { for ( $i = 0; $i < count( $attr['dcFields'] ); $i++ ) { $dcGroup = $attr['dcFields'][ $i ]; if ( ! isset( $dcGroup['fields'] ) || ! isset( $dcGroup['id'] ) ) { continue; } $dcContent[ $i ] .= '
' . $dcField['beforeText'] . '
' : ''; $text = ''; if ( str_starts_with( $dcField['dataSrc'], 'site_' ) ) { $text = self::get_site_info( $dcField['dataSrc'] ); } elseif ( str_starts_with( $dcField['contentSrc'], 'post_' ) ) { $text = self::get_post_info( $dcField['postId'], $dcField['contentSrc'] ); } elseif ( str_starts_with( $dcField['contentSrc'], 'a_' ) ) { $text = self::get_author_info( $dcField['postId'], $dcField['contentSrc'] ); } elseif ( str_starts_with( $dcField['contentSrc'], 'acf_' ) || str_starts_with( $dcField['contentSrc'], 'cmeta_' ) || str_starts_with( $dcField['contentSrc'], 'pods_' ) || str_starts_with( $dcField['contentSrc'], 'mb_' ) ) { $text = self::get_field_value( $dcField['postId'], $dcField['contentSrc'] ); } if ( ! empty( $text ) && ! empty( $dcField['maxCharLen'] ) && intval( $dcField['maxCharLen'] ) > 0 ) { $text = self::limit_str( $text, intval( $dcField['maxCharLen'] ) ); } if ( empty( $text ) && '0' !== $text && 0 !== $text ) { $text = $dcField['fallback']; } $dcContent[ $i ] .= '' . sanitize_text_field( $text ) . '
'; $dcContent[ $i ] .= $dcField['afterText'] ? '' . $dcField['afterText'] . '
' : ''; $dcContent[ $i ] .= '