PluginProbe
Snippet Shortcodes / 1.3.1
Snippet Shortcodes v1.3.1
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-premade.php

shortcode-premade.php in Snippet Shortcodes 1.3.1, at includes/shortcode-premade.php

64 lines 1.4 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_is_shortcode_preset($slug)
6 {
7 if (!empty($slug) && array_key_exists($slug, sh_cd_shortcode_presets())) {
8 return true;
9 }
10
11 return false;
12
13 }
14
15 function sh_cd_shortcode_presets()
16 {
17 return array(
18
19 'sc-todays-date' => 'Displays today\'s date. 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>',
20 'sc-site-title' => 'Displays the site title.',
21 'sc-site-url' => 'Displays the site URL.',
22 'sc-page-title' => 'Displays the page title.',
23 'sc-admin-email' => 'Displays the admin email address.'
24 );
25 }
26
27 function sh_cd_render_shortcode_presets($shortcode_args)
28 {
29 $slug = $shortcode_args['slug'];
30
31 switch ($slug) {
32 case 'sc-todays-date':
33 return sh_cd_render_todays_date($shortcode_args['format']);
34 break;
35 case 'sc-site-url':
36 return site_url();
37 break;
38 case 'sc-page-title':
39 return the_title('', '', true);
40 break;
41 case 'sc-site-title':
42 return bloginfo( 'name');
43 break;
44 case 'sc-admin-email':
45 return bloginfo( 'admin_email');
46 break;
47
48 default:
49 # code...
50 break;
51 }
52
53
54 }
55
56
57 function sh_cd_render_todays_date($format)
58 {
59 if (false == $format) {
60 $format = 'd/m/Y';
61 }
62
63 return date($format);
64 }