Completed
Branch master (545f87)
by Swapnil V.
01:52
created
shortcodely-admin-form-html.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -71,6 +71,9 @@
 block discarded – undo
71 71
              return $links;
72 72
         }
73 73
 
74
+        /**
75
+         * @param string $title
76
+         */
74 77
         public function admin_heading( $title ) 
75 78
         {
76 79
              echo '<div class="wrap" >
Please login to merge, or discard this patch.
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -44,20 +44,20 @@  discard block
 block discarded – undo
44 44
         public $accesslvl        = 'manage_options';
45 45
         public function __construct() 
46 46
         {
47
-             add_action('admin_menu', array( &$this, 'register_settings_page' ));
48
-             add_filter('plugin_action_links', array( &$this, 'add_action_link' ), 10, 2);
47
+                add_action('admin_menu', array( &$this, 'register_settings_page' ));
48
+                add_filter('plugin_action_links', array( &$this, 'add_action_link' ), 10, 2);
49 49
         }
50 50
         public function register_settings_page() 
51 51
         {
52
-             add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array( &$this, 'config_page' ));
52
+                add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array( &$this, 'config_page' ));
53 53
         }
54 54
         public function plugin_options_url() 
55 55
         {
56
-             return admin_url('options-general.php?page=' . $this->hook);
56
+                return admin_url('options-general.php?page=' . $this->hook);
57 57
         }
58 58
         /**
59
-                 * Add a link to the settings page to the plugins list
60
-                 */
59
+         * Add a link to the settings page to the plugins list
60
+         */
61 61
         public function add_action_link( $links, $file ) 
62 62
         {
63 63
             static $this_plugin;
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
                 $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __('Settings', 'shortcodely-shortcode-any-widget') . '</a>';
69 69
                 array_unshift($links, $settings_link);
70 70
             }
71
-             return $links;
71
+                return $links;
72 72
         }
73 73
 
74 74
         public function admin_heading( $title ) 
