@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |