PluginProbe
Snippet Shortcodes / 1.7
Snippet Shortcodes v1.7
5.2.1 5.2 5.1.8 5.1.6 5.1.7 5.1.5 trunk 1.0 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 2.0 2.0.1 All 74 releases
shortcode-variables / includes / shortcode.php

shortcode.php in Snippet Shortcodes 1.7, at includes/shortcode.php

80 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') or die('Jog on!');
4
5 function sh_cd_shortcode( $atts )
6 {
7 $user_defined_parameters = false;
8
9 $default_arguments = array(
10 'slug' => false,
11 'format' => false,
12 'redirect' => false
13 );
14
15 $shortcode_args = shortcode_atts( $default_arguments, $atts );
16
17 // User defined parameters
18 $user_defined_parameters = sh_cd_get_user_defined_arguments($default_arguments, $atts);
19
20 return sh_cd_render_shortcode_from_db($shortcode_args, $user_defined_parameters);
21
22 }
23 add_shortcode( SH_CD_SHORTCODE, 'sh_cd_shortcode' );
24 add_shortcode( SH_CD_SHORTCODE_SMALL, 'sh_cd_shortcode' );
25
26 function sh_cd_render_shortcode_from_db($shortcode_args, $user_defined_parameters = false)
27 {
28 $slug = $shortcode_args['slug'];
29
30 if ($slug != false && !empty($slug))
31 {
32 // Check if a shortcode preset
33 if (sh_cd_is_shortcode_preset($slug)) {
34 return sh_cd_render_shortcode_presets($shortcode_args);
35 }
36 else
37 {
38 $cached_shortcode = sh_cd_get_cache($slug);
39
40 if ($cached_shortcode != false)
41 {
42 // Process other shortcodes
43 $cached_shortcode = do_shortcode($cached_shortcode);
44
45 // No shortcode found or disabled? Then return nothing.
46 if(!$cached_shortcode) {
47 return '';
48 }
49
50 // Replace placeholders with user defined parameters
51 $cached_shortcode = sh_cd_apply_user_defined_parameters($cached_shortcode, $user_defined_parameters);
52
53 return $cached_shortcode;
54 }
55 else
56 {
57 $shortcode = sh_cd_get_shortcode_by_slug($slug);
58
59 if ($shortcode)
60 {
61 sh_cd_set_cache($slug, $shortcode);
62
63 // No shortcode found or disabled? Then return nothing.
64 if(!$cached_shortcode) {
65 return '';
66 }
67
68 // Process other shortcodes
69 $shortcode = do_shortcode($shortcode);
70
71 // Replace placeholders with user defined parameters
72 $shortcode = sh_cd_apply_user_defined_parameters($shortcode, $user_defined_parameters);
73
74 return $shortcode;
75 }
76 }
77 }
78 }
79 }
80