75 75
         {
76
-             echo '<div class="wrap" >
76
+                echo '<div class="wrap" >
77 77
 			<div id="icon-options-general" class="icon32"><br />
78 78
 			</div>
79 79
 			<h2>' . $title . ' </h2>';
@@ -81,153 +81,153 @@  discard block
 block discarded – undo
81 81
 
82 82
         public function admin_subheading( $title ) 
83 83
         {
84
-             echo '<h2>' . $title . '</h2>';
84
+                echo '<h2>' . $title . '</h2>';
85 85
         }
86 86
         public function config_page() 
87 87
         {
88
-             $this->admin_heading($this->longname);
89
-             echo '<h3>More detailed instructions at the wordpress plugin <a target="_new" href="http://wordpress.org/plugins/shortcodely/installation">installation and faq pages.</a></h3>';
90
-             echo '<ol>';
91
-             echo '<li>';
92
-             _e('Test your widget in a normal sidebar first.', 'shortcodely-shortcode-any-widget');
93
-             echo ' <a title="Go to widget area" href="' . get_admin_url('', 'widgets.php') . '">';
94
-             _e('Go to widgets', 'shortcodely-shortcode-any-widget');
95
-             echo '</a>';
96
-             echo '<li>';
97
-             _e('Drag the widgets you want to use to the shortcodes sidebar.', 'shortcodely-shortcode-any-widget');
98
-             echo '</li>';
99
-             echo '<li>';
100
-             _e('Add a do_widget or do_widget_area shortcode to a page.', 'shortcodely-shortcode-any-widget');
101
-             echo ' <a title="Create a page" href="'
102
-             . get_admin_url('', 'post-new.php?post_type=page&content=&#91;do_widget Archives &#93;')
103
-             . '">';
104
-             _e('Create a page with example do_widget shortcode', 'shortcodely-shortcode-any-widget');
105
-             echo '</a>';
106
-             echo '</li>';
107
-             echo '</ol>';
108
-
109
-             echo '<h2>';
110
-             _e('To add a single widget to a page', 'shortcodely-shortcode-any-widget');
111
-             echo '</h2>';
112
-             echo '<ul>';
113
-             echo '<li>';
114
-             _e('Add the shortcode [do_widget widgetname] to a page:', 'shortcodely-shortcode-any-widget');
115
-             echo '</li>';
116
-             echo '<li>';
117
-             echo '<li>';
118
-             echo '[do_widget categories] or [do_widget name=categories] ';
119
-             echo '</li>';
120
-             echo '<li>';
121
-             _e('[do_widget "tag cloud"] or [do_widget id=widgetid]', 'shortcodely-shortcode-any-widget');
122
-             echo '</li>';
123
-             echo '<li>';
124
-             echo 'To see a list of your widgets in their sidebars, add <b>?do_widget_debug</b> to the url of page with the do_widget shortcode.';
125
-             echo '</li>';
126
-             echo '</ul>';
127
-
128
-             echo '<br />';
129
-             echo '<h2>';
130
-             _e('More advanced options:', 'shortcodely-shortcode-any-widget');
131
-             echo '</h2>';
132
-             echo '<ul><li>';
133
-             echo 'Use title=false to hide a widget title. ';
134
-             echo '</li>';
135
-             echo '<li>';
136
-             echo '[do_widget pages title=false]	will hide the widget title';
137
-             echo '</li></ul>';
138
-             echo '<h3>';
139
-             _e('To change the style, change the html:', 'shortcodely-shortcode-any-widget');
140
-             echo '</h3>';
141
-             echo '<ul>';
142
-
143
-             echo '<li>';
144
-             echo 'Use title=somehtmltag and wrap=somehtmltag	to change the html used.	This may change how your theme\'s css affects the widget when it is in	page.	It all depends what what html selectors your theme uses.';
145
-             echo '</li>';
146
-             echo '<li>';
147
-             echo ' Use class=yourclassname to add a class - maybe to override your themes widget styling?	Obviously you must have css that applies to that class.';
148
-             echo '</li>';
149
-
150
-             echo '<li>';
151
-             echo '[do_widget pages title=h3]	give the title a heading 3 html tag.';
152
-             echo '</li>';
153
-             echo '<li>';
154
-             echo '[do_widget "tag cloud" wrap=aside]	 will wrap the widget in an "aside" html tag.';
155
-             echo '</li>';
156
-
157
-             echo '</ul>';
158
-
159
-             echo '<h4>';
160
-             echo 'Valid title html tags are : </h4><ul>';
161
-             echo '<li>h1</li>';
162
-             echo '<li>h2</li>';
163
-             echo '<li>h3</li>';
164
-             echo '<li>h4</li>';
165
-             echo '<li>h5</li>';
166
-             echo '<li>header</li>';
167
-             echo '<li>strong</li>';
168
-             echo '<li>em</li>';
169
-             echo '</ul>';
170
-
171
-             echo '<h4>Valid html wrap tags are :</h4><ul>';
172
-             echo '<li>div</li>';
173
-             echo '<li>p</li>';
174
-             echo '<li>aside</li>';
175
-             echo '<li>section</li>';
176
-             echo '</ul>';
177
-
178
-             echo '<h2>';
179
-             _e('To add multiple instances of the same widget:', 'shortcodely-shortcode-any-widget');
180
-
181
-             echo '</h2>';
182
-             echo '<ul>';
183
-             echo '<li>';
184
-             echo '[do_widget id=widgetid1] [do_widget id=widgetid2]';
185
-             echo '</li>';
186
-             echo '</ul>';
187
-
188
-             echo '<h2>';
189
-             _e('To add a widget area - all widgets in the widget area:', 'shortcodely-shortcode-any-widget');
190
-
191
-             echo '</h2>';
192
-             echo '<ul>';
193
-             echo '<li>';
194
-             echo '<a title="Create a page" href="'
195
-             . get_admin_url('', 'post-new.php?post_type=page&content=&#91;do_widget_area&#93;')
196
-             . '"> ';
197
-             _e('Create a page with do_widget_area shortcode', 'shortcodely-shortcode-any-widget');
198
-             echo '</a> Hoping to use theme styling.';
199
-             echo '</li>';
200
-             echo '<li>';
201
-             echo '<a title="Create a page" href="'
202
-             . get_admin_url(
203
-                 '',
204
-                 'post-new.php?post_type=page&content=&#91;do_widget_area widget_area_class=none&#93;'
205
-             )
206
-             . '"> ';
207
-             _e('Create a page with do_widget_area shortcode	without the widget_area class', 'shortcodely-shortcode-any-widget');
208
-             echo '</a> Hoping to avoid theme sidebar styling.';
209
-             echo '</li>';
210
-             echo '<li>';
211
-             _e('Examples:', 'shortcodely-shortcode-any-widget');
212
-             echo '</li>';
213
-             echo '<li>';
214
-             _e('[do_widget_area] or [do_widget_area widget_area=sidebar-1]', 'shortcodely-shortcode-any-widget');
215
-             echo '</li>';
216
-             echo '<li>';
217
-             _e('NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background.	Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.', 'shortcodely-shortcode-any-widget');
218
-             echo '</li>';
219
-             echo '</ul>';
220
-             echo '<br />';
88
+                $this->admin_heading($this->longname);
89
+                echo '<h3>More detailed instructions at the wordpress plugin <a target="_new" href="http://wordpress.org/plugins/shortcodely/installation">installation and faq pages.</a></h3>';
90
+                echo '<ol>';
91
+                echo '<li>';
92
+                _e('Test your widget in a normal sidebar first.', 'shortcodely-shortcode-any-widget');
93
+                echo ' <a title="Go to widget area" href="' . get_admin_url('', 'widgets.php') . '">';
94
+                _e('Go to widgets', 'shortcodely-shortcode-any-widget');
95
+                echo '</a>';
96
+                echo '<li>';
97
+                _e('Drag the widgets you want to use to the shortcodes sidebar.', 'shortcodely-shortcode-any-widget');
98
+                echo '</li>';
99
+                echo '<li>';
100
+                _e('Add a do_widget or do_widget_area shortcode to a page.', 'shortcodely-shortcode-any-widget');
101
+                echo ' <a title="Create a page" href="'
102
+                . get_admin_url('', 'post-new.php?post_type=page&content=&#91;do_widget Archives &#93;')
103
+                . '">';
104
+                _e('Create a page with example do_widget shortcode', 'shortcodely-shortcode-any-widget');
105
+                echo '</a>';
106
+                echo '</li>';
107
+                echo '</ol>';
108
+
109
+                echo '<h2>';
110
+                _e('To add a single widget to a page', 'shortcodely-shortcode-any-widget');
111
+                echo '</h2>';
112
+                echo '<ul>';
113
+                echo '<li>';
114
+                _e('Add the shortcode [do_widget widgetname] to a page:', 'shortcodely-shortcode-any-widget');
115
+                echo '</li>';
116
+                echo '<li>';
117
+                echo '<li>';
118
+                echo '[do_widget categories] or [do_widget name=categories] ';
119
+                echo '</li>';
120
+                echo '<li>';
121
+                _e('[do_widget "tag cloud"] or [do_widget id=widgetid]', 'shortcodely-shortcode-any-widget');
122
+                echo '</li>';
123
+                echo '<li>';
124
+                echo 'To see a list of your widgets in their sidebars, add <b>?do_widget_debug</b> to the url of page with the do_widget shortcode.';
125
+                echo '</li>';
126
+                echo '</ul>';
127
+
128
+                echo '<br />';
129
+                echo '<h2>';
130
+                _e('More advanced options:', 'shortcodely-shortcode-any-widget');
131
+                echo '</h2>';
132
+                echo '<ul><li>';
133
+                echo 'Use title=false to hide a widget title. ';
134
+                echo '</li>';
135
+                echo '<li>';
136
+                echo '[do_widget pages title=false]	will hide the widget title';
137
+                echo '</li></ul>';
138
+                echo '<h3>';
139
+                _e('To change the style, change the html:', 'shortcodely-shortcode-any-widget');
140
+                echo '</h3>';
141
+                echo '<ul>';
142
+
143
+                echo '<li>';
144
+                echo 'Use title=somehtmltag and wrap=somehtmltag	to change the html used.	This may change how your theme\'s css affects the widget when it is in	page.	It all depends what what html selectors your theme uses.';
145
+                echo '</li>';
146
+                echo '<li>';
147
+                echo ' Use class=yourclassname to add a class - maybe to override your themes widget styling?	Obviously you must have css that applies to that class.';
148
+                echo '</li>';
149
+
150
+                echo '<li>';
151
+                echo '[do_widget pages title=h3]	give the title a heading 3 html tag.';
152
+                echo '</li>';
153
+                echo '<li>';
154
+                echo '[do_widget "tag cloud" wrap=aside]	 will wrap the widget in an "aside" html tag.';
155
+                echo '</li>';
156
+
157
+                echo '</ul>';
158
+
159
+                echo '<h4>';
160
+                echo 'Valid title html tags are : </h4><ul>';
161
+                echo '<li>h1</li>';
162
+                echo '<li>h2</li>';
163
+                echo '<li>h3</li>';
164
+                echo '<li>h4</li>';
165
+                echo '<li>h5</li>';
166
+                echo '<li>header</li>';
167
+                echo '<li>strong</li>';
168
+                echo '<li>em</li>';
169
+                echo '</ul>';
170
+
171
+                echo '<h4>Valid html wrap tags are :</h4><ul>';
172
+                echo '<li>div</li>';
173
+                echo '<li>p</li>';
174
+                echo '<li>aside</li>';
175
+                echo '<li>section</li>';
176
+                echo '</ul>';
177
+
178
+                echo '<h2>';
179
+                _e('To add multiple instances of the same widget:', 'shortcodely-shortcode-any-widget');
180
+
181
+                echo '</h2>';
182
+                echo '<ul>';
183
+                echo '<li>';
184
+                echo '[do_widget id=widgetid1] [do_widget id=widgetid2]';
185
+                echo '</li>';
186
+                echo '</ul>';
187
+
188
+                echo '<h2>';
189
+                _e('To add a widget area - all widgets in the widget area:', 'shortcodely-shortcode-any-widget');
190
+
191
+                echo '</h2>';
192
+                echo '<ul>';
193
+                echo '<li>';
194
+                echo '<a title="Create a page" href="'
195
+                . get_admin_url('', 'post-new.php?post_type=page&content=&#91;do_widget_area&#93;')
196
+                . '"> ';
197
+                _e('Create a page with do_widget_area shortcode', 'shortcodely-shortcode-any-widget');
198
+                echo '</a> Hoping to use theme styling.';
199
+                echo '</li>';
200
+                echo '<li>';
201
+                echo '<a title="Create a page" href="'
202
+                . get_admin_url(
203
+                    '',
204
+                    'post-new.php?post_type=page&content=&#91;do_widget_area widget_area_class=none&#93;'
205
+                )
206
+                . '"> ';
207
+                _e('Create a page with do_widget_area shortcode	without the widget_area class', 'shortcodely-shortcode-any-widget');
208
+                echo '</a> Hoping to avoid theme sidebar styling.';
209
+                echo '</li>';
210
+                echo '<li>';
211
+                _e('Examples:', 'shortcodely-shortcode-any-widget');
212
+                echo '</li>';
213
+                echo '<li>';
214
+                _e('[do_widget_area] or [do_widget_area widget_area=sidebar-1]', 'shortcodely-shortcode-any-widget');
215
+                echo '</li>';
216
+                echo '<li>';
217
+                _e('NB: Using something like the twenty-fourteen theme? you might end up with white text on a white background.	Tweak the widget classes or the html of the wrap or title. If that fails, adjust your css.', 'shortcodely-shortcode-any-widget');
218
+                echo '</li>';
219
+                echo '</ul>';
220
+                echo '<br />';
221 221
         }
222 222
 
223 223
 
224 224
         /**
225
-                 * Info box with link to the support forums.
226
-                 */
225
+         * Info box with link to the support forums.
226
+         */
227 227
         public function plugin_support() 
228 228
         {
229
-             $content = '<p>' . __('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the', 'shortcodely-shortcode-any-widget') . ' <a href="http://wordpress.org/tags/' . $this->hook . '">' . __('Support forums', 'shortcodely-shortcode-any-widget') . '</a>.</p>';
230
-             $this->postbox($this->hook . 'support', 'Need support?', $content);
229
+                $content = '<p>' . __('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the', 'shortcodely-shortcode-any-widget') . ' <a href="http://wordpress.org/tags/' . $this->hook . '">' . __('Support forums', 'shortcodely-shortcode-any-widget') . '</a>.</p>';
230
+                $this->postbox($this->hook . 'support', 'Need support?', $content);
231 231
         }
232 232
 
233 233
         public function text_limit( $text, $limit, $finish = ' [&hellip;]' ) 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
                 $text = substr($text, 0, - (strlen(strrchr($text, ' '))));
238 238
                 $text .= $finish;
239 239
             }
