Apply specific post type media filters

Support General Apply specific post type media filters

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10316
    Infolu OfficialInfolu Official
    Participant

    Hello, I would like to apply the filters to change the texts in specific post type and not in all post types that use metabox, is it possible?

    add_filter( 'rwmb_media_add_string', 'prefix_change_add_string' );
    function prefix_change_add_string() {
        return '+ New File';
    }

    Thank you

    #10325
    Anh TranAnh Tran
    Keymaster

    Yes, you can do that with the filter, like this:

    add_filter( 'rwmb_media_add_string', function( $string ) {
        $screen = get_current_screen();
        return 'page' === $screen->post_type ? '+ New File' : $string;
    } );
    #10338
    Infolu OfficialInfolu Official
    Participant

    Your solution works, I also have the solution below, but in both solutions if you have more than one field it is not possible to create different texts.

    In the future it could include something like this in upload media

    array(
        'name'       => 'Uploadr',
        'id'         => 'field_id',
        'type'       => 'file_upload',
    
    'text_options' => array(
        'add'      => __( 'Text Exemple', 'text_domain' ),
        'single'      => __( 'Text Exemple', 'text_domain' ),
        'multiple'      => __( 'Text Exemple', 'text_domain' ),
        'remove'      => __( 'Text Exemple', 'text_domain' ),
        'edit'      => __( 'Text Exemple', 'text_domain' ),
        'view'      => __( 'Text Exemple', 'text_domain' ),
        'noTitle'      => __( 'Text Exemple', 'text_domain' ),
        'loadingUrl'      => __( 'Text Exemple', 'text_domain' ),
        'extensions'      => __( 'Text Exemple', 'text_domain' ),
        'select'      => __( 'Text Exemple', 'text_domain' ),
        'or'      => __( 'Text Exemple', 'text_domain' ),
        'uploadInstructions'      => __( 'Text Exemple', 'text_domain' ),
    ),
    
    ),

    Image and video hosting by TinyPic

    Araujo, Luiz

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Apply specific post type media filters’ is closed to new replies.