"+Add More" Button Customization

Support MB Group "+Add More" Button Customization

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #5855
    DavidDavid
    Participant

    Hi,
    I had a problem in changing the text of the clone button, using your following snippet:

    add_filter( 'rwmb_group_add_clone_button_text', 'prefix_group_add_clone_button_text', 10, 2 );
    function prefix_group_add_clone_button_text( $text, $field ) {
        // If you want to change text by field, you can do something like this
         if ( 'group_id' == $field['id'] ) {
             $text = __( '+ Add more chapter', 'textdomain' );
         }
        // return $text;
    }

    In order to solve the problem, I edited the meta-box/inc/clone.php by changing $field['add_button'] to $field.

    /**
    	 * Add clone button.
    	 *
    	 * @param array $field Field parameters.
    	 * @return string $html
    	 */
    	public static function add_clone_button( $field ) {
    		if ( ! $field['clone'] ) {
    			return '';
    		}
    		$text = RWMB_Field::filter( 'add_clone_button_text', $field['add_button'] ); // <---
    		return '<a href="#" class="rwmb-button button-primary add-clone">' . esc_html( $text ) . '</a>';
    	}

    I'm not sure if I am doing right thing and if this is a bug. If that's the case, it would be great if you could update the plugin. Otherwise, could you please suggest me how to manage this issue?

    Thanks

    #5857
    DavidDavid
    Participant

    Ok, I found the "add_button" attribute. Sorry for that!

    #5860
    Anh TranAnh Tran
    Keymaster

    Yes, the add_button is just added recently to help you change the button text quickly. Glad that you found it 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘"+Add More" Button Customization’ is closed to new replies.