240
-             return $text;
240
+                return $text;
241 241
         }
242 242
     }
243 243
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
 
9 9
 // ------------------------------------------------------------------------------------------------------------------
10
-if (! class_exists('Shortcodely_Saw_Plugin_Admin') ) {
10
+if ( ! class_exists('Shortcodely_Saw_Plugin_Admin')) {
11 11
     /*
12 12
     * Shortcodely_Saw_Plugin_Admin Class Doc Comment
13 13
     *
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
     class Shortcodely_Saw_Plugin_Admin
22 22
     {
23 23
 
24
-        public $hook                = 'shortcodely_saw';
24
+        public $hook = 'shortcodely_saw';
25 25
         public $filename        = 'shortcodely_shortcode_any_widget/shortcodely_shortcode_any_widget.php';
26 26
         public $longname        = 'Shortcode any widget - insert widgets or widget areas into a page.';
27
-        public $shortname        = 'Shortcode any widget';
27
+        public $shortname = 'Shortcode any widget';
28 28
         public $optionname = '';
29 29
         /**
30 30
          * Homepage variable Doc Comment
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
          * This is a "Docblock Comment," also known as a "docblock."    The class'
40 40
          * docblock, below, contains a complete description of how to write these.
41 41
          */
42
-        public $homepage        = '';
42
+        public $homepage = '';
43 43
         public $parent_slug = 'plugin_listings_menu';
44
-        public $accesslvl        = 'manage_options';
44
+        public $accesslvl = 'manage_options';
45 45
         public function __construct() 
46 46
         {
47
-             add_action('admin_menu', array( &$this, 'register_settings_page' ));
48
-             add_filter('plugin_action_links', array( &$this, 'add_action_link' ), 10, 2);
47
+             add_action('admin_menu', array(&$this, 'register_settings_page'));
48
+             add_filter('plugin_action_links', array(&$this, 'add_action_link'), 10, 2);
49 49
         }
50 50
         public function register_settings_page() 
51 51
         {
52
-             add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array( &$this, 'config_page' ));
52
+             add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array(&$this, 'config_page'));
53 53
         }
54 54
         public function plugin_options_url() 
