@@ -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 | |
@@ -28,14 +28,14 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return bool Always returns true. |
| 30 | 30 | */ |
| 31 | - public function upload( $data ) { |
|
| 31 | + public function upload($data) { |
|
| 32 | 32 | |
| 33 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
| 34 | - $image_id = isset( $data['image_id'] ) ? absint( $data['image_id'] ) : false; |
|
| 33 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
| 34 | + $image_id = isset($data['image_id']) ? absint($data['image_id']) : false; |
|
| 35 | 35 | |
| 36 | - set_post_thumbnail( $postid, $image_id ); |
|
| 36 | + set_post_thumbnail($postid, $image_id); |
|
| 37 | 37 | |
| 38 | - do_action( 'lasso_featured_image_set', $postid, $image_id, get_current_user_ID() ); |
|
| 38 | + do_action('lasso_featured_image_set', $postid, $image_id, get_current_user_ID()); |
|
| 39 | 39 | |
| 40 | 40 | return true; |
| 41 | 41 | |
@@ -50,13 +50,13 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return bool Always returns true. |
| 52 | 52 | */ |
| 53 | - public function delete( $data ) { |
|
| 53 | + public function delete($data) { |
|
| 54 | 54 | |
| 55 | - $postid = isset( $data['postid'] ) ? $data['postid'] : false; |
|
| 55 | + $postid = isset($data['postid']) ? $data['postid'] : false; |
|
| 56 | 56 | |
| 57 | - delete_post_thumbnail( $postid ); |
|
| 57 | + delete_post_thumbnail($postid); |
|
| 58 | 58 | |
| 59 | - do_action( 'lasso_featured_image_deleted', $postid, get_current_user_ID() ); |
|
| 59 | + do_action('lasso_featured_image_deleted', $postid, get_current_user_ID()); |
|
| 60 | 60 | |
| 61 | 61 | return true; |
| 62 | 62 | |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return array Array of keys to pull from $data per action and their sanitization callback |
| 71 | 71 | */ |
| 72 | - public static function params(){ |
|
| 73 | - $params[ 'process_upload_image_upload' ] = array( |
|
| 72 | + public static function params() { |
|
| 73 | + $params['process_upload_image_upload'] = array( |
|
| 74 | 74 | 'postid' => 'absint', |
| 75 | 75 | 'image_id' => 'absint' |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $params[ 'process_upload_image_delete' ] = array( |
|
| 78 | + $params['process_upload_image_delete'] = array( |
|
| 79 | 79 | 'postid' => 'absint', |
| 80 | 80 | ); |
| 81 | 81 | |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | * @since 1.1.10 |
| 29 | 29 | * |
| 30 | 30 | */ |
| 31 | - public static function do_sanitize( $input, $params = array() ) { |
|
| 31 | + public static function do_sanitize($input, $params = array()) { |
|
| 32 | 32 | |
| 33 | - $input = stripslashes_deep( $input ); |
|
| 33 | + $input = stripslashes_deep($input); |
|
| 34 | 34 | |
| 35 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 35 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
| 36 | 36 | return $input; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -43,45 +43,45 @@ discard block |
||
| 43 | 43 | 'type' => null // %s %d %f etc |
| 44 | 44 | ); |
| 45 | 45 | |
| 46 | - if ( !is_array( $params ) ) { |
|
| 47 | - $defaults[ 'type' ] = $params; |
|
| 46 | + if (!is_array($params)) { |
|
| 47 | + $defaults['type'] = $params; |
|
| 48 | 48 | |
| 49 | 49 | $params = $defaults; |
| 50 | 50 | } |
| 51 | 51 | else { |
| 52 | - $params = array_merge( $defaults, (array) $params ); |
|
| 52 | + $params = array_merge($defaults, (array) $params); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( is_object( $input ) ) { |
|
| 56 | - $input = get_object_vars( $input ); |
|
| 55 | + if (is_object($input)) { |
|
| 56 | + $input = get_object_vars($input); |
|
| 57 | 57 | |
| 58 | 58 | $n_params = $params; |
| 59 | - $n_params[ 'nested' ] = true; |
|
| 59 | + $n_params['nested'] = true; |
|
| 60 | 60 | |
| 61 | - foreach ( $input as $key => $val ) { |
|
| 62 | - $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
|
| 61 | + foreach ($input as $key => $val) { |
|
| 62 | + $output[self::do_sanitize($key)] = self::do_sanitize($val, $n_params); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | $output = (object) $output; |
| 66 | 66 | } |
| 67 | - elseif ( is_array( $input ) ) { |
|
| 67 | + elseif (is_array($input)) { |
|
| 68 | 68 | $n_params = $params; |
| 69 | - $n_params[ 'nested' ] = true; |
|
| 69 | + $n_params['nested'] = true; |
|
| 70 | 70 | |
| 71 | - foreach ( $input as $key => $val ) { |
|
| 72 | - $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
|
| 71 | + foreach ($input as $key => $val) { |
|
| 72 | + $output[self::do_sanitize($key)] = self::do_sanitize($val, $n_params); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | - elseif ( !empty( $params[ 'type' ] ) && false !== strpos( $params[ 'type' ], '%' ) ) { |
|
| 75 | + elseif (!empty($params['type']) && false !== strpos($params['type'], '%')) { |
|
| 76 | 76 | /** |
| 77 | 77 | * @var $wpdb wpdb |
| 78 | 78 | */ |
| 79 | 79 | global $wpdb; |
| 80 | 80 | |
| 81 | - $output = $wpdb->prepare( $params[ 'type' ], $output ); |
|
| 81 | + $output = $wpdb->prepare($params['type'], $output); |
|
| 82 | 82 | } |
| 83 | 83 | else { |
| 84 | - $output = wp_slash( $input ); |
|
| 84 | + $output = wp_slash($input); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | return $output; |
@@ -99,38 +99,38 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @see like_escape |
| 101 | 101 | */ |
| 102 | - public static function sanitize_like( $input ) { |
|
| 102 | + public static function sanitize_like($input) { |
|
| 103 | 103 | |
| 104 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 104 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
| 105 | 105 | return $input; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $output = array(); |
| 109 | 109 | |
| 110 | - if ( is_object( $input ) ) { |
|
| 111 | - $input = get_object_vars( $input ); |
|
| 110 | + if (is_object($input)) { |
|
| 111 | + $input = get_object_vars($input); |
|
| 112 | 112 | |
| 113 | - foreach ( $input as $key => $val ) { |
|
| 114 | - $output[ $key ] = self::sanitize_like( $val ); |
|
| 113 | + foreach ($input as $key => $val) { |
|
| 114 | + $output[$key] = self::sanitize_like($val); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $output = (object) $output; |
| 118 | 118 | } |
| 119 | - elseif ( is_array( $input ) ) { |
|
| 120 | - foreach ( $input as $key => $val ) { |
|
| 121 | - $output[ $key ] = self::sanitize_like( $val ); |
|
| 119 | + elseif (is_array($input)) { |
|
| 120 | + foreach ($input as $key => $val) { |
|
| 121 | + $output[$key] = self::sanitize_like($val); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | else { |
| 125 | 125 | global $wpdb; |
| 126 | 126 | |
| 127 | 127 | //backwords-compat check for pre WP4.0 |
| 128 | - if ( method_exists( 'wpdb', 'esc_like' ) ) { |
|
| 129 | - $output = $wpdb->esc_like( self::do_sanitize( $input ) ); |
|
| 128 | + if (method_exists('wpdb', 'esc_like')) { |
|
| 129 | + $output = $wpdb->esc_like(self::do_sanitize($input)); |
|
| 130 | 130 | } |
| 131 | 131 | else { |
| 132 | 132 | // like_escape is deprecated in WordPress 4.0 |
| 133 | - $output = like_escape( self::do_sanitize( $input ) ); |
|
| 133 | + $output = like_escape(self::do_sanitize($input)); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -150,33 +150,33 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @see wp_unslash |
| 152 | 152 | */ |
| 153 | - public static function unslash( $input ) { |
|
| 153 | + public static function unslash($input) { |
|
| 154 | 154 | |
| 155 | - if ( '' === $input || is_int( $input ) || is_float( $input ) || empty( $input ) ) { |
|
| 155 | + if ('' === $input || is_int($input) || is_float($input) || empty($input)) { |
|
| 156 | 156 | return $input; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $output = array(); |
| 160 | 160 | |
| 161 | - if ( empty( $input ) ) { |
|
| 161 | + if (empty($input)) { |
|
| 162 | 162 | $output = $input; |
| 163 | 163 | } |
| 164 | - elseif ( is_object( $input ) ) { |
|
| 165 | - $input = get_object_vars( $input ); |
|
| 164 | + elseif (is_object($input)) { |
|
| 165 | + $input = get_object_vars($input); |
|
| 166 | 166 | |
| 167 | - foreach ( $input as $key => $val ) { |
|
| 168 | - $output[ $key ] = self::unslash( $val ); |
|
| 167 | + foreach ($input as $key => $val) { |
|
| 168 | + $output[$key] = self::unslash($val); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $output = (object) $output; |
| 172 | 172 | } |
| 173 | - elseif ( is_array( $input ) ) { |
|
| 174 | - foreach ( $input as $key => $val ) { |
|
| 175 | - $output[ $key ] = self::unslash( $val ); |
|
| 173 | + elseif (is_array($input)) { |
|
| 174 | + foreach ($input as $key => $val) { |
|
| 175 | + $output[$key] = self::unslash($val); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | else { |
| 179 | - $output = wp_unslash( $input ); |
|
| 179 | + $output = wp_unslash($input); |
|
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | $defaults[ 'type' ] = $params; |
| 48 | 48 | |
| 49 | 49 | $params = $defaults; |
| 50 | - } |
|
| 51 | - else { |
|
| 50 | + } else { |
|
| 52 | 51 | $params = array_merge( $defaults, (array) $params ); |
| 53 | 52 | } |
| 54 | 53 | |
@@ -63,24 +62,21 @@ discard block |
||
| 63 | 62 | } |
| 64 | 63 | |
| 65 | 64 | $output = (object) $output; |
| 66 | - } |
|
| 67 | - elseif ( is_array( $input ) ) { |
|
| 65 | + } elseif ( is_array( $input ) ) { |
|
| 68 | 66 | $n_params = $params; |
| 69 | 67 | $n_params[ 'nested' ] = true; |
| 70 | 68 | |
| 71 | 69 | foreach ( $input as $key => $val ) { |
| 72 | 70 | $output[ self::do_sanitize( $key ) ] = self::do_sanitize( $val, $n_params ); |
| 73 | 71 | } |
| 74 | - } |
|
| 75 | - elseif ( !empty( $params[ 'type' ] ) && false !== strpos( $params[ 'type' ], '%' ) ) { |
|
| 72 | + } elseif ( !empty( $params[ 'type' ] ) && false !== strpos( $params[ 'type' ], '%' ) ) { |
|
| 76 | 73 | /** |
| 77 | 74 | * @var $wpdb wpdb |
| 78 | 75 | */ |
| 79 | 76 | global $wpdb; |
| 80 | 77 | |
| 81 | 78 | $output = $wpdb->prepare( $params[ 'type' ], $output ); |
| 82 | - } |
|
| 83 | - else { |
|
| 79 | + } else { |
|
| 84 | 80 | $output = wp_slash( $input ); |
| 85 | 81 | } |
| 86 | 82 | |
@@ -115,20 +111,17 @@ discard block |
||
| 115 | 111 | } |
| 116 | 112 | |
| 117 | 113 | $output = (object) $output; |
| 118 | - } |
|
| 119 | - elseif ( is_array( $input ) ) { |
|
| 114 | + } elseif ( is_array( $input ) ) { |
|
| 120 | 115 | foreach ( $input as $key => $val ) { |
| 121 | 116 | $output[ $key ] = self::sanitize_like( $val ); |
| 122 | 117 | } |
| 123 | - } |
|
| 124 | - else { |
|
| 118 | + } else { |
|
| 125 | 119 | global $wpdb; |
| 126 | 120 | |
| 127 | 121 | //backwords-compat check for pre WP4.0 |
| 128 | 122 | if ( method_exists( 'wpdb', 'esc_like' ) ) { |
| 129 | 123 | $output = $wpdb->esc_like( self::do_sanitize( $input ) ); |
| 130 | - } |
|
| 131 | - else { |
|
| 124 | + } else { |
|
| 132 | 125 | // like_escape is deprecated in WordPress 4.0 |
| 133 | 126 | $output = like_escape( self::do_sanitize( $input ) ); |
| 134 | 127 | } |
@@ -160,8 +153,7 @@ discard block |
||
| 160 | 153 | |
| 161 | 154 | if ( empty( $input ) ) { |
| 162 | 155 | $output = $input; |
| 163 | - } |
|
| 164 | - elseif ( is_object( $input ) ) { |
|
| 156 | + } elseif ( is_object( $input ) ) { |
|
| 165 | 157 | $input = get_object_vars( $input ); |
| 166 | 158 | |
| 167 | 159 | foreach ( $input as $key => $val ) { |
@@ -169,13 +161,11 @@ discard block |
||
| 169 | 161 | } |
| 170 | 162 | |
| 171 | 163 | $output = (object) $output; |
| 172 | - } |
|
| 173 | - elseif ( is_array( $input ) ) { |
|
| 164 | + } elseif ( is_array( $input ) ) { |
|
| 174 | 165 | foreach ( $input as $key => $val ) { |
| 175 | 166 | $output[ $key ] = self::unslash( $val ); |
| 176 | 167 | } |
| 177 | - } |
|
| 178 | - else { |
|
| 168 | + } else { |
|
| 179 | 169 | $output = wp_unslash( $input ); |
| 180 | 170 | |
| 181 | 171 | } |
@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | * Adds our API endpoint and hooks it in at template_redirect |
| 19 | 19 | */ |
| 20 | 20 | public function __construct() { |
| 21 | - add_action( 'init', array( $this, 'add_endpoints' ) ); |
|
| 22 | - add_action( 'template_redirect', array( route::init(), 'do_api' ) ); |
|
| 21 | + add_action('init', array($this, 'add_endpoints')); |
|
| 22 | + add_action('template_redirect', array(route::init(), 'do_api')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function add_endpoints() { |
| 31 | 31 | //add "action" as a rewrite tag |
| 32 | - add_rewrite_tag( '%action%', '^[a-z0-9_\-]+$' ); |
|
| 32 | + add_rewrite_tag('%action%', '^[a-z0-9_\-]+$'); |
|
| 33 | 33 | |
| 34 | 34 | //add the endpoint |
| 35 | - add_rewrite_rule( 'lasso-internal-api/^[a-z0-9_\-]+$/?', 'index.php?action=$matches[1]', 'top' ); |
|
| 35 | + add_rewrite_rule('lasso-internal-api/^[a-z0-9_\-]+$/?', 'index.php?action=$matches[1]', 'top'); |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | } |