@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * @param array $_api_data Optional data to send with API calls. |
27 | 27 | * @return void |
28 | 28 | */ |
29 | - function __construct( $_api_url, $_plugin_file, $_api_data = null ) { |
|
30 | - $this->api_url = trailingslashit( $_api_url ); |
|
29 | + function __construct($_api_url, $_plugin_file, $_api_data = null) { |
|
30 | + $this->api_url = trailingslashit($_api_url); |
|
31 | 31 | $this->api_data = $_api_data; |
32 | - $this->name = plugin_basename( $_plugin_file ); |
|
33 | - $this->slug = basename( $_plugin_file, '.php' ); |
|
32 | + $this->name = plugin_basename($_plugin_file); |
|
33 | + $this->slug = basename($_plugin_file, '.php'); |
|
34 | 34 | $this->version = $_api_data['version']; |
35 | 35 | |
36 | 36 | // Set up hooks. |
37 | 37 | $this->init(); |
38 | - add_action( 'admin_init', array( $this, 'show_changelog' ) ); |
|
38 | + add_action('admin_init', array($this, 'show_changelog')); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function init() { |
49 | 49 | |
50 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
51 | - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
|
50 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
51 | + add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3); |
|
52 | 52 | |
53 | - add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); |
|
53 | + add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -66,34 +66,34 @@ discard block |
||
66 | 66 | * @param array $_transient_data Update array build by WordPress. |
67 | 67 | * @return array Modified update array with custom plugin data. |
68 | 68 | */ |
69 | - function check_update( $_transient_data ) { |
|
69 | + function check_update($_transient_data) { |
|
70 | 70 | |
71 | 71 | global $pagenow; |
72 | 72 | |
73 | - if ( ! is_object( $_transient_data ) ) { |
|
73 | + if (!is_object($_transient_data)) { |
|
74 | 74 | $_transient_data = new stdClass; |
75 | 75 | } |
76 | 76 | |
77 | - if ( 'plugins.php' == $pagenow && is_multisite() ) { |
|
77 | + if ('plugins.php' == $pagenow && is_multisite()) { |
|
78 | 78 | return $_transient_data; |
79 | 79 | } |
80 | 80 | |
81 | - if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) { |
|
81 | + if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) { |
|
82 | 82 | |
83 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
83 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
84 | 84 | |
85 | - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { |
|
85 | + if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) { |
|
86 | 86 | |
87 | 87 | $this->did_check = true; |
88 | 88 | |
89 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
89 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
90 | 90 | |
91 | - $_transient_data->response[ $this->name ] = $version_info; |
|
91 | + $_transient_data->response[$this->name] = $version_info; |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | |
95 | 95 | $_transient_data->last_checked = time(); |
96 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
96 | + $_transient_data->checked[$this->name] = $this->version; |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -108,84 +108,84 @@ discard block |
||
108 | 108 | * @param string $file |
109 | 109 | * @param array $plugin |
110 | 110 | */ |
111 | - public function show_update_notification( $file, $plugin ) { |
|
111 | + public function show_update_notification($file, $plugin) { |
|
112 | 112 | |
113 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
113 | + if (!current_user_can('update_plugins')) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | - if ( ! is_multisite() ) { |
|
117 | + if (!is_multisite()) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | - if ( $this->name != $file ) { |
|
121 | + if ($this->name != $file) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Remove our filter on the site transient |
126 | - remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 ); |
|
126 | + remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10); |
|
127 | 127 | |
128 | - $update_cache = get_site_transient( 'update_plugins' ); |
|
128 | + $update_cache = get_site_transient('update_plugins'); |
|
129 | 129 | |
130 | - if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) { |
|
130 | + if (!is_object($update_cache) || empty($update_cache->response) || empty($update_cache->response[$this->name])) { |
|
131 | 131 | |
132 | - $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' ); |
|
133 | - $version_info = get_transient( $cache_key ); |
|
132 | + $cache_key = md5('edd_plugin_'.sanitize_key($this->name).'_version_info'); |
|
133 | + $version_info = get_transient($cache_key); |
|
134 | 134 | |
135 | - if ( false === $version_info ) { |
|
135 | + if (false === $version_info) { |
|
136 | 136 | |
137 | - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) ); |
|
137 | + $version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug)); |
|
138 | 138 | |
139 | - set_transient( $cache_key, $version_info, 3600 ); |
|
139 | + set_transient($cache_key, $version_info, 3600); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | - if ( ! is_object( $version_info ) ) { |
|
143 | + if (!is_object($version_info)) { |
|
144 | 144 | return; |
145 | 145 | } |
146 | 146 | |
147 | - if ( version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
147 | + if (version_compare($this->version, $version_info->new_version, '<')) { |
|
148 | 148 | |
149 | - $update_cache->response[ $this->name ] = $version_info; |
|
149 | + $update_cache->response[$this->name] = $version_info; |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
153 | 153 | $update_cache->last_checked = time(); |
154 | - $update_cache->checked[ $this->name ] = $this->version; |
|
154 | + $update_cache->checked[$this->name] = $this->version; |
|
155 | 155 | |
156 | - set_site_transient( 'update_plugins', $update_cache ); |
|
156 | + set_site_transient('update_plugins', $update_cache); |
|
157 | 157 | |
158 | 158 | } else { |
159 | 159 | |
160 | - $version_info = $update_cache->response[ $this->name ]; |
|
160 | + $version_info = $update_cache->response[$this->name]; |
|
161 | 161 | |
162 | 162 | } |
163 | 163 | |
164 | 164 | // Restore our filter |
165 | - add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) ); |
|
165 | + add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update')); |
|
166 | 166 | |
167 | - if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) { |
|
167 | + if (!empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) { |
|
168 | 168 | |
169 | 169 | // build a plugin list row, with update notification |
170 | - $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
171 | - echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">'; |
|
170 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
171 | + echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">'; |
|
172 | 172 | |
173 | - $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' ); |
|
173 | + $changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911'); |
|
174 | 174 | |
175 | - if ( empty( $version_info->download_link ) ) { |
|
175 | + if (empty($version_info->download_link)) { |
|
176 | 176 | printf( |
177 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'lasso' ), |
|
178 | - esc_html( $version_info->name ), |
|
179 | - esc_url( $changelog_link ), |
|
180 | - esc_html( $version_info->new_version ) |
|
177 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'lasso'), |
|
178 | + esc_html($version_info->name), |
|
179 | + esc_url($changelog_link), |
|
180 | + esc_html($version_info->new_version) |
|
181 | 181 | ); |
182 | 182 | } else { |
183 | 183 | printf( |
184 | - __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'lasso' ), |
|
185 | - esc_html( $version_info->name ), |
|
186 | - esc_url( $changelog_link ), |
|
187 | - esc_html( $version_info->new_version ), |
|
188 | - esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) |
|
184 | + __('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'lasso'), |
|
185 | + esc_html($version_info->name), |
|
186 | + esc_url($changelog_link), |
|
187 | + esc_html($version_info->new_version), |
|
188 | + esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name)) |
|
189 | 189 | ); |
190 | 190 | } |
191 | 191 | |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | * @param object $_args |
205 | 205 | * @return object $_data |
206 | 206 | */ |
207 | - function plugins_api_filter( $_data, $_action = '', $_args = null ) { |
|
207 | + function plugins_api_filter($_data, $_action = '', $_args = null) { |
|
208 | 208 | |
209 | 209 | |
210 | - if ( $_action != 'plugin_information' ) { |
|
210 | + if ($_action != 'plugin_information') { |
|
211 | 211 | |
212 | 212 | return $_data; |
213 | 213 | |
214 | 214 | } |
215 | 215 | |
216 | - if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) { |
|
216 | + if (!isset($_args->slug) || ($_args->slug != $this->slug)) { |
|
217 | 217 | |
218 | 218 | return $_data; |
219 | 219 | |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | ) |
229 | 229 | ); |
230 | 230 | |
231 | - $api_response = $this->api_request( 'plugin_information', $to_send ); |
|
231 | + $api_response = $this->api_request('plugin_information', $to_send); |
|
232 | 232 | |
233 | - if ( false !== $api_response ) { |
|
233 | + if (false !== $api_response) { |
|
234 | 234 | $_data = $api_response; |
235 | 235 | } |
236 | 236 | |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | * @param string $url |
246 | 246 | * @return object $array |
247 | 247 | */ |
248 | - function http_request_args( $args, $url ) { |
|
248 | + function http_request_args($args, $url) { |
|
249 | 249 | // If it is an https request and we are performing a package download, disable ssl verification |
250 | - if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) { |
|
250 | + if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) { |
|
251 | 251 | $args['sslverify'] = false; |
252 | 252 | } |
253 | 253 | return $args; |
@@ -264,40 +264,40 @@ discard block |
||
264 | 264 | * @param array $_data Parameters for the API action. |
265 | 265 | * @return false||object |
266 | 266 | */ |
267 | - private function api_request( $_action, $_data ) { |
|
267 | + private function api_request($_action, $_data) { |
|
268 | 268 | |
269 | 269 | global $wp_version; |
270 | 270 | |
271 | - $data = array_merge( $this->api_data, $_data ); |
|
271 | + $data = array_merge($this->api_data, $_data); |
|
272 | 272 | |
273 | - if ( $data['slug'] != $this->slug ) |
|
273 | + if ($data['slug'] != $this->slug) |
|
274 | 274 | return; |
275 | 275 | |
276 | - if ( empty( $data['license'] ) ) |
|
276 | + if (empty($data['license'])) |
|
277 | 277 | return; |
278 | 278 | |
279 | - if ( $this->api_url == home_url() ) { |
|
279 | + if ($this->api_url == home_url()) { |
|
280 | 280 | return false; // Don't allow a plugin to ping itself |
281 | 281 | } |
282 | 282 | |
283 | 283 | $api_params = array( |
284 | 284 | 'edd_action' => 'get_version', |
285 | 285 | 'license' => $data['license'], |
286 | - 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false, |
|
287 | - 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false, |
|
286 | + 'item_name' => isset($data['item_name']) ? $data['item_name'] : false, |
|
287 | + 'item_id' => isset($data['item_id']) ? $data['item_id'] : false, |
|
288 | 288 | 'slug' => $data['slug'], |
289 | 289 | 'author' => $data['author'], |
290 | 290 | 'url' => home_url() |
291 | 291 | ); |
292 | 292 | |
293 | - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) ); |
|
293 | + $request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params)); |
|
294 | 294 | |
295 | - if ( ! is_wp_error( $request ) ) { |
|
296 | - $request = json_decode( wp_remote_retrieve_body( $request ) ); |
|
295 | + if (!is_wp_error($request)) { |
|
296 | + $request = json_decode(wp_remote_retrieve_body($request)); |
|
297 | 297 | } |
298 | 298 | |
299 | - if ( $request && isset( $request->sections ) ) { |
|
300 | - $request->sections = maybe_unserialize( $request->sections ); |
|
299 | + if ($request && isset($request->sections)) { |
|
300 | + $request->sections = maybe_unserialize($request->sections); |
|
301 | 301 | } else { |
302 | 302 | $request = false; |
303 | 303 | } |
@@ -308,26 +308,26 @@ discard block |
||
308 | 308 | public function show_changelog() { |
309 | 309 | |
310 | 310 | |
311 | - if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { |
|
311 | + if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) { |
|
312 | 312 | return; |
313 | 313 | } |
314 | 314 | |
315 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
315 | + if (empty($_REQUEST['plugin'])) { |
|
316 | 316 | return; |
317 | 317 | } |
318 | 318 | |
319 | - if ( empty( $_REQUEST['slug'] ) ) { |
|
319 | + if (empty($_REQUEST['slug'])) { |
|
320 | 320 | return; |
321 | 321 | } |
322 | 322 | |
323 | - if ( ! current_user_can( 'update_plugins' ) ) { |
|
324 | - wp_die( __( 'You do not have permission to install plugin updates', 'lasso' ), __( 'Error', 'lasso' ), array( 'response' => 403 ) ); |
|
323 | + if (!current_user_can('update_plugins')) { |
|
324 | + wp_die(__('You do not have permission to install plugin updates', 'lasso'), __('Error', 'lasso'), array('response' => 403)); |
|
325 | 325 | } |
326 | 326 | |
327 | - $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) ); |
|
327 | + $response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug'])); |
|
328 | 328 | |
329 | - if ( $response && isset( $response->sections['changelog'] ) ) { |
|
330 | - echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>'; |
|
329 | + if ($response && isset($response->sections['changelog'])) { |
|
330 | + echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>'; |
|
331 | 331 | } |
332 | 332 | |
333 | 333 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /*----------------------------------------------------------------------------* |
10 | 10 | * Register Autoloader |
11 | 11 | *----------------------------------------------------------------------------*/ |
12 | -include_once( LASSO_DIR . '/includes/lasso_autoloader.php' ); |
|
12 | +include_once(LASSO_DIR.'/includes/lasso_autoloader.php'); |
|
13 | 13 | $loader = new lasso_autoloader(); |
14 | 14 | |
15 | 15 | $loader->register(); |
@@ -19,19 +19,19 @@ discard block |
||
19 | 19 | *----------------------------------------------------------------------------*/ |
20 | 20 | //require_once plugin_dir_path( __FILE__ ) . 'public/class-lasso.php'; |
21 | 21 | |
22 | -$loader->addNamespace('lasso', LASSO_DIR . 'includes' ); |
|
23 | -$loader->addNamespace('lasso_public_facing', LASSO_DIR . 'public/includes' ); |
|
24 | -$loader->addNamespace('lasso\internal_api', LASSO_DIR . 'internal-api' ); |
|
22 | +$loader->addNamespace('lasso', LASSO_DIR.'includes'); |
|
23 | +$loader->addNamespace('lasso_public_facing', LASSO_DIR.'public/includes'); |
|
24 | +$loader->addNamespace('lasso\internal_api', LASSO_DIR.'internal-api'); |
|
25 | 25 | new lasso\internal_api\end_points(); |
26 | 26 | |
27 | -register_activation_hook( __FILE__, array( 'lasso_public_facing\lasso', 'activate' ) ); |
|
28 | -register_deactivation_hook( __FILE__, array( 'lasso_public_facing\lasso', 'deactivate' ) ); |
|
27 | +register_activation_hook(__FILE__, array('lasso_public_facing\lasso', 'activate')); |
|
28 | +register_deactivation_hook(__FILE__, array('lasso_public_facing\lasso', 'deactivate')); |
|
29 | 29 | |
30 | -add_action( 'plugins_loaded', array( 'lasso_public_facing\lasso', 'get_instance' ) ); |
|
30 | +add_action('plugins_loaded', array('lasso_public_facing\lasso', 'get_instance')); |
|
31 | 31 | |
32 | 32 | //load tour |
33 | -add_action( 'init', function() { |
|
34 | - if (! is_admin() && is_user_logged_in() ) { |
|
33 | +add_action('init', function() { |
|
34 | + if (!is_admin() && is_user_logged_in()) { |
|
35 | 35 | new \lasso_public_facing\tour(); |
36 | 36 | } |
37 | 37 | }); |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * Dashboard and Administrative Functionality |
42 | 42 | *----------------------------------------------------------------------------*/ |
43 | 43 | |
44 | -if ( is_admin() ) { |
|
45 | - $loader->addNamespace('lasso_admin', LASSO_DIR . 'admin/includes' ); |
|
46 | - add_action( 'plugins_loaded', array( 'lasso_admin\load_admin', 'get_instance' ) ); |
|
44 | +if (is_admin()) { |
|
45 | + $loader->addNamespace('lasso_admin', LASSO_DIR.'admin/includes'); |
|
46 | + add_action('plugins_loaded', array('lasso_admin\load_admin', 'get_instance')); |
|
47 | 47 | |
48 | 48 | } |
@@ -40,10 +40,10 @@ |
||
40 | 40 | */ |
41 | 41 | public function addNamespace($prefix, $base_dir, $prepend = false) { |
42 | 42 | // normalize namespace prefix |
43 | - $prefix = trim($prefix, '\\') . '\\'; |
|
43 | + $prefix = trim($prefix, '\\').'\\'; |
|
44 | 44 | |
45 | 45 | // normalize the base directory with a trailing separator |
46 | - $base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/'; |
|
46 | + $base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR).'/'; |
|
47 | 47 | |
48 | 48 | // initialize the namespace prefix array |
49 | 49 | if (isset($this->prefixes[$prefix]) === false) { |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @since 1.0 |
27 | 27 | */ |
28 | - public function post( $data ) { |
|
28 | + public function post($data) { |
|
29 | 29 | |
30 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
30 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
31 | 31 | |
32 | 32 | // bail out if teh current user can't publish posts |
33 | - if ( !lasso_user_can( 'delete_post', $postid ) ) |
|
33 | + if (!lasso_user_can('delete_post', $postid)) |
|
34 | 34 | return; |
35 | 35 | |
36 | 36 | $args = array( |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | 'post_status' => 'trash' |
39 | 39 | ); |
40 | 40 | |
41 | - wp_update_post( apply_filters( 'lasso_object_deleted_args', $args ) ); |
|
41 | + wp_update_post(apply_filters('lasso_object_deleted_args', $args)); |
|
42 | 42 | |
43 | - do_action( 'lasso_object_deleted', $postid, get_current_user_ID() ); |
|
43 | + do_action('lasso_object_deleted', $postid, get_current_user_ID()); |
|
44 | 44 | |
45 | 45 | return true; |
46 | 46 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
54 | 54 | */ |
55 | - public static function params(){ |
|
56 | - $params[ 'process_delete_post' ] = array( |
|
55 | + public static function params() { |
|
56 | + $params['process_delete_post'] = array( |
|
57 | 57 | 'postid' => 'absint', |
58 | 58 | ); |
59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array Array of additional functions to use to authorize action. |
69 | 69 | */ |
70 | 70 | public static function auth_callbacks() { |
71 | - $params[ 'process_delete_post' ] = array( |
|
71 | + $params['process_delete_post'] = array( |
|
72 | 72 | 'lasso_user_can' |
73 | 73 | ); |
74 | 74 |
@@ -27,17 +27,17 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return array |
29 | 29 | */ |
30 | - public static function get( $data ) { |
|
30 | + public static function get($data) { |
|
31 | 31 | $args = array(); |
32 | - if ( isset( $data[ 'limit' ] ) ) { |
|
33 | - $args[ 'posts_per_page' ] = $data[ 'limit' ]; |
|
34 | - }else{ |
|
35 | - $args[ 'posts_per_page' ] = 6; // we start at revision 0 |
|
32 | + if (isset($data['limit'])) { |
|
33 | + $args['posts_per_page'] = $data['limit']; |
|
34 | + } else { |
|
35 | + $args['posts_per_page'] = 6; // we start at revision 0 |
|
36 | 36 | } |
37 | 37 | |
38 | - $revisions = wp_get_post_revisions( $data[ 'postid' ], $args ); |
|
39 | - if ( is_array( $revisions ) && ! empty( $revisions ) ) { |
|
40 | - self::set_revisions( $data[ 'postid' ], $revisions ); |
|
38 | + $revisions = wp_get_post_revisions($data['postid'], $args); |
|
39 | + if (is_array($revisions) && !empty($revisions)) { |
|
40 | + self::set_revisions($data['postid'], $revisions); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return self::$revisions; |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @param int $id The post ID to get the revisions for |
54 | 54 | * @param obj $revisions The revisions for this post |
55 | 55 | */ |
56 | - protected static function set_revisions( $id, $revisions ) { |
|
56 | + protected static function set_revisions($id, $revisions) { |
|
57 | 57 | |
58 | - array_walk( $revisions, function ( $post, $i ) { |
|
58 | + array_walk($revisions, function($post, $i) { |
|
59 | 59 | self::$revisions[] = array( |
60 | 60 | 'post_content' => $post->post_content, |
61 | 61 | 'post_title' => $post->post_title, |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
75 | 75 | */ |
76 | - public static function params(){ |
|
77 | - $params[ 'process_revision_get' ] = array( |
|
76 | + public static function params() { |
|
77 | + $params['process_revision_get'] = array( |
|
78 | 78 | 'postid' => 'absint', |
79 | 79 | 'limit' => 'absint' |
80 | 80 | ); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return array Array of additional functions to use to authorize action. |
91 | 91 | */ |
92 | 92 | public static function auth_callbacks() { |
93 | - $params[ 'process_revision_get' ] = array( |
|
93 | + $params['process_revision_get'] = array( |
|
94 | 94 | 'lasso_user_can' |
95 | 95 | ); |
96 | 96 |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool Always returns true. |
30 | 30 | */ |
31 | - public function post( $data ) { |
|
31 | + public function post($data) { |
|
32 | 32 | |
33 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
34 | - $title = isset( $data['title'] ) ? $data['title'] : false; |
|
33 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
34 | + $title = isset($data['title']) ? $data['title'] : false; |
|
35 | 35 | |
36 | 36 | $args = array( |
37 | 37 | 'ID' => (int) $postid, |
38 | - 'post_title' => wp_strip_all_tags( $title ) |
|
38 | + 'post_title' => wp_strip_all_tags($title) |
|
39 | 39 | ); |
40 | 40 | |
41 | - wp_update_post( apply_filters( 'lasso_title_updated_args', $args ) ); |
|
41 | + wp_update_post(apply_filters('lasso_title_updated_args', $args)); |
|
42 | 42 | |
43 | - do_action( 'lasso_title_updated', $postid, $title, get_current_user_ID() ); |
|
43 | + do_action('lasso_title_updated', $postid, $title, get_current_user_ID()); |
|
44 | 44 | |
45 | 45 | return true; |
46 | 46 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return array Array of keys to pull from $data per action and their sanitization callback |
55 | 55 | */ |
56 | - public static function params(){ |
|
57 | - $params[ 'process_title_update_post' ] = array( |
|
56 | + public static function params() { |
|
57 | + $params['process_title_update_post'] = array( |
|
58 | 58 | 'postid' => 'absint', |
59 | 59 | 'title' => 'strip_tags' |
60 | 60 | ); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return array Array of additional functions to use to authorize action. |
72 | 72 | */ |
73 | 73 | public static function auth_callbacks() { |
74 | - $params[ 'process_title_update_post' ] = array( |
|
74 | + $params['process_title_update_post'] = array( |
|
75 | 75 | 'lasso_user_can' |
76 | 76 | ); |
77 | 77 |
@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @returns bool Always returns true |
28 | 28 | */ |
29 | - public function hide( $data ) { |
|
29 | + public function hide($data) { |
|
30 | 30 | |
31 | 31 | $user_id = get_current_user_ID(); |
32 | 32 | |
33 | - update_user_meta( $user_id, 'lasso_hide_tour', true ); |
|
33 | + update_user_meta($user_id, 'lasso_hide_tour', true); |
|
34 | 34 | |
35 | - do_action( 'lasso_tour_hidden', $user_id ); |
|
35 | + do_action('lasso_tour_hidden', $user_id); |
|
36 | 36 | |
37 | 37 | return true; |
38 | 38 | |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
47 | 47 | */ |
48 | - public static function params(){ |
|
49 | - $params[ 'process_tour_hide' ] = array( |
|
48 | + public static function params() { |
|
49 | + $params['process_tour_hide'] = array( |
|
50 | 50 | 'action' |
51 | 51 | ); |
52 | 52 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return array Array of additional functions to use to authorize action. |
62 | 62 | */ |
63 | 63 | public static function auth_callbacks() { |
64 | - $params[ 'process_tour_hide' ] = array( |
|
64 | + $params['process_tour_hide'] = array( |
|
65 | 65 | 'lasso_user_can' |
66 | 66 | ); |
67 | 67 |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool Always returns true. |
30 | 30 | */ |
31 | - public function upload( $data ) { |
|
31 | + public function upload($data) { |
|
32 | 32 | |
33 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
34 | - $image_id = isset( $data['image_id'] ) ? absint( $data['image_id'] ) : false; |
|
33 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
34 | + $image_id = isset($data['image_id']) ? absint($data['image_id']) : false; |
|
35 | 35 | |
36 | - set_post_thumbnail( $postid, $image_id ); |
|
36 | + set_post_thumbnail($postid, $image_id); |
|
37 | 37 | |
38 | - do_action( 'lasso_featured_image_set', $postid, $image_id, get_current_user_ID() ); |
|
38 | + do_action('lasso_featured_image_set', $postid, $image_id, get_current_user_ID()); |
|
39 | 39 | |
40 | 40 | return true; |
41 | 41 | |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @return bool Always returns true. |
52 | 52 | */ |
53 | - public function delete( $data ) { |
|
53 | + public function delete($data) { |
|
54 | 54 | |
55 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
55 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
56 | 56 | |
57 | - delete_post_thumbnail( $postid ); |
|
57 | + delete_post_thumbnail($postid); |
|
58 | 58 | |
59 | - do_action( 'lasso_featured_image_deleted', $postid, get_current_user_ID() ); |
|
59 | + do_action('lasso_featured_image_deleted', $postid, get_current_user_ID()); |
|
60 | 60 | |
61 | 61 | return true; |
62 | 62 | |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return array Array of keys to pull from $data per action and their sanitization callback |
71 | 71 | */ |
72 | - public static function params(){ |
|
73 | - $params[ 'process_upload_image_upload' ] = array( |
|
72 | + public static function params() { |
|
73 | + $params['process_upload_image_upload'] = array( |
|
74 | 74 | 'postid' => 'absint', |
75 | 75 | 'image_id' => 'absint' |
76 | 76 | ); |
77 | 77 | |
78 | - $params[ 'process_upload_image_delete' ] = array( |
|
78 | + $params['process_upload_image_delete'] = array( |
|
79 | 79 | 'postid' => 'absint', |
80 | 80 | ); |
81 | 81 |
@@ -28,11 +28,11 @@ discard block |
||
28 | 28 | * @since 1.1.10 |
29 | 29 | * |
30 | 30 | */ |
31 | - public static function do_sanitize( $input, $params = array() ) { |
|
31 | + public static function do_sanitize($input, $params = array()) { |
|
32 | 32 | |
33 | - $input = stripslashes_deep( $input ); |
|
33 | + $input = stripslashes_deep($input); |
|
34 | 34 | |
35 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
35 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
36 | 36 | return $input; |
37 | 37 | } |
38 | 38 | |
@@ -43,45 +43,45 @@ discard block |
||
43 | 43 | 'type' => null // %s %d %f etc |
44 | 44 | ); |
45 | 45 | |
46 | - if ( !is_array( $params ) ) { |
|
47 | - $defaults[ 'type' ] = $params; |
|
46 | + if (!is_array($params)) { |
|
47 | + $defaults['type'] = $params; |
|
48 | 48 | |
49 | 49 | $params = $defaults; |
50 | 50 | } |
51 | 51 | else { |
52 | - $params = array_merge( $defaults, (array) $params ); |
|
52 | + $params = array_merge($defaults, (array) $params); |
|
53 | 53 | } |
54 | 54 | |
55 | - if ( is_object( $input ) ) { |
|
56 | - $input = get_object_vars( $input ); |
|
55 | + if (is_object($input)) { |
|
56 | + $input = get_object_vars($input); |
|
57 | 57 | |
58 | 58 | $n_params = $params; |
59 | - $n_params[ 'nested' ] = true; |
|
59 | + $n_params['nested'] = true; |
|
60 | 60 | |
61 | - foreach ( $input as $key => $val ) { |
|
62 | - $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
|
61 | + foreach ($input as $key => $val) { |
|
62 | + $output[self::do_sanitize($key)] = self::do_sanitize($val, $n_params); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $output = (object) $output; |
66 | 66 | } |
67 | - elseif ( is_array( $input ) ) { |
|
67 | + elseif (is_array($input)) { |
|
68 | 68 | $n_params = $params; |
69 | - $n_params[ 'nested' ] = true; |
|
69 | + $n_params['nested'] = true; |
|
70 | 70 | |
71 | - foreach ( $input as $key => $val ) { |
|
72 | - $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
|
71 | + foreach ($input as $key => $val) { |
|
72 | + $output[self::do_sanitize($key)] = self::do_sanitize($val, $n_params); |
|
73 | 73 | } |
74 | 74 | } |
75 | - elseif ( !empty( $params[ 'type' ] ) && false !== strpos( $params[ 'type' ], '%' ) ) { |
|
75 | + elseif (!empty($params['type']) && false !== strpos($params['type'], '%')) { |
|
76 | 76 | /** |
77 | 77 | * @var $wpdb wpdb |
78 | 78 | */ |
79 | 79 | global $wpdb; |
80 | 80 | |
81 | - $output = $wpdb->prepare( $params[ 'type' ], $output ); |
|
81 | + $output = $wpdb->prepare($params['type'], $output); |
|
82 | 82 | } |
83 | 83 | else { |
84 | - $output = wp_slash( $input ); |
|
84 | + $output = wp_slash($input); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | return $output; |
@@ -99,38 +99,38 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @see like_escape |
101 | 101 | */ |
102 | - public static function sanitize_like( $input ) { |
|
102 | + public static function sanitize_like($input) { |
|
103 | 103 | |
104 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
104 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
105 | 105 | return $input; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $output = array(); |
109 | 109 | |
110 | - if ( is_object( $input ) ) { |
|
111 | - $input = get_object_vars( $input ); |
|
110 | + if (is_object($input)) { |
|
111 | + $input = get_object_vars($input); |
|
112 | 112 | |
113 | - foreach ( $input as $key => $val ) { |
|
114 | - $output[ $key ] = self::sanitize_like( $val ); |
|
113 | + foreach ($input as $key => $val) { |
|
114 | + $output[$key] = self::sanitize_like($val); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $output = (object) $output; |
118 | 118 | } |
119 | - elseif ( is_array( $input ) ) { |
|
120 | - foreach ( $input as $key => $val ) { |
|
121 | - $output[ $key ] = self::sanitize_like( $val ); |
|
119 | + elseif (is_array($input)) { |
|
120 | + foreach ($input as $key => $val) { |
|
121 | + $output[$key] = self::sanitize_like($val); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | else { |
125 | 125 | global $wpdb; |
126 | 126 | |
127 | 127 | //backwords-compat check for pre WP4.0 |
128 | - if ( method_exists( 'wpdb', 'esc_like' ) ) { |
|
129 | - $output = $wpdb->esc_like( self::do_sanitize( $input ) ); |
|
128 | + if (method_exists('wpdb', 'esc_like')) { |
|
129 | + $output = $wpdb->esc_like(self::do_sanitize($input)); |
|
130 | 130 | } |
131 | 131 | else { |
132 | 132 | // like_escape is deprecated in WordPress 4.0 |
133 | - $output = like_escape( self::do_sanitize( $input ) ); |
|
133 | + $output = like_escape(self::do_sanitize($input)); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -150,33 +150,33 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @see wp_unslash |
152 | 152 | */ |
153 | - public static function unslash( $input ) { |
|
153 | + public static function unslash($input) { |
|
154 | 154 | |
155 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
155 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
156 | 156 | return $input; |
157 | 157 | } |
158 | 158 | |
159 | 159 | $output = array(); |
160 | 160 | |
161 | - if ( empty( $input ) ) { |
|
161 | + if (empty($input)) { |
|
162 | 162 | $output = $input; |
163 | 163 | } |
164 | - elseif ( is_object( $input ) ) { |
|
165 | - $input = get_object_vars( $input ); |
|
164 | + elseif (is_object($input)) { |
|
165 | + $input = get_object_vars($input); |
|
166 | 166 | |
167 | - foreach ( $input as $key => $val ) { |
|
168 | - $output[ $key ] = self::unslash( $val ); |
|
167 | + foreach ($input as $key => $val) { |
|
168 | + $output[$key] = self::unslash($val); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | $output = (object) $output; |
172 | 172 | } |
173 | - elseif ( is_array( $input ) ) { |
|
174 | - foreach ( $input as $key => $val ) { |
|
175 | - $output[ $key ] = self::unslash( $val ); |
|
173 | + elseif (is_array($input)) { |
|
174 | + foreach ($input as $key => $val) { |
|
175 | + $output[$key] = self::unslash($val); |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | else { |
179 | - $output = wp_unslash( $input ); |
|
179 | + $output = wp_unslash($input); |
|
180 | 180 | |
181 | 181 | } |
182 | 182 |