-
Notifications
You must be signed in to change notification settings - Fork 28
/
helpers.php
62 lines (51 loc) · 1.48 KB
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php if (!defined('FW')) die('Forbidden');
/**
* @param array $attributes Encoded attributes
* @param $shortcode_tag 'button', 'section', etc.
* @param $post_id
* @return array|WP_Error
* @since 1.3.0
*/
function fw_ext_shortcodes_decode_attr(array $attributes, $shortcode_tag, $post_id) {
/**
* @var FW_Extension_Shortcodes $shortcodes_ext
*/
$shortcodes_ext = fw_ext('shortcodes');
foreach ($shortcodes_ext->get_attr_coder() as $coder) {
if ($coder->can_decode($attributes, $shortcode_tag, $post_id)) {
return $coder->decode($attributes, $shortcode_tag, $post_id);
}
}
return $attributes;
}
/**
* Parse string, extract shortcodes and enqueue their static files
* @param string $content 'Hello [shortcode1 attr1="..."] World'
* @since 1.3.17
*/
function fw_ext_shortcodes_enqueue_shortcodes_static($content) {
/**
* @var FW_Extension_Shortcodes $shortcodes_ext
*/
$shortcodes_ext = fw_ext('shortcodes');
$shortcodes_ext->enqueue_shortcodes_static($content);
}
/**
* Enqueue admin scripts for each shortcode
* @since 1.3.18
*/
function fw_ext_shortcodes_enqueue_shortcodes_admin_scripts() {
static $has_run = false;
if ($has_run) {
return;
}
$has_run = true;
/**
* @var FW_Extension_Shortcodes $shortcodes_ext
*/
$shortcodes_ext = fw_ext('shortcodes');
foreach ($shortcodes_ext->get_shortcodes() as $shortcode) {
fw()->backend->enqueue_options_static($shortcode->get_options());
}
do_action('fw:ext:shortcodes:enqueue-shortcodes-admin-scripts');
}