@@ -195,7 +195,7 @@ |
||
| 195 | 195 | * |
| 196 | 196 | * @since 1.6 |
| 197 | 197 | * |
| 198 | - * @param int $new_view_id The ID of the newly created View |
|
| 198 | + * @param int $new_id The ID of the newly created View |
|
| 199 | 199 | * @param WP_Post $post The View that was just cloned |
| 200 | 200 | * |
| 201 | 201 | * @return void |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | function __construct() { |
| 16 | 16 | |
| 17 | 17 | // Only run on Admin |
| 18 | - if ( !is_admin() ) { |
|
| 18 | + if (!is_admin()) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // If the Duplicate Post plugin is active, don't run. |
| 23 | - if( defined('DUPLICATE_POST_CURRENT_VERSION') ) { |
|
| 23 | + if (defined('DUPLICATE_POST_CURRENT_VERSION')) { |
|
| 24 | 24 | return; |
| 25 | 25 | } |
| 26 | 26 | |
@@ -33,18 +33,18 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | 35 | private function add_hooks() { |
| 36 | - add_filter( 'post_row_actions', array( $this, 'make_duplicate_link_row' ), 10, 2 ); |
|
| 36 | + add_filter('post_row_actions', array($this, 'make_duplicate_link_row'), 10, 2); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Connect actions to functions |
| 40 | 40 | */ |
| 41 | - add_action( 'admin_action_duplicate_view', array( $this, 'save_as_new_view' ) ); |
|
| 42 | - add_action( 'admin_action_duplicate_view_as_draft', array( $this, 'save_as_new_view_draft' ) ); |
|
| 41 | + add_action('admin_action_duplicate_view', array($this, 'save_as_new_view')); |
|
| 42 | + add_action('admin_action_duplicate_view_as_draft', array($this, 'save_as_new_view_draft')); |
|
| 43 | 43 | |
| 44 | 44 | // Using our action hooks to copy meta fields |
| 45 | - add_action( 'gv_duplicate_view', array( $this, 'copy_view_meta_info' ), 10, 2 ); |
|
| 45 | + add_action('gv_duplicate_view', array($this, 'copy_view_meta_info'), 10, 2); |
|
| 46 | 46 | |
| 47 | - add_filter( 'gravityview_connected_form_links', array( $this, 'connected_form_links' ), 10, 2 ); |
|
| 47 | + add_filter('gravityview_connected_form_links', array($this, 'connected_form_links'), 10, 2); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return array If it's the All Views page, return unedited. Otherwise, add a link to create cloned draft of View |
| 57 | 57 | */ |
| 58 | - function connected_form_links( $links = array(), $form = array() ) { |
|
| 58 | + function connected_form_links($links = array(), $form = array()) { |
|
| 59 | 59 | /** @global WP_Post $post */ |
| 60 | 60 | global $post; |
| 61 | 61 | |
| 62 | 62 | // We only want to add Clone links to the Edit View metabox |
| 63 | - if( !$this->is_all_views_page() ) { |
|
| 63 | + if (!$this->is_all_views_page()) { |
|
| 64 | 64 | |
| 65 | - if( $duplicate_links = $this->make_duplicate_link_row( array(), $post ) ) { |
|
| 66 | - $links[] = '<span>' . $duplicate_links['edit_as_new_draft'] . '</span>'; |
|
| 65 | + if ($duplicate_links = $this->make_duplicate_link_row(array(), $post)) { |
|
| 66 | + $links[] = '<span>'.$duplicate_links['edit_as_new_draft'].'</span>'; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | } |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @since 1.6 |
| 90 | 90 | */ |
| 91 | - private function current_user_can_copy( $post ) { |
|
| 91 | + private function current_user_can_copy($post) { |
|
| 92 | 92 | |
| 93 | - $id = is_object( $post ) ? $post->ID : $post; |
|
| 93 | + $id = is_object($post) ? $post->ID : $post; |
|
| 94 | 94 | |
| 95 | 95 | // Can't edit this current View |
| 96 | - return GVCommon::has_cap( 'copy_gravityviews', $id ); |
|
| 96 | + return GVCommon::has_cap('copy_gravityviews', $id); |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | |
@@ -104,10 +104,10 @@ discard block |
||
| 104 | 104 | * @param string $status The post status |
| 105 | 105 | * @since 1.6 |
| 106 | 106 | */ |
| 107 | - private function create_duplicate( $post, $status = '' ) { |
|
| 107 | + private function create_duplicate($post, $status = '') { |
|
| 108 | 108 | |
| 109 | 109 | // We only want to clone Views |
| 110 | - if ( $post->post_type !== 'gravityview' ) { |
|
| 110 | + if ($post->post_type !== 'gravityview') { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @param string|null If string, the status to set for the new View. If empty, use existing View status. |
| 120 | 120 | * @param WP_Post $post View being cloned |
| 121 | 121 | */ |
| 122 | - $new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post ); |
|
| 122 | + $new_view_status = apply_filters('gravityview/duplicate-view/status', $status, $post); |
|
| 123 | 123 | |
| 124 | 124 | $new_view = array( |
| 125 | 125 | 'menu_order' => $post->menu_order, |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | 'post_mime_type' => $post->post_mime_type, |
| 132 | 132 | 'post_parent' => $post->post_parent, |
| 133 | 133 | 'post_password' => $post->post_password, |
| 134 | - 'post_status' => ( empty( $new_view_status ) ) ? $post->post_status : $new_view_status, |
|
| 134 | + 'post_status' => (empty($new_view_status)) ? $post->post_status : $new_view_status, |
|
| 135 | 135 | 'post_title' => $post->post_title, |
| 136 | 136 | 'post_type' => $post->post_type, |
| 137 | 137 | ); |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | * @param boolean $copy_date Whether the copy the date from the existing View. Default: `false` |
| 143 | 143 | * @param WP_Post $post View being cloned |
| 144 | 144 | */ |
| 145 | - $copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post ); |
|
| 145 | + $copy_date = apply_filters('gravityview/duplicate-view/copy-date', false, $post); |
|
| 146 | 146 | |
| 147 | - if ( $copy_date ) { |
|
| 147 | + if ($copy_date) { |
|
| 148 | 148 | $new_view['post_date'] = $new_post_date = $post->post_date; |
| 149 | - $new_view['post_date_gmt'] = get_gmt_from_date( $new_post_date ); |
|
| 149 | + $new_view['post_date_gmt'] = get_gmt_from_date($new_post_date); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -155,15 +155,15 @@ discard block |
||
| 155 | 155 | * @param array $new_view Array of settings to be passed to wp_insert_post() |
| 156 | 156 | * @param WP_Post $post View being cloned |
| 157 | 157 | */ |
| 158 | - $new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post ); |
|
| 158 | + $new_view = apply_filters('gravityview/duplicate-view/new-view', $new_view, $post); |
|
| 159 | 159 | |
| 160 | 160 | // Magic happens here. |
| 161 | - $new_view_id = wp_insert_post( $new_view ); |
|
| 161 | + $new_view_id = wp_insert_post($new_view); |
|
| 162 | 162 | |
| 163 | 163 | // If the copy is published or scheduled, we have to set a proper slug. |
| 164 | - if ( $new_view_status == 'publish' || $new_view_status == 'future' ) { |
|
| 164 | + if ($new_view_status == 'publish' || $new_view_status == 'future') { |
|
| 165 | 165 | |
| 166 | - $view_name = wp_unique_post_slug( $post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent ); |
|
| 166 | + $view_name = wp_unique_post_slug($post->post_name, $new_view_id, $new_view_status, $post->post_type, $post->post_parent); |
|
| 167 | 167 | |
| 168 | 168 | $new_view_name_array = array( |
| 169 | 169 | 'ID' => $new_view_id, |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | 173 | // Update the post into the database |
| 174 | - wp_update_post( $new_view_name_array ); |
|
| 174 | + wp_update_post($new_view_name_array); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -181,11 +181,11 @@ discard block |
||
| 181 | 181 | * @param int $new_view_id The ID of the newly created View |
| 182 | 182 | * @param WP_Post The View that was just cloned |
| 183 | 183 | */ |
| 184 | - do_action( 'gv_duplicate_view', $new_view_id, $post ); |
|
| 184 | + do_action('gv_duplicate_view', $new_view_id, $post); |
|
| 185 | 185 | |
| 186 | - delete_post_meta( $new_view_id, '_dp_original' ); |
|
| 186 | + delete_post_meta($new_view_id, '_dp_original'); |
|
| 187 | 187 | |
| 188 | - add_post_meta( $new_view_id, '_dp_original', $post->ID, false ); |
|
| 188 | + add_post_meta($new_view_id, '_dp_original', $post->ID, false); |
|
| 189 | 189 | |
| 190 | 190 | return $new_view_id; |
| 191 | 191 | } |
@@ -200,23 +200,23 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return void |
| 202 | 202 | */ |
| 203 | - public function copy_view_meta_info( $new_id, $post ) { |
|
| 203 | + public function copy_view_meta_info($new_id, $post) { |
|
| 204 | 204 | |
| 205 | - $post_meta_keys = get_post_custom_keys( $post->ID ); |
|
| 205 | + $post_meta_keys = get_post_custom_keys($post->ID); |
|
| 206 | 206 | |
| 207 | - if ( empty( $post_meta_keys ) ) { |
|
| 207 | + if (empty($post_meta_keys)) { |
|
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - foreach ( $post_meta_keys as $meta_key ) { |
|
| 211 | + foreach ($post_meta_keys as $meta_key) { |
|
| 212 | 212 | |
| 213 | - $meta_values = get_post_custom_values( $meta_key, $post->ID ); |
|
| 213 | + $meta_values = get_post_custom_values($meta_key, $post->ID); |
|
| 214 | 214 | |
| 215 | - foreach ( $meta_values as $meta_value ) { |
|
| 215 | + foreach ($meta_values as $meta_value) { |
|
| 216 | 216 | |
| 217 | - $meta_value = maybe_unserialize( $meta_value ); |
|
| 217 | + $meta_value = maybe_unserialize($meta_value); |
|
| 218 | 218 | |
| 219 | - add_post_meta( $new_id, $meta_key, $meta_value ); |
|
| 219 | + add_post_meta($new_id, $meta_key, $meta_value); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -228,22 +228,22 @@ discard block |
||
| 228 | 228 | * @param array $actions Row action links. Defaults are 'Edit', 'Quick Edit', 'Restore, 'Trash', 'Delete Permanently', 'Preview', and 'View' |
| 229 | 229 | * @param WP_Post $post |
| 230 | 230 | */ |
| 231 | - public function make_duplicate_link_row( $actions, $post ) { |
|
| 231 | + public function make_duplicate_link_row($actions, $post) { |
|
| 232 | 232 | |
| 233 | 233 | // Only process on GravityView Views |
| 234 | - if ( get_post_type( $post ) === 'gravityview' && $this->current_user_can_copy( $post ) ) { |
|
| 234 | + if (get_post_type($post) === 'gravityview' && $this->current_user_can_copy($post)) { |
|
| 235 | 235 | |
| 236 | - $clone_link = $this->get_clone_view_link( $post->ID, 'display', false ); |
|
| 237 | - $clone_text = __( 'Clone', 'gravityview' ); |
|
| 238 | - $clone_title = __( 'Clone this View', 'gravityview' ); |
|
| 236 | + $clone_link = $this->get_clone_view_link($post->ID, 'display', false); |
|
| 237 | + $clone_text = __('Clone', 'gravityview'); |
|
| 238 | + $clone_title = __('Clone this View', 'gravityview'); |
|
| 239 | 239 | |
| 240 | - $actions['clone'] = gravityview_get_link( $clone_link, $clone_text, 'title='.$clone_title ); |
|
| 240 | + $actions['clone'] = gravityview_get_link($clone_link, $clone_text, 'title='.$clone_title); |
|
| 241 | 241 | |
| 242 | - $clone_draft_link = $this->get_clone_view_link( $post->ID ); |
|
| 243 | - $clone_draft_text = $this->is_all_views_page() ? __( 'New Draft', 'gravityview' ) : __( 'Clone View', 'gravityview' ); |
|
| 244 | - $clone_draft_title = __( 'Copy as a new draft View', 'gravityview' ); |
|
| 242 | + $clone_draft_link = $this->get_clone_view_link($post->ID); |
|
| 243 | + $clone_draft_text = $this->is_all_views_page() ? __('New Draft', 'gravityview') : __('Clone View', 'gravityview'); |
|
| 244 | + $clone_draft_title = __('Copy as a new draft View', 'gravityview'); |
|
| 245 | 245 | |
| 246 | - $actions['edit_as_new_draft'] = gravityview_get_link( $clone_draft_link, esc_html( $clone_draft_text ), 'title='.$clone_draft_title ); |
|
| 246 | + $actions['edit_as_new_draft'] = gravityview_get_link($clone_draft_link, esc_html($clone_draft_text), 'title='.$clone_draft_title); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | return $actions; |
@@ -259,31 +259,31 @@ discard block |
||
| 259 | 259 | * @param string $draft Optional, default to true |
| 260 | 260 | * @return string |
| 261 | 261 | */ |
| 262 | - private function get_clone_view_link( $id = 0, $context = 'display', $draft = true ) { |
|
| 262 | + private function get_clone_view_link($id = 0, $context = 'display', $draft = true) { |
|
| 263 | 263 | |
| 264 | 264 | // Make sure they have permission |
| 265 | - if ( false === $this->current_user_can_copy( $id ) ) { |
|
| 265 | + if (false === $this->current_user_can_copy($id)) { |
|
| 266 | 266 | return ''; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // Verify the View exists |
| 270 | - if ( !$view = get_post( $id ) ) { |
|
| 270 | + if (!$view = get_post($id)) { |
|
| 271 | 271 | return ''; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $action_name = $draft ? "duplicate_view_as_draft" : "duplicate_view"; |
| 275 | 275 | |
| 276 | - $action = '?action=' . $action_name . '&post=' . $view->ID; |
|
| 276 | + $action = '?action='.$action_name.'&post='.$view->ID; |
|
| 277 | 277 | |
| 278 | - if ( 'display' == $context ) { |
|
| 279 | - $action = esc_html( $action ); |
|
| 278 | + if ('display' == $context) { |
|
| 279 | + $action = esc_html($action); |
|
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - $post_type_object = get_post_type_object( $view->post_type ); |
|
| 282 | + $post_type_object = get_post_type_object($view->post_type); |
|
| 283 | 283 | |
| 284 | 284 | /** If there's no gravityview post type for some reason, abort! */ |
| 285 | - if ( !$post_type_object ) { |
|
| 286 | - do_action( 'gravityview_log_error', __METHOD__ . ' No gravityview post type exists when trying to clone the View.', $view ); |
|
| 285 | + if (!$post_type_object) { |
|
| 286 | + do_action('gravityview_log_error', __METHOD__.' No gravityview post type exists when trying to clone the View.', $view); |
|
| 287 | 287 | return ''; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @param int $view_id View ID |
| 295 | 295 | * @param string $context How to display the link. If "display", the URL is run through esc_html(). Default: `display` |
| 296 | 296 | */ |
| 297 | - $clone_view_link = apply_filters( 'gravityview/duplicate-view/get_clone_view_link', admin_url( "admin.php". $action ), $view->ID, $context ); |
|
| 297 | + $clone_view_link = apply_filters('gravityview/duplicate-view/get_clone_view_link', admin_url("admin.php".$action), $view->ID, $context); |
|
| 298 | 298 | |
| 299 | 299 | return $clone_view_link; |
| 300 | 300 | } |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | * @return void |
| 309 | 309 | */ |
| 310 | 310 | public function save_as_new_view_draft() { |
| 311 | - $this->save_as_new_view( 'draft' ); |
|
| 311 | + $this->save_as_new_view('draft'); |
|
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | /** |
@@ -319,38 +319,38 @@ discard block |
||
| 319 | 319 | * @param string $status The status to set for the new View |
| 320 | 320 | * @return void |
| 321 | 321 | */ |
| 322 | - public function save_as_new_view( $status = '' ) { |
|
| 322 | + public function save_as_new_view($status = '') { |
|
| 323 | 323 | |
| 324 | - if ( ! ( isset( $_GET['post'] ) || isset( $_POST['post'] ) ) ) { |
|
| 325 | - wp_die( __( 'No post to duplicate has been supplied!', 'gravityview' ) ); |
|
| 324 | + if (!(isset($_GET['post']) || isset($_POST['post']))) { |
|
| 325 | + wp_die(__('No post to duplicate has been supplied!', 'gravityview')); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // Get the original post |
| 329 | - $id = ( isset( $_GET['post'] ) ? $_GET['post'] : $_POST['post'] ); |
|
| 329 | + $id = (isset($_GET['post']) ? $_GET['post'] : $_POST['post']); |
|
| 330 | 330 | |
| 331 | - if( ! $this->current_user_can_copy( $id ) ) { |
|
| 332 | - wp_die( __( 'You don\'t have permission to copy this View.', 'gravityview' ) ); |
|
| 331 | + if (!$this->current_user_can_copy($id)) { |
|
| 332 | + wp_die(__('You don\'t have permission to copy this View.', 'gravityview')); |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - $post = get_post( $id ); |
|
| 335 | + $post = get_post($id); |
|
| 336 | 336 | |
| 337 | 337 | // Copy the post and insert it |
| 338 | - if ( isset( $post ) && $post != NULL ) { |
|
| 338 | + if (isset($post) && $post != NULL) { |
|
| 339 | 339 | |
| 340 | - $new_id = $this->create_duplicate( $post, $status ); |
|
| 340 | + $new_id = $this->create_duplicate($post, $status); |
|
| 341 | 341 | |
| 342 | - if ( $status == '' ) { |
|
| 342 | + if ($status == '') { |
|
| 343 | 343 | // Redirect to the post list screen |
| 344 | - wp_redirect( admin_url( 'edit.php?post_type=' . $post->post_type ) ); |
|
| 344 | + wp_redirect(admin_url('edit.php?post_type='.$post->post_type)); |
|
| 345 | 345 | } else { |
| 346 | 346 | // Redirect to the edit screen for the new draft post |
| 347 | - wp_redirect( admin_url( 'post.php?action=edit&post=' . $new_id ) ); |
|
| 347 | + wp_redirect(admin_url('post.php?action=edit&post='.$new_id)); |
|
| 348 | 348 | } |
| 349 | 349 | exit; |
| 350 | 350 | |
| 351 | 351 | } else { |
| 352 | 352 | |
| 353 | - wp_die( sprintf( esc_attr__( 'Copy creation failed, could not find original View with ID #%d', 'gravityview' ), $id ) ); |
|
| 353 | + wp_die(sprintf(esc_attr__('Copy creation failed, could not find original View with ID #%d', 'gravityview'), $id)); |
|
| 354 | 354 | |
| 355 | 355 | } |
| 356 | 356 | } |
@@ -116,7 +116,7 @@ |
||
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @since 1.12 |
| 119 | - * @return bool |
|
| 119 | + * @return boolean|null |
|
| 120 | 120 | */ |
| 121 | 121 | private function add_fallback_shortcode() { |
| 122 | 122 | |
@@ -204,7 +204,7 @@ |
||
| 204 | 204 | self::$notices['wp_version'] = array( |
| 205 | 205 | 'class' => 'error', |
| 206 | 206 | 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
| 207 | - 'cap' => 'update_core', |
|
| 207 | + 'cap' => 'update_core', |
|
| 208 | 208 | 'dismiss' => 'wp_version', |
| 209 | 209 | ); |
| 210 | 210 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | function add_hooks() { |
| 59 | 59 | |
| 60 | - add_filter( 'gravityview/admin/notices', array( $this, 'insert_admin_notices' ) ); |
|
| 60 | + add_filter('gravityview/admin/notices', array($this, 'insert_admin_notices')); |
|
| 61 | 61 | |
| 62 | 62 | $this->add_fallback_shortcode(); |
| 63 | 63 | } |
@@ -68,15 +68,15 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return array |
| 70 | 70 | */ |
| 71 | - function insert_admin_notices( $notices = array() ) { |
|
| 72 | - return array_merge( $notices, self::$notices ); |
|
| 71 | + function insert_admin_notices($notices = array()) { |
|
| 72 | + return array_merge($notices, self::$notices); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * @return GravityView_Compatibility |
| 77 | 77 | */ |
| 78 | 78 | public static function getInstance() { |
| 79 | - if( self::$instance ) { |
|
| 79 | + if (self::$instance) { |
|
| 80 | 80 | return self::$instance; |
| 81 | 81 | } |
| 82 | 82 | return new self; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @return bool |
| 88 | 88 | */ |
| 89 | 89 | public static function is_valid() { |
| 90 | - return ( self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php() ); |
|
| 90 | + return (self::is_valid_gravity_forms() && self::is_valid_wordpress() && self::is_valid_php()); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | // If Gravity Forms doesn't exist or is outdated, load the admin view class to |
| 124 | 124 | // show the notice, but not load any post types or process shortcodes. |
| 125 | 125 | // Without Gravity Forms, there is no GravityView. Beautiful, really. |
| 126 | - if( ! self::is_valid() ) { |
|
| 126 | + if (!self::is_valid()) { |
|
| 127 | 127 | |
| 128 | 128 | // If the plugin's not loaded, might as well hide the shortcode for people. |
| 129 | - add_shortcode( 'gravityview', array( $this, '_shortcode_gf_notice') ); |
|
| 129 | + add_shortcode('gravityview', array($this, '_shortcode_gf_notice')); |
|
| 130 | 130 | |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -150,17 +150,17 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @return null|string NULL returned if user can't activate plugins. Notice shown with a warning that GF isn't supported. |
| 152 | 152 | */ |
| 153 | - public function _shortcode_gf_notice( $atts = array(), $content = null, $shortcode = 'gravityview' ) { |
|
| 153 | + public function _shortcode_gf_notice($atts = array(), $content = null, $shortcode = 'gravityview') { |
|
| 154 | 154 | |
| 155 | - if( ! GVCommon::has_cap( 'activate_plugins' ) ) { |
|
| 155 | + if (!GVCommon::has_cap('activate_plugins')) { |
|
| 156 | 156 | return null; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $notices = self::get_notices(); |
| 160 | 160 | |
| 161 | - $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>' . esc_html__( 'You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview') . '</em></p>'; |
|
| 162 | - foreach( (array)$notices as $notice ) { |
|
| 163 | - $message .= wpautop( $notice['message'] ); |
|
| 161 | + $message = '<div style="border:1px solid red; padding: 15px;"><p style="text-align:center;"><em>'.esc_html__('You are seeing this notice because you are an administrator. Other users of the site will see nothing.', 'gravityview').'</em></p>'; |
|
| 162 | + foreach ((array)$notices as $notice) { |
|
| 163 | + $message .= wpautop($notice['message']); |
|
| 164 | 164 | } |
| 165 | 165 | $message .= '</div>'; |
| 166 | 166 | |
@@ -175,11 +175,11 @@ discard block |
||
| 175 | 175 | * @return boolean |
| 176 | 176 | */ |
| 177 | 177 | public static function check_php() { |
| 178 | - if( false === version_compare( phpversion(), GV_MIN_PHP_VERSION , '>=' ) ) { |
|
| 178 | + if (false === version_compare(phpversion(), GV_MIN_PHP_VERSION, '>=')) { |
|
| 179 | 179 | |
| 180 | 180 | self::$notices['php_version'] = array( |
| 181 | 181 | 'class' => 'error', |
| 182 | - 'message' => sprintf( __( "%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview' ), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>' ), |
|
| 182 | + 'message' => sprintf(__("%sGravityView requires PHP Version %s or newer.%s \n\nYou're using Version %s. Please ask your host to upgrade your server's PHP.", 'gravityview'), '<h3>', GV_MIN_PHP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.phpversion().'</span>'), |
|
| 183 | 183 | 'cap' => 'manage_options', |
| 184 | 184 | 'dismiss' => 'php_version', |
| 185 | 185 | ); |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | public static function check_wordpress() { |
| 200 | 200 | global $wp_version; |
| 201 | 201 | |
| 202 | - if( version_compare( $wp_version, GV_MIN_WP_VERSION ) <= 0 ) { |
|
| 202 | + if (version_compare($wp_version, GV_MIN_WP_VERSION) <= 0) { |
|
| 203 | 203 | |
| 204 | 204 | self::$notices['wp_version'] = array( |
| 205 | 205 | 'class' => 'error', |
| 206 | - 'message' => sprintf( __( "%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview' ), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>' ), |
|
| 206 | + 'message' => sprintf(__("%sGravityView requires WordPress %s or newer.%s \n\nYou're using Version %s. Please upgrade your WordPress installation.", 'gravityview'), '<h3>', GV_MIN_WP_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.$wp_version.'</span>'), |
|
| 207 | 207 | 'cap' => 'update_core', |
| 208 | 208 | 'dismiss' => 'wp_version', |
| 209 | 209 | ); |
@@ -226,17 +226,17 @@ discard block |
||
| 226 | 226 | public static function check_gravityforms() { |
| 227 | 227 | |
| 228 | 228 | // Bypass other checks: if the class exists |
| 229 | - if( class_exists( 'GFCommon' ) ) { |
|
| 229 | + if (class_exists('GFCommon')) { |
|
| 230 | 230 | |
| 231 | 231 | // and the version's right, we're good. |
| 232 | - if( true === version_compare( GFCommon::$version, GV_MIN_GF_VERSION, ">=" ) ) { |
|
| 232 | + if (true === version_compare(GFCommon::$version, GV_MIN_GF_VERSION, ">=")) { |
|
| 233 | 233 | return true; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Or the version's wrong |
| 237 | 237 | self::$notices['gf_version'] = array( |
| 238 | 238 | 'class' => 'error', |
| 239 | - 'message' => sprintf( __( "%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview' ), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
| 239 | + 'message' => sprintf(__("%sGravityView requires Gravity Forms Version %s or newer.%s \n\nYou're using Version %s. Please update your Gravity Forms or purchase a license. %sGet Gravity Forms%s - starting at $39%s%s", 'gravityview'), '<h3>', GV_MIN_GF_VERSION, "</h3>\n\n", '<span style="font-family: Consolas, Courier, monospace;">'.GFCommon::$version.'</span>', "\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>'), |
|
| 240 | 240 | 'cap' => 'update_plugins', |
| 241 | 241 | 'dismiss' => 'gf_version', |
| 242 | 242 | ); |
@@ -244,40 +244,40 @@ discard block |
||
| 244 | 244 | return false; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $gf_status = self::get_plugin_status( 'gravityforms/gravityforms.php' ); |
|
| 247 | + $gf_status = self::get_plugin_status('gravityforms/gravityforms.php'); |
|
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * The plugin is activated and yet somehow GFCommon didn't get picked up... |
| 251 | 251 | * OR |
| 252 | 252 | * It's the Network Admin and we just don't know whether the sites have GF activated themselves. |
| 253 | 253 | */ |
| 254 | - if( true === $gf_status || is_network_admin() ) { |
|
| 254 | + if (true === $gf_status || is_network_admin()) { |
|
| 255 | 255 | return true; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | // If GFCommon doesn't exist, assume GF not active |
| 259 | 259 | $return = false; |
| 260 | 260 | |
| 261 | - switch( $gf_status ) { |
|
| 261 | + switch ($gf_status) { |
|
| 262 | 262 | case 'inactive': |
| 263 | 263 | |
| 264 | 264 | // Required for multisite |
| 265 | - if( ! function_exists('wp_create_nonce') ) { |
|
| 266 | - require_once ABSPATH . WPINC . '/pluggable.php'; |
|
| 265 | + if (!function_exists('wp_create_nonce')) { |
|
| 266 | + require_once ABSPATH.WPINC.'/pluggable.php'; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // Otherwise, throws an error on activation & deactivation "Use of undefined constant LOGGED_IN_COOKIE" |
| 270 | - if( is_multisite() ) { |
|
| 270 | + if (is_multisite()) { |
|
| 271 | 271 | wp_cookie_constants(); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | $return = false; |
| 275 | 275 | |
| 276 | - $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'. wp_nonce_url( admin_url( 'plugins.php?action=activate&plugin=gravityforms/gravityforms.php' ), 'activate-plugin_gravityforms/gravityforms.php') . '" class="button button-large">'; |
|
| 276 | + $button = function_exists('is_network_admin') && is_network_admin() ? '<strong><a href="#gravity-forms">' : '<strong><a href="'.wp_nonce_url(admin_url('plugins.php?action=activate&plugin=gravityforms/gravityforms.php'), 'activate-plugin_gravityforms/gravityforms.php').'" class="button button-large">'; |
|
| 277 | 277 | |
| 278 | 278 | self::$notices['gf_inactive'] = array( |
| 279 | 279 | 'class' => 'error', |
| 280 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview' ), '<h3>', "</h3>\n\n". $button, '</a></strong>' ), |
|
| 280 | + 'message' => sprintf(__('%sGravityView requires Gravity Forms to be active. %sActivate Gravity Forms%s to use the GravityView plugin.', 'gravityview'), '<h3>', "</h3>\n\n".$button, '</a></strong>'), |
|
| 281 | 281 | 'cap' => 'activate_plugins', |
| 282 | 282 | 'dismiss' => 'gf_inactive', |
| 283 | 283 | ); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | default: |
| 287 | 287 | self::$notices['gf_installed'] = array( |
| 288 | 288 | 'class' => 'error', |
| 289 | - 'message' => sprintf( __( '%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview' ), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">' , '<em>', '</em>', '</a>'), |
|
| 289 | + 'message' => sprintf(__('%sGravityView requires Gravity Forms to be installed in order to run properly. %sGet Gravity Forms%s - starting at $39%s%s', 'gravityview'), '<h3>', "</h3>\n\n".'<a href="http://katz.si/gravityforms" class="button button-secondary button-large button-hero">', '<em>', '</em>', '</a>'), |
|
| 290 | 290 | 'cap' => 'install_plugins', |
| 291 | 291 | 'dismiss' => 'gf_installed', |
| 292 | 292 | ); |
@@ -303,11 +303,11 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | private static function check_gf_directory() { |
| 305 | 305 | |
| 306 | - if( class_exists( 'GFDirectory' ) ) { |
|
| 306 | + if (class_exists('GFDirectory')) { |
|
| 307 | 307 | self::$notices['gf_directory'] = array( |
| 308 | 308 | 'class' => 'error is-dismissible', |
| 309 | - 'title' => __('Potential Conflict', 'gravityview' ), |
|
| 310 | - 'message' => __( 'GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview' ), |
|
| 309 | + 'title' => __('Potential Conflict', 'gravityview'), |
|
| 310 | + 'message' => __('GravityView and Gravity Forms Directory are both active. This may cause problems. If you experience issues, disable the Gravity Forms Directory plugin.', 'gravityview'), |
|
| 311 | 311 | 'dismiss' => 'gf_directory', |
| 312 | 312 | 'cap' => 'activate_plugins', |
| 313 | 313 | ); |
@@ -323,23 +323,23 @@ discard block |
||
| 323 | 323 | * @param string $location (default: '') |
| 324 | 324 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
| 325 | 325 | */ |
| 326 | - public static function get_plugin_status( $location = '' ) { |
|
| 326 | + public static function get_plugin_status($location = '') { |
|
| 327 | 327 | |
| 328 | - if( ! function_exists('is_plugin_active') ) { |
|
| 329 | - include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
|
| 328 | + if (!function_exists('is_plugin_active')) { |
|
| 329 | + include_once(ABSPATH.'/wp-admin/includes/plugin.php'); |
|
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - if( is_network_admin() && is_plugin_active_for_network( $location ) ) { |
|
| 332 | + if (is_network_admin() && is_plugin_active_for_network($location)) { |
|
| 333 | 333 | return true; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if( !is_network_admin() && is_plugin_active( $location ) ) { |
|
| 336 | + if (!is_network_admin() && is_plugin_active($location)) { |
|
| 337 | 337 | return true; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if( |
|
| 341 | - !file_exists( trailingslashit( WP_PLUGIN_DIR ) . $location ) && |
|
| 342 | - !file_exists( trailingslashit( WPMU_PLUGIN_DIR ) . $location ) |
|
| 340 | + if ( |
|
| 341 | + !file_exists(trailingslashit(WP_PLUGIN_DIR).$location) && |
|
| 342 | + !file_exists(trailingslashit(WPMU_PLUGIN_DIR).$location) |
|
| 343 | 343 | ) { |
| 344 | 344 | return false; |
| 345 | 345 | } |
@@ -221,7 +221,6 @@ discard block |
||
| 221 | 221 | * |
| 222 | 222 | * @since 1.15 |
| 223 | 223 | * |
| 224 | - * @param string|null $content Content inside shortcode, if defined |
|
| 225 | 224 | * |
| 226 | 225 | * @return string|boolean If URL is fetched, the URL to the entry link. If not found, returns false. |
| 227 | 226 | */ |
@@ -316,7 +315,7 @@ discard block |
||
| 316 | 315 | * |
| 317 | 316 | * @since 1.15 |
| 318 | 317 | * |
| 319 | - * @param string $href URL |
|
| 318 | + * @param string|null $url |
|
| 320 | 319 | */ |
| 321 | 320 | private function maybe_add_field_values_query_args( $url ) { |
| 322 | 321 | |
@@ -51,17 +51,17 @@ discard block |
||
| 51 | 51 | * @since 1.15 |
| 52 | 52 | */ |
| 53 | 53 | private function add_hooks() { |
| 54 | - add_shortcode( 'gv_entry_link', array( $this, 'read_shortcode' ) ); |
|
| 55 | - add_shortcode( 'gv_edit_entry_link', array( $this, 'edit_shortcode' ) ); |
|
| 56 | - add_shortcode( 'gv_delete_entry_link', array( $this, 'delete_shortcode' ) ); |
|
| 54 | + add_shortcode('gv_entry_link', array($this, 'read_shortcode')); |
|
| 55 | + add_shortcode('gv_edit_entry_link', array($this, 'edit_shortcode')); |
|
| 56 | + add_shortcode('gv_delete_entry_link', array($this, 'delete_shortcode')); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @since 1.15 |
| 61 | 61 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
| 62 | 62 | */ |
| 63 | - public function read_shortcode( $atts, $content = null, $context = 'gv_entry_link' ) { |
|
| 64 | - return $this->shortcode( $atts, $content, $context ); |
|
| 63 | + public function read_shortcode($atts, $content = null, $context = 'gv_entry_link') { |
|
| 64 | + return $this->shortcode($atts, $content, $context); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | * @since 1.15 |
| 72 | 72 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
| 73 | 73 | */ |
| 74 | - public function edit_shortcode( $atts, $content = null, $context = 'gv_edit_entry_link' ) { |
|
| 74 | + public function edit_shortcode($atts, $content = null, $context = 'gv_edit_entry_link') { |
|
| 75 | 75 | $atts['action'] = 'edit'; |
| 76 | 76 | |
| 77 | - return $this->shortcode( $atts, $content, $context ); |
|
| 77 | + return $this->shortcode($atts, $content, $context); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | * @since 1.15 |
| 85 | 85 | * @copydoc GravityView_Entry_Link_Shortcode::shortcode |
| 86 | 86 | */ |
| 87 | - public function delete_shortcode( $atts, $content = null, $context = 'gv_delete_entry_link' ) { |
|
| 87 | + public function delete_shortcode($atts, $content = null, $context = 'gv_delete_entry_link') { |
|
| 88 | 88 | $atts['action'] = 'delete'; |
| 89 | 89 | |
| 90 | - return $this->shortcode( $atts, $content, $context ); |
|
| 90 | + return $this->shortcode($atts, $content, $context); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -110,58 +110,58 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @return null|string If admin or an error occurred, returns null. Otherwise, returns entry link output. If `$atts['return']` is 'url', the entry link URL. Otherwise, entry link `<a>` HTML tag. |
| 112 | 112 | */ |
| 113 | - private function shortcode( $atts, $content = null, $context = 'gv_entry_link' ) { |
|
| 113 | + private function shortcode($atts, $content = null, $context = 'gv_entry_link') { |
|
| 114 | 114 | |
| 115 | 115 | // Don't process when saving post. Keep processing if it's admin-ajax.php |
| 116 | - if ( ! class_exists( 'GravityView_Plugin' ) || GravityView_Plugin::is_admin() ) { |
|
| 116 | + if (!class_exists('GravityView_Plugin') || GravityView_Plugin::is_admin()) { |
|
| 117 | 117 | return null; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // Make sure GV is loaded |
| 121 | - if ( ! class_exists( 'GravityView_frontend' ) || ! class_exists( 'GravityView_View' ) ) { |
|
| 122 | - do_action( 'gravityview_log_error', __METHOD__ . ' GravityView_frontend or GravityView_View do not exist.' ); |
|
| 121 | + if (!class_exists('GravityView_frontend') || !class_exists('GravityView_View')) { |
|
| 122 | + do_action('gravityview_log_error', __METHOD__.' GravityView_frontend or GravityView_View do not exist.'); |
|
| 123 | 123 | |
| 124 | 124 | return null; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $this->settings = shortcode_atts( self::$defaults, $atts, $context ); |
|
| 127 | + $this->settings = shortcode_atts(self::$defaults, $atts, $context); |
|
| 128 | 128 | |
| 129 | - $this->view_id = empty( $this->settings['view_id'] ) ? GravityView_View::getInstance()->getViewId() : absint( $this->settings['view_id'] ); |
|
| 129 | + $this->view_id = empty($this->settings['view_id']) ? GravityView_View::getInstance()->getViewId() : absint($this->settings['view_id']); |
|
| 130 | 130 | |
| 131 | - if ( empty( $this->view_id ) ) { |
|
| 132 | - do_action( 'gravityview_log_error', __METHOD__ . ' A View ID was not defined and we are not inside a View' ); |
|
| 131 | + if (empty($this->view_id)) { |
|
| 132 | + do_action('gravityview_log_error', __METHOD__.' A View ID was not defined and we are not inside a View'); |
|
| 133 | 133 | |
| 134 | 134 | return null; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $this->entry = $this->get_entry( $this->settings['entry_id'] ); |
|
| 137 | + $this->entry = $this->get_entry($this->settings['entry_id']); |
|
| 138 | 138 | |
| 139 | - do_action( 'gravityview_log_debug', __METHOD__ . ' ' . $context . ' $atts: ', $atts ); |
|
| 139 | + do_action('gravityview_log_debug', __METHOD__.' '.$context.' $atts: ', $atts); |
|
| 140 | 140 | |
| 141 | - if ( ! $this->has_cap() ) { |
|
| 142 | - do_action( 'gravityview_log_error', __METHOD__ . ' User does not have the capability to ' . esc_attr( $this->settings['action'] ) . ' this entry: ' . $this->entry['id'] ); |
|
| 141 | + if (!$this->has_cap()) { |
|
| 142 | + do_action('gravityview_log_error', __METHOD__.' User does not have the capability to '.esc_attr($this->settings['action']).' this entry: '.$this->entry['id']); |
|
| 143 | 143 | |
| 144 | 144 | return null; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | $url = $this->get_url(); |
| 148 | 148 | |
| 149 | - if ( ! $url ) { |
|
| 150 | - do_action( 'gravityview_log_error', __METHOD__ . ' Link returned false; View or Post may not exist.' ); |
|
| 149 | + if (!$url) { |
|
| 150 | + do_action('gravityview_log_error', __METHOD__.' Link returned false; View or Post may not exist.'); |
|
| 151 | 151 | |
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Get just the URL, not the tag |
| 156 | - if ( 'url' === $this->settings['return'] ) { |
|
| 156 | + if ('url' === $this->settings['return']) { |
|
| 157 | 157 | return $url; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $link_atts = $this->get_link_atts(); |
| 161 | 161 | |
| 162 | - $link_text = $this->get_anchor_text( $content ); |
|
| 162 | + $link_text = $this->get_anchor_text($content); |
|
| 163 | 163 | |
| 164 | - return gravityview_get_link( $url, $link_text, $link_atts ); |
|
| 164 | + return gravityview_get_link($url, $link_text, $link_atts); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | */ |
| 175 | 175 | private function get_link_atts() { |
| 176 | 176 | |
| 177 | - wp_parse_str( $this->settings['link_atts'], $link_atts ); |
|
| 177 | + wp_parse_str($this->settings['link_atts'], $link_atts); |
|
| 178 | 178 | |
| 179 | - if ( 'delete' === $this->settings['action'] ) { |
|
| 180 | - $link_atts['onclick'] = isset( $link_atts['onclick'] ) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
| 179 | + if ('delete' === $this->settings['action']) { |
|
| 180 | + $link_atts['onclick'] = isset($link_atts['onclick']) ? $link_atts['onclick'] : GravityView_Delete_Entry::get_confirm_dialog(); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - return (array) $link_atts; |
|
| 183 | + return (array)$link_atts; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -194,21 +194,21 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return string Text to use for HTML anchor |
| 196 | 196 | */ |
| 197 | - private function get_anchor_text( $content = null ) { |
|
| 197 | + private function get_anchor_text($content = null) { |
|
| 198 | 198 | |
| 199 | - if ( $content ) { |
|
| 199 | + if ($content) { |
|
| 200 | 200 | return $content; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - switch ( $this->settings['action'] ) { |
|
| 203 | + switch ($this->settings['action']) { |
|
| 204 | 204 | case 'edit': |
| 205 | - $anchor_text = __( 'Edit Entry', 'gravityview' ); |
|
| 205 | + $anchor_text = __('Edit Entry', 'gravityview'); |
|
| 206 | 206 | break; |
| 207 | 207 | case 'delete': |
| 208 | - $anchor_text = __( 'Delete Entry', 'gravityview' ); |
|
| 208 | + $anchor_text = __('Delete Entry', 'gravityview'); |
|
| 209 | 209 | break; |
| 210 | 210 | default: |
| 211 | - $anchor_text = __( 'View Details', 'gravityview' ); |
|
| 211 | + $anchor_text = __('View Details', 'gravityview'); |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | return $anchor_text; |
@@ -228,21 +228,21 @@ discard block |
||
| 228 | 228 | private function get_url() { |
| 229 | 229 | |
| 230 | 230 | // if post_id is not defined, default to view_id |
| 231 | - $post_id = empty( $this->settings['post_id'] ) ? $this->view_id : absint( $this->settings['post_id'] ); |
|
| 231 | + $post_id = empty($this->settings['post_id']) ? $this->view_id : absint($this->settings['post_id']); |
|
| 232 | 232 | |
| 233 | - switch ( $this->settings['action'] ) { |
|
| 233 | + switch ($this->settings['action']) { |
|
| 234 | 234 | case 'edit': |
| 235 | - $url = GravityView_Edit_Entry::get_edit_link( $this->entry, $this->view_id, $post_id ); |
|
| 235 | + $url = GravityView_Edit_Entry::get_edit_link($this->entry, $this->view_id, $post_id); |
|
| 236 | 236 | break; |
| 237 | 237 | case 'delete': |
| 238 | - $url = GravityView_Delete_Entry::get_delete_link( $this->entry, $this->view_id, $post_id ); |
|
| 238 | + $url = GravityView_Delete_Entry::get_delete_link($this->entry, $this->view_id, $post_id); |
|
| 239 | 239 | break; |
| 240 | 240 | case 'read': |
| 241 | 241 | default: |
| 242 | - $url = GravityView_API::entry_link( $this->entry, $post_id ); |
|
| 242 | + $url = GravityView_API::entry_link($this->entry, $post_id); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - $url = $this->maybe_add_field_values_query_args( $url ); |
|
| 245 | + $url = $this->maybe_add_field_values_query_args($url); |
|
| 246 | 246 | |
| 247 | 247 | return $url; |
| 248 | 248 | } |
@@ -255,12 +255,12 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | private function has_cap() { |
| 257 | 257 | |
| 258 | - switch ( $this->settings['action'] ) { |
|
| 258 | + switch ($this->settings['action']) { |
|
| 259 | 259 | case 'edit': |
| 260 | - $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry, $this->view_id ); |
|
| 260 | + $has_cap = GravityView_Edit_Entry::check_user_cap_edit_entry($this->entry, $this->view_id); |
|
| 261 | 261 | break; |
| 262 | 262 | case 'delete': |
| 263 | - $has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry( $this->entry, array(), $this->view_id ); |
|
| 263 | + $has_cap = GravityView_Delete_Entry::check_user_cap_delete_entry($this->entry, array(), $this->view_id); |
|
| 264 | 264 | break; |
| 265 | 265 | case 'read': |
| 266 | 266 | default: |
@@ -281,28 +281,28 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @return array|bool Gravity Forms array, if found. Otherwise, false. |
| 283 | 283 | */ |
| 284 | - private function get_entry( $entry_id = 0 ) { |
|
| 284 | + private function get_entry($entry_id = 0) { |
|
| 285 | 285 | |
| 286 | 286 | $backup_entry = GravityView_frontend::getInstance()->getSingleEntry() ? GravityView_frontend::getInstance()->getEntry() : GravityView_View::getInstance()->getCurrentEntry(); |
| 287 | 287 | |
| 288 | - if ( empty( $entry_id ) ) { |
|
| 289 | - if ( ! $backup_entry ) { |
|
| 290 | - do_action( 'gravityview_log_error', __METHOD__ . ' No entry defined (or entry id not valid number)', $this->settings ); |
|
| 288 | + if (empty($entry_id)) { |
|
| 289 | + if (!$backup_entry) { |
|
| 290 | + do_action('gravityview_log_error', __METHOD__.' No entry defined (or entry id not valid number)', $this->settings); |
|
| 291 | 291 | |
| 292 | 292 | return false; |
| 293 | 293 | } |
| 294 | 294 | $entry = $backup_entry; |
| 295 | 295 | } else { |
| 296 | - $entry = wp_cache_get( 'gv_entry_link_entry_' . $entry_id, 'gravityview_entry_link_shortcode' ); |
|
| 297 | - if ( false === $entry ) { |
|
| 298 | - $entry = GVCommon::get_entry( $entry_id, true, false ); |
|
| 299 | - wp_cache_add( 'gv_entry_link_entry_' . $entry_id, $entry, 'gravityview_entry_link_shortcode' ); |
|
| 296 | + $entry = wp_cache_get('gv_entry_link_entry_'.$entry_id, 'gravityview_entry_link_shortcode'); |
|
| 297 | + if (false === $entry) { |
|
| 298 | + $entry = GVCommon::get_entry($entry_id, true, false); |
|
| 299 | + wp_cache_add('gv_entry_link_entry_'.$entry_id, $entry, 'gravityview_entry_link_shortcode'); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | // No search results |
| 304 | - if ( false === $entry ) { |
|
| 305 | - do_action( 'gravityview_log_error', __METHOD__ . ' No entries match the entry ID defined', $entry_id ); |
|
| 304 | + if (false === $entry) { |
|
| 305 | + do_action('gravityview_log_error', __METHOD__.' No entries match the entry ID defined', $entry_id); |
|
| 306 | 306 | |
| 307 | 307 | return false; |
| 308 | 308 | } |
@@ -318,13 +318,13 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @param string $href URL |
| 320 | 320 | */ |
| 321 | - private function maybe_add_field_values_query_args( $url ) { |
|
| 321 | + private function maybe_add_field_values_query_args($url) { |
|
| 322 | 322 | |
| 323 | - if ( $url && ! empty( $this->settings['field_values'] ) ) { |
|
| 323 | + if ($url && !empty($this->settings['field_values'])) { |
|
| 324 | 324 | |
| 325 | - wp_parse_str( $this->settings['field_values'], $field_values ); |
|
| 325 | + wp_parse_str($this->settings['field_values'], $field_values); |
|
| 326 | 326 | |
| 327 | - $url = add_query_arg( $field_values, $url ); |
|
| 327 | + $url = add_query_arg($field_values, $url); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | return $url; |
@@ -278,7 +278,7 @@ |
||
| 278 | 278 | |
| 279 | 279 | /** |
| 280 | 280 | * Add a notice to be displayed in the admin. |
| 281 | - * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
|
| 281 | + * @param string $notice Array with `class` and `message` keys. The message is not escaped. |
|
| 282 | 282 | */ |
| 283 | 283 | public static function add_notice( $notice = array() ) { |
| 284 | 284 | |
@@ -244,13 +244,13 @@ |
||
| 244 | 244 | $this->_remote_update_url, |
| 245 | 245 | $this->_path, |
| 246 | 246 | array( |
| 247 | - 'version' => $this->_version, // current version number |
|
| 248 | - 'license' => $license['license'], |
|
| 249 | - 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
|
| 250 | - 'item_name' => $this->_title, // name of this plugin |
|
| 251 | - 'author' => strip_tags( $this->_author ) // author of this plugin |
|
| 252 | - ) |
|
| 253 | - ); |
|
| 247 | + 'version' => $this->_version, // current version number |
|
| 248 | + 'license' => $license['license'], |
|
| 249 | + 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
|
| 250 | + 'item_name' => $this->_title, // name of this plugin |
|
| 251 | + 'author' => strip_tags( $this->_author ) // author of this plugin |
|
| 252 | + ) |
|
| 253 | + ); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -69,22 +69,22 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | function __construct() { |
| 71 | 71 | |
| 72 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
| 72 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
| 73 | 73 | |
| 74 | - add_action( 'admin_init', array( $this, 'settings') ); |
|
| 74 | + add_action('admin_init', array($this, 'settings')); |
|
| 75 | 75 | |
| 76 | - add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 ); |
|
| 76 | + add_action('admin_notices', array($this, 'admin_notice'), 100); |
|
| 77 | 77 | |
| 78 | - add_action( 'gravityview/metaboxes/before_render', array( $this, 'add_metabox_tab' ) ); |
|
| 78 | + add_action('gravityview/metaboxes/before_render', array($this, 'add_metabox_tab')); |
|
| 79 | 79 | |
| 80 | - if( false === $this->is_extension_supported() ) { |
|
| 80 | + if (false === $this->is_extension_supported()) { |
|
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - add_filter( 'gravityview_tooltips', array( $this, 'tooltips' ) ); |
|
| 84 | + add_filter('gravityview_tooltips', array($this, 'tooltips')); |
|
| 85 | 85 | |
| 86 | 86 | // Save the form configuration. Run at 14 so that View metadata is already saved (at 10) |
| 87 | - add_action( 'save_post', array( $this, 'save_post' ), 14 ); |
|
| 87 | + add_action('save_post', array($this, 'save_post'), 14); |
|
| 88 | 88 | |
| 89 | 89 | $this->add_hooks(); |
| 90 | 90 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $tab_settings = $this->tab_settings(); |
| 117 | 117 | |
| 118 | 118 | // Don't add a tab if it's empty. |
| 119 | - if( empty( $tab_settings ) ) { |
|
| 119 | + if (empty($tab_settings)) { |
|
| 120 | 120 | return; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -131,20 +131,20 @@ discard block |
||
| 131 | 131 | 'priority' => 'default', |
| 132 | 132 | ); |
| 133 | 133 | |
| 134 | - $tab = wp_parse_args( $tab_settings, $tab_defaults ); |
|
| 134 | + $tab = wp_parse_args($tab_settings, $tab_defaults); |
|
| 135 | 135 | |
| 136 | 136 | // Force the screen to be GravityView |
| 137 | 137 | $tab['screen'] = 'gravityview'; |
| 138 | 138 | |
| 139 | - if( class_exists('GravityView_Metabox_Tab') ) { |
|
| 139 | + if (class_exists('GravityView_Metabox_Tab')) { |
|
| 140 | 140 | |
| 141 | - $metabox = new GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] ); |
|
| 141 | + $metabox = new GravityView_Metabox_Tab($tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args']); |
|
| 142 | 142 | |
| 143 | - GravityView_Metabox_Tabs::add( $metabox ); |
|
| 143 | + GravityView_Metabox_Tabs::add($metabox); |
|
| 144 | 144 | |
| 145 | 145 | } else { |
| 146 | 146 | |
| 147 | - add_meta_box( 'gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] ); |
|
| 147 | + add_meta_box('gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority']); |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | } |
@@ -160,37 +160,37 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | public function load_plugin_textdomain() { |
| 162 | 162 | |
| 163 | - if( empty( $this->_text_domain ) ) { |
|
| 164 | - do_action( 'gravityview_log_debug', __METHOD__ . ': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this ); |
|
| 163 | + if (empty($this->_text_domain)) { |
|
| 164 | + do_action('gravityview_log_debug', __METHOD__.': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this); |
|
| 165 | 165 | return; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Backward compat for Ratings & Reviews / Maps |
| 169 | - $path = isset( $this->_path ) ? $this->_path : ( isset( $this->plugin_file ) ? $this->plugin_file : '' ); |
|
| 169 | + $path = isset($this->_path) ? $this->_path : (isset($this->plugin_file) ? $this->plugin_file : ''); |
|
| 170 | 170 | |
| 171 | 171 | // Set filter for plugin's languages directory |
| 172 | - $lang_dir = dirname( plugin_basename( $path ) ) . '/languages/'; |
|
| 172 | + $lang_dir = dirname(plugin_basename($path)).'/languages/'; |
|
| 173 | 173 | |
| 174 | 174 | // Traditional WordPress plugin locale filter |
| 175 | - $locale = apply_filters( 'plugin_locale', get_locale(), $this->_text_domain ); |
|
| 175 | + $locale = apply_filters('plugin_locale', get_locale(), $this->_text_domain); |
|
| 176 | 176 | |
| 177 | - $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale ); |
|
| 177 | + $mofile = sprintf('%1$s-%2$s.mo', $this->_text_domain, $locale); |
|
| 178 | 178 | |
| 179 | 179 | // Setup paths to current locale file |
| 180 | - $mofile_local = $lang_dir . $mofile; |
|
| 181 | - $mofile_global = WP_LANG_DIR . '/' . $this->_text_domain . '/' . $mofile; |
|
| 180 | + $mofile_local = $lang_dir.$mofile; |
|
| 181 | + $mofile_global = WP_LANG_DIR.'/'.$this->_text_domain.'/'.$mofile; |
|
| 182 | 182 | |
| 183 | - if ( file_exists( $mofile_global ) ) { |
|
| 183 | + if (file_exists($mofile_global)) { |
|
| 184 | 184 | // Look in global /wp-content/languages/[plugin-dir]/ folder |
| 185 | - load_textdomain( $this->_text_domain, $mofile_global ); |
|
| 185 | + load_textdomain($this->_text_domain, $mofile_global); |
|
| 186 | 186 | } |
| 187 | - elseif ( file_exists( $mofile_local ) ) { |
|
| 187 | + elseif (file_exists($mofile_local)) { |
|
| 188 | 188 | // Look in local /wp-content/plugins/[plugin-dir]/languages/ folder |
| 189 | - load_textdomain( $this->_text_domain, $mofile_local ); |
|
| 189 | + load_textdomain($this->_text_domain, $mofile_local); |
|
| 190 | 190 | } |
| 191 | 191 | else { |
| 192 | 192 | // Load the default language files |
| 193 | - load_plugin_textdomain( $this->_text_domain, false, $lang_dir ); |
|
| 193 | + load_plugin_textdomain($this->_text_domain, false, $lang_dir); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | protected function get_license() { |
| 204 | 204 | |
| 205 | - if( !class_exists( 'GravityView_Settings' ) ) { |
|
| 205 | + if (!class_exists('GravityView_Settings')) { |
|
| 206 | 206 | return false; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -219,17 +219,17 @@ discard block |
||
| 219 | 219 | public function settings() { |
| 220 | 220 | |
| 221 | 221 | // If doing ajax, get outta here |
| 222 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
| 222 | + if (!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
| 223 | 223 | return; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
| 226 | + if (!class_exists('EDD_SL_Plugin_Updater')) { |
|
| 227 | 227 | |
| 228 | - $file_path = plugin_dir_path( __FILE__ ) . 'lib/EDD_SL_Plugin_Updater.php'; |
|
| 228 | + $file_path = plugin_dir_path(__FILE__).'lib/EDD_SL_Plugin_Updater.php'; |
|
| 229 | 229 | |
| 230 | 230 | // This file may be in the lib/ directory already |
| 231 | - if( ! file_exists( $file_path ) ) { |
|
| 232 | - $file_path = plugin_dir_path( __FILE__ ) . '/EDD_SL_Plugin_Updater.php'; |
|
| 231 | + if (!file_exists($file_path)) { |
|
| 232 | + $file_path = plugin_dir_path(__FILE__).'/EDD_SL_Plugin_Updater.php'; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | include_once $file_path; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $license = $this->get_license(); |
| 239 | 239 | |
| 240 | 240 | // Don't update if invalid license. |
| 241 | - if( false === $license || empty( $license['status'] ) || strtolower( $license['status'] ) !== 'valid' ) { return; } |
|
| 241 | + if (false === $license || empty($license['status']) || strtolower($license['status']) !== 'valid') { return; } |
|
| 242 | 242 | |
| 243 | 243 | new EDD_SL_Plugin_Updater( |
| 244 | 244 | $this->_remote_update_url, |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | 'version' => $this->_version, // current version number |
| 248 | 248 | 'license' => $license['license'], |
| 249 | 249 | 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
| 250 | - 'item_name' => $this->_title, // name of this plugin |
|
| 251 | - 'author' => strip_tags( $this->_author ) // author of this plugin |
|
| 250 | + 'item_name' => $this->_title, // name of this plugin |
|
| 251 | + 'author' => strip_tags($this->_author) // author of this plugin |
|
| 252 | 252 | ) |
| 253 | 253 | ); |
| 254 | 254 | } |
@@ -260,14 +260,14 @@ discard block |
||
| 260 | 260 | */ |
| 261 | 261 | public function admin_notice() { |
| 262 | 262 | |
| 263 | - if( empty( self::$admin_notices ) ) { |
|
| 263 | + if (empty(self::$admin_notices)) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - foreach( self::$admin_notices as $key => $notice ) { |
|
| 267 | + foreach (self::$admin_notices as $key => $notice) { |
|
| 268 | 268 | |
| 269 | - echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">'; |
|
| 270 | - echo wpautop( $notice['message'] ); |
|
| 269 | + echo '<div id="message" class="'.esc_attr($notice['class']).'">'; |
|
| 270 | + echo wpautop($notice['message']); |
|
| 271 | 271 | echo '<div class="clear"></div>'; |
| 272 | 272 | echo '</div>'; |
| 273 | 273 | } |
@@ -280,16 +280,16 @@ discard block |
||
| 280 | 280 | * Add a notice to be displayed in the admin. |
| 281 | 281 | * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
| 282 | 282 | */ |
| 283 | - public static function add_notice( $notice = array() ) { |
|
| 283 | + public static function add_notice($notice = array()) { |
|
| 284 | 284 | |
| 285 | - if( is_array( $notice ) && !isset( $notice['message'] ) ) { |
|
| 286 | - do_action( 'gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice ); |
|
| 285 | + if (is_array($notice) && !isset($notice['message'])) { |
|
| 286 | + do_action('gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice); |
|
| 287 | 287 | return; |
| 288 | - } else if( is_string( $notice ) ) { |
|
| 289 | - $notice = array( 'message' => $notice ); |
|
| 288 | + } else if (is_string($notice)) { |
|
| 289 | + $notice = array('message' => $notice); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
| 292 | + $notice['class'] = empty($notice['class']) ? 'error' : $notice['class']; |
|
| 293 | 293 | |
| 294 | 294 | self::$admin_notices[] = $notice; |
| 295 | 295 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * @param int $post_id Post ID |
| 305 | 305 | * @return void |
| 306 | 306 | */ |
| 307 | - public function save_post( $post_id ) {} |
|
| 307 | + public function save_post($post_id) {} |
|
| 308 | 308 | |
| 309 | 309 | /** |
| 310 | 310 | * Add tooltips for the extension. |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * @param array $tooltips Existing GV tooltips, with `title` and `value` keys |
| 324 | 324 | * @return array Modified tooltips |
| 325 | 325 | */ |
| 326 | - public function tooltips( $tooltips = array() ) { |
|
| 326 | + public function tooltips($tooltips = array()) { |
|
| 327 | 327 | |
| 328 | 328 | return $tooltips; |
| 329 | 329 | |
@@ -346,17 +346,17 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | $message = ''; |
| 348 | 348 | |
| 349 | - if( !class_exists( 'GravityView_Plugin' ) ) { |
|
| 349 | + if (!class_exists('GravityView_Plugin')) { |
|
| 350 | 350 | |
| 351 | - $message = sprintf( __('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title ); |
|
| 351 | + $message = sprintf(__('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title); |
|
| 352 | 352 | |
| 353 | - } else if( false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version , ">=") ) { |
|
| 353 | + } else if (false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version, ">=")) { |
|
| 354 | 354 | |
| 355 | - $message = sprintf( __('The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>' ); |
|
| 355 | + $message = sprintf(__('The %s Extension requires GravityView Version %s or newer.', 'gravityview'), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>'); |
|
| 356 | 356 | |
| 357 | - } else if( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=") ) { |
|
| 357 | + } else if (isset($this->_min_php_version) && false === version_compare(phpversion(), $this->_min_php_version, ">=")) { |
|
| 358 | 358 | |
| 359 | - $message = sprintf( __('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_php_version.'</tt>' ); |
|
| 359 | + $message = sprintf(__('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview'), $this->_title, '<tt>'.$this->_min_php_version.'</tt>'); |
|
| 360 | 360 | |
| 361 | 361 | } else { |
| 362 | 362 | |
@@ -364,11 +364,11 @@ discard block |
||
| 364 | 364 | |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if ( ! empty( $message ) ) { |
|
| 367 | + if (!empty($message)) { |
|
| 368 | 368 | |
| 369 | - self::add_notice( $message ); |
|
| 369 | + self::add_notice($message); |
|
| 370 | 370 | |
| 371 | - do_action( 'gravityview_log_error', __METHOD__. ' ' . $message ); |
|
| 371 | + do_action('gravityview_log_error', __METHOD__.' '.$message); |
|
| 372 | 372 | |
| 373 | 373 | self::$is_compatible = false; |
| 374 | 374 | } |
@@ -183,12 +183,10 @@ |
||
| 183 | 183 | if ( file_exists( $mofile_global ) ) { |
| 184 | 184 | // Look in global /wp-content/languages/[plugin-dir]/ folder |
| 185 | 185 | load_textdomain( $this->_text_domain, $mofile_global ); |
| 186 | - } |
|
| 187 | - elseif ( file_exists( $mofile_local ) ) { |
|
| 186 | + } elseif ( file_exists( $mofile_local ) ) { |
|
| 188 | 187 | // Look in local /wp-content/plugins/[plugin-dir]/languages/ folder |
| 189 | 188 | load_textdomain( $this->_text_domain, $mofile_local ); |
| 190 | - } |
|
| 191 | - else { |
|
| 189 | + } else { |
|
| 192 | 190 | // Load the default language files |
| 193 | 191 | load_plugin_textdomain( $this->_text_domain, false, $lang_dir ); |
| 194 | 192 | } |
@@ -135,7 +135,7 @@ |
||
| 135 | 135 | * @param bool $url_encode Whether to URL-encode output |
| 136 | 136 | * @param bool $esc_html Whether to apply `esc_html()` to output |
| 137 | 137 | * |
| 138 | - * @return mixed |
|
| 138 | + * @return string |
|
| 139 | 139 | */ |
| 140 | 140 | public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
| 141 | 141 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | private function add_hooks() { |
| 21 | 21 | |
| 22 | 22 | /** @see GFCommon::replace_variables_prepopulate **/ |
| 23 | - add_filter( 'gform_replace_merge_tags', array( 'GravityView_Merge_Tags', 'replace_gv_merge_tags' ), 10, 7 ); |
|
| 23 | + add_filter('gform_replace_merge_tags', array('GravityView_Merge_Tags', 'replace_gv_merge_tags'), 10, 7); |
|
| 24 | 24 | |
| 25 | 25 | } |
| 26 | 26 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param bool $esc_html Pass return value through `esc_html()` |
| 42 | 42 | * @return string Text with variables maybe replaced |
| 43 | 43 | */ |
| 44 | - public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true ) { |
|
| 44 | + public static function replace_variables($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = true) { |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @filter `gravityview_do_replace_variables` Turn off merge tag variable replacements.\n |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @param[in] array $form GF Form array |
| 54 | 54 | * @param[in] array $entry GF Entry array |
| 55 | 55 | */ |
| 56 | - $do_replace_variables = apply_filters( 'gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry ); |
|
| 56 | + $do_replace_variables = apply_filters('gravityview/merge_tags/do_replace_variables', true, $text, $form, $entry); |
|
| 57 | 57 | |
| 58 | - if ( strpos( $text, '{' ) === false || ! $do_replace_variables ) { |
|
| 58 | + if (strpos($text, '{') === false || !$do_replace_variables) { |
|
| 59 | 59 | return $text; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @internal Reported to GF Support on 12/3 |
| 66 | 66 | */ |
| 67 | - $form['title'] = isset( $form['title'] ) ? $form['title'] : ''; |
|
| 68 | - $form['id'] = isset( $form['id'] ) ? $form['id'] : ''; |
|
| 69 | - $form['fields'] = isset( $form['fields'] ) ? $form['fields'] : array(); |
|
| 67 | + $form['title'] = isset($form['title']) ? $form['title'] : ''; |
|
| 68 | + $form['id'] = isset($form['id']) ? $form['id'] : ''; |
|
| 69 | + $form['fields'] = isset($form['fields']) ? $form['fields'] : array(); |
|
| 70 | 70 | |
| 71 | - return GFCommon::replace_variables( $text, $form, $entry, $url_encode, $esc_html ); |
|
| 71 | + return GFCommon::replace_variables($text, $form, $entry, $url_encode, $esc_html); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * |
| 87 | 87 | * @return mixed |
| 88 | 88 | */ |
| 89 | - public static function replace_gv_merge_tags( $text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false ) { |
|
| 89 | + public static function replace_gv_merge_tags($text, $form = array(), $entry = array(), $url_encode = false, $esc_html = false) { |
|
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * This prevents the gform_replace_merge_tags filter from being called twice, as defined in: |
@@ -94,52 +94,52 @@ discard block |
||
| 94 | 94 | * @see GFCommon::replace_variables_prepopulate() |
| 95 | 95 | * @todo Remove eventually: Gravity Forms fixed this issue in 1.9.14 |
| 96 | 96 | */ |
| 97 | - if( false === $form ) { |
|
| 97 | + if (false === $form) { |
|
| 98 | 98 | return $text; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - $text = self::replace_get_variables( $text, $form, $entry, $url_encode ); |
|
| 101 | + $text = self::replace_get_variables($text, $form, $entry, $url_encode); |
|
| 102 | 102 | |
| 103 | 103 | return $text; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public static function format_date( $date_created, $full_tag, $property ) { |
|
| 106 | + public static function format_date($date_created, $full_tag, $property) { |
|
| 107 | 107 | |
| 108 | - $site_date_format = get_option( 'date_format' ); |
|
| 108 | + $site_date_format = get_option('date_format'); |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * Gravity Forms code to adjust date to locally-configured Time Zone |
| 112 | 112 | * @see GFCommon::format_date() |
| 113 | 113 | */ |
| 114 | - $entry_gmt_time = mysql2date( 'G', $date_created ); |
|
| 115 | - $entry_local_timestamp = GFCommon::get_local_timestamp( $entry_gmt_time ); |
|
| 114 | + $entry_gmt_time = mysql2date('G', $date_created); |
|
| 115 | + $entry_local_timestamp = GFCommon::get_local_timestamp($entry_gmt_time); |
|
| 116 | 116 | |
| 117 | 117 | // Expand all modifiers, skipping escaped colons. str_replace worked better than preg_split( "/(?<!\\):/" ) |
| 118 | - $exploded = explode( ':', str_replace( '\:', '|COLON|', $property ) ); |
|
| 118 | + $exploded = explode(':', str_replace('\:', '|COLON|', $property)); |
|
| 119 | 119 | |
| 120 | - $is_human = in_array( 'human', $exploded ); // {date_created:human} |
|
| 121 | - $is_diff = in_array( 'diff', $exploded ); // {date_created:diff} |
|
| 122 | - $is_raw = in_array( 'raw', $exploded ); // {date_created:raw} |
|
| 123 | - $is_timestamp = in_array( 'timestamp', $exploded ); // {date_created:timestamp} |
|
| 120 | + $is_human = in_array('human', $exploded); // {date_created:human} |
|
| 121 | + $is_diff = in_array('diff', $exploded); // {date_created:diff} |
|
| 122 | + $is_raw = in_array('raw', $exploded); // {date_created:raw} |
|
| 123 | + $is_timestamp = in_array('timestamp', $exploded); // {date_created:timestamp} |
|
| 124 | 124 | |
| 125 | 125 | // If {date_created:raw} was specified, don't modify the stored value |
| 126 | - if ( $is_raw ) { |
|
| 126 | + if ($is_raw) { |
|
| 127 | 127 | $formatted_date = $date_created; |
| 128 | - } elseif( $is_timestamp ) { |
|
| 128 | + } elseif ($is_timestamp) { |
|
| 129 | 129 | $formatted_date = $entry_local_timestamp; |
| 130 | - } elseif ( $is_diff ) { |
|
| 130 | + } elseif ($is_diff) { |
|
| 131 | 131 | |
| 132 | 132 | /* translators: %s is the time (seconds, hours, days, weeks, months, years) since entry was created */ |
| 133 | - $relative_format = self::get_format_from_modifiers( $exploded, esc_html__( '%s ago', 'gravityview' ) ); |
|
| 133 | + $relative_format = self::get_format_from_modifiers($exploded, esc_html__('%s ago', 'gravityview')); |
|
| 134 | 134 | |
| 135 | - $formatted_date = sprintf( $relative_format, human_time_diff( $entry_gmt_time ) ); |
|
| 135 | + $formatted_date = sprintf($relative_format, human_time_diff($entry_gmt_time)); |
|
| 136 | 136 | |
| 137 | 137 | } else { |
| 138 | 138 | |
| 139 | - $include_time = in_array( 'time', $exploded ); // {date_created:time} |
|
| 140 | - $match_date_format = self::get_format_from_modifiers( $exploded, $site_date_format ); |
|
| 139 | + $include_time = in_array('time', $exploded); // {date_created:time} |
|
| 140 | + $match_date_format = self::get_format_from_modifiers($exploded, $site_date_format); |
|
| 141 | 141 | |
| 142 | - $formatted_date = GFCommon::format_date( $date_created, $is_human, $match_date_format, $include_time ); |
|
| 142 | + $formatted_date = GFCommon::format_date($date_created, $is_human, $match_date_format, $include_time); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | return $formatted_date; |
@@ -158,16 +158,16 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return string If format is found, the passed format. Otherwise, the backup. |
| 160 | 160 | */ |
| 161 | - private static function get_format_from_modifiers( $exploded, $backup = '' ) { |
|
| 161 | + private static function get_format_from_modifiers($exploded, $backup = '') { |
|
| 162 | 162 | |
| 163 | 163 | $return = $backup; |
| 164 | 164 | |
| 165 | - $format_key_index = array_search( 'format', $exploded ); |
|
| 165 | + $format_key_index = array_search('format', $exploded); |
|
| 166 | 166 | |
| 167 | 167 | // If there's a "format:[php date format string]" date format, grab it |
| 168 | - if ( false !== $format_key_index && isset( $exploded[ $format_key_index + 1 ] ) ) { |
|
| 168 | + if (false !== $format_key_index && isset($exploded[$format_key_index + 1])) { |
|
| 169 | 169 | // Return escaped colons placeholder |
| 170 | - $return = str_replace( '|COLON|', ':', $exploded[ $format_key_index + 1 ] ); |
|
| 170 | + $return = str_replace('|COLON|', ':', $exploded[$format_key_index + 1]); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $return; |
@@ -194,22 +194,22 @@ discard block |
||
| 194 | 194 | * @param array $entry Entry array |
| 195 | 195 | * @param bool $url_encode Whether to URL-encode output |
| 196 | 196 | */ |
| 197 | - public static function replace_get_variables( $text, $form = array(), $entry = array(), $url_encode = false ) { |
|
| 197 | + public static function replace_get_variables($text, $form = array(), $entry = array(), $url_encode = false) { |
|
| 198 | 198 | |
| 199 | 199 | // Is there is {get:[xyz]} merge tag? |
| 200 | - preg_match_all( "/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER ); |
|
| 200 | + preg_match_all("/{get:(.*?)}/ism", $text, $matches, PREG_SET_ORDER); |
|
| 201 | 201 | |
| 202 | 202 | // If there are no matches OR the Entry `created_by` isn't set or is 0 (no user) |
| 203 | - if( empty( $matches ) ) { |
|
| 203 | + if (empty($matches)) { |
|
| 204 | 204 | return $text; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - foreach ( $matches as $match ) { |
|
| 207 | + foreach ($matches as $match) { |
|
| 208 | 208 | |
| 209 | 209 | $full_tag = $match[0]; |
| 210 | 210 | $property = $match[1]; |
| 211 | 211 | |
| 212 | - $value = stripslashes_deep( rgget( $property ) ); |
|
| 212 | + $value = stripslashes_deep(rgget($property)); |
|
| 213 | 213 | |
| 214 | 214 | /** |
| 215 | 215 | * @filter `gravityview/merge_tags/get/glue/` Modify the glue used to convert an array of `{get}` values from an array to string |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | * @param[in,out] string $glue String used to `implode()` $_GET values Default: ', ' |
| 218 | 218 | * @param[in] string $property The current name of the $_GET parameter being combined |
| 219 | 219 | */ |
| 220 | - $glue = apply_filters( 'gravityview/merge_tags/get/glue/', ', ', $property ); |
|
| 220 | + $glue = apply_filters('gravityview/merge_tags/get/glue/', ', ', $property); |
|
| 221 | 221 | |
| 222 | - $value = is_array( $value ) ? implode( $glue, $value ) : $value; |
|
| 222 | + $value = is_array($value) ? implode($glue, $value) : $value; |
|
| 223 | 223 | |
| 224 | - $value = $url_encode ? urlencode( $value ) : $value; |
|
| 224 | + $value = $url_encode ? urlencode($value) : $value; |
|
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Disable esc_html() from running on `{get}` merge tag |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | * @since 1.15 |
| 232 | 232 | * @param bool $esc_html Whether to esc_html() the value. Default: `true` |
| 233 | 233 | */ |
| 234 | - $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/' . $property, true ); |
|
| 234 | + $esc_html = apply_filters('gravityview/merge_tags/get/esc_html/'.$property, true); |
|
| 235 | 235 | |
| 236 | - $value = $esc_html ? esc_html( $value ) : $value; |
|
| 236 | + $value = $esc_html ? esc_html($value) : $value; |
|
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | 239 | * @filter `gravityview/merge_tags/get/esc_html/{url parameter name}` Modify the value of the `{get}` replacement before being used |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | * @param[in] array $form Gravity Forms form array |
| 243 | 243 | * @param[in] array $entry Entry array |
| 244 | 244 | */ |
| 245 | - $value = apply_filters('gravityview/merge_tags/get/value/' . $property, $value, $text, $form, $entry ); |
|
| 245 | + $value = apply_filters('gravityview/merge_tags/get/value/'.$property, $value, $text, $form, $entry); |
|
| 246 | 246 | |
| 247 | - $text = str_replace( $full_tag, $value, $text ); |
|
| 247 | + $text = str_replace($full_tag, $value, $text); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - unset( $value, $glue, $matches ); |
|
| 250 | + unset($value, $glue, $matches); |
|
| 251 | 251 | |
| 252 | 252 | return $text; |
| 253 | 253 | } |
@@ -67,7 +67,6 @@ |
||
| 67 | 67 | * |
| 68 | 68 | * @since 1.15 |
| 69 | 69 | * |
| 70 | - * @param array $allcaps An array of all the user's capabilities. |
|
| 71 | 70 | * @param array $caps Actual capabilities for meta capability. |
| 72 | 71 | * @param array $args Optional parameters passed to has_cap(), typically object ID. |
| 73 | 72 | * @param WP_User|null $user The user object, in WordPress 3.7.0 or higher |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
| 57 | 57 | add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
| 58 | 58 | add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 59 | + add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -360,7 +360,6 @@ discard block |
||
| 360 | 360 | * Add Gravity Forms and GravityView's "full access" caps when any other caps are checked against. |
| 361 | 361 | * |
| 362 | 362 | * @since 1.15 |
| 363 | - |
|
| 364 | 363 | * @param array $caps_to_check |
| 365 | 364 | * |
| 366 | 365 | * @return array |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly |
| 14 | -defined( 'ABSPATH' ) || exit; |
|
| 14 | +defined('ABSPATH') || exit; |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * GravityView Roles Class |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public static function get_instance() { |
| 35 | 35 | |
| 36 | - if( ! self::$instance ) { |
|
| 36 | + if (!self::$instance) { |
|
| 37 | 37 | self::$instance = new self; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | * @since 1.15 |
| 54 | 54 | */ |
| 55 | 55 | private function add_hooks() { |
| 56 | - add_filter( 'members_get_capabilities', array( 'GravityView_Roles_Capabilities', 'merge_with_all_caps' ) ); |
|
| 57 | - add_action( 'members_register_cap_groups', array( $this, 'members_register_cap_group' ), 20 ); |
|
| 58 | - add_filter( 'user_has_cap', array( $this, 'filter_user_has_cap' ), 10, 4 ); |
|
| 59 | - add_action( 'admin_init', array( $this, 'add_caps') ); |
|
| 56 | + add_filter('members_get_capabilities', array('GravityView_Roles_Capabilities', 'merge_with_all_caps')); |
|
| 57 | + add_action('members_register_cap_groups', array($this, 'members_register_cap_group'), 20); |
|
| 58 | + add_filter('user_has_cap', array($this, 'filter_user_has_cap'), 10, 4); |
|
| 59 | + add_action('admin_init', array($this, 'add_caps')); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
@@ -74,28 +74,28 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return mixed |
| 76 | 76 | */ |
| 77 | - public function filter_user_has_cap( $usercaps = array(), $caps = array(), $args = array(), $user = NULL ) { |
|
| 77 | + public function filter_user_has_cap($usercaps = array(), $caps = array(), $args = array(), $user = NULL) { |
|
| 78 | 78 | |
| 79 | 79 | // Empty caps_to_check array |
| 80 | - if( ! $usercaps || ! $caps ) { |
|
| 80 | + if (!$usercaps || !$caps) { |
|
| 81 | 81 | return $usercaps; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Enable all GravityView caps_to_check if `gravityview_full_access` is enabled |
| 86 | 86 | */ |
| 87 | - if( ! empty( $usercaps['gravityview_full_access'] ) ) { |
|
| 87 | + if (!empty($usercaps['gravityview_full_access'])) { |
|
| 88 | 88 | |
| 89 | 89 | $all_gravityview_caps = self::all_caps(); |
| 90 | 90 | |
| 91 | - foreach( $all_gravityview_caps as $gv_cap ) { |
|
| 92 | - $usercaps[ $gv_cap ] = true; |
|
| 91 | + foreach ($all_gravityview_caps as $gv_cap) { |
|
| 92 | + $usercaps[$gv_cap] = true; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - unset( $all_gravityview_caps ); |
|
| 95 | + unset($all_gravityview_caps); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - $usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps( $usercaps ); |
|
| 98 | + $usercaps = $this->add_gravity_forms_usercaps_to_gravityview_caps($usercaps); |
|
| 99 | 99 | |
| 100 | 100 | return $usercaps; |
| 101 | 101 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return array |
| 116 | 116 | */ |
| 117 | - private function add_gravity_forms_usercaps_to_gravityview_caps( $usercaps ) { |
|
| 117 | + private function add_gravity_forms_usercaps_to_gravityview_caps($usercaps) { |
|
| 118 | 118 | |
| 119 | 119 | $gf_to_gv_caps = array( |
| 120 | 120 | 'gravityforms_edit_entries' => 'gravityview_edit_others_entries', |
@@ -122,9 +122,9 @@ discard block |
||
| 122 | 122 | 'gravityforms_edit_entry_notes' => 'gravityview_edit_others_entry_notes', |
| 123 | 123 | ); |
| 124 | 124 | |
| 125 | - foreach ( $gf_to_gv_caps as $gf_cap => $gv_cap ) { |
|
| 126 | - if ( isset( $usercaps[ $gf_cap ] ) && ! isset( $usercaps[ $gv_cap ] ) ) { |
|
| 127 | - $usercaps[ $gv_cap ] = $usercaps[ $gf_cap ]; |
|
| 125 | + foreach ($gf_to_gv_caps as $gf_cap => $gv_cap) { |
|
| 126 | + if (isset($usercaps[$gf_cap]) && !isset($usercaps[$gv_cap])) { |
|
| 127 | + $usercaps[$gv_cap] = $usercaps[$gf_cap]; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -138,17 +138,17 @@ discard block |
||
| 138 | 138 | * @return void |
| 139 | 139 | */ |
| 140 | 140 | function members_register_cap_group() { |
| 141 | - if ( function_exists( 'members_register_cap_group' ) ) { |
|
| 141 | + if (function_exists('members_register_cap_group')) { |
|
| 142 | 142 | |
| 143 | 143 | $args = array( |
| 144 | - 'label' => __( 'GravityView', 'gravityview' ), |
|
| 144 | + 'label' => __('GravityView', 'gravityview'), |
|
| 145 | 145 | 'icon' => 'gv-icon-astronaut-head', |
| 146 | 146 | 'caps' => self::all_caps(), |
| 147 | 147 | 'merge_added' => true, |
| 148 | 148 | 'diff_added' => false, |
| 149 | 149 | ); |
| 150 | 150 | |
| 151 | - members_register_cap_group( 'gravityview', $args ); |
|
| 151 | + members_register_cap_group('gravityview', $args); |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | |
@@ -159,11 +159,11 @@ discard block |
||
| 159 | 159 | * @param array $caps Existing capabilities |
| 160 | 160 | * @return array Modified capabilities array |
| 161 | 161 | */ |
| 162 | - public static function merge_with_all_caps( $caps ) { |
|
| 162 | + public static function merge_with_all_caps($caps) { |
|
| 163 | 163 | |
| 164 | - $return_caps = array_merge( $caps, self::all_caps() ); |
|
| 164 | + $return_caps = array_merge($caps, self::all_caps()); |
|
| 165 | 165 | |
| 166 | - return array_unique( $return_caps ); |
|
| 166 | + return array_unique($return_caps); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | private function wp_roles() { |
| 179 | 179 | global $wp_roles; |
| 180 | 180 | |
| 181 | - if ( ! isset( $wp_roles ) ) { |
|
| 181 | + if (!isset($wp_roles)) { |
|
| 182 | 182 | $wp_roles = new WP_Roles(); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | $wp_roles = $this->wp_roles(); |
| 198 | 198 | |
| 199 | - if ( is_object( $wp_roles ) ) { |
|
| 199 | + if (is_object($wp_roles)) { |
|
| 200 | 200 | |
| 201 | 201 | $_use_db_backup = $wp_roles->use_db; |
| 202 | 202 | |
@@ -206,11 +206,11 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | $wp_roles->use_db = false; |
| 208 | 208 | |
| 209 | - $capabilities = self::all_caps( false, false ); |
|
| 209 | + $capabilities = self::all_caps(false, false); |
|
| 210 | 210 | |
| 211 | - foreach ( $capabilities as $role_slug => $role_caps ) { |
|
| 212 | - foreach ( $role_caps as $cap ) { |
|
| 213 | - $wp_roles->add_cap( $role_slug, $cap ); |
|
| 211 | + foreach ($capabilities as $role_slug => $role_caps) { |
|
| 212 | + foreach ($role_caps as $cap) { |
|
| 213 | + $wp_roles->add_cap($role_slug, $cap); |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | * |
| 220 | 220 | * @see WP_Roles::add_cap() Original code |
| 221 | 221 | */ |
| 222 | - update_option( $wp_roles->role_key, $wp_roles->roles ); |
|
| 222 | + update_option($wp_roles->role_key, $wp_roles->roles); |
|
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | 225 | * Restore previous $use_db setting |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * |
| 241 | 241 | * @return array If $role is set, flat array of caps_to_check. Otherwise, a multi-dimensional array of roles and their caps_to_check with the following keys: 'administrator', 'editor', 'author', 'contributor', 'subscriber' |
| 242 | 242 | */ |
| 243 | - public static function all_caps( $single_role = false, $flat_array = true ) { |
|
| 243 | + public static function all_caps($single_role = false, $flat_array = true) { |
|
| 244 | 244 | |
| 245 | 245 | // Change settings |
| 246 | 246 | $administrator_caps = array( |
@@ -297,20 +297,20 @@ discard block |
||
| 297 | 297 | ); |
| 298 | 298 | |
| 299 | 299 | $subscriber = $subscriber_caps; |
| 300 | - $contributor = array_merge( $contributor_caps, $subscriber_caps ); |
|
| 301 | - $author = array_merge( $author_caps, $contributor_caps, $subscriber_caps ); |
|
| 302 | - $editor = array_merge( $editor_caps, $author_caps, $contributor_caps, $subscriber_caps ); |
|
| 303 | - $administrator = array_merge( $administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps ); |
|
| 300 | + $contributor = array_merge($contributor_caps, $subscriber_caps); |
|
| 301 | + $author = array_merge($author_caps, $contributor_caps, $subscriber_caps); |
|
| 302 | + $editor = array_merge($editor_caps, $author_caps, $contributor_caps, $subscriber_caps); |
|
| 303 | + $administrator = array_merge($administrator_caps, $editor_caps, $author_caps, $contributor_caps, $subscriber_caps); |
|
| 304 | 304 | $all = $administrator; |
| 305 | 305 | |
| 306 | 306 | // If role is set, return caps_to_check for just that role. |
| 307 | - if( $single_role ) { |
|
| 308 | - $caps = isset( ${$single_role} ) ? ${$single_role} : false; |
|
| 309 | - return $flat_array ? $caps : array( $single_role => $caps ); |
|
| 307 | + if ($single_role) { |
|
| 308 | + $caps = isset(${$single_role} ) ? ${$single_role} : false; |
|
| 309 | + return $flat_array ? $caps : array($single_role => $caps); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Otherwise, return multi-dimensional array of all caps_to_check |
| 313 | - return $flat_array ? $all : compact( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 313 | + return $flat_array ? $all : compact('administrator', 'editor', 'author', 'contributor', 'subscriber'); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | * |
| 331 | 331 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
| 332 | 332 | */ |
| 333 | - public static function has_cap( $caps_to_check = '', $object_id = null, $user_id = null ) { |
|
| 333 | + public static function has_cap($caps_to_check = '', $object_id = null, $user_id = null) { |
|
| 334 | 334 | |
| 335 | 335 | $has_cap = false; |
| 336 | 336 | |
| 337 | - if( empty( $caps_to_check ) ) { |
|
| 337 | + if (empty($caps_to_check)) { |
|
| 338 | 338 | return $has_cap; |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | // Add full access caps for GV & GF |
| 342 | - $caps_to_check = self::maybe_add_full_access_caps( $caps_to_check ); |
|
| 342 | + $caps_to_check = self::maybe_add_full_access_caps($caps_to_check); |
|
| 343 | 343 | |
| 344 | - foreach ( $caps_to_check as $cap ) { |
|
| 345 | - if( ! is_null( $object_id ) ) { |
|
| 346 | - $has_cap = $user_id ? user_can( $user_id, $cap, $object_id ) : current_user_can( $cap, $object_id ); |
|
| 344 | + foreach ($caps_to_check as $cap) { |
|
| 345 | + if (!is_null($object_id)) { |
|
| 346 | + $has_cap = $user_id ? user_can($user_id, $cap, $object_id) : current_user_can($cap, $object_id); |
|
| 347 | 347 | } else { |
| 348 | - $has_cap = $user_id ? user_can( $user_id, $cap ) : current_user_can( $cap ); |
|
| 348 | + $has_cap = $user_id ? user_can($user_id, $cap) : current_user_can($cap); |
|
| 349 | 349 | } |
| 350 | 350 | // At the first successful response, stop checking |
| 351 | - if( $has_cap ) { |
|
| 351 | + if ($has_cap) { |
|
| 352 | 352 | break; |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -365,25 +365,25 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @return array |
| 367 | 367 | */ |
| 368 | - public static function maybe_add_full_access_caps( $caps_to_check = array() ) { |
|
| 368 | + public static function maybe_add_full_access_caps($caps_to_check = array()) { |
|
| 369 | 369 | |
| 370 | 370 | $caps_to_check = (array)$caps_to_check; |
| 371 | 371 | |
| 372 | 372 | $all_gravityview_caps = self::all_caps(); |
| 373 | 373 | |
| 374 | 374 | // Are there any $caps_to_check that are from GravityView? |
| 375 | - if( $has_gravityview_caps = array_intersect( $caps_to_check, $all_gravityview_caps ) ) { |
|
| 375 | + if ($has_gravityview_caps = array_intersect($caps_to_check, $all_gravityview_caps)) { |
|
| 376 | 376 | $caps_to_check[] = 'gravityview_full_access'; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - $all_gravity_forms_caps = class_exists( 'GFCommon' ) ? GFCommon::all_caps() : array(); |
|
| 379 | + $all_gravity_forms_caps = class_exists('GFCommon') ? GFCommon::all_caps() : array(); |
|
| 380 | 380 | |
| 381 | 381 | // Are there any $caps_to_check that are from Gravity Forms? |
| 382 | - if( $all_gravity_forms_caps = array_intersect( $caps_to_check, $all_gravity_forms_caps ) ) { |
|
| 382 | + if ($all_gravity_forms_caps = array_intersect($caps_to_check, $all_gravity_forms_caps)) { |
|
| 383 | 383 | $caps_to_check[] = 'gform_full_access'; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - return array_unique( $caps_to_check ); |
|
| 386 | + return array_unique($caps_to_check); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -396,19 +396,19 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | $wp_roles = $this->wp_roles(); |
| 398 | 398 | |
| 399 | - if ( is_object( $wp_roles ) ) { |
|
| 399 | + if (is_object($wp_roles)) { |
|
| 400 | 400 | |
| 401 | 401 | /** Remove all GravityView caps_to_check from all roles */ |
| 402 | 402 | $capabilities = self::all_caps(); |
| 403 | 403 | |
| 404 | 404 | // Loop through each role and remove GV caps_to_check |
| 405 | - foreach( $wp_roles->get_names() as $role_slug => $role_name ) { |
|
| 406 | - foreach ( $capabilities as $cap ) { |
|
| 407 | - $wp_roles->remove_cap( $role_slug, $cap ); |
|
| 405 | + foreach ($wp_roles->get_names() as $role_slug => $role_name) { |
|
| 406 | + foreach ($capabilities as $cap) { |
|
| 407 | + $wp_roles->remove_cap($role_slug, $cap); |
|
| 408 | 408 | } |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | -add_action( 'init', array( 'GravityView_Roles_Capabilities', 'get_instance' ), 1 ); |
|
| 415 | 414 | \ No newline at end of file |
| 415 | +add_action('init', array('GravityView_Roles_Capabilities', 'get_instance'), 1); |
|
| 416 | 416 | \ No newline at end of file |
@@ -37,6 +37,9 @@ discard block |
||
| 37 | 37 | public $active_areas; |
| 38 | 38 | |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $id |
|
| 42 | + */ |
|
| 40 | 43 | function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) { |
| 41 | 44 | |
| 42 | 45 | if ( empty( $id ) ) { |
@@ -144,6 +147,9 @@ discard block |
||
| 144 | 147 | return $areas; |
| 145 | 148 | } |
| 146 | 149 | |
| 150 | + /** |
|
| 151 | + * @param string $context |
|
| 152 | + */ |
|
| 147 | 153 | public function get_active_areas( $context ) { |
| 148 | 154 | if ( isset( $this->active_areas[ $context ] ) ) { |
| 149 | 155 | return $this->active_areas[ $context ]; |
@@ -156,8 +162,8 @@ discard block |
||
| 156 | 162 | /** |
| 157 | 163 | * Assign template specific field options |
| 158 | 164 | * |
| 159 | - * @param array $options (default: array()) |
|
| 160 | - * @param string $template (default: '') |
|
| 165 | + * @param array $field_options (default: array()) |
|
| 166 | + * @param string $template_id (default: '') |
|
| 161 | 167 | * @param string $field_id key for the field |
| 162 | 168 | * @param string|array $context Context for the field; `directory` or `single` for example. |
| 163 | 169 | * |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | public $active_areas; |
| 38 | 38 | |
| 39 | 39 | |
| 40 | - function __construct( $id, $settings = array(), $field_options = array(), $areas = array() ) { |
|
| 40 | + function __construct($id, $settings = array(), $field_options = array(), $areas = array()) { |
|
| 41 | 41 | |
| 42 | - if ( empty( $id ) ) { |
|
| 42 | + if (empty($id)) { |
|
| 43 | 43 | return; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $this->template_id = $id; |
| 47 | 47 | |
| 48 | - $this->merge_defaults( $settings ); |
|
| 48 | + $this->merge_defaults($settings); |
|
| 49 | 49 | |
| 50 | 50 | $this->field_options = $field_options; |
| 51 | 51 | $this->active_areas = $areas; |
@@ -60,25 +60,25 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | private function add_hooks() { |
| 62 | 62 | |
| 63 | - add_filter( 'gravityview_register_directory_template', array( $this, 'register_template' ) ); |
|
| 63 | + add_filter('gravityview_register_directory_template', array($this, 'register_template')); |
|
| 64 | 64 | |
| 65 | 65 | // presets hooks: |
| 66 | 66 | // form xml |
| 67 | - add_filter( 'gravityview_template_formxml', array( $this, 'assign_form_xml' ), 10, 2 ); |
|
| 67 | + add_filter('gravityview_template_formxml', array($this, 'assign_form_xml'), 10, 2); |
|
| 68 | 68 | // fields config xml |
| 69 | - add_filter( 'gravityview_template_fieldsxml', array( $this, 'assign_fields_xml' ), 10, 2 ); |
|
| 69 | + add_filter('gravityview_template_fieldsxml', array($this, 'assign_fields_xml'), 10, 2); |
|
| 70 | 70 | |
| 71 | 71 | // assign active areas |
| 72 | - add_filter( 'gravityview_template_active_areas', array( $this, 'assign_active_areas' ), 10, 3 ); |
|
| 72 | + add_filter('gravityview_template_active_areas', array($this, 'assign_active_areas'), 10, 3); |
|
| 73 | 73 | |
| 74 | 74 | // field options |
| 75 | - add_filter( 'gravityview_template_field_options', array( $this, 'assign_field_options' ), 10, 4 ); |
|
| 75 | + add_filter('gravityview_template_field_options', array($this, 'assign_field_options'), 10, 4); |
|
| 76 | 76 | |
| 77 | 77 | // template slug |
| 78 | - add_filter( "gravityview_template_slug_{$this->template_id}", array( $this, 'assign_view_slug' ), 10, 2 ); |
|
| 78 | + add_filter("gravityview_template_slug_{$this->template_id}", array($this, 'assign_view_slug'), 10, 2); |
|
| 79 | 79 | |
| 80 | 80 | // register template CSS |
| 81 | - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) ); |
|
| 81 | + add_action('wp_enqueue_scripts', array($this, 'register_styles')); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return array Merged template settings. |
| 92 | 92 | */ |
| 93 | - private function merge_defaults( $settings = array() ) { |
|
| 93 | + private function merge_defaults($settings = array()) { |
|
| 94 | 94 | |
| 95 | 95 | $defaults = array( |
| 96 | 96 | 'slug' => '', |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | 'preset_fields' => '' |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - $this->settings = wp_parse_args( $settings, $defaults ); |
|
| 108 | + $this->settings = wp_parse_args($settings, $defaults); |
|
| 109 | 109 | |
| 110 | 110 | return $this->settings; |
| 111 | 111 | } |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @return array Array of templates available for GV |
| 121 | 121 | */ |
| 122 | - public function register_template( $templates ) { |
|
| 123 | - $templates[ $this->template_id ] = $this->settings; |
|
| 122 | + public function register_template($templates) { |
|
| 123 | + $templates[$this->template_id] = $this->settings; |
|
| 124 | 124 | |
| 125 | 125 | return $templates; |
| 126 | 126 | } |
@@ -136,17 +136,17 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return array Array of active areas |
| 138 | 138 | */ |
| 139 | - public function assign_active_areas( $areas, $template = '', $context = 'directory' ) { |
|
| 140 | - if ( $this->template_id === $template ) { |
|
| 141 | - $areas = $this->get_active_areas( $context ); |
|
| 139 | + public function assign_active_areas($areas, $template = '', $context = 'directory') { |
|
| 140 | + if ($this->template_id === $template) { |
|
| 141 | + $areas = $this->get_active_areas($context); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | return $areas; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function get_active_areas( $context ) { |
|
| 148 | - if ( isset( $this->active_areas[ $context ] ) ) { |
|
| 149 | - return $this->active_areas[ $context ]; |
|
| 147 | + public function get_active_areas($context) { |
|
| 148 | + if (isset($this->active_areas[$context])) { |
|
| 149 | + return $this->active_areas[$context]; |
|
| 150 | 150 | } else { |
| 151 | 151 | return $this->active_areas; |
| 152 | 152 | } |
@@ -163,21 +163,21 @@ discard block |
||
| 163 | 163 | * |
| 164 | 164 | * @return array Array of field options |
| 165 | 165 | */ |
| 166 | - public function assign_field_options( $field_options, $template_id, $field_id = NULL, $context = 'directory' ) { |
|
| 166 | + public function assign_field_options($field_options, $template_id, $field_id = NULL, $context = 'directory') { |
|
| 167 | 167 | |
| 168 | - if ( $this->template_id === $template_id ) { |
|
| 168 | + if ($this->template_id === $template_id) { |
|
| 169 | 169 | |
| 170 | - foreach ( $this->field_options as $key => $field_option ) { |
|
| 170 | + foreach ($this->field_options as $key => $field_option) { |
|
| 171 | 171 | |
| 172 | - $field_context = rgar( $field_option, 'context' ); |
|
| 172 | + $field_context = rgar($field_option, 'context'); |
|
| 173 | 173 | |
| 174 | 174 | // Does the field option only apply to a certain context? |
| 175 | 175 | // You can define multiple contexts as an array: `context => array("directory", "single")` |
| 176 | - $context_matches = is_array( $field_context ) ? in_array( $context, $field_context ) : $context === $field_context; |
|
| 176 | + $context_matches = is_array($field_context) ? in_array($context, $field_context) : $context === $field_context; |
|
| 177 | 177 | |
| 178 | 178 | // If the context matches (or isn't defined), add the field options. |
| 179 | - if ( $context_matches ) { |
|
| 180 | - $field_options[ $key ] = $field_option; |
|
| 179 | + if ($context_matches) { |
|
| 180 | + $field_options[$key] = $field_option; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | } |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | * @see GravityView_Admin_Views::create_preset_form() |
| 193 | 193 | * @return string Path to XML file |
| 194 | 194 | */ |
| 195 | - public function assign_form_xml( $xml = '', $template = '' ) { |
|
| 196 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_form'] ) && $this->template_id === $template ) { |
|
| 195 | + public function assign_form_xml($xml = '', $template = '') { |
|
| 196 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_form']) && $this->template_id === $template) { |
|
| 197 | 197 | return $this->settings['preset_form']; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | * @see GravityView_Admin_Views::pre_get_form_fields() |
| 207 | 207 | * @return string Path to XML file |
| 208 | 208 | */ |
| 209 | - public function assign_fields_xml( $xml = '', $template = '' ) { |
|
| 210 | - if ( $this->settings['type'] === 'preset' && ! empty( $this->settings['preset_fields'] ) && $this->template_id === $template ) { |
|
| 209 | + public function assign_fields_xml($xml = '', $template = '') { |
|
| 210 | + if ($this->settings['type'] === 'preset' && !empty($this->settings['preset_fields']) && $this->template_id === $template) { |
|
| 211 | 211 | return $this->settings['preset_fields']; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -224,12 +224,12 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @return string |
| 226 | 226 | */ |
| 227 | - public function assign_view_slug( $default, $context ) { |
|
| 227 | + public function assign_view_slug($default, $context) { |
|
| 228 | 228 | |
| 229 | - if ( ! empty( $this->settings['slug'] ) ) { |
|
| 229 | + if (!empty($this->settings['slug'])) { |
|
| 230 | 230 | return $this->settings['slug']; |
| 231 | 231 | } |
| 232 | - if ( ! empty( $default ) ) { |
|
| 232 | + if (!empty($default)) { |
|
| 233 | 233 | return $default; |
| 234 | 234 | } |
| 235 | 235 | |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | * @return void |
| 245 | 245 | */ |
| 246 | 246 | public function register_styles() { |
| 247 | - if ( ! empty( $this->settings['css_source'] ) ) { |
|
| 248 | - wp_register_style( 'gravityview_style_' . $this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all' ); |
|
| 247 | + if (!empty($this->settings['css_source'])) { |
|
| 248 | + wp_register_style('gravityview_style_'.$this->template_id, $this->settings['css_source'], array(), GravityView_Plugin::version, 'all'); |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -53,6 +53,9 @@ discard block |
||
| 53 | 53 | add_action( 'wp_ajax_gravityview_license', array( $this, 'license_call' ) ); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | + /** |
|
| 57 | + * @param boolean $echo |
|
| 58 | + */ |
|
| 56 | 59 | function settings_edd_license_activation( $field, $echo ) { |
| 57 | 60 | |
| 58 | 61 | wp_enqueue_script( 'gv-admin-edd-license', GRAVITYVIEW_URL . 'assets/js/admin-edd-license.js', array( 'jquery' ) ); |
@@ -241,7 +244,7 @@ discard block |
||
| 241 | 244 | * Generate the status message box HTML based on the current status |
| 242 | 245 | * |
| 243 | 246 | * @since 1.7.4 |
| 244 | - * @param $message |
|
| 247 | + * @param string $message |
|
| 245 | 248 | * @param string $class |
| 246 | 249 | * |
| 247 | 250 | * @return string |
@@ -340,7 +340,7 @@ |
||
| 340 | 340 | // Update option with passed data license |
| 341 | 341 | $settings = $this->Addon->get_app_settings(); |
| 342 | 342 | |
| 343 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 343 | + $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 344 | 344 | $settings['license_key_status'] = $license_data->license; |
| 345 | 345 | $settings['license_key_response'] = (array)$license_data; |
| 346 | 346 | |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return GV_License_Handler |
| 35 | 35 | */ |
| 36 | - public static function get_instance( GravityView_Settings $GFAddOn ) { |
|
| 37 | - if( empty( self::$instance ) ) { |
|
| 38 | - self::$instance = new self( $GFAddOn ); |
|
| 36 | + public static function get_instance(GravityView_Settings $GFAddOn) { |
|
| 37 | + if (empty(self::$instance)) { |
|
| 38 | + self::$instance = new self($GFAddOn); |
|
| 39 | 39 | } |
| 40 | 40 | return self::$instance; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - private function __construct( GravityView_Settings $GFAddOn ) { |
|
| 43 | + private function __construct(GravityView_Settings $GFAddOn) { |
|
| 44 | 44 | |
| 45 | 45 | $this->Addon = $GFAddOn; |
| 46 | 46 | |
@@ -50,25 +50,25 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | private function add_hooks() { |
| 53 | - add_action( 'wp_ajax_gravityview_license', array( $this, 'license_call' ) ); |
|
| 53 | + add_action('wp_ajax_gravityview_license', array($this, 'license_call')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - function settings_edd_license_activation( $field, $echo ) { |
|
| 56 | + function settings_edd_license_activation($field, $echo) { |
|
| 57 | 57 | |
| 58 | - wp_enqueue_script( 'gv-admin-edd-license', GRAVITYVIEW_URL . 'assets/js/admin-edd-license.js', array( 'jquery' ) ); |
|
| 58 | + wp_enqueue_script('gv-admin-edd-license', GRAVITYVIEW_URL.'assets/js/admin-edd-license.js', array('jquery')); |
|
| 59 | 59 | |
| 60 | - $status = trim( $this->Addon->get_app_setting( 'license_key_status' ) ); |
|
| 61 | - $key = trim( $this->Addon->get_app_setting( 'license_key' ) ); |
|
| 60 | + $status = trim($this->Addon->get_app_setting('license_key_status')); |
|
| 61 | + $key = trim($this->Addon->get_app_setting('license_key')); |
|
| 62 | 62 | |
| 63 | - if( !empty( $key ) ) { |
|
| 64 | - $response = $this->Addon->get_app_setting( 'license_key_response' ); |
|
| 65 | - $response = is_array( $response ) ? (object) $response : json_decode( $response ); |
|
| 63 | + if (!empty($key)) { |
|
| 64 | + $response = $this->Addon->get_app_setting('license_key_response'); |
|
| 65 | + $response = is_array($response) ? (object)$response : json_decode($response); |
|
| 66 | 66 | } else { |
| 67 | 67 | $response = array(); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - wp_localize_script( 'gv-admin-edd-license', 'GVGlobals', array( |
|
| 71 | - 'license_box' => $this->get_license_message( $response ) |
|
| 70 | + wp_localize_script('gv-admin-edd-license', 'GVGlobals', array( |
|
| 71 | + 'license_box' => $this->get_license_message($response) |
|
| 72 | 72 | )); |
| 73 | 73 | |
| 74 | 74 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | 'value' => __('Deactivate License', 'gravityview'), |
| 86 | 86 | 'data-pending_text' => __('Deactivating license…', 'gravityview'), |
| 87 | 87 | 'data-edd_action' => 'deactivate_license', |
| 88 | - 'class' => ( empty( $status ) ? 'button-primary hide' : 'button-primary' ), |
|
| 88 | + 'class' => (empty($status) ? 'button-primary hide' : 'button-primary'), |
|
| 89 | 89 | ), |
| 90 | 90 | array( |
| 91 | 91 | 'name' => 'edd-check', |
@@ -100,19 +100,19 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $class = 'button gv-edd-action'; |
| 102 | 102 | |
| 103 | - $class .= ( !empty( $key ) && $status !== 'valid' ) ? '' : ' hide'; |
|
| 103 | + $class .= (!empty($key) && $status !== 'valid') ? '' : ' hide'; |
|
| 104 | 104 | |
| 105 | - $disabled_attribute = GVCommon::has_cap( 'gravityview_edit_settings' ) ? false : 'disabled'; |
|
| 105 | + $disabled_attribute = GVCommon::has_cap('gravityview_edit_settings') ? false : 'disabled'; |
|
| 106 | 106 | |
| 107 | 107 | $submit = '<div class="gv-edd-button-wrapper">'; |
| 108 | - foreach ( $fields as $field ) { |
|
| 108 | + foreach ($fields as $field) { |
|
| 109 | 109 | $field['type'] = 'button'; |
| 110 | - $field['class'] = isset( $field['class'] ) ? $field['class'] . ' '. $class : $class; |
|
| 110 | + $field['class'] = isset($field['class']) ? $field['class'].' '.$class : $class; |
|
| 111 | 111 | $field['style'] = 'margin-left: 10px;'; |
| 112 | - if( $disabled_attribute ) { |
|
| 112 | + if ($disabled_attribute) { |
|
| 113 | 113 | $field['disabled'] = $disabled_attribute; |
| 114 | 114 | } |
| 115 | - $submit .= $this->Addon->settings_submit( $field, $echo ); |
|
| 115 | + $submit .= $this->Addon->settings_submit($field, $echo); |
|
| 116 | 116 | } |
| 117 | 117 | $submit .= '</div>'; |
| 118 | 118 | |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | private function setup_edd() { |
| 128 | 128 | |
| 129 | - if( !class_exists('EDD_SL_Plugin_Updater') ) { |
|
| 130 | - require_once( GRAVITYVIEW_DIR . 'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
| 129 | + if (!class_exists('EDD_SL_Plugin_Updater')) { |
|
| 130 | + require_once(GRAVITYVIEW_DIR.'includes/lib/EDD_SL_Plugin_Updater.php'); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // setup the updater |
@@ -149,10 +149,10 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @return array |
| 151 | 151 | */ |
| 152 | - function _get_edd_settings( $action = '', $license = '' ) { |
|
| 152 | + function _get_edd_settings($action = '', $license = '') { |
|
| 153 | 153 | |
| 154 | 154 | // retrieve our license key from the DB |
| 155 | - $license_key = empty( $license ) ? trim( $this->Addon->get_app_setting( 'license_key' ) ) : $license; |
|
| 155 | + $license_key = empty($license) ? trim($this->Addon->get_app_setting('license_key')) : $license; |
|
| 156 | 156 | |
| 157 | 157 | $settings = array( |
| 158 | 158 | 'version' => self::version, |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | 'url' => home_url(), |
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | - if( !empty( $action ) ) { |
|
| 167 | - $settings['edd_action'] = esc_attr( $action ); |
|
| 166 | + if (!empty($action)) { |
|
| 167 | + $settings['edd_action'] = esc_attr($action); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $settings = array_map( 'urlencode', $settings ); |
|
| 170 | + $settings = array_map('urlencode', $settings); |
|
| 171 | 171 | |
| 172 | 172 | return $settings; |
| 173 | 173 | } |
@@ -176,27 +176,27 @@ discard block |
||
| 176 | 176 | * Perform the call |
| 177 | 177 | * @return array|WP_Error |
| 178 | 178 | */ |
| 179 | - private function _license_get_remote_response( $data, $license = '' ) { |
|
| 179 | + private function _license_get_remote_response($data, $license = '') { |
|
| 180 | 180 | |
| 181 | - $api_params = $this->_get_edd_settings( $data['edd_action'], $license ); |
|
| 181 | + $api_params = $this->_get_edd_settings($data['edd_action'], $license); |
|
| 182 | 182 | |
| 183 | - $url = add_query_arg( $api_params, self::url ); |
|
| 183 | + $url = add_query_arg($api_params, self::url); |
|
| 184 | 184 | |
| 185 | - $response = wp_remote_get( $url, array( |
|
| 185 | + $response = wp_remote_get($url, array( |
|
| 186 | 186 | 'timeout' => 15, |
| 187 | 187 | 'sslverify' => false, |
| 188 | 188 | )); |
| 189 | 189 | |
| 190 | - if ( is_wp_error( $response ) ) { |
|
| 190 | + if (is_wp_error($response)) { |
|
| 191 | 191 | return array(); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 194 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
| 195 | 195 | |
| 196 | 196 | // Not JSON |
| 197 | - if ( empty( $license_data ) ) { |
|
| 197 | + if (empty($license_data)) { |
|
| 198 | 198 | |
| 199 | - delete_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid' ); |
|
| 199 | + delete_transient('gravityview_'.esc_attr($data['field_id']).'_valid'); |
|
| 200 | 200 | |
| 201 | 201 | // Change status |
| 202 | 202 | return array(); |
@@ -216,14 +216,14 @@ discard block |
||
| 216 | 216 | * |
| 217 | 217 | * @return string |
| 218 | 218 | */ |
| 219 | - function get_license_message( $license_data ) { |
|
| 219 | + function get_license_message($license_data) { |
|
| 220 | 220 | |
| 221 | - if( empty( $license_data ) ) { |
|
| 221 | + if (empty($license_data)) { |
|
| 222 | 222 | $class = 'hide'; |
| 223 | 223 | $message = ''; |
| 224 | 224 | } else { |
| 225 | 225 | |
| 226 | - if( ! empty( $license_data->error ) ) { |
|
| 226 | + if (!empty($license_data->error)) { |
|
| 227 | 227 | $class = 'error'; |
| 228 | 228 | $string_key = $license_data->error; |
| 229 | 229 | } else { |
@@ -231,10 +231,10 @@ discard block |
||
| 231 | 231 | $string_key = $license_data->license; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - $message = sprintf( '<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings( $string_key, $license_data ) ); |
|
| 234 | + $message = sprintf('<p><strong>%s: %s</strong></p>', $this->strings('status'), $this->strings($string_key, $license_data)); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - return $this->generate_license_box( $message, $class ); |
|
| 237 | + return $this->generate_license_box($message, $class); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | * |
| 247 | 247 | * @return string |
| 248 | 248 | */ |
| 249 | - private function generate_license_box( $message, $class = '' ) { |
|
| 249 | + private function generate_license_box($message, $class = '') { |
|
| 250 | 250 | |
| 251 | 251 | $template = '<div id="gv-edd-status" class="gv-edd-message inline %s">%s</div>'; |
| 252 | 252 | |
| 253 | - $output = sprintf( $template, esc_attr( $class ), $message ); |
|
| 253 | + $output = sprintf($template, esc_attr($class), $message); |
|
| 254 | 254 | |
| 255 | 255 | return $output; |
| 256 | 256 | } |
@@ -270,63 +270,63 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @return mixed|string|void |
| 272 | 272 | */ |
| 273 | - public function license_call( $array = array() ) { |
|
| 273 | + public function license_call($array = array()) { |
|
| 274 | 274 | |
| 275 | - $is_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
| 276 | - $data = empty( $array ) ? $_POST['data'] : $array; |
|
| 277 | - $has_cap = GVCommon::has_cap( 'gravityview_edit_settings' ); |
|
| 275 | + $is_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
| 276 | + $data = empty($array) ? $_POST['data'] : $array; |
|
| 277 | + $has_cap = GVCommon::has_cap('gravityview_edit_settings'); |
|
| 278 | 278 | |
| 279 | - if ( $is_ajax && empty( $data['license'] ) ) { |
|
| 280 | - die( - 1 ); |
|
| 279 | + if ($is_ajax && empty($data['license'])) { |
|
| 280 | + die( -1 ); |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // If the user isn't allowed to edit settings, show an error message |
| 284 | - if( ! $has_cap ) { |
|
| 284 | + if (!$has_cap) { |
|
| 285 | 285 | $license_data = new stdClass(); |
| 286 | 286 | $license_data->error = 'capability'; |
| 287 | - $license_data->message = $this->get_license_message( $license_data ); |
|
| 288 | - $json = json_encode( $license_data ); |
|
| 287 | + $license_data->message = $this->get_license_message($license_data); |
|
| 288 | + $json = json_encode($license_data); |
|
| 289 | 289 | } else { |
| 290 | 290 | |
| 291 | - $license = esc_attr( rgget( 'license', $data ) ); |
|
| 292 | - $license_data = $this->_license_get_remote_response( $data, $license ); |
|
| 291 | + $license = esc_attr(rgget('license', $data)); |
|
| 292 | + $license_data = $this->_license_get_remote_response($data, $license); |
|
| 293 | 293 | |
| 294 | 294 | // Empty is returned when there's an error. |
| 295 | - if ( empty( $license_data ) ) { |
|
| 296 | - if ( $is_ajax ) { |
|
| 297 | - exit( json_encode( array() ) ); |
|
| 295 | + if (empty($license_data)) { |
|
| 296 | + if ($is_ajax) { |
|
| 297 | + exit(json_encode(array())); |
|
| 298 | 298 | } else { // Non-ajax call |
| 299 | - return json_encode( array() ); |
|
| 299 | + return json_encode(array()); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - $license_data->message = $this->get_license_message( $license_data ); |
|
| 303 | + $license_data->message = $this->get_license_message($license_data); |
|
| 304 | 304 | |
| 305 | - $json = json_encode( $license_data ); |
|
| 305 | + $json = json_encode($license_data); |
|
| 306 | 306 | |
| 307 | - $update_license = ( ! isset( $data['update'] ) || ! empty( $data['update'] ) ); |
|
| 307 | + $update_license = (!isset($data['update']) || !empty($data['update'])); |
|
| 308 | 308 | |
| 309 | - $is_check_action_button = ( 'check_license' === $data['edd_action'] && defined( 'DOING_AJAX' ) && DOING_AJAX ); |
|
| 309 | + $is_check_action_button = ('check_license' === $data['edd_action'] && defined('DOING_AJAX') && DOING_AJAX); |
|
| 310 | 310 | |
| 311 | 311 | // Failed is the response from trying to de-activate a license and it didn't work. |
| 312 | 312 | // This likely happened because people entered in a different key and clicked "Deactivate", |
| 313 | 313 | // meaning to deactivate the original key. We don't want to save this response, since it is |
| 314 | 314 | // most likely a mistake. |
| 315 | - if ( $license_data->license !== 'failed' && ! $is_check_action_button && $update_license ) { |
|
| 315 | + if ($license_data->license !== 'failed' && !$is_check_action_button && $update_license) { |
|
| 316 | 316 | |
| 317 | - if ( ! empty( $data['field_id'] ) ) { |
|
| 318 | - set_transient( 'gravityview_' . esc_attr( $data['field_id'] ) . '_valid', $license_data, DAY_IN_SECONDS ); |
|
| 317 | + if (!empty($data['field_id'])) { |
|
| 318 | + set_transient('gravityview_'.esc_attr($data['field_id']).'_valid', $license_data, DAY_IN_SECONDS); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - $this->license_call_update_settings( $license_data, $data ); |
|
| 321 | + $this->license_call_update_settings($license_data, $data); |
|
| 322 | 322 | |
| 323 | 323 | } |
| 324 | 324 | } // End $has_cap |
| 325 | 325 | |
| 326 | - if ( $is_ajax ) { |
|
| 327 | - exit( $json ); |
|
| 326 | + if ($is_ajax) { |
|
| 327 | + exit($json); |
|
| 328 | 328 | } else { // Non-ajax call |
| 329 | - return ( rgget('format', $data ) === 'object' ) ? $license_data : $json; |
|
| 329 | + return (rgget('format', $data) === 'object') ? $license_data : $json; |
|
| 330 | 330 | } |
| 331 | 331 | } |
| 332 | 332 | |
@@ -335,16 +335,16 @@ discard block |
||
| 335 | 335 | * @param object $license_data |
| 336 | 336 | * @return void |
| 337 | 337 | */ |
| 338 | - private function license_call_update_settings( $license_data, $data ) { |
|
| 338 | + private function license_call_update_settings($license_data, $data) { |
|
| 339 | 339 | |
| 340 | 340 | // Update option with passed data license |
| 341 | 341 | $settings = $this->Addon->get_app_settings(); |
| 342 | 342 | |
| 343 | - $settings['license_key'] = $license_data->license_key = trim( $data['license'] ); |
|
| 343 | + $settings['license_key'] = $license_data->license_key = trim($data['license']); |
|
| 344 | 344 | $settings['license_key_status'] = $license_data->license; |
| 345 | 345 | $settings['license_key_response'] = (array)$license_data; |
| 346 | 346 | |
| 347 | - $this->Addon->update_app_settings( $settings ); |
|
| 347 | + $this->Addon->update_app_settings($settings); |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | /** |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | * @param object|null $license_data Object with license data |
| 354 | 354 | * @return string Renewal or account URL |
| 355 | 355 | */ |
| 356 | - private function get_license_renewal_url( $license_data ) { |
|
| 357 | - $renew_license_url = ( ! empty( $license_data ) && !empty( $license_data->license_key ) ) ? sprintf( 'https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key ) : 'https://gravityview.co/account/'; |
|
| 356 | + private function get_license_renewal_url($license_data) { |
|
| 357 | + $renew_license_url = (!empty($license_data) && !empty($license_data->license_key)) ? sprintf('https://gravityview.co/checkout/?download_id=17&edd_license_key=%s&utm_source=admin_notice&utm_medium=admin&utm_content=expired&utm_campaign=Activation', $license_data->license_key) : 'https://gravityview.co/account/'; |
|
| 358 | 358 | return $renew_license_url; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * @param object|null $license_data Object with license data |
| 365 | 365 | * @return array Modified array of content |
| 366 | 366 | */ |
| 367 | - public function strings( $status = NULL, $license_data = null ) { |
|
| 367 | + public function strings($status = NULL, $license_data = null) { |
|
| 368 | 368 | |
| 369 | 369 | |
| 370 | 370 | $strings = array( |
@@ -372,14 +372,14 @@ discard block |
||
| 372 | 372 | 'error' => esc_html__('There was an error processing the request.', 'gravityview'), |
| 373 | 373 | 'failed' => esc_html__('Could not deactivate the license. The license key you attempted to deactivate may not be active or valid.', 'gravityview'), |
| 374 | 374 | 'site_inactive' => esc_html__('The license key is valid, but it has not been activated for this site.', 'gravityview'), |
| 375 | - 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview') . ' ' . sprintf( esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>' ), |
|
| 375 | + 'no_activations_left' => esc_html__('Invalid: this license has reached its activation limit.', 'gravityview').' '.sprintf(esc_html__('You can manage license activations %son your GravityView account page%s.', 'gravityview'), '<a href="https://gravityview.co/account/#licenses">', '</a>'), |
|
| 376 | 376 | 'deactivated' => esc_html__('The license has been deactivated.', 'gravityview'), |
| 377 | 377 | 'valid' => esc_html__('The license key is valid and active.', 'gravityview'), |
| 378 | 378 | 'invalid' => esc_html__('The license key entered is invalid.', 'gravityview'), |
| 379 | 379 | 'missing' => esc_html__('The license key was not defined.', 'gravityview'), |
| 380 | 380 | 'revoked' => esc_html__('This license key has been revoked.', 'gravityview'), |
| 381 | - 'expired' => sprintf( esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'. esc_url( $this->get_license_renewal_url( $license_data ) ) .'">', '</a>' ), |
|
| 382 | - 'capability' => esc_html__( 'You don\'t have the ability to edit plugin settings.', 'gravityview' ), |
|
| 381 | + 'expired' => sprintf(esc_html__('This license key has expired. %sRenew your license on the GravityView website%s to receive updates and support.', 'gravityview'), '<a href="'.esc_url($this->get_license_renewal_url($license_data)).'">', '</a>'), |
|
| 382 | + 'capability' => esc_html__('You don\'t have the ability to edit plugin settings.', 'gravityview'), |
|
| 383 | 383 | |
| 384 | 384 | 'verifying_license' => esc_html__('Verifying license…', 'gravityview'), |
| 385 | 385 | 'activate_license' => esc_html__('Activate License', 'gravityview'), |
@@ -387,33 +387,33 @@ discard block |
||
| 387 | 387 | 'check_license' => esc_html__('Verify License', 'gravityview'), |
| 388 | 388 | ); |
| 389 | 389 | |
| 390 | - if( empty( $status ) ) { |
|
| 390 | + if (empty($status)) { |
|
| 391 | 391 | return $strings; |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - if( isset( $strings[ $status ] ) ) { |
|
| 395 | - return $strings[ $status ]; |
|
| 394 | + if (isset($strings[$status])) { |
|
| 395 | + return $strings[$status]; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | return NULL; |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | - public function validate_license_key( $value, $field ) { |
|
| 401 | + public function validate_license_key($value, $field) { |
|
| 402 | 402 | |
| 403 | 403 | // No license? No status. |
| 404 | - if( empty( $value ) ) { |
|
| 404 | + if (empty($value)) { |
|
| 405 | 405 | return NULL; |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | $response = $this->license_call(array( |
| 409 | - 'license' => $this->Addon->get_app_setting( 'license_key' ), |
|
| 409 | + 'license' => $this->Addon->get_app_setting('license_key'), |
|
| 410 | 410 | 'edd_action' => 'check_license', |
| 411 | 411 | 'field_id' => $field['name'], |
| 412 | 412 | )); |
| 413 | 413 | |
| 414 | - $response = is_string( $response ) ? json_decode( $response, true ) : $response; |
|
| 414 | + $response = is_string($response) ? json_decode($response, true) : $response; |
|
| 415 | 415 | |
| 416 | - switch( $response['license'] ) { |
|
| 416 | + switch ($response['license']) { |
|
| 417 | 417 | case 'valid': |
| 418 | 418 | $return = true; |
| 419 | 419 | break; |
@@ -225,7 +225,7 @@ |
||
| 225 | 225 | * Does the if and the comparison match? |
| 226 | 226 | * @uses GVCommon::matches_operation |
| 227 | 227 | * |
| 228 | - * @return boolean True: yep; false: nope |
|
| 228 | + * @return boolean|null True: yep; false: nope |
|
| 229 | 229 | */ |
| 230 | 230 | function set_is_match() { |
| 231 | 231 | $this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation ); |
@@ -5,13 +5,13 @@ discard block |
||
| 5 | 5 | */ |
| 6 | 6 | class GVLogic_Shortcode { |
| 7 | 7 | |
| 8 | - private static $SUPPORTED_SCALAR_OPERATORS = array( 'is', 'isnot', 'contains', 'starts_with', 'ends_with' ); |
|
| 8 | + private static $SUPPORTED_SCALAR_OPERATORS = array('is', 'isnot', 'contains', 'starts_with', 'ends_with'); |
|
| 9 | 9 | |
| 10 | - private static $SUPPORTED_NUMERIC_OPERATORS = array( 'greater_than', 'less_than' ); |
|
| 10 | + private static $SUPPORTED_NUMERIC_OPERATORS = array('greater_than', 'less_than'); |
|
| 11 | 11 | |
| 12 | - private static $SUPPORTED_ARRAY_OPERATORS = array( 'in', 'not_in', 'isnot', 'contains' ); |
|
| 12 | + private static $SUPPORTED_ARRAY_OPERATORS = array('in', 'not_in', 'isnot', 'contains'); |
|
| 13 | 13 | |
| 14 | - private static $SUPPORTED_CUSTOM_OPERATORS = array( 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains' ); |
|
| 14 | + private static $SUPPORTED_CUSTOM_OPERATORS = array('equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains'); |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Attributes passed to the shortcode |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public static function get_instance() { |
| 87 | 87 | |
| 88 | - if( empty( self::$instance ) ) { |
|
| 88 | + if (empty(self::$instance)) { |
|
| 89 | 89 | self::$instance = new self; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @return void |
| 106 | 106 | */ |
| 107 | 107 | function add_hooks() { |
| 108 | - add_shortcode( 'gvlogic', array( $this, 'shortcode' ) ); |
|
| 108 | + add_shortcode('gvlogic', array($this, 'shortcode')); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -114,14 +114,14 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return array |
| 116 | 116 | */ |
| 117 | - function get_operators( $with_values = false ) { |
|
| 117 | + function get_operators($with_values = false) { |
|
| 118 | 118 | |
| 119 | - $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
|
| 119 | + $operators = array_merge(self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS); |
|
| 120 | 120 | |
| 121 | - if( $with_values ) { |
|
| 121 | + if ($with_values) { |
|
| 122 | 122 | $operators_with_values = array(); |
| 123 | - foreach( $operators as $key ) { |
|
| 124 | - $operators_with_values[ $key ] = ''; |
|
| 123 | + foreach ($operators as $key) { |
|
| 124 | + $operators_with_values[$key] = ''; |
|
| 125 | 125 | } |
| 126 | 126 | return $operators_with_values; |
| 127 | 127 | } else { |
@@ -135,16 +135,16 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return bool True: it's an allowed operation type and was added. False: invalid operation type |
| 137 | 137 | */ |
| 138 | - function set_operation( $operation = '' ) { |
|
| 138 | + function set_operation($operation = '') { |
|
| 139 | 139 | |
| 140 | - if( empty( $operation ) ) { |
|
| 140 | + if (empty($operation)) { |
|
| 141 | 141 | return false; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - $operators = $this->get_operators( false ); |
|
| 144 | + $operators = $this->get_operators(false); |
|
| 145 | 145 | |
| 146 | - if( !in_array( $operation, $operators ) ) { |
|
| 147 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
| 146 | + if (!in_array($operation, $operators)) { |
|
| 147 | + do_action('gravityview_log_debug', __METHOD__.' Attempted to add invalid operation type.', $operation); |
|
| 148 | 148 | return false; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | */ |
| 165 | 165 | function setup_operation_and_comparison() { |
| 166 | 166 | |
| 167 | - foreach( $this->atts as $key => $value ) { |
|
| 167 | + foreach ($this->atts as $key => $value) { |
|
| 168 | 168 | |
| 169 | - $valid = $this->set_operation( $key ); |
|
| 169 | + $valid = $this->set_operation($key); |
|
| 170 | 170 | |
| 171 | - if( $valid ) { |
|
| 171 | + if ($valid) { |
|
| 172 | 172 | $this->comparison = $value; |
| 173 | 173 | return true; |
| 174 | 174 | } |
@@ -184,10 +184,10 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @return string|null |
| 186 | 186 | */ |
| 187 | - public function shortcode( $atts = array(), $content = NULL, $shortcode_tag = '' ) { |
|
| 187 | + public function shortcode($atts = array(), $content = NULL, $shortcode_tag = '') { |
|
| 188 | 188 | |
| 189 | 189 | // Don't process except on frontend |
| 190 | - if ( GravityView_Plugin::is_admin() ) { |
|
| 190 | + if (GravityView_Plugin::is_admin()) { |
|
| 191 | 191 | return null; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -198,16 +198,16 @@ discard block |
||
| 198 | 198 | $this->parse_atts(); |
| 199 | 199 | |
| 200 | 200 | // We need an "if" |
| 201 | - if( false === $this->if ) { |
|
| 202 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts ); |
|
| 201 | + if (false === $this->if) { |
|
| 202 | + do_action('gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->atts); |
|
| 203 | 203 | return null; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | $setup = $this->setup_operation_and_comparison(); |
| 207 | 207 | |
| 208 | 208 | // We need an operation and comparison value |
| 209 | - if( ! $setup ) { |
|
| 210 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
| 209 | + if (!$setup) { |
|
| 210 | + do_action('gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts); |
|
| 211 | 211 | return null; |
| 212 | 212 | } |
| 213 | 213 | |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @return boolean True: yep; false: nope |
| 229 | 229 | */ |
| 230 | 230 | function set_is_match() { |
| 231 | - $this->is_match = GVCommon::matches_operation( $this->if, $this->comparison, $this->operation ); |
|
| 231 | + $this->is_match = GVCommon::matches_operation($this->if, $this->comparison, $this->operation); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | /** |
@@ -238,23 +238,23 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | function get_output() { |
| 240 | 240 | |
| 241 | - if( $this->is_match ) { |
|
| 241 | + if ($this->is_match) { |
|
| 242 | 242 | $output = $this->content; |
| 243 | 243 | } else { |
| 244 | 244 | $output = $this->else_content; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | // Get recursive! |
| 248 | - $output = do_shortcode( $output ); |
|
| 248 | + $output = do_shortcode($output); |
|
| 249 | 249 | |
| 250 | 250 | /** |
| 251 | 251 | * @filter `gravityview/gvlogic/output` Modify the [gvlogic] output |
| 252 | 252 | * @param string $output HTML/text output |
| 253 | 253 | * @param GVLogic_Shortcode $this This class |
| 254 | 254 | */ |
| 255 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
| 255 | + $output = apply_filters('gravityview/gvlogic/output', $output, $this); |
|
| 256 | 256 | |
| 257 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
| 257 | + do_action('gravityview_log_debug', __METHOD__.' Output: ', $output); |
|
| 258 | 258 | |
| 259 | 259 | return $output; |
| 260 | 260 | } |
@@ -268,13 +268,13 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | function set_content_and_else_content() { |
| 270 | 270 | |
| 271 | - $content = explode( '[else]', $this->passed_content ); |
|
| 271 | + $content = explode('[else]', $this->passed_content); |
|
| 272 | 272 | |
| 273 | 273 | $this->content = $content[0]; |
| 274 | 274 | |
| 275 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
| 275 | + $else_attr = isset($this->atts['else']) ? $this->atts['else'] : NULL; |
|
| 276 | 276 | |
| 277 | - $this->else_content = isset( $content[1] ) ? $content[1] : $else_attr; |
|
| 277 | + $this->else_content = isset($content[1]) ? $content[1] : $else_attr; |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -288,19 +288,19 @@ discard block |
||
| 288 | 288 | 'else' => false, |
| 289 | 289 | ); |
| 290 | 290 | |
| 291 | - $supported_args = $supported + $this->get_operators( true ); |
|
| 291 | + $supported_args = $supported + $this->get_operators(true); |
|
| 292 | 292 | |
| 293 | 293 | // Whittle down the attributes to only valid pairs |
| 294 | - $this->atts = shortcode_atts( $supported_args, $this->passed_atts, $this->shortcode ); |
|
| 294 | + $this->atts = shortcode_atts($supported_args, $this->passed_atts, $this->shortcode); |
|
| 295 | 295 | |
| 296 | 296 | // Only keep the passed attributes after making sure that they're valid pairs |
| 297 | - $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
|
| 297 | + $this->atts = function_exists('array_intersect_key') ? array_intersect_key($this->passed_atts, $this->atts) : $this->atts; |
|
| 298 | 298 | |
| 299 | 299 | // Strip whitespace if it's not default false |
| 300 | - $this->if = is_string( $this->atts['if'] ) ? trim( $this->atts['if'] ) : false; |
|
| 300 | + $this->if = is_string($this->atts['if']) ? trim($this->atts['if']) : false; |
|
| 301 | 301 | |
| 302 | 302 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
| 303 | - unset( $this->atts['if'] ); |
|
| 303 | + unset($this->atts['if']); |
|
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |