@@ -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 |
@@ -118,7 +118,7 @@ |
||
118 | 118 | * @since 0.9.3 |
119 | 119 | * |
120 | 120 | * @param int $postid The current postid |
121 | - * @param string|bool $value The term slug, or a comma separated list of slugs. Or false to remove all terms set for post. |
|
121 | + * @param string|bool $value The term slug, or a comma separated list of slugs. Or false to remove all terms set for post. |
|
122 | 122 | * @param string $taxonomy The name of the taxonomy to which the term belongs. |
123 | 123 | * |
124 | 124 | * @return bool True if update was successful, false if not. |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | use lasso\internal_api\api_action; |
11 | 11 | |
12 | -class update_object implements api_action{ |
|
12 | +class update_object implements api_action { |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * The nonce action for this request. |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return bool Always returns true. |
31 | 31 | */ |
32 | - public function post( $data ) { |
|
32 | + public function post($data) { |
|
33 | 33 | |
34 | - $status = isset( $data['status'] ) ? $data['status'] : false; |
|
35 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
36 | - $slug = isset( $data['story_slug'] ) ? $data['story_slug'] : false; |
|
34 | + $status = isset($data['status']) ? $data['status'] : false; |
|
35 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
36 | + $slug = isset($data['story_slug']) ? $data['story_slug'] : false; |
|
37 | 37 | |
38 | 38 | |
39 | 39 | |
@@ -43,20 +43,20 @@ discard block |
||
43 | 43 | 'post_status' => $status |
44 | 44 | ); |
45 | 45 | |
46 | - wp_update_post( apply_filters( 'lasso_object_status_update_args', $args ) ); |
|
46 | + wp_update_post(apply_filters('lasso_object_status_update_args', $args)); |
|
47 | 47 | |
48 | 48 | |
49 | 49 | // update categories |
50 | - $cats = isset( $data['story_cats'] ) ? $data['story_cats'] : false; |
|
51 | - self::set_post_terms( $postid, $cats, 'category' ); |
|
50 | + $cats = isset($data['story_cats']) ? $data['story_cats'] : false; |
|
51 | + self::set_post_terms($postid, $cats, 'category'); |
|
52 | 52 | |
53 | 53 | |
54 | 54 | // update tags |
55 | - $tags = isset( $data['story_tags'] ) ? $data['story_tags'] : false; |
|
56 | - self::set_post_terms( $postid, $tags, 'post_tag' ); |
|
55 | + $tags = isset($data['story_tags']) ? $data['story_tags'] : false; |
|
56 | + self::set_post_terms($postid, $tags, 'post_tag'); |
|
57 | 57 | |
58 | 58 | |
59 | - do_action( 'lasso_post_updated', $postid, $slug, $status, get_current_user_ID() ); |
|
59 | + do_action('lasso_post_updated', $postid, $slug, $status, get_current_user_ID()); |
|
60 | 60 | |
61 | 61 | return true; |
62 | 62 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
72 | 72 | */ |
73 | - public static function params(){ |
|
74 | - $params[ 'process_update_object_post' ] = array( |
|
73 | + public static function params() { |
|
74 | + $params['process_update_object_post'] = array( |
|
75 | 75 | 'postid' => 'absint', |
76 | 76 | 'status' => 'strip_tags', |
77 | 77 | 'story_slug' => array( |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return array Array of additional functions to use to authorize action. |
102 | 102 | */ |
103 | 103 | public static function auth_callbacks() { |
104 | - $params[ 'process_update_object_post' ] = array( |
|
104 | + $params['process_update_object_post'] = array( |
|
105 | 105 | 'lasso_user_can' |
106 | 106 | ); |
107 | 107 | |
@@ -123,25 +123,25 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return bool True if update was successful, false if not. |
125 | 125 | */ |
126 | - public function set_post_terms( $postid, $value, $taxonomy ) { |
|
127 | - if( $value ) { |
|
126 | + public function set_post_terms($postid, $value, $taxonomy) { |
|
127 | + if ($value) { |
|
128 | 128 | // first check if multiple, make array if so. |
129 | - if ( self::has_multiple_objects( $value ) ) { |
|
130 | - $value = explode( ',', $value ); |
|
129 | + if (self::has_multiple_objects($value)) { |
|
130 | + $value = explode(',', $value); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | - $result = wp_set_object_terms( $postid, $value, $taxonomy ); |
|
134 | + $result = wp_set_object_terms($postid, $value, $taxonomy); |
|
135 | 135 | } |
136 | - else { |
|
136 | + else { |
|
137 | 137 | //remove all terms from post |
138 | - $result = wp_set_object_terms( $postid, null, $taxonomy ); |
|
138 | + $result = wp_set_object_terms($postid, null, $taxonomy); |
|
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | - if ( ! is_wp_error( $result ) ) { |
|
142 | + if (!is_wp_error($result)) { |
|
143 | 143 | return true; |
144 | - }else{ |
|
144 | + } else { |
|
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | * @return bool True if there are multiple terms; otherwise, false. |
157 | 157 | * @since 0.9.3 |
158 | 158 | */ |
159 | - public function has_multiple_objects( $value ) { |
|
159 | + public function has_multiple_objects($value) { |
|
160 | 160 | |
161 | - return 0 < strpos( $value, ',' ); |
|
161 | + return 0 < strpos($value, ','); |
|
162 | 162 | |
163 | 163 | } |
164 | 164 |
@@ -132,8 +132,7 @@ discard block |
||
132 | 132 | |
133 | 133 | |
134 | 134 | $result = wp_set_object_terms( $postid, $value, $taxonomy ); |
135 | - } |
|
136 | - else { |
|
135 | + } else { |
|
137 | 136 | //remove all terms from post |
138 | 137 | $result = wp_set_object_terms( $postid, null, $taxonomy ); |
139 | 138 | |
@@ -141,7 +140,7 @@ discard block |
||
141 | 140 | |
142 | 141 | if ( ! is_wp_error( $result ) ) { |
143 | 142 | return true; |
144 | - }else{ |
|
143 | + } else{ |
|
145 | 144 | return false; |
146 | 145 | } |
147 | 146 |
@@ -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 |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Process a user uploading an image for the featured image in a post |
|
4 | - * |
|
5 | - * @since 1.0 |
|
6 | - */ |
|
3 | + * Process a user uploading an image for the featured image in a post |
|
4 | + * |
|
5 | + * @since 1.0 |
|
6 | + */ |
|
7 | 7 | namespace lasso\process; |
8 | 8 | |
9 | 9 | use lasso\internal_api\api_action; |
@@ -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 | } |
@@ -12,56 +12,56 @@ |
||
12 | 12 | /** |
13 | 13 | * Update an existing galleries options |
14 | 14 | */ |
15 | - public static function save_gallery_options( $postid, $gallery_ids, $options, $type = false ) { |
|
15 | + public static function save_gallery_options($postid, $gallery_ids, $options, $type = false) { |
|
16 | 16 | |
17 | 17 | // gallery width |
18 | - $gallery_width = isset( $options['width'] ) ? $options['width'] : false; |
|
18 | + $gallery_width = isset($options['width']) ? $options['width'] : false; |
|
19 | 19 | |
20 | 20 | // gallery grid item width |
21 | - $item_width = isset( $options['itemwidth'] ) ? $options['itemwidth'] : false; |
|
21 | + $item_width = isset($options['itemwidth']) ? $options['itemwidth'] : false; |
|
22 | 22 | |
23 | 23 | // caption |
24 | - $caption = isset( $options['caption'] ) ? $options['caption'] : false; |
|
24 | + $caption = isset($options['caption']) ? $options['caption'] : false; |
|
25 | 25 | |
26 | 26 | // gallery transition |
27 | - $transition = isset( $options['transition'] ) ? $options['transition'] : false; |
|
27 | + $transition = isset($options['transition']) ? $options['transition'] : false; |
|
28 | 28 | |
29 | 29 | // gallery transition speed |
30 | - $transitionSpeed = isset( $options['speed'] ) ? $options['speed'] : false; |
|
30 | + $transitionSpeed = isset($options['speed']) ? $options['speed'] : false; |
|
31 | 31 | |
32 | 32 | // gallery hide thumbs |
33 | - $hideThumbs = isset( $options['hideThumbs'] ) ? $options['hideThumbs'] : false; |
|
33 | + $hideThumbs = isset($options['hideThumbs']) ? $options['hideThumbs'] : false; |
|
34 | 34 | |
35 | 35 | // photoset layout |
36 | - $psLayout = isset( $options['pslayout'] ) ? $options['pslayout'] : false; |
|
36 | + $psLayout = isset($options['pslayout']) ? $options['pslayout'] : false; |
|
37 | 37 | |
38 | 38 | // photoset layout |
39 | - $psLightbox = isset( $options['pslightbox'] ) ? $options['pslightbox'] : false; |
|
39 | + $psLightbox = isset($options['pslightbox']) ? $options['pslightbox'] : false; |
|
40 | 40 | |
41 | 41 | // update gallery ids |
42 | - if ( !empty( $gallery_ids ) ) { |
|
42 | + if (!empty($gallery_ids)) { |
|
43 | 43 | |
44 | - update_post_meta( $postid, '_ase_gallery_images', $gallery_ids ); |
|
44 | + update_post_meta($postid, '_ase_gallery_images', $gallery_ids); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | - update_post_meta( $postid, 'aesop_gallery_type', sanitize_text_field( trim( $type ) ) ); |
|
48 | + update_post_meta($postid, 'aesop_gallery_type', sanitize_text_field(trim($type))); |
|
49 | 49 | |
50 | - update_post_meta( $postid, 'aesop_gallery_width', sanitize_text_field( trim( $gallery_width ) ) ); |
|
50 | + update_post_meta($postid, 'aesop_gallery_width', sanitize_text_field(trim($gallery_width))); |
|
51 | 51 | |
52 | - update_post_meta( $postid, 'aesop_grid_gallery_width', sanitize_text_field( trim( $item_width ) ) ); |
|
52 | + update_post_meta($postid, 'aesop_grid_gallery_width', sanitize_text_field(trim($item_width))); |
|
53 | 53 | |
54 | - update_post_meta( $postid, 'aesop_gallery_caption', sanitize_text_field( trim( $caption ) ) ); |
|
54 | + update_post_meta($postid, 'aesop_gallery_caption', sanitize_text_field(trim($caption))); |
|
55 | 55 | |
56 | - update_post_meta( $postid, 'aesop_thumb_gallery_transition', sanitize_text_field( trim( $transition ) ) ); |
|
56 | + update_post_meta($postid, 'aesop_thumb_gallery_transition', sanitize_text_field(trim($transition))); |
|
57 | 57 | |
58 | - update_post_meta( $postid, 'aesop_thumb_gallery_transition_speed', absint( trim( $transitionSpeed ) ) ); |
|
58 | + update_post_meta($postid, 'aesop_thumb_gallery_transition_speed', absint(trim($transitionSpeed))); |
|
59 | 59 | |
60 | - update_post_meta( $postid, 'aesop_thumb_gallery_hide_thumbs', sanitize_text_field( trim( $hideThumbs ) ) ); |
|
60 | + update_post_meta($postid, 'aesop_thumb_gallery_hide_thumbs', sanitize_text_field(trim($hideThumbs))); |
|
61 | 61 | |
62 | - update_post_meta( $postid, 'aesop_photoset_gallery_layout', sanitize_text_field( trim( $psLayout ) ) ); |
|
62 | + update_post_meta($postid, 'aesop_photoset_gallery_layout', sanitize_text_field(trim($psLayout))); |
|
63 | 63 | |
64 | - update_post_meta( $postid, 'aesop_photoset_gallery_lightbox', sanitize_text_field( trim( $psLightbox ) ) ); |
|
64 | + update_post_meta($postid, 'aesop_photoset_gallery_lightbox', sanitize_text_field(trim($psLightbox))); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 |
@@ -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 |
@@ -18,27 +18,27 @@ |
||
18 | 18 | */ |
19 | 19 | |
20 | 20 | // If this file is called directly, abort. |
21 | -if ( ! defined( 'WPINC' ) ) { |
|
21 | +if (!defined('WPINC')) { |
|
22 | 22 | die; |
23 | 23 | } |
24 | 24 | |
25 | 25 | // Set some constants |
26 | -define( 'LASSO_VERSION', '0.9.8.2' ); |
|
27 | -define( 'LASSO_DIR', plugin_dir_path( __FILE__ ) ); |
|
28 | -define( 'LASSO_URL', plugins_url( '', __FILE__ ) ); |
|
29 | -define( 'LASSO_FILE', __FILE__ ); |
|
26 | +define('LASSO_VERSION', '0.9.8.2'); |
|
27 | +define('LASSO_DIR', plugin_dir_path(__FILE__)); |
|
28 | +define('LASSO_URL', plugins_url('', __FILE__)); |
|
29 | +define('LASSO_FILE', __FILE__); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Load plugin if PHP version is 5.4 or later. |
33 | 33 | */ |
34 | -if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) { |
|
34 | +if (version_compare(PHP_VERSION, '5.4.0', '>=')) { |
|
35 | 35 | |
36 | - include_once( LASSO_DIR . '/bootstrap.php' ); |
|
36 | + include_once(LASSO_DIR.'/bootstrap.php'); |
|
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | 40 | add_action('admin_head', 'lasso_fail_notice'); |
41 | - function lasso_fail_notice(){ |
|
41 | + function lasso_fail_notice() { |
|
42 | 42 | |
43 | 43 | printf('<div class="error"><p>Lasso requires PHP 5.4 or higher.</p></div>'); |
44 | 44 |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | |
11 | 11 | class assets { |
12 | 12 | |
13 | - public function __construct(){ |
|
13 | + public function __construct() { |
|
14 | 14 | |
15 | - add_action('wp_enqueue_scripts', array($this,'scripts')); |
|
15 | + add_action('wp_enqueue_scripts', array($this, 'scripts')); |
|
16 | 16 | } |
17 | 17 | |
18 | - public function scripts(){ |
|
18 | + public function scripts() { |
|
19 | 19 | |
20 | - if ( lasso_user_can('edit_posts') ) { |
|
20 | + if (lasso_user_can('edit_posts')) { |
|
21 | 21 | |
22 | 22 | wp_enqueue_style('lasso-style', LASSO_URL.'/public/assets/css/lasso.css', LASSO_VERSION, true); |
23 | 23 | |
@@ -32,75 +32,75 @@ discard block |
||
32 | 32 | // url for json api |
33 | 33 | $home_url = function_exists('json_get_url_prefix') ? json_get_url_prefix() : false; |
34 | 34 | |
35 | - $article_object = lasso_editor_get_option('article_class','lasso_editor'); |
|
35 | + $article_object = lasso_editor_get_option('article_class', 'lasso_editor'); |
|
36 | 36 | |
37 | - $article_object = empty( $article_object ) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object; |
|
37 | + $article_object = empty($article_object) && lasso_get_supported_theme_class() ? lasso_get_supported_theme_class() : $article_object; |
|
38 | 38 | |
39 | - $featImgClass = lasso_editor_get_option('featimg_class','lasso_editor'); |
|
40 | - $titleClass = lasso_editor_get_option('title_class','lasso_editor'); |
|
41 | - $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); |
|
42 | - $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); |
|
39 | + $featImgClass = lasso_editor_get_option('featimg_class', 'lasso_editor'); |
|
40 | + $titleClass = lasso_editor_get_option('title_class', 'lasso_editor'); |
|
41 | + $toolbar_headings = lasso_editor_get_option('toolbar_headings', 'lasso_editor'); |
|
42 | + $objectsNoSave = lasso_editor_get_option('dont_save', 'lasso_editor'); |
|
43 | 43 | |
44 | 44 | // post id reference |
45 | - $postid = get_the_ID(); |
|
45 | + $postid = get_the_ID(); |
|
46 | 46 | |
47 | 47 | $strings = array( |
48 | - 'save' => __('Save','lasso'), |
|
49 | - 'saving' => __('Saving...','lasso'), |
|
50 | - 'saved' => __('Saved!','lasso'), |
|
51 | - 'adding' => __('Adding...','lasso'), |
|
52 | - 'added' => __('Added!','lasso'), |
|
53 | - 'loading' => __('Loading...','lasso'), |
|
54 | - 'loadMore' => __('Load More','lasso'), |
|
55 | - 'noPostsFound' => __('No more posts found','lasso'), |
|
56 | - 'galleryCreated' => __('Gallery Created!','lasso'), |
|
57 | - 'galleryUpdated' => __('Gallery Updated!','lasso'), |
|
58 | - 'justWrite' => __('Just write...','lasso'), |
|
59 | - 'chooseImage' => __('Choose an image','lasso'), |
|
60 | - 'updateImage' => __('Update Image','lasso'), |
|
61 | - 'insertImage' => __('Insert Image','lasso'), |
|
62 | - 'selectImage' => __('Select Image','lasso'), |
|
63 | - 'removeFeatImg' => __('Remove featured image?','lasso'), |
|
64 | - 'updateSelectedImg' => __('Update Selected Image','lasso'), |
|
65 | - 'chooseImages' => __('Choose images','lasso'), |
|
66 | - 'editImage' => __('Edit Image','lasso'), |
|
67 | - 'addImages' => __('Add Images','lasso'), |
|
68 | - 'addNewGallery' => __('Add New Gallery','lasso'), |
|
69 | - 'selectGallery' => __('Select Lasso Gallery Image','lasso'), |
|
70 | - 'useSelectedImages' => __('Use Selected Images','lasso'), |
|
71 | - 'publishPost' => __('Publish Post?','lasso'), |
|
72 | - 'publishYes' => __('Yes, publish it!','lasso'), |
|
73 | - 'deletePost' => __('Trash Post?','lasso'), |
|
74 | - 'deleteYes' => __('Yes, trash it!','lasso'), |
|
75 | - 'warning' => __('Oh snap!','laso'), |
|
76 | - 'cancelText' => __('O.K. got it!','lasso'), |
|
77 | - 'missingClass' => __('It looks like we are missing the Article CSS class. Lasso will not function correctly without this CSS class.','lasso'), |
|
48 | + 'save' => __('Save', 'lasso'), |
|
49 | + 'saving' => __('Saving...', 'lasso'), |
|
50 | + 'saved' => __('Saved!', 'lasso'), |
|
51 | + 'adding' => __('Adding...', 'lasso'), |
|
52 | + 'added' => __('Added!', 'lasso'), |
|
53 | + 'loading' => __('Loading...', 'lasso'), |
|
54 | + 'loadMore' => __('Load More', 'lasso'), |
|
55 | + 'noPostsFound' => __('No more posts found', 'lasso'), |
|
56 | + 'galleryCreated' => __('Gallery Created!', 'lasso'), |
|
57 | + 'galleryUpdated' => __('Gallery Updated!', 'lasso'), |
|
58 | + 'justWrite' => __('Just write...', 'lasso'), |
|
59 | + 'chooseImage' => __('Choose an image', 'lasso'), |
|
60 | + 'updateImage' => __('Update Image', 'lasso'), |
|
61 | + 'insertImage' => __('Insert Image', 'lasso'), |
|
62 | + 'selectImage' => __('Select Image', 'lasso'), |
|
63 | + 'removeFeatImg' => __('Remove featured image?', 'lasso'), |
|
64 | + 'updateSelectedImg' => __('Update Selected Image', 'lasso'), |
|
65 | + 'chooseImages' => __('Choose images', 'lasso'), |
|
66 | + 'editImage' => __('Edit Image', 'lasso'), |
|
67 | + 'addImages' => __('Add Images', 'lasso'), |
|
68 | + 'addNewGallery' => __('Add New Gallery', 'lasso'), |
|
69 | + 'selectGallery' => __('Select Lasso Gallery Image', 'lasso'), |
|
70 | + 'useSelectedImages' => __('Use Selected Images', 'lasso'), |
|
71 | + 'publishPost' => __('Publish Post?', 'lasso'), |
|
72 | + 'publishYes' => __('Yes, publish it!', 'lasso'), |
|
73 | + 'deletePost' => __('Trash Post?', 'lasso'), |
|
74 | + 'deleteYes' => __('Yes, trash it!', 'lasso'), |
|
75 | + 'warning' => __('Oh snap!', 'laso'), |
|
76 | + 'cancelText' => __('O.K. got it!', 'lasso'), |
|
77 | + 'missingClass' => __('It looks like we are missing the Article CSS class. Lasso will not function correctly without this CSS class.', 'lasso'), |
|
78 | 78 | 'missingConfirm' => __('Update Settings', 'lasso'), |
79 | - 'helperText' => __('one more letter','lasso'), |
|
79 | + 'helperText' => __('one more letter', 'lasso'), |
|
80 | 80 | 'editingBackup' => __('You are currently editing a backup copy of this post.') |
81 | 81 | ); |
82 | 82 | |
83 | - $api_url = trailingslashit( home_url() ) . 'lasso-internal-api'; |
|
83 | + $api_url = trailingslashit(home_url()).'lasso-internal-api'; |
|
84 | 84 | |
85 | 85 | $gallery_class = new gallery(); |
86 | 86 | $gallery_nonce_action = $gallery_class->nonce_action; |
87 | - $gallery_nonce = wp_create_nonce( $gallery_nonce_action ); |
|
87 | + $gallery_nonce = wp_create_nonce($gallery_nonce_action); |
|
88 | 88 | |
89 | 89 | // localized objects |
90 | 90 | $objects = array( |
91 | - 'ajaxurl' => esc_url( $api_url ), |
|
91 | + 'ajaxurl' => esc_url($api_url), |
|
92 | 92 | 'editor' => 'lasso--content', // ID of editable content (without #) DONT CHANGE |
93 | 93 | 'article_object' => $article_object, |
94 | 94 | 'featImgClass' => $featImgClass, |
95 | 95 | 'titleClass' => $titleClass, |
96 | 96 | 'strings' => $strings, |
97 | - 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url( 'settings.php?page=lasso-editor' ) : admin_url( 'admin.php?page=lasso-editor-settings' ), |
|
98 | - 'post_status' => get_post_status( $postid ), |
|
97 | + 'settingsLink' => function_exists('is_multisite') && is_multisite() ? network_admin_url('settings.php?page=lasso-editor') : admin_url('admin.php?page=lasso-editor-settings'), |
|
98 | + 'post_status' => get_post_status($postid), |
|
99 | 99 | 'postid' => $postid, |
100 | 100 | 'permalink' => get_permalink(), |
101 | 101 | 'edit_others_pages' => current_user_can('edit_others_pages') ? 'true' : 'false', |
102 | 102 | 'edit_others_posts' => current_user_can('edit_others_posts') ? 'true' : 'false', |
103 | - 'userCanEdit' => current_user_can('edit_post', $postid ), |
|
103 | + 'userCanEdit' => current_user_can('edit_post', $postid), |
|
104 | 104 | 'can_publish_posts' => current_user_can('publish_posts'), |
105 | 105 | 'can_publish_pages' => current_user_can('publish_pages'), |
106 | 106 | 'author' => is_user_logged_in() ? get_current_user_ID() : false, |
@@ -132,22 +132,22 @@ discard block |
||
132 | 132 | 'postTags' => lasso_get_objects('tag'), |
133 | 133 | 'noResultsDiv' => lasso_editor_empty_results(), |
134 | 134 | 'noRevisionsDiv' => lasso_editor_empty_results('revision'), |
135 | - 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider( $postid ) : false, |
|
136 | - 'mapLocations' => get_post_meta( $postid, 'ase_map_component_locations' ), |
|
137 | - 'mapStart' => get_post_meta( $postid, 'ase_map_component_start_point', true ), |
|
138 | - 'mapZoom' => get_post_meta( $postid, 'ase_map_component_zoom', true ), |
|
135 | + 'mapTileProvider' => function_exists('aesop_map_tile_provider') ? aesop_map_tile_provider($postid) : false, |
|
136 | + 'mapLocations' => get_post_meta($postid, 'ase_map_component_locations'), |
|
137 | + 'mapStart' => get_post_meta($postid, 'ase_map_component_start_point', true), |
|
138 | + 'mapZoom' => get_post_meta($postid, 'ase_map_component_zoom', true), |
|
139 | 139 | 'revisionModal' => lasso_editor_revision_modal() |
140 | 140 | ); |
141 | 141 | |
142 | 142 | |
143 | 143 | // wp api client |
144 | - wp_enqueue_script( 'wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array( 'jquery', 'underscore', 'backbone' ), LASSO_VERSION, true ); |
|
145 | - $settings = array( 'root' => home_url( $home_url ), 'nonce' => wp_create_nonce( 'wp_json' ) ); |
|
146 | - wp_localize_script( 'wp-api-js', 'WP_API_Settings', $settings ); |
|
144 | + wp_enqueue_script('wp-api-js', LASSO_URL.'/public/assets/js/source/util--wp-api.js', array('jquery', 'underscore', 'backbone'), LASSO_VERSION, true); |
|
145 | + $settings = array('root' => home_url($home_url), 'nonce' => wp_create_nonce('wp_json')); |
|
146 | + wp_localize_script('wp-api-js', 'WP_API_Settings', $settings); |
|
147 | 147 | |
148 | - $postfix = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min'; |
|
149 | - wp_enqueue_script('lasso', LASSO_URL. "/public/assets/js/lasso{$postfix}.js", array('jquery'), LASSO_VERSION, true); |
|
150 | - wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects ) ); |
|
148 | + $postfix = (defined('SCRIPT_DEBUG') && true === SCRIPT_DEBUG) ? '' : '.min'; |
|
149 | + wp_enqueue_script('lasso', LASSO_URL."/public/assets/js/lasso{$postfix}.js", array('jquery'), LASSO_VERSION, true); |
|
150 | + wp_localize_script('lasso', 'lasso_editor', apply_filters('lasso_localized_objects', $objects)); |
|
151 | 151 | |
152 | 152 | |
153 | 153 | } |