@@ -28,19 +28,19 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return bool Always returns true. |
| 30 | 30 | */ |
| 31 | - public function post( $data ) { |
|
| 31 | + public function post($data) { |
|
| 32 | 32 | |
| 33 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
| 34 | - $title = isset( $data['title'] ) ? $data['title'] : false; |
|
| 33 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
| 34 | + $title = isset($data['title']) ? $data['title'] : false; |
|
| 35 | 35 | |
| 36 | 36 | $args = array( |
| 37 | 37 | 'ID' => (int) $postid, |
| 38 | - 'post_title' => wp_strip_all_tags( $title ) |
|
| 38 | + 'post_title' => wp_strip_all_tags($title) |
|
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | - wp_update_post( apply_filters( 'lasso_title_updated_args', $args ) ); |
|
| 41 | + wp_update_post(apply_filters('lasso_title_updated_args', $args)); |
|
| 42 | 42 | |
| 43 | - do_action( 'lasso_title_updated', $postid, $title, get_current_user_ID() ); |
|
| 43 | + do_action('lasso_title_updated', $postid, $title, get_current_user_ID()); |
|
| 44 | 44 | |
| 45 | 45 | return true; |
| 46 | 46 | |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return array Array of keys to pull from $data per action and their sanitization callback |
| 55 | 55 | */ |
| 56 | - public static function params(){ |
|
| 57 | - $params[ 'process_title_update_post' ] = array( |
|
| 56 | + public static function params() { |
|
| 57 | + $params['process_title_update_post'] = array( |
|
| 58 | 58 | 'postid' => 'absint', |
| 59 | 59 | 'title' => 'strip_tags' |
| 60 | 60 | ); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @return array Array of additional functions to use to authorize action. |
| 72 | 72 | */ |
| 73 | 73 | public static function auth_callbacks() { |
| 74 | - $params[ 'process_title_update_post' ] = array( |
|
| 74 | + $params['process_title_update_post'] = array( |
|
| 75 | 75 | 'lasso_user_can' |
| 76 | 76 | ); |
| 77 | 77 | |
@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @returns bool Always returns true |
| 28 | 28 | */ |
| 29 | - public function hide( $data ) { |
|
| 29 | + public function hide($data) { |
|
| 30 | 30 | |
| 31 | 31 | $user_id = get_current_user_ID(); |
| 32 | 32 | |
| 33 | - update_user_meta( $user_id, 'lasso_hide_tour', true ); |
|
| 33 | + update_user_meta($user_id, 'lasso_hide_tour', true); |
|
| 34 | 34 | |
| 35 | - do_action( 'lasso_tour_hidden', $user_id ); |
|
| 35 | + do_action('lasso_tour_hidden', $user_id); |
|
| 36 | 36 | |
| 37 | 37 | return true; |
| 38 | 38 | |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
| 47 | 47 | */ |
| 48 | - public static function params(){ |
|
| 49 | - $params[ 'process_tour_hide' ] = array( |
|
| 48 | + public static function params() { |
|
| 49 | + $params['process_tour_hide'] = array( |
|
| 50 | 50 | 'action' |
| 51 | 51 | ); |
| 52 | 52 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @return array Array of additional functions to use to authorize action. |
| 62 | 62 | */ |
| 63 | 63 | public static function auth_callbacks() { |
| 64 | - $params[ 'process_tour_hide' ] = array( |
|
| 64 | + $params['process_tour_hide'] = array( |
|
| 65 | 65 | 'lasso_user_can' |
| 66 | 66 | ); |
| 67 | 67 | |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return bool Always returns true. |
| 30 | 30 | */ |
| 31 | - public function upload( $data ) { |
|
| 31 | + public function upload($data) { |
|
| 32 | 32 | |
| 33 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
| 34 | - $image_id = isset( $data['image_id'] ) ? absint( $data['image_id'] ) : false; |
|
| 33 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
| 34 | + $image_id = isset($data['image_id']) ? absint($data['image_id']) : false; |
|
| 35 | 35 | |
| 36 | - set_post_thumbnail( $postid, $image_id ); |
|
| 36 | + set_post_thumbnail($postid, $image_id); |
|
| 37 | 37 | |
| 38 | - do_action( 'lasso_featured_image_set', $postid, $image_id, get_current_user_ID() ); |
|
| 38 | + do_action('lasso_featured_image_set', $postid, $image_id, get_current_user_ID()); |
|
| 39 | 39 | |
| 40 | 40 | return true; |
| 41 | 41 | |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return bool Always returns true. |
| 52 | 52 | */ |
| 53 | - public function delete( $data ) { |
|
| 53 | + public function delete($data) { |
|
| 54 | 54 | |
| 55 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
| 55 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
| 56 | 56 | |
| 57 | - delete_post_thumbnail( $postid ); |
|
| 57 | + delete_post_thumbnail($postid); |
|
| 58 | 58 | |
| 59 | - do_action( 'lasso_featured_image_deleted', $postid, get_current_user_ID() ); |
|
| 59 | + do_action('lasso_featured_image_deleted', $postid, get_current_user_ID()); |
|
| 60 | 60 | |
| 61 | 61 | return true; |
| 62 | 62 | |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return array Array of keys to pull from $data per action and their sanitization callback |
| 71 | 71 | */ |
| 72 | - public static function params(){ |
|
| 73 | - $params[ 'process_upload_image_upload' ] = array( |
|
| 72 | + public static function params() { |
|
| 73 | + $params['process_upload_image_upload'] = array( |
|
| 74 | 74 | 'postid' => 'absint', |
| 75 | 75 | 'image_id' => 'absint' |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $params[ 'process_upload_image_delete' ] = array( |
|
| 78 | + $params['process_upload_image_delete'] = array( |
|
| 79 | 79 | 'postid' => 'absint', |
| 80 | 80 | ); |
| 81 | 81 | |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | * @since 1.1.10 |
| 29 | 29 | * |
| 30 | 30 | */ |
| 31 | - public static function do_sanitize( $input, $params = array() ) { |
|
| 31 | + public static function do_sanitize($input, $params = array()) { |
|
| 32 | 32 | |
| 33 | - $input = stripslashes_deep( $input ); |
|
| 33 | + $input = stripslashes_deep($input); |
|
| 34 | 34 | |
| 35 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 35 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
| 36 | 36 | return $input; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -43,45 +43,45 @@ discard block |
||
| 43 | 43 | 'type' => null // %s %d %f etc |
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | - if ( !is_array( $params ) ) { |
|
| 47 | - $defaults[ 'type' ] = $params; |
|
| 46 | + if (!is_array($params)) { |
|
| 47 | + $defaults['type'] = $params; |
|
| 48 | 48 | |
| 49 | 49 | $params = $defaults; |
| 50 | 50 | } |
| 51 | 51 | else { |
| 52 | - $params = array_merge( $defaults, (array) $params ); |
|
| 52 | + $params = array_merge($defaults, (array) $params); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( is_object( $input ) ) { |
|
| 56 | - $input = get_object_vars( $input ); |
|
| 55 | + if (is_object($input)) { |
|
| 56 | + $input = get_object_vars($input); |
|
| 57 | 57 | |
| 58 | 58 | $n_params = $params; |
| 59 | - $n_params[ 'nested' ] = true; |
|
| 59 | + $n_params['nested'] = true; |
|
| 60 | 60 | |
| 61 | - foreach ( $input as $key => $val ) { |
|
| 62 | - $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
|
| 61 | + foreach ($input as $key => $val) { |
|
| 62 | + $output[self::do_sanitize($key)] = self::do_sanitize($val, $n_params); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $output = (object) $output; |
| 66 | 66 | } |
| 67 | - elseif ( is_array( $input ) ) { |
|
| 67 | + elseif (is_array($input)) { |
|
| 68 | 68 | $n_params = $params; |
| 69 | - $n_params[ 'nested' ] = true; |
|
| 69 | + $n_params['nested'] = true; |
|
| 70 | 70 | |
| 71 | - foreach ( $input as $key => $val ) { |
|
| 72 | - $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
|
| 71 | + foreach ($input as $key => $val) { |
|
| 72 | + $output[self::do_sanitize($key)] = self::do_sanitize($val, $n_params); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | - elseif ( !empty( $params[ 'type' ] ) && false !== strpos( $params[ 'type' ], '%' ) ) { |
|
| 75 | + elseif (!empty($params['type']) && false !== strpos($params['type'], '%')) { |
|
| 76 | 76 | /** |
| 77 | 77 | * @var $wpdb wpdb |
| 78 | 78 | */ |
| 79 | 79 | global $wpdb; |
| 80 | 80 | |
| 81 | - $output = $wpdb->prepare( $params[ 'type' ], $output ); |
|
| 81 | + $output = $wpdb->prepare($params['type'], $output); |
|
| 82 | 82 | } |
| 83 | 83 | else { |
| 84 | - $output = wp_slash( $input ); |
|
| 84 | + $output = wp_slash($input); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return $output; |
@@ -99,38 +99,38 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @see like_escape |
| 101 | 101 | */ |
| 102 | - public static function sanitize_like( $input ) { |
|
| 102 | + public static function sanitize_like($input) { |
|
| 103 | 103 | |
| 104 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 104 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
| 105 | 105 | return $input; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $output = array(); |
| 109 | 109 | |
| 110 | - if ( is_object( $input ) ) { |
|
| 111 | - $input = get_object_vars( $input ); |
|
| 110 | + if (is_object($input)) { |
|
| 111 | + $input = get_object_vars($input); |
|
| 112 | 112 | |
| 113 | - foreach ( $input as $key => $val ) { |
|
| 114 | - $output[ $key ] = self::sanitize_like( $val ); |
|
| 113 | + foreach ($input as $key => $val) { |
|
| 114 | + $output[$key] = self::sanitize_like($val); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $output = (object) $output; |
| 118 | 118 | } |
| 119 | - elseif ( is_array( $input ) ) { |
|
| 120 | - foreach ( $input as $key => $val ) { |
|
| 121 | - $output[ $key ] = self::sanitize_like( $val ); |
|
| 119 | + elseif (is_array($input)) { |
|
| 120 | + foreach ($input as $key => $val) { |
|
| 121 | + $output[$key] = self::sanitize_like($val); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | else { |
| 125 | 125 | global $wpdb; |
| 126 | 126 | |
| 127 | 127 | //backwords-compat check for pre WP4.0 |
| 128 | - if ( method_exists( 'wpdb', 'esc_like' ) ) { |
|
| 129 | - $output = $wpdb->esc_like( self::do_sanitize( $input ) ); |
|
| 128 | + if (method_exists('wpdb', 'esc_like')) { |
|
| 129 | + $output = $wpdb->esc_like(self::do_sanitize($input)); |
|
| 130 | 130 | } |
| 131 | 131 | else { |
| 132 | 132 | // like_escape is deprecated in WordPress 4.0 |
| 133 | - $output = like_escape( self::do_sanitize( $input ) ); |
|
| 133 | + $output = like_escape(self::do_sanitize($input)); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -150,33 +150,33 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @see wp_unslash |
| 152 | 152 | */ |
| 153 | - public static function unslash( $input ) { |
|
| 153 | + public static function unslash($input) { |
|
| 154 | 154 | |
| 155 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 155 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
| 156 | 156 | return $input; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $output = array(); |
| 160 | 160 | |
| 161 | - if ( empty( $input ) ) { |
|
| 161 | + if (empty($input)) { |
|
| 162 | 162 | $output = $input; |
| 163 | 163 | } |
| 164 | - elseif ( is_object( $input ) ) { |
|
| 165 | - $input = get_object_vars( $input ); |
|
| 164 | + elseif (is_object($input)) { |
|
| 165 | + $input = get_object_vars($input); |
|
| 166 | 166 | |
| 167 | - foreach ( $input as $key => $val ) { |
|
| 168 | - $output[ $key ] = self::unslash( $val ); |
|
| 167 | + foreach ($input as $key => $val) { |
|
| 168 | + $output[$key] = self::unslash($val); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $output = (object) $output; |
| 172 | 172 | } |
| 173 | - elseif ( is_array( $input ) ) { |
|
| 174 | - foreach ( $input as $key => $val ) { |
|
| 175 | - $output[ $key ] = self::unslash( $val ); |
|
| 173 | + elseif (is_array($input)) { |
|
| 174 | + foreach ($input as $key => $val) { |
|
| 175 | + $output[$key] = self::unslash($val); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | else { |
| 179 | - $output = wp_unslash( $input ); |
|
| 179 | + $output = wp_unslash($input); |
|
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | $defaults[ 'type' ] = $params; |
| 48 | 48 | |
| 49 | 49 | $params = $defaults; |
| 50 | - } |
|
| 51 | - else { |
|
| 50 | + } else { |
|
| 52 | 51 | $params = array_merge( $defaults, (array) $params ); |
| 53 | 52 | } |
| 54 | 53 | |
@@ -63,24 +62,21 @@ discard block |
||
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | $output = (object) $output; |
| 66 | - } |
|
| 67 | - elseif ( is_array( $input ) ) { |
|
| 65 | + } elseif ( is_array( $input ) ) { |
|
| 68 | 66 | $n_params = $params; |
| 69 | 67 | $n_params[ 'nested' ] = true; |
| 70 | 68 | |
| 71 | 69 | foreach ( $input as $key => $val ) { |
| 72 | 70 | $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
| 73 | 71 | } |
| 74 | - } |
|
| 75 | - elseif ( !empty( $params[ 'type' ] ) && false !== strpos( $params[ 'type' ], '%' ) ) { |
|
| 72 | + } elseif ( !empty( $params[ 'type' ] ) && false !== strpos( $params[ 'type' ], '%' ) ) { |
|
| 76 | 73 | /** |
| 77 | 74 | * @var $wpdb wpdb |
| 78 | 75 | */ |
| 79 | 76 | global $wpdb; |
| 80 | 77 | |
| 81 | 78 | $output = $wpdb->prepare( $params[ 'type' ], $output ); |
| 82 | - } |
|
| 83 | - else { |
|
| 79 | + } else { |
|
| 84 | 80 | $output = wp_slash( $input ); |
| 85 | 81 | } |
| 86 | 82 | |
@@ -115,20 +111,17 @@ discard block |
||
| 115 | 111 | } |
| 116 | 112 | |
| 117 | 113 | $output = (object) $output; |
| 118 | - } |
|
| 119 | - elseif ( is_array( $input ) ) { |
|
| 114 | + } elseif ( is_array( $input ) ) { |
|
| 120 | 115 | foreach ( $input as $key => $val ) { |
| 121 | 116 | $output[ $key ] = self::sanitize_like( $val ); |
| 122 | 117 | } |
| 123 | - } |
|
| 124 | - else { |
|
| 118 | + } else { |
|
| 125 | 119 | global $wpdb; |
| 126 | 120 | |
| 127 | 121 | //backwords-compat check for pre WP4.0 |
| 128 | 122 | if ( method_exists( 'wpdb', 'esc_like' ) ) { |
| 129 | 123 | $output = $wpdb->esc_like( self::do_sanitize( $input ) ); |
| 130 | - } |
|
| 131 | - else { |
|
| 124 | + } else { |
|
| 132 | 125 | // like_escape is deprecated in WordPress 4.0 |
| 133 | 126 | $output = like_escape( self::do_sanitize( $input ) ); |
| 134 | 127 | } |
@@ -160,8 +153,7 @@ discard block |
||
| 160 | 153 | |
| 161 | 154 | if ( empty( $input ) ) { |
| 162 | 155 | $output = $input; |
| 163 | - } |
|
| 164 | - elseif ( is_object( $input ) ) { |
|
| 156 | + } elseif ( is_object( $input ) ) { |
|
| 165 | 157 | $input = get_object_vars( $input ); |
| 166 | 158 | |
| 167 | 159 | foreach ( $input as $key => $val ) { |
@@ -169,13 +161,11 @@ discard block |
||
| 169 | 161 | } |
| 170 | 162 | |
| 171 | 163 | $output = (object) $output; |
| 172 | - } |
|
| 173 | - elseif ( is_array( $input ) ) { |
|
| 164 | + } elseif ( is_array( $input ) ) { |
|
| 174 | 165 | foreach ( $input as $key => $val ) { |
| 175 | 166 | $output[ $key ] = self::unslash( $val ); |
| 176 | 167 | } |
| 177 | - } |
|
| 178 | - else { |
|
| 168 | + } else { |
|
| 179 | 169 | $output = wp_unslash( $input ); |
| 180 | 170 | |
| 181 | 171 | } |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | * Adds our API endpoint and hooks it in at template_redirect |
| 19 | 19 | */ |
| 20 | 20 | public function __construct() { |
| 21 | - add_action( 'init', array( $this, 'add_endpoints' ) ); |
|
| 22 | - add_action( 'template_redirect', array( route::init(), 'do_api' ) ); |
|
| 21 | + add_action('init', array($this, 'add_endpoints')); |
|
| 22 | + add_action('template_redirect', array(route::init(), 'do_api')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function add_endpoints() { |
| 31 | 31 | //add "action" as a rewrite tag |
| 32 | - add_rewrite_tag( '%action%', '^[a-z0-9_\-]+$' ); |
|
| 32 | + add_rewrite_tag('%action%', '^[a-z0-9_\-]+$'); |
|
| 33 | 33 | |
| 34 | 34 | //add the endpoint |
| 35 | - add_rewrite_rule( 'lasso-internal-api/^[a-z0-9_\-]+$/?', 'index.php?action=$matches[1]', 'top' ); |
|
| 35 | + add_rewrite_rule('lasso-internal-api/^[a-z0-9_\-]+$/?', 'index.php?action=$matches[1]', 'top'); |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | * @param object $callback_instance Callback class. |
| 30 | 30 | * @param string $action The name of the action we are processing for. |
| 31 | 31 | */ |
| 32 | - public function __construct( $callback_instance, $action ) { |
|
| 33 | - if ( is_object( $callback_instance ) ) { |
|
| 34 | - $this->get_data( $callback_instance, $action ); |
|
| 32 | + public function __construct($callback_instance, $action) { |
|
| 33 | + if (is_object($callback_instance)) { |
|
| 34 | + $this->get_data($callback_instance, $action); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | } |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | * @param object $callback_instance Callback class. |
| 50 | 50 | * @param string $action The name of the action we are processing for. |
| 51 | 51 | */ |
| 52 | - protected function get_data( $callback_instance, $action ) { |
|
| 52 | + protected function get_data($callback_instance, $action) { |
|
| 53 | 53 | $data = array(); |
| 54 | - if ( is_array( $_POST ) ) { |
|
| 54 | + if (is_array($_POST)) { |
|
| 55 | 55 | $params = $callback_instance::params(); |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -61,20 +61,20 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @param array $params Array of params in form of $params[ 'action_name' ][ 'POST_field' ] = 'callback_function_for_sanatizing' ] |
| 63 | 63 | */ |
| 64 | - $params = apply_filters( 'lasso_api_params', $params ); |
|
| 65 | - if ( is_array( $params ) && isset( $params[ $action ] ) && is_array( $params[ $action ] ) ) { |
|
| 66 | - $params = $params[ $action ]; |
|
| 67 | - foreach( $params as $key => $callback ) { |
|
| 64 | + $params = apply_filters('lasso_api_params', $params); |
|
| 65 | + if (is_array($params) && isset($params[$action]) && is_array($params[$action])) { |
|
| 66 | + $params = $params[$action]; |
|
| 67 | + foreach ($params as $key => $callback) { |
|
| 68 | 68 | $_data = null; |
| 69 | - if ( is_array( $callback ) ) { |
|
| 70 | - foreach( $callback as $cb ) { |
|
| 71 | - $_data = $this->sanitize( $key, $cb ); |
|
| 69 | + if (is_array($callback)) { |
|
| 70 | + foreach ($callback as $cb) { |
|
| 71 | + $_data = $this->sanitize($key, $cb); |
|
| 72 | 72 | } |
| 73 | - }else{ |
|
| 74 | - $_data = $this->sanitize( $key, $callback ); |
|
| 73 | + } else { |
|
| 74 | + $_data = $this->sanitize($key, $callback); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $data[ $key ] = $_data; |
|
| 77 | + $data[$key] = $_data; |
|
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return string|null Sanitized data or null. |
| 100 | 100 | */ |
| 101 | - protected function sanitize( $key, $cb ) { |
|
| 101 | + protected function sanitize($key, $cb) { |
|
| 102 | 102 | $_data = null; |
| 103 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 104 | - if ( function_exists( $cb ) ) { |
|
| 105 | - $_data = call_user_func( $cb, $_POST[ $key ] ); |
|
| 103 | + if (isset($_POST[$key])) { |
|
| 104 | + if (function_exists($cb)) { |
|
| 105 | + $_data = call_user_func($cb, $_POST[$key]); |
|
| 106 | 106 | |
| 107 | 107 | return $_data; |
| 108 | 108 | |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | foreach( $callback as $cb ) { |
| 71 | 71 | $_data = $this->sanitize( $key, $cb ); |
| 72 | 72 | } |
| 73 | - }else{ |
|
| 73 | + } else{ |
|
| 74 | 74 | $_data = $this->sanitize( $key, $callback ); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -121,8 +121,9 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | ob_start(); |
| 123 | 123 | |
| 124 | - if ( empty( $name ) || empty( $options ) || !is_array( $options ) ) |
|
| 125 | - return; |
|
| 124 | + if ( empty( $name ) || empty( $options ) || !is_array( $options ) ) { |
|
| 125 | + return; |
|
| 126 | + } |
|
| 126 | 127 | |
| 127 | 128 | $nonce = wp_create_nonce('lasso-process-post-meta'); |
| 128 | 129 | $key = sprintf('_lasso_%s_settings', $name ); |
@@ -160,8 +161,9 @@ discard block |
||
| 160 | 161 | $before = '<div class="lasso--postsettings__option">'; |
| 161 | 162 | $after = '</div>'; |
| 162 | 163 | |
| 163 | - if ( empty( $name ) || empty( $options ) ) |
|
| 164 | - return; |
|
| 164 | + if ( empty( $name ) || empty( $options ) ) { |
|
| 165 | + return; |
|
| 166 | + } |
|
| 165 | 167 | |
| 166 | 168 | foreach ( (array) $options as $option ) { |
| 167 | 169 | |
@@ -195,8 +197,9 @@ discard block |
||
| 195 | 197 | */ |
| 196 | 198 | function lasso_option_engine_option( $name = '', $option = '', $type = '') { |
| 197 | 199 | |
| 198 | - if ( empty( $type ) || empty( $option ) ) |
|
| 199 | - return; |
|
| 200 | + if ( empty( $type ) || empty( $option ) ) { |
|
| 201 | + return; |
|
| 202 | + } |
|
| 200 | 203 | |
| 201 | 204 | $id = isset( $option['id'] ) ? $option['id'] : false; |
| 202 | 205 | $id = $id ? lasso_clean_string( $id ) : false; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * Get an array of addon data for the settings modal |
| 44 | 44 | * @since 0.9.4 |
| 45 | 45 | */ |
| 46 | -function lasso_get_modal_tabs(){ |
|
| 46 | +function lasso_get_modal_tabs() { |
|
| 47 | 47 | |
| 48 | 48 | $tabs = array(); |
| 49 | 49 | |
@@ -60,36 +60,36 @@ discard block |
||
| 60 | 60 | * @uses lasso_modal_addons_content() |
| 61 | 61 | * @since 0.9.4 |
| 62 | 62 | */ |
| 63 | -function lasso_modal_addons( $type = 'tab' ){ |
|
| 63 | +function lasso_modal_addons($type = 'tab') { |
|
| 64 | 64 | |
| 65 | 65 | $tabs = lasso_get_modal_tabs(); |
| 66 | 66 | $out = ''; |
| 67 | 67 | |
| 68 | - if ( $tabs ): |
|
| 68 | + if ($tabs): |
|
| 69 | 69 | |
| 70 | - if ( 'tab' == $type ) { |
|
| 70 | + if ('tab' == $type) { |
|
| 71 | 71 | |
| 72 | 72 | $out = '<ul class="lasso--modal__tabs">'; |
| 73 | 73 | |
| 74 | 74 | $out .= '<li class="active-tab" data-addon-name="core">Editus</li>'; |
| 75 | 75 | |
| 76 | - foreach ( $tabs as $tab ) { |
|
| 76 | + foreach ($tabs as $tab) { |
|
| 77 | 77 | |
| 78 | - if ( isset( $tab ) ) { |
|
| 78 | + if (isset($tab)) { |
|
| 79 | 79 | |
| 80 | - $out .= lasso_modal_addons_content( $tab, $type ); |
|
| 80 | + $out .= lasso_modal_addons_content($tab, $type); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $out .= '</ul>'; |
| 85 | 85 | |
| 86 | - } elseif ( 'content' == $type ) { |
|
| 86 | + } elseif ('content' == $type) { |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | - foreach ( $tabs as $tab ) { |
|
| 89 | + foreach ($tabs as $tab) { |
|
| 90 | 90 | |
| 91 | - if ( isset( $tab ) ) { |
|
| 92 | - $out .= lasso_modal_addons_content( $tab , $type ); |
|
| 91 | + if (isset($tab)) { |
|
| 92 | + $out .= lasso_modal_addons_content($tab, $type); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | endif; |
| 99 | 99 | |
| 100 | - return !empty( $out ) ? $out : false; |
|
| 100 | + return !empty($out) ? $out : false; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -117,26 +117,26 @@ discard block |
||
| 117 | 117 | * @since 0.9.5 |
| 118 | 118 | * @subpackage lasso_modal_addons_content |
| 119 | 119 | */ |
| 120 | -function lasso_option_form( $name = '', $options = array() ){ |
|
| 120 | +function lasso_option_form($name = '', $options = array()) { |
|
| 121 | 121 | |
| 122 | 122 | ob_start(); |
| 123 | 123 | |
| 124 | - if ( empty( $name ) || empty( $options ) || !is_array( $options ) ) |
|
| 124 | + if (empty($name) || empty($options) || !is_array($options)) |
|
| 125 | 125 | return; |
| 126 | 126 | |
| 127 | 127 | $nonce = wp_create_nonce('lasso-process-post-meta'); |
| 128 | - $key = sprintf('_lasso_%s_settings', $name ); |
|
| 128 | + $key = sprintf('_lasso_%s_settings', $name); |
|
| 129 | 129 | |
| 130 | - $out = sprintf('<form id="lasso--post-form" class="lasso--post-form">' ); |
|
| 130 | + $out = sprintf('<form id="lasso--post-form" class="lasso--post-form">'); |
|
| 131 | 131 | |
| 132 | - $out .= lasso_option_fields( $name, $options ); |
|
| 133 | - $out .='<div class="form--bottom">'; |
|
| 134 | - $out .='<input type="submit" value="'.__( 'Save', 'lasso' ).'">'; |
|
| 135 | - $out .='<input type="hidden" name="tab_name" value="'.$key.'">'; |
|
| 136 | - $out .='<input type="hidden" name="post_id" value="'.get_the_ID().'">'; |
|
| 137 | - $out .='<input type="hidden" name="nonce" value="'.$nonce.'">'; |
|
| 138 | - $out .='<input type="hidden" name="action" value="process_meta_update">'; |
|
| 139 | - $out .='</div>'; |
|
| 132 | + $out .= lasso_option_fields($name, $options); |
|
| 133 | + $out .= '<div class="form--bottom">'; |
|
| 134 | + $out .= '<input type="submit" value="'.__('Save', 'lasso').'">'; |
|
| 135 | + $out .= '<input type="hidden" name="tab_name" value="'.$key.'">'; |
|
| 136 | + $out .= '<input type="hidden" name="post_id" value="'.get_the_ID().'">'; |
|
| 137 | + $out .= '<input type="hidden" name="nonce" value="'.$nonce.'">'; |
|
| 138 | + $out .= '<input type="hidden" name="action" value="process_meta_update">'; |
|
| 139 | + $out .= '</div>'; |
|
| 140 | 140 | |
| 141 | 141 | $out .= '</form>'; |
| 142 | 142 | |
@@ -154,28 +154,28 @@ discard block |
||
| 154 | 154 | * @since 0.9.5 |
| 155 | 155 | * @subpackage lasso_modal_addons_content |
| 156 | 156 | */ |
| 157 | -function lasso_option_fields( $name = '', $options = array() ){ |
|
| 157 | +function lasso_option_fields($name = '', $options = array()) { |
|
| 158 | 158 | |
| 159 | - $out = ''; |
|
| 159 | + $out = ''; |
|
| 160 | 160 | $before = '<div class="lasso--postsettings__option">'; |
| 161 | 161 | $after = '</div>'; |
| 162 | 162 | |
| 163 | - if ( empty( $name ) || empty( $options ) ) |
|
| 163 | + if (empty($name) || empty($options)) |
|
| 164 | 164 | return; |
| 165 | 165 | |
| 166 | - foreach ( (array) $options as $option ) { |
|
| 166 | + foreach ((array) $options as $option) { |
|
| 167 | 167 | |
| 168 | - $type = isset( $option['type'] ) ? $option['type'] : 'text'; |
|
| 168 | + $type = isset($option['type']) ? $option['type'] : 'text'; |
|
| 169 | 169 | |
| 170 | - switch ( $type ) { |
|
| 170 | + switch ($type) { |
|
| 171 | 171 | case 'text': |
| 172 | - $out .= sprintf('%s%s%s', $before, lasso_option_engine_option( $name, $option,'text' ), $after ); |
|
| 172 | + $out .= sprintf('%s%s%s', $before, lasso_option_engine_option($name, $option, 'text'), $after); |
|
| 173 | 173 | break; |
| 174 | 174 | case 'textarea': |
| 175 | - $out .= sprintf('%s%s%s', $before, lasso_option_engine_option( $name, $option,'textarea' ), $after ); |
|
| 175 | + $out .= sprintf('%s%s%s', $before, lasso_option_engine_option($name, $option, 'textarea'), $after); |
|
| 176 | 176 | break; |
| 177 | 177 | case 'checkbox': |
| 178 | - $out .= sprintf('%s%s%s', $before, lasso_option_engine_option( $name, $option,'checkbox' ), $after ); |
|
| 178 | + $out .= sprintf('%s%s%s', $before, lasso_option_engine_option($name, $option, 'checkbox'), $after); |
|
| 179 | 179 | break; |
| 180 | 180 | } |
| 181 | 181 | |
@@ -193,27 +193,27 @@ discard block |
||
| 193 | 193 | * @param $type string text, textarea, checkbox, color |
| 194 | 194 | * @since 5.0 |
| 195 | 195 | */ |
| 196 | -function lasso_option_engine_option( $name = '', $option = '', $type = '') { |
|
| 196 | +function lasso_option_engine_option($name = '', $option = '', $type = '') { |
|
| 197 | 197 | |
| 198 | - if ( empty( $type ) || empty( $option ) ) |
|
| 198 | + if (empty($type) || empty($option)) |
|
| 199 | 199 | return; |
| 200 | 200 | |
| 201 | - $id = isset( $option['id'] ) ? $option['id'] : false; |
|
| 202 | - $id = $id ? lasso_clean_string( $id ) : false; |
|
| 201 | + $id = isset($option['id']) ? $option['id'] : false; |
|
| 202 | + $id = $id ? lasso_clean_string($id) : false; |
|
| 203 | 203 | |
| 204 | - $desc = isset( $option['desc'] ) ? $option['desc'] : false; |
|
| 204 | + $desc = isset($option['desc']) ? $option['desc'] : false; |
|
| 205 | 205 | |
| 206 | - $value = get_post_meta( get_the_id(), $option[ 'id' ], true ); |
|
| 206 | + $value = get_post_meta(get_the_id(), $option['id'], true); |
|
| 207 | 207 | |
| 208 | - switch ( $type ) { |
|
| 208 | + switch ($type) { |
|
| 209 | 209 | case 'text': |
| 210 | - $out = sprintf('<label for="lasso--post-option-%s">%s</label><input id="lasso--post-option-%s" name="%s" type="text" value="%s">',$id, esc_html( $desc ), $id, $id, $value ); |
|
| 210 | + $out = sprintf('<label for="lasso--post-option-%s">%s</label><input id="lasso--post-option-%s" name="%s" type="text" value="%s">', $id, esc_html($desc), $id, $id, $value); |
|
| 211 | 211 | break; |
| 212 | 212 | case 'textarea': |
| 213 | - $out = sprintf('<label for="lasso--post-option-%s">%s</label><textarea id="lasso--post-option-%s" name="%s">%s</textarea>',$id, esc_html( $desc ), $id, $id, $value ); |
|
| 213 | + $out = sprintf('<label for="lasso--post-option-%s">%s</label><textarea id="lasso--post-option-%s" name="%s">%s</textarea>', $id, esc_html($desc), $id, $id, $value); |
|
| 214 | 214 | break; |
| 215 | 215 | case 'checkbox': |
| 216 | - $out = sprintf('<label for="lasso--post-option-%s" class="checkbox-control checkbox"><input id="lasso--post-option-%s" type="checkbox" name="%s" class="checkbox"><span class="control-indicator"></span>%s',$id, $id, $id ,esc_html( $desc ) ); |
|
| 216 | + $out = sprintf('<label for="lasso--post-option-%s" class="checkbox-control checkbox"><input id="lasso--post-option-%s" type="checkbox" name="%s" class="checkbox"><span class="control-indicator"></span>%s', $id, $id, $id, esc_html($desc)); |
|
| 217 | 217 | break; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -15,22 +15,22 @@ |
||
| 15 | 15 | * |
| 16 | 16 | * @param array $fields |
| 17 | 17 | */ |
| 18 | - public function __construct( $fields ) { |
|
| 18 | + public function __construct($fields) { |
|
| 19 | 19 | $this->fields = $fields; |
| 20 | - add_filter( 'lasso_api_params', function( $params ) { |
|
| 21 | - foreach( $this->fields as $field => $cbs ) { |
|
| 22 | - $field = lasso_clean_string( $field ); |
|
| 23 | - $params[ 'process_meta_update' ][ $field ] = $cbs; |
|
| 20 | + add_filter('lasso_api_params', function($params) { |
|
| 21 | + foreach ($this->fields as $field => $cbs) { |
|
| 22 | + $field = lasso_clean_string($field); |
|
| 23 | + $params['process_meta_update'][$field] = $cbs; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | return $params; |
| 27 | 27 | |
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | - add_filter( 'lasso_meta_fields', function( $allowed ) { |
|
| 30 | + add_filter('lasso_meta_fields', function($allowed) { |
|
| 31 | 31 | |
| 32 | - foreach( array_keys( $this->fields ) as $field ) { |
|
| 33 | - $field = lasso_clean_string( $field ); |
|
| 32 | + foreach (array_keys($this->fields) as $field) { |
|
| 33 | + $field = lasso_clean_string($field); |
|
| 34 | 34 | $allowed[] = $field; |
| 35 | 35 | |
| 36 | 36 | } |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // If uninstall not called from WordPress, then exit |
| 13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 13 | +if (!defined('WP_UNINSTALL_PLUGIN')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |