PluginProbe
Snippet Shortcodes / 4.0
Snippet Shortcodes v4.0
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
← All changes | includes/shortcode.presets.premium.php +395 -273 2.04.0 View file →
@@ -1,273 +1,395 @@
1 -<?php
2 -
3 -defined('ABSPATH') or die("Jog on!");
4 -
5 -/**
6 - * Return a list of slugs / titles for free presets
7 - * @return array
8 - */
9 -function sh_cd_shortcode_presets_premium_list() {
10 -
11 - return [
12 - 'sc-site-language' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'Language code for the current site', 'args' => [ '_sh_cd_func' => 'language' ], 'premium' => true ],
13 - 'sc-site-description' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'Site tagline (set in Settings > General)', 'args' => [ '_sh_cd_func' => 'description' ], 'premium' => true ],
14 - 'sc-site-wp-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The WordPress address (URL) (set in Settings > General)', 'args' => [ '_sh_cd_func' => 'wpurl' ], 'premium' => true ],
15 - 'sc-site-charset' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The "Encoding for pages and feeds" (set in Settings > Reading)', 'args' => [ '_sh_cd_func' => 'charset' ], 'premium' => true ],
16 - 'sc-site-wp-version' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The current WordPress version', 'args' => [ '_sh_cd_func' => 'version' ], 'premium' => true ],
17 - 'sc-site-html-type' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The content-type (default: "text/html"). Themes and plugins', 'args' => [ '_sh_cd_func' => 'html_type' ], 'premium' => true ],
18 - 'sc-site-stylesheet-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'URL to the stylesheet for the active theme.', 'args' => [ '_sh_cd_func' => 'stylesheet_url' ], 'premium' => true ],
19 - 'sc-site-stylesheet_directory' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'Directory path for the active theme.', 'args' => [ '_sh_cd_func' => 'stylesheet_directory' ], 'premium' => true ],
20 - 'sc-site-template-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The URL of the active theme\'s directory.', 'args' => [ '_sh_cd_func' => 'template_url' ], 'premium' => true],
21 - 'sc-site-pingback-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The pingback XML-RPC file URL (xmlrpc.php)', 'args' => [ '_sh_cd_func' => 'pingback_url' ], 'premium' => true ],
22 - 'sc-site-atom-feed' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The Atom feed URL (/feed/atom)', 'args' => [ '_sh_cd_func' => 'atom_url' ], 'premium' => true ],
23 - 'sc-site-rdf-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The RDF/RSS 1.0 feed URL (/feed/rfd)', 'args' => [ '_sh_cd_func' => 'rdf_url' ], 'premium' => true ],
24 - 'sc-site-rss-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The RSS 0.92 feed URL (/feed/rss)', 'args' => [ '_sh_cd_func' => 'rss_url' ], 'premium' => true ],
25 - 'sc-site-rss2-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The RSS 2.0 feed URL (/feed)', 'args' => [ '_sh_cd_func' => 'rss2_url' ], 'premium' => true ],
26 - 'sc-site-comments-atom-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The comments Atom feed URL (/comments/feed)', 'args' => [ '_sh_cd_func' => 'comments_atom_url' ], 'premium' => true ],
27 - 'sc-site-comments-rss2-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => 'The comments RSS 2.0 feed URL (/comments/feed)', 'args' => [ '_sh_cd_func' => 'comments_rss2_url' ], 'premium' => true ],
28 - 'sc-php-server-info' => [ 'class' => 'SC_SERVER_INFO', 'description' => 'Display data from the PHP $_SERVER global e.g. [sv slug="sc-server-info" field="SERVER_SOFTWARE"]. <a href="http://php.net/manual/en/reserved.variables.server.php" rel="noopener" target="_blank">Allowed values for field attribute</a>.', 'premium' => true ],
29 - 'sc-php-unique-id' => [ 'class' => 'SC_UNIQUE_ID', 'description' => 'Generate a unique ID. Based upon <a href="http://php.net/manual/en/function.uniqid.php" rel="noopener" target="_blank">uniqid()</a>. If you wish the unique ID to be prefixed, add a the prefix attribute e.g. [sv slug="sc-php-unique-id" prefix="yeken"]', 'premium' => true ],
30 - 'sc-php-timestamp' => [ 'class' => 'SC_TIMESTAMP', 'description' => 'Display the current unix timestamp. Based upon <a href="http://php.net/manual/en/function.time.php" rel="noopener" target="_blank">time()</a>.', 'premium' => true ],
31 - 'sc-php-random-number' => [ 'class' => 'SC_RAND_NUMBER', 'description' => 'Display a random number. Based upon <a href="http://php.net/manual/en/function.rand.php" rel="noopener" target="_blank">rand()</a>. It also supports the optional arguments of min and max e.g. [sv slug="sc-php-random-number" min="5" max="20" ]', 'premium' => true ],
32 - 'sc-php-random-string' => [ 'class' => 'SC_RAND_STRING', 'description' => 'Display a random string of characters. It also supports the optional argument of "length". This specifies the number of characters you wish to display (default is 10) [sv slug="sc-php-random-string" length="15"]', 'premium' => true ],
33 - 'sc-php-post-value' => [ 'class' => 'SC_POST_VALUE', 'description' => 'Display a value from the $_POST array. The "key" arguments specifies which array value to render. It also supports the optional arguments of "default". If there is no value in the array for the given "key" then the "default" will be displayed. [sv slug="sc-php-post-value" key="username" default="Not Found"]', 'premium' => true ],
34 - 'sc-php-get-value' => [ 'class' => 'SC_GET_VALUE', 'description' => 'Display a value from the $_GET array. The "key" arguments specifies which array value to render. It also supports the optional arguments of "default". If there is no value in the array for the given "key" then the "default" will be displayed. [sv slug="sc-php-get-value" key="username" default="Not Found"]', 'premium' => true ],
35 - 'sc-php-info' => [ 'class' => 'SC_PHP_INFO', 'description' => 'Display PHP Info', 'premium' => true ],
36 - 'sc-post-id' => [ 'class' => 'SC_POST_ID', 'description' => 'Display ID for the current post.', 'premium' => true ],
37 - 'sc-post-author' => [ 'class' => 'SC_POST_AUTHOR', 'description' => 'Display the author\'s display name or ID. The optional argument "field" allows you to specify whether you wish to display the author\'s "display-name" or "id". [sv slug="sc-post-author" field="id" ]', 'premium' => true ],
38 - 'sc-post-counts' => [ 'class' => 'SC_POST_COUNTS', 'description' => 'Display a count of posts for certain statuses. Using the argument status, specify whether to return a count for all posts that have a status of "publish" (default), "future", "draft", "pending" or "private". [sv slug="sc-post-counts" status="draft"]', 'premium' => true ]
39 -
40 - // '' => [ 'class' => '', 'description' => '', 'premium' => true ]
41 - ];
42 -}
43 -
44 -
45 -/**
46 - * Get data from get_bloginfo()
47 - *
48 - * Class SV_SC_SITE_TITLE
49 - */
50 -class SV_SC_BLOG_INFO extends SV_Preset {
51 -
52 - protected function unsanitised() {
53 -
54 - $args = $this->get_arguments();
55 -
56 - $key = ( false === empty( $args['_sh_cd_func'] ) ) ? $args['_sh_cd_func'] : 'name';
57 -
58 - return get_bloginfo( $key );
59 - }
60 -}
61 -
62 -/**
63 - * Get data from $_SERVER
64 - *
65 - * Class SV_SC_SERVER_INFO
66 - */
67 -class SV_SC_SERVER_INFO extends SV_Preset {
68 -
69 - protected function unsanitised() {
70 -
71 - $args = $this->get_arguments();
72 -
73 - return ( false === empty( $_SERVER[ $args['field'] ] ) ) ? $_SERVER[ $args['field'] ] : '';
74 - }
75 -}
76 -
77 -/**
78 - * Get a unique ID
79 - *
80 - * Class SV_SC_UNIQUE_ID
81 - */
82 -class SV_SC_UNIQUE_ID extends SV_Preset {
83 -
84 - protected function unsanitised() {
85 -
86 - $args = $this->get_arguments();
87 -
88 - $prefix = ( false === empty( $args['prefix'] ) ) ? $args['prefix'] : '';
89 -
90 - return uniqid ( $prefix, true );
91 - }
92 -}
93 -
94 -/**
95 - * Get timestamp
96 - *
97 - * Class SV_SC_TIMESTAMP
98 - */
99 -class SV_SC_TIMESTAMP extends SV_Preset {
100 -
101 - protected function unsanitised() {
102 - return time();
103 - }
104 -}
105 -
106 -/**
107 - * Display PHP INFO
108 - *
109 - * Class SV_SC_PHP_INFO
110 - */
111 -class SV_SC_PHP_INFO extends SV_Preset {
112 -
113 - protected function unsanitised() {
114 - return phpinfo();
115 - }
116 -}
117 -
118 -/**
119 - * Random number
120 - *
121 - * Class SV_SC_RAND_NUMBER
122 - */
123 -class SV_SC_RAND_NUMBER extends SV_Preset {
124 -
125 - protected function unsanitised() {
126 -
127 - $args = $this->get_arguments();
128 -
129 - $min = ( false === empty( $args['min'] ) ) ? (int) $args['min'] : 0;
130 -
131 - $max = ( false === empty( $args['max'] ) ) ? (int) $args['max'] : getrandmax();
132 -
133 - return rand( $min, $max );
134 - }
135 -}
136 -
137 -/**
138 - * Random string
139 - *
140 - * Based upon: https://stackoverflow.com/questions/4356289/php-random-string-generator
141 - *
142 - * Class SV_SC_RAND_STRING
143 - */
144 -class SV_SC_RAND_STRING extends SV_Preset {
145 -
146 - protected function unsanitised() {
147 -
148 - $args = $this->get_arguments();
149 -
150 - $length = ( false === empty( $args['length'] ) ) ? (int) $args['length'] : 10;
151 -
152 - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
153 - $no_characters = strlen( $characters );
154 - $random_string = '';
155 -
156 - for ($i = 0; $i < $length; $i++) {
157 - $random_string .= $characters[ rand( 0, $no_characters - 1 ) ];
158 - }
159 -
160 - return $random_string;
161 - }
162 -}
163 -
164 -/**
165 - * Fetch an item from the $_POST array
166 - *
167 - * Class SV_SC_POST_VALUE
168 - */
169 -class SV_SC_POST_VALUE extends SV_Preset {
170 -
171 - protected function unsanitised() {
172 -
173 - $args = $this->get_arguments();
174 -
175 - $post_value = ( false === empty( $_POST[ $args['key'] ] ) ) ? $_POST[ $args['key'] ] : NULL;
176 -
177 - if ( null !== $post_value ) {
178 - return $post_value;
179 - }
180 -
181 - // Do we have a fall back default?
182 - return ( false === empty( $args['default'] ) ) ? $args['default'] : '';
183 -
184 - }
185 -}
186 -
187 -/**
188 - * Fetch an item from the $_GET array
189 - *
190 - * Class SV_SC_GET_VALUE
191 - */
192 -class SV_SC_GET_VALUE extends SV_Preset {
193 -
194 - protected function unsanitised() {
195 -
196 - $args = $this->get_arguments();
197 -
198 - $post_value = ( false === empty( $_GET[ $args['key'] ] ) ) ? $_GET[ $args['key'] ] : NULL;
199 -
200 - if ( null !== $post_value ) {
201 - return $post_value;
202 - }
203 -
204 - // Do we have a fall back default?
205 - return ( false === empty( $args['default'] ) ) ? $args['default'] : '';
206 -
207 - }
208 -}
209 -
210 -/**
211 - * Display current Post ID
212 - *
213 - * Class SV_SC_POST_ID
214 - */
215 -class SV_SC_POST_ID extends SV_Preset {
216 -
217 - protected function unsanitised() {
218 - return get_the_ID();
219 - }
220 -}
221 -
222 -/**
223 - * Display author of current post
224 - *
225 - * Class SV_SC_POST_AUTHOR
226 - */
227 -class SV_SC_POST_AUTHOR extends SV_Preset {
228 -
229 - protected function unsanitised() {
230 -
231 - $args = $this->get_arguments();
232 -
233 - switch ( $args['field'] ) {
234 - case 'id':
235 - return get_the_author_meta( 'ID' );
236 - break;
237 - default:
238 - return get_the_author();
239 - }
240 - }
241 -}
242 -
243 -/**
244 - * Display post counts
245 - *
246 - * Class SV_SC_POST_COUNTS
247 - */
248 -class SV_SC_POST_COUNTS extends SV_Preset {
249 -
250 - protected function unsanitised() {
251 -
252 - $args = $this->get_arguments();
253 -
254 - $counts = wp_count_posts();
255 -
256 - switch ( $args['status'] ) {
257 - case 'future':
258 - return $counts->future;
259 - break;
260 - case 'draft':
261 - return $counts->draft;
262 - break;
263 - case 'pending':
264 - return $counts->pending;
265 - break;
266 - case 'private':
267 - return $counts->private;
268 - break;
269 - default:
270 - return $counts->publish;
271 - }
272 - }
273 -}
1 +<?php
2 +
3 +defined('ABSPATH') or die("Jog on!");
4 +
5 +/**
6 + * Return a list of slugs / titles for free presets
7 + * @return array
8 + */
9 +function sh_cd_shortcode_presets_premium_list() {
10 +
11 + return [
12 + 'sc-date' => [ 'class' => 'SC_DATE', 'description' => __( 'A shortcode that displays today\'s date with the ability to add or subtract days, months and years. To specify an interval to add or subtract onto the date use the parameter "interval" e.g. [sv slug="sc-date" interval="-1 year"], [sv slug="sc-date" interval="+5 days"], [sv slug="sc-date" interval="+3 months"]. Intervals are based upon PHP intervals and are outlined here <a href="https://www.php.net/manual/en/dateinterval.createfromdatestring.php" target="_blank">https://www.php.net/manual/en/dateinterval.createfromdatestring.php</a>. Default is UK format (DD/MM/YYYY). Format can be changed by adding the parameter format="m/d/Y" onto the shortcode. Format syntax is based upon PHP date: <a href="http://php.net/manual/en/function.date.php" target="_blank">http://php.net/manual/en/function.date.php</a>', SH_CD_SLUG ), 'premium' => true ],
13 + 'sc-site-language' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'Language code for the current site', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'language' ], 'premium' => true ],
14 + 'sc-site-description' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'Site tagline (set in Settings > General)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'description' ], 'premium' => true ],
15 + 'sc-site-wp-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The WordPress address (URL) (set in Settings > General)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'wpurl' ], 'premium' => true ],
16 + 'sc-site-charset' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The "Encoding for pages and feeds" (set in Settings > Reading)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'charset' ], 'premium' => true ],
17 + 'sc-site-wp-version' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The current WordPress version', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'version' ], 'premium' => true ],
18 + 'sc-site-html-type' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The content-type (default: "text/html"). Themes and plugins', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'html_type' ], 'premium' => true ],
19 + 'sc-site-stylesheet-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'URL to the stylesheet for the active theme.', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'stylesheet_url' ], 'premium' => true ],
20 + 'sc-site-stylesheet_directory' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'Directory path for the active theme.', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'stylesheet_directory' ], 'premium' => true ],
21 + 'sc-site-current-url' => [ 'class' => 'SC_CURRENT_URL', 'description' => __( 'Get the current URL.', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'current_url' ], 'premium' => true],
22 + 'sc-site-register-url' => [ 'class' => 'SC_REGISTER_URL', 'description' => __( 'Get the URL to the WordPress registration page.', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'registration_url' ], 'premium' => true],
23 + 'sc-site-template-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The URL of the active theme\'s directory.', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'template_url' ], 'premium' => true],
24 + 'sc-site-pingback-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The pingback XML-RPC file URL (xmlrpc.php)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'pingback_url' ], 'premium' => true ],
25 + 'sc-site-atom-feed' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The Atom feed URL (/feed/atom)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'atom_url' ], 'premium' => true ],
26 + 'sc-site-rdf-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The RDF/RSS 1.0 feed URL (/feed/rfd)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'rdf_url' ], 'premium' => true ],
27 + 'sc-site-rss-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The RSS 0.92 feed URL (/feed/rss)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'rss_url' ], 'premium' => true ],
28 + 'sc-site-rss2-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The RSS 2.0 feed URL (/feed)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'rss2_url' ], 'premium' => true ],
29 + 'sc-site-comments-atom-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The comments Atom feed URL (/comments/feed)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'comments_atom_url' ], 'premium' => true ],
30 + 'sc-site-comments-rss2-url' => [ 'class' => 'SC_BLOG_INFO', 'description' => __( 'The comments RSS 2.0 feed URL (/comments/feed)', SH_CD_SLUG ), 'args' => [ '_sh_cd_func' => 'comments_rss2_url' ], 'premium' => true ],
31 + 'sc-php-server-info' => [ 'class' => 'SC_SERVER_INFO', 'description' => __( 'Display data from the PHP $_SERVER global e.g. [sv slug="sc-server-info" field="SERVER_SOFTWARE"]. <a href="http://php.net/manual/en/reserved.variables.server.php" rel="noopener" target="_blank">Allowed values for field attribute</a>.', SH_CD_SLUG ), 'premium' => true ],
32 + 'sc-php-unique-id' => [ 'class' => 'SC_UNIQUE_ID', 'description' => __( 'Generate a unique ID. Based upon <a href="http://php.net/manual/en/function.uniqid.php" rel="noopener" target="_blank">uniqid()</a>. If you wish the unique ID to be prefixed, add a the prefix attribute e.g. [sv slug="sc-php-unique-id" prefix="yeken"]', SH_CD_SLUG ), 'premium' => true ],
33 + 'sc-php-timestamp' => [ 'class' => 'SC_TIMESTAMP', 'description' => __( 'Display the current unix timestamp. Based upon <a href="http://php.net/manual/en/function.time.php" rel="noopener" target="_blank">time()</a>.', SH_CD_SLUG ), 'premium' => true ],
34 + 'sc-php-random-number' => [ 'class' => 'SC_RAND_NUMBER', 'description' => __( 'Display a random number. Based upon <a href="http://php.net/manual/en/function.rand.php" rel="noopener" target="_blank">rand()</a>. It also supports the optional arguments of min and max e.g. [sv slug="sc-php-random-number" min="5" max="20" ]', SH_CD_SLUG ), 'premium' => true ],
35 + 'sc-php-random-string' => [ 'class' => 'SC_RAND_STRING', 'description' => __( 'Display a random string of characters. It also supports the optional argument of "length". This specifies the number of characters you wish to display (default is 10) [sv slug="sc-php-random-string" length="15"]', SH_CD_SLUG ), 'premium' => true ],
36 + 'sc-php-post-value' => [ 'class' => 'SC_POST_VALUE', 'description' => __( 'Display a value from the $_POST array. The "key" arguments specifies which array value to render. It also supports the optional arguments of "default". If there is no value in the array for the given "key" then the "default" will be displayed. [sv slug="sc-php-post-value" key="username" default="Not Found"]', SH_CD_SLUG ), 'premium' => true ],
37 + 'sc-php-get-value' => [ 'class' => 'SC_GET_VALUE', 'description' => __( 'Display a value from the $_GET array. The "key" arguments specifies which array value to render. It also supports the optional arguments of "default". If there is no value in the array for the given "key" then the "default" will be displayed. [sv slug="sc-php-get-value" key="username" default="Not Found"]', SH_CD_SLUG ), 'premium' => true ],
38 + 'sc-php-info' => [ 'class' => 'SC_PHP_INFO', 'description' => __( 'Display PHP Info', SH_CD_SLUG ), 'premium' => true ],
39 + 'sc-post-id' => [ 'class' => 'SC_POST_ID', 'description' => __( 'Display ID for the current post.', SH_CD_SLUG ), 'premium' => true ],
40 + 'sc-post-author' => [ 'class' => 'SC_POST_AUTHOR', 'description' => __( 'Display the author\'s display name or ID. The optional argument "field" allows you to specify whether you wish to display the author\'s "display-name" or "id". [sv slug="sc-post-author" field="id" ]', SH_CD_SLUG ), 'premium' => true ],
41 + 'sc-post-counts' => [ 'class' => 'SC_POST_COUNTS', 'description' => __( 'Display a count of posts for certain statuses. Using the argument status, specify whether to return a count for all posts that have a status of "publish" (default), "future", "draft", "pending" or "private". [sv slug="sc-post-counts" status="draft"]', SH_CD_SLUG ), 'premium' => true ],
42 + 'sc-user-counts' => [ 'class' => 'SC_USER_COUNTS', 'description' => __( 'Display a count of all WordPress users or the number of WordPress users for a given role e.g. [sv slug="sc-user-counts" role="subscriber"] or [sv slug="sc-user-counts"]', SH_CD_SLUG ), 'premium' => true ],
43 + 'sc-user-profile-photo' => [ 'class' => 'SC_AVATAR', 'description' => __( 'Display the WordPress profile photo for the logged in user e.g. [sv slug="sc-user-profile-photo" width="150"] or [sv slug="sc-user-profile-photo"]. Please note, width defaults to 96px.', SH_CD_SLUG ), 'premium' => true ]
44 +
45 + // '' => [ 'class' => '', 'description' => '', 'premium' => true ]
46 + ];
47 +}
48 +
49 +
50 +/**
51 + * Get data from get_bloginfo()
52 + *
53 + * Class SV_SC_SITE_TITLE
54 + */
55 +class SV_SC_BLOG_INFO extends SV_Preset {
56 +
57 + protected function unsanitised() {
58 +
59 + $args = $this->get_arguments();
60 +
61 + $key = ( false === empty( $args['_sh_cd_func'] ) ) ? $args['_sh_cd_func'] : 'name';
62 +
63 + return get_bloginfo( $key );
64 + }
65 +}
66 +
67 +/**
68 + * Get data from $_SERVER
69 + *
70 + * Class SV_SC_SERVER_INFO
71 + */
72 +class SV_SC_SERVER_INFO extends SV_Preset {
73 +
74 + protected function unsanitised() {
75 +
76 + $args = $this->get_arguments();
77 +
78 + return ( false === empty( $_SERVER[ $args['field'] ] ) ) ? $_SERVER[ $args['field'] ] : '';
79 + }
80 +}
81 +
82 +/**
83 + * Get a unique ID
84 + *
85 + * Class SV_SC_UNIQUE_ID
86 + */
87 +class SV_SC_UNIQUE_ID extends SV_Preset {
88 +
89 + protected function unsanitised() {
90 +
91 + $args = $this->get_arguments();
92 +
93 + $prefix = ( false === empty( $args['prefix'] ) ) ? $args['prefix'] : '';
94 +
95 + return uniqid ( $prefix, true );
96 + }
97 +}
98 +
99 +/**
100 + * Get timestamp
101 + *
102 + * Class SV_SC_TIMESTAMP
103 + */
104 +class SV_SC_TIMESTAMP extends SV_Preset {
105 +
106 + protected function unsanitised() {
107 + return time();
108 + }
109 +}
110 +
111 +/**
112 + * Display PHP INFO
113 + *
114 + * Class SV_SC_PHP_INFO
115 + */
116 +class SV_SC_PHP_INFO extends SV_Preset {
117 +
118 + protected function unsanitised() {
119 + return phpinfo();
120 + }
121 +}
122 +
123 +/**
124 + * Current URL
125 + *
126 + * Class SV_SC_CURRENT_URL
127 + */
128 +class SV_SC_CURRENT_URL extends SV_Preset {
129 +
130 + protected function unsanitised() {
131 +
132 + $protocol = (
133 + ( isset($_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
134 + ( isset($_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
135 + ) ? 'https://' : 'http://';
136 +
137 + return $protocol . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
138 + }
139 +}
140 +
141 +/**
142 + * Register URL
143 + *
144 + * Class SV_SC_REGISTER_URL
145 + */
146 +class SV_SC_REGISTER_URL extends SV_Preset {
147 +
148 + protected function unsanitised() {
149 + return wp_registration_url();
150 + }
151 +}
152 +
153 +/**
154 + * Random number
155 + *
156 + * Class SV_SC_RAND_NUMBER
157 + */
158 +class SV_SC_RAND_NUMBER extends SV_Preset {
159 +
160 + protected function unsanitised() {
161 +
162 + $args = $this->get_arguments();
163 +
164 + $min = ( false === empty( $args['min'] ) ) ? (int) $args['min'] : 0;
165 +
166 + $max = ( false === empty( $args['max'] ) ) ? (int) $args['max'] : getrandmax();
167 +
168 + return rand( $min, $max );
169 + }
170 +}
171 +
172 +/**
173 + * Avatar URL
174 + *
175 + * Class SV_SC_AVATAR
176 + */
177 +class SV_SC_AVATAR extends SV_Preset {
178 +
179 + public function init() {
180 +
181 + $this->escape_method = false;
182 + }
183 +
184 + protected function unsanitised() {
185 +
186 + $args = $this->get_arguments();
187 + $user_id = get_current_user_id();
188 +
189 +// if ( true === empty( $user_id ) ) {
190 +// return '';
191 +// }
192 +
193 + $width = ( false === empty( $args['width'] ) ) ? (int) $args['width'] : 96;
194 + $profile_url = get_avatar_url( $user_id, [ 'size' => $width ] );
195 +
196 + if ( true === empty( $profile_url ) ){
197 + return '';
198 + }
199 +
200 + return sprintf( '<img src="%1$s" />', esc_url( $profile_url ) );
201 + }
202 +}
203 +
204 +/**
205 + * Random string
206 + *
207 + * Based upon: https://stackoverflow.com/questions/4356289/php-random-string-generator
208 + *
209 + * Class SV_SC_RAND_STRING
210 + */
211 +class SV_SC_RAND_STRING extends SV_Preset {
212 +
213 + protected function unsanitised() {
214 +
215 + $args = $this->get_arguments();
216 +
217 + $length = ( false === empty( $args['length'] ) ) ? (int) $args['length'] : 10;
218 +
219 + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
220 + $no_characters = strlen( $characters );
221 + $random_string = '';
222 +
223 + for ($i = 0; $i < $length; $i++) {
224 + $random_string .= $characters[ rand( 0, $no_characters - 1 ) ];
225 + }
226 +
227 + return $random_string;
228 + }
229 +}
230 +
231 +/**
232 + * Fetch an item from the $_POST array
233 + *
234 + * Class SV_SC_POST_VALUE
235 + */
236 +class SV_SC_POST_VALUE extends SV_Preset {
237 +
238 + protected function unsanitised() {
239 +
240 + $args = $this->get_arguments();
241 +
242 + $post_value = ( false === empty( $_POST[ $args['key'] ] ) ) ? $_POST[ $args['key'] ] : NULL;
243 +
244 + if ( null !== $post_value ) {
245 + return $post_value;
246 + }
247 +
248 + // Do we have a fall back default?
249 + return ( false === empty( $args['default'] ) ) ? $args['default'] : '';
250 +
251 + }
252 +}
253 +
254 +/**
255 + * Fetch an item from the $_GET array
256 + *
257 + * Class SV_SC_GET_VALUE
258 + */
259 +class SV_SC_GET_VALUE extends SV_Preset {
260 +
261 + protected function unsanitised() {
262 +
263 + $args = $this->get_arguments();
264 +
265 + $post_value = ( false === empty( $_GET[ $args['key'] ] ) ) ? $_GET[ $args['key'] ] : NULL;
266 +
267 + if ( null !== $post_value ) {
268 + return $post_value;
269 + }
270 +
271 + // Do we have a fall back default?
272 + return ( false === empty( $args['default'] ) ) ? $args['default'] : '';
273 +
274 + }
275 +}
276 +
277 +/**
278 + * Display current Post ID
279 + *
280 + * Class SV_SC_POST_ID
281 + */
282 +class SV_SC_POST_ID extends SV_Preset {
283 +
284 + protected function unsanitised() {
285 + return get_the_ID();
286 + }
287 +}
288 +
289 +/**
290 + * Display author of current post
291 + *
292 + * Class SV_SC_POST_AUTHOR
293 + */
294 +class SV_SC_POST_AUTHOR extends SV_Preset {
295 +
296 + protected function unsanitised() {
297 +
298 + $args = $this->get_arguments();
299 +
300 + switch ( $args['field'] ) {
301 + case 'id':
302 + return get_the_author_meta( 'ID' );
303 + break;
304 + default:
305 + return get_the_author();
306 + }
307 + }
308 +}
309 +
310 +/**
311 + * Display post counts
312 + *
313 + * Class SV_SC_POST_COUNTS
314 + */
315 +class SV_SC_POST_COUNTS extends SV_Preset {
316 +
317 + protected function unsanitised() {
318 +
319 + $args = $this->get_arguments();
320 +
321 + $counts = wp_count_posts();
322 +
323 + switch ( $args['status'] ) {
324 + case 'future':
325 + return $counts->future;
326 + break;
327 + case 'draft':
328 + return $counts->draft;
329 + break;
330 + case 'pending':
331 + return $counts->pending;
332 + break;
333 + case 'private':
334 + return $counts->private;
335 + break;
336 + default:
337 + return $counts->publish;
338 + }
339 + }
340 +}
341 +
342 +/**
343 + * Get a User counts
344 + *
345 + * Class SV_SC_USER_COUNTS
346 + */
347 +class SV_SC_USER_COUNTS extends SV_Preset {
348 +
349 + protected function unsanitised() {
350 +
351 + $args = $this->get_arguments();
352 +
353 + $role = ( false === empty( $args['role'] ) ) ? $args['role'] : NULL;
354 +
355 + $users = count_users();
356 +
357 + if ( false === empty( $role ) && true === isset( $users['avail_roles'][ $role ] ) ) {
358 + return $users['avail_roles'][ $role ];
359 + } if ( true === isset( $users['total_users'] ) ) {
360 + return $users['total_users'];
361 + }
362 +
363 + return '';
364 + }
365 +}
366 +
367 +/**
368 + * Display a date and also support date arithmetic
369 + *
370 + * Class SV_SC_DATE
371 + */
372 +class SV_SC_DATE extends SV_Preset {
373 +
374 + protected function unsanitised() {
375 +
376 + $args = $this->get_arguments();
377 +
378 + $todays_date = date_create();
379 +
380 + // Do we have an interval?
381 + if ( false === empty( $args['interval'] ) ) {
382 +
383 + $interval = date_interval_create_from_date_string( $args['interval'] );
384 +
385 + if ( $interval !== false ) {
386 + $todays_date = date_add( $todays_date, $interval );
387 + }
388 +
389 + }
390 +
391 + $date_format = ( false === empty( $args['format'] ) ) ? $args['format'] : 'd/m/Y';
392 +
393 + return date_format( $todays_date, $date_format );
394 + }
395 +}