sarkfultion
โ
โบ
wp-includes
sarkfultion
293 dreads
โ redisq
๐
abilities-api/
dreads
sarkfultion
dreads
๐
ai-client/
dreads
sarkfultion
dreads
๐
assets/
dreads
sarkfultion
dreads
๐
block-bindings/
dreads
sarkfultion
dreads
๐
block-patterns/
dreads
sarkfultion
dreads
๐
block-supports/
dreads
sarkfultion
dreads
๐
blocks/
dreads
sarkfultion
dreads
๐
build/
dreads
sarkfultion
dreads
๐
certificates/
dreads
sarkfultion
dreads
๐
css/
dreads
sarkfultion
dreads
๐
customize/
dreads
sarkfultion
dreads
๐
fonts/
dreads
sarkfultion
dreads
๐
html-api/
dreads
sarkfultion
dreads
๐
ID3/
dreads
sarkfultion
dreads
๐
images/
dreads
sarkfultion
dreads
๐
interactivity-api/
dreads
sarkfultion
dreads
๐
IXR/
dreads
sarkfultion
dreads
๐
js/
dreads
sarkfultion
dreads
๐
l10n/
dreads
sarkfultion
dreads
๐
php-ai-client/
dreads
sarkfultion
dreads
๐
php-compat/
dreads
sarkfultion
dreads
๐
PHPMailer/
dreads
sarkfultion
dreads
๐
pomo/
dreads
sarkfultion
dreads
๐
Requests/
dreads
sarkfultion
dreads
๐
rest-api/
dreads
sarkfultion
dreads
๐
SimplePie/
dreads
sarkfultion
dreads
๐
sitemaps/
dreads
sarkfultion
dreads
๐
sodium_compat/
dreads
sarkfultion
dreads
๐
style-engine/
dreads
sarkfultion
dreads
๐
Text/
dreads
sarkfultion
dreads
๐
theme-compat/
dreads
sarkfultion
dreads
๐
widgets/
dreads
sarkfultion
dreads
๐
abilities-api.php
32,800 B
sarkfultion
dreads
๐
abilities.php
11,797 B
sarkfultion
dreads
๐
admin-bar.php
40,115 B
sarkfultion
dreads
๐
ai-client.php
2,549 B
sarkfultion
dreads
๐
atomlib.php
12,181 B
sarkfultion
dreads
๐
author-template.php
19,844 B
sarkfultion
dreads
๐
block-bindings.php
7,632 B
sarkfultion
dreads
๐
block-editor.php
28,724 B
sarkfultion
dreads
๐
block-i18n.json
316 B
sarkfultion
dreads
๐
block-patterns.php
15,606 B
sarkfultion
dreads
๐
block-template-utils.php
63,477 B
sarkfultion
dreads
๐
block-template.php
18,257 B
sarkfultion
dreads
๐
blocks.php
124,205 B
sarkfultion
dreads
๐
bookmark-template.php
12,768 B
sarkfultion
dreads
๐
bookmark.php
15,427 B
sarkfultion
dreads
๐
cache-compat.php
11,021 B
sarkfultion
dreads
๐
cache.php
13,486 B
sarkfultion
dreads
๐
canonical.php
34,786 B
sarkfultion
dreads
๐
capabilities.php
43,584 B
sarkfultion
dreads
๐
category-template.php
56,990 B
sarkfultion
dreads
๐
category.php
12,834 B
sarkfultion
dreads
๐
class-avif-info.php
30,008 B
sarkfultion
dreads
๐
class-feed.php
539 B
sarkfultion
dreads
๐
class-http.php
367 B
sarkfultion
dreads
๐
class-IXR.php
2,609 B
sarkfultion
dreads
๐
class-json.php
43,676 B
sarkfultion
dreads
๐
class-oembed.php
401 B
sarkfultion
dreads
๐
class-phpass.php
6,771 B
sarkfultion
dreads
๐
class-phpmailer.php
664 B
sarkfultion
dreads
๐
class-pop3.php
21,100 B
sarkfultion
dreads
๐
class-requests.php
2,237 B
sarkfultion
dreads
๐
class-simplepie.php
453 B
sarkfultion
dreads
๐
class-smtp.php
457 B
sarkfultion
dreads
๐
class-snoopy.php
37,715 B
sarkfultion
dreads
๐
class-walker-category-dropdown.php
2,469 B
sarkfultion
dreads
๐
class-walker-category.php
8,477 B
sarkfultion
dreads
๐
class-walker-comment.php
14,221 B
sarkfultion
dreads
๐
class-walker-nav-menu.php
12,044 B
sarkfultion
dreads
๐
class-walker-page-dropdown.php
2,710 B
sarkfultion
dreads
๐
class-walker-page.php
7,612 B
sarkfultion
dreads
๐
class-wp-admin-bar.php
18,002 B
sarkfultion
dreads
๐
class-wp-ajax-response.php
5,288 B
sarkfultion
dreads
๐
class-wp-application-passwords.php
17,099 B
sarkfultion
dreads
๐
class-wp-block-bindings-registry.php
8,263 B
sarkfultion
dreads
๐
class-wp-block-bindings-source.php
2,992 B
sarkfultion
dreads
๐
class-wp-block-editor-context.php
1,350 B
sarkfultion
dreads
๐
class-wp-block-list.php
4,713 B
sarkfultion
dreads
๐
class-wp-block-metadata-registry.php
11,846 B
sarkfultion
dreads
๐
class-wp-block-parser-block.php
2,555 B
sarkfultion
dreads
๐
class-wp-block-parser-frame.php
1,994 B
sarkfultion
dreads
๐
class-wp-block-parser.php
11,561 B
sarkfultion
dreads
๐
class-wp-block-pattern-categories-registry.php
4,383 B
sarkfultion
dreads
๐
class-wp-block-patterns-registry.php
10,265 B
sarkfultion
dreads
๐
class-wp-block-processor.php
69,914 B
sarkfultion
dreads
๐
class-wp-block-styles-registry.php
6,419 B
sarkfultion
dreads
๐
class-wp-block-supports.php
7,578 B
sarkfultion
dreads
๐
class-wp-block-template.php
2,111 B
sarkfultion
dreads
๐
class-wp-block-templates-registry.php
7,080 B
sarkfultion
dreads
๐
class-wp-block-type-registry.php
5,305 B
sarkfultion
dreads
๐
class-wp-block-type.php
17,222 B
sarkfultion
dreads
๐
class-wp-block.php
28,236 B
sarkfultion
dreads
๐
class-wp-classic-to-block-menu-converter.php
4,026 B
sarkfultion
dreads
๐
class-wp-comment-query.php
49,040 B
sarkfultion
dreads
๐
class-wp-comment.php
17,249 B
sarkfultion
dreads
๐
class-wp-connector-registry.php
15,181 B
sarkfultion
dreads
๐
class-wp-customize-control.php
26,112 B
sarkfultion
dreads
๐
class-wp-customize-manager.php
203,420 B
sarkfultion
dreads
๐
class-wp-customize-nav-menus.php
58,285 B
sarkfultion
dreads
๐
class-wp-customize-panel.php
10,703 B
sarkfultion
dreads
๐
class-wp-customize-section.php
11,209 B
sarkfultion
dreads
๐
class-wp-customize-setting.php
37,685 B
sarkfultion
dreads
๐
class-wp-customize-widgets.php
72,596 B
sarkfultion
dreads
๐
class-wp-date-query.php
35,970 B
sarkfultion
dreads
๐
class-wp-dependencies.php
17,089 B
sarkfultion
dreads
๐
class-wp-dependency.php
2,653 B
sarkfultion
dreads
๐
class-wp-duotone.php
40,836 B
sarkfultion
dreads
๐
class-wp-editor.php
72,228 B
sarkfultion
dreads
๐
class-wp-embed.php
15,908 B
sarkfultion
dreads
๐
class-wp-error.php
7,514 B
sarkfultion
dreads
๐
class-wp-exception.php
253 B
sarkfultion
dreads
๐
class-wp-fatal-error-handler.php
8,150 B
sarkfultion
dreads
๐
class-wp-feed-cache-transient.php
3,304 B
sarkfultion
dreads
๐
class-wp-feed-cache.php
969 B
sarkfultion
dreads
๐
class-wp-filter-sentinel.php
760 B
sarkfultion
dreads
๐
class-wp-hook.php
17,584 B
sarkfultion
dreads
๐
class-wp-http-cookie.php
7,269 B
sarkfultion
dreads
๐
class-wp-http-curl.php
13,261 B
sarkfultion
dreads
๐
class-wp-http-encoding.php
6,689 B
sarkfultion
dreads
๐
class-wp-http-ixr-client.php
3,516 B
sarkfultion
dreads
๐
class-wp-http-proxy.php
5,980 B
sarkfultion
dreads
๐
class-wp-http-requests-hooks.php
2,022 B
sarkfultion
dreads
๐
class-wp-http-requests-response.php
4,243 B
sarkfultion
dreads
๐
class-wp-http-response.php
2,977 B
sarkfultion
dreads
๐
class-wp-http-streams.php
16,764 B
sarkfultion
dreads
๐
class-wp-http.php
41,737 B
sarkfultion
dreads
๐
class-wp-icon-collections-registry.php
5,805 B
sarkfultion
dreads
๐
class-wp-icons-registry.php
9,903 B
sarkfultion
dreads
๐
class-wp-image-editor-gd.php
20,741 B
sarkfultion
dreads
๐
class-wp-image-editor-imagick.php
43,454 B
sarkfultion
dreads
๐
class-wp-image-editor.php
17,456 B
sarkfultion
dreads
๐
class-wp-list-util.php
7,443 B
sarkfultion
dreads
๐
class-wp-locale-switcher.php
6,776 B
sarkfultion
dreads
๐
class-wp-locale.php
16,848 B
sarkfultion
dreads
๐
class-wp-matchesmapregex.php
1,828 B
sarkfultion
dreads
๐
class-wp-meta-query.php
31,697 B
sarkfultion
dreads
๐
class-wp-metadata-lazyloader.php
6,833 B
sarkfultion
dreads
๐
class-wp-navigation-fallback.php
9,193 B
sarkfultion
dreads
๐
class-wp-network-query.php
19,989 B
sarkfultion
dreads
๐
class-wp-network.php
12,411 B
sarkfultion
dreads
๐
class-wp-object-cache.php
17,524 B
sarkfultion
dreads
๐
class-wp-oembed-controller.php
7,152 B
sarkfultion
dreads
๐
class-wp-oembed.php
33,922 B
sarkfultion
dreads
๐
class-wp-paused-extensions-storage.php
5,067 B
sarkfultion
dreads
๐
class-wp-phpmailer.php
4,348 B
sarkfultion
dreads
๐
class-wp-plugin-dependencies.php
25,209 B
sarkfultion
dreads
๐
class-wp-post-type.php
30,672 B
sarkfultion
dreads
๐
class-wp-post.php
8,806 B
sarkfultion
dreads
๐
class-wp-query.php
165,603 B
sarkfultion
dreads
๐
class-wp-recovery-mode-cookie-service.php
6,877 B
sarkfultion
dreads
๐
class-wp-recovery-mode-email-service.php
11,162 B
sarkfultion
dreads
๐
class-wp-recovery-mode-key-service.php
4,914 B
sarkfultion
dreads
๐
class-wp-recovery-mode-link-service.php
3,523 B
sarkfultion
dreads
๐
class-wp-recovery-mode.php
11,460 B
sarkfultion
dreads
๐
class-wp-rewrite.php
63,693 B
sarkfultion
dreads
๐
class-wp-role.php
2,523 B
sarkfultion
dreads
๐
class-wp-roles.php
9,326 B
sarkfultion
dreads
๐
class-wp-script-modules.php
40,743 B
sarkfultion
dreads
๐
class-wp-scripts.php
36,754 B
sarkfultion
dreads
๐
class-wp-session-tokens.php
7,319 B
sarkfultion
dreads
๐
class-wp-simplepie-file.php
3,552 B
sarkfultion
dreads
๐
class-wp-simplepie-sanitize-kses.php
1,903 B
sarkfultion
dreads
๐
class-wp-site-query.php
31,482 B
sarkfultion
dreads
๐
class-wp-site.php
7,836 B
sarkfultion
dreads
๐
class-wp-speculation-rules.php
7,884 B
sarkfultion
dreads
๐
class-wp-styles.php
13,316 B
sarkfultion
dreads
๐
class-wp-tax-query.php
19,577 B
sarkfultion
dreads
๐
class-wp-taxonomy.php
18,559 B
sarkfultion
dreads
๐
class-wp-term-query.php
40,751 B
sarkfultion
dreads
๐
class-wp-term.php
5,263 B
sarkfultion
dreads
๐
class-wp-text-diff-renderer-inline.php
979 B
sarkfultion
dreads
๐
class-wp-text-diff-renderer-table.php
18,925 B
sarkfultion
dreads
๐
class-wp-textdomain-registry.php
10,481 B
sarkfultion
dreads
๐
class-wp-theme-json-data.php
1,805 B
sarkfultion
dreads
๐
class-wp-theme-json-resolver.php
35,692 B
sarkfultion
dreads
๐
class-wp-theme-json-schema.php
7,367 B
sarkfultion
dreads
๐
class-wp-theme-json.php
222,059 B
sarkfultion
dreads
๐
class-wp-theme.php
65,811 B
sarkfultion
dreads
๐
class-wp-token-map.php
29,032 B
sarkfultion
dreads
๐
class-wp-url-pattern-prefixer.php
4,802 B
sarkfultion
dreads
๐
class-wp-user-meta-session-tokens.php
2,954 B
sarkfultion
dreads
๐
class-wp-user-query.php
44,102 B
sarkfultion
dreads
๐
class-wp-user-request.php
2,342 B
sarkfultion
dreads
๐
class-wp-user.php
23,189 B
sarkfultion
dreads
๐
class-wp-view-config-data.php
29,427 B
sarkfultion
dreads
๐
class-wp-walker.php
13,292 B
sarkfultion
dreads
๐
class-wp-widget-factory.php
4,113 B
sarkfultion
dreads
๐
class-wp-widget.php
18,452 B
sarkfultion
dreads
๐
class-wp-xmlrpc-server.php
219,083 B
sarkfultion
dreads
๐
class-wp.php
26,520 B
sarkfultion
dreads
๐
class-wpdb.php
121,437 B
sarkfultion
dreads
๐
class.wp-dependencies.php
373 B
sarkfultion
dreads
๐
class.wp-scripts.php
343 B
sarkfultion
dreads
๐
class.wp-styles.php
338 B
sarkfultion
dreads
๐
comment-template.php
103,211 B
sarkfultion
dreads
๐
comment.php
150,630 B
sarkfultion
dreads
๐
compat-utf8.php
19,386 B
sarkfultion
dreads
๐
compat.php
22,479 B
sarkfultion
dreads
๐
connectors.php
32,922 B
sarkfultion
dreads
๐
cron.php
46,266 B
sarkfultion
dreads
๐
date.php
400 B
sarkfultion
dreads
๐
default-constants.php
11,365 B
sarkfultion
dreads
๐
default-filters.php
39,500 B
sarkfultion
dreads
๐
default-widgets.php
2,288 B
sarkfultion
dreads
๐
deprecated.php
193,977 B
sarkfultion
dreads
๐
embed-template.php
338 B
sarkfultion
dreads
๐
embed.php
39,215 B
sarkfultion
dreads
๐
error-protection.php
4,092 B
sarkfultion
dreads
๐
error_log
30,221 B
sarkfultion
dreads
๐
feed-atom-comments.php
5,504 B
sarkfultion
dreads
๐
feed-atom.php
3,114 B
sarkfultion
dreads
๐
feed-rdf.php
2,668 B
sarkfultion
dreads
๐
feed-rss.php
1,189 B
sarkfultion
dreads
๐
feed-rss2-comments.php
4,136 B
sarkfultion
dreads
๐
feed-rss2.php
3,799 B
sarkfultion
dreads
๐
feed.php
25,189 B
sarkfultion
dreads
๐
fonts.php
9,789 B
sarkfultion
dreads
๐
formatting.php
357,884 B
sarkfultion
dreads
๐
functions.php
295,481 B
sarkfultion
dreads
๐
functions.wp-scripts.php
20,492 B
sarkfultion
dreads
๐
functions.wp-styles.php
8,654 B
sarkfultion
dreads
๐
general-template.php
184,198 B
sarkfultion
dreads
๐
global-styles-and-settings.php
20,780 B
sarkfultion
dreads
๐
http.php
28,961 B
sarkfultion
dreads
๐
https-detection.php
5,857 B
sarkfultion
dreads
๐
https-migration.php
4,741 B
sarkfultion
dreads
๐
icons.php
6,334 B
sarkfultion
dreads
๐
json-schema.php
7,802 B
sarkfultion
dreads
๐
kses.php
91,874 B
sarkfultion
dreads
๐
l10n.php
71,415 B
sarkfultion
dreads
๐
link-template.php
160,143 B
sarkfultion
dreads
๐
load.php
56,476 B
sarkfultion
dreads
๐
locale.php
162 B
sarkfultion
dreads
๐
media-template.php
65,759 B
sarkfultion
dreads
๐
media.php
236,804 B
sarkfultion
dreads
๐
meta.php
66,739 B
sarkfultion
dreads
๐
ms-blogs.php
26,324 B
sarkfultion
dreads
๐
ms-default-constants.php
4,921 B
sarkfultion
dreads
๐
ms-default-filters.php
6,636 B
sarkfultion
dreads
๐
ms-deprecated.php
21,787 B
sarkfultion
dreads
๐
ms-files.php
2,857 B
sarkfultion
dreads
๐
ms-functions.php
92,530 B
sarkfultion
dreads
๐
ms-load.php
20,055 B
sarkfultion
dreads
๐
ms-network.php
3,782 B
sarkfultion
dreads
๐
ms-settings.php
4,197 B
sarkfultion
dreads
๐
ms-site.php
41,729 B
sarkfultion
dreads
๐
nav-menu-template.php
25,983 B
sarkfultion
dreads
๐
nav-menu.php
44,269 B
sarkfultion
dreads
๐
option.php
105,246 B
sarkfultion
dreads
๐
pluggable-deprecated.php
6,324 B
sarkfultion
dreads
๐
pluggable.php
127,919 B
sarkfultion
dreads
๐
plugin.php
37,123 B
sarkfultion
dreads
๐
post-formats.php
7,070 B
sarkfultion
dreads
๐
post-template.php
69,129 B
sarkfultion
dreads
๐
post-thumbnail-template.php
10,879 B
sarkfultion
dreads
๐
post.php
305,589 B
sarkfultion
dreads
๐
query.php
37,554 B
sarkfultion
dreads
๐
registration-functions.php
200 B
sarkfultion
dreads
๐
registration.php
200 B
sarkfultion
dreads
๐
rest-api.php
103,142 B
sarkfultion
dreads
๐
revision.php
31,241 B
sarkfultion
dreads
๐
rewrite.php
19,567 B
sarkfultion
dreads
๐
robots-template.php
5,185 B
sarkfultion
dreads
๐
rss-functions.php
277 B
sarkfultion
dreads
๐
rss.php
23,203 B
sarkfultion
dreads
๐
script-loader.php
163,550 B
sarkfultion
dreads
๐
script-modules.php
12,311 B
sarkfultion
dreads
๐
session.php
258 B
sarkfultion
dreads
๐
shortcodes.php
24,870 B
sarkfultion
dreads
๐
sitemaps.php
3,238 B
sarkfultion
dreads
๐
speculative-loading.php
11,880 B
sarkfultion
dreads
๐
spl-autoload-compat.php
441 B
sarkfultion
dreads
๐
style-engine.php
8,045 B
sarkfultion
dreads
๐
taxonomy.php
178,307 B
sarkfultion
dreads
๐
template-canvas.php
544 B
sarkfultion
dreads
๐
template-loader.php
4,267 B
sarkfultion
dreads
๐
template.php
38,826 B
sarkfultion
dreads
๐
theme-i18n.json
1,892 B
sarkfultion
dreads
๐
theme-previews.php
2,887 B
sarkfultion
dreads
๐
theme-templates.php
4,060 B
sarkfultion
dreads
๐
theme.json
9,480 B
sarkfultion
dreads
๐
theme.php
134,913 B
sarkfultion
dreads
๐
update.php
38,269 B
sarkfultion
dreads
๐
user.php
180,301 B
sarkfultion
dreads
๐
utf8.php
6,977 B
sarkfultion
dreads
๐
vars.php
6,600 B
sarkfultion
dreads
๐
version.php
1,103 B
sarkfultion
dreads
๐
view-config.php
19,087 B
sarkfultion
dreads
๐
view-transitions.php
602 B
sarkfultion
dreads
๐
widgets.php
70,866 B
sarkfultion
dreads
๐
wp-db.php
445 B
sarkfultion
dreads
๐
wp-diff.php
792 B
sarkfultion
dreads
redisq: shortcodes.php
<?php /** * WordPress API for creating bbcode-like tags or what WordPress calls * "shortcodes". The tag and attribute parsing or regular expression code is * based on the Textpattern tag parser. * * A few examples are below: * * [shortcode /] * [shortcode foo="bar" baz="bing" /] * [shortcode foo="bar"]content[/shortcode] * * Shortcode tags support attributes and enclosed content, but does not entirely * support inline shortcodes in other shortcodes. You will have to call the * shortcode parser in your function to account for that. * * {@internal * Please be aware that the above note was made during the beta of WordPress 2.6 * and in the future may not be accurate. Please update the note when it is no * longer the case.}} * * To apply shortcode tags to content: * * $out = do_shortcode( $content ); * * @link https://developer.wordpress.org/plugins/shortcodes/ * * @package WordPress * @subpackage Shortcodes * @since 2.5.0 */ /** * Container for storing shortcode tags and their hook to call for the shortcode. * * @since 2.5.0 * * @name $shortcode_tags * @var array * @global array $shortcode_tags */ $shortcode_tags = array(); /** * Adds a new shortcode. * * Care should be taken through prefixing or other means to ensure that the * shortcode tag being added is unique and will not conflict with other, * already-added shortcode tags. In the event of a duplicated tag, the tag * loaded last will take precedence. * * @since 2.5.0 * * @global array $shortcode_tags * * @param string $tag Shortcode tag to be searched in post content. * @param callable $callback The callback function to run when the shortcode is found. * Every shortcode callback is passed three parameters by default, * including an array of attributes (`$atts`), the shortcode content * or null if not set (`$content`), and finally the shortcode tag * itself (`$shortcode_tag`), in that order. */ function add_shortcode( $tag, $callback ) { global $shortcode_tags; if ( '' === trim( $tag ) ) { _doing_it_wrong( __FUNCTION__, __( 'Invalid shortcode name: Empty name given.' ), '4.4.0' ); return; } if ( 0 !== preg_match( '@[<>&/\[\]\x00-\x20=]@', $tag ) ) { _doing_it_wrong( __FUNCTION__, sprintf( /* translators: 1: Shortcode name, 2: Space-separated list of reserved characters. */ __( 'Invalid shortcode name: %1$s. Do not use spaces or reserved characters: %2$s' ), $tag, '& / < > [ ] =' ), '4.4.0' ); return; } $shortcode_tags[ $tag ] = $callback; } /** * Removes hook for shortcode. * * @since 2.5.0 * * @global array $shortcode_tags * * @param string $tag Shortcode tag to remove hook for. */ function remove_shortcode( $tag ) { global $shortcode_tags; unset( $shortcode_tags[ $tag ] ); } /** * Clears all shortcodes. * * This function clears all of the shortcode tags by replacing the shortcodes global with * an empty array. This is actually an efficient method for removing all shortcodes. * * @since 2.5.0 * * @global array $shortcode_tags */ function remove_all_shortcodes() { global $shortcode_tags; $shortcode_tags = array(); } /** * Determines whether a registered shortcode exists named $tag. * * @since 3.6.0 * * @global array $shortcode_tags List of shortcode tags and their callback hooks. * * @param string $tag Shortcode tag to check. * @return bool Whether the given shortcode exists. */ function shortcode_exists( $tag ) { global $shortcode_tags; return array_key_exists( $tag, $shortcode_tags ); } /** * Determines whether the passed content contains the specified shortcode. * * @since 3.6.0 * * @global array $shortcode_tags * * @param string $content Content to search for shortcodes. * @param string $tag Shortcode tag to check. * @return bool Whether the passed content contains the given shortcode. */ function has_shortcode( $content, $tag ) { if ( ! str_contains( $content, '[' ) ) { return false; } if ( shortcode_exists( $tag ) ) { preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); if ( empty( $matches ) ) { return false; } foreach ( $matches as $shortcode ) { if ( $tag === $shortcode[2] ) { return true; } elseif ( ! empty( $shortcode[5] ) && has_shortcode( $shortcode[5], $tag ) ) { return true; } } } return false; } /** * Returns a list of registered shortcode names found in the given content. * * Example usage: * * get_shortcode_tags_in_content( '[audio src="file.mp3"][/audio] [foo] [gallery ids="1,2,3"]' ); * // array( 'audio', 'gallery' ) * * @since 6.3.2 * * @param string $content The content to check. * @return string[] An array of registered shortcode names found in the content. */ function get_shortcode_tags_in_content( $content ) { if ( ! str_contains( $content, '[' ) ) { return array(); } preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); if ( empty( $matches ) ) { return array(); } $tags = array(); foreach ( $matches as $shortcode ) { $tags[] = $shortcode[2]; if ( ! empty( $shortcode[5] ) ) { $deep_tags = get_shortcode_tags_in_content( $shortcode[5] ); if ( ! empty( $deep_tags ) ) { $tags = array_merge( $tags, $deep_tags ); } } } return $tags; } /** * Searches content for shortcodes and filter shortcodes through their hooks. * * This function is an alias for do_shortcode(). * * @since 5.4.0 * * @see do_shortcode() * * @param string $content Content to search for shortcodes. * @param bool $ignore_html When true, shortcodes inside HTML elements will be skipped. * Default false. * @return string Content with shortcodes filtered out. */ function apply_shortcodes( $content, $ignore_html = false ) { return do_shortcode( $content, $ignore_html ); } /** * Searches content for shortcodes and filter shortcodes through their hooks. * * If there are no shortcode tags defined, then the content will be returned * without any filtering. This might cause issues when plugins are disabled but * the shortcode will still show up in the post or content. * * @since 2.5.0 * * @global array $shortcode_tags List of shortcode tags and their callback hooks. * * @param string $content Content to search for shortcodes. * @param bool $ignore_html When true, shortcodes inside HTML elements will be skipped. * Default false. * @return string Content with shortcodes filtered out. */ function do_shortcode( $content, $ignore_html = false ) { global $shortcode_tags; if ( ! str_contains( $content, '[' ) ) { return $content; } if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { return $content; } // Find all registered tag names in $content. preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); $tagnames = array_intersect( array_keys( $shortcode_tags ), $matches[1] ); if ( empty( $tagnames ) ) { return $content; } // Ensure this context is only added once if shortcodes are nested. $has_filter = has_filter( 'wp_get_attachment_image_context', '_filter_do_shortcode_context' ); $filter_added = false; if ( ! $has_filter ) { $filter_added = add_filter( 'wp_get_attachment_image_context', '_filter_do_shortcode_context' ); } $content = do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ); $pattern = get_shortcode_regex( $tagnames ); $content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content ); // Always restore square braces so we don't break things like <!--[if IE ]>. $content = unescape_invalid_shortcodes( $content ); // Only remove the filter if it was added in this scope. if ( $filter_added ) { remove_filter( 'wp_get_attachment_image_context', '_filter_do_shortcode_context' ); } return $content; } /** * Filter the `wp_get_attachment_image_context` hook during shortcode rendering. * * When wp_get_attachment_image() is called during shortcode rendering, we need to make clear * that the context is a shortcode and not part of the theme's template rendering logic. * * @since 6.3.0 * @access private * * @return string The filtered context value for wp_get_attachment_images when doing shortcodes. */ function _filter_do_shortcode_context() { return 'do_shortcode'; } /** * Retrieves the shortcode regular expression for searching. * * The regular expression combines the shortcode tags in the regular expression * in a regex class. * * The regular expression contains 6 different sub matches to help with parsing. * * 1 - An extra [ to allow for escaping shortcodes with double [[]] * 2 - The shortcode name * 3 - The shortcode argument list * 4 - The self closing / * 5 - The content of a shortcode when it wraps some content. * 6 - An extra ] to allow for escaping shortcodes with double [[]] * * @since 2.5.0 * @since 4.4.0 Added the `$tagnames` parameter. * * @global array $shortcode_tags * * @param array $tagnames Optional. List of shortcodes to find. Defaults to all registered shortcodes. * @return string The shortcode search regular expression. */ function get_shortcode_regex( $tagnames = null ) { global $shortcode_tags; if ( empty( $tagnames ) ) { $tagnames = array_keys( $shortcode_tags ); } $tagregexp = implode( '|', array_map( 'preg_quote', $tagnames ) ); /* * WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag(). * Also, see shortcode_unautop() and shortcode.js. */ // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation return '\\[' // Opening bracket. . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]]. . "($tagregexp)" // 2: Shortcode name. . '(?![\\w-])' // Not followed by word character or hyphen. . '(' // 3: Unroll the loop: Inside the opening shortcode tag. . '[^\\]\\/]*' // Not a closing bracket or forward slash. . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket. . '[^\\]\\/]*' // Not a closing bracket or forward slash. . ')*?' . ')' . '(?:' . '(\\/)' // 4: Self closing tag... . '\\]' // ...and closing bracket. . '|' . '\\]' // Closing bracket. . '(?:' . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags. . '[^\\[]*+' // Not an opening bracket. . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag. . '[^\\[]*+' // Not an opening bracket. . ')*+' . ')' . '\\[\\/\\2\\]' // Closing shortcode tag. . ')?' . ')' . '(\\]?)'; // 6: Optional second closing bracket for escaping shortcodes: [[tag]]. // phpcs:enable } /** * Regular Expression callable for do_shortcode() for calling shortcode hook. * * @see get_shortcode_regex() for details of the match array contents. * * @since 2.5.0 * @access private * * @global array $shortcode_tags * * @param array $m { * Regular expression match array. * * @type string $0 Entire matched shortcode text. * @type string $1 Optional second opening bracket for escaping shortcodes. * @type string $2 Shortcode name. * @type string $3 Shortcode arguments list. * @type string $4 Optional self closing slash. * @type string $5 Content of a shortcode when it wraps some content. * @type string $6 Optional second closing bracket for escaping shortcodes. * } * @return string Shortcode output. */ function do_shortcode_tag( $m ) { global $shortcode_tags; // Allow [[foo]] syntax for escaping a tag. if ( '[' === $m[1] && ']' === $m[6] ) { return substr( $m[0], 1, -1 ); } $tag = $m[2]; $attr = shortcode_parse_atts( $m[3] ); if ( ! is_callable( $shortcode_tags[ $tag ] ) ) { _doing_it_wrong( __FUNCTION__, /* translators: %s: Shortcode tag. */ sprintf( __( 'Attempting to parse a shortcode without a valid callback: %s' ), $tag ), '4.3.0' ); return $m[0]; } /** * Filters whether to call a shortcode callback. * * Returning a non-false value from filter will short-circuit the * shortcode generation process, returning that value instead. * * @since 4.7.0 * @since 6.5.0 The `$attr` parameter is always an array. * * @param false|string $output Short-circuit return value. Either false or the value to replace the shortcode with. * @param string $tag Shortcode name. * @param array $attr Shortcode attributes array, can be empty if the original arguments string cannot be parsed. * @param array $m Regular expression match array. */ $return = apply_filters( 'pre_do_shortcode_tag', false, $tag, $attr, $m ); if ( false !== $return ) { return $return; } $content = $m[5] ?? null; $output = $m[1] . call_user_func( $shortcode_tags[ $tag ], $attr, $content, $tag ) . $m[6]; /** * Filters the output created by a shortcode callback. * * @since 4.7.0 * @since 6.5.0 The `$attr` parameter is always an array. * * @param string $output Shortcode output. * @param string $tag Shortcode name. * @param array $attr Shortcode attributes array, can be empty if the original arguments string cannot be parsed. * @param array $m Regular expression match array. */ return apply_filters( 'do_shortcode_tag', $output, $tag, $attr, $m ); } /** * Searches only inside HTML elements for shortcodes and process them. * * Any [ or ] characters remaining inside elements will be HTML encoded * to prevent interference with shortcodes that are outside the elements. * Assumes $content processed by KSES already. Users with unfiltered_html * capability may get unexpected output if angle braces are nested in tags. * * @since 4.2.3 * * @param string $content Content to search for shortcodes. * @param bool $ignore_html When true, all square braces inside elements will be encoded. * @param array $tagnames List of shortcodes to find. * @return string Content with shortcodes filtered out. */ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { // Normalize entities in unfiltered HTML before adding placeholders. $trans = array( '[' => '[', ']' => ']', ); $content = strtr( $content, $trans ); $trans = array( '[' => '[', ']' => ']', ); $pattern = get_shortcode_regex( $tagnames ); $textarr = wp_html_split( $content ); foreach ( $textarr as &$element ) { if ( '' === $element || '<' !== $element[0] ) { continue; } $noopen = ! str_contains( $element, '[' ); $noclose = ! str_contains( $element, ']' ); if ( $noopen || $noclose ) { // This element does not contain shortcodes. if ( $noopen xor $noclose ) { // Need to encode stray '[' or ']' chars. $element = strtr( $element, $trans ); } continue; } if ( $ignore_html || str_starts_with( $element, '<!--' ) || str_starts_with( $element, '<![CDATA[' ) ) { // Encode all '[' and ']' chars. $element = strtr( $element, $trans ); continue; } $attributes = wp_kses_attr_parse( $element ); if ( false === $attributes ) { // Some plugins are doing things like [name] <[email]>. if ( 1 === preg_match( '%^<\s*\[\[?[^\[\]]+\]%', $element ) ) { $element = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $element ); } // Looks like we found some unexpected unfiltered HTML. Skipping it for confidence. $element = strtr( $element, $trans ); continue; } // Get element name. $front = array_shift( $attributes ); $back = array_pop( $attributes ); $matches = array(); preg_match( '%[a-zA-Z0-9]+%', $front, $matches ); $elname = $matches[0]; // Look for shortcodes in each attribute separately. foreach ( $attributes as &$attr ) { $open = strpos( $attr, '[' ); $close = strpos( $attr, ']' ); if ( false === $open || false === $close ) { continue; // Go to next attribute. Square braces will be escaped at end of loop. } $double = strpos( $attr, '"' ); $single = strpos( $attr, "'" ); if ( ( false === $single || $open < $single ) && ( false === $double || $open < $double ) ) { /* * $attr like '[shortcode]' or 'name = [shortcode]' implies unfiltered_html. * In this specific situation we assume KSES did not run because the input * was written by an administrator, so we should avoid changing the output * and we do not need to run KSES here. */ $attr = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $attr ); } else { /* * $attr like 'name = "[shortcode]"' or "name = '[shortcode]'". * We do not know if $content was unfiltered. Assume KSES ran before shortcodes. */ $count = 0; $new_attr = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $attr, -1, $count ); if ( $count > 0 ) { // Sanitize the shortcode output using KSES. $new_attr = wp_kses_one_attr( $new_attr, $elname ); if ( '' !== trim( $new_attr ) ) { // The shortcode is safe to use now. $attr = $new_attr; } } } } $element = $front . implode( '', $attributes ) . $back; // Now encode any remaining '[' or ']' chars. $element = strtr( $element, $trans ); } $content = implode( '', $textarr ); return $content; } /** * Removes placeholders added by do_shortcodes_in_html_tags(). * * @since 4.2.3 * * @param string $content Content to search for placeholders. * @return string Content with placeholders removed. */ function unescape_invalid_shortcodes( $content ) { // Clean up entire string, avoids re-parsing HTML. $trans = array( '[' => '[', ']' => ']', ); $content = strtr( $content, $trans ); return $content; } /** * Retrieves the shortcode attributes regex. * * @since 4.4.0 * * @return string The shortcode attribute regular expression. */ function get_shortcode_atts_regex() { return '/([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*\'([^\']*)\'(?:\s|$)|([\w-]+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|\'([^\']*)\'(?:\s|$)|(\S+)(?:\s|$)/'; } /** * Retrieves all attributes from the shortcodes tag. * * The attributes list has the attribute name as the key and the value of the * attribute as the value in the key/value pair. This allows for easier * retrieval of the attributes, since all attributes have to be known. * * @since 2.5.0 * @since 6.5.0 The function now always returns an array, * even if the original arguments string cannot be parsed or is empty. * @since 7.1.5 A hex or octal escape that decodes to <, >, " or ' produces a character reference. * * @param string $text Shortcode arguments list. * @return array Array of attribute values keyed by attribute name. * Returns empty array if there are no attributes * or if the original arguments string cannot be parsed. */ function shortcode_parse_atts( $text ) { // Decodes like stripcslashes(), except that a hex or octal escape that decodes // to `<`, `>`, `"` or `'` produces `<`, `>`, `"` or `'`. $decode = static function ( $value ) { if ( ! str_contains( $value, '\\' ) ) { return $value; } return preg_replace_callback( '/\\\\(?:x[0-9A-Fa-f]{1,2}|[0-7]{1,3}|.)/s', static function ( $matches ) { $decoded = stripcslashes( $matches[0] ); // A two-byte escape cannot decode to a structural character that the raw value lacks. if ( 2 === strlen( $matches[0] ) ) { return $decoded; } $structural = array( '<' => '<', '>' => '>', '"' => '"', "'" => ''', ); return $structural[ $decoded ] ?? $decoded; }, $value ); }; $atts = array(); $pattern = get_shortcode_atts_regex(); $text = preg_replace( "/[\x{00a0}\x{200b}]+/u", ' ', $text ); if ( preg_match_all( $pattern, $text, $match, PREG_SET_ORDER ) ) { foreach ( $match as $m ) { if ( ! empty( $m[1] ) ) { $atts[ strtolower( $m[1] ) ] = $decode( $m[2] ); } elseif ( ! empty( $m[3] ) ) { $atts[ strtolower( $m[3] ) ] = $decode( $m[4] ); } elseif ( ! empty( $m[5] ) ) { $atts[ strtolower( $m[5] ) ] = $decode( $m[6] ); } elseif ( isset( $m[7] ) && strlen( $m[7] ) ) { $atts[] = $decode( $m[7] ); } elseif ( isset( $m[8] ) && strlen( $m[8] ) ) { $atts[] = $decode( $m[8] ); } elseif ( isset( $m[9] ) ) { $atts[] = $decode( $m[9] ); } } // Reject any unclosed HTML elements. foreach ( $atts as &$value ) { if ( str_contains( $value, '<' ) ) { if ( 1 !== preg_match( '/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value ) ) { $value = ''; } } } } return $atts; } /** * Combines user attributes with known attributes and fill in defaults when needed. * * The pairs should be considered to be all of the attributes which are * supported by the caller and given as a list. The returned attributes will * only contain the attributes in the $pairs list. * * If the $atts list has unsupported attributes, then they will be ignored and * removed from the final returned list. * * @since 2.5.0 * * @param array $pairs Entire list of supported attributes and their defaults. * @param array $atts User defined attributes in shortcode tag. * @param string $shortcode Optional. The name of the shortcode, provided for context to enable filtering * @return array Combined and filtered attribute list. */ function shortcode_atts( $pairs, $atts, $shortcode = '' ) { $atts = (array) $atts; $out = array(); foreach ( $pairs as $name => $default ) { if ( array_key_exists( $name, $atts ) ) { $out[ $name ] = $atts[ $name ]; } else { $out[ $name ] = $default; } } if ( $shortcode ) { /** * Filters shortcode attributes. * * If the third parameter of the shortcode_atts() function is present then this filter is available. * The third parameter, $shortcode, is the name of the shortcode. * * @since 3.6.0 * @since 4.4.0 Added the `$shortcode` parameter. * * @param array $out The output array of shortcode attributes. * @param array $pairs The supported attributes and their defaults. * @param array $atts The user defined shortcode attributes. * @param string $shortcode The shortcode name. */ $out = apply_filters( "shortcode_atts_{$shortcode}", $out, $pairs, $atts, $shortcode ); } return $out; } /** * Removes all shortcode tags from the given content. * * @since 2.5.0 * * @global array $shortcode_tags * * @param string $content Content to remove shortcode tags. * @return string Content without shortcode tags. */ function strip_shortcodes( $content ) { global $shortcode_tags; if ( ! str_contains( $content, '[' ) ) { return $content; } if ( empty( $shortcode_tags ) || ! is_array( $shortcode_tags ) ) { return $content; } // Find all registered tag names in $content. preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches ); $tags_to_remove = array_keys( $shortcode_tags ); /** * Filters the list of shortcode tags to remove from the content. * * @since 4.7.0 * * @param array $tags_to_remove Array of shortcode tags to remove. * @param string $content Content shortcodes are being removed from. */ $tags_to_remove = apply_filters( 'strip_shortcodes_tagnames', $tags_to_remove, $content ); $tagnames = array_intersect( $tags_to_remove, $matches[1] ); if ( empty( $tagnames ) ) { return $content; } $content = do_shortcodes_in_html_tags( $content, true, $tagnames ); $pattern = get_shortcode_regex( $tagnames ); $content = preg_replace_callback( "/$pattern/", 'strip_shortcode_tag', $content ); // Always restore square braces so we don't break things like <!--[if IE ]>. $content = unescape_invalid_shortcodes( $content ); return $content; } /** * Strips a shortcode tag based on RegEx matches against post content. * * @since 3.3.0 * * @param array $m RegEx matches against post content. * @return string|false The content stripped of the tag, otherwise false. */ function strip_shortcode_tag( $m ) { // Allow [[foo]] syntax for escaping a tag. if ( '[' === $m[1] && ']' === $m[6] ) { return substr( $m[0], 1, -1 ); } return $m[1] . $m[6]; }
sarkfultion