@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @since 1.0 |
27 | 27 | */ |
28 | - public function post( $data ) { |
|
28 | + public function post($data) { |
|
29 | 29 | |
30 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
30 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
31 | 31 | |
32 | 32 | // bail out if teh current user can't publish posts |
33 | - if ( !lasso_user_can( 'delete_post', $postid ) ) |
|
33 | + if (!lasso_user_can('delete_post', $postid)) |
|
34 | 34 | return; |
35 | 35 | |
36 | 36 | $args = array( |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | 'post_status' => 'trash' |
39 | 39 | ); |
40 | 40 | |
41 | - wp_update_post( apply_filters( 'lasso_object_deleted_args', $args ) ); |
|
41 | + wp_update_post(apply_filters('lasso_object_deleted_args', $args)); |
|
42 | 42 | |
43 | - do_action( 'lasso_object_deleted', $postid, get_current_user_ID() ); |
|
43 | + do_action('lasso_object_deleted', $postid, get_current_user_ID()); |
|
44 | 44 | |
45 | 45 | return true; |
46 | 46 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
54 | 54 | */ |
55 | - public static function params(){ |
|
56 | - $params[ 'process_delete_post' ] = array( |
|
55 | + public static function params() { |
|
56 | + $params['process_delete_post'] = array( |
|
57 | 57 | 'postid' => 'absint', |
58 | 58 | ); |
59 | 59 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return array Array of additional functions to use to authorize action. |
69 | 69 | */ |
70 | 70 | public static function auth_callbacks() { |
71 | - $params[ 'process_delete_post' ] = array( |
|
71 | + $params['process_delete_post'] = array( |
|
72 | 72 | 'lasso_user_can' |
73 | 73 | ); |
74 | 74 |
@@ -30,8 +30,9 @@ |
||
30 | 30 | $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
31 | 31 | |
32 | 32 | // bail out if teh current user can't publish posts |
33 | - if ( !lasso_user_can( 'delete_post', $postid ) ) |
|
34 | - return; |
|
33 | + if ( !lasso_user_can( 'delete_post', $postid ) ) { |
|
34 | + return; |
|
35 | + } |
|
35 | 36 | |
36 | 37 | $args = array( |
37 | 38 | 'ID' => (int) $postid, |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | $gallery_ids = isset( $data['gallery_ids'] ) ? $data['gallery_ids'] : false; |
120 | 120 | if ( ! empty( $data ) && $data[ 'gallery_type' ] ) { |
121 | 121 | $type = $data[ 'gallery_type' ]; |
122 | - }elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
122 | + } elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
123 | 123 | $type = $options[ 'galleryType' ]; |
124 | - }else{ |
|
124 | + } else{ |
|
125 | 125 | $type = false; |
126 | 126 | } |
127 | 127 | |
@@ -173,8 +173,9 @@ discard block |
||
173 | 173 | */ |
174 | 174 | private function get_the_images( $image_ids = '' ) { |
175 | 175 | |
176 | - if ( empty( $image_ids ) ) |
|
177 | - return; |
|
176 | + if ( empty( $image_ids ) ) { |
|
177 | + return; |
|
178 | + } |
|
178 | 179 | |
179 | 180 | $image_ids = array_map( 'intval', explode( ',', $image_ids ) ); |
180 | 181 |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return array Key "markup" has the HTML. |
31 | 31 | */ |
32 | - public function swap( $data ) { |
|
32 | + public function swap($data) { |
|
33 | 33 | |
34 | 34 | |
35 | - $id = $data[ 'gallery_id' ]; |
|
36 | - if ( is_null( $id ) ) { |
|
35 | + $id = $data['gallery_id']; |
|
36 | + if (is_null($id)) { |
|
37 | 37 | $id = false; |
38 | 38 | } |
39 | 39 | |
40 | - $markup = sprintf( '<div contenteditable="false" class="lasso--empty-component aesop-component aesop-gallery-component" data-component-type="gallery" data-id="%s">%s</div>', $id, __( 'Save and refresh to view gallery.','lasso' ) ); |
|
40 | + $markup = sprintf('<div contenteditable="false" class="lasso--empty-component aesop-component aesop-gallery-component" data-component-type="gallery" data-id="%s">%s</div>', $id, __('Save and refresh to view gallery.', 'lasso')); |
|
41 | 41 | |
42 | 42 | return array( |
43 | 43 | 'gallery' => $markup |
@@ -54,49 +54,49 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return array|bool On success an array containing "message" or on failure false. |
56 | 56 | */ |
57 | - public function create( $data ) { |
|
57 | + public function create($data) { |
|
58 | 58 | |
59 | 59 | //@todo adapt auth callbacks to work with args. |
60 | - if ( ! lasso_user_can( 'publish_posts' ) ) { |
|
60 | + if (!lasso_user_can('publish_posts')) { |
|
61 | 61 | return false; |
62 | 62 | |
63 | 63 | } |
64 | 64 | |
65 | - $gallery_ids = isset( $data['gallery_ids'] ) ? $data['gallery_ids'] : false; |
|
65 | + $gallery_ids = isset($data['gallery_ids']) ? $data['gallery_ids'] : false; |
|
66 | 66 | |
67 | 67 | // bail if no gallery ids |
68 | - if ( empty( $gallery_ids ) ) { |
|
68 | + if (empty($gallery_ids)) { |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
72 | - $postid = isset( $data['postid'] ) ? (int) $data['postid'] : false; |
|
73 | - $type = isset( $data['gallery_type'] ) ? $data['gallery_type'] : false; |
|
74 | - $edgallerytitle = isset( $data['edgallerytitle'] ) ? $data['edgallerytitle'] : $postid.'-'.rand(); |
|
72 | + $postid = isset($data['postid']) ? (int) $data['postid'] : false; |
|
73 | + $type = isset($data['gallery_type']) ? $data['gallery_type'] : false; |
|
74 | + $edgallerytitle = isset($data['edgallerytitle']) ? $data['edgallerytitle'] : $postid.'-'.rand(); |
|
75 | 75 | |
76 | 76 | // insert a new gallery |
77 | 77 | $args = array( |
78 | - 'post_title' => $edgallerytitle , |
|
78 | + 'post_title' => $edgallerytitle, |
|
79 | 79 | 'post_status' => 'publish', |
80 | 80 | 'post_type' => 'ai_galleries' |
81 | 81 | ); |
82 | 82 | |
83 | - $postid = wp_insert_post( apply_filters( 'lasso_insert_gallery_args', $args ) ); |
|
83 | + $postid = wp_insert_post(apply_filters('lasso_insert_gallery_args', $args)); |
|
84 | 84 | |
85 | 85 | // update gallery ids |
86 | - if ( $gallery_ids ) { |
|
86 | + if ($gallery_ids) { |
|
87 | 87 | |
88 | - update_post_meta( $postid, '_ase_gallery_images', $gallery_ids ); |
|
88 | + update_post_meta($postid, '_ase_gallery_images', $gallery_ids); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | 92 | // update the gallery type |
93 | - if ( !empty( $type ) ) { |
|
93 | + if (!empty($type)) { |
|
94 | 94 | |
95 | - update_post_meta( $postid, 'aesop_gallery_type', $type ); |
|
95 | + update_post_meta($postid, 'aesop_gallery_type', $type); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
99 | - do_action( 'lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID() ); |
|
99 | + do_action('lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID()); |
|
100 | 100 | |
101 | 101 | return array( |
102 | 102 | 'message' => 'gallery-created', |
@@ -114,20 +114,20 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array "message" key has the message. |
116 | 116 | */ |
117 | - public function update( $data ) { |
|
118 | - |
|
119 | - $options = isset( $data['fields'] ) ? $data['fields'] : false; |
|
120 | - $postid = !empty( $options ) ? (int) $options['id'] : false; |
|
121 | - $gallery_ids = isset( $data['gallery_ids'] ) ? $data['gallery_ids'] : false; |
|
122 | - if ( ! empty( $data ) && $data[ 'gallery_type' ] ) { |
|
123 | - $type = $data[ 'gallery_type' ]; |
|
124 | - }elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
125 | - $type = $options[ 'galleryType' ]; |
|
126 | - }else{ |
|
117 | + public function update($data) { |
|
118 | + |
|
119 | + $options = isset($data['fields']) ? $data['fields'] : false; |
|
120 | + $postid = !empty($options) ? (int) $options['id'] : false; |
|
121 | + $gallery_ids = isset($data['gallery_ids']) ? $data['gallery_ids'] : false; |
|
122 | + if (!empty($data) && $data['gallery_type']) { |
|
123 | + $type = $data['gallery_type']; |
|
124 | + }elseif (!empty($options) && $options['galleryType']) { |
|
125 | + $type = $options['galleryType']; |
|
126 | + } else { |
|
127 | 127 | $type = false; |
128 | 128 | } |
129 | 129 | |
130 | - save_gallery::save_gallery_options( $postid, $gallery_ids, $options, $type ); |
|
130 | + save_gallery::save_gallery_options($postid, $gallery_ids, $options, $type); |
|
131 | 131 | |
132 | 132 | return array( |
133 | 133 | 'message' => 'gallery-updated' |
@@ -145,25 +145,25 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return bool |
147 | 147 | */ |
148 | - public function get_images( $data ) { |
|
148 | + public function get_images($data) { |
|
149 | 149 | |
150 | 150 | //check caps |
151 | - if ( !current_user_can( 'edit_posts' ) ) { |
|
151 | + if (!current_user_can('edit_posts')) { |
|
152 | 152 | return false; |
153 | 153 | } |
154 | 154 | |
155 | 155 | // bail if no id specified like on new galleries |
156 | - if ( is_null( $data['post_id'] ) || empty( $data['post_id'] ) ) { |
|
156 | + if (is_null($data['post_id']) || empty($data['post_id'])) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | |
160 | - $postid = isset( $data['post_id'] ) ? $data['post_id'] : false; |
|
160 | + $postid = isset($data['post_id']) ? $data['post_id'] : false; |
|
161 | 161 | |
162 | 162 | // fetch image ids from cache |
163 | - $image_ids = get_post_meta( $postid, '_ase_gallery_images', true ); |
|
163 | + $image_ids = get_post_meta($postid, '_ase_gallery_images', true); |
|
164 | 164 | |
165 | 165 | // send ids to return images |
166 | - return self::get_the_images( $image_ids ); |
|
166 | + return self::get_the_images($image_ids); |
|
167 | 167 | |
168 | 168 | } |
169 | 169 | |
@@ -173,32 +173,32 @@ discard block |
||
173 | 173 | * @param $image_ids array array of image ids |
174 | 174 | * @since 0.1 |
175 | 175 | */ |
176 | - private function get_the_images( $image_ids = '' ) { |
|
176 | + private function get_the_images($image_ids = '') { |
|
177 | 177 | |
178 | - if ( empty( $image_ids ) ) |
|
178 | + if (empty($image_ids)) |
|
179 | 179 | return; |
180 | 180 | |
181 | - $image_ids = array_map( 'intval', explode( ',', $image_ids ) ); |
|
181 | + $image_ids = array_map('intval', explode(',', $image_ids)); |
|
182 | 182 | |
183 | 183 | $out[] = '<ul id="ase-gallery-images">'; |
184 | 184 | |
185 | - if ( !empty( $image_ids ) ): |
|
185 | + if (!empty($image_ids)): |
|
186 | 186 | |
187 | - foreach ( $image_ids as $image_id ) { |
|
187 | + foreach ($image_ids as $image_id) { |
|
188 | 188 | |
189 | - $image = wp_get_attachment_image_src( $image_id, 'thumbnail', false ); |
|
189 | + $image = wp_get_attachment_image_src($image_id, 'thumbnail', false); |
|
190 | 190 | |
191 | - $out[] = sprintf( ' |
|
191 | + $out[] = sprintf(' |
|
192 | 192 | <li id="%1s" class="ase-gallery-image"> |
193 | 193 | <i class="dashicons dashicons-no-alt" title="%2s"></i> |
194 | 194 | <i class="dashicons dashicons-edit" title="%3s"></i> |
195 | 195 | <img src="%4s"> |
196 | 196 | </li> |
197 | 197 | ', |
198 | - absint( $image_id ), |
|
199 | - __( 'Delete From Gallery', 'lasso' ), |
|
200 | - __( 'Edit Image Caption', 'lasso' ), |
|
201 | - esc_url( $image[0] ) |
|
198 | + absint($image_id), |
|
199 | + __('Delete From Gallery', 'lasso'), |
|
200 | + __('Edit Image Caption', 'lasso'), |
|
201 | + esc_url($image[0]) |
|
202 | 202 | ); |
203 | 203 | |
204 | 204 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | |
208 | 208 | $out[] = '</ul>'; |
209 | 209 | |
210 | - return array( 'html' => implode( '', $out ) ); |
|
210 | + return array('html' => implode('', $out)); |
|
211 | 211 | |
212 | 212 | } |
213 | 213 | |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return array Array of keys to pull from $data per action and their sanitization callback |
221 | 221 | */ |
222 | - public static function params(){ |
|
223 | - $params[ 'process_gallery_swap' ] = array( |
|
222 | + public static function params() { |
|
223 | + $params['process_gallery_swap'] = array( |
|
224 | 224 | 'gallery_id' => 'absint', |
225 | 225 | |
226 | 226 | ); |
227 | 227 | |
228 | - $params[ 'process_gallery_create' ] = array( |
|
228 | + $params['process_gallery_create'] = array( |
|
229 | 229 | 'postid' => 'absint', |
230 | 230 | 'content' => 'wp_kses_post', |
231 | 231 | 'edgallerytitle' =>'sanitize_text_field', |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | ); |
239 | 239 | |
240 | - $params[ 'process_gallery_update' ] = array( |
|
240 | + $params['process_gallery_update'] = array( |
|
241 | 241 | 'postid' => 'absint', |
242 | 242 | 'gallery_ids' => 'lasso_sanitize_data', |
243 | 243 | 'fields' => 'lasso_sanitize_data', |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | ) |
248 | 248 | ); |
249 | 249 | |
250 | - $params[ 'process_gallery_get_images' ] = array( |
|
250 | + $params['process_gallery_get_images'] = array( |
|
251 | 251 | 'post_id' => 'absint' |
252 | 252 | ); |
253 | 253 | |
@@ -263,19 +263,19 @@ discard block |
||
263 | 263 | * @return array Array of additional functions to use to authorize action. |
264 | 264 | */ |
265 | 265 | public static function auth_callbacks() { |
266 | - $params[ 'process_gallery_swap' ] = array( |
|
266 | + $params['process_gallery_swap'] = array( |
|
267 | 267 | 'lasso_user_can' |
268 | 268 | ); |
269 | 269 | |
270 | - $params[ 'process_gallery_create' ] = array( |
|
270 | + $params['process_gallery_create'] = array( |
|
271 | 271 | 'is_user_logged_in' |
272 | 272 | ); |
273 | 273 | |
274 | - $params[ 'process_gallery_update' ] = array( |
|
274 | + $params['process_gallery_update'] = array( |
|
275 | 275 | 'lasso_user_can' |
276 | 276 | ); |
277 | 277 | |
278 | - $params[ 'process_gallery_get_images' ] = array(); |
|
278 | + $params['process_gallery_get_images'] = array(); |
|
279 | 279 | |
280 | 280 | return $params; |
281 | 281 |
@@ -28,27 +28,27 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool Always returns true. |
30 | 30 | */ |
31 | - public function save( $data ) { |
|
31 | + public function save($data) { |
|
32 | 32 | |
33 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
34 | - $locations = isset( $data['ase-map-component-locations'] ) ? $data['ase-map-component-locations'] : false; |
|
35 | - $start_point = isset( $data['ase-map-component-start-point'] ) ? $data['ase-map-component-start-point']: false; |
|
36 | - $zoom = isset( $data['ase-map-component-zoom'] ) ? $data['ase-map-component-zoom' ] : false; |
|
33 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
34 | + $locations = isset($data['ase-map-component-locations']) ? $data['ase-map-component-locations'] : false; |
|
35 | + $start_point = isset($data['ase-map-component-start-point']) ? $data['ase-map-component-start-point'] : false; |
|
36 | + $zoom = isset($data['ase-map-component-zoom']) ? $data['ase-map-component-zoom'] : false; |
|
37 | 37 | |
38 | - if ( is_array( $locations ) ) { |
|
39 | - delete_post_meta( $postid, 'ase_map_component_locations' ); |
|
38 | + if (is_array($locations)) { |
|
39 | + delete_post_meta($postid, 'ase_map_component_locations'); |
|
40 | 40 | |
41 | 41 | // update locations if set |
42 | - foreach ( $locations as $location ) { |
|
43 | - $point = json_decode( urldecode( $location ), true ); |
|
44 | - add_post_meta( $postid, 'ase_map_component_locations', $point ); |
|
42 | + foreach ($locations as $location) { |
|
43 | + $point = json_decode(urldecode($location), true); |
|
44 | + add_post_meta($postid, 'ase_map_component_locations', $point); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | // udpate start point |
48 | - update_post_meta( $postid, 'ase_map_component_start_point', $start_point ); |
|
48 | + update_post_meta($postid, 'ase_map_component_start_point', $start_point); |
|
49 | 49 | |
50 | 50 | // update zoom |
51 | - update_post_meta( $postid, 'ase_map_component_zoom', $zoom ); |
|
51 | + update_post_meta($postid, 'ase_map_component_zoom', $zoom); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | return true; |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
64 | 64 | */ |
65 | - public static function params(){ |
|
66 | - $params[ 'process_map_save' ] = array( |
|
65 | + public static function params() { |
|
66 | + $params['process_map_save'] = array( |
|
67 | 67 | 'postid' => 'absint', |
68 | 68 | 'ase-map-component-locations' => 'lasso_sanitize_data', |
69 | 69 | 'ase-map-component-start-point' => array( |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return array Array of additional functions to use to authorize action. |
88 | 88 | */ |
89 | 89 | public static function auth_callbacks() { |
90 | - $params[ 'process_map_save' ] = array( |
|
90 | + $params['process_map_save'] = array( |
|
91 | 91 | 'lasso_user_can' |
92 | 92 | ); |
93 | 93 |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool Always returns true. |
30 | 30 | */ |
31 | - public function update( $data ) { |
|
31 | + public function update($data) { |
|
32 | 32 | |
33 | - $post_id = isset( $data['post_id'] ) ? $data['post_id'] : false; |
|
33 | + $post_id = isset($data['post_id']) ? $data['post_id'] : false; |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param array $allowed_fields The fields |
42 | 42 | */ |
43 | - $allowed_fields = apply_filters( 'lasso_meta_fields', array() ); |
|
44 | - if ( ! empty( $allowed_fields ) ) { |
|
45 | - foreach( $allowed_fields as $field ) { |
|
46 | - if ( isset( $data[ $field ] ) ) { |
|
47 | - update_post_meta( $post_id, lasso_unclean_string( $field ), $data[ $field ] ); |
|
43 | + $allowed_fields = apply_filters('lasso_meta_fields', array()); |
|
44 | + if (!empty($allowed_fields)) { |
|
45 | + foreach ($allowed_fields as $field) { |
|
46 | + if (isset($data[$field])) { |
|
47 | + update_post_meta($post_id, lasso_unclean_string($field), $data[$field]); |
|
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return array Array of keys to pull from $data per action and their sanitization callback |
64 | 64 | */ |
65 | - public static function params(){ |
|
66 | - $params[ 'process_meta_update' ] = array( |
|
65 | + public static function params() { |
|
66 | + $params['process_meta_update'] = array( |
|
67 | 67 | 'post_id' => 'absint', |
68 | 68 | 'tab_name' => 'trim' |
69 | 69 | ); |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @return array Array of additional functions to use to authorize action. |
81 | 81 | */ |
82 | 82 | public static function auth_callbacks() { |
83 | - $params[ 'process_meta_update' ] = array( |
|
83 | + $params['process_meta_update'] = array( |
|
84 | 84 | 'lasso_user_can' |
85 | 85 | ); |
86 | 86 |
@@ -28,26 +28,26 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @since 1.0 |
30 | 30 | */ |
31 | - public function post( $data ) { |
|
31 | + public function post($data) { |
|
32 | 32 | |
33 | - $title = $data[ 'story_title' ]; |
|
33 | + $title = $data['story_title']; |
|
34 | 34 | |
35 | - $object = is_null( $data[ 'object'] ) ? false : $data[ 'object' ]; |
|
35 | + $object = is_null($data['object']) ? false : $data['object']; |
|
36 | 36 | |
37 | 37 | // insert a new post |
38 | 38 | $args = array( |
39 | 39 | 'post_title' => $title, |
40 | 40 | 'post_status' => 'draft', |
41 | 41 | 'post_type' => $object, |
42 | - 'post_content' => apply_filters( 'lasso_new_object_content', __( 'Once upon a time...','lasso') ) |
|
42 | + 'post_content' => apply_filters('lasso_new_object_content', __('Once upon a time...', 'lasso')) |
|
43 | 43 | ); |
44 | 44 | |
45 | - $postid = wp_insert_post( apply_filters( 'lasso_insert_object_args', $args ) ); |
|
45 | + $postid = wp_insert_post(apply_filters('lasso_insert_object_args', $args)); |
|
46 | 46 | |
47 | - do_action( 'lasso_new_object', $postid, $object, $title, get_current_user_ID() ); |
|
47 | + do_action('lasso_new_object', $postid, $object, $title, get_current_user_ID()); |
|
48 | 48 | |
49 | 49 | return array( |
50 | - 'postlink' => get_permalink( $postid ) |
|
50 | + 'postlink' => get_permalink($postid) |
|
51 | 51 | ); |
52 | 52 | |
53 | 53 | } |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
61 | 61 | */ |
62 | 62 | public static function params() { |
63 | - $params[ 'process_new_object_post' ] = array( |
|
64 | - 'story_title' => array( 'wp_strip_all_tags', 'trim' ), |
|
63 | + $params['process_new_object_post'] = array( |
|
64 | + 'story_title' => array('wp_strip_all_tags', 'trim'), |
|
65 | 65 | 'object' => 'trim' |
66 | 66 | ); |
67 | 67 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return array Array of additional functions to use to authorize action. |
78 | 78 | */ |
79 | 79 | public static function auth_callbacks() { |
80 | - $params[ 'process_new_object_post' ] = array(); |
|
80 | + $params['process_new_object_post'] = array(); |
|
81 | 81 | |
82 | 82 | return $params; |
83 | 83 |
@@ -27,17 +27,17 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return array |
29 | 29 | */ |
30 | - public static function get( $data ) { |
|
30 | + public static function get($data) { |
|
31 | 31 | $args = array(); |
32 | - if ( isset( $data[ 'limit' ] ) ) { |
|
33 | - $args[ 'posts_per_page' ] = $data[ 'limit' ]; |
|
34 | - }else{ |
|
35 | - $args[ 'posts_per_page' ] = 6; // we start at revision 0 |
|
32 | + if (isset($data['limit'])) { |
|
33 | + $args['posts_per_page'] = $data['limit']; |
|
34 | + } else { |
|
35 | + $args['posts_per_page'] = 6; // we start at revision 0 |
|
36 | 36 | } |
37 | 37 | |
38 | - $revisions = wp_get_post_revisions( $data[ 'postid' ], $args ); |
|
39 | - if ( is_array( $revisions ) && ! empty( $revisions ) ) { |
|
40 | - self::set_revisions( $data[ 'postid' ], $revisions ); |
|
38 | + $revisions = wp_get_post_revisions($data['postid'], $args); |
|
39 | + if (is_array($revisions) && !empty($revisions)) { |
|
40 | + self::set_revisions($data['postid'], $revisions); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | return self::$revisions; |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @param int $id The post ID to get the revisions for |
54 | 54 | * @param obj $revisions The revisions for this post |
55 | 55 | */ |
56 | - protected static function set_revisions( $id, $revisions ) { |
|
56 | + protected static function set_revisions($id, $revisions) { |
|
57 | 57 | |
58 | - array_walk( $revisions, function ( $post, $i ) { |
|
58 | + array_walk($revisions, function($post, $i) { |
|
59 | 59 | self::$revisions[] = array( |
60 | 60 | 'post_content' => $post->post_content, |
61 | 61 | 'post_title' => $post->post_title, |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return array Array of keys to pull from $_POST per action and their sanitization callback |
75 | 75 | */ |
76 | - public static function params(){ |
|
77 | - $params[ 'process_revision_get' ] = array( |
|
76 | + public static function params() { |
|
77 | + $params['process_revision_get'] = array( |
|
78 | 78 | 'postid' => 'absint', |
79 | 79 | 'limit' => 'absint' |
80 | 80 | ); |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @return array Array of additional functions to use to authorize action. |
91 | 91 | */ |
92 | 92 | public static function auth_callbacks() { |
93 | - $params[ 'process_revision_get' ] = array( |
|
93 | + $params['process_revision_get'] = array( |
|
94 | 94 | 'lasso_user_can' |
95 | 95 | ); |
96 | 96 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | $args = array(); |
32 | 32 | if ( isset( $data[ 'limit' ] ) ) { |
33 | 33 | $args[ 'posts_per_page' ] = $data[ 'limit' ]; |
34 | - }else{ |
|
34 | + } else{ |
|
35 | 35 | $args[ 'posts_per_page' ] = 6; // we start at revision 0 |
36 | 36 | } |
37 | 37 |
@@ -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 |
@@ -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 |