[wp-trac] [WordPress Trac] #47616: Enhancement: doing_shortcode() function similar to doing_filter()
WordPress Trac
noreply at wordpress.org
Mon Feb 1 15:13:44 UTC 2021
#47616: Enhancement: doing_shortcode() function similar to doing_filter()
-------------------------------------------------+-------------------------
Reporter: keraweb | Owner: audrasjb
Type: enhancement | Status: accepted
Priority: normal | Milestone: 5.7
Component: Shortcodes | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-docs needs-dev-note | Focuses:
commit |
-------------------------------------------------+-------------------------
Changes (by hellofromTonya):
* keywords: has-patch needs-docs needs-dev-note => has-patch needs-docs
needs-dev-note commit
Comment:
Latest patch works as expected. Here is the code I used for the attached
screenshot above:
{{{#!php
<?php
function worg_get_testing_foo() {
if ( doing_shortcode( 'testing-foo' ) ) {
return 'Yes. [' . current_shortcode() . '] is currently
used';
}
return 'No. Not called from a shortcode';
}
add_shortcode(
'testing-foo',
function () {
return '<p>Doing shortcode? ' . worg_get_testing_foo() .
'</p>';
}
);
}}}
Marking for `commit` consideration.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47616#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list