@@ -64,7 +64,7 @@ |
||
| 64 | 64 | * @uses api_request() |
| 65 | 65 | * |
| 66 | 66 | * @param array $_transient_data Update array build by WordPress. |
| 67 | - * @return array Modified update array with custom plugin data. |
|
| 67 | + * @return stdClass Modified update array with custom plugin data. |
|
| 68 | 68 | */ |
| 69 | 69 | function check_update( $_transient_data ) { |
| 70 | 70 | |
@@ -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 | |
@@ -270,11 +270,13 @@ |
||
| 270 | 270 | |
| 271 | 271 | $data = array_merge( $this->api_data, $_data ); |
| 272 | 272 | |
| 273 | - if ( $data['slug'] != $this->slug ) |
|
| 274 | - return; |
|
| 273 | + if ( $data['slug'] != $this->slug ) { |
|
| 274 | + return; |
|
| 275 | + } |
|
| 275 | 276 | |
| 276 | - if ( empty( $data['license'] ) ) |
|
| 277 | - return; |
|
| 277 | + if ( empty( $data['license'] ) ) { |
|
| 278 | + return; |
|
| 279 | + } |
|
| 278 | 280 | |
| 279 | 281 | if ( $this->api_url == home_url() ) { |
| 280 | 282 | return false; // Don't allow a plugin to ping itself |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * Loads the class file for a given class name. |
| 63 | 63 | * |
| 64 | 64 | * @param string $class The fully-qualified class name. |
| 65 | - * @return mixed The mapped file name on success, or boolean false on |
|
| 65 | + * @return string|false The mapped file name on success, or boolean false on |
|
| 66 | 66 | * failure. |
| 67 | 67 | */ |
| 68 | 68 | public function loadClass($class) { |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @param string $prefix The namespace prefix. |
| 101 | 101 | * @param string $relative_class The relative class name. |
| 102 | - * @return mixed Boolean false if no mapped file can be loaded, or the |
|
| 102 | + * @return false|string Boolean false if no mapped file can be loaded, or the |
|
| 103 | 103 | * name of the mapped file that was loaded. |
| 104 | 104 | */ |
| 105 | 105 | protected function loadMappedFile($prefix, $relative_class) { |
@@ -115,8 +115,8 @@ |
||
| 115 | 115 | // replace namespace separators with directory separators |
| 116 | 116 | // in the relative class name, append with .php |
| 117 | 117 | $file = $base_dir |
| 118 | - . str_replace('\\', '/', $relative_class) |
|
| 119 | - . '.php'; |
|
| 118 | + . str_replace('\\', '/', $relative_class) |
|
| 119 | + . '.php'; |
|
| 120 | 120 | |
| 121 | 121 | // if the mapped file exists, require it |
| 122 | 122 | if ($this->requireFile($file)) { |
@@ -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) { |
@@ -49,7 +49,6 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param string $action The AJAX action we are processing. |
| 51 | 51 | * @param string|object $callback_class The class to use for the callback. Either the name of the class or an instance of that class. |
| 52 | - * @param string $method The name of the callback method. |
|
| 53 | 52 | |
| 54 | 53 | */ |
| 55 | 54 | public function __construct( $action, $callback_class) { |
@@ -123,7 +122,7 @@ discard block |
||
| 123 | 122 | * |
| 124 | 123 | * @access protected |
| 125 | 124 | * |
| 126 | - * @return bool |
|
| 125 | + * @return boolean|null |
|
| 127 | 126 | */ |
| 128 | 127 | protected function if_implements() { |
| 129 | 128 | |
@@ -52,28 +52,28 @@ discard block |
||
| 52 | 52 | * @param string $method The name of the callback method. |
| 53 | 53 | |
| 54 | 54 | */ |
| 55 | - public function __construct( $action, $callback_class) { |
|
| 56 | - if ( ! is_object( $callback_class ) ) { |
|
| 55 | + public function __construct($action, $callback_class) { |
|
| 56 | + if (!is_object($callback_class)) { |
|
| 57 | 57 | $this->callback_instance = new $callback_class; |
| 58 | - }else{ |
|
| 58 | + } else { |
|
| 59 | 59 | $this->callback_instance = $callback_class; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ( $this->check_nonce() ) { |
|
| 63 | - if ( is_object( $this->callback_instance ) && $this->if_implements() ) { |
|
| 64 | - if ( $this->other_auth_checks( $action ) ) { |
|
| 62 | + if ($this->check_nonce()) { |
|
| 63 | + if (is_object($this->callback_instance) && $this->if_implements()) { |
|
| 64 | + if ($this->other_auth_checks($action)) { |
|
| 65 | 65 | $this->status_code = 200; |
| 66 | 66 | } else { |
| 67 | - $this->error_message = __( 'Unauthorized action', 'lasso' ); |
|
| 67 | + $this->error_message = __('Unauthorized action', 'lasso'); |
|
| 68 | 68 | $this->status_code = 401; |
| 69 | 69 | } |
| 70 | 70 | } else { |
| 71 | - $this->error_message = __( 'All callback classes used for processing the Lasso Internal API must implement the lasso\internal_api\api_action interface.', 'lasso' ); |
|
| 71 | + $this->error_message = __('All callback classes used for processing the Lasso Internal API must implement the lasso\internal_api\api_action interface.', 'lasso'); |
|
| 72 | 72 | $this->status_code = 401; |
| 73 | 73 | } |
| 74 | 74 | } else { |
| 75 | 75 | $this->status_code = 401; |
| 76 | - $this->error_message = __( 'Nonce invalid', 'lasso' ); |
|
| 76 | + $this->error_message = __('Nonce invalid', 'lasso'); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | } |
@@ -89,20 +89,20 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return bool True if auth checks were all postive. |
| 91 | 91 | */ |
| 92 | - protected function other_auth_checks( $action ) { |
|
| 92 | + protected function other_auth_checks($action) { |
|
| 93 | 93 | $auth_callbacks = $this->callback_instance->auth_callbacks(); |
| 94 | 94 | |
| 95 | - if ( is_array( $auth_callbacks ) && isset( $auth_callbacks[ $action ] ) && is_array( $auth_callbacks[ $action ] ) ) { |
|
| 96 | - $checks = $auth_callbacks[ $action ]; |
|
| 97 | - if ( is_array( $checks ) ) { |
|
| 98 | - foreach ( $checks as $check ) { |
|
| 99 | - if ( is_array( $check ) ) { |
|
| 100 | - $check = call_user_func( array( $check[0], $check[1] ) ); |
|
| 95 | + if (is_array($auth_callbacks) && isset($auth_callbacks[$action]) && is_array($auth_callbacks[$action])) { |
|
| 96 | + $checks = $auth_callbacks[$action]; |
|
| 97 | + if (is_array($checks)) { |
|
| 98 | + foreach ($checks as $check) { |
|
| 99 | + if (is_array($check)) { |
|
| 100 | + $check = call_user_func(array($check[0], $check[1])); |
|
| 101 | 101 | } else { |
| 102 | - $check = call_user_func( $check ); |
|
| 102 | + $check = call_user_func($check); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( false === $check ) { |
|
| 105 | + if (false === $check) { |
|
| 106 | 106 | return false; |
| 107 | 107 | |
| 108 | 108 | } |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | protected function if_implements() { |
| 129 | 129 | |
| 130 | - $implements = class_implements( $this->callback_instance ); |
|
| 131 | - if ( is_array( $implements ) && in_array( 'lasso\internal_api\api_action', $implements ) ) { |
|
| 130 | + $implements = class_implements($this->callback_instance); |
|
| 131 | + if (is_array($implements) && in_array('lasso\internal_api\api_action', $implements)) { |
|
| 132 | 132 | return true; |
| 133 | 133 | |
| 134 | 134 | } |
@@ -147,13 +147,13 @@ discard block |
||
| 147 | 147 | * @return bool |
| 148 | 148 | */ |
| 149 | 149 | protected function check_nonce() { |
| 150 | - if ( isset( $this->callback_instance->nonce_action ) ) { |
|
| 150 | + if (isset($this->callback_instance->nonce_action)) { |
|
| 151 | 151 | $nonce = $this->callback_instance->nonce_action; |
| 152 | - }else{ |
|
| 152 | + } else { |
|
| 153 | 153 | $nonce = 'lasso_editor'; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - return wp_verify_nonce( $_POST[ 'nonce' ], $nonce ); |
|
| 156 | + return wp_verify_nonce($_POST['nonce'], $nonce); |
|
| 157 | 157 | |
| 158 | 158 | } |
| 159 | 159 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | public function __construct( $action, $callback_class) { |
| 56 | 56 | if ( ! is_object( $callback_class ) ) { |
| 57 | 57 | $this->callback_instance = new $callback_class; |
| 58 | - }else{ |
|
| 58 | + } else{ |
|
| 59 | 59 | $this->callback_instance = $callback_class; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | protected function check_nonce() { |
| 150 | 150 | if ( isset( $this->callback_instance->nonce_action ) ) { |
| 151 | 151 | $nonce = $this->callback_instance->nonce_action; |
| 152 | - }else{ |
|
| 152 | + } else{ |
|
| 153 | 153 | $nonce = 'lasso_editor'; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -81,7 +81,6 @@ |
||
| 81 | 81 | * |
| 82 | 82 | * @param string $action The AJAX action we are processing. |
| 83 | 83 | * @param string|object $callback The class to use for the callback. Either the name of the class or an instance of that class. |
| 84 | - |
|
| 85 | 84 | * |
| 86 | 85 | * @return \lasso\internal_api\auth |
| 87 | 86 | */ |
@@ -97,6 +97,7 @@ |
||
| 97 | 97 | * |
| 98 | 98 | * @access protected |
| 99 | 99 | * |
| 100 | + * @param string $action |
|
| 100 | 101 | * @return array |
| 101 | 102 | */ |
| 102 | 103 | protected static function find_callback( $action ) { |
@@ -24,35 +24,35 @@ discard block |
||
| 24 | 24 | global $wp_query; |
| 25 | 25 | |
| 26 | 26 | //get action, and if set, possibly act |
| 27 | - $action = $wp_query->get( 'action' ); |
|
| 28 | - if ( $action && strpos( $_SERVER['REQUEST_URI'], 'lasso-internal-api' ) ) { |
|
| 27 | + $action = $wp_query->get('action'); |
|
| 28 | + if ($action && strpos($_SERVER['REQUEST_URI'], 'lasso-internal-api')) { |
|
| 29 | 29 | |
| 30 | - $response = __( 'Lasso API Error.', 'lasso' ); |
|
| 30 | + $response = __('Lasso API Error.', 'lasso'); |
|
| 31 | 31 | $code = 400; |
| 32 | 32 | |
| 33 | 33 | //see if have a nonce. Will verify it in auth class. |
| 34 | - if ( isset( $_POST[ 'nonce' ] ) ) { |
|
| 34 | + if (isset($_POST['nonce'])) { |
|
| 35 | 35 | |
| 36 | - $callback = self::find_callback( strip_tags( $action ) ); |
|
| 37 | - if ( is_int( $callback ) ) { |
|
| 36 | + $callback = self::find_callback(strip_tags($action)); |
|
| 37 | + if (is_int($callback)) { |
|
| 38 | 38 | $code = $callback; |
| 39 | - }elseif( ! class_exists( $callback['class'] ) ) { |
|
| 39 | + }elseif (!class_exists($callback['class'])) { |
|
| 40 | 40 | $code = 415; |
| 41 | - }else { |
|
| 42 | - $action = str_replace( '-', '_', $action ); |
|
| 41 | + } else { |
|
| 42 | + $action = str_replace('-', '_', $action); |
|
| 43 | 43 | $callback_instance = new $callback['class']; |
| 44 | - $auth = self::auth( $action, $callback_instance, $callback['method'] ); |
|
| 45 | - if ( 200 == $auth->status_code && is_array( $callback ) ) { |
|
| 44 | + $auth = self::auth($action, $callback_instance, $callback['method']); |
|
| 45 | + if (200 == $auth->status_code && is_array($callback)) { |
|
| 46 | 46 | $code = 200; |
| 47 | - $data = new find_data( $callback_instance, $action ); |
|
| 48 | - if ( is_array( $data->data ) && ! empty( $data->data ) ) { |
|
| 49 | - $response = self::route( $action, $callback_instance, $callback['method'], $data->data ); |
|
| 47 | + $data = new find_data($callback_instance, $action); |
|
| 48 | + if (is_array($data->data) && !empty($data->data)) { |
|
| 49 | + $response = self::route($action, $callback_instance, $callback['method'], $data->data); |
|
| 50 | 50 | } else { |
| 51 | 51 | $code = 500; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | } else { |
| 55 | - if ( isset( $auth->error_message ) && is_string( $auth->error_message ) ) { |
|
| 55 | + if (isset($auth->error_message) && is_string($auth->error_message)) { |
|
| 56 | 56 | $response = $auth->error_message; |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,12 +61,12 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - }else{ |
|
| 64 | + } else { |
|
| 65 | 65 | $code = 401; |
| 66 | - $response = __( 'Nonce not set.', 'lasso' ); |
|
| 66 | + $response = __('Nonce not set.', 'lasso'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - self::respond( $response, $code ); |
|
| 69 | + self::respond($response, $code); |
|
| 70 | 70 | |
| 71 | 71 | } |
| 72 | 72 | |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @return \lasso\internal_api\auth |
| 87 | 87 | */ |
| 88 | - protected static function auth( $action, $callback ) { |
|
| 89 | - return new auth( $action, $callback ); |
|
| 88 | + protected static function auth($action, $callback) { |
|
| 89 | + return new auth($action, $callback); |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return array |
| 101 | 101 | */ |
| 102 | - protected static function find_callback( $action ) { |
|
| 103 | - if ( $action ) { |
|
| 104 | - $parts = explode( '_', $action ); |
|
| 102 | + protected static function find_callback($action) { |
|
| 103 | + if ($action) { |
|
| 104 | + $parts = explode('_', $action); |
|
| 105 | 105 | |
| 106 | - if ( isset( $parts[0] ) && isset( $parts[1] ) && isset( $parts[2] ) ) { |
|
| 107 | - $class = str_replace( '-', '_', $parts[1] ); |
|
| 106 | + if (isset($parts[0]) && isset($parts[1]) && isset($parts[2])) { |
|
| 107 | + $class = str_replace('-', '_', $parts[1]); |
|
| 108 | 108 | |
| 109 | 109 | $class = "\\lasso\\{$parts[0]}\\{$class}"; |
| 110 | - $callback = str_replace( '-', '_', $parts[2] ); |
|
| 110 | + $callback = str_replace('-', '_', $parts[2]); |
|
| 111 | 111 | |
| 112 | 112 | return array( |
| 113 | 113 | 'class' => $class, |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return mixed |
| 138 | 138 | */ |
| 139 | - protected static function route( $action, $callback, $method, $data ) { |
|
| 140 | - if ( method_exists( $callback, $method ) ) { |
|
| 141 | - $response = call_user_func( array( $callback, $method ), $data ); |
|
| 139 | + protected static function route($action, $callback, $method, $data) { |
|
| 140 | + if (method_exists($callback, $method)) { |
|
| 141 | + $response = call_user_func(array($callback, $method), $data); |
|
| 142 | 142 | |
| 143 | 143 | return $response; |
| 144 | 144 | |
@@ -156,29 +156,29 @@ discard block |
||
| 156 | 156 | * @param array|string $response The response message to send. |
| 157 | 157 | * @param bool|int $code Response code or bool. If is bool, response code will be 200 or 401 |
| 158 | 158 | */ |
| 159 | - protected static function respond( $response, $code ) { |
|
| 160 | - if ( true === $code ) { |
|
| 159 | + protected static function respond($response, $code) { |
|
| 160 | + if (true === $code) { |
|
| 161 | 161 | $code = 200; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - if ( false == $code ) { |
|
| 164 | + if (false == $code) { |
|
| 165 | 165 | $code = 401; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ( is_string( $response ) ) { |
|
| 168 | + if (is_string($response)) { |
|
| 169 | 169 | $data[] = $response; |
| 170 | - }elseif( is_array( $response ) ) { |
|
| 170 | + }elseif (is_array($response)) { |
|
| 171 | 171 | $data = $response; |
| 172 | - }else{ |
|
| 172 | + } else { |
|
| 173 | 173 | $data[] = $code; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - status_header( $code ); |
|
| 176 | + status_header($code); |
|
| 177 | 177 | nocache_headers(); |
| 178 | - if ( 200 == $code ) { |
|
| 179 | - wp_send_json_success( $data ); |
|
| 180 | - }else{ |
|
| 181 | - wp_send_json_error( $data ); |
|
| 178 | + if (200 == $code) { |
|
| 179 | + wp_send_json_success($data); |
|
| 180 | + } else { |
|
| 181 | + wp_send_json_error($data); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | public static function init() { |
| 202 | 202 | |
| 203 | - if ( ! self::$instance ) { |
|
| 203 | + if (!self::$instance) { |
|
| 204 | 204 | self::$instance = new self; |
| 205 | 205 | } |
| 206 | 206 | |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | $callback = self::find_callback( strip_tags( $action ) ); |
| 37 | 37 | if ( is_int( $callback ) ) { |
| 38 | 38 | $code = $callback; |
| 39 | - }elseif( ! class_exists( $callback['class'] ) ) { |
|
| 39 | + } elseif( ! class_exists( $callback['class'] ) ) { |
|
| 40 | 40 | $code = 415; |
| 41 | - }else { |
|
| 41 | + } else { |
|
| 42 | 42 | $action = str_replace( '-', '_', $action ); |
| 43 | 43 | $callback_instance = new $callback['class']; |
| 44 | 44 | $auth = self::auth( $action, $callback_instance, $callback['method'] ); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - }else{ |
|
| 64 | + } else{ |
|
| 65 | 65 | $code = 401; |
| 66 | 66 | $response = __( 'Nonce not set.', 'lasso' ); |
| 67 | 67 | } |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | if ( is_string( $response ) ) { |
| 169 | 169 | $data[] = $response; |
| 170 | - }elseif( is_array( $response ) ) { |
|
| 170 | + } elseif( is_array( $response ) ) { |
|
| 171 | 171 | $data = $response; |
| 172 | - }else{ |
|
| 172 | + } else{ |
|
| 173 | 173 | $data[] = $code; |
| 174 | 174 | } |
| 175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | nocache_headers(); |
| 178 | 178 | if ( 200 == $code ) { |
| 179 | 179 | wp_send_json_success( $data ); |
| 180 | - }else{ |
|
| 180 | + } else{ |
|
| 181 | 181 | wp_send_json_error( $data ); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Route the requests |
|
| 4 | - * |
|
| 5 | - * @package lasso |
|
| 6 | - * @author Josh Pollock <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - */ |
|
| 3 | + * Route the requests |
|
| 4 | + * |
|
| 5 | + * @package lasso |
|
| 6 | + * @author Josh Pollock <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | namespace lasso\internal_api; |
| 11 | 11 | |
@@ -81,7 +81,6 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @param string $action The AJAX action we are processing. |
| 83 | 83 | * @param string|object $callback The class to use for the callback. Either the name of the class or an instance of that class. |
| 84 | - |
|
| 85 | 84 | * |
| 86 | 85 | * @return \lasso\internal_api\auth |
| 87 | 86 | */ |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | * If we're on multsite we'll grab the site option which is stored in the main blogs site option tables, otherwise |
| 7 | 7 | * we'll grab the option which is stored on the single blogs option tables |
| 8 | 8 | * |
| 9 | - * @param unknown $option string name of the option |
|
| 10 | - * @param unknown $section string name of the section |
|
| 9 | + * @param string $option string name of the option |
|
| 10 | + * @param string $section string name of the section |
|
| 11 | 11 | * @param unknown $default string/int default option value |
| 12 | 12 | * @return the option value |
| 13 | 13 | * @since 1.0 |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * Return a CSS class of an automatically supported theme |
| 53 | 53 | * |
| 54 | 54 | * @since 0.8.6 |
| 55 | - * @return a css class if the theme is supported, false if nothing |
|
| 55 | + * @return string|false css class if the theme is supported, false if nothing |
|
| 56 | 56 | */ |
| 57 | 57 | function lasso_get_supported_theme_class() { |
| 58 | 58 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * Used internally as a callback to build a tab or content area for modal addons |
| 229 | 229 | * |
| 230 | 230 | * @param $tab object |
| 231 | -* @param $type string tab or content |
|
| 231 | +* @param string $type string tab or content |
|
| 232 | 232 | * @uses lasso_modal_addons() |
| 233 | 233 | * @since 0.9.4 |
| 234 | 234 | */ |
@@ -200,7 +200,7 @@ |
||
| 200 | 200 | 'public' => true, |
| 201 | 201 | ), 'objects' ); |
| 202 | 202 | $post_types = array_combine( array_keys( $post_types ), wp_list_pluck( $post_types, 'label' ) ); |
| 203 | - unset( $post_types[ 'attachment' ] ); |
|
| 203 | + unset( $post_types[ 'attachment' ] ); |
|
| 204 | 204 | |
| 205 | 205 | /** |
| 206 | 206 | * Set which post types are allowed |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function lasso_editor_get_option( $option, $section, $default = '' ) { |
| 16 | 16 | |
| 17 | - if ( empty( $option ) ) |
|
| 18 | - return; |
|
| 17 | + if ( empty( $option ) ) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | 21 | if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 21 | 22 | |
@@ -42,11 +43,12 @@ discard block |
||
| 42 | 43 | |
| 43 | 44 | $q = new wp_query( array( 'post_type' => 'ai_galleries', 'post_status' => 'publish' ) ); |
| 44 | 45 | |
| 45 | - if ( $q->have_posts() ) |
|
| 46 | - return true; |
|
| 47 | - else |
|
| 48 | - return false; |
|
| 49 | -} |
|
| 46 | + if ( $q->have_posts() ) { |
|
| 47 | + return true; |
|
| 48 | + } else { |
|
| 49 | + return false; |
|
| 50 | + } |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | /** |
| 52 | 54 | * Return a CSS class of an automatically supported theme |
@@ -149,13 +151,15 @@ discard block |
||
| 149 | 151 | */ |
| 150 | 152 | function lasso_get_post_objects( $postid = '', $taxonomy = 'category') { |
| 151 | 153 | |
| 152 | - if ( empty( $postid ) ) |
|
| 153 | - $postid = get_the_ID(); |
|
| 154 | + if ( empty( $postid ) ) { |
|
| 155 | + $postid = get_the_ID(); |
|
| 156 | + } |
|
| 154 | 157 | |
| 155 | 158 | $objects = 'category' == $taxonomy ? get_the_category( $postid ) : get_the_tags( $postid ); |
| 156 | 159 | |
| 157 | - if ( empty( $objects) ) |
|
| 158 | - return; |
|
| 160 | + if ( empty( $objects) ) { |
|
| 161 | + return; |
|
| 162 | + } |
|
| 159 | 163 | |
| 160 | 164 | $out = ''; |
| 161 | 165 | foreach( $objects as $object ) { |
@@ -176,8 +180,9 @@ discard block |
||
| 176 | 180 | |
| 177 | 181 | $objects = 'category' == $taxonomy ? get_categories(array('hide_empty' => 0)) : get_tags(array('hide_empty' => 0)); |
| 178 | 182 | |
| 179 | - if ( empty( $objects) ) |
|
| 180 | - return; |
|
| 183 | + if ( empty( $objects) ) { |
|
| 184 | + return; |
|
| 185 | + } |
|
| 181 | 186 | |
| 182 | 187 | $out = array(); |
| 183 | 188 | foreach( $objects as $object ) { |
@@ -264,8 +269,9 @@ discard block |
||
| 264 | 269 | */ |
| 265 | 270 | function lasso_clean_string( $string = '' ) { |
| 266 | 271 | |
| 267 | - if ( empty( $string ) ) |
|
| 268 | - return; |
|
| 272 | + if ( empty( $string ) ) { |
|
| 273 | + return; |
|
| 274 | + } |
|
| 269 | 275 | |
| 270 | 276 | return sanitize_text_field( strtolower( preg_replace('/[\s_]/', '-', $string ) ) ); |
| 271 | 277 | } |
@@ -304,11 +310,13 @@ discard block |
||
| 304 | 310 | if ( !function_exists( 'lasso_user_can' ) ): |
| 305 | 311 | function lasso_user_can( $action = '', $postid = 0 ) { |
| 306 | 312 | |
| 307 | - if ( empty( $action ) ) |
|
| 308 | - $action = 'edit_posts'; |
|
| 313 | + if ( empty( $action ) ) { |
|
| 314 | + $action = 'edit_posts'; |
|
| 315 | + } |
|
| 309 | 316 | |
| 310 | - if ( empty( $postid ) ) |
|
| 311 | - $postid = get_the_ID(); |
|
| 317 | + if ( empty( $postid ) ) { |
|
| 318 | + $postid = get_the_ID(); |
|
| 319 | + } |
|
| 312 | 320 | |
| 313 | 321 | if ( is_user_logged_in() && current_user_can( $action, $postid ) ) { |
| 314 | 322 | |
@@ -12,21 +12,21 @@ discard block |
||
| 12 | 12 | * @return the option value |
| 13 | 13 | * @since 1.0 |
| 14 | 14 | */ |
| 15 | -function lasso_editor_get_option( $option, $section, $default = '' ) { |
|
| 15 | +function lasso_editor_get_option($option, $section, $default = '') { |
|
| 16 | 16 | |
| 17 | - if ( empty( $option ) ) |
|
| 17 | + if (empty($option)) |
|
| 18 | 18 | return; |
| 19 | 19 | |
| 20 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 20 | + if (function_exists('is_multisite') && is_multisite()) { |
|
| 21 | 21 | |
| 22 | - $options = get_site_option( $section ); |
|
| 22 | + $options = get_site_option($section); |
|
| 23 | 23 | |
| 24 | 24 | } else { |
| 25 | 25 | |
| 26 | - $options = get_option( $section ); |
|
| 26 | + $options = get_option($section); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if ( isset( $options[$option] ) ) { |
|
| 29 | + if (isset($options[$option])) { |
|
| 30 | 30 | return $options[$option]; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function lasso_editor_galleries_exist() { |
| 42 | 42 | |
| 43 | - $q = new wp_query( array( 'post_type' => 'ai_galleries', 'post_status' => 'publish' ) ); |
|
| 43 | + $q = new wp_query(array('post_type' => 'ai_galleries', 'post_status' => 'publish')); |
|
| 44 | 44 | |
| 45 | - if ( $q->have_posts() ) |
|
| 45 | + if ($q->have_posts()) |
|
| 46 | 46 | return true; |
| 47 | 47 | else |
| 48 | 48 | return false; |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | function lasso_get_supported_theme_class() { |
| 58 | 58 | |
| 59 | 59 | $name = wp_get_theme()->get('Name'); |
| 60 | - $slug = lasso_clean_string( $name ); |
|
| 60 | + $slug = lasso_clean_string($name); |
|
| 61 | 61 | |
| 62 | - switch ( $slug ) { |
|
| 62 | + switch ($slug) { |
|
| 63 | 63 | case 'aesop-story-theme': // aesop |
| 64 | 64 | $out = '.aesop-entry-content'; |
| 65 | 65 | break; |
@@ -108,15 +108,15 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return !empty( $out ) ? $out : false; |
|
| 111 | + return !empty($out) ? $out : false; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | function lasso_get_supported_theme_title_class() { |
| 115 | 115 | |
| 116 | 116 | $name = wp_get_theme()->get('Name'); |
| 117 | - $slug = lasso_clean_string( $name ); |
|
| 117 | + $slug = lasso_clean_string($name); |
|
| 118 | 118 | |
| 119 | - switch ( $slug ) { |
|
| 119 | + switch ($slug) { |
|
| 120 | 120 | |
| 121 | 121 | case 'aesop-story-theme': // aesop |
| 122 | 122 | $out = '.aesop-entry-title'; |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | break; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return !empty( $out ) ? $out : false; |
|
| 147 | + return !empty($out) ? $out : false; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @since 0.8.7 |
| 155 | 155 | * @return string of comma separated classes |
| 156 | 156 | */ |
| 157 | -function lasso_supported_no_save(){ |
|
| 157 | +function lasso_supported_no_save() { |
|
| 158 | 158 | |
| 159 | 159 | return apply_filters('lasso_dont_save', '.lasso--ignore, .sharedaddy, .us_wrapper, .twitter-tweet'); |
| 160 | 160 | } |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return array|mixed|object|string|void |
| 170 | 170 | */ |
| 171 | -function lasso_sanitize_data( $data ) { |
|
| 172 | - return \lasso\sanatize::do_sanitize( $data ); |
|
| 171 | +function lasso_sanitize_data($data) { |
|
| 172 | + return \lasso\sanatize::do_sanitize($data); |
|
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | * @since 0.9.3 |
| 180 | 180 | * @return string of comma delimited category slugs |
| 181 | 181 | */ |
| 182 | -function lasso_get_post_objects( $postid = '', $taxonomy = 'category') { |
|
| 182 | +function lasso_get_post_objects($postid = '', $taxonomy = 'category') { |
|
| 183 | 183 | |
| 184 | - if ( empty( $postid ) ) |
|
| 184 | + if (empty($postid)) |
|
| 185 | 185 | $postid = get_the_ID(); |
| 186 | 186 | |
| 187 | - $objects = 'category' == $taxonomy ? get_the_category( $postid ) : get_the_tags( $postid ); |
|
| 187 | + $objects = 'category' == $taxonomy ? get_the_category($postid) : get_the_tags($postid); |
|
| 188 | 188 | |
| 189 | - if ( empty( $objects) ) |
|
| 189 | + if (empty($objects)) |
|
| 190 | 190 | return; |
| 191 | 191 | |
| 192 | 192 | $out = ''; |
| 193 | - foreach( $objects as $object ) { |
|
| 193 | + foreach ($objects as $object) { |
|
| 194 | 194 | $out .= $object->slug.', '; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -204,15 +204,15 @@ discard block |
||
| 204 | 204 | * @since 0.9.3 |
| 205 | 205 | * @return array all categoiries |
| 206 | 206 | */ |
| 207 | -function lasso_get_objects( $taxonomy = 'category' ) { |
|
| 207 | +function lasso_get_objects($taxonomy = 'category') { |
|
| 208 | 208 | |
| 209 | 209 | $objects = 'category' == $taxonomy ? get_categories(array('hide_empty' => 0)) : get_tags(array('hide_empty' => 0)); |
| 210 | 210 | |
| 211 | - if ( empty( $objects) ) |
|
| 211 | + if (empty($objects)) |
|
| 212 | 212 | return; |
| 213 | 213 | |
| 214 | 214 | $out = array(); |
| 215 | - foreach( $objects as $object ) { |
|
| 215 | + foreach ($objects as $object) { |
|
| 216 | 216 | $out[] = $object->slug; |
| 217 | 217 | } |
| 218 | 218 | |
@@ -228,11 +228,11 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | function lasso_post_types() { |
| 230 | 230 | |
| 231 | - $post_types = get_post_types( array( |
|
| 231 | + $post_types = get_post_types(array( |
|
| 232 | 232 | 'public' => true, |
| 233 | - ), 'objects' ); |
|
| 234 | - $post_types = array_combine( array_keys( $post_types ), wp_list_pluck( $post_types, 'label' ) ); |
|
| 235 | - unset( $post_types[ 'attachment' ] ); |
|
| 233 | + ), 'objects'); |
|
| 234 | + $post_types = array_combine(array_keys($post_types), wp_list_pluck($post_types, 'label')); |
|
| 235 | + unset($post_types['attachment']); |
|
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | 238 | * Set which post types are allowed |
@@ -241,10 +241,10 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @param array $allowed_post_types Array of names (not labels) of allowed post types. Must be registered. |
| 243 | 243 | */ |
| 244 | - $allowed_post_types = apply_filters( 'lasso_allowed_post_types', array( 'post', 'page' ) ); |
|
| 245 | - foreach( $post_types as $name => $label ) { |
|
| 246 | - if ( ! in_array( $name, $allowed_post_types ) ) { |
|
| 247 | - unset( $post_types[ $name ] ); |
|
| 244 | + $allowed_post_types = apply_filters('lasso_allowed_post_types', array('post', 'page')); |
|
| 245 | + foreach ($post_types as $name => $label) { |
|
| 246 | + if (!in_array($name, $allowed_post_types)) { |
|
| 247 | + unset($post_types[$name]); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | } |
@@ -264,22 +264,22 @@ discard block |
||
| 264 | 264 | * @uses lasso_modal_addons() |
| 265 | 265 | * @since 0.9.4 |
| 266 | 266 | */ |
| 267 | -function lasso_modal_addons_content( $tab = '', $type ){ |
|
| 267 | +function lasso_modal_addons_content($tab = '', $type) { |
|
| 268 | 268 | |
| 269 | - $name = lasso_clean_string( $tab['name'] ); |
|
| 269 | + $name = lasso_clean_string($tab['name']); |
|
| 270 | 270 | |
| 271 | - if ( 'tab' == $type ) { |
|
| 271 | + if ('tab' == $type) { |
|
| 272 | 272 | |
| 273 | - $out = sprintf( '<li data-addon-name="%s">%s</li>', $name, $tab['name'] ); |
|
| 273 | + $out = sprintf('<li data-addon-name="%s">%s</li>', $name, $tab['name']); |
|
| 274 | 274 | |
| 275 | - } else if ( 'content' == $type ){ |
|
| 275 | + } else if ('content' == $type) { |
|
| 276 | 276 | |
| 277 | - $content = isset( $tab['content'] ) && is_callable( $tab['content'] ) ? call_user_func( $tab['content'] ) : false; |
|
| 278 | - $options = isset( $tab['options'] ) && is_callable( $tab['options'] ) ? call_user_func( $tab['options'] ) : false; |
|
| 277 | + $content = isset($tab['content']) && is_callable($tab['content']) ? call_user_func($tab['content']) : false; |
|
| 278 | + $options = isset($tab['options']) && is_callable($tab['options']) ? call_user_func($tab['options']) : false; |
|
| 279 | 279 | |
| 280 | - $out = sprintf( '<div class="lasso--modal__content not-visible" data-addon-content="%s"> |
|
| 280 | + $out = sprintf('<div class="lasso--modal__content not-visible" data-addon-content="%s"> |
|
| 281 | 281 | %s%s |
| 282 | - </div>', $name, $content, lasso_option_form( $name, $options ) ); |
|
| 282 | + </div>', $name, $content, lasso_option_form($name, $options)); |
|
| 283 | 283 | |
| 284 | 284 | } |
| 285 | 285 | |
@@ -294,12 +294,12 @@ discard block |
||
| 294 | 294 | * |
| 295 | 295 | * @return void|string |
| 296 | 296 | */ |
| 297 | -function lasso_clean_string( $string = '' ) { |
|
| 297 | +function lasso_clean_string($string = '') { |
|
| 298 | 298 | |
| 299 | - if ( empty( $string ) ) |
|
| 299 | + if (empty($string)) |
|
| 300 | 300 | return; |
| 301 | 301 | |
| 302 | - return sanitize_text_field( strtolower( preg_replace('/[\s_]/', '-', $string ) ) ); |
|
| 302 | + return sanitize_text_field(strtolower(preg_replace('/[\s_]/', '-', $string))); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -312,13 +312,13 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return void|string |
| 314 | 314 | */ |
| 315 | -function lasso_unclean_string( $string = '' ) { |
|
| 315 | +function lasso_unclean_string($string = '') { |
|
| 316 | 316 | |
| 317 | - if ( empty( $string ) ) { |
|
| 317 | + if (empty($string)) { |
|
| 318 | 318 | return; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - return sanitize_text_field( strtolower( str_replace( '-', '_', $string ) ) ); |
|
| 321 | + return sanitize_text_field(strtolower(str_replace('-', '_', $string))); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | |
@@ -333,16 +333,16 @@ discard block |
||
| 333 | 333 | * @param unknown $postid int the id of the post object to check against |
| 334 | 334 | * @since 1.0 |
| 335 | 335 | */ |
| 336 | -if ( !function_exists( 'lasso_user_can' ) ): |
|
| 337 | - function lasso_user_can( $action = '', $postid = 0 ) { |
|
| 336 | +if (!function_exists('lasso_user_can')): |
|
| 337 | + function lasso_user_can($action = '', $postid = 0) { |
|
| 338 | 338 | |
| 339 | - if ( empty( $action ) ) |
|
| 339 | + if (empty($action)) |
|
| 340 | 340 | $action = 'edit_posts'; |
| 341 | 341 | |
| 342 | - if ( empty( $postid ) ) |
|
| 342 | + if (empty($postid)) |
|
| 343 | 343 | $postid = get_the_ID(); |
| 344 | 344 | |
| 345 | - if ( is_user_logged_in() && current_user_can( $action, $postid ) ) { |
|
| 345 | + if (is_user_logged_in() && current_user_can($action, $postid)) { |
|
| 346 | 346 | |
| 347 | 347 | return true; |
| 348 | 348 | |
@@ -360,25 +360,25 @@ discard block |
||
| 360 | 360 | * |
| 361 | 361 | * @since 0.9.5 |
| 362 | 362 | */ |
| 363 | -if ( !function_exists('lasso_editor_empty_results') ): |
|
| 363 | +if (!function_exists('lasso_editor_empty_results')): |
|
| 364 | 364 | |
| 365 | - function lasso_editor_empty_results( $type = 'posts' ){ |
|
| 365 | + function lasso_editor_empty_results($type = 'posts') { |
|
| 366 | 366 | |
| 367 | - if ( 'posts' == $type ) { |
|
| 367 | + if ('posts' == $type) { |
|
| 368 | 368 | |
| 369 | - $string = apply_filters('lasso_empty_state_message', __('No posts to show', 'lasso') ); |
|
| 369 | + $string = apply_filters('lasso_empty_state_message', __('No posts to show', 'lasso')); |
|
| 370 | 370 | $icon = 'lasso-icon-file-text2'; |
| 371 | 371 | $button = false; |
| 372 | 372 | |
| 373 | - } elseif ( 'revision' == $type ) { |
|
| 373 | + } elseif ('revision' == $type) { |
|
| 374 | 374 | |
| 375 | - $string = apply_filters('lasso_empty_state_message', __('No revisions found', 'lasso') ); |
|
| 375 | + $string = apply_filters('lasso_empty_state_message', __('No revisions found', 'lasso')); |
|
| 376 | 376 | $icon = 'lasso-icon-history'; |
| 377 | - $button = sprintf('<a href="#" class="lasso--btn-secondary" id="lasso--close-modal">%s</a>', __('Close','lasso') ); |
|
| 377 | + $button = sprintf('<a href="#" class="lasso--btn-secondary" id="lasso--close-modal">%s</a>', __('Close', 'lasso')); |
|
| 378 | 378 | |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - return sprintf('<div id="lasso--empty-state" class="lasso--empty-state"><i class="lasso--empty-state-icon lasso-icon %s"></i><p>%s</p>%s</div>', $icon, $string, $button ); |
|
| 381 | + return sprintf('<div id="lasso--empty-state" class="lasso--empty-state"><i class="lasso--empty-state-icon lasso-icon %s"></i><p>%s</p>%s</div>', $icon, $string, $button); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | endif; |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | * |
| 67 | 67 | * @since 0.0.1 |
| 68 | 68 | * |
| 69 | - * @return Plugin slug variable. |
|
| 69 | + * @return string slug variable. |
|
| 70 | 70 | */ |
| 71 | 71 | public function get_plugin_slug() { |
| 72 | 72 | return $this->plugin_slug; |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | require_once LASSO_DIR.'/public/includes/option-engine.php'; |
| 52 | 52 | |
| 53 | 53 | // Activate plugin when new blog is added |
| 54 | - add_action( 'wpmu_new_blog', array( $this, 'activate_new_site' ) ); |
|
| 54 | + add_action('wpmu_new_blog', array($this, 'activate_new_site')); |
|
| 55 | 55 | |
| 56 | 56 | // Load plugin text domain |
| 57 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
| 57 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
| 58 | 58 | |
| 59 | 59 | //enqueue assets |
| 60 | 60 | new assets(); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public static function get_instance() { |
| 83 | 83 | |
| 84 | 84 | // If the single instance hasn't been set, set it now. |
| 85 | - if ( null == self::$instance ) { |
|
| 85 | + if (null == self::$instance) { |
|
| 86 | 86 | self::$instance = new self; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -99,18 +99,18 @@ discard block |
||
| 99 | 99 | * WPMU is disabled or plugin is |
| 100 | 100 | * activated on an individual blog. |
| 101 | 101 | */ |
| 102 | - public static function activate( $network_wide ) { |
|
| 102 | + public static function activate($network_wide) { |
|
| 103 | 103 | |
| 104 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 104 | + if (function_exists('is_multisite') && is_multisite()) { |
|
| 105 | 105 | |
| 106 | - if ( $network_wide ) { |
|
| 106 | + if ($network_wide) { |
|
| 107 | 107 | |
| 108 | 108 | // Get all blog ids |
| 109 | 109 | $blog_ids = self::get_blog_ids(); |
| 110 | 110 | |
| 111 | - foreach ( $blog_ids as $blog_id ) { |
|
| 111 | + foreach ($blog_ids as $blog_id) { |
|
| 112 | 112 | |
| 113 | - switch_to_blog( $blog_id ); |
|
| 113 | + switch_to_blog($blog_id); |
|
| 114 | 114 | self::single_activate(); |
| 115 | 115 | } |
| 116 | 116 | |
@@ -136,18 +136,18 @@ discard block |
||
| 136 | 136 | * WPMU is disabled or plugin is |
| 137 | 137 | * deactivated on an individual blog. |
| 138 | 138 | */ |
| 139 | - public static function deactivate( $network_wide ) { |
|
| 139 | + public static function deactivate($network_wide) { |
|
| 140 | 140 | |
| 141 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 141 | + if (function_exists('is_multisite') && is_multisite()) { |
|
| 142 | 142 | |
| 143 | - if ( $network_wide ) { |
|
| 143 | + if ($network_wide) { |
|
| 144 | 144 | |
| 145 | 145 | // Get all blog ids |
| 146 | 146 | $blog_ids = self::get_blog_ids(); |
| 147 | 147 | |
| 148 | - foreach ( $blog_ids as $blog_id ) { |
|
| 148 | + foreach ($blog_ids as $blog_id) { |
|
| 149 | 149 | |
| 150 | - switch_to_blog( $blog_id ); |
|
| 150 | + switch_to_blog($blog_id); |
|
| 151 | 151 | self::single_deactivate(); |
| 152 | 152 | |
| 153 | 153 | } |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @param int $blog_id ID of the new blog. |
| 173 | 173 | */ |
| 174 | - public function activate_new_site( $blog_id ) { |
|
| 174 | + public function activate_new_site($blog_id) { |
|
| 175 | 175 | |
| 176 | - if ( 1 !== did_action( 'wpmu_new_blog' ) ) { |
|
| 176 | + if (1 !== did_action('wpmu_new_blog')) { |
|
| 177 | 177 | return; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - switch_to_blog( $blog_id ); |
|
| 180 | + switch_to_blog($blog_id); |
|
| 181 | 181 | self::single_activate(); |
| 182 | 182 | restore_current_blog(); |
| 183 | 183 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | WHERE archived = '0' AND spam = '0' |
| 203 | 203 | AND deleted = '0'"; |
| 204 | 204 | |
| 205 | - return $wpdb->get_col( $sql ); |
|
| 205 | + return $wpdb->get_col($sql); |
|
| 206 | 206 | |
| 207 | 207 | } |
| 208 | 208 | |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | private static function single_activate() { |
| 215 | 215 | |
| 216 | - $curr_version = get_option( 'lasso_version' ); |
|
| 216 | + $curr_version = get_option('lasso_version'); |
|
| 217 | 217 | |
| 218 | 218 | // update upgraded from |
| 219 | - if ( $curr_version ) { |
|
| 220 | - update_option( 'lasso_updated_from', $curr_version ); |
|
| 219 | + if ($curr_version) { |
|
| 220 | + update_option('lasso_updated_from', $curr_version); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // update lasso version option |
| 224 | - update_option( 'lasso_version', LASSO_VERSION ); |
|
| 224 | + update_option('lasso_version', LASSO_VERSION); |
|
| 225 | 225 | |
| 226 | 226 | // set transietn for activation welcome |
| 227 | - set_transient( '_lasso_welcome_redirect', true, 30 ); |
|
| 227 | + set_transient('_lasso_welcome_redirect', true, 30); |
|
| 228 | 228 | |
| 229 | 229 | |
| 230 | 230 | } |
@@ -246,8 +246,8 @@ discard block |
||
| 246 | 246 | public function load_plugin_textdomain() { |
| 247 | 247 | |
| 248 | 248 | $domain = $this->plugin_slug; |
| 249 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
| 249 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
| 250 | 250 | |
| 251 | - $out = load_textdomain( $domain, trailingslashit( LASSO_DIR ). 'languages/' . $domain . '-' . $locale . '.mo' ); |
|
| 251 | + $out = load_textdomain($domain, trailingslashit(LASSO_DIR).'languages/'.$domain.'-'.$locale.'.mo'); |
|
| 252 | 252 | } |
| 253 | 253 | } |
@@ -1,20 +1,20 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * AH Editor |
|
| 4 | - * |
|
| 5 | - * @package Lasso |
|
| 6 | - * @author Nick Haskins <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - * @link http://aesopinteractive.com |
|
| 9 | - * @copyright 2015 Aesopinteractive LLC |
|
| 10 | - */ |
|
| 3 | + * AH Editor |
|
| 4 | + * |
|
| 5 | + * @package Lasso |
|
| 6 | + * @author Nick Haskins <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + * @link http://aesopinteractive.com |
|
| 9 | + * @copyright 2015 Aesopinteractive LLC |
|
| 10 | + */ |
|
| 11 | 11 | namespace lasso_public_facing; |
| 12 | 12 | /** |
| 13 | - * |
|
| 14 | - * |
|
| 15 | - * @package Lasso |
|
| 16 | - * @author Nick Haskins <[email protected]> |
|
| 17 | - */ |
|
| 13 | + * |
|
| 14 | + * |
|
| 15 | + * @package Lasso |
|
| 16 | + * @author Nick Haskins <[email protected]> |
|
| 17 | + */ |
|
| 18 | 18 | class lasso { |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -43,23 +43,23 @@ discard block |
||
| 43 | 43 | $plugin = lasso::get_instance(); |
| 44 | 44 | $this->plugin_slug = $plugin->get_plugin_slug(); |
| 45 | 45 | |
| 46 | - add_action( 'admin_head', array( $this, 'admin_assets' ) ); |
|
| 47 | - add_action( 'admin_notices', array( $this, 'license_nag' ) ); |
|
| 48 | - add_action( 'admin_head', array( $this, 'dismiss_nag' ) ); |
|
| 49 | - add_filter( 'plugin_row_meta', array( $this, 'plugin_meta' ), 10, 2 ); |
|
| 46 | + add_action('admin_head', array($this, 'admin_assets')); |
|
| 47 | + add_action('admin_notices', array($this, 'license_nag')); |
|
| 48 | + add_action('admin_head', array($this, 'dismiss_nag')); |
|
| 49 | + add_filter('plugin_row_meta', array($this, 'plugin_meta'), 10, 2); |
|
| 50 | 50 | |
| 51 | - if ( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 51 | + if (!class_exists('EDD_SL_Plugin_Updater')) { |
|
| 52 | 52 | include LASSO_DIR.'admin/includes/EDD_SL_Plugin_Updater.php'; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( !class_exists( 'TGM_Plugin_Activation' ) ) { |
|
| 55 | + if (!class_exists('TGM_Plugin_Activation')) { |
|
| 56 | 56 | include LASSO_DIR.'admin/includes/class-tgm-plugin-activation.php'; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | new menus\welcome(); |
| 60 | 60 | new menus\settings(); |
| 61 | 61 | |
| 62 | - if ( !defined( 'LASSO_AGENCY_MODE' ) ) { |
|
| 62 | + if (!defined('LASSO_AGENCY_MODE')) { |
|
| 63 | 63 | new menus\license(); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public static function get_instance() { |
| 76 | 76 | |
| 77 | 77 | // If the single instance hasn't been set, set it now. |
| 78 | - if ( null == self::$instance ) { |
|
| 78 | + if (null == self::$instance) { |
|
| 79 | 79 | self::$instance = new self; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | 'dashboard_page_lasso-welcome-screen' |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - foreach ( $pages as $page ) { |
|
| 101 | - wp_enqueue_script( 'lasso-editor-settings-script', LASSO_URL.'/admin/assets/js/lasso-editor-settings.js', array( 'jquery' ), LASSO_VERSION, true ); |
|
| 102 | - wp_enqueue_style( 'lasso-editor-settings-style', LASSO_URL.'/admin/assets/css/lasso-editor-settings.css', LASSO_VERSION ); |
|
| 100 | + foreach ($pages as $page) { |
|
| 101 | + wp_enqueue_script('lasso-editor-settings-script', LASSO_URL.'/admin/assets/js/lasso-editor-settings.js', array('jquery'), LASSO_VERSION, true); |
|
| 102 | + wp_enqueue_style('lasso-editor-settings-style', LASSO_URL.'/admin/assets/css/lasso-editor-settings.css', LASSO_VERSION); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -112,15 +112,15 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return array new array of links for our plugin listing on plugins.php |
| 114 | 114 | */ |
| 115 | - public function plugin_meta( $links, $file ) { |
|
| 115 | + public function plugin_meta($links, $file) { |
|
| 116 | 116 | |
| 117 | - if ( strpos( $file, 'lasso.php' ) !== false && !defined( 'LASSO_AGENCY_MODE' ) ) { |
|
| 117 | + if (strpos($file, 'lasso.php') !== false && !defined('LASSO_AGENCY_MODE')) { |
|
| 118 | 118 | |
| 119 | 119 | $new_links = array( |
| 120 | 120 | '<a href="http://edituswp.com/help" target="_blank">Help</a>' |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | - $links = array_merge( $links, $new_links ); |
|
| 123 | + $links = array_merge($links, $new_links); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | return $links; |
@@ -132,35 +132,35 @@ discard block |
||
| 132 | 132 | * @since 0.9.7 |
| 133 | 133 | * @todo make dismissible |
| 134 | 134 | */ |
| 135 | - public function license_nag(){ |
|
| 135 | + public function license_nag() { |
|
| 136 | 136 | |
| 137 | - $screen = get_current_screen(); |
|
| 138 | - $welcome = 'toplevel_page_lasso-editor' == $screen->id; |
|
| 139 | - $license = get_option( 'lasso_license_key' ); |
|
| 140 | - $status = get_option( 'lasso_license_status' ); |
|
| 137 | + $screen = get_current_screen(); |
|
| 138 | + $welcome = 'toplevel_page_lasso-editor' == $screen->id; |
|
| 139 | + $license = get_option('lasso_license_key'); |
|
| 140 | + $status = get_option('lasso_license_status'); |
|
| 141 | 141 | |
| 142 | - $message_empty = apply_filters('lasso_empty_license_message','Your license key for support and automatic updates for Editus is missing!'); |
|
| 143 | - $message_invalid = apply_filters('lasso_invalid_license_message','Oh snap! It looks like your Editus license key is invalid. Might check here to see if its been added correctly.'); |
|
| 144 | - $message_inactive = apply_filters('lasso_inactive_license_message','It looks like your license key has not yet been activated.'); |
|
| 142 | + $message_empty = apply_filters('lasso_empty_license_message', 'Your license key for support and automatic updates for Editus is missing!'); |
|
| 143 | + $message_invalid = apply_filters('lasso_invalid_license_message', 'Oh snap! It looks like your Editus license key is invalid. Might check here to see if its been added correctly.'); |
|
| 144 | + $message_inactive = apply_filters('lasso_inactive_license_message', 'It looks like your license key has not yet been activated.'); |
|
| 145 | 145 | |
| 146 | - $license_link = sprintf('<a href="%s">Update License</a>', esc_url( add_query_arg( array( 'page' => 'lasso-license' ), admin_url('admin.php') ) ) ); |
|
| 147 | - $dismiss_link = sprintf('<a style="text-decoration:none;" href="%s" id="lasso-dismiss-notice" class="notice-dismiss"><span class="screen-reader-text">%s</span></a>', esc_url( add_query_arg( 'lasso-notice', 'dismiss' ) ), __('Dismiss this notice.','lasso') ); |
|
| 146 | + $license_link = sprintf('<a href="%s">Update License</a>', esc_url(add_query_arg(array('page' => 'lasso-license'), admin_url('admin.php')))); |
|
| 147 | + $dismiss_link = sprintf('<a style="text-decoration:none;" href="%s" id="lasso-dismiss-notice" class="notice-dismiss"><span class="screen-reader-text">%s</span></a>', esc_url(add_query_arg('lasso-notice', 'dismiss')), __('Dismiss this notice.', 'lasso')); |
|
| 148 | 148 | |
| 149 | - $not_hidden = get_user_meta( get_current_user_ID(), 'lasso_license_nag_dismissed', true ); |
|
| 149 | + $not_hidden = get_user_meta(get_current_user_ID(), 'lasso_license_nag_dismissed', true); |
|
| 150 | 150 | |
| 151 | - if ( current_user_can('manage_options') && !$welcome && !defined( 'LASSO_AGENCY_MODE') && !$not_hidden ) { |
|
| 151 | + if (current_user_can('manage_options') && !$welcome && !defined('LASSO_AGENCY_MODE') && !$not_hidden) { |
|
| 152 | 152 | |
| 153 | - if ( empty( $license ) ) { |
|
| 153 | + if (empty($license)) { |
|
| 154 | 154 | |
| 155 | - printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_empty, $license_link, $dismiss_link ); |
|
| 155 | + printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_empty, $license_link, $dismiss_link); |
|
| 156 | 156 | |
| 157 | - } else if ( 'invalid' == $status ){ // license key entered wrong or something |
|
| 157 | + } else if ('invalid' == $status) { // license key entered wrong or something |
|
| 158 | 158 | |
| 159 | - printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_invalid, $license_link , $dismiss_link ); |
|
| 159 | + printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_invalid, $license_link, $dismiss_link); |
|
| 160 | 160 | |
| 161 | - } else if ( empty( $status ) ){ // license key saved but not activated |
|
| 161 | + } else if (empty($status)) { // license key saved but not activated |
|
| 162 | 162 | |
| 163 | - printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_inactive, $license_link, $dismiss_link ); |
|
| 163 | + printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_inactive, $license_link, $dismiss_link); |
|
| 164 | 164 | |
| 165 | 165 | } |
| 166 | 166 | } |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | public function dismiss_nag() { |
| 176 | 176 | |
| 177 | - if ( isset( $_GET['lasso-notice'] ) && 'dismiss' == $_GET['lasso-notice'] && current_user_can('manage_options') ) { |
|
| 178 | - update_user_meta( get_current_user_id(), 'lasso_license_nag_dismissed', 1 ); |
|
| 177 | + if (isset($_GET['lasso-notice']) && 'dismiss' == $_GET['lasso-notice'] && current_user_can('manage_options')) { |
|
| 178 | + update_user_meta(get_current_user_id(), 'lasso_license_nag_dismissed', 1); |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * AH Stripe |
|
| 4 | - * |
|
| 5 | - * @package Editus_Admin |
|
| 6 | - * @author Nick Haskins <[email protected]> |
|
| 7 | - * @license GPL-2.0+ |
|
| 8 | - * @link http://aesopinteractive.com |
|
| 9 | - * @copyright 2015 Aesopinteractive LLC |
|
| 10 | - */ |
|
| 3 | + * AH Stripe |
|
| 4 | + * |
|
| 5 | + * @package Editus_Admin |
|
| 6 | + * @author Nick Haskins <[email protected]> |
|
| 7 | + * @license GPL-2.0+ |
|
| 8 | + * @link http://aesopinteractive.com |
|
| 9 | + * @copyright 2015 Aesopinteractive LLC |
|
| 10 | + */ |
|
| 11 | 11 | namespace lasso_admin; |
| 12 | 12 | |
| 13 | 13 | use lasso_public_facing\lasso; |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
| 130 | - * Adds an admin notice reminding the user if their license key has not been saved |
|
| 131 | - * |
|
| 132 | - * @since 0.9.7 |
|
| 133 | - * @todo make dismissible |
|
| 134 | - */ |
|
| 130 | + * Adds an admin notice reminding the user if their license key has not been saved |
|
| 131 | + * |
|
| 132 | + * @since 0.9.7 |
|
| 133 | + * @todo make dismissible |
|
| 134 | + */ |
|
| 135 | 135 | public function license_nag(){ |
| 136 | 136 | |
| 137 | 137 | $screen = get_current_screen(); |
@@ -152,26 +152,26 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | if ( empty( $license ) ) { |
| 154 | 154 | |
| 155 | - printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_empty, $license_link, $dismiss_link ); |
|
| 155 | + printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_empty, $license_link, $dismiss_link ); |
|
| 156 | 156 | |
| 157 | - } else if ( 'invalid' == $status ){ // license key entered wrong or something |
|
| 157 | + } else if ( 'invalid' == $status ){ // license key entered wrong or something |
|
| 158 | 158 | |
| 159 | 159 | printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_invalid, $license_link , $dismiss_link ); |
| 160 | 160 | |
| 161 | - } else if ( empty( $status ) ){ // license key saved but not activated |
|
| 161 | + } else if ( empty( $status ) ){ // license key saved but not activated |
|
| 162 | 162 | |
| 163 | 163 | printf('<div class="lasso-notice error" style="position:relative;"><p>%s %s</p>%s</div>', $message_inactive, $license_link, $dismiss_link ); |
| 164 | 164 | |
| 165 | - } |
|
| 165 | + } |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | - * Process hiding the dimiss |
|
| 172 | - * |
|
| 173 | - * @since 0.9.7 |
|
| 174 | - */ |
|
| 171 | + * Process hiding the dimiss |
|
| 172 | + * |
|
| 173 | + * @since 0.9.7 |
|
| 174 | + */ |
|
| 175 | 175 | public function dismiss_nag() { |
| 176 | 176 | |
| 177 | 177 | if ( isset( $_GET['lasso-notice'] ) && 'dismiss' == $_GET['lasso-notice'] && current_user_can('manage_options') ) { |
@@ -6,79 +6,79 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | function __construct() { |
| 8 | 8 | |
| 9 | - define( 'LASSO_STORE_ITEM_NAME', 'lasso' ); |
|
| 10 | - define( 'LASSO_STORE_URL', 'https://edituswp.com' ); |
|
| 11 | - |
|
| 12 | - add_action( 'admin_init', array( $this, 'plugin_updater' ), 0 ); |
|
| 13 | - add_action( 'admin_menu', array( $this, 'license_menu' ) ); |
|
| 14 | - add_action( 'admin_init', array( $this, 'register_option' ) ); |
|
| 15 | - add_action( 'admin_init', array( $this, 'activate_license' ) ); |
|
| 16 | - add_action( 'admin_init', array( $this, 'deactivate_license' ) ); |
|
| 9 | + define('LASSO_STORE_ITEM_NAME', 'lasso'); |
|
| 10 | + define('LASSO_STORE_URL', 'https://edituswp.com'); |
|
| 11 | + |
|
| 12 | + add_action('admin_init', array($this, 'plugin_updater'), 0); |
|
| 13 | + add_action('admin_menu', array($this, 'license_menu')); |
|
| 14 | + add_action('admin_init', array($this, 'register_option')); |
|
| 15 | + add_action('admin_init', array($this, 'activate_license')); |
|
| 16 | + add_action('admin_init', array($this, 'deactivate_license')); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | function plugin_updater() { |
| 20 | 20 | |
| 21 | 21 | // retrieve our license key from the DB |
| 22 | - $license_key = trim( get_option( 'lasso_license_key' ) ); |
|
| 22 | + $license_key = trim(get_option('lasso_license_key')); |
|
| 23 | 23 | |
| 24 | 24 | // setup the updater |
| 25 | - $edd_updater = new \EDD_SL_Plugin_Updater( LASSO_STORE_URL , LASSO_FILE, array( |
|
| 25 | + $edd_updater = new \EDD_SL_Plugin_Updater(LASSO_STORE_URL, LASSO_FILE, array( |
|
| 26 | 26 | 'version' => LASSO_VERSION, |
| 27 | 27 | 'license' => $license_key, |
| 28 | 28 | 'item_name' => LASSO_STORE_ITEM_NAME, |
| 29 | - 'author' => __( 'Aesopinteractive LLC', 'lasso' ) |
|
| 29 | + 'author' => __('Aesopinteractive LLC', 'lasso') |
|
| 30 | 30 | ) |
| 31 | 31 | ); |
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | function license_menu() { |
| 35 | 35 | |
| 36 | - if ( function_exists( 'is_multisite' ) && !is_multisite() ) { |
|
| 37 | - add_submenu_page( 'lasso-editor', __( 'License Key', 'lasso' ), __( 'License', 'lasso' ), 'manage_options', 'lasso-license', array( $this, 'license_page' ) ); |
|
| 36 | + if (function_exists('is_multisite') && !is_multisite()) { |
|
| 37 | + add_submenu_page('lasso-editor', __('License Key', 'lasso'), __('License', 'lasso'), 'manage_options', 'lasso-license', array($this, 'license_page')); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | function license_page() { |
| 41 | - $license = get_option( 'lasso_license_key' ); |
|
| 42 | - $status = get_option( 'lasso_license_status' ); |
|
| 41 | + $license = get_option('lasso_license_key'); |
|
| 42 | + $status = get_option('lasso_license_status'); |
|
| 43 | 43 | |
| 44 | 44 | ?> |
| 45 | 45 | <div class="wrap"> |
| 46 | - <h2><?php _e( 'Editus License', 'lasso' ); ?></h2> |
|
| 47 | - <p><?php _e( 'Input the license key you recieved with your purchase to ensure your version of Editus stays updated.', 'lasso' );?></p> |
|
| 46 | + <h2><?php _e('Editus License', 'lasso'); ?></h2> |
|
| 47 | + <p><?php _e('Input the license key you recieved with your purchase to ensure your version of Editus stays updated.', 'lasso'); ?></p> |
|
| 48 | 48 | <form class="lasso--form-settings" method="post" action="options.php"> |
| 49 | 49 | |
| 50 | - <?php settings_fields( 'lasso_license' ); ?> |
|
| 50 | + <?php settings_fields('lasso_license'); ?> |
|
| 51 | 51 | |
| 52 | 52 | <table class="form-table"> |
| 53 | 53 | <tbody> |
| 54 | 54 | <tr valign="top"> |
| 55 | 55 | <th scope="row" valign="top"> |
| 56 | - <?php _e( 'License Key', 'lasso' ); ?> |
|
| 56 | + <?php _e('License Key', 'lasso'); ?> |
|
| 57 | 57 | </th> |
| 58 | 58 | <td> |
| 59 | - <input id="lasso_license_key" name="lasso_license_key" type="text" class="regular-text" value="<?php esc_attr_e( $license ); ?>" /> |
|
| 59 | + <input id="lasso_license_key" name="lasso_license_key" type="text" class="regular-text" value="<?php esc_attr_e($license); ?>" /> |
|
| 60 | 60 | </td> |
| 61 | 61 | </tr> |
| 62 | - <?php if ( false !== $license ) { ?> |
|
| 62 | + <?php if (false !== $license) { ?> |
|
| 63 | 63 | <tr valign="top"> |
| 64 | 64 | <th scope="row" valign="top"> |
| 65 | - <?php _e( 'Activate License', 'lasso' ); ?> |
|
| 65 | + <?php _e('Activate License', 'lasso'); ?> |
|
| 66 | 66 | </th> |
| 67 | 67 | <td> |
| 68 | - <?php if ( $status !== false && $status == 'valid' ) { ?> |
|
| 69 | - <span style="color:green;"><?php _e( 'active' ); ?></span> |
|
| 70 | - <?php wp_nonce_field( 'lasso_license_nonce', 'lasso_license_nonce' ); ?> |
|
| 71 | - <input type="submit" class="button-secondary" name="edd_license_deactivate" value="<?php esc_attr_e( 'Deactivate License', 'lasso' ); ?>"/> |
|
| 68 | + <?php if ($status !== false && $status == 'valid') { ?> |
|
| 69 | + <span style="color:green;"><?php _e('active'); ?></span> |
|
| 70 | + <?php wp_nonce_field('lasso_license_nonce', 'lasso_license_nonce'); ?> |
|
| 71 | + <input type="submit" class="button-secondary" name="edd_license_deactivate" value="<?php esc_attr_e('Deactivate License', 'lasso'); ?>"/> |
|
| 72 | 72 | <?php } else { |
| 73 | - wp_nonce_field( 'lasso_license_nonce', 'lasso_license_nonce' ); ?> |
|
| 74 | - <input type="submit" class="button-secondary" name="edd_license_activate" value="<?php esc_attr_e( 'Activate License', 'lasso' ); ?>"/> |
|
| 73 | + wp_nonce_field('lasso_license_nonce', 'lasso_license_nonce'); ?> |
|
| 74 | + <input type="submit" class="button-secondary" name="edd_license_activate" value="<?php esc_attr_e('Activate License', 'lasso'); ?>"/> |
|
| 75 | 75 | <?php } ?> |
| 76 | 76 | </td> |
| 77 | 77 | </tr> |
| 78 | 78 | <?php } ?> |
| 79 | 79 | </tbody> |
| 80 | 80 | </table> |
| 81 | - <?php submit_button( 'Save License' ); ?> |
|
| 81 | + <?php submit_button('Save License'); ?> |
|
| 82 | 82 | |
| 83 | 83 | </form> |
| 84 | 84 | <?php |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | // register option |
| 88 | 88 | function register_option() { |
| 89 | 89 | |
| 90 | - register_setting( 'lasso_license', 'lasso_license_key', array( $this, 'sanitize_license' ) ); |
|
| 90 | + register_setting('lasso_license', 'lasso_license_key', array($this, 'sanitize_license')); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // santize |
| 94 | - function sanitize_license( $new ) { |
|
| 95 | - $old = get_option( 'lasso_license_key' ); |
|
| 96 | - if ( $old && $old != $new ) { |
|
| 97 | - delete_option( 'lasso_license_status' ); // new license has been entered, so must reactivate |
|
| 94 | + function sanitize_license($new) { |
|
| 95 | + $old = get_option('lasso_license_key'); |
|
| 96 | + if ($old && $old != $new) { |
|
| 97 | + delete_option('lasso_license_status'); // new license has been entered, so must reactivate |
|
| 98 | 98 | } |
| 99 | 99 | return $new; |
| 100 | 100 | } |
@@ -103,36 +103,36 @@ discard block |
||
| 103 | 103 | function activate_license() { |
| 104 | 104 | |
| 105 | 105 | // listen for our activate button to be clicked |
| 106 | - if ( isset( $_POST['edd_license_activate'] ) ) { |
|
| 106 | + if (isset($_POST['edd_license_activate'])) { |
|
| 107 | 107 | |
| 108 | 108 | // run a quick security check |
| 109 | - if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) |
|
| 109 | + if (!check_admin_referer('lasso_license_nonce', 'lasso_license_nonce')) |
|
| 110 | 110 | return; // get out if we didn't click the Activate button |
| 111 | 111 | |
| 112 | 112 | // retrieve the license from the database |
| 113 | - $license = trim( get_option( 'lasso_license_key' ) ); |
|
| 113 | + $license = trim(get_option('lasso_license_key')); |
|
| 114 | 114 | |
| 115 | 115 | // data to send in our API request |
| 116 | 116 | $api_params = array( |
| 117 | 117 | 'edd_action'=> 'activate_license', |
| 118 | 118 | 'license' => $license, |
| 119 | - 'item_name' => urlencode( LASSO_STORE_ITEM_NAME ), // the name of our product in EDD |
|
| 119 | + 'item_name' => urlencode(LASSO_STORE_ITEM_NAME), // the name of our product in EDD |
|
| 120 | 120 | 'url' => home_url() |
| 121 | 121 | ); |
| 122 | 122 | |
| 123 | 123 | // Call the custom API. |
| 124 | - $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
|
| 124 | + $response = wp_remote_post(LASSO_STORE_URL, array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
|
| 125 | 125 | |
| 126 | 126 | // make sure the response came back okay |
| 127 | - if ( is_wp_error( $response ) ) |
|
| 127 | + if (is_wp_error($response)) |
|
| 128 | 128 | return false; |
| 129 | 129 | |
| 130 | 130 | // decode the license data |
| 131 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 131 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 132 | 132 | |
| 133 | 133 | // $license_data->license will be either "valid" or "invalid" |
| 134 | 134 | |
| 135 | - update_option( 'lasso_license_status', $license_data->license ); |
|
| 135 | + update_option('lasso_license_status', $license_data->license); |
|
| 136 | 136 | |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -140,37 +140,37 @@ discard block |
||
| 140 | 140 | function deactivate_license() { |
| 141 | 141 | |
| 142 | 142 | // listen for our activate button to be clicked |
| 143 | - if ( isset( $_POST['edd_license_deactivate'] ) ) { |
|
| 143 | + if (isset($_POST['edd_license_deactivate'])) { |
|
| 144 | 144 | |
| 145 | 145 | // run a quick security check |
| 146 | - if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) |
|
| 146 | + if (!check_admin_referer('lasso_license_nonce', 'lasso_license_nonce')) |
|
| 147 | 147 | return; // get out if we didn't click the Activate button |
| 148 | 148 | |
| 149 | 149 | // retrieve the license from the database |
| 150 | - $license = trim( get_option( 'lasso_license_key' ) ); |
|
| 150 | + $license = trim(get_option('lasso_license_key')); |
|
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | // data to send in our API request |
| 154 | 154 | $api_params = array( |
| 155 | 155 | 'edd_action'=> 'deactivate_license', |
| 156 | 156 | 'license' => $license, |
| 157 | - 'item_name' => urlencode( LASSO_STORE_ITEM_NAME ), // the name of our product in EDD |
|
| 157 | + 'item_name' => urlencode(LASSO_STORE_ITEM_NAME), // the name of our product in EDD |
|
| 158 | 158 | 'url' => home_url() |
| 159 | 159 | ); |
| 160 | 160 | |
| 161 | 161 | // Call the custom API. |
| 162 | - $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
|
| 162 | + $response = wp_remote_post(LASSO_STORE_URL, array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
|
| 163 | 163 | |
| 164 | 164 | // make sure the response came back okay |
| 165 | - if ( is_wp_error( $response ) ) |
|
| 165 | + if (is_wp_error($response)) |
|
| 166 | 166 | return false; |
| 167 | 167 | |
| 168 | 168 | // decode the license data |
| 169 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 169 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 170 | 170 | |
| 171 | 171 | // $license_data->license will be either "deactivated" or "failed" |
| 172 | - if ( $license_data->license == 'deactivated' ) |
|
| 173 | - delete_option( 'lasso_license_status' ); |
|
| 172 | + if ($license_data->license == 'deactivated') |
|
| 173 | + delete_option('lasso_license_status'); |
|
| 174 | 174 | |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | global $wp_version; |
| 182 | 182 | |
| 183 | - $license = trim( get_option( 'lasso_license_key' ) ); |
|
| 183 | + $license = trim(get_option('lasso_license_key')); |
|
| 184 | 184 | |
| 185 | 185 | $api_params = array( |
| 186 | 186 | 'edd_action' => 'check_license', |
| 187 | 187 | 'license' => $license, |
| 188 | - 'item_name' => urlencode( LASSO_STORE_ITEM_NAME ), |
|
| 188 | + 'item_name' => urlencode(LASSO_STORE_ITEM_NAME), |
|
| 189 | 189 | 'url' => home_url() |
| 190 | 190 | ); |
| 191 | 191 | |
| 192 | 192 | // Call the custom API. |
| 193 | - $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
|
| 193 | + $response = wp_remote_post(LASSO_STORE_URL, array('body' => $api_params, 'timeout' => 15, 'sslverify' => false)); |
|
| 194 | 194 | |
| 195 | - if ( is_wp_error( $response ) ) |
|
| 195 | + if (is_wp_error($response)) |
|
| 196 | 196 | return false; |
| 197 | 197 | |
| 198 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 198 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 199 | 199 | |
| 200 | - if ( $license_data->license == 'valid' ) { |
|
| 200 | + if ($license_data->license == 'valid') { |
|
| 201 | 201 | echo 'valid'; exit; |
| 202 | 202 | // this license is still valid |
| 203 | 203 | } else { |
@@ -106,8 +106,10 @@ discard block |
||
| 106 | 106 | if ( isset( $_POST['edd_license_activate'] ) ) { |
| 107 | 107 | |
| 108 | 108 | // run a quick security check |
| 109 | - if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) |
|
| 110 | - return; // get out if we didn't click the Activate button |
|
| 109 | + if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) { |
|
| 110 | + return; |
|
| 111 | + } |
|
| 112 | + // get out if we didn't click the Activate button |
|
| 111 | 113 | |
| 112 | 114 | // retrieve the license from the database |
| 113 | 115 | $license = trim( get_option( 'lasso_license_key' ) ); |
@@ -124,8 +126,9 @@ discard block |
||
| 124 | 126 | $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
| 125 | 127 | |
| 126 | 128 | // make sure the response came back okay |
| 127 | - if ( is_wp_error( $response ) ) |
|
| 128 | - return false; |
|
| 129 | + if ( is_wp_error( $response ) ) { |
|
| 130 | + return false; |
|
| 131 | + } |
|
| 129 | 132 | |
| 130 | 133 | // decode the license data |
| 131 | 134 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
@@ -143,8 +146,10 @@ discard block |
||
| 143 | 146 | if ( isset( $_POST['edd_license_deactivate'] ) ) { |
| 144 | 147 | |
| 145 | 148 | // run a quick security check |
| 146 | - if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) |
|
| 147 | - return; // get out if we didn't click the Activate button |
|
| 149 | + if ( ! check_admin_referer( 'lasso_license_nonce', 'lasso_license_nonce' ) ) { |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + // get out if we didn't click the Activate button |
|
| 148 | 153 | |
| 149 | 154 | // retrieve the license from the database |
| 150 | 155 | $license = trim( get_option( 'lasso_license_key' ) ); |
@@ -162,15 +167,17 @@ discard block |
||
| 162 | 167 | $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
| 163 | 168 | |
| 164 | 169 | // make sure the response came back okay |
| 165 | - if ( is_wp_error( $response ) ) |
|
| 166 | - return false; |
|
| 170 | + if ( is_wp_error( $response ) ) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 167 | 173 | |
| 168 | 174 | // decode the license data |
| 169 | 175 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 170 | 176 | |
| 171 | 177 | // $license_data->license will be either "deactivated" or "failed" |
| 172 | - if ( $license_data->license == 'deactivated' ) |
|
| 173 | - delete_option( 'lasso_license_status' ); |
|
| 178 | + if ( $license_data->license == 'deactivated' ) { |
|
| 179 | + delete_option( 'lasso_license_status' ); |
|
| 180 | + } |
|
| 174 | 181 | |
| 175 | 182 | } |
| 176 | 183 | } |
@@ -192,8 +199,9 @@ discard block |
||
| 192 | 199 | // Call the custom API. |
| 193 | 200 | $response = wp_remote_post( LASSO_STORE_URL, array( 'body' => $api_params, 'timeout' => 15, 'sslverify' => false ) ); |
| 194 | 201 | |
| 195 | - if ( is_wp_error( $response ) ) |
|
| 196 | - return false; |
|
| 202 | + if ( is_wp_error( $response ) ) { |
|
| 203 | + return false; |
|
| 204 | + } |
|
| 197 | 205 | |
| 198 | 206 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 199 | 207 | |
@@ -1,8 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Class responsible for adding a settings submenu |
|
| 4 | - * |
|
| 5 | - */ |
|
| 3 | + * Class responsible for adding a settings submenu |
|
| 4 | + * |
|
| 5 | + */ |
|
| 6 | 6 | namespace lasso_admin\menus; |
| 7 | 7 | |
| 8 | 8 | class settings { |
@@ -9,9 +9,9 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | function __construct() { |
| 11 | 11 | |
| 12 | - add_action( 'admin_menu', array( $this, 'menu' ) ); |
|
| 13 | - add_action( 'network_admin_menu', array( $this, 'menu' ) ); |
|
| 14 | - add_action( 'wp_ajax_lasso-editor-settings', array( $this, 'process_settings' ) ); |
|
| 12 | + add_action('admin_menu', array($this, 'menu')); |
|
| 13 | + add_action('network_admin_menu', array($this, 'menu')); |
|
| 14 | + add_action('wp_ajax_lasso-editor-settings', array($this, 'process_settings')); |
|
| 15 | 15 | |
| 16 | 16 | } |
| 17 | 17 | |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | function menu() { |
| 24 | 24 | |
| 25 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 25 | + if (function_exists('is_multisite') && is_multisite()) { |
|
| 26 | 26 | |
| 27 | - add_submenu_page( 'settings.php', __( 'Editus', 'lasso' ), __( 'Editus', 'lasso' ), 'manage_network', 'lasso-editor', array( $this, 'settings' ) ); |
|
| 27 | + add_submenu_page('settings.php', __('Editus', 'lasso'), __('Editus', 'lasso'), 'manage_network', 'lasso-editor', array($this, 'settings')); |
|
| 28 | 28 | |
| 29 | 29 | } else { |
| 30 | 30 | |
| 31 | - add_submenu_page( 'lasso-editor', __( 'Settings', 'lasso' ), __( 'Settings', 'lasso' ), 'manage_options', 'lasso-editor-settings', array( $this, 'settings' ) ); |
|
| 31 | + add_submenu_page('lasso-editor', __('Settings', 'lasso'), __('Settings', 'lasso'), 'manage_options', 'lasso-editor-settings', array($this, 'settings')); |
|
| 32 | 32 | |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -51,22 +51,22 @@ discard block |
||
| 51 | 51 | function process_settings() { |
| 52 | 52 | |
| 53 | 53 | // bail out if current user isn't and administrator and they are not logged in |
| 54 | - if ( !current_user_can( 'manage_options' ) || !is_user_logged_in() ) |
|
| 54 | + if (!current_user_can('manage_options') || !is_user_logged_in()) |
|
| 55 | 55 | return; |
| 56 | 56 | |
| 57 | - if ( isset( $_POST['action'] ) && 'lasso-editor-settings' == $_POST['action'] && check_admin_referer( 'nonce', 'lasso_editor_settings' ) ) { |
|
| 57 | + if (isset($_POST['action']) && 'lasso-editor-settings' == $_POST['action'] && check_admin_referer('nonce', 'lasso_editor_settings')) { |
|
| 58 | 58 | |
| 59 | - $options = isset( $_POST['lasso_editor'] ) ? $_POST['lasso_editor'] : false; |
|
| 59 | + $options = isset($_POST['lasso_editor']) ? $_POST['lasso_editor'] : false; |
|
| 60 | 60 | |
| 61 | - $options = array_map( 'sanitize_text_field', $options ); |
|
| 61 | + $options = array_map('sanitize_text_field', $options); |
|
| 62 | 62 | |
| 63 | - if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
|
| 63 | + if (function_exists('is_multisite') && is_multisite()) { |
|
| 64 | 64 | |
| 65 | - update_site_option( 'lasso_editor', $options ); |
|
| 65 | + update_site_option('lasso_editor', $options); |
|
| 66 | 66 | |
| 67 | 67 | } else { |
| 68 | 68 | |
| 69 | - update_option( 'lasso_editor', $options ); |
|
| 69 | + update_option('lasso_editor', $options); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | wp_send_json_success(); |
@@ -88,111 +88,111 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | function lasso_editor_settings_form() { |
| 90 | 90 | |
| 91 | - if ( !is_user_logged_in() ) |
|
| 91 | + if (!is_user_logged_in()) |
|
| 92 | 92 | return; |
| 93 | 93 | |
| 94 | - $article_object = lasso_editor_get_option( 'article_class', 'lasso_editor' ); |
|
| 95 | - $featImgClass = lasso_editor_get_option( 'featimg_class', 'lasso_editor' ); |
|
| 96 | - $titleClass = lasso_editor_get_option( 'title_class', 'lasso_editor' ); |
|
| 94 | + $article_object = lasso_editor_get_option('article_class', 'lasso_editor'); |
|
| 95 | + $featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor'); |
|
| 96 | + $titleClass = lasso_editor_get_option('title_class', 'lasso_editor'); |
|
| 97 | 97 | |
| 98 | - $post_new_disabled = lasso_editor_get_option( 'post_adding_disabled', 'lasso_editor' ); |
|
| 99 | - $save_to_post_disabled = lasso_editor_get_option( 'post_save_disabled', 'lasso_editor' ); |
|
| 100 | - $post_settings_disabled = lasso_editor_get_option( 'post_settings_disabled', 'lasso_editor' ); |
|
| 101 | - $shortcodify_disabled = lasso_editor_get_option( 'shortcodify_disabled', 'lasso_editor' ); |
|
| 98 | + $post_new_disabled = lasso_editor_get_option('post_adding_disabled', 'lasso_editor'); |
|
| 99 | + $save_to_post_disabled = lasso_editor_get_option('post_save_disabled', 'lasso_editor'); |
|
| 100 | + $post_settings_disabled = lasso_editor_get_option('post_settings_disabled', 'lasso_editor'); |
|
| 101 | + $shortcodify_disabled = lasso_editor_get_option('shortcodify_disabled', 'lasso_editor'); |
|
| 102 | 102 | |
| 103 | - $toolbar_headings = lasso_editor_get_option( 'toolbar_headings', 'lasso_editor' ); |
|
| 104 | - $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); |
|
| 103 | + $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); |
|
| 104 | + $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); |
|
| 105 | 105 | |
| 106 | 106 | ?> |
| 107 | 107 | <div class="wrap"> |
| 108 | 108 | |
| 109 | - <h2><?php _e( 'Editus Settings', 'lasso' );?></h2> |
|
| 109 | + <h2><?php _e('Editus Settings', 'lasso'); ?></h2> |
|
| 110 | 110 | |
| 111 | 111 | <form id="lasso-editor-settings-form" class="lasso--form-settings" method="post" enctype="multipart/form-data"> |
| 112 | 112 | |
| 113 | - <?php do_action('lasso_settings_before');?> |
|
| 113 | + <?php do_action('lasso_settings_before'); ?> |
|
| 114 | 114 | |
| 115 | 115 | <div class="lasso-editor-settings--option-wrap"> |
| 116 | 116 | <div class="lasso-editor-settings--option-inner"> |
| 117 | - <label><?php _e( 'Article Class', 'lasso' );?></label> |
|
| 118 | - <span class="lasso--setting-description"><?php _e( 'Provide the CSS class (including the preceding dot) of container that holds the post. This should be the first parent container class that holds the_content.', 'lasso' );?></span> |
|
| 119 | - <input required type="text" name="lasso_editor[article_class]" id="lasso_editor[article_class]" value="<?php echo esc_attr( $article_object );?>" placeholder=".entry-content"> |
|
| 117 | + <label><?php _e('Article Class', 'lasso'); ?></label> |
|
| 118 | + <span class="lasso--setting-description"><?php _e('Provide the CSS class (including the preceding dot) of container that holds the post. This should be the first parent container class that holds the_content.', 'lasso'); ?></span> |
|
| 119 | + <input required type="text" name="lasso_editor[article_class]" id="lasso_editor[article_class]" value="<?php echo esc_attr($article_object); ?>" placeholder=".entry-content"> |
|
| 120 | 120 | </div> |
| 121 | 121 | </div> |
| 122 | 122 | |
| 123 | 123 | <div class="lasso-editor-settings--option-wrap"> |
| 124 | 124 | <div class="lasso-editor-settings--option-inner"> |
| 125 | - <label><?php _e( 'Featured Image Class', 'lasso' );?></label> |
|
| 126 | - <span class="lasso--setting-description"><?php _e( 'Provide the CSS class that uses a featured image as a background image. This currently only supports themes that have the featured image set as background image.', 'lasso' );?></span> |
|
| 127 | - <input type="text" name="lasso_editor[featimg_class]" id="lasso_editor[featimg_class]" value="<?php echo esc_attr( $featImgClass );?>" placeholder=".entry-content"> |
|
| 125 | + <label><?php _e('Featured Image Class', 'lasso'); ?></label> |
|
| 126 | + <span class="lasso--setting-description"><?php _e('Provide the CSS class that uses a featured image as a background image. This currently only supports themes that have the featured image set as background image.', 'lasso'); ?></span> |
|
| 127 | + <input type="text" name="lasso_editor[featimg_class]" id="lasso_editor[featimg_class]" value="<?php echo esc_attr($featImgClass); ?>" placeholder=".entry-content"> |
|
| 128 | 128 | </div> |
| 129 | 129 | </div> |
| 130 | 130 | |
| 131 | 131 | <div class="lasso-editor-settings--option-wrap"> |
| 132 | 132 | <div class="lasso-editor-settings--option-inner"> |
| 133 | - <label><?php _e( 'Article Title Class', 'lasso' );?></label> |
|
| 134 | - <span class="lasso--setting-description"><?php _e( 'Provide the CSS class for the post title. This will enable you to update the title of the post by clicking and typing.', 'lasso' );?></span> |
|
| 135 | - <input type="text" name="lasso_editor[title_class]" id="lasso_editor[title_class]" value="<?php echo esc_attr( $titleClass );?>" placeholder=".entry-content"> |
|
| 133 | + <label><?php _e('Article Title Class', 'lasso'); ?></label> |
|
| 134 | + <span class="lasso--setting-description"><?php _e('Provide the CSS class for the post title. This will enable you to update the title of the post by clicking and typing.', 'lasso'); ?></span> |
|
| 135 | + <input type="text" name="lasso_editor[title_class]" id="lasso_editor[title_class]" value="<?php echo esc_attr($titleClass); ?>" placeholder=".entry-content"> |
|
| 136 | 136 | </div> |
| 137 | 137 | </div> |
| 138 | 138 | |
| 139 | 139 | <!-- Advanced --> |
| 140 | 140 | <div class="lasso-editor-settings--option-wrap"> |
| 141 | 141 | <div class="lasso-editor-settings--option-inner"> |
| 142 | - <label><?php _e( 'Ignored Items to Save', 'lasso' );?></label> |
|
| 143 | - <span class="lasso--setting-description"><?php _e( 'If your post container holds additional markup, list the css class names (comma separated, including the dot) of those items. When you enter the editor, Editus will remove (NOT delete) these items so that it does not save them as HTML.', 'lasso' );?></span> |
|
| 144 | - <textarea name="lasso_editor[dont_save]" id="lasso_editor[dont_save]" placeholder=".classname, .another-class"><?php echo esc_attr( $objectsNoSave );?></textarea> |
|
| 142 | + <label><?php _e('Ignored Items to Save', 'lasso'); ?></label> |
|
| 143 | + <span class="lasso--setting-description"><?php _e('If your post container holds additional markup, list the css class names (comma separated, including the dot) of those items. When you enter the editor, Editus will remove (NOT delete) these items so that it does not save them as HTML.', 'lasso'); ?></span> |
|
| 144 | + <textarea name="lasso_editor[dont_save]" id="lasso_editor[dont_save]" placeholder=".classname, .another-class"><?php echo esc_attr($objectsNoSave); ?></textarea> |
|
| 145 | 145 | </div> |
| 146 | 146 | </div> |
| 147 | 147 | |
| 148 | 148 | <div class="lasso-editor-settings--option-wrap"> |
| 149 | 149 | <div class="lasso-editor-settings--option-inner"> |
| 150 | - <input type="checkbox" class="checkbox" name="lasso_editor[toolbar_headings]" id="lasso_editor[toolbar_headings]" <?php echo checked( $toolbar_headings, 'on' );?> > |
|
| 151 | - <label for="lasso_editor[toolbar_headings]"><?php _e( 'Enable Toolbar Headings', 'lasso' );?></label> |
|
| 152 | - <span class="lasso--setting-description"><?php _e( 'By default the H2 and H3 options for headings are in the insert HTML area. You may prefer those headings to act just like the underline, and strikethrough, so toggling this will add them to the toolbar.', 'lasso' );?></span> |
|
| 150 | + <input type="checkbox" class="checkbox" name="lasso_editor[toolbar_headings]" id="lasso_editor[toolbar_headings]" <?php echo checked($toolbar_headings, 'on'); ?> > |
|
| 151 | + <label for="lasso_editor[toolbar_headings]"><?php _e('Enable Toolbar Headings', 'lasso'); ?></label> |
|
| 152 | + <span class="lasso--setting-description"><?php _e('By default the H2 and H3 options for headings are in the insert HTML area. You may prefer those headings to act just like the underline, and strikethrough, so toggling this will add them to the toolbar.', 'lasso'); ?></span> |
|
| 153 | 153 | |
| 154 | 154 | </div> |
| 155 | 155 | </div> |
| 156 | 156 | |
| 157 | 157 | <div class="lasso-editor-settings--option-wrap"> |
| 158 | 158 | <div class="lasso-editor-settings--option-inner"> |
| 159 | - <input type="checkbox" class="checkbox" name="lasso_editor[post_save_disabled]" id="lasso_editor[post_save_disabled]" <?php echo checked( $save_to_post_disabled, 'on' );?> > |
|
| 160 | - <label for="lasso_editor[post_save_disabled]"><?php _e( 'Disable Post Saving', 'lasso' );?></label> |
|
| 161 | - <span class="lasso--setting-description"><?php _e( 'By default the editor will update the database with the post or page it is being used on. Check this box to disable this. If you check this box, it is assumed that you will be using the provided filters to save your own content.', 'lasso' );?></span> |
|
| 159 | + <input type="checkbox" class="checkbox" name="lasso_editor[post_save_disabled]" id="lasso_editor[post_save_disabled]" <?php echo checked($save_to_post_disabled, 'on'); ?> > |
|
| 160 | + <label for="lasso_editor[post_save_disabled]"><?php _e('Disable Post Saving', 'lasso'); ?></label> |
|
| 161 | + <span class="lasso--setting-description"><?php _e('By default the editor will update the database with the post or page it is being used on. Check this box to disable this. If you check this box, it is assumed that you will be using the provided filters to save your own content.', 'lasso'); ?></span> |
|
| 162 | 162 | |
| 163 | 163 | </div> |
| 164 | 164 | </div> |
| 165 | 165 | |
| 166 | 166 | <div class="lasso-editor-settings--option-wrap"> |
| 167 | 167 | <div class="lasso-editor-settings--option-inner"> |
| 168 | - <input type="checkbox" class="checkbox" name="lasso_editor[post_settings_disabled]" id="lasso_editor[post_settings_disabled]" <?php echo checked( $post_settings_disabled, 'on' );?> > |
|
| 169 | - <label for="lasso_editor[post_settings_disabled]"> <?php _e( 'Disable Post Settings', 'lasso' );?></label> |
|
| 170 | - <span class="lasso--setting-description"><?php _e( 'Check this to disable users from being able to edit post settings from the front-end.', 'lasso' );?></span> |
|
| 168 | + <input type="checkbox" class="checkbox" name="lasso_editor[post_settings_disabled]" id="lasso_editor[post_settings_disabled]" <?php echo checked($post_settings_disabled, 'on'); ?> > |
|
| 169 | + <label for="lasso_editor[post_settings_disabled]"> <?php _e('Disable Post Settings', 'lasso'); ?></label> |
|
| 170 | + <span class="lasso--setting-description"><?php _e('Check this to disable users from being able to edit post settings from the front-end.', 'lasso'); ?></span> |
|
| 171 | 171 | </div> |
| 172 | 172 | </div> |
| 173 | 173 | |
| 174 | 174 | <div class="lasso-editor-settings--option-wrap"> |
| 175 | 175 | <div class="lasso-editor-settings--option-inner"> |
| 176 | - <input type="checkbox" class="checkbox" name="lasso_editor[post_adding_disabled]" id="lasso_editor[post_adding_disabled]" <?php echo checked( $post_new_disabled, 'on' );?> > |
|
| 177 | - <label for="lasso_editor[post_adding_disabled]"><?php _e( 'Disable Post Adding', 'lasso' );?></label> |
|
| 178 | - <span class="lasso--setting-description"><?php _e( 'Check this box to disable users from being able to add new posts from the front-end.', 'lasso' );?></span> |
|
| 176 | + <input type="checkbox" class="checkbox" name="lasso_editor[post_adding_disabled]" id="lasso_editor[post_adding_disabled]" <?php echo checked($post_new_disabled, 'on'); ?> > |
|
| 177 | + <label for="lasso_editor[post_adding_disabled]"><?php _e('Disable Post Adding', 'lasso'); ?></label> |
|
| 178 | + <span class="lasso--setting-description"><?php _e('Check this box to disable users from being able to add new posts from the front-end.', 'lasso'); ?></span> |
|
| 179 | 179 | </div> |
| 180 | 180 | </div> |
| 181 | 181 | |
| 182 | 182 | <div class="lasso-editor-settings--option-wrap last"> |
| 183 | 183 | <div class="lasso-editor-settings--option-inner"> |
| 184 | - <input type="checkbox" class="checkbox" name="lasso_editor[shortcodify_disabled]" id="lasso_editor[shortcodify_disabled]" <?php echo checked( $shortcodify_disabled, 'on' );?> > |
|
| 185 | - <label for="lasso_editor[shortcodify_disabled]"><?php _e( 'Disable Aesop Component Conversion', 'lasso' );?></label> |
|
| 186 | - <span class="lasso--setting-description"><?php _e( 'Check this box to disable the conversion process used on Aesop Story Engine components.', 'lasso' );?></span> |
|
| 184 | + <input type="checkbox" class="checkbox" name="lasso_editor[shortcodify_disabled]" id="lasso_editor[shortcodify_disabled]" <?php echo checked($shortcodify_disabled, 'on'); ?> > |
|
| 185 | + <label for="lasso_editor[shortcodify_disabled]"><?php _e('Disable Aesop Component Conversion', 'lasso'); ?></label> |
|
| 186 | + <span class="lasso--setting-description"><?php _e('Check this box to disable the conversion process used on Aesop Story Engine components.', 'lasso'); ?></span> |
|
| 187 | 187 | </div> |
| 188 | 188 | </div> |
| 189 | 189 | |
| 190 | - <?php do_action('lasso_settings_after');?> |
|
| 190 | + <?php do_action('lasso_settings_after'); ?> |
|
| 191 | 191 | |
| 192 | 192 | <div class="lasso-editor-settings--submit"> |
| 193 | 193 | <input type="hidden" name="action" value="lasso-editor-settings" /> |
| 194 | - <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Settings', 'lasso' );?>" /> |
|
| 195 | - <?php wp_nonce_field( 'nonce', 'lasso_editor_settings' ); ?> |
|
| 194 | + <input type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'lasso'); ?>" /> |
|
| 195 | + <?php wp_nonce_field('nonce', 'lasso_editor_settings'); ?> |
|
| 196 | 196 | </div> |
| 197 | 197 | </form> |
| 198 | 198 | |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | function process_settings() { |
| 52 | 52 | |
| 53 | 53 | // bail out if current user isn't and administrator and they are not logged in |
| 54 | - if ( !current_user_can( 'manage_options' ) || !is_user_logged_in() ) |
|
| 55 | - return; |
|
| 54 | + if ( !current_user_can( 'manage_options' ) || !is_user_logged_in() ) { |
|
| 55 | + return; |
|
| 56 | + } |
|
| 56 | 57 | |
| 57 | 58 | if ( isset( $_POST['action'] ) && 'lasso-editor-settings' == $_POST['action'] && check_admin_referer( 'nonce', 'lasso_editor_settings' ) ) { |
| 58 | 59 | |
@@ -88,8 +89,9 @@ discard block |
||
| 88 | 89 | */ |
| 89 | 90 | function lasso_editor_settings_form() { |
| 90 | 91 | |
| 91 | - if ( !is_user_logged_in() ) |
|
| 92 | - return; |
|
| 92 | + if ( !is_user_logged_in() ) { |
|
| 93 | + return; |
|
| 94 | + } |
|
| 93 | 95 | |
| 94 | 96 | $article_object = lasso_editor_get_option( 'article_class', 'lasso_editor' ); |
| 95 | 97 | $featImgClass = lasso_editor_get_option( 'featimg_class', 'lasso_editor' ); |