$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugins - Add Cancel Button to a Custom Meta Box|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugins - Add Cancel Button to a Custom Meta Box

matteradmin9PV0评论

Any ideas how I could add a cancel button, like the default one in the Publish meta box, to a custom meta box?

The standard code is <a href="#visibility" class="cancel-post-visibility hide-if-no-js button-cancel">Cancel</a> I guess it's using some js to do the cancel/reset action so it's not easy to replicate.

I basically want to add a button that will clear an input field in my meta box. input type=reset will clear all the fields on the page, so I wanted to see if I could use WP's toolset.

Open to ideas for the best solution here.

Any ideas how I could add a cancel button, like the default one in the Publish meta box, to a custom meta box?

The standard code is <a href="#visibility" class="cancel-post-visibility hide-if-no-js button-cancel">Cancel</a> I guess it's using some js to do the cancel/reset action so it's not easy to replicate.

I basically want to add a button that will clear an input field in my meta box. input type=reset will clear all the fields on the page, so I wanted to see if I could use WP's toolset.

Open to ideas for the best solution here.

Share Improve this question asked Oct 20, 2018 at 17:05 SalSal 1535 bronze badges 2
  • Have you added a cancel button? Even if it's non-functional, I think you can ignore the whole metabox/WP thing and treat this as a pure "I have a series on input form elements inside of a div container, how do I clear them when a link is clicked?". If you're looking for a WP specific way to do this though, there isn't one – Tom J Nowell Commented Oct 20, 2018 at 17:31
  • Yeah, I was hoping for a Wordpress-specific way to do this. If there isn't something like that, then I can use a line of js to handle it. – Sal Commented Oct 20, 2018 at 19:38
Add a comment  | 

1 Answer 1

Reset to default 0

I ended up using this:

<a class="clear_button hide-if-no-js button-cancel" title="clear" data-clear style="text-decoration:underline;">Clear</a>

It does the job. I was hoping for something more "Wordpressy" but don't see a metabox cancel function.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far