Paparappa Paparappa - 1 month ago 7
Javascript Question

How do I edit a submit button in Wordpress?

I want to add an

onclick
attribute to the submit button of the media.php section in wordpress adminpanel. Where can I edit this button in Wordpress? It only writes out
<?php submit_button( __( 'Update Media' ), 'primary', 'save' ); ?>
and I can't find a way to just edit the HTML to add my
onclick
.

Answer

The function submit_button($text, $type, $name, $wrap, $other_attributes) is located in the /wp-admin/includes/template.php file on line 2169

submit_button(..) It then does a call on get_submit_button($text, $type, $name, $wrap, $other_attributes) which is located in the same file on line 2190.

Unfortunately there is no apply_filters to modify the output of the WordPress. In that case you have to make changes in the WordPress core files. I do not suggest you make any change in the WordPress core files, because on next update you will lose that changes.

Comments