@@ -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,34 +60,34 @@ 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 ) { |
|
87 | - foreach ( $tabs as $tab ) { |
|
86 | + } elseif ('content' == $type) { |
|
87 | + foreach ($tabs as $tab) { |
|
88 | 88 | |
89 | - if ( isset( $tab ) ) { |
|
90 | - $out .= lasso_modal_addons_content( $tab , $type ); |
|
89 | + if (isset($tab)) { |
|
90 | + $out .= lasso_modal_addons_content($tab, $type); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | |
96 | 96 | endif; |
97 | 97 | |
98 | - return !empty( $out ) ? $out : false; |
|
98 | + return !empty($out) ? $out : false; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -115,26 +115,26 @@ discard block |
||
115 | 115 | * @since 0.9.5 |
116 | 116 | * @subpackage lasso_modal_addons_content |
117 | 117 | */ |
118 | -function lasso_option_form( $name = '', $options = array() ){ |
|
118 | +function lasso_option_form($name = '', $options = array()) { |
|
119 | 119 | |
120 | 120 | ob_start(); |
121 | 121 | |
122 | - if ( empty( $name ) || empty( $options ) || !is_array( $options ) ) |
|
122 | + if (empty($name) || empty($options) || !is_array($options)) |
|
123 | 123 | return; |
124 | 124 | |
125 | 125 | $nonce = wp_create_nonce('lasso-process-post-meta'); |
126 | - $key = sprintf('_lasso_%s_settings', $name ); |
|
126 | + $key = sprintf('_lasso_%s_settings', $name); |
|
127 | 127 | |
128 | - $out = sprintf('<form id="lasso--post-form" class="lasso--post-form">' ); |
|
128 | + $out = sprintf('<form id="lasso--post-form" class="lasso--post-form">'); |
|
129 | 129 | |
130 | - $out .= lasso_option_fields( $name, $options ); |
|
131 | - $out .='<div class="form--bottom">'; |
|
132 | - $out .='<input type="submit" value="'.__( 'Save', 'lasso' ).'">'; |
|
133 | - $out .='<input type="hidden" name="tab_name" value="'.$key.'">'; |
|
134 | - $out .='<input type="hidden" name="post_id" value="'.get_the_ID().'">'; |
|
135 | - $out .='<input type="hidden" name="nonce" value="'.$nonce.'">'; |
|
136 | - $out .='<input type="hidden" name="action" value="process_meta_update">'; |
|
137 | - $out .='</div>'; |
|
130 | + $out .= lasso_option_fields($name, $options); |
|
131 | + $out .= '<div class="form--bottom">'; |
|
132 | + $out .= '<input type="submit" value="'.__('Save', 'lasso').'">'; |
|
133 | + $out .= '<input type="hidden" name="tab_name" value="'.$key.'">'; |
|
134 | + $out .= '<input type="hidden" name="post_id" value="'.get_the_ID().'">'; |
|
135 | + $out .= '<input type="hidden" name="nonce" value="'.$nonce.'">'; |
|
136 | + $out .= '<input type="hidden" name="action" value="process_meta_update">'; |
|
137 | + $out .= '</div>'; |
|
138 | 138 | |
139 | 139 | $out .= '</form>'; |
140 | 140 | |
@@ -192,31 +192,31 @@ discard block |
||
192 | 192 | * @since 0.9.5 |
193 | 193 | * @subpackage lasso_modal_addons_content |
194 | 194 | */ |
195 | -function lasso_option_fields( $name = '', $options = array() ){ |
|
195 | +function lasso_option_fields($name = '', $options = array()) { |
|
196 | 196 | |
197 | - $out = ''; |
|
197 | + $out = ''; |
|
198 | 198 | $before = '<div class="lasso--postsettings__option">'; |
199 | 199 | $after = '</div>'; |
200 | 200 | |
201 | - if ( empty( $name ) || empty( $options ) ) |
|
201 | + if (empty($name) || empty($options)) |
|
202 | 202 | return; |
203 | 203 | |
204 | - foreach ( (array) $options as $option ) { |
|
204 | + foreach ((array) $options as $option) { |
|
205 | 205 | |
206 | - $type = isset( $option['type'] ) ? $option['type'] : 'text'; |
|
206 | + $type = isset($option['type']) ? $option['type'] : 'text'; |
|
207 | 207 | |
208 | - switch ( $type ) { |
|
208 | + switch ($type) { |
|
209 | 209 | case 'text': |
210 | - $out .= sprintf('%s%s%s', $before, lasso_option_engine_option( $name, $option,'text' ), $after ); |
|
210 | + $out .= sprintf('%s%s%s', $before, lasso_option_engine_option($name, $option, 'text'), $after); |
|
211 | 211 | break; |
212 | 212 | case 'textarea': |
213 | - $out .= sprintf('%s%s%s', $before, lasso_option_engine_option( $name, $option,'textarea' ), $after ); |
|
213 | + $out .= sprintf('%s%s%s', $before, lasso_option_engine_option($name, $option, 'textarea'), $after); |
|
214 | 214 | break; |
215 | 215 | case 'imgurl': |
216 | - $out .= sprintf('%s%s%s', $before, lasso_option_engine_option( $name, $option,'imgurl' ), $after ); |
|
216 | + $out .= sprintf('%s%s%s', $before, lasso_option_engine_option($name, $option, 'imgurl'), $after); |
|
217 | 217 | break; |
218 | 218 | case 'checkbox': |
219 | - $out .= sprintf('%s%s%s', $before, lasso_option_engine_option( $name, $option,'checkbox' ), $after ); |
|
219 | + $out .= sprintf('%s%s%s', $before, lasso_option_engine_option($name, $option, 'checkbox'), $after); |
|
220 | 220 | break; |
221 | 221 | } |
222 | 222 | |
@@ -236,30 +236,30 @@ discard block |
||
236 | 236 | * @param $type string text, textarea, checkbox, color |
237 | 237 | * @since 5.0 |
238 | 238 | */ |
239 | -function lasso_option_engine_option( $name = '', $option = '', $type = '') { |
|
239 | +function lasso_option_engine_option($name = '', $option = '', $type = '') { |
|
240 | 240 | |
241 | - if ( empty( $type ) || empty( $option ) ) |
|
241 | + if (empty($type) || empty($option)) |
|
242 | 242 | return; |
243 | 243 | |
244 | - $id = isset( $option['id'] ) ? $option['id'] : false; |
|
245 | - $id = $id ? lasso_clean_string( $id ) : false; |
|
244 | + $id = isset($option['id']) ? $option['id'] : false; |
|
245 | + $id = $id ? lasso_clean_string($id) : false; |
|
246 | 246 | |
247 | - $desc = isset( $option['desc'] ) ? $option['desc'] : false; |
|
247 | + $desc = isset($option['desc']) ? $option['desc'] : false; |
|
248 | 248 | |
249 | - $value = get_post_meta( get_the_id(), $option[ 'id' ], true ); |
|
249 | + $value = get_post_meta(get_the_id(), $option['id'], true); |
|
250 | 250 | |
251 | - switch ( $type ) { |
|
251 | + switch ($type) { |
|
252 | 252 | case 'text': |
253 | - $out = sprintf('<label for="lasso--post-option-%s">%s</label><input id="lasso--post-option-%s" class="editus-custom-field-text" name="%s" type="text" value="%s">',$id, esc_html( $desc ), $id, $id, $value ); |
|
253 | + $out = sprintf('<label for="lasso--post-option-%s">%s</label><input id="lasso--post-option-%s" class="editus-custom-field-text" name="%s" type="text" value="%s">', $id, esc_html($desc), $id, $id, $value); |
|
254 | 254 | break; |
255 | 255 | case 'textarea': |
256 | - $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 ); |
|
256 | + $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); |
|
257 | 257 | break; |
258 | 258 | case 'imgurl': |
259 | - $out = sprintf('<label for="lasso--post-option-%s">%s</label><img src="%s" style="height:80px;"><input id="lasso--post-option-%s" class="editus-custom-field-text" name="%s" type="text" value="%s" style="display:none;"><div title="Replace Image" class="editus-customtab-image-control" style="float:left;"><i class="lasso-icon-image" style="font-size:20px;padding:5px;"></i></div><div title="Remove Image" class="editus-customtab-image-remove" style="float:left;"><i class="lasso-icon-bin2" style="font-size:20px;padding:5px;"></i></div>',$id, esc_html( $desc ), $value, $id, $id, $value ); |
|
259 | + $out = sprintf('<label for="lasso--post-option-%s">%s</label><img src="%s" style="height:80px;"><input id="lasso--post-option-%s" class="editus-custom-field-text" name="%s" type="text" value="%s" style="display:none;"><div title="Replace Image" class="editus-customtab-image-control" style="float:left;"><i class="lasso-icon-image" style="font-size:20px;padding:5px;"></i></div><div title="Remove Image" class="editus-customtab-image-remove" style="float:left;"><i class="lasso-icon-bin2" style="font-size:20px;padding:5px;"></i></div>', $id, esc_html($desc), $value, $id, $id, $value); |
|
260 | 260 | break; |
261 | 261 | case 'checkbox': |
262 | - $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 ) ); |
|
262 | + $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)); |
|
263 | 263 | break; |
264 | 264 | } |
265 | 265 |
@@ -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 |