پرش به محتویات

"Filter: bricks/dynamic_data/format_value"

مقدار نهایی پردازش شده هر تگ داده پویا را قبل از ارائه فیلتر می‌کند. این یک فیلتر قدرتمند است که برای هر تگ پویا اجرا می‌شود و به شما امکان می‌دهد خروجی‌ها را بر اساس زمینه یا نام برچسب به صورت جهانی تغییر دهید.

پارامترها

  • $value (mixed): The processed value of the dynamic tag.
  • $tag (string): The dynamic data tag (e.g., post_title, my_custom_tag).
  • $post_id (int): The ID of the post context.
  • $filters (array): Array of modifiers/arguments applied to the tag (e.g., ['fallback' => '...']).
  • $context (string): The context where the tag is being rendered (e.g., text, link, image, video, object, media).

نمونه استفاده

add_filter( 'bricks/dynamic_data/format_value', function( $value, $tag, $post_id, $filters, $context ) {
    // Example: Add a suffix to the post title when used in text context
    if ( $tag === 'post_title' && $context === 'text' ) {
        return $value . ' | My Site';
    }

    return $value;
}, 10, 5 );