@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /*----------------------------------------------------------------------------* |
| 10 | 10 | * Register Autoloader |
| 11 | 11 | *----------------------------------------------------------------------------*/ |
| 12 | -include_once( LASSO_DIR . '/includes/lasso_autoloader.php' ); |
|
| 12 | +include_once(LASSO_DIR.'/includes/lasso_autoloader.php'); |
|
| 13 | 13 | $loader = new lasso_autoloader(); |
| 14 | 14 | |
| 15 | 15 | $loader->register(); |
@@ -19,19 +19,19 @@ discard block |
||
| 19 | 19 | *----------------------------------------------------------------------------*/ |
| 20 | 20 | //require_once plugin_dir_path( __FILE__ ) . 'public/class-lasso.php'; |
| 21 | 21 | |
| 22 | -$loader->addNamespace('lasso', LASSO_DIR . 'includes' ); |
|
| 23 | -$loader->addNamespace('lasso_public_facing', LASSO_DIR . 'public/includes' ); |
|
| 24 | -$loader->addNamespace('lasso\internal_api', LASSO_DIR . 'internal-api' ); |
|
| 22 | +$loader->addNamespace('lasso', LASSO_DIR.'includes'); |
|
| 23 | +$loader->addNamespace('lasso_public_facing', LASSO_DIR.'public/includes'); |
|
| 24 | +$loader->addNamespace('lasso\internal_api', LASSO_DIR.'internal-api'); |
|
| 25 | 25 | new lasso\internal_api\end_points(); |
| 26 | 26 | |
| 27 | -register_activation_hook( __FILE__, array( 'lasso_public_facing\lasso', 'activate' ) ); |
|
| 28 | -register_deactivation_hook( __FILE__, array( 'lasso_public_facing\lasso', 'deactivate' ) ); |
|
| 27 | +register_activation_hook(__FILE__, array('lasso_public_facing\lasso', 'activate')); |
|
| 28 | +register_deactivation_hook(__FILE__, array('lasso_public_facing\lasso', 'deactivate')); |
|
| 29 | 29 | |
| 30 | -add_action( 'plugins_loaded', array( 'lasso_public_facing\lasso', 'get_instance' ) ); |
|
| 30 | +add_action('plugins_loaded', array('lasso_public_facing\lasso', 'get_instance')); |
|
| 31 | 31 | |
| 32 | 32 | //load tour |
| 33 | -add_action( 'init', function() { |
|
| 34 | - if (! is_admin() && is_user_logged_in() ) { |
|
| 33 | +add_action('init', function() { |
|
| 34 | + if (!is_admin() && is_user_logged_in()) { |
|
| 35 | 35 | new \lasso_public_facing\tour(); |
| 36 | 36 | } |
| 37 | 37 | }); |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | * Dashboard and Administrative Functionality |
| 42 | 42 | *----------------------------------------------------------------------------*/ |
| 43 | 43 | |
| 44 | -if ( is_admin() ) { |
|
| 45 | - $loader->addNamespace('lasso_admin', LASSO_DIR . 'admin/includes' ); |
|
| 46 | - add_action( 'plugins_loaded', array( 'lasso_admin\load_admin', 'get_instance' ) ); |
|
| 44 | +if (is_admin()) { |
|
| 45 | + $loader->addNamespace('lasso_admin', LASSO_DIR.'admin/includes'); |
|
| 46 | + add_action('plugins_loaded', array('lasso_admin\load_admin', 'get_instance')); |
|
| 47 | 47 | |
| 48 | 48 | } |
@@ -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, |
@@ -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,23 +54,23 @@ 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; |
|
| 72 | + $postid = isset($data['postid']) ? (int) $data['postid'] : false; |
|
| 73 | + $type = isset($data['gallery_type']) ? $data['gallery_type'] : false; |
|
| 74 | 74 | |
| 75 | 75 | // insert a new gallery |
| 76 | 76 | $args = array( |
@@ -79,23 +79,23 @@ discard block |
||
| 79 | 79 | 'post_type' => 'ai_galleries' |
| 80 | 80 | ); |
| 81 | 81 | |
| 82 | - $postid = wp_insert_post( apply_filters( 'lasso_insert_gallery_args', $args ) ); |
|
| 82 | + $postid = wp_insert_post(apply_filters('lasso_insert_gallery_args', $args)); |
|
| 83 | 83 | |
| 84 | 84 | // update gallery ids |
| 85 | - if ( $gallery_ids ) { |
|
| 85 | + if ($gallery_ids) { |
|
| 86 | 86 | |
| 87 | - update_post_meta( $postid, '_ase_gallery_images', $gallery_ids ); |
|
| 87 | + update_post_meta($postid, '_ase_gallery_images', $gallery_ids); |
|
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // update the gallery type |
| 92 | - if ( !empty( $type ) ) { |
|
| 92 | + if (!empty($type)) { |
|
| 93 | 93 | |
| 94 | - update_post_meta( $postid, 'aesop_gallery_type', $type ); |
|
| 94 | + update_post_meta($postid, 'aesop_gallery_type', $type); |
|
| 95 | 95 | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - do_action( 'lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID() ); |
|
| 98 | + do_action('lasso_gallery_published', $postid, $gallery_ids, get_current_user_ID()); |
|
| 99 | 99 | |
| 100 | 100 | return array( |
| 101 | 101 | 'message' => 'gallery-created' |
@@ -112,20 +112,20 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return array "message" key has the message. |
| 114 | 114 | */ |
| 115 | - public function update( $data ) { |
|
| 116 | - |
|
| 117 | - $options = isset( $data['fields'] ) ? $data['fields'] : false; |
|
| 118 | - $postid = !empty( $options ) ? (int) $options['id'] : false; |
|
| 119 | - $gallery_ids = isset( $data['gallery_ids'] ) ? $data['gallery_ids'] : false; |
|
| 120 | - if ( ! empty( $data ) && $data[ 'gallery_type' ] ) { |
|
| 121 | - $type = $data[ 'gallery_type' ]; |
|
| 122 | - }elseif ( ! empty( $options ) && $options[ 'galleryType' ] ) { |
|
| 123 | - $type = $options[ 'galleryType' ]; |
|
| 124 | - }else{ |
|
| 115 | + public function update($data) { |
|
| 116 | + |
|
| 117 | + $options = isset($data['fields']) ? $data['fields'] : false; |
|
| 118 | + $postid = !empty($options) ? (int) $options['id'] : false; |
|
| 119 | + $gallery_ids = isset($data['gallery_ids']) ? $data['gallery_ids'] : false; |
|
| 120 | + if (!empty($data) && $data['gallery_type']) { |
|
| 121 | + $type = $data['gallery_type']; |
|
| 122 | + }elseif (!empty($options) && $options['galleryType']) { |
|
| 123 | + $type = $options['galleryType']; |
|
| 124 | + } else { |
|
| 125 | 125 | $type = false; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - save_gallery::save_gallery_options( $postid, $gallery_ids, $options, $type ); |
|
| 128 | + save_gallery::save_gallery_options($postid, $gallery_ids, $options, $type); |
|
| 129 | 129 | |
| 130 | 130 | return array( |
| 131 | 131 | 'message' => 'gallery-updated' |
@@ -143,25 +143,25 @@ discard block |
||
| 143 | 143 | * |
| 144 | 144 | * @return bool |
| 145 | 145 | */ |
| 146 | - public function get_images( $data ) { |
|
| 146 | + public function get_images($data) { |
|
| 147 | 147 | |
| 148 | 148 | //check caps |
| 149 | - if ( !current_user_can( 'edit_posts' ) ) { |
|
| 149 | + if (!current_user_can('edit_posts')) { |
|
| 150 | 150 | return false; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // bail if no id specified like on new galleries |
| 154 | - if ( is_null( $data['post_id'] ) || empty( $data['post_id'] ) ) { |
|
| 154 | + if (is_null($data['post_id']) || empty($data['post_id'])) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - $postid = isset( $data['post_id'] ) ? $data['post_id'] : false; |
|
| 158 | + $postid = isset($data['post_id']) ? $data['post_id'] : false; |
|
| 159 | 159 | |
| 160 | 160 | // fetch image ids from cache |
| 161 | - $image_ids = get_post_meta( $postid, '_ase_gallery_images', true ); |
|
| 161 | + $image_ids = get_post_meta($postid, '_ase_gallery_images', true); |
|
| 162 | 162 | |
| 163 | 163 | // send ids to return images |
| 164 | - return self::get_the_images( $image_ids ); |
|
| 164 | + return self::get_the_images($image_ids); |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -171,32 +171,32 @@ discard block |
||
| 171 | 171 | * @param $image_ids array array of image ids |
| 172 | 172 | * @since 0.1 |
| 173 | 173 | */ |
| 174 | - private function get_the_images( $image_ids = '' ) { |
|
| 174 | + private function get_the_images($image_ids = '') { |
|
| 175 | 175 | |
| 176 | - if ( empty( $image_ids ) ) |
|
| 176 | + if (empty($image_ids)) |
|
| 177 | 177 | return; |
| 178 | 178 | |
| 179 | - $image_ids = array_map( 'intval', explode( ',', $image_ids ) ); |
|
| 179 | + $image_ids = array_map('intval', explode(',', $image_ids)); |
|
| 180 | 180 | |
| 181 | 181 | $out[] = '<ul id="ase-gallery-images">'; |
| 182 | 182 | |
| 183 | - if ( !empty( $image_ids ) ): |
|
| 183 | + if (!empty($image_ids)): |
|
| 184 | 184 | |
| 185 | - foreach ( $image_ids as $image_id ) { |
|
| 185 | + foreach ($image_ids as $image_id) { |
|
| 186 | 186 | |
| 187 | - $image = wp_get_attachment_image_src( $image_id, 'thumbnail', false ); |
|
| 187 | + $image = wp_get_attachment_image_src($image_id, 'thumbnail', false); |
|
| 188 | 188 | |
| 189 | - $out[] = sprintf( ' |
|
| 189 | + $out[] = sprintf(' |
|
| 190 | 190 | <li id="%1s" class="ase-gallery-image"> |
| 191 | 191 | <i class="dashicons dashicons-no-alt" title="%2s"></i> |
| 192 | 192 | <i class="dashicons dashicons-edit" title="%3s"></i> |
| 193 | 193 | <img src="%4s"> |
| 194 | 194 | </li> |
| 195 | 195 | ', |
| 196 | - absint( $image_id ), |
|
| 197 | - __( 'Delete From Gallery', 'lasso' ), |
|
| 198 | - __( 'Edit Image Caption', 'lasso' ), |
|
| 199 | - esc_url( $image[0] ) |
|
| 196 | + absint($image_id), |
|
| 197 | + __('Delete From Gallery', 'lasso'), |
|
| 198 | + __('Edit Image Caption', 'lasso'), |
|
| 199 | + esc_url($image[0]) |
|
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | 202 | } |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | $out[] = '</ul>'; |
| 207 | 207 | |
| 208 | - return array( 'html' => implode( '', $out ) ); |
|
| 208 | + return array('html' => implode('', $out)); |
|
| 209 | 209 | |
| 210 | 210 | } |
| 211 | 211 | |
@@ -217,13 +217,13 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @return array Array of keys to pull from $data per action and their sanitization callback |
| 219 | 219 | */ |
| 220 | - public static function params(){ |
|
| 221 | - $params[ 'process_gallery_swap' ] = array( |
|
| 220 | + public static function params() { |
|
| 221 | + $params['process_gallery_swap'] = array( |
|
| 222 | 222 | 'gallery_id' => 'absint', |
| 223 | 223 | |
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | - $params[ 'process_gallery_create' ] = array( |
|
| 226 | + $params['process_gallery_create'] = array( |
|
| 227 | 227 | 'postid' => 'absint', |
| 228 | 228 | 'content' => 'wp_kses_post', |
| 229 | 229 | 'galleryType' => array( |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | ); |
| 236 | 236 | |
| 237 | - $params[ 'process_gallery_update' ] = array( |
|
| 237 | + $params['process_gallery_update'] = array( |
|
| 238 | 238 | 'postid' => 'absint', |
| 239 | 239 | 'gallery_ids' => 'lasso_sanitize_data', |
| 240 | 240 | 'fields' => 'lasso_sanitize_data', |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | ) |
| 245 | 245 | ); |
| 246 | 246 | |
| 247 | - $params[ 'process_gallery_get_images' ] = array( |
|
| 247 | + $params['process_gallery_get_images'] = array( |
|
| 248 | 248 | 'post_id' => 'absint' |
| 249 | 249 | ); |
| 250 | 250 | |
@@ -260,19 +260,19 @@ discard block |
||
| 260 | 260 | * @return array Array of additional functions to use to authorize action. |
| 261 | 261 | */ |
| 262 | 262 | public static function auth_callbacks() { |
| 263 | - $params[ 'process_gallery_swap' ] = array( |
|
| 263 | + $params['process_gallery_swap'] = array( |
|
| 264 | 264 | 'lasso_user_can' |
| 265 | 265 | ); |
| 266 | 266 | |
| 267 | - $params[ 'process_gallery_create' ] = array( |
|
| 267 | + $params['process_gallery_create'] = array( |
|
| 268 | 268 | 'is_user_logged_in' |
| 269 | 269 | ); |
| 270 | 270 | |
| 271 | - $params[ 'process_gallery_update' ] = array( |
|
| 271 | + $params['process_gallery_update'] = array( |
|
| 272 | 272 | 'lasso_user_can' |
| 273 | 273 | ); |
| 274 | 274 | |
| 275 | - $params[ 'process_gallery_get_images' ] = array(); |
|
| 275 | + $params['process_gallery_get_images'] = array(); |
|
| 276 | 276 | |
| 277 | 277 | return $params; |
| 278 | 278 | |
@@ -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 | |
@@ -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 | |