55 55
         {
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
         /**
59 59
                  * Add a link to the settings page to the plugins list
60 60
                  */
61
-        public function add_action_link( $links, $file ) 
61
+        public function add_action_link($links, $file) 
62 62
         {
63 63
             static $this_plugin;
64
-            if (empty($this_plugin) ) {
64
+            if (empty($this_plugin)) {
65 65
                 $this_plugin = $this->filename;
66 66
             }
67
-            if ($file == $this_plugin ) {
67
+            if ($file == $this_plugin) {
68 68
                 $settings_link = '<a href="' . $this->plugin_options_url() . '">' . __('Settings', 'shortcodely-shortcode-any-widget') . '</a>';
69 69
                 array_unshift($links, $settings_link);
70 70
             }
71 71
              return $links;
72 72
         }
73 73
 
74
-        public function admin_heading( $title ) 
74
+        public function admin_heading($title) 
75 75
         {
76 76
              echo '<div class="wrap" >
77 77
 			<div id="icon-options-general" class="icon32"><br />
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			<h2>' . $title . ' </h2>';
80 80
         }
81 81
 
82
-        public function admin_subheading( $title ) 
82
+        public function admin_subheading($title) 
83 83
         {
84 84
              echo '<h2>' . $title . '</h2>';
85 85
         }
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
              $this->postbox($this->hook . 'support', 'Need support?', $content);
231 231
         }
232 232
 
233
-        public function text_limit( $text, $limit, $finish = ' [&hellip;]' ) 
233
+        public function text_limit($text, $limit, $finish = ' [&hellip;]') 
234 234
         {
235
-            if (strlen($text) > $limit ) {
235
+            if (strlen($text) > $limit) {
236 236
                 $text = substr($text, 0, $limit);
237 237
                 $text = substr($text, 0, - (strlen(strrchr($text, ' '))));
238 238
                 $text .= $finish;
Please login to merge, or discard this patch.
shortcodely-utilities.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -116,6 +116,9 @@
 block discarded – undo
116 116
     }
117 117
 }
118 118
 /*-----------------------------------*/
119
+/**
120
+ * @param string $type
121
+ */
119 122
 function shortcodely_show_widget_debug( $type, $name, $id, $sidebar ) 
120 123
 {
121 124
     global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount;
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@
 block discarded – undo
130 130
         }
131 131
     } elseif (($type == 'which one') and ($debug) ) {
132 132
         $text = '<p>Debug help is on: Is your widget in the widgets_for_shortcodes sidebar?</p>'
133
-         . $text;
133
+            . $text;
134 134
     }
135 135
 
136 136
     return $text;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
     global $_wp_sidebars_widgets;
12 12
 
13 13
     $sidebars_widgets = $_wp_sidebars_widgets;
14
-    ksort($sidebars_widgets);  // push inactive down the bottom of the list
14
+    ksort($sidebars_widgets); // push inactive down the bottom of the list
15 15
     $text = '<ul>';
16
-    foreach ( $sidebars_widgets as $sidebarid => $sidebar ) {
17
-        if (is_array($sidebar) ) {
16
+    foreach ($sidebars_widgets as $sidebarid => $sidebar) {
17
+        if (is_array($sidebar)) {
18 18
             $text .= '<li><em>[do_widget_area ' . $sidebarid . ']</em><ul>';
19
-            foreach ( $sidebar as $i => $w ) {
19
+            foreach ($sidebar as $i => $w) {
20 20
                 $text .= '<li>';
21 21
                 $text .= '[do_widget id="' . $w . '"]';
22 22
                 $text .= '</li>';
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
 }
31 31
 
32 32
 /*-----------------------------------*/
33
-function shortcodely_get_widgets_sidebar( $wid ) 
33
+function shortcodely_get_widgets_sidebar($wid) 
34 34
 {
35 35
     /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
36 36
     take the first one that matches */
37 37
     global $_wp_sidebars_widgets;
38 38
 
39
-    foreach ( $_wp_sidebars_widgets as $sidebarid => $sidebar ) {
40
-        if (is_array($sidebar) ) { // ignore the 'array version' sidebarid that isnt actually a sidebar
41
-            foreach ( $sidebar as $i => $w ) {
42
-                if ($w == $wid ) {
39
+    foreach ($_wp_sidebars_widgets as $sidebarid => $sidebar) {
40
+        if (is_array($sidebar)) { // ignore the 'array version' sidebarid that isnt actually a sidebar
41
+            foreach ($sidebar as $i => $w) {
42
+                if ($w == $wid) {
43 43
                     return    $sidebarid;
44 44
                 }
45 45
             }
@@ -49,14 +49,14 @@  discard block
 block discarded – undo
49 49
     return false; // widget id not in any sidebar
50 50
 }
51 51
 /*-----------------------------------*/
52
-function shortcodely_get_sidebar_id( $name ) 
52
+function shortcodely_get_sidebar_id($name) 
53 53
 {
54 54
     /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.
55 55
     take the first one that matches */
56 56
     global $wp_registered_sidebars;
57 57
 
58
-    foreach ( $wp_registered_sidebars as $i => $a ) {
59
-        if ((isset($a['name'])) and ($a['name'] === $name) ) {
58
+    foreach ($wp_registered_sidebars as $i => $a) {
59
+        if ((isset($a['name'])) and ($a['name'] === $name)) {
60 60
             return $i;
61 61
         }
62 62
     }
@@ -64,14 +64,14 @@  discard block
 block discarded – undo
64 64
     return false;
65 65
 }
66 66
 /*-----------------------------------*/
67
-function shortcodely_get_sidebar_name( $id ) 
67
+function shortcodely_get_sidebar_name($id) 
68 68
 {
69 69
     /* dont need anymore ? or at least temporarily */
70 70
     /* walk through the registered sidebars with a name and find the id - will be something like sidebar-integer.  take the first one */
71 71
     global $wp_registered_sidebars;
72
-    foreach ( $wp_registered_sidebars as $i => $a ) {
73
-        if ((isset($a['id'])) and ($a['id'] === $id) ) {
74
-            if (isset($a['name']) ) {
72
+    foreach ($wp_registered_sidebars as $i => $a) {
73
+        if ((isset($a['id'])) and ($a['id'] === $id)) {
74
+            if (isset($a['name'])) {
75 75
                 return $a['name'];
76 76
             } else {
77 77
                 return $id;
@@ -87,16 +87,16 @@  discard block
 block discarded – undo
87 87
     global $said;
88 88
     // only do these debug if we are logged in and are the administrator
89 89
 
90
-    if (is_admin() ) {
90
+    if (is_admin()) {
91 91
         return false;
92 92
     }   // if running in backend, then do not do debug.  20151217
93 93
 
94
-    if (( ! is_user_logged_in()) or ( ! current_user_can('administrator')) ) {
94
+    if (( ! is_user_logged_in()) or ( ! current_user_can('administrator'))) {
95 95
         return false;
96 96
     }
97 97
 
98
-    if (isset($_REQUEST['do_widget_debug']) ) {
99
-        if (empty($said) ) {
98
+    if (isset($_REQUEST['do_widget_debug'])) {
99
+        if (empty($said)) {
100 100
             $said = true;
101 101
         } else {
102 102
             return true;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
     }
117 117
 }
118 118
 /*-----------------------------------*/
119
-function shortcodely_show_widget_debug( $type, $name, $id, $sidebar ) 
119
+function shortcodely_show_widget_debug($type, $name, $id, $sidebar) 
120 120
 {
121 121
     global $wp_registered_sidebars, $wp_registered_widgets, $_wp_sidebars_widgets, $debugcount;
122 122
     // only do these debug if we are logged in and are the administrator
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
     $debug = shortcodely_check_if_widget_debug();
125 125
     $text = Shortcodely_show_shortcode_widget_possibilities();
126 126
 
127
-    if ($type == 'empty' ) {
128
-        if (current_user_can('administrator') ) {
127
+    if ($type == 'empty') {
128
+        if (current_user_can('administrator')) {
129 129
             $text = '<p>Problem with do_widget shortcode?  Try one of the following:</p>' . $text;
130 130
         }
131
-    } elseif (($type == 'which one') and ($debug) ) {
131
+    } elseif (($type == 'which one') and ($debug)) {
132 132
         $text = '<p>Debug help is on: Is your widget in the widgets_for_shortcodes sidebar?</p>'
133 133
          . $text;
134 134
     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 {
141 141
     // when switching a theme, save the widgets we use for the shortcodes as they are getting overwritten
142 142
     $sidebars_widgets = wp_get_sidebars_widgets();
143
-    if (! empty($sidebars_widgets['widgets_for_shortcodes']) ) {
143
+    if ( ! empty($sidebars_widgets['widgets_for_shortcodes'])) {
144 144
         update_option('sidebars_widgets_for_shortcodes_saved', $sidebars_widgets['widgets_for_shortcodes']);
145 145
     } else {  // our shortcodes sidebar is empty  but when to fix ?
146 146
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     global $_wp_sidebars_widgets;
153 153
 
154 154
     $sidebars_widgets = wp_get_sidebars_widgets();
155
-    if (empty($sidebars_widgets['widgets_for_shortcodes']) ) {
155
+    if (empty($sidebars_widgets['widgets_for_shortcodes'])) {
156 156
         $sidebars_widgets['widgets_for_shortcodes'] = get_option('sidebars_widgets_for_shortcodes_saved');
157 157
         update_option('sidebars_widgets', $sidebars_widgets);
158 158
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 {
163 163
     // added in 2014 February for compatibility.. keep for how long. till no sites running older versions.?
164 164
     $sidebars_widgets = wp_get_sidebars_widgets();
165
-    if (! empty($sidebars_widgets['Shortcodes']) and empty($sidebars_widgets['widgets_for_shortcodes']) ) {  // we need to upgrade
165
+    if ( ! empty($sidebars_widgets['Shortcodes']) and empty($sidebars_widgets['widgets_for_shortcodes'])) {  // we need to upgrade
166 166
         $sidebars_widgets['widgets_for_shortcodes'] = $sidebars_widgets['Shortcodes'];
167 167
         unset($sidebars_widgets['Shortcodes']);
168 168
         update_option('sidebars_widgets', $sidebars_widgets);
Please login to merge, or discard this patch.
shortcodely.php 3 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -48,6 +48,9 @@
 block discarded – undo
48 48
     }
49 49
 }
50 50
 
51
+/**
52
+ * @return callable
53
+ */
51 54
 function shortcodely_remove_widget_class( $params ) 
52 55
 {
53 56
     /* 
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
     */
56 56
     if (! empty($params[0]['before_widget']) ) {
57 57
         $params[0]['before_widget'] =
58
-          str_replace('"widget ', '"', $params[0]['before_widget']);
58
+            str_replace('"widget ', '"', $params[0]['before_widget']);
59 59
     }
60 60
 
61 61
     if (! empty($params[0]['before_title']) ) {
62 62
         $params[0]['before_title']
63
-          = $params[0]['before_title'] = str_replace('widget-title', '', $params[0]['before_title']);
63
+            = $params[0]['before_title'] = str_replace('widget-title', '', $params[0]['before_title']);
64 64
     }
65 65
 
66 66
     return $params;
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 
189 189
             return $output;
190 190
         }
191
-          // if we have id, get the sidebar for it
192
-          $sidebarid = shortcodely_get_widgets_sidebar($id);
191
+            // if we have id, get the sidebar for it
192
+            $sidebarid = shortcodely_get_widgets_sidebar($id);
193 193
         if (! $sidebarid ) {
194 194
             $output = '<br />Widget not in any sidebars<br />';
195 195
 
@@ -393,11 +393,11 @@  discard block
 block discarded – undo
393 393
         );
394 394
 
395 395
         if (! empty($wp_registered_sidebars) ) {    // we got some sidebars already.
396
-               $main_sidebar = reset($wp_registered_sidebars);    // Grab the first sidebar and use that as defaults for the widgets
397
-               $args['before_widget'] = $main_sidebar['before_widget'];
398
-               $args['after_widget'] = $main_sidebar['after_widget'];
399
-               $args['before_title'] = $main_sidebar['before_title'];
400
-               $args['after_title'] = $main_sidebar['after_title'];
396
+                $main_sidebar = reset($wp_registered_sidebars);    // Grab the first sidebar and use that as defaults for the widgets
397
+                $args['before_widget'] = $main_sidebar['before_widget'];
398
+                $args['after_widget'] = $main_sidebar['after_widget'];
399
+                $args['before_title'] = $main_sidebar['before_title'];
400
+                $args['after_title'] = $main_sidebar['after_title'];
401 401
         }
402 402
 
403 403
         register_sidebar($args);
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -34,31 +34,31 @@  discard block
 block discarded – undo
34 34
 */
35 35
 
36 36
 add_action('in_widget_form', 'Shortcodely_spice_get_widget_id');
37
-function Shortcodely_spice_get_widget_id( $widget_instance ) 
37
+function Shortcodely_spice_get_widget_id($widget_instance) 
38 38
 {
39 39
     /*
40 40
          * Main function to get widget id
41 41
          * 
42 42
          */
43 43
     echo '<p><strong>To use as shortcode with id:</strong> ';
44
-    if ($widget_instance->number == '__i__' ) {
44
+    if ($widget_instance->number == '__i__') {
45 45
         echo 'Save the widget first!</p>';
46 46
     } else {
47 47
         echo '[do_widget id=' . $widget_instance->id . ']</p>';
48 48
     }
49 49
 }
50 50
 
51
-function shortcodely_remove_widget_class( $params ) 
51
+function shortcodely_remove_widget_class($params) 
52 52
 {
53 53
     /* 
54 54
     * Remove the widget classes
55 55
     */
56
-    if (! empty($params[0]['before_widget']) ) {
56
+    if ( ! empty($params[0]['before_widget'])) {
57 57
         $params[0]['before_widget'] =
58 58
           str_replace('"widget ', '"', $params[0]['before_widget']);
59 59
     }
60 60
 
61
-    if (! empty($params[0]['before_title']) ) {
61
+    if ( ! empty($params[0]['before_title'])) {
62 62
         $params[0]['before_title']
63 63
           = $params[0]['before_title'] = str_replace('widget-title', '', $params[0]['before_title']);
64 64
     }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     return $params;
67 67
 }
68 68
 /*-----------------------------------*/
69
-function shortcodely_do_widget_area( $atts ) 
69
+function shortcodely_do_widget_area($atts) 
70 70
 {
71 71
     global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
72 72
 
@@ -75,42 +75,42 @@  discard block
 block discarded – undo
75 75
             array(
76 76
                         'widget_area' => 'widgets_for_shortcodes',
77 77
                         'class' => 'shortcodely-widget-area', /* the widget class is picked up automatically.	If we want to add an additional class at the wrap level to try to match a theme, use this */
78
-                        'widget_area_class' => '',    /* option to disassociate from themes widget styling use =none*/
79
-                        'widget_classes' => '',    /* option to disassociate from themes widget styling */
78
+                        'widget_area_class' => '', /* option to disassociate from themes widget styling use =none*/
79
+                        'widget_classes' => '', /* option to disassociate from themes widget styling */
80 80
 
81 81
                         ), $atts
82 82
         )
83 83
     );
84 84
 
85
-    if (! empty($atts) ) {
86
-        if (($widget_area == 'widgets_for_shortcodes') and ! empty($atts[0]) ) {
85
+    if ( ! empty($atts)) {
86
+        if (($widget_area == 'widgets_for_shortcodes') and ! empty($atts[0])) {
87 87
             $widget_area = $atts[0];
88 88
         }
89 89
     }
90 90
 
91
-    if (empty($wp_registered_sidebars[ $widget_area ]) ) {
91
+    if (empty($wp_registered_sidebars[$widget_area])) {
92 92
         echo '<br/>Widget area "' . $widget_area . '" not found. Registered widget areas (sidebars) are: <br/>';
93
-        foreach ( $wp_registered_sidebars as $area => $sidebar ) {
93
+        foreach ($wp_registered_sidebars as $area => $sidebar) {
94 94
             echo $area . '<br />';
95 95
         }
96 96
     }
97 97
     //if (isset($_REQUEST['do_widget_debug']) and current_user_can('administrator')) var_dump( $wp_registered_sidebars); /**/
98 98
 
99
-    if ($widget_area_class == 'none' ) {
99
+    if ($widget_area_class == 'none') {
100 100
         $class = '';
101 101
     } else {
102
-        if (! empty($widget_area_class) ) {    //2014 08
102
+        if ( ! empty($widget_area_class)) {    //2014 08
103 103
             $class .= 'class="' . $class . ' ' . $widget_area_class . '"';
104 104
         } else {
105 105
             $class = 'class="' . $class . '"';
106 106
         }
107 107
     }
108 108
 
109
-    if (! empty($widget_classes) and ($widget_classes == 'none') ) {
109
+    if ( ! empty($widget_classes) and ($widget_classes == 'none')) {
110 110
         add_filter('dynamic_sidebar_params', 'shortcodely_remove_widget_class');
111 111
     }
112 112
 
113
-    ob_start();    /* catch the echo output, so we can control where it appears in the text	*/
113
+    ob_start(); /* catch the echo output, so we can control where it appears in the text	*/
114 114
     dynamic_sidebar($widget_area);
115 115
     $output = ob_get_clean();
116 116
     remove_filter('dynamic_sidebar_params', 'shortcodely_remove_widget_class');
@@ -122,14 +122,14 @@  discard block
 block discarded – undo
122 122
     return $output;
123 123
 }
124 124
 /*-----------------------------------*/
125
-function shortcodely_do_widget( $atts ) 
125
+function shortcodely_do_widget($atts) 
126 126
 {
127 127
     global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
128 128
 
129 129
     /* check if the widget is in	the shortcode x sidebar	if not , just use generic,
130 130
     if it is in, then get the instance	data and use that */
131 131
 
132
-    if (is_admin() ) {
132
+    if (is_admin()) {
133 133
         return '';
134 134
     }    // eg in case someone decides to apply content filters when apost is saved, and not all widget stuff is there.
135 135
 
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
                         'sidebar' => 'Widgets for Shortcodes', //default
140 140
                         'id' => '',
141 141
                         'name' => '',
142
-                        'title' => '',     /* do the default title unless they ask us not to - use string here not boolean */
142
+                        'title' => '', /* do the default title unless they ask us not to - use string here not boolean */
143 143
                         'class' => 'shortcodely_widget', /* the widget class is picked up automatically.	If we want to add an additional class at the wrap level to try to match a theme, use this */
144 144
                         'wrap' => '', /* wrap the whole thing - title plus widget in a div - maybe the themes use a div, maybe not, maybe we want that styling, maybe not */
145
-                        'widget_classes' => '',    /* option to disassociate from themes widget styling */
145
+                        'widget_classes' => '', /* option to disassociate from themes widget styling */
146 146
                         ), $atts
147 147
         )
148 148
     );
149 149
 
150
-    if (isset($_wp_sidebars_widgets) ) {
151
-        shortcodely_show_widget_debug('which one', $name, $id, $sidebar);    //check for debug prompt and show widgets in shortcode sidebar if requested and logged in etc
150
+    if (isset($_wp_sidebars_widgets)) {
151
+        shortcodely_show_widget_debug('which one', $name, $id, $sidebar); //check for debug prompt and show widgets in shortcode sidebar if requested and logged in etc
152 152
     } else {
153 153
         $output = '<br />No widgets defined at all in any sidebar!';
154 154
 
@@ -156,29 +156,29 @@  discard block
 block discarded – undo
156 156
     }
157 157
 
158 158
     /* compatibility check - if the name is not entered, then the first parameter is the name */
159
-    if (empty($name) and ! empty($atts[0]) ) {
159
+    if (empty($name) and ! empty($atts[0])) {
160 160
         $name = $atts[0];
161 161
     }
162 162
 
163 163
     /* the widget need not be specified, [do_widget widgetname] is adequate */
164
-    if (! empty($name) ) {    // we have a name
164
+    if ( ! empty($name)) {    // we have a name
165 165
         $widget = $name;
166 166
 
167
-        foreach ( $wp_registered_widgets as $i => $w ) { /* get the official internal name or id that the widget was registered with	*/
168
-            if (strtolower($w['name']) === strtolower($widget) ) {
167
+        foreach ($wp_registered_widgets as $i => $w) { /* get the official internal name or id that the widget was registered with	*/
168
+            if (strtolower($w['name']) === strtolower($widget)) {
169 169
                 $widget_ids[] = $i;
170 170
             }
171 171
             //if ($debug) {echo '<br /> Check: '.$w['name'];}
172 172
         }
173 173
 
174
-        if (! ($sidebarid = shortcodely_get_sidebar_id($sidebar)) ) {
175
-            $sidebarid = $sidebar;     /* get the official sidebar id for this widget area - will take the first one */
174
+        if ( ! ($sidebarid = shortcodely_get_sidebar_id($sidebar))) {
175
+            $sidebarid = $sidebar; /* get the official sidebar id for this widget area - will take the first one */
176 176
         }
177 177
     } else { /* check for id if we do not have a name */
178 178
 
179
-        if (! empty($id) ) {        /* if a specific id has been specified */
180
-            foreach ( $wp_registered_widgets as $i => $w ) { /* get the official internal name or id that the widget was registered with	*/
181
-                if ($w['id'] === $id ) {
179
+        if ( ! empty($id)) {        /* if a specific id has been specified */
180
+            foreach ($wp_registered_widgets as $i => $w) { /* get the official internal name or id that the widget was registered with	*/
181
+                if ($w['id'] === $id) {
182 182
                     $widget_ids[] = $id;
183 183
                 }
184 184
             }
@@ -190,46 +190,46 @@  discard block
 block discarded – undo
190 190
         }
191 191
           // if we have id, get the sidebar for it
192 192
           $sidebarid = shortcodely_get_widgets_sidebar($id);
193
-        if (! $sidebarid ) {
193
+        if ( ! $sidebarid) {
194 194
             $output = '<br />Widget not in any sidebars<br />';
195 195
 
196 196
             return $output;
197 197
         }
198 198
     }
199 199
 
200
-    if (empty($widget) ) {
200
+    if (empty($widget)) {
201 201
         $widget = '';
202 202
     }
203
-    if (empty($id) ) {
203
+    if (empty($id)) {
204 204
         $id = '';
205 205
     }
206 206
 
207
-    if (empty($widget_ids) ) {
207
+    if (empty($widget_ids)) {
208 208
         $output = '<br />Error: Your Requested widget "' . $widget . ' ' . $id . '" is not in the widget list.<br />';
209 209
         $output .= shortcodely_show_widget_debug('empty', $name, $id, $sidebar);
210 210
 
211 211
         return $output;
212 212
     }
213 213
 
214
-    if (empty($widget) ) {
214
+    if (empty($widget)) {
215 215
         $widget = '';
216 216
     }
217 217
 
218 218
     //$content = '';
219 219
     /* if the widget is in our chosen sidebar, then use the options stored for that */
220 220
 
221
-    if (( ! isset($_wp_sidebars_widgets[ $sidebarid ])) or (empty($_wp_sidebars_widgets[ $sidebarid ])) ) { // try upgrade
221
+    if (( ! isset($_wp_sidebars_widgets[$sidebarid])) or (empty($_wp_sidebars_widgets[$sidebarid]))) { // try upgrade
222 222
         shortcodely_upgrade_sidebar();
223 223
     }
224 224
 
225 225
     //if we have a specific sidebar selected, use that
226
-    if ((isset($_wp_sidebars_widgets[ $sidebarid ])) and ( ! empty($_wp_sidebars_widgets[ $sidebarid ])) ) {
226
+    if ((isset($_wp_sidebars_widgets[$sidebarid])) and ( ! empty($_wp_sidebars_widgets[$sidebarid]))) {
227 227
         /* get the intersect of the 2 widget setups so we just get the widget we want	*/
228 228
 
229
-        $wid = array_intersect($_wp_sidebars_widgets[ $sidebarid ], $widget_ids);
229
+        $wid = array_intersect($_wp_sidebars_widgets[$sidebarid], $widget_ids);
230 230
     } else { /* the sidebar is not defined or selected - should not happen */
231
-        if (isset($debug) ) {    // only do this in debug mode
232
-            if (! isset($_wp_sidebars_widgets[ $sidebarid ]) ) {
231
+        if (isset($debug)) {    // only do this in debug mode
232
+            if ( ! isset($_wp_sidebars_widgets[$sidebarid])) {
233 233
                 $output = '<p>Error: Sidebar "' . $sidebar . '" with sidebarid "' . $sidebarid . '" is not defined.</p>';
234 234
             } // shouldnt happen - maybe someone running content filters on save
235 235
             else {
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
     }
240 240
 
241 241
     $output = '';
242
-    if (empty($wid) or ( ! is_array($wid)) or (count($wid) < 1) ) {
242
+    if (empty($wid) or ( ! is_array($wid)) or (count($wid) < 1)) {
243 243
         $output = '<p>Error: Your requested Widget "' . $widget . '" is not in the "' . $sidebar . '" sidebar</p>';
244 244
         $output .= shortcodely_show_widget_debug('empty', $name, $id, $sidebar);
245 245
 
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
     } else {
249 249
         /*	There may only be one but if we have two in our chosen widget then it will do both */
250 250
         $output = '';
251
-        foreach ( $wid as $i => $widget_instance ) {
252
-            ob_start();    /* catch the echo output, so we can control where it appears in the text	*/
251
+        foreach ($wid as $i => $widget_instance) {
252
+            ob_start(); /* catch the echo output, so we can control where it appears in the text	*/
253 253
             shortcodely_shortcode_sidebar($widget_instance, $sidebar, $title, $class, $wrap, $widget_classes);
254 254
             $output .= ob_get_clean();
255 255
         }
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     return $output;
259 259
 }
260 260
 /* -------------------------------------------------------------------------*/
261
-function shortcodely_shortcode_sidebar( $widget_id,
261
+function shortcodely_shortcode_sidebar($widget_id,
262 262
     $name = 'widgets_for_shortcode',
263 263
     $title = true,
264 264
     $class = '',
@@ -274,13 +274,13 @@  discard block
 block discarded – undo
274 274
 
275 275
     $sidebars_widgets = wp_get_sidebars_widgets();
276 276
 
277
-    $sidebar = $wp_registered_sidebars[ $sidebarid ];    // has the params etc
277
+    $sidebar = $wp_registered_sidebars[$sidebarid]; // has the params etc
278 278
 
279 279
     $did_one = false;
280 280
 
281 281
     /* lifted from wordpress code, keep as similar as possible for now */
282 282
 
283
-    if (! isset($wp_registered_widgets[ $widget_id ]) ) {
283
+    if ( ! isset($wp_registered_widgets[$widget_id])) {
284 284
         return;
285 285
     } // wp had c o n t i n u e
286 286
 
@@ -290,25 +290,25 @@  discard block
 block discarded – undo
290 290
                                     $sidebar,
291 291
                                     array(
292 292
                                     'widget_id' => $widget_id,
293
-                                        'widget_name' => $wp_registered_widgets[ $widget_id ]['name'],
293
+                                        'widget_name' => $wp_registered_widgets[$widget_id]['name'],
294 294
                                     )
295 295
                                 ),
296 296
                     ),
297
-                    (array) $wp_registered_widgets[ $widget_id ]['params']
297
+                    (array) $wp_registered_widgets[$widget_id]['params']
298 298
                 );
299 299
 
300
-    $validtitletags = array( 'h1', 'h2', 'h3', 'h4', 'h5', 'header', 'strong', 'em' );
301
-    $validwraptags = array( 'div', 'p', 'main', 'aside', 'section' );
300
+    $validtitletags = array('h1', 'h2', 'h3', 'h4', 'h5', 'header', 'strong', 'em');
301
+    $validwraptags = array('div', 'p', 'main', 'aside', 'section');
302 302
 
303
-    if (! empty($wrap) ) { /* then folks want to 'wrap' with their own html tag, or wrap = yes	*/
304
-        if (( ! in_array($wrap, $validwraptags)) ) {
303
+    if ( ! empty($wrap)) { /* then folks want to 'wrap' with their own html tag, or wrap = yes	*/
304
+        if (( ! in_array($wrap, $validwraptags))) {
305 305
             $wrap = '';
306 306
         }
307 307
         /* To match a variety of themes, allow for a variety of html tags. */
308 308
         /* May not need if our sidebar match attempt has worked */
309 309
     }
310 310
 
311
-    if (! empty($wrap) ) {
311
+    if ( ! empty($wrap)) {
312 312
         $params[0]['before_widget'] = '<' . $wrap . ' id="%1$s" class="%2$s">';
313 313
         $params[0]['after_widget'] = '</' . $wrap . '>';
314 314
     }
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
                 // wp code to get classname
317 317
                 $classname_ = '';
318 318
                 //foreach ( (array) $wp_registered_widgets[$widget_id]['classname'] as $cn ) {
319
-                        $cn = $wp_registered_widgets[ $widget_id ]['classname'];
320
-    if (is_string($cn) ) {
319
+                        $cn = $wp_registered_widgets[$widget_id]['classname'];
320
+    if (is_string($cn)) {
321 321
         $classname_ .= '_' . $cn;
322
-    } elseif (is_object($cn) ) {
322
+    } elseif (is_object($cn)) {
323 323
         $classname_ .= '_' . get_class($cn);
324 324
     }
325 325
                 //}
@@ -335,25 +335,25 @@  discard block
 block discarded – undo
335 335
                 // we are picking up the defaults from the	thems sidebar ad they have registered heir sidebar to issue widget classes?
336 336
 
337 337
                 // Substitute HTML id and class attributes into before_widget
338
-    if (! empty($params[0]['before_widget']) ) {
338
+    if ( ! empty($params[0]['before_widget'])) {
339 339
         $params[0]['before_widget'] = sprintf($params[0]['before_widget'], $widget_id, $classname_);
340 340
     } else {
341 341
         $params[0]['before_widget'] = '';
342 342
     }
343 343
 
344
-    if (empty($params[0]['before_widget']) ) {
344
+    if (empty($params[0]['before_widget'])) {
345 345
         $params[0]['after_widget'] = '';
346 346
     }
347 347
 
348 348
     $params = apply_filters('dynamic_sidebar_params', $params);
349 349
                 // allow, any pne usingmust ensure they apply to the correct sidebars
350 350
 
351
-    if (! empty($title) ) {
352
-        if ($title == 'false' ) { /* shortcodely switch off the title html, still need to get rid of title separately */
351
+    if ( ! empty($title)) {
352
+        if ($title == 'false') { /* shortcodely switch off the title html, still need to get rid of title separately */
353 353
             $params[0]['before_title'] = '<span style="display: none">';
354 354
             $params[0]['after_title'] = '</span>';
355 355
         } else {
356
-            if (in_array($title, $validtitletags) ) {
356
+            if (in_array($title, $validtitletags)) {
357 357
                 $class = ' class="widget-title" ';
358 358
 
359 359
                 $params[0]['before_title'] = '<' . $title . ' ' . $class . ' >';
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
         }
363 363
     }
364 364
 
365
-    if (! empty($widget_classes) and ($widget_classes == 'none') ) {
366
-        $params = shortcodely_remove_widget_class($params);    // also called in widget area shortcode
365
+    if ( ! empty($widget_classes) and ($widget_classes == 'none')) {
366
+        $params = shortcodely_remove_widget_class($params); // also called in widget area shortcode
367 367
     }
368 368
 
369
-    $callback = $wp_registered_widgets[ $widget_id ]['callback'];
370
-    if (is_callable($callback) ) {
369
+    $callback = $wp_registered_widgets[$widget_id]['callback'];
370
+    if (is_callable($callback)) {
371 371
         call_user_func_array($callback, $params);
372 372
         $did_one = true;
373 373
     }
@@ -381,19 +381,19 @@  discard block
 block discarded – undo
381 381
 
382 382
     global $wp_registered_widgets, $_wp_sidebars_widgets, $wp_registered_sidebars;
383 383
 
384
-    if (function_exists('register_sidebar') ) {    // maybe later, get the first main sidebar and copy it's before/after etc
384
+    if (function_exists('register_sidebar')) {    // maybe later, get the first main sidebar and copy it's before/after etc
385 385
         $args = array(
386 386
         'name' => 'Widgets for Shortcodes',
387
-        'id' => 'widgets_for_shortcodes',    // hope to avoid losing widgets
387
+        'id' => 'widgets_for_shortcodes', // hope to avoid losing widgets
388 388
         'description' => __('Sidebar to hold widgets and their settings. These widgets will be used in a shortcode.	This sidebars widgets should be saved with your theme settings now.', 'shortcodely-shortcode-any-widget'),
389
-        'before_widget' => '<aside' . ' id="%1$s" class="%2$s ">',    // 201402 to match twentyfourteen theme
389
+        'before_widget' => '<aside' . ' id="%1$s" class="%2$s ">', // 201402 to match twentyfourteen theme
390 390
         'after_widget' => '</aside>',
391 391
         'before_title' => '<h1 class="widget-title" >', // 201402 maybe dont use widget class - we are in content here not in a widget area but others want the widget styling. ?
392 392
         'after_title' => '</h1>',
393 393
         );
394 394
 
395
-        if (! empty($wp_registered_sidebars) ) {    // we got some sidebars already.
396
-               $main_sidebar = reset($wp_registered_sidebars);    // Grab the first sidebar and use that as defaults for the widgets
395
+        if ( ! empty($wp_registered_sidebars)) {    // we got some sidebars already.
396
+               $main_sidebar = reset($wp_registered_sidebars); // Grab the first sidebar and use that as defaults for the widgets
397 397
                $args['before_widget'] = $main_sidebar['before_widget'];
398 398
                $args['after_widget'] = $main_sidebar['after_widget'];
399 399
                $args['before_title'] = $main_sidebar['before_title'];
@@ -409,17 +409,17 @@  discard block
 block discarded – undo
409 409
 require 'shortcodely-admin-form-html.php';
410 410
 require 'shortcodely-utilities.php';
411 411
 
412
-if (is_admin() ) {
412
+if (is_admin()) {
413 413
     $shortcodely_saw_plugin_admin = new shortcodely_saw_plugin_admin();
414 414
 }
415 415
 
416
-add_action('widgets_init',                'shortcodely_reg_sidebar', 98);     // register late so it appears last
416
+add_action('widgets_init', 'shortcodely_reg_sidebar', 98); // register late so it appears last
417 417
 
418
-add_action('switch_theme',                        'shortcodely_save_shortcodes_sidebar');
419
-add_action('after_switch_theme',        'shortcodely_restore_shortcodes_sidebar');
418
+add_action('switch_theme', 'shortcodely_save_shortcodes_sidebar');
419
+add_action('after_switch_theme', 'shortcodely_restore_shortcodes_sidebar');
420 420
 
421
-add_shortcode('do_widget',                'shortcodely_do_widget');
422
-add_shortcode('do_widget_area', 'shortcodely_do_widget_area');    // just dump the whole widget area - to get same styling
421
+add_shortcode('do_widget', 'shortcodely_do_widget');
422
+add_shortcode('do_widget_area', 'shortcodely_do_widget_area'); // just dump the whole widget area - to get same styling
423 423
 
424 424
 //require_once(ABSPATH . 'wp-includes/widgets.php');	 // *** do we really need this here?
425 425
 function shortcodely_saw_load_text() 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 
436 436
 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'shortcodely_add_action_links');
437 437
 
438
-function shortcodely_add_action_links( $links ) 
438
+function shortcodely_add_action_links($links) 
439 439
 {
440 440
     $mylinks[] =
441 441
     '<a title="Haven\'t read the instructions? Need your hand held?" href="' . admin_url('options-general.php?page=shortcodely_saw') . '">Settings</a>';
Please login to merge, or discard this patch.