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