@@ -1,42 +1,42 @@ discard block |
||
| 1 | 1 | <div id="gv-view-configuration-tabs"> |
| 2 | 2 | |
| 3 | 3 | <ul class="nav-tab-wrapper"> |
| 4 | - <li><a href="#directory-view" class="nav-tab"><i class="dashicons dashicons-admin-page"></i> <?php esc_html_e( 'Multiple Entries', 'gravityview' ); ?></a></li> |
|
| 5 | - <li><a href="#single-view" class="nav-tab"><i class="dashicons dashicons-media-default"></i> <?php esc_html_e( 'Single Entry', 'gravityview' ); ?></a></li> |
|
| 6 | - <li><a href="#edit-view" class="nav-tab"><i class="dashicons dashicons-welcome-write-blog"></i> <?php esc_html_e( 'Edit Entry', 'gravityview' ); ?></a></li> |
|
| 4 | + <li><a href="#directory-view" class="nav-tab"><i class="dashicons dashicons-admin-page"></i> <?php esc_html_e('Multiple Entries', 'gravityview'); ?></a></li> |
|
| 5 | + <li><a href="#single-view" class="nav-tab"><i class="dashicons dashicons-media-default"></i> <?php esc_html_e('Single Entry', 'gravityview'); ?></a></li> |
|
| 6 | + <li><a href="#edit-view" class="nav-tab"><i class="dashicons dashicons-welcome-write-blog"></i> <?php esc_html_e('Edit Entry', 'gravityview'); ?></a></li> |
|
| 7 | 7 | </ul> |
| 8 | 8 | |
| 9 | 9 | <div id="directory-view"> |
| 10 | 10 | |
| 11 | 11 | <div id="directory-fields" class="gv-section"> |
| 12 | 12 | |
| 13 | - <h4><?php esc_html_e( 'Above Entries Widgets', 'gravityview'); ?> <span><?php esc_html_e( 'These widgets will be shown above entries.', 'gravityview'); ?></span></h4> |
|
| 13 | + <h4><?php esc_html_e('Above Entries Widgets', 'gravityview'); ?> <span><?php esc_html_e('These widgets will be shown above entries.', 'gravityview'); ?></span></h4> |
|
| 14 | 14 | |
| 15 | - <?php do_action('gravityview_render_widgets_active_areas', $curr_template, 'header', $post->ID ); ?> |
|
| 15 | + <?php do_action('gravityview_render_widgets_active_areas', $curr_template, 'header', $post->ID); ?> |
|
| 16 | 16 | |
| 17 | - <h4><?php esc_html_e( 'Entries Fields', 'gravityview'); ?> <span><?php esc_html_e( 'These fields will be shown for each entry.', 'gravityview'); ?></span></h4> |
|
| 17 | + <h4><?php esc_html_e('Entries Fields', 'gravityview'); ?> <span><?php esc_html_e('These fields will be shown for each entry.', 'gravityview'); ?></span></h4> |
|
| 18 | 18 | |
| 19 | 19 | <div id="directory-active-fields" class="gv-grid gv-grid-pad gv-grid-border"> |
| 20 | - <?php if(!empty( $curr_template ) ) { |
|
| 21 | - do_action('gravityview_render_directory_active_areas', $curr_template, 'directory', $post->ID, true ); |
|
| 20 | + <?php if (!empty($curr_template)) { |
|
| 21 | + do_action('gravityview_render_directory_active_areas', $curr_template, 'directory', $post->ID, true); |
|
| 22 | 22 | } ?> |
| 23 | 23 | </div> |
| 24 | 24 | |
| 25 | - <h4><?php esc_html_e( 'Below Entries Widgets', 'gravityview'); ?> <span><?php esc_html_e( 'These widgets will be shown below entries.', 'gravityview'); ?></span></h4> |
|
| 25 | + <h4><?php esc_html_e('Below Entries Widgets', 'gravityview'); ?> <span><?php esc_html_e('These widgets will be shown below entries.', 'gravityview'); ?></span></h4> |
|
| 26 | 26 | |
| 27 | - <?php do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID ); ?> |
|
| 27 | + <?php do_action('gravityview_render_widgets_active_areas', $curr_template, 'footer', $post->ID); ?> |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | <?php // list of available fields to be shown in the popup ?> |
| 31 | 31 | <div id="directory-available-fields" class="hide-if-js gv-tooltip"> |
| 32 | 32 | <span class="close"><i class="dashicons dashicons-dismiss"></i></span> |
| 33 | - <?php do_action('gravityview_render_available_fields', $curr_form, 'directory' ); ?> |
|
| 33 | + <?php do_action('gravityview_render_available_fields', $curr_form, 'directory'); ?> |
|
| 34 | 34 | </div> |
| 35 | 35 | |
| 36 | 36 | <?php // list of available widgets to be shown in the popup ?> |
| 37 | 37 | <div id="directory-available-widgets" class="hide-if-js gv-tooltip"> |
| 38 | 38 | <span class="close"><i class="dashicons dashicons-dismiss"></i></span> |
| 39 | - <?php do_action('gravityview_render_available_widgets' ); ?> |
|
| 39 | + <?php do_action('gravityview_render_available_widgets'); ?> |
|
| 40 | 40 | </div> |
| 41 | 41 | |
| 42 | 42 | </div> |
@@ -52,17 +52,17 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | <div id="single-fields" class="gv-section"> |
| 54 | 54 | |
| 55 | - <h4><?php esc_html_e( 'These fields will be shown in Single Entry view.', 'gravityview'); ?></h4> |
|
| 55 | + <h4><?php esc_html_e('These fields will be shown in Single Entry view.', 'gravityview'); ?></h4> |
|
| 56 | 56 | |
| 57 | 57 | <div id="single-active-fields" class="gv-grid gv-grid-pad gv-grid-border"> |
| 58 | - <?php if(!empty( $curr_template ) ) { |
|
| 59 | - do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true ); |
|
| 58 | + <?php if (!empty($curr_template)) { |
|
| 59 | + do_action('gravityview_render_directory_active_areas', $curr_template, 'single', $post->ID, true); |
|
| 60 | 60 | } ?> |
| 61 | 61 | </div> |
| 62 | 62 | |
| 63 | 63 | <div id="single-available-fields" class="hide-if-js gv-tooltip"> |
| 64 | 64 | <span class="close"><i class="dashicons dashicons-dismiss"></i></span> |
| 65 | - <?php do_action('gravityview_render_available_fields', $curr_form, 'single' ); ?> |
|
| 65 | + <?php do_action('gravityview_render_available_fields', $curr_form, 'single'); ?> |
|
| 66 | 66 | </div> |
| 67 | 67 | |
| 68 | 68 | </div> |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | <div id="edit-fields" class="gv-section"> |
| 75 | 75 | |
| 76 | - <h4><?php esc_html_e( 'Fields shown when editing an entry.', 'gravityview'); ?> <span><?php esc_html_e('If not configured, all form fields will be displayed.', 'gravityview'); ?></span></h4> |
|
| 76 | + <h4><?php esc_html_e('Fields shown when editing an entry.', 'gravityview'); ?> <span><?php esc_html_e('If not configured, all form fields will be displayed.', 'gravityview'); ?></span></h4> |
|
| 77 | 77 | |
| 78 | 78 | <div id="edit-active-fields" class="gv-grid gv-grid-pad gv-grid-border"> |
| 79 | 79 | <?php |
| 80 | - do_action('gravityview_render_directory_active_areas', apply_filters( 'gravityview/template/edit', 'default_table_edit' ), 'edit', $post->ID, true ); |
|
| 80 | + do_action('gravityview_render_directory_active_areas', apply_filters('gravityview/template/edit', 'default_table_edit'), 'edit', $post->ID, true); |
|
| 81 | 81 | ?> |
| 82 | 82 | </div> |
| 83 | 83 | |
| 84 | 84 | <div id="edit-available-fields" class="hide-if-js gv-tooltip"> |
| 85 | 85 | <span class="close"><i class="dashicons dashicons-dismiss"></i></span> |
| 86 | - <?php do_action('gravityview_render_available_fields', $curr_form, 'edit' ); ?> |
|
| 86 | + <?php do_action('gravityview_render_available_fields', $curr_form, 'edit'); ?> |
|
| 87 | 87 | </div> |
| 88 | 88 | |
| 89 | 89 | </div> |
@@ -6,10 +6,10 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | global $post; |
| 8 | 8 | |
| 9 | -$curr_form = gravityview_get_form_id( $post->ID ); |
|
| 9 | +$curr_form = gravityview_get_form_id($post->ID); |
|
| 10 | 10 | |
| 11 | 11 | // View template settings |
| 12 | -$current_settings = gravityview_get_template_settings( $post->ID ); |
|
| 12 | +$current_settings = gravityview_get_template_settings($post->ID); |
|
| 13 | 13 | |
| 14 | 14 | ?> |
| 15 | 15 | |
@@ -17,32 +17,32 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | <?php |
| 19 | 19 | |
| 20 | - GravityView_Render_Settings::render_setting_row( 'page_size', $current_settings ); |
|
| 20 | + GravityView_Render_Settings::render_setting_row('page_size', $current_settings); |
|
| 21 | 21 | |
| 22 | - GravityView_Render_Settings::render_setting_row( 'lightbox', $current_settings ); |
|
| 22 | + GravityView_Render_Settings::render_setting_row('lightbox', $current_settings); |
|
| 23 | 23 | |
| 24 | - GravityView_Render_Settings::render_setting_row( 'show_only_approved', $current_settings ); |
|
| 24 | + GravityView_Render_Settings::render_setting_row('show_only_approved', $current_settings); |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @since 1.5.4 |
| 28 | 28 | */ |
| 29 | - GravityView_Render_Settings::render_setting_row( 'hide_until_searched', $current_settings ); |
|
| 29 | + GravityView_Render_Settings::render_setting_row('hide_until_searched', $current_settings); |
|
| 30 | 30 | |
| 31 | - GravityView_Render_Settings::render_setting_row( 'hide_empty', $current_settings ); |
|
| 31 | + GravityView_Render_Settings::render_setting_row('hide_empty', $current_settings); |
|
| 32 | 32 | |
| 33 | - GravityView_Render_Settings::render_setting_row( 'user_edit', $current_settings ); |
|
| 33 | + GravityView_Render_Settings::render_setting_row('user_edit', $current_settings); |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @since 1.5.1 |
| 37 | 37 | */ |
| 38 | - GravityView_Render_Settings::render_setting_row( 'user_delete', $current_settings ); |
|
| 38 | + GravityView_Render_Settings::render_setting_row('user_delete', $current_settings); |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @since 1.15.2 |
| 42 | 42 | */ |
| 43 | - GravityView_Render_Settings::render_setting_row( 'embed_only', $current_settings ); |
|
| 43 | + GravityView_Render_Settings::render_setting_row('embed_only', $current_settings); |
|
| 44 | 44 | |
| 45 | - do_action( 'gravityview_admin_directory_settings', $current_settings ); |
|
| 45 | + do_action('gravityview_admin_directory_settings', $current_settings); |
|
| 46 | 46 | |
| 47 | 47 | ?> |
| 48 | 48 | |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * @package GravityView |
|
| 4 | - * @subpackage Gravityview/admin/metaboxes/views |
|
| 5 | - * @global $post |
|
| 6 | - */ |
|
| 3 | + * @package GravityView |
|
| 4 | + * @subpackage Gravityview/admin/metaboxes/views |
|
| 5 | + * @global $post |
|
| 6 | + */ |
|
| 7 | 7 | global $post; |
| 8 | 8 | |
| 9 | 9 | $curr_form = gravityview_get_form_id( $post->ID ); |
@@ -11,29 +11,29 @@ discard block |
||
| 11 | 11 | $field_info_items = array(); |
| 12 | 12 | |
| 13 | 13 | // Fields with IDs, not like Source URL or Entry ID |
| 14 | - if( is_numeric( $this->id ) ) { |
|
| 14 | + if (is_numeric($this->id)) { |
|
| 15 | 15 | |
| 16 | - $field_type_title = GFCommon::get_field_type_title( $this->item['input_type'] ); |
|
| 16 | + $field_type_title = GFCommon::get_field_type_title($this->item['input_type']); |
|
| 17 | 17 | |
| 18 | 18 | $field_info_items[] = array( |
| 19 | - 'value' => sprintf( __('Type: %s', 'gravityview'), $field_type_title ) |
|
| 19 | + 'value' => sprintf(__('Type: %s', 'gravityview'), $field_type_title) |
|
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | 22 | $field_info_items[] = array( |
| 23 | - 'value' => sprintf( __('Field ID: %s', 'gravityview'), $this->id ), |
|
| 23 | + 'value' => sprintf(__('Field ID: %s', 'gravityview'), $this->id), |
|
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - if( !empty( $this->item['desc'] ) ) { |
|
| 28 | + if (!empty($this->item['desc'])) { |
|
| 29 | 29 | $field_info_items[] = array( |
| 30 | 30 | 'value' => $this->item['desc'] |
| 31 | 31 | ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if( !empty( $this->item['adminLabel'] ) ) { |
|
| 34 | + if (!empty($this->item['adminLabel'])) { |
|
| 35 | 35 | $field_info_items[] = array( |
| 36 | - 'value' => sprintf( __('Admin Label: %s', 'gravityview' ), $this->item['adminLabel'] ), |
|
| 36 | + 'value' => sprintf(__('Admin Label: %s', 'gravityview'), $this->item['adminLabel']), |
|
| 37 | 37 | 'class' => 'gv-sublabel' |
| 38 | 38 | ); |
| 39 | 39 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $field_info = ''; |
| 53 | 53 | $field_info_items = array(); |
| 54 | 54 | |
| 55 | - if( !empty( $this->item['description'] ) ) { |
|
| 55 | + if (!empty($this->item['description'])) { |
|
| 56 | 56 | |
| 57 | 57 | $field_info_items[] = array( |
| 58 | 58 | 'value' => $this->item['description'] |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | private $label_type; |
| 78 | 78 | protected $item; |
| 79 | 79 | |
| 80 | - function __construct( $title = '', $field_id, $item = array(), $settings = array() ) { |
|
| 80 | + function __construct($title = '', $field_id, $item = array(), $settings = array()) { |
|
| 81 | 81 | |
| 82 | 82 | // Backward compat |
| 83 | - if( !empty( $item['type'] ) ) { |
|
| 83 | + if (!empty($item['type'])) { |
|
| 84 | 84 | $item['input_type'] = $item['type']; |
| 85 | - unset( $item['type'] ); |
|
| 85 | + unset($item['type']); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Prevent items from not having index set |
| 89 | - $item = wp_parse_args( $item, array( |
|
| 89 | + $item = wp_parse_args($item, array( |
|
| 90 | 90 | 'label_text' => $title, |
| 91 | 91 | 'field_id' => NULL, |
| 92 | 92 | 'parent_label' => NULL, |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param boolean $html Display HTML output? If yes, output is wrapped in spans. If no, plaintext. |
| 130 | 130 | * @return string|null If empty, return null. Otherwise, return output HTML/text. |
| 131 | 131 | */ |
| 132 | - protected function get_item_info( $html = true ) { |
|
| 132 | + protected function get_item_info($html = true) { |
|
| 133 | 133 | |
| 134 | 134 | $output = NULL; |
| 135 | 135 | $field_info_items = $this->additional_info(); |
@@ -139,27 +139,27 @@ discard block |
||
| 139 | 139 | * @param array $field_info_items Additional information to display in a field |
| 140 | 140 | * @param GravityView_Admin_View_Field $this Field shown in the admin |
| 141 | 141 | */ |
| 142 | - $field_info_items = apply_filters( 'gravityview_admin_label_item_info', $field_info_items, $this ); |
|
| 142 | + $field_info_items = apply_filters('gravityview_admin_label_item_info', $field_info_items, $this); |
|
| 143 | 143 | |
| 144 | - if( $html ) { |
|
| 144 | + if ($html) { |
|
| 145 | 145 | |
| 146 | - foreach ( $field_info_items as $item ) { |
|
| 147 | - $class = isset($item['class']) ? sanitize_html_class( $item['class'] ).' description' : 'description'; |
|
| 146 | + foreach ($field_info_items as $item) { |
|
| 147 | + $class = isset($item['class']) ? sanitize_html_class($item['class']).' description' : 'description'; |
|
| 148 | 148 | // Add the title in case the value's long, in which case, it'll be truncated by CSS. |
| 149 | 149 | $output .= '<span class="'.$class.'">'; |
| 150 | - $output .= esc_html( $item['value'] ); |
|
| 150 | + $output .= esc_html($item['value']); |
|
| 151 | 151 | $output .= '</span>'; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | } else { |
| 155 | 155 | |
| 156 | - $values = wp_list_pluck( $field_info_items, 'value' ); |
|
| 156 | + $values = wp_list_pluck($field_info_items, 'value'); |
|
| 157 | 157 | |
| 158 | - $output = esc_html( implode(', ', $values) ); |
|
| 158 | + $output = esc_html(implode(', ', $values)); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - return empty( $output ) ? NULL : $output; |
|
| 162 | + return empty($output) ? NULL : $output; |
|
| 163 | 163 | |
| 164 | 164 | } |
| 165 | 165 | |
@@ -176,47 +176,47 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | // $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know. |
| 178 | 178 | // TODO: Un-hack this |
| 179 | - $hide_settings_link = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->') > 0 ) ? 'hide-if-js' : ''; |
|
| 180 | - $settings_link = sprintf( '<a href="#settings" class="dashicons-admin-generic dashicons %s" title="%s"></a>', $hide_settings_link, esc_attr( $settings_title ) ); |
|
| 179 | + $hide_settings_link = (empty($this->item['settings_html']) || strpos($this->item['settings_html'], '<!-- No Options -->') > 0) ? 'hide-if-js' : ''; |
|
| 180 | + $settings_link = sprintf('<a href="#settings" class="dashicons-admin-generic dashicons %s" title="%s"></a>', $hide_settings_link, esc_attr($settings_title)); |
|
| 181 | 181 | |
| 182 | 182 | // Should we show the icon that the field is being used as a link to single entry? |
| 183 | - $hide_show_as_link_class = empty( $this->settings['show_as_link'] ) ? 'hide-if-js' : ''; |
|
| 184 | - $show_as_link = '<span class="dashicons dashicons-admin-links '.$hide_show_as_link_class.'" title="'.esc_attr( $single_link_title ).'"></span>'; |
|
| 183 | + $hide_show_as_link_class = empty($this->settings['show_as_link']) ? 'hide-if-js' : ''; |
|
| 184 | + $show_as_link = '<span class="dashicons dashicons-admin-links '.$hide_show_as_link_class.'" title="'.esc_attr($single_link_title).'"></span>'; |
|
| 185 | 185 | |
| 186 | 186 | // When a field label is empty, use the Field ID |
| 187 | - $label = empty( $this->title ) ? sprintf( _x('Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview'), $this->id ) : $this->title; |
|
| 187 | + $label = empty($this->title) ? sprintf(_x('Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview'), $this->id) : $this->title; |
|
| 188 | 188 | |
| 189 | 189 | // If there's a custom label, and show label is checked, use that as the field heading |
| 190 | - if( !empty( $this->settings['custom_label'] ) && !empty( $this->settings['show_label'] ) ) { |
|
| 190 | + if (!empty($this->settings['custom_label']) && !empty($this->settings['show_label'])) { |
|
| 191 | 191 | $label = $this->settings['custom_label']; |
| 192 | - } else if( !empty( $this->item['customLabel'] ) ) { |
|
| 192 | + } else if (!empty($this->item['customLabel'])) { |
|
| 193 | 193 | $label = $this->item['customLabel']; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | $output = '<h5 class="selectable gfield field-id-'.esc_attr($this->id).'">'; |
| 197 | 197 | |
| 198 | - $label = esc_attr( $label ); |
|
| 198 | + $label = esc_attr($label); |
|
| 199 | 199 | |
| 200 | - if( !empty( $this->item['parent'] ) ) { |
|
| 201 | - $label .= ' <small>('.esc_attr( $this->item['parent']['label'] ) .')</small>'; |
|
| 200 | + if (!empty($this->item['parent'])) { |
|
| 201 | + $label .= ' <small>('.esc_attr($this->item['parent']['label']).')</small>'; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Name of field / widget |
| 205 | - $output .= '<span class="gv-field-label" data-original-title="'.esc_attr( $label ).'" title="'. $this->get_item_info( false ) .'">'. $label . '</span>'; |
|
| 205 | + $output .= '<span class="gv-field-label" data-original-title="'.esc_attr($label).'" title="'.$this->get_item_info(false).'">'.$label.'</span>'; |
|
| 206 | 206 | |
| 207 | 207 | |
| 208 | - $output .= '<span class="gv-field-controls">'.$settings_link.$show_as_link.'<a href="#remove" class="dashicons-dismiss dashicons" title="'.esc_attr( $delete_title ) .'"></a></span>'; |
|
| 208 | + $output .= '<span class="gv-field-controls">'.$settings_link.$show_as_link.'<a href="#remove" class="dashicons-dismiss dashicons" title="'.esc_attr($delete_title).'"></a></span>'; |
|
| 209 | 209 | |
| 210 | 210 | // Displays only in the field/widget picker. |
| 211 | - if( $field_info = $this->get_item_info() ) { |
|
| 211 | + if ($field_info = $this->get_item_info()) { |
|
| 212 | 212 | $output .= '<span class="gv-field-info">'.$field_info.'</span>'; |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | $output .= '</h5>'; |
| 216 | 216 | |
| 217 | - $container_class = !empty( $this->item['parent'] ) ? ' gv-child-field' : ''; |
|
| 217 | + $container_class = !empty($this->item['parent']) ? ' gv-child-field' : ''; |
|
| 218 | 218 | |
| 219 | - $output = '<div data-fieldid="'.esc_attr($this->id).'" data-inputtype="'.esc_attr( $this->item['input_type'] ).'" class="gv-fields'.$container_class.'">'.$output.$this->item['settings_html'].'</div>'; |
|
| 219 | + $output = '<div data-fieldid="'.esc_attr($this->id).'" data-inputtype="'.esc_attr($this->item['input_type']).'" class="gv-fields'.$container_class.'">'.$output.$this->item['settings_html'].'</div>'; |
|
| 220 | 220 | |
| 221 | 221 | return $output; |
| 222 | 222 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Exit if accessed directly |
| 15 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 15 | +if (!defined('ABSPATH')) exit; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * GravityView_Welcome Class |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * @since 1.0 |
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | - add_action( 'admin_menu', array( $this, 'admin_menus'), 200 ); |
|
| 38 | - add_action( 'admin_head', array( $this, 'admin_head' ) ); |
|
| 39 | - add_action( 'admin_init', array( $this, 'welcome' ) ); |
|
| 40 | - add_filter( 'gravityview_is_admin_page', array( $this, 'is_dashboard_page'), 10, 2 ); |
|
| 37 | + add_action('admin_menu', array($this, 'admin_menus'), 200); |
|
| 38 | + add_action('admin_head', array($this, 'admin_head')); |
|
| 39 | + add_action('admin_init', array($this, 'welcome')); |
|
| 40 | + add_filter('gravityview_is_admin_page', array($this, 'is_dashboard_page'), 10, 2); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -57,27 +57,27 @@ discard block |
||
| 57 | 57 | __('Getting Started', 'gravityview'), |
| 58 | 58 | $this->minimum_capability, |
| 59 | 59 | 'gv-getting-started', |
| 60 | - array( $this, 'getting_started_screen' ) |
|
| 60 | + array($this, 'getting_started_screen') |
|
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | // Changelog Page |
| 64 | 64 | add_submenu_page( |
| 65 | 65 | 'edit.php?post_type=gravityview', |
| 66 | - __( 'Changelog', 'gravityview' ), |
|
| 67 | - __( 'Changelog', 'gravityview' ), |
|
| 66 | + __('Changelog', 'gravityview'), |
|
| 67 | + __('Changelog', 'gravityview'), |
|
| 68 | 68 | $this->minimum_capability, |
| 69 | 69 | 'gv-changelog', |
| 70 | - array( $this, 'changelog_screen' ) |
|
| 70 | + array($this, 'changelog_screen') |
|
| 71 | 71 | ); |
| 72 | 72 | |
| 73 | 73 | // Credits Page |
| 74 | 74 | add_submenu_page( |
| 75 | 75 | 'edit.php?post_type=gravityview', |
| 76 | - __( 'Credits', 'gravityview' ), |
|
| 77 | - __( 'Credits', 'gravityview' ), |
|
| 76 | + __('Credits', 'gravityview'), |
|
| 77 | + __('Credits', 'gravityview'), |
|
| 78 | 78 | $this->minimum_capability, |
| 79 | 79 | 'gv-credits', |
| 80 | - array( $this, 'credits_screen' ) |
|
| 80 | + array($this, 'credits_screen') |
|
| 81 | 81 | ); |
| 82 | 82 | |
| 83 | 83 | } |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | public function is_dashboard_page($is_page = false, $hook = NULL) { |
| 91 | 91 | global $plugin_page; |
| 92 | 92 | |
| 93 | - if($is_page) { return $is_page; } |
|
| 93 | + if ($is_page) { return $is_page; } |
|
| 94 | 94 | |
| 95 | - return in_array( $plugin_page, array( 'gv-about', 'gv-credits', 'gv-getting-started' ) ); |
|
| 95 | + return in_array($plugin_page, array('gv-about', 'gv-credits', 'gv-getting-started')); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -105,10 +105,10 @@ discard block |
||
| 105 | 105 | public function admin_head() { |
| 106 | 106 | global $plugin_page; |
| 107 | 107 | |
| 108 | - remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-credits' ); |
|
| 109 | - remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-changelog' ); |
|
| 108 | + remove_submenu_page('edit.php?post_type=gravityview', 'gv-credits'); |
|
| 109 | + remove_submenu_page('edit.php?post_type=gravityview', 'gv-changelog'); |
|
| 110 | 110 | |
| 111 | - if( !$this->is_dashboard_page() ) { return; } |
|
| 111 | + if (!$this->is_dashboard_page()) { return; } |
|
| 112 | 112 | |
| 113 | 113 | ?> |
| 114 | 114 | <style type="text/css" media="screen"> |
@@ -139,23 +139,23 @@ discard block |
||
| 139 | 139 | global $plugin_page; |
| 140 | 140 | |
| 141 | 141 | // Don't fetch -beta, etc. |
| 142 | - list( $display_version ) = explode( '-', GravityView_Plugin::version ); |
|
| 142 | + list($display_version) = explode('-', GravityView_Plugin::version); |
|
| 143 | 143 | |
| 144 | - $selected = !empty( $plugin_page ) ? $plugin_page : 'gv-getting-started'; |
|
| 144 | + $selected = !empty($plugin_page) ? $plugin_page : 'gv-getting-started'; |
|
| 145 | 145 | ?> |
| 146 | 146 | |
| 147 | - <h1><img class="alignleft" src="<?php echo plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ); ?>" width="100" height="132" /><?php printf( esc_html__( 'Welcome to GravityView %s', 'gravityview' ), $display_version ); ?></h1> |
|
| 148 | - <div class="about-text"><?php esc_html_e( 'Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview' ); ?></div> |
|
| 147 | + <h1><img class="alignleft" src="<?php echo plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE); ?>" width="100" height="132" /><?php printf(esc_html__('Welcome to GravityView %s', 'gravityview'), $display_version); ?></h1> |
|
| 148 | + <div class="about-text"><?php esc_html_e('Thank you for installing GravityView. Beautifully display your Gravity Forms entries.', 'gravityview'); ?></div> |
|
| 149 | 149 | |
| 150 | 150 | <h2 class="nav-tab-wrapper clear"> |
| 151 | - <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 152 | - <?php _e( "Getting Started", 'gravityview' ); ?> |
|
| 151 | + <a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 152 | + <?php _e("Getting Started", 'gravityview'); ?> |
|
| 153 | 153 | </a> |
| 154 | - <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 155 | - <?php _e( "List of Changes", 'gravityview' ); ?> |
|
| 154 | + <a class="nav-tab <?php echo $selected == 'gv-changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-changelog', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 155 | + <?php _e("List of Changes", 'gravityview'); ?> |
|
| 156 | 156 | </a> |
| 157 | - <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>"> |
|
| 158 | - <?php _e( 'Credits', 'gravityview' ); ?> |
|
| 157 | + <a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url(admin_url(add_query_arg(array('page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php'))); ?>"> |
|
| 158 | + <?php _e('Credits', 'gravityview'); ?> |
|
| 159 | 159 | </a> |
| 160 | 160 | </h2> |
| 161 | 161 | <?php |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | |
| 206 | 206 | <div class="last-feature"> |
| 207 | 207 | <h2>Embed Views in Posts & Pages</h2> |
| 208 | - <p><img src="<?php echo plugins_url( 'assets/images/screenshots/add-view-button.png', GRAVITYVIEW_FILE ); ?>" class="gv-welcome-screenshots" height="35" width="97" />Views don’t need to be embedded in a post or page, but you can if you want. Embed Views using the "Add View" button above your content editor.</p> |
|
| 208 | + <p><img src="<?php echo plugins_url('assets/images/screenshots/add-view-button.png', GRAVITYVIEW_FILE); ?>" class="gv-welcome-screenshots" height="35" width="97" />Views don’t need to be embedded in a post or page, but you can if you want. Embed Views using the "Add View" button above your content editor.</p> |
|
| 209 | 209 | </div> |
| 210 | 210 | |
| 211 | 211 | </div> |
| 212 | 212 | |
| 213 | 213 | <div class="feature-section clear"> |
| 214 | 214 | <h2>Configure Multiple Entry, Single Entry, and Edit Entry Layouts</h2> |
| 215 | - <p><img src="<?php echo plugins_url( 'assets/images/screenshots/add-field.png', GRAVITYVIEW_FILE ); ?>" alt="Add a field dialog box" class="gv-welcome-screenshots" />You can configure what fields are displayed in <strong>Multiple Entry</strong>, <strong>Single Entry</strong>, and <strong>Edit Entry</strong> modes. These can be configured by clicking on the tabs in "View Configuration."</p> |
|
| 215 | + <p><img src="<?php echo plugins_url('assets/images/screenshots/add-field.png', GRAVITYVIEW_FILE); ?>" alt="Add a field dialog box" class="gv-welcome-screenshots" />You can configure what fields are displayed in <strong>Multiple Entry</strong>, <strong>Single Entry</strong>, and <strong>Edit Entry</strong> modes. These can be configured by clicking on the tabs in "View Configuration."</p> |
|
| 216 | 216 | |
| 217 | 217 | <ul class="ul-disc"> |
| 218 | 218 | <li>Click "+ Add Field" to add a field to a zone</li> |
@@ -254,23 +254,23 @@ discard block |
||
| 254 | 254 | |
| 255 | 255 | <div class="changelog point-releases"> |
| 256 | 256 | |
| 257 | - <h2 class="subtitle" style="text-align: center;"><?php esc_html_e('What’s New', 'gravityview' ); ?></h2> |
|
| 257 | + <h2 class="subtitle" style="text-align: center;"><?php esc_html_e('What’s New', 'gravityview'); ?></h2> |
|
| 258 | 258 | |
| 259 | 259 | <div class="feature-section col two-col" style="margin-top:0"> |
| 260 | 260 | <div class="col col-1"> |
| 261 | - <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url( 'assets/images/screenshots/caps.png', GRAVITYVIEW_FILE ); ?>" alt="Icons representing capabilities"></div> |
|
| 261 | + <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url('assets/images/screenshots/caps.png', GRAVITYVIEW_FILE); ?>" alt="Icons representing capabilities"></div> |
|
| 262 | 262 | <h4 class="higher">Capability Management</h4> |
| 263 | 263 | <p>Manage what users and roles have access to GravityView functionality. <a href="http://docs.gravityview.co/article/311-gravityview-capabilities">See what capabilities are available</a>.</p> |
| 264 | 264 | |
| 265 | - <div class="media-container" style="margin-top: 2em; min-height:80px;"><img src="<?php echo plugins_url( 'assets/images/screenshots/get.png', GRAVITYVIEW_FILE ); ?>" alt=""></div> |
|
| 265 | + <div class="media-container" style="margin-top: 2em; min-height:80px;"><img src="<?php echo plugins_url('assets/images/screenshots/get.png', GRAVITYVIEW_FILE); ?>" alt=""></div> |
|
| 266 | 266 | <h4 class="higher">The <code>{get}</code> Merge Tag</h4> |
| 267 | 267 | <p>Pass data using URLs and create even more powerful integrations with GravityView. <a href="http://docs.gravityview.co/article/314-the-get-merge-tag">Learn how to use <code>{get}</code></a>.</p> |
| 268 | 268 | </div> |
| 269 | 269 | |
| 270 | 270 | <div class="col col-2 last-feature"> |
| 271 | - <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url( 'assets/images/screenshots/support-port.png', GRAVITYVIEW_FILE ); ?>" alt="The Support Port"></div> |
|
| 271 | + <div class="media-container" style="min-height:81px; border: none;"><img src="<?php echo plugins_url('assets/images/screenshots/support-port.png', GRAVITYVIEW_FILE); ?>" alt="The Support Port"></div> |
|
| 272 | 272 | <h4 class="higher">Support Port</h4> |
| 273 | - <p>Users can easily search GravityView help docs. Administrators can use it to contact support. Just click the <img src="<?php echo plugins_url( 'assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ); ?>" width="16" alt="The Support Port icon looks like a question mark"> icon on GravityView screens to activate.</p> |
|
| 273 | + <p>Users can easily search GravityView help docs. Administrators can use it to contact support. Just click the <img src="<?php echo plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE); ?>" width="16" alt="The Support Port icon looks like a question mark"> icon on GravityView screens to activate.</p> |
|
| 274 | 274 | </div> |
| 275 | 275 | </div> |
| 276 | 276 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | <?php $this->tabs(); ?> |
| 621 | 621 | |
| 622 | - <p class="about-description"><?php _e( 'GravityView is brought to you by:', 'gravityview' ); ?></p> |
|
| 622 | + <p class="about-description"><?php _e('GravityView is brought to you by:', 'gravityview'); ?></p> |
|
| 623 | 623 | |
| 624 | 624 | <div class="feature-section col two-col"> |
| 625 | 625 | |
@@ -627,14 +627,14 @@ discard block |
||
| 627 | 627 | <h2>Zack Katz</h2> |
| 628 | 628 | <h4 style="font-weight:0; margin-top:0">Project Lead & Developer</h4> |
| 629 | 629 | <p></p> |
| 630 | - <p><img style="float:left; margin: 0 15px 10px 0;" src="<?php echo plugins_url( 'assets/images/zack.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Zack has been developing integrations with Gravity Forms since 2009. He is the President of Katz Web Services and lives with his wife (and cat) in Denver, Colorado.</p> |
|
| 630 | + <p><img style="float:left; margin: 0 15px 10px 0;" src="<?php echo plugins_url('assets/images/zack.jpg', GRAVITYVIEW_FILE); ?>" width="94" height="94" />Zack has been developing integrations with Gravity Forms since 2009. He is the President of Katz Web Services and lives with his wife (and cat) in Denver, Colorado.</p> |
|
| 631 | 631 | <p><a href="https://katz.co">View Zack’s website</a></p> |
| 632 | 632 | </div> |
| 633 | 633 | |
| 634 | 634 | <div class="col last-feature"> |
| 635 | 635 | <h2>Luis Godinho</h2> |
| 636 | 636 | <h4 style="font-weight:0; margin-top:0">Developer & Support</h4> |
| 637 | - <p><img style="margin: 0 15px 10px 0;" class="alignleft avatar" src="<?php echo plugins_url( 'assets/images/luis.jpg', GRAVITYVIEW_FILE ); ?>" width="94" height="94" />Luis is a WordPress developer passionate about WordPress. He is a co-founder and partner of GOMO, a digital agency located in Lisbon, Portugal.</p> |
|
| 637 | + <p><img style="margin: 0 15px 10px 0;" class="alignleft avatar" src="<?php echo plugins_url('assets/images/luis.jpg', GRAVITYVIEW_FILE); ?>" width="94" height="94" />Luis is a WordPress developer passionate about WordPress. He is a co-founder and partner of GOMO, a digital agency located in Lisbon, Portugal.</p> |
|
| 638 | 638 | <p><a href="http://tinygod.pt">View Luis’s website</a></p> |
| 639 | 639 | </div> |
| 640 | 640 | |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | |
| 645 | 645 | <div class="feature-section"> |
| 646 | 646 | <div> |
| 647 | - <h2><?php esc_attr_e( 'Contributors', 'gravityview' ); ?></h2> |
|
| 647 | + <h2><?php esc_attr_e('Contributors', 'gravityview'); ?></h2> |
|
| 648 | 648 | |
| 649 | 649 | <ul class="wp-people-group"> |
| 650 | 650 | <li class="wp-person">Bengali translation by <a href="https://www.transifex.com/accounts/profile/tareqhi/">@tareqhi</a></li> |
@@ -665,8 +665,8 @@ discard block |
||
| 665 | 665 | <li class="wp-person">Code contributions by <a href="https://github.com/ryanduff">@ryanduff</a> and <a href="https://github.com/dmlinn">@dmlinn</a></li> |
| 666 | 666 | </ul> |
| 667 | 667 | |
| 668 | - <h4><?php esc_attr_e( 'Want to contribute?', 'gravityview' ); ?></h4> |
|
| 669 | - <p><?php echo sprintf( esc_attr__( 'If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>' ); ?></p> |
|
| 668 | + <h4><?php esc_attr_e('Want to contribute?', 'gravityview'); ?></h4> |
|
| 669 | + <p><?php echo sprintf(esc_attr__('If you want to contribute to the code, %syou can on Github%s. If your contributions are accepted, you will be thanked here.', 'gravityview'), '<a href="https://github.com/katzwebservices/GravityView">', '</a>'); ?></p> |
|
| 670 | 670 | </div> |
| 671 | 671 | </div> |
| 672 | 672 | |
@@ -705,34 +705,34 @@ discard block |
||
| 705 | 705 | global $plugin_page; |
| 706 | 706 | |
| 707 | 707 | // Bail if we're just editing the plugin |
| 708 | - if( $plugin_page === 'plugin-editor.php' ) { return; } |
|
| 708 | + if ($plugin_page === 'plugin-editor.php') { return; } |
|
| 709 | 709 | |
| 710 | 710 | // Bail if no activation redirect |
| 711 | - if ( ! get_transient( '_gv_activation_redirect' ) ) { return; } |
|
| 711 | + if (!get_transient('_gv_activation_redirect')) { return; } |
|
| 712 | 712 | |
| 713 | 713 | // Delete the redirect transient |
| 714 | - delete_transient( '_gv_activation_redirect' ); |
|
| 714 | + delete_transient('_gv_activation_redirect'); |
|
| 715 | 715 | |
| 716 | - $upgrade = get_option( 'gv_version_upgraded_from' ); |
|
| 716 | + $upgrade = get_option('gv_version_upgraded_from'); |
|
| 717 | 717 | |
| 718 | 718 | // Don't do anything if they've already seen the new version info |
| 719 | - if( $upgrade === GravityView_Plugin::version ) { |
|
| 719 | + if ($upgrade === GravityView_Plugin::version) { |
|
| 720 | 720 | return; |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | // Add "Upgraded From" Option |
| 724 | - update_option( 'gv_version_upgraded_from', GravityView_Plugin::version ); |
|
| 724 | + update_option('gv_version_upgraded_from', GravityView_Plugin::version); |
|
| 725 | 725 | |
| 726 | 726 | // Bail if activating from network, or bulk |
| 727 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { return; } |
|
| 727 | + if (is_network_admin() || isset($_GET['activate-multi'])) { return; } |
|
| 728 | 728 | |
| 729 | 729 | // First time install |
| 730 | - if( ! $upgrade ) { |
|
| 731 | - wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit; |
|
| 730 | + if (!$upgrade) { |
|
| 731 | + wp_safe_redirect(admin_url('edit.php?post_type=gravityview&page=gv-getting-started')); exit; |
|
| 732 | 732 | } |
| 733 | 733 | // Update |
| 734 | 734 | else { |
| 735 | - wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-changelog' ) ); exit; |
|
| 735 | + wp_safe_redirect(admin_url('edit.php?post_type=gravityview&page=gv-changelog')); exit; |
|
| 736 | 736 | } |
| 737 | 737 | } |
| 738 | 738 | } |
@@ -4,7 +4,9 @@ |
||
| 4 | 4 | //set_site_transient( 'update_plugins', null ); |
| 5 | 5 | |
| 6 | 6 | // Exit if accessed directly |
| 7 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 7 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 8 | + exit; |
|
| 9 | +} |
|
| 8 | 10 | |
| 9 | 11 | /** |
| 10 | 12 | * Allows plugins to use their own update API. |
@@ -146,20 +146,20 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | if( !empty( $field['custom_class'] ) ) { |
| 148 | 148 | |
| 149 | - $custom_class = $field['custom_class']; |
|
| 149 | + $custom_class = $field['custom_class']; |
|
| 150 | 150 | |
| 151 | - if( !empty( $entry ) ) { |
|
| 151 | + if( !empty( $entry ) ) { |
|
| 152 | 152 | |
| 153 | - // We want the merge tag to be formatted as a class. The merge tag may be |
|
| 154 | - // replaced by a multiple-word value that should be output as a single class. |
|
| 155 | - // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
|
| 156 | - add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 153 | + // We want the merge tag to be formatted as a class. The merge tag may be |
|
| 154 | + // replaced by a multiple-word value that should be output as a single class. |
|
| 155 | + // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
|
| 156 | + add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 157 | 157 | |
| 158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 158 | + $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 159 | 159 | |
| 160 | - // And then we want life to return to normal |
|
| 161 | - remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 162 | - } |
|
| 160 | + // And then we want life to return to normal |
|
| 161 | + remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | 164 | // And now we want the spaces to be handled nicely. |
| 165 | 165 | $classes[] = gravityview_sanitize_html_class( $custom_class ); |
@@ -591,29 +591,29 @@ discard block |
||
| 591 | 591 | return sanitize_title( $slug ); |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta |
|
| 596 | - * |
|
| 597 | - * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
| 598 | - * |
|
| 599 | - * @param $entry array Gravity Forms entry object |
|
| 600 | - * @param $form array Gravity Forms form object |
|
| 601 | - */ |
|
| 602 | - public static function entry_create_custom_slug( $entry, $form ) { |
|
| 603 | - /** |
|
| 604 | - * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
|
| 605 | - * @param boolean $custom Should we process the custom entry slug? |
|
| 606 | - */ |
|
| 607 | - $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 608 | - if( $custom ) { |
|
| 609 | - // create the gravityview_unique_id and save it |
|
| 594 | + /** |
|
| 595 | + * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta |
|
| 596 | + * |
|
| 597 | + * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 ); |
|
| 598 | + * |
|
| 599 | + * @param $entry array Gravity Forms entry object |
|
| 600 | + * @param $form array Gravity Forms form object |
|
| 601 | + */ |
|
| 602 | + public static function entry_create_custom_slug( $entry, $form ) { |
|
| 603 | + /** |
|
| 604 | + * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
|
| 605 | + * @param boolean $custom Should we process the custom entry slug? |
|
| 606 | + */ |
|
| 607 | + $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 608 | + if( $custom ) { |
|
| 609 | + // create the gravityview_unique_id and save it |
|
| 610 | 610 | |
| 611 | - // Get the entry hash |
|
| 612 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 613 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 611 | + // Get the entry hash |
|
| 612 | + $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 613 | + gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 614 | 614 | |
| 615 | - } |
|
| 616 | - } |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | 618 | |
| 619 | 619 | |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | |
| 852 | 852 | // If there was an error, continue to the next term. |
| 853 | 853 | if ( is_wp_error( $term_link ) ) { |
| 854 | - continue; |
|
| 854 | + continue; |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
@@ -214,7 +214,6 @@ discard block |
||
| 214 | 214 | * |
| 215 | 215 | * @access public |
| 216 | 216 | * @param array $entry |
| 217 | - * @param integer $field |
|
| 218 | 217 | * @return null|string |
| 219 | 218 | */ |
| 220 | 219 | public static function field_value( $entry, $field_settings, $format = 'html' ) { |
@@ -967,7 +966,7 @@ discard block |
||
| 967 | 966 | * Get the current View ID being rendered |
| 968 | 967 | * |
| 969 | 968 | * @global GravityView_View $gravityview_view |
| 970 | - * @return string View context "directory" or "single" |
|
| 969 | + * @return integer View context "directory" or "single" |
|
| 971 | 970 | */ |
| 972 | 971 | function gravityview_get_view_id() { |
| 973 | 972 | return GravityView_View::getInstance()->getViewId(); |
@@ -23,36 +23,36 @@ discard block |
||
| 23 | 23 | * @param boolean $force_show_label Whether to always show the label, regardless of field settings |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public static function field_label( $field, $entry = array(), $force_show_label = false ) { |
|
| 26 | + public static function field_label($field, $entry = array(), $force_show_label = false) { |
|
| 27 | 27 | $gravityview_view = GravityView_View::getInstance(); |
| 28 | 28 | |
| 29 | 29 | $form = $gravityview_view->getForm(); |
| 30 | 30 | |
| 31 | 31 | $label = ''; |
| 32 | 32 | |
| 33 | - if( !empty( $field['show_label'] ) || $force_show_label ) { |
|
| 33 | + if (!empty($field['show_label']) || $force_show_label) { |
|
| 34 | 34 | |
| 35 | 35 | $label = $field['label']; |
| 36 | 36 | |
| 37 | 37 | // Support Gravity Forms 1.9+ |
| 38 | - if( class_exists( 'GF_Field' ) ) { |
|
| 38 | + if (class_exists('GF_Field')) { |
|
| 39 | 39 | |
| 40 | - $field_object = RGFormsModel::get_field( $form, $field['id'] ); |
|
| 40 | + $field_object = RGFormsModel::get_field($form, $field['id']); |
|
| 41 | 41 | |
| 42 | - if( $field_object ) { |
|
| 42 | + if ($field_object) { |
|
| 43 | 43 | |
| 44 | - $input = GFFormsModel::get_input( $field_object, $field['id'] ); |
|
| 44 | + $input = GFFormsModel::get_input($field_object, $field['id']); |
|
| 45 | 45 | |
| 46 | 46 | // This is a complex field, with labels on a per-input basis |
| 47 | - if( $input ) { |
|
| 47 | + if ($input) { |
|
| 48 | 48 | |
| 49 | 49 | // Does the input have a custom label on a per-input basis? Otherwise, default label. |
| 50 | - $label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label']; |
|
| 50 | + $label = !empty($input['customLabel']) ? $input['customLabel'] : $input['label']; |
|
| 51 | 51 | |
| 52 | 52 | } else { |
| 53 | 53 | |
| 54 | 54 | // This is a field with one label |
| 55 | - $label = $field_object->get_field_label( true, $field['label'] ); |
|
| 55 | + $label = $field_object->get_field_label(true, $field['label']); |
|
| 56 | 56 | |
| 57 | 57 | } |
| 58 | 58 | |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // Use Gravity Forms label by default, but if a custom label is defined in GV, use it. |
| 64 | - if ( !empty( $field['custom_label'] ) ) { |
|
| 64 | + if (!empty($field['custom_label'])) { |
|
| 65 | 65 | |
| 66 | - $label = self::replace_variables( $field['custom_label'], $form, $entry ); |
|
| 66 | + $label = self::replace_variables($field['custom_label'], $form, $entry); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param[in,out] string $appended_content Content you can add after a label. Empty by default. |
| 73 | 73 | * @param[in] array $field GravityView field array |
| 74 | 74 | */ |
| 75 | - $label .= apply_filters( 'gravityview_render_after_label', '', $field ); |
|
| 75 | + $label .= apply_filters('gravityview_render_after_label', '', $field); |
|
| 76 | 76 | |
| 77 | 77 | } // End $field['show_label'] |
| 78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param[in] array $form Gravity Forms form array |
| 85 | 85 | * @param[in] array $entry Gravity Forms entry array |
| 86 | 86 | */ |
| 87 | - $label = apply_filters( 'gravityview/template/field_label', $label, $field, $form, $entry ); |
|
| 87 | + $label = apply_filters('gravityview/template/field_label', $label, $field, $form, $entry); |
|
| 88 | 88 | |
| 89 | 89 | return $label; |
| 90 | 90 | } |
@@ -99,8 +99,8 @@ discard block |
||
| 99 | 99 | * @param array $entry GF Entry array |
| 100 | 100 | * @return string Text with variables maybe replaced |
| 101 | 101 | */ |
| 102 | - public static function replace_variables($text, $form, $entry ) { |
|
| 103 | - return GravityView_Merge_Tags::replace_variables( $text, $form, $entry ); |
|
| 102 | + public static function replace_variables($text, $form, $entry) { |
|
| 103 | + return GravityView_Merge_Tags::replace_variables($text, $form, $entry); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,19 +113,19 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return string|null If not empty, string in $format format. Otherwise, null. |
| 115 | 115 | */ |
| 116 | - public static function field_width( $field, $format = '%d%%' ) { |
|
| 116 | + public static function field_width($field, $format = '%d%%') { |
|
| 117 | 117 | |
| 118 | 118 | $width = NULL; |
| 119 | 119 | |
| 120 | - if( !empty( $field['width'] ) ) { |
|
| 121 | - $width = absint( $field['width'] ); |
|
| 120 | + if (!empty($field['width'])) { |
|
| 121 | + $width = absint($field['width']); |
|
| 122 | 122 | |
| 123 | 123 | // If using percentages, limit to 100% |
| 124 | - if( '%d%%' === $format && $width > 100 ) { |
|
| 124 | + if ('%d%%' === $format && $width > 100) { |
|
| 125 | 125 | $width = 100; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $width = sprintf( $format, $width ); |
|
| 128 | + $width = sprintf($format, $width); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | return $width; |
@@ -139,38 +139,38 @@ discard block |
||
| 139 | 139 | * @param mixed $field |
| 140 | 140 | * @return string |
| 141 | 141 | */ |
| 142 | - public static function field_class( $field, $form = NULL, $entry = NULL ) { |
|
| 142 | + public static function field_class($field, $form = NULL, $entry = NULL) { |
|
| 143 | 143 | $gravityview_view = GravityView_View::getInstance(); |
| 144 | 144 | |
| 145 | 145 | $classes = array(); |
| 146 | 146 | |
| 147 | - if( !empty( $field['custom_class'] ) ) { |
|
| 147 | + if (!empty($field['custom_class'])) { |
|
| 148 | 148 | |
| 149 | 149 | $custom_class = $field['custom_class']; |
| 150 | 150 | |
| 151 | - if( !empty( $entry ) ) { |
|
| 151 | + if (!empty($entry)) { |
|
| 152 | 152 | |
| 153 | 153 | // We want the merge tag to be formatted as a class. The merge tag may be |
| 154 | 154 | // replaced by a multiple-word value that should be output as a single class. |
| 155 | 155 | // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager` |
| 156 | 156 | add_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
| 157 | 157 | |
| 158 | - $custom_class = self::replace_variables( $custom_class, $form, $entry); |
|
| 158 | + $custom_class = self::replace_variables($custom_class, $form, $entry); |
|
| 159 | 159 | |
| 160 | 160 | // And then we want life to return to normal |
| 161 | 161 | remove_filter('gform_merge_tag_filter', 'sanitize_html_class'); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // And now we want the spaces to be handled nicely. |
| 165 | - $classes[] = gravityview_sanitize_html_class( $custom_class ); |
|
| 165 | + $classes[] = gravityview_sanitize_html_class($custom_class); |
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if(!empty($field['id'])) { |
|
| 170 | - if( !empty( $form ) && !empty( $form['id'] ) ) { |
|
| 169 | + if (!empty($field['id'])) { |
|
| 170 | + if (!empty($form) && !empty($form['id'])) { |
|
| 171 | 171 | $form_id = '-'.$form['id']; |
| 172 | 172 | } else { |
| 173 | - $form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : ''; |
|
| 173 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | $classes[] = 'gv-field'.$form_id.'-'.$field['id']; |
@@ -191,21 +191,21 @@ discard block |
||
| 191 | 191 | * @param array $entry Gravity Forms entry array |
| 192 | 192 | * @return string Sanitized unique HTML `id` attribute for the field |
| 193 | 193 | */ |
| 194 | - public static function field_html_attr_id( $field, $form = array(), $entry = array() ) { |
|
| 194 | + public static function field_html_attr_id($field, $form = array(), $entry = array()) { |
|
| 195 | 195 | $gravityview_view = GravityView_View::getInstance(); |
| 196 | 196 | $id = $field['id']; |
| 197 | 197 | |
| 198 | - if ( ! empty( $id ) ) { |
|
| 199 | - if ( ! empty( $form ) && ! empty( $form['id'] ) ) { |
|
| 200 | - $form_id = '-' . $form['id']; |
|
| 198 | + if (!empty($id)) { |
|
| 199 | + if (!empty($form) && !empty($form['id'])) { |
|
| 200 | + $form_id = '-'.$form['id']; |
|
| 201 | 201 | } else { |
| 202 | - $form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : ''; |
|
| 202 | + $form_id = $gravityview_view->getFormId() ? '-'.$gravityview_view->getFormId() : ''; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - $id = 'gv-field' . $form_id . '-' . $field['id']; |
|
| 205 | + $id = 'gv-field'.$form_id.'-'.$field['id']; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - return esc_attr( $id ); |
|
| 208 | + return esc_attr($id); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -217,15 +217,15 @@ discard block |
||
| 217 | 217 | * @param integer $field |
| 218 | 218 | * @return null|string |
| 219 | 219 | */ |
| 220 | - public static function field_value( $entry, $field_settings, $format = 'html' ) { |
|
| 220 | + public static function field_value($entry, $field_settings, $format = 'html') { |
|
| 221 | 221 | |
| 222 | - if( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) { |
|
| 222 | + if (empty($entry['form_id']) || empty($field_settings['id'])) { |
|
| 223 | 223 | return NULL; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
| 227 | 227 | |
| 228 | - if( class_exists( 'GFCache' ) ) { |
|
| 228 | + if (class_exists('GFCache')) { |
|
| 229 | 229 | /** |
| 230 | 230 | * Gravity Forms' GFCache function was thrashing the database, causing double the amount of time for the field_value() method to run. |
| 231 | 231 | * |
@@ -240,18 +240,18 @@ discard block |
||
| 240 | 240 | * @param boolean false Tell Gravity Forms not to store this as a transient |
| 241 | 241 | * @param int 0 Time to store the value. 0 is maximum amount of time possible. |
| 242 | 242 | */ |
| 243 | - GFCache::set( "GFFormsModel::get_lead_field_value_" . $entry["id"] . "_" . $field_settings["id"], false, false, 0 ); |
|
| 243 | + GFCache::set("GFFormsModel::get_lead_field_value_".$entry["id"]."_".$field_settings["id"], false, false, 0); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $field_id = $field_settings['id']; |
| 247 | 247 | |
| 248 | 248 | $form = $gravityview_view->getForm(); |
| 249 | 249 | |
| 250 | - $field = gravityview_get_field( $form, $field_id ); |
|
| 250 | + $field = gravityview_get_field($form, $field_id); |
|
| 251 | 251 | |
| 252 | 252 | $field_type = RGFormsModel::get_input_type($field); |
| 253 | 253 | |
| 254 | - if( $field_type ) { |
|
| 254 | + if ($field_type) { |
|
| 255 | 255 | $field_type = $field['type']; |
| 256 | 256 | $value = RGFormsModel::get_lead_field_value($entry, $field); |
| 257 | 257 | } else { |
@@ -266,15 +266,15 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | $display_value = GFCommon::get_lead_field_display($field, $value, $entry["currency"], false, $format); |
| 268 | 268 | |
| 269 | - if( $errors = ob_get_clean() ) { |
|
| 270 | - do_action( 'gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors ); |
|
| 269 | + if ($errors = ob_get_clean()) { |
|
| 270 | + do_action('gravityview_log_error', 'GravityView_API[field_value] Errors when calling GFCommon::get_lead_field_display()', $errors); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | $display_value = apply_filters("gform_entry_field_value", $display_value, $field, $entry, $form); |
| 274 | 274 | |
| 275 | 275 | // prevent the use of merge_tags for non-admin fields |
| 276 | - if( !empty( $field['adminOnly'] ) ) { |
|
| 277 | - $display_value = self::replace_variables( $display_value, $form, $entry ); |
|
| 276 | + if (!empty($field['adminOnly'])) { |
|
| 277 | + $display_value = self::replace_variables($display_value, $form, $entry); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // Check whether the field exists in /includes/fields/{$field_type}.php |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $field_path = $gravityview_view->locate_template("fields/{$field_type}.php"); |
| 283 | 283 | |
| 284 | 284 | // Set the field data to be available in the templates |
| 285 | - $gravityview_view->setCurrentField( array( |
|
| 285 | + $gravityview_view->setCurrentField(array( |
|
| 286 | 286 | 'form' => $form, |
| 287 | 287 | 'field_id' => $field_id, |
| 288 | 288 | 'field' => $field, |
@@ -294,13 +294,13 @@ discard block |
||
| 294 | 294 | 'field_type' => $field_type, /** {@since 1.6} **/ |
| 295 | 295 | )); |
| 296 | 296 | |
| 297 | - if( ! empty( $field_path ) ) { |
|
| 297 | + if (!empty($field_path)) { |
|
| 298 | 298 | |
| 299 | - do_action( 'gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path ) ); |
|
| 299 | + do_action('gravityview_log_debug', sprintf('[field_value] Rendering %s', $field_path)); |
|
| 300 | 300 | |
| 301 | 301 | ob_start(); |
| 302 | 302 | |
| 303 | - load_template( $field_path, false ); |
|
| 303 | + load_template($field_path, false); |
|
| 304 | 304 | |
| 305 | 305 | $output = ob_get_clean(); |
| 306 | 306 | |
@@ -319,11 +319,11 @@ discard block |
||
| 319 | 319 | * Fields can override this by modifying the field data variable inside the field. See /templates/fields/post_image.php for an example. |
| 320 | 320 | * |
| 321 | 321 | */ |
| 322 | - if( !empty( $field_settings['show_as_link'] ) ) { |
|
| 322 | + if (!empty($field_settings['show_as_link'])) { |
|
| 323 | 323 | |
| 324 | - $link_atts = empty( $field_settings['new_window'] ) ? array() : array( 'target' => '_blank' ); |
|
| 324 | + $link_atts = empty($field_settings['new_window']) ? array() : array('target' => '_blank'); |
|
| 325 | 325 | |
| 326 | - $output = self::entry_link_html( $entry, $output, $link_atts, $field_settings ); |
|
| 326 | + $output = self::entry_link_html($entry, $output, $link_atts, $field_settings); |
|
| 327 | 327 | |
| 328 | 328 | } |
| 329 | 329 | |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | * @param array $entry The GF entry array |
| 335 | 335 | * @param array $field_settings Settings for the particular GV field |
| 336 | 336 | */ |
| 337 | - $output = apply_filters( 'gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 337 | + $output = apply_filters('gravityview_field_entry_value_'.$field_type, $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
| 338 | 338 | |
| 339 | 339 | /** |
| 340 | 340 | * @filter `gravityview_field_entry_value` Modify the field value output for all field types |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | * @param array $field_settings Settings for the particular GV field |
| 344 | 344 | * @param array $field_data {@since 1.6} |
| 345 | 345 | */ |
| 346 | - $output = apply_filters( 'gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField() ); |
|
| 346 | + $output = apply_filters('gravityview_field_entry_value', $output, $entry, $field_settings, $gravityview_view->getCurrentField()); |
|
| 347 | 347 | |
| 348 | 348 | return $output; |
| 349 | 349 | } |
@@ -357,18 +357,18 @@ discard block |
||
| 357 | 357 | * @param array $entry Gravity Forms entry array |
| 358 | 358 | * @param array $field_settings Array of field settings. Optional, but passed to the `gravityview_field_entry_link` filter |
| 359 | 359 | */ |
| 360 | - public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array() ) { |
|
| 360 | + public static function entry_link_html($entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array()) { |
|
| 361 | 361 | |
| 362 | - if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) { |
|
| 362 | + if (empty($entry) || !is_array($entry) || !isset($entry['id'])) { |
|
| 363 | 363 | |
| 364 | - do_action( 'gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry ); |
|
| 364 | + do_action('gravityview_log_debug', 'GravityView_API[entry_link_tag] Entry not defined; returning null', $entry); |
|
| 365 | 365 | |
| 366 | 366 | return NULL; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - $href = self::entry_link( $entry ); |
|
| 369 | + $href = self::entry_link($entry); |
|
| 370 | 370 | |
| 371 | - $link = gravityview_get_link( $href, $anchor_text, $passed_tag_atts ); |
|
| 371 | + $link = gravityview_get_link($href, $anchor_text, $passed_tag_atts); |
|
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * @filter `gravityview_field_entry_link` Modify the link HTML |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | * @param array $entry The GF entry array |
| 378 | 378 | * @param array $field_settings Settings for the particular GV field |
| 379 | 379 | */ |
| 380 | - $output = apply_filters( 'gravityview_field_entry_link', $link, $href, $entry, $field_settings ); |
|
| 380 | + $output = apply_filters('gravityview_field_entry_link', $link, $href, $entry, $field_settings); |
|
| 381 | 381 | |
| 382 | 382 | return $output; |
| 383 | 383 | } |
@@ -392,11 +392,11 @@ discard block |
||
| 392 | 392 | |
| 393 | 393 | $is_search = false; |
| 394 | 394 | |
| 395 | - if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) { |
|
| 395 | + if ($gravityview_view && ($gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search)) { |
|
| 396 | 396 | $is_search = true; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - if($is_search) { |
|
| 399 | + if ($is_search) { |
|
| 400 | 400 | $output = __('This search returned no results.', 'gravityview'); |
| 401 | 401 | } else { |
| 402 | 402 | $output = __('No entries match your request.', 'gravityview'); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | * @param string $output The existing "No Entries" text |
| 408 | 408 | * @param boolean $is_search Is the current page a search result, or just a multiple entries screen? |
| 409 | 409 | */ |
| 410 | - $output = apply_filters( 'gravitview_no_entries_text', $output, $is_search); |
|
| 410 | + $output = apply_filters('gravitview_no_entries_text', $output, $is_search); |
|
| 411 | 411 | |
| 412 | 412 | return $wpautop ? wpautop($output) : $output; |
| 413 | 413 | } |
@@ -421,42 +421,42 @@ discard block |
||
| 421 | 421 | * @param boolean $add_query_args Add pagination and sorting arguments |
| 422 | 422 | * @return string Permalink to multiple entries view |
| 423 | 423 | */ |
| 424 | - public static function directory_link( $post_id = NULL, $add_query_args = true ) { |
|
| 424 | + public static function directory_link($post_id = NULL, $add_query_args = true) { |
|
| 425 | 425 | global $post; |
| 426 | 426 | |
| 427 | 427 | $gravityview_view = GravityView_View::getInstance(); |
| 428 | 428 | |
| 429 | - if( empty( $post_id ) ) { |
|
| 429 | + if (empty($post_id)) { |
|
| 430 | 430 | |
| 431 | 431 | $post_id = false; |
| 432 | 432 | |
| 433 | 433 | // DataTables passes the Post ID |
| 434 | - if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
| 434 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 435 | 435 | |
| 436 | - $post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : false; |
|
| 436 | + $post_id = isset($_POST['post_id']) ? (int)$_POST['post_id'] : false; |
|
| 437 | 437 | |
| 438 | 438 | } else { |
| 439 | 439 | |
| 440 | 440 | // The Post ID has been passed via the shortcode |
| 441 | - if( !empty( $gravityview_view ) && $gravityview_view->getPostId() ) { |
|
| 441 | + if (!empty($gravityview_view) && $gravityview_view->getPostId()) { |
|
| 442 | 442 | |
| 443 | 443 | $post_id = $gravityview_view->getPostId(); |
| 444 | 444 | |
| 445 | 445 | } else { |
| 446 | 446 | |
| 447 | 447 | // This is a GravityView post type |
| 448 | - if( GravityView_frontend::getInstance()->isGravityviewPostType() ) { |
|
| 448 | + if (GravityView_frontend::getInstance()->isGravityviewPostType()) { |
|
| 449 | 449 | |
| 450 | - $post_id = isset( $gravityview_view ) ? $gravityview_view->getViewId() : $post->ID; |
|
| 450 | + $post_id = isset($gravityview_view) ? $gravityview_view->getViewId() : $post->ID; |
|
| 451 | 451 | |
| 452 | 452 | } else { |
| 453 | 453 | |
| 454 | 454 | // This is an embedded GravityView; use the embedded post's ID as the base. |
| 455 | - if( GravityView_frontend::getInstance()->isPostHasShortcode() && is_a( $post, 'WP_Post' ) ) { |
|
| 455 | + if (GravityView_frontend::getInstance()->isPostHasShortcode() && is_a($post, 'WP_Post')) { |
|
| 456 | 456 | |
| 457 | 457 | $post_id = $post->ID; |
| 458 | 458 | |
| 459 | - } elseif( $gravityview_view->getViewId() ) { |
|
| 459 | + } elseif ($gravityview_view->getViewId()) { |
|
| 460 | 460 | |
| 461 | 461 | // The GravityView has been embedded in a widget or in a template, and |
| 462 | 462 | // is not in the current content. Thus, we defer to the View's own ID. |
@@ -471,39 +471,39 @@ discard block |
||
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | // No post ID, get outta here. |
| 474 | - if( empty( $post_id ) ) { |
|
| 474 | + if (empty($post_id)) { |
|
| 475 | 475 | return NULL; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | // If we've saved the permalink in memory, use it |
| 479 | 479 | // @since 1.3 |
| 480 | - $link = wp_cache_get( 'gv_directory_link_'.$post_id ); |
|
| 480 | + $link = wp_cache_get('gv_directory_link_'.$post_id); |
|
| 481 | 481 | |
| 482 | - if( empty( $link ) ) { |
|
| 482 | + if (empty($link)) { |
|
| 483 | 483 | |
| 484 | - $link = get_permalink( $post_id ); |
|
| 484 | + $link = get_permalink($post_id); |
|
| 485 | 485 | |
| 486 | 486 | // If not yet saved, cache the permalink. |
| 487 | 487 | // @since 1.3 |
| 488 | - wp_cache_set( 'gv_directory_link_'.$post_id, $link ); |
|
| 488 | + wp_cache_set('gv_directory_link_'.$post_id, $link); |
|
| 489 | 489 | |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | // Deal with returning to proper pagination for embedded views |
| 493 | - if( $link && $add_query_args ) { |
|
| 493 | + if ($link && $add_query_args) { |
|
| 494 | 494 | |
| 495 | 495 | $args = array(); |
| 496 | 496 | |
| 497 | - if( $pagenum = rgget('pagenum') ) { |
|
| 498 | - $args['pagenum'] = intval( $pagenum ); |
|
| 497 | + if ($pagenum = rgget('pagenum')) { |
|
| 498 | + $args['pagenum'] = intval($pagenum); |
|
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - if( $sort = rgget('sort') ) { |
|
| 501 | + if ($sort = rgget('sort')) { |
|
| 502 | 502 | $args['sort'] = $sort; |
| 503 | 503 | $args['dir'] = rgget('dir'); |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | - $link = add_query_arg( $args, $link ); |
|
| 506 | + $link = add_query_arg($args, $link); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | return $link; |
@@ -520,10 +520,10 @@ discard block |
||
| 520 | 520 | * @param array $entry Entry data passed to provide additional information when generating the hash. Optional - don't rely on it being available. |
| 521 | 521 | * @return string Hashed unique value for entry |
| 522 | 522 | */ |
| 523 | - private static function get_custom_entry_slug( $id, $entry = array() ) { |
|
| 523 | + private static function get_custom_entry_slug($id, $entry = array()) { |
|
| 524 | 524 | |
| 525 | 525 | // Generate an unique hash to use as the default value |
| 526 | - $slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 ); |
|
| 526 | + $slug = substr(wp_hash($id, 'gravityview'.$id), 0, 8); |
|
| 527 | 527 | |
| 528 | 528 | /** |
| 529 | 529 | * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}` |
@@ -531,14 +531,14 @@ discard block |
||
| 531 | 531 | * @param string $id The entry ID |
| 532 | 532 | * @param array $entry Entry data array. May be empty. |
| 533 | 533 | */ |
| 534 | - $slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry ); |
|
| 534 | + $slug = apply_filters('gravityview_entry_slug', $slug, $id, $entry); |
|
| 535 | 535 | |
| 536 | 536 | // Make sure we have something - use the original ID as backup. |
| 537 | - if( empty( $slug ) ) { |
|
| 537 | + if (empty($slug)) { |
|
| 538 | 538 | $slug = $id; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - return sanitize_title( $slug ); |
|
| 541 | + return sanitize_title($slug); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | * @param array $entry Gravity Forms Entry array, optional. Used only to provide data to customize the `gravityview_entry_slug` filter |
| 553 | 553 | * @return string Unique slug ID, passed through `sanitize_title()` |
| 554 | 554 | */ |
| 555 | - public static function get_entry_slug( $id_or_string, $entry = array() ) { |
|
| 555 | + public static function get_entry_slug($id_or_string, $entry = array()) { |
|
| 556 | 556 | |
| 557 | 557 | /** |
| 558 | 558 | * Default: use the entry ID as the unique identifier |
@@ -563,32 +563,32 @@ discard block |
||
| 563 | 563 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
| 564 | 564 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
| 565 | 565 | */ |
| 566 | - $custom = apply_filters('gravityview_custom_entry_slug', false ); |
|
| 566 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
| 567 | 567 | |
| 568 | 568 | // If we're using custom slug... |
| 569 | - if ( $custom ) { |
|
| 569 | + if ($custom) { |
|
| 570 | 570 | |
| 571 | 571 | // Get the entry hash |
| 572 | - $hash = self::get_custom_entry_slug( $id_or_string, $entry ); |
|
| 572 | + $hash = self::get_custom_entry_slug($id_or_string, $entry); |
|
| 573 | 573 | |
| 574 | 574 | // See if the entry already has a hash set |
| 575 | - $value = gform_get_meta( $id_or_string, 'gravityview_unique_id' ); |
|
| 575 | + $value = gform_get_meta($id_or_string, 'gravityview_unique_id'); |
|
| 576 | 576 | |
| 577 | 577 | // If it does have a hash set, and the hash is expected, use it. |
| 578 | 578 | // This check allows users to change the hash structure using the |
| 579 | 579 | // gravityview_entry_hash filter and have the old hashes expire. |
| 580 | - if( empty( $value ) || $value !== $hash ) { |
|
| 580 | + if (empty($value) || $value !== $hash) { |
|
| 581 | 581 | |
| 582 | - gform_update_meta( $id_or_string, 'gravityview_unique_id', $hash ); |
|
| 582 | + gform_update_meta($id_or_string, 'gravityview_unique_id', $hash); |
|
| 583 | 583 | |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | $slug = $hash; |
| 587 | 587 | |
| 588 | - unset( $value, $hash ); |
|
| 588 | + unset($value, $hash); |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - return sanitize_title( $slug ); |
|
| 591 | + return sanitize_title($slug); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -599,18 +599,18 @@ discard block |
||
| 599 | 599 | * @param $entry array Gravity Forms entry object |
| 600 | 600 | * @param $form array Gravity Forms form object |
| 601 | 601 | */ |
| 602 | - public static function entry_create_custom_slug( $entry, $form ) { |
|
| 602 | + public static function entry_create_custom_slug($entry, $form) { |
|
| 603 | 603 | /** |
| 604 | 604 | * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta |
| 605 | 605 | * @param boolean $custom Should we process the custom entry slug? |
| 606 | 606 | */ |
| 607 | - $custom = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 608 | - if( $custom ) { |
|
| 607 | + $custom = apply_filters('gravityview_custom_entry_slug', false); |
|
| 608 | + if ($custom) { |
|
| 609 | 609 | // create the gravityview_unique_id and save it |
| 610 | 610 | |
| 611 | 611 | // Get the entry hash |
| 612 | - $hash = self::get_custom_entry_slug( $entry['id'], $entry ); |
|
| 613 | - gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash ); |
|
| 612 | + $hash = self::get_custom_entry_slug($entry['id'], $entry); |
|
| 613 | + gform_update_meta($entry['id'], 'gravityview_unique_id', $hash); |
|
| 614 | 614 | |
| 615 | 615 | } |
| 616 | 616 | } |
@@ -625,55 +625,55 @@ discard block |
||
| 625 | 625 | * @param boolean $add_directory_args True: Add args to help return to directory; False: only include args required to get to entry {@since 1.7.3} |
| 626 | 626 | * @return string Link to the entry with the directory parent slug |
| 627 | 627 | */ |
| 628 | - public static function entry_link( $entry, $post_id = NULL, $add_directory_args = true ) { |
|
| 628 | + public static function entry_link($entry, $post_id = NULL, $add_directory_args = true) { |
|
| 629 | 629 | |
| 630 | - if( ! empty( $entry ) && ! is_array( $entry ) ) { |
|
| 631 | - $entry = GVCommon::get_entry( $entry ); |
|
| 632 | - } else if( empty( $entry ) ) { |
|
| 630 | + if (!empty($entry) && !is_array($entry)) { |
|
| 631 | + $entry = GVCommon::get_entry($entry); |
|
| 632 | + } else if (empty($entry)) { |
|
| 633 | 633 | $entry = GravityView_frontend::getInstance()->getEntry(); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | // Second parameter used to be passed as $field; this makes sure it's not an array |
| 637 | - if( !is_numeric( $post_id ) ) { |
|
| 637 | + if (!is_numeric($post_id)) { |
|
| 638 | 638 | $post_id = NULL; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | // Get the permalink to the View |
| 642 | - $directory_link = self::directory_link( $post_id, false ); |
|
| 642 | + $directory_link = self::directory_link($post_id, false); |
|
| 643 | 643 | |
| 644 | 644 | // No post ID? Get outta here. |
| 645 | - if( empty( $directory_link ) ) { |
|
| 645 | + if (empty($directory_link)) { |
|
| 646 | 646 | return ''; |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | $query_arg_name = GravityView_Post_Types::get_entry_var_name(); |
| 650 | 650 | |
| 651 | - $entry_slug = self::get_entry_slug( $entry['id'], $entry ); |
|
| 651 | + $entry_slug = self::get_entry_slug($entry['id'], $entry); |
|
| 652 | 652 | |
| 653 | - if( get_option('permalink_structure') && !is_preview() ) { |
|
| 653 | + if (get_option('permalink_structure') && !is_preview()) { |
|
| 654 | 654 | |
| 655 | 655 | $args = array(); |
| 656 | 656 | |
| 657 | - $directory_link = trailingslashit( $directory_link ) . $query_arg_name . '/'. $entry_slug .'/'; |
|
| 657 | + $directory_link = trailingslashit($directory_link).$query_arg_name.'/'.$entry_slug.'/'; |
|
| 658 | 658 | |
| 659 | 659 | } else { |
| 660 | 660 | |
| 661 | - $args = array( $query_arg_name => $entry_slug ); |
|
| 661 | + $args = array($query_arg_name => $entry_slug); |
|
| 662 | 662 | } |
| 663 | 663 | |
| 664 | 664 | /** |
| 665 | 665 | * @since 1.7.3 |
| 666 | 666 | */ |
| 667 | - if( $add_directory_args ) { |
|
| 667 | + if ($add_directory_args) { |
|
| 668 | 668 | |
| 669 | - if( !empty( $_GET['pagenum'] ) ) { |
|
| 670 | - $args['pagenum'] = intval( $_GET['pagenum'] ); |
|
| 669 | + if (!empty($_GET['pagenum'])) { |
|
| 670 | + $args['pagenum'] = intval($_GET['pagenum']); |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | /** |
| 674 | 674 | * @since 1.7 |
| 675 | 675 | */ |
| 676 | - if( $sort = rgget('sort') ) { |
|
| 676 | + if ($sort = rgget('sort')) { |
|
| 677 | 677 | $args['sort'] = $sort; |
| 678 | 678 | $args['dir'] = rgget('dir'); |
| 679 | 679 | } |
@@ -685,11 +685,11 @@ discard block |
||
| 685 | 685 | * has the view id so that Advanced Filters can be applied correctly when rendering the single view |
| 686 | 686 | * @see GravityView_frontend::get_context_view_id() |
| 687 | 687 | */ |
| 688 | - if( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() ) { |
|
| 688 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views()) { |
|
| 689 | 689 | $args['gvid'] = gravityview_get_view_id(); |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | - return add_query_arg( $args, $directory_link ); |
|
| 692 | + return add_query_arg($args, $directory_link); |
|
| 693 | 693 | |
| 694 | 694 | } |
| 695 | 695 | |
@@ -699,12 +699,12 @@ discard block |
||
| 699 | 699 | |
| 700 | 700 | // inside loop functions |
| 701 | 701 | |
| 702 | -function gv_label( $field, $entry = NULL ) { |
|
| 703 | - return GravityView_API::field_label( $field, $entry ); |
|
| 702 | +function gv_label($field, $entry = NULL) { |
|
| 703 | + return GravityView_API::field_label($field, $entry); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | -function gv_class( $field, $form = NULL, $entry = array() ) { |
|
| 707 | - return GravityView_API::field_class( $field, $form, $entry ); |
|
| 706 | +function gv_class($field, $form = NULL, $entry = array()) { |
|
| 707 | + return GravityView_API::field_class($field, $form, $entry); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | /** |
@@ -716,11 +716,11 @@ discard block |
||
| 716 | 716 | * |
| 717 | 717 | * @return string CSS class, sanitized by gravityview_sanitize_html_class() |
| 718 | 718 | */ |
| 719 | -function gv_container_class( $class = '' ) { |
|
| 719 | +function gv_container_class($class = '') { |
|
| 720 | 720 | |
| 721 | - $default = sprintf( 'gv-container gv-container-%d', GravityView_View::getInstance()->getViewId() ); |
|
| 721 | + $default = sprintf('gv-container gv-container-%d', GravityView_View::getInstance()->getViewId()); |
|
| 722 | 722 | |
| 723 | - if( GravityView_View::getInstance()->isHideUntilSearched() ) { |
|
| 723 | + if (GravityView_View::getInstance()->isHideUntilSearched()) { |
|
| 724 | 724 | $default .= ' hidden'; |
| 725 | 725 | } |
| 726 | 726 | |
@@ -729,38 +729,38 @@ discard block |
||
| 729 | 729 | * @since 1.5.4 |
| 730 | 730 | * @param[in,out] string $class Default: `gv-container gv-container-{view id}`. If View is hidden until search, adds ` hidden` |
| 731 | 731 | */ |
| 732 | - $class = apply_filters( 'gravityview/render/container/class', $class . $default ); |
|
| 732 | + $class = apply_filters('gravityview/render/container/class', $class.$default); |
|
| 733 | 733 | |
| 734 | - $class = gravityview_sanitize_html_class( $class ); |
|
| 734 | + $class = gravityview_sanitize_html_class($class); |
|
| 735 | 735 | |
| 736 | 736 | echo $class; |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | -function gv_value( $entry, $field ) { |
|
| 739 | +function gv_value($entry, $field) { |
|
| 740 | 740 | |
| 741 | - $value = GravityView_API::field_value( $entry, $field ); |
|
| 741 | + $value = GravityView_API::field_value($entry, $field); |
|
| 742 | 742 | |
| 743 | - if( $value === '') { |
|
| 743 | + if ($value === '') { |
|
| 744 | 744 | /** |
| 745 | 745 | * @filter `gravityview_empty_value` What to display when a field is empty |
| 746 | 746 | * @param string $value (empty string) |
| 747 | 747 | */ |
| 748 | - $value = apply_filters( 'gravityview_empty_value', '' ); |
|
| 748 | + $value = apply_filters('gravityview_empty_value', ''); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | return $value; |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | -function gv_directory_link( $post = NULL, $add_pagination = true ) { |
|
| 755 | - return GravityView_API::directory_link( $post, $add_pagination ); |
|
| 754 | +function gv_directory_link($post = NULL, $add_pagination = true) { |
|
| 755 | + return GravityView_API::directory_link($post, $add_pagination); |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | -function gv_entry_link( $entry, $post_id = NULL ) { |
|
| 759 | - return GravityView_API::entry_link( $entry, $post_id ); |
|
| 758 | +function gv_entry_link($entry, $post_id = NULL) { |
|
| 759 | + return GravityView_API::entry_link($entry, $post_id); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | function gv_no_results($wpautop = true) { |
| 763 | - return GravityView_API::no_results( $wpautop ); |
|
| 763 | + return GravityView_API::no_results($wpautop); |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | /** |
@@ -772,21 +772,21 @@ discard block |
||
| 772 | 772 | |
| 773 | 773 | $href = gv_directory_link(); |
| 774 | 774 | |
| 775 | - if( empty( $href ) ) { return NULL; } |
|
| 775 | + if (empty($href)) { return NULL; } |
|
| 776 | 776 | |
| 777 | 777 | // calculate link label |
| 778 | 778 | $gravityview_view = GravityView_View::getInstance(); |
| 779 | 779 | |
| 780 | - $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __( '← Go back', 'gravityview' ); |
|
| 780 | + $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __('← Go back', 'gravityview'); |
|
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | 783 | * @filter `gravityview_go_back_label` Modify the back link text |
| 784 | 784 | * @since 1.0.9 |
| 785 | 785 | * @param string $label Existing label text |
| 786 | 786 | */ |
| 787 | - $label = apply_filters( 'gravityview_go_back_label', $label ); |
|
| 787 | + $label = apply_filters('gravityview_go_back_label', $label); |
|
| 788 | 788 | |
| 789 | - $link = gravityview_get_link( $href, esc_html( $label ), array( |
|
| 789 | + $link = gravityview_get_link($href, esc_html($label), array( |
|
| 790 | 790 | 'data-viewid' => $gravityview_view->getViewId() |
| 791 | 791 | )); |
| 792 | 792 | |
@@ -805,9 +805,9 @@ discard block |
||
| 805 | 805 | * @param string $display_value The value generated by Gravity Forms |
| 806 | 806 | * @return string Value |
| 807 | 807 | */ |
| 808 | -function gravityview_get_field_value( $entry, $field_id, $display_value ) { |
|
| 808 | +function gravityview_get_field_value($entry, $field_id, $display_value) { |
|
| 809 | 809 | |
| 810 | - if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) { |
|
| 810 | + if (floatval($field_id) === floor(floatval($field_id))) { |
|
| 811 | 811 | |
| 812 | 812 | // For the complete field value as generated by Gravity Forms |
| 813 | 813 | return $display_value; |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | } else { |
| 816 | 816 | |
| 817 | 817 | // For one part of the address (City, ZIP, etc.) |
| 818 | - return isset( $entry[ $field_id ] ) ? $entry[ $field_id ] : ''; |
|
| 818 | + return isset($entry[$field_id]) ? $entry[$field_id] : ''; |
|
| 819 | 819 | |
| 820 | 820 | } |
| 821 | 821 | |
@@ -831,48 +831,48 @@ discard block |
||
| 831 | 831 | * @param string $taxonomy Type of term (`post_tag` or `category`) |
| 832 | 832 | * @return string CSV of linked terms |
| 833 | 833 | */ |
| 834 | -function gravityview_convert_value_to_term_list( $value, $taxonomy = 'post_tag' ) { |
|
| 834 | +function gravityview_convert_value_to_term_list($value, $taxonomy = 'post_tag') { |
|
| 835 | 835 | |
| 836 | 836 | $output = array(); |
| 837 | 837 | |
| 838 | - $terms = explode( ', ', $value ); |
|
| 838 | + $terms = explode(', ', $value); |
|
| 839 | 839 | |
| 840 | - foreach ($terms as $term_name ) { |
|
| 840 | + foreach ($terms as $term_name) { |
|
| 841 | 841 | |
| 842 | 842 | // If we're processing a category, |
| 843 | - if( $taxonomy === 'category' ) { |
|
| 843 | + if ($taxonomy === 'category') { |
|
| 844 | 844 | |
| 845 | 845 | // Use rgexplode to prevent errors if : doesn't exist |
| 846 | - list( $term_name, $term_id ) = rgexplode( ':', $value, 2 ); |
|
| 846 | + list($term_name, $term_id) = rgexplode(':', $value, 2); |
|
| 847 | 847 | |
| 848 | 848 | // The explode was succesful; we have the category ID |
| 849 | - if( !empty( $term_id )) { |
|
| 850 | - $term = get_term_by( 'id', $term_id, $taxonomy ); |
|
| 849 | + if (!empty($term_id)) { |
|
| 850 | + $term = get_term_by('id', $term_id, $taxonomy); |
|
| 851 | 851 | } else { |
| 852 | 852 | // We have to fall back to the name |
| 853 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
| 853 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | } else { |
| 857 | 857 | // Use the name of the tag to get the full term information |
| 858 | - $term = get_term_by( 'name', $term_name, $taxonomy ); |
|
| 858 | + $term = get_term_by('name', $term_name, $taxonomy); |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | // There's still a tag/category here. |
| 862 | - if( $term ) { |
|
| 862 | + if ($term) { |
|
| 863 | 863 | |
| 864 | - $term_link = get_term_link( $term, $taxonomy ); |
|
| 864 | + $term_link = get_term_link($term, $taxonomy); |
|
| 865 | 865 | |
| 866 | 866 | // If there was an error, continue to the next term. |
| 867 | - if ( is_wp_error( $term_link ) ) { |
|
| 867 | + if (is_wp_error($term_link)) { |
|
| 868 | 868 | continue; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - $output[] = gravityview_get_link( $term_link, esc_html( $term->name ) ); |
|
| 871 | + $output[] = gravityview_get_link($term_link, esc_html($term->name)); |
|
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | - return implode(', ', $output ); |
|
| 875 | + return implode(', ', $output); |
|
| 876 | 876 | } |
| 877 | 877 | |
| 878 | 878 | /** |
@@ -882,12 +882,12 @@ discard block |
||
| 882 | 882 | * @param string $taxonomy Taxonomy of term to fetch. |
| 883 | 883 | * @return string String with terms |
| 884 | 884 | */ |
| 885 | -function gravityview_get_the_term_list( $post_id, $link = true, $taxonomy = 'post_tag' ) { |
|
| 885 | +function gravityview_get_the_term_list($post_id, $link = true, $taxonomy = 'post_tag') { |
|
| 886 | 886 | |
| 887 | - $output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' ); |
|
| 887 | + $output = get_the_term_list($post_id, $taxonomy, NULL, ', '); |
|
| 888 | 888 | |
| 889 | - if( empty( $link ) ) { |
|
| 890 | - return strip_tags( $output); |
|
| 889 | + if (empty($link)) { |
|
| 890 | + return strip_tags($output); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | return $output; |
@@ -906,17 +906,17 @@ discard block |
||
| 906 | 906 | $fe = GravityView_frontend::getInstance(); |
| 907 | 907 | |
| 908 | 908 | // Solve problem when loading content via admin-ajax.php |
| 909 | - if( ! $fe->getGvOutputData() ) { |
|
| 909 | + if (!$fe->getGvOutputData()) { |
|
| 910 | 910 | |
| 911 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.' ); |
|
| 911 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not defined; parsing content.'); |
|
| 912 | 912 | |
| 913 | 913 | $fe->parse_content(); |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | 916 | // Make 100% sure that we're dealing with a properly called situation |
| 917 | - if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) { |
|
| 917 | + if (!is_a($fe->getGvOutputData(), 'GravityView_View_Data')) { |
|
| 918 | 918 | |
| 919 | - do_action( 'gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData() ); |
|
| 919 | + do_action('gravityview_log_debug', '[gravityview_get_current_views] gv_output_data not an object or get_view not callable.', $fe->getGvOutputData()); |
|
| 920 | 920 | |
| 921 | 921 | return array(); |
| 922 | 922 | } |
@@ -930,18 +930,18 @@ discard block |
||
| 930 | 930 | * @see GravityView_View_Data::get_view() |
| 931 | 931 | * @return array View data with `id`, `view_id`, `form_id`, `template_id`, `atts`, `fields`, `widgets`, `form` keys. |
| 932 | 932 | */ |
| 933 | -function gravityview_get_current_view_data( $view_id = 0 ) { |
|
| 933 | +function gravityview_get_current_view_data($view_id = 0) { |
|
| 934 | 934 | |
| 935 | 935 | $fe = GravityView_frontend::getInstance(); |
| 936 | 936 | |
| 937 | - if( ! $fe->getGvOutputData() ) { return array(); } |
|
| 937 | + if (!$fe->getGvOutputData()) { return array(); } |
|
| 938 | 938 | |
| 939 | 939 | // If not set, grab the current view ID |
| 940 | - if( empty( $view_id ) ) { |
|
| 940 | + if (empty($view_id)) { |
|
| 941 | 941 | $view_id = $fe->get_context_view_id(); |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | - return $fe->getGvOutputData()->get_view( $view_id ); |
|
| 944 | + return $fe->getGvOutputData()->get_view($view_id); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | 947 | // Templates' hooks |
@@ -950,7 +950,7 @@ discard block |
||
| 950 | 950 | * @action `gravityview_before` Display content before a View. Used to render widget areas. Rendered outside the View container `<div>` |
| 951 | 951 | * @param int $view_id The ID of the View being displayed |
| 952 | 952 | */ |
| 953 | - do_action( 'gravityview_before', gravityview_get_view_id() ); |
|
| 953 | + do_action('gravityview_before', gravityview_get_view_id()); |
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | function gravityview_header() { |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | * @action `gravityview_header` Prepend content to the View container `<div>` |
| 959 | 959 | * @param int $view_id The ID of the View being displayed |
| 960 | 960 | */ |
| 961 | - do_action( 'gravityview_header', gravityview_get_view_id() ); |
|
| 961 | + do_action('gravityview_header', gravityview_get_view_id()); |
|
| 962 | 962 | } |
| 963 | 963 | |
| 964 | 964 | function gravityview_footer() { |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | * @action `gravityview_after` Display content after a View. Used to render footer widget areas. Rendered outside the View container `<div>` |
| 967 | 967 | * @param int $view_id The ID of the View being displayed |
| 968 | 968 | */ |
| 969 | - do_action( 'gravityview_footer', gravityview_get_view_id() ); |
|
| 969 | + do_action('gravityview_footer', gravityview_get_view_id()); |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | function gravityview_after() { |
@@ -974,7 +974,7 @@ discard block |
||
| 974 | 974 | * @action `gravityview_after` Append content to the View container `<div>` |
| 975 | 975 | * @param int $view_id The ID of the View being displayed |
| 976 | 976 | */ |
| 977 | - do_action( 'gravityview_after', gravityview_get_view_id() ); |
|
| 977 | + do_action('gravityview_after', gravityview_get_view_id()); |
|
| 978 | 978 | } |
| 979 | 979 | |
| 980 | 980 | /** |
@@ -1000,13 +1000,13 @@ discard block |
||
| 1000 | 1000 | * The Edit Entry functionality overrides this value. |
| 1001 | 1001 | * @param boolean $is_edit_entry |
| 1002 | 1002 | */ |
| 1003 | - $is_edit_entry = apply_filters( 'gravityview_is_edit_entry', false ); |
|
| 1003 | + $is_edit_entry = apply_filters('gravityview_is_edit_entry', false); |
|
| 1004 | 1004 | |
| 1005 | - if( $is_edit_entry ) { |
|
| 1005 | + if ($is_edit_entry) { |
|
| 1006 | 1006 | $context = 'edit'; |
| 1007 | - } else if( class_exists( 'GravityView_frontend' ) && $single = GravityView_frontend::is_single_entry() ) { |
|
| 1007 | + } else if (class_exists('GravityView_frontend') && $single = GravityView_frontend::is_single_entry()) { |
|
| 1008 | 1008 | $context = 'single'; |
| 1009 | - } else if( class_exists( 'GravityView_View' ) ) { |
|
| 1009 | + } else if (class_exists('GravityView_View')) { |
|
| 1010 | 1010 | $context = GravityView_View::getInstance()->getContext(); |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1031,18 +1031,18 @@ discard block |
||
| 1031 | 1031 | * @param string $gv_class Field class to add to the output HTML |
| 1032 | 1032 | * @return array Array of file output, with `file_path` and `html` keys (see comments above) |
| 1033 | 1033 | */ |
| 1034 | -function gravityview_get_files_array( $value, $gv_class = '' ) { |
|
| 1034 | +function gravityview_get_files_array($value, $gv_class = '') { |
|
| 1035 | 1035 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 1036 | 1036 | |
| 1037 | - if( !class_exists( 'GravityView_Field' ) ) { |
|
| 1038 | - include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' ); |
|
| 1037 | + if (!class_exists('GravityView_Field')) { |
|
| 1038 | + include_once(GRAVITYVIEW_DIR.'includes/fields/class-gravityview-field.php'); |
|
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | - if( !class_exists( 'GravityView_Field_FileUpload' ) ) { |
|
| 1042 | - include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' ); |
|
| 1041 | + if (!class_exists('GravityView_Field_FileUpload')) { |
|
| 1042 | + include_once(GRAVITYVIEW_DIR.'includes/fields/fileupload.php'); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | - return GravityView_Field_FileUpload::get_files_array( $value, $gv_class ); |
|
| 1045 | + return GravityView_Field_FileUpload::get_files_array($value, $gv_class); |
|
| 1046 | 1046 | } |
| 1047 | 1047 | |
| 1048 | 1048 | /** |
@@ -1056,16 +1056,16 @@ discard block |
||
| 1056 | 1056 | * @param string $address Address |
| 1057 | 1057 | * @return string URL of link to map of address |
| 1058 | 1058 | */ |
| 1059 | -function gravityview_get_map_link( $address ) { |
|
| 1059 | +function gravityview_get_map_link($address) { |
|
| 1060 | 1060 | |
| 1061 | - $address_qs = str_replace( array( '<br />', "\n" ), ' ', $address ); // Replace \n with spaces |
|
| 1062 | - $address_qs = urlencode( $address_qs ); |
|
| 1061 | + $address_qs = str_replace(array('<br />', "\n"), ' ', $address); // Replace \n with spaces |
|
| 1062 | + $address_qs = urlencode($address_qs); |
|
| 1063 | 1063 | |
| 1064 | 1064 | $url = "https://maps.google.com/maps?q={$address_qs}"; |
| 1065 | 1065 | |
| 1066 | - $link_text = esc_html__( 'Map It', 'gravityview' ); |
|
| 1066 | + $link_text = esc_html__('Map It', 'gravityview'); |
|
| 1067 | 1067 | |
| 1068 | - $link = gravityview_get_link( $url, $link_text, 'class=map-it-link' ); |
|
| 1068 | + $link = gravityview_get_link($url, $link_text, 'class=map-it-link'); |
|
| 1069 | 1069 | |
| 1070 | 1070 | /** |
| 1071 | 1071 | * @filter `gravityview_map_link` Modify the map link generated. You can use a different mapping service, for example. |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | * @param[in] string $address Address to generate link for |
| 1074 | 1074 | * @param[in] string $url URL generated by the function |
| 1075 | 1075 | */ |
| 1076 | - $link = apply_filters( 'gravityview_map_link', $link, $address, $url ); |
|
| 1076 | + $link = apply_filters('gravityview_map_link', $link, $address, $url); |
|
| 1077 | 1077 | |
| 1078 | 1078 | return $link; |
| 1079 | 1079 | } |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | * @param array $passed_args Associative array with field data. `field` and `form` are required. |
| 1095 | 1095 | * @return string Field output. If empty value and hide empty is true, return empty. |
| 1096 | 1096 | */ |
| 1097 | -function gravityview_field_output( $passed_args ) { |
|
| 1097 | +function gravityview_field_output($passed_args) { |
|
| 1098 | 1098 | $defaults = array( |
| 1099 | 1099 | 'entry' => null, |
| 1100 | 1100 | 'field' => null, |
@@ -1106,7 +1106,7 @@ discard block |
||
| 1106 | 1106 | 'zone_id' => null, |
| 1107 | 1107 | ); |
| 1108 | 1108 | |
| 1109 | - $args = wp_parse_args( $passed_args, $defaults ); |
|
| 1109 | + $args = wp_parse_args($passed_args, $defaults); |
|
| 1110 | 1110 | |
| 1111 | 1111 | /** |
| 1112 | 1112 | * @filter `gravityview/field_output/args` Modify the args before generation begins |
@@ -1114,15 +1114,15 @@ discard block |
||
| 1114 | 1114 | * @param array $args Associative array; `field` and `form` is required. |
| 1115 | 1115 | * @param array $passed_args Original associative array with field data. `field` and `form` are required. |
| 1116 | 1116 | */ |
| 1117 | - $args = apply_filters( 'gravityview/field_output/args', $args, $passed_args ); |
|
| 1117 | + $args = apply_filters('gravityview/field_output/args', $args, $passed_args); |
|
| 1118 | 1118 | |
| 1119 | 1119 | // Required fields. |
| 1120 | - if ( empty( $args['field'] ) || empty( $args['form'] ) ) { |
|
| 1121 | - do_action( 'gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args ); |
|
| 1120 | + if (empty($args['field']) || empty($args['form'])) { |
|
| 1121 | + do_action('gravityview_log_error', '[gravityview_field_output] Field or form are empty.', $args); |
|
| 1122 | 1122 | return ''; |
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | - $entry = empty( $args['entry'] ) ? array() : $args['entry']; |
|
| 1125 | + $entry = empty($args['entry']) ? array() : $args['entry']; |
|
| 1126 | 1126 | |
| 1127 | 1127 | /** |
| 1128 | 1128 | * Create the content variables for replacing. |
@@ -1138,36 +1138,36 @@ discard block |
||
| 1138 | 1138 | 'field_id' => '', |
| 1139 | 1139 | ); |
| 1140 | 1140 | |
| 1141 | - $context['value'] = gv_value( $entry, $args['field'] ); |
|
| 1141 | + $context['value'] = gv_value($entry, $args['field']); |
|
| 1142 | 1142 | |
| 1143 | 1143 | // If the value is empty and we're hiding empty, return empty. |
| 1144 | - if ( $context['value'] === '' && ! empty( $args['hide_empty'] ) ) { |
|
| 1144 | + if ($context['value'] === '' && !empty($args['hide_empty'])) { |
|
| 1145 | 1145 | return ''; |
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | - if ( $context['value'] !== '' && ! empty( $args['wpautop'] ) ) { |
|
| 1149 | - $context['value'] = wpautop( $context['value'] ); |
|
| 1148 | + if ($context['value'] !== '' && !empty($args['wpautop'])) { |
|
| 1149 | + $context['value'] = wpautop($context['value']); |
|
| 1150 | 1150 | } |
| 1151 | 1151 | |
| 1152 | 1152 | // Get width setting, if exists |
| 1153 | - $context['width'] = GravityView_API::field_width( $args['field'] ); |
|
| 1153 | + $context['width'] = GravityView_API::field_width($args['field']); |
|
| 1154 | 1154 | |
| 1155 | 1155 | // If replacing with CSS inline formatting, let's do it. |
| 1156 | - $context['width:style'] = GravityView_API::field_width( $args['field'], 'width:' . $context['width'] . '%;' ); |
|
| 1156 | + $context['width:style'] = GravityView_API::field_width($args['field'], 'width:'.$context['width'].'%;'); |
|
| 1157 | 1157 | |
| 1158 | 1158 | // Grab the Class using `gv_class` |
| 1159 | - $context['class'] = gv_class( $args['field'], $args['form'], $entry ); |
|
| 1160 | - $context['field_id'] = GravityView_API::field_html_attr_id( $args['field'], $args['form'], $entry ); |
|
| 1159 | + $context['class'] = gv_class($args['field'], $args['form'], $entry); |
|
| 1160 | + $context['field_id'] = GravityView_API::field_html_attr_id($args['field'], $args['form'], $entry); |
|
| 1161 | 1161 | |
| 1162 | 1162 | // Get field label if needed |
| 1163 | - if ( ! empty( $args['label_markup'] ) && ! empty( $args['field']['show_label'] ) ) { |
|
| 1164 | - $context['label'] = str_replace( array( '{{label}}', '{{ label }}' ), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup'] ); |
|
| 1163 | + if (!empty($args['label_markup']) && !empty($args['field']['show_label'])) { |
|
| 1164 | + $context['label'] = str_replace(array('{{label}}', '{{ label }}'), '<span class="gv-field-label">{{ label_value }}</span>', $args['label_markup']); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | // Default Label value |
| 1168 | - $context['label_value'] = gv_label( $args['field'], $entry ); |
|
| 1168 | + $context['label_value'] = gv_label($args['field'], $entry); |
|
| 1169 | 1169 | |
| 1170 | - if ( empty( $context['label'] ) && ! empty( $context['label_value'] ) ){ |
|
| 1170 | + if (empty($context['label']) && !empty($context['label_value'])) { |
|
| 1171 | 1171 | $context['label'] = '<span class="gv-field-label">{{ label_value }}</span>'; |
| 1172 | 1172 | } |
| 1173 | 1173 | |
@@ -1177,37 +1177,37 @@ discard block |
||
| 1177 | 1177 | * @param string $markup The HTML for the markup |
| 1178 | 1178 | * @param array $args All args for the field output |
| 1179 | 1179 | */ |
| 1180 | - $html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args ); |
|
| 1180 | + $html = apply_filters('gravityview/field_output/pre_html', $args['markup'], $args); |
|
| 1181 | 1181 | |
| 1182 | 1182 | /** |
| 1183 | 1183 | * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders |
| 1184 | 1184 | * @since 1.11 |
| 1185 | 1185 | * @param string $open_tag Open tag for template content placeholders. Default: `{{` |
| 1186 | 1186 | */ |
| 1187 | - $open_tag = apply_filters( 'gravityview/field_output/open_tag', '{{', $args ); |
|
| 1187 | + $open_tag = apply_filters('gravityview/field_output/open_tag', '{{', $args); |
|
| 1188 | 1188 | |
| 1189 | 1189 | /** |
| 1190 | 1190 | * @filter `gravityview/field_output/close_tag` Modify the closing tags for the template content placeholders |
| 1191 | 1191 | * @since 1.11 |
| 1192 | 1192 | * @param string $close_tag Close tag for template content placeholders. Default: `}}` |
| 1193 | 1193 | */ |
| 1194 | - $close_tag = apply_filters( 'gravityview/field_output/close_tag', '}}', $args ); |
|
| 1194 | + $close_tag = apply_filters('gravityview/field_output/close_tag', '}}', $args); |
|
| 1195 | 1195 | |
| 1196 | 1196 | /** |
| 1197 | 1197 | * Loop through each of the tags to replace and replace both `{{tag}}` and `{{ tag }}` with the values |
| 1198 | 1198 | * @since 1.11 |
| 1199 | 1199 | */ |
| 1200 | - foreach ( $context as $tag => $value ) { |
|
| 1200 | + foreach ($context as $tag => $value) { |
|
| 1201 | 1201 | |
| 1202 | 1202 | // If the tag doesn't exist just skip it |
| 1203 | - if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){ |
|
| 1203 | + if (false === strpos($html, $open_tag.$tag.$close_tag) && false === strpos($html, $open_tag.' '.$tag.' '.$close_tag)) { |
|
| 1204 | 1204 | continue; |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | 1207 | // Array to search |
| 1208 | 1208 | $search = array( |
| 1209 | - $open_tag . $tag . $close_tag, |
|
| 1210 | - $open_tag . ' ' . $tag . ' ' . $close_tag, |
|
| 1209 | + $open_tag.$tag.$close_tag, |
|
| 1210 | + $open_tag.' '.$tag.' '.$close_tag, |
|
| 1211 | 1211 | ); |
| 1212 | 1212 | |
| 1213 | 1213 | /** |
@@ -1216,26 +1216,26 @@ discard block |
||
| 1216 | 1216 | * @param string $value The content to be shown instead of the {{tag}} placeholder |
| 1217 | 1217 | * @param array $args Arguments passed to the function |
| 1218 | 1218 | */ |
| 1219 | - $value = apply_filters( 'gravityview/field_output/context/' . $tag, $value, $args ); |
|
| 1219 | + $value = apply_filters('gravityview/field_output/context/'.$tag, $value, $args); |
|
| 1220 | 1220 | |
| 1221 | 1221 | // Finally do the replace |
| 1222 | - $html = str_replace( $search, $value, $html ); |
|
| 1222 | + $html = str_replace($search, $value, $html); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | /** |
| 1226 | 1226 | * @todo Depricate `gravityview_field_output` |
| 1227 | 1227 | */ |
| 1228 | - $html = apply_filters( 'gravityview_field_output', $html, $args ); |
|
| 1228 | + $html = apply_filters('gravityview_field_output', $html, $args); |
|
| 1229 | 1229 | |
| 1230 | 1230 | /** |
| 1231 | 1231 | * @filter `gravityview/field_output/html` Modify field HTML output |
| 1232 | 1232 | * @param string $html Existing HTML output |
| 1233 | 1233 | * @param array $args Arguments passed to the function |
| 1234 | 1234 | */ |
| 1235 | - $html = apply_filters( 'gravityview/field_output/html', $html, $args ); |
|
| 1235 | + $html = apply_filters('gravityview/field_output/html', $html, $args); |
|
| 1236 | 1236 | |
| 1237 | 1237 | // Just free up a tiny amount of memory |
| 1238 | - unset( $value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag ); |
|
| 1238 | + unset($value, $args, $passed_args, $entry, $context, $search, $open_tag, $tag, $close_tag); |
|
| 1239 | 1239 | |
| 1240 | 1240 | return $html; |
| 1241 | 1241 | } |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | * @since 1.13.1 |
| 33 | 33 | * @var array Columns in the database for leads |
| 34 | 34 | */ |
| 35 | - private $lead_db_columns = array( 'id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status' ); |
|
| 35 | + private $lead_db_columns = array('id', 'form_id', 'post_id', 'date_created', 'is_starred', 'is_read', 'ip', 'source_url', 'user_agent', 'currency', 'payment_status', 'payment_date', 'payment_amount', 'transaction_id', 'is_fulfilled', 'created_by', 'transaction_type', 'status'); |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * |
| 39 | 39 | * @param array|int $form_ids Form ID or array of form IDs used in a request |
| 40 | 40 | * @param array $args Extra request parameters used to generate the query. This is used to generate the unique transient key. |
| 41 | 41 | */ |
| 42 | - function __construct( $form_ids = NULL, $args = array() ) { |
|
| 42 | + function __construct($form_ids = NULL, $args = array()) { |
|
| 43 | 43 | |
| 44 | 44 | $this->add_hooks(); |
| 45 | 45 | |
| 46 | - if ( ! is_null( $form_ids ) ) { |
|
| 46 | + if (!is_null($form_ids)) { |
|
| 47 | 47 | |
| 48 | 48 | $this->form_ids = $form_ids; |
| 49 | 49 | |
@@ -59,31 +59,31 @@ discard block |
||
| 59 | 59 | function add_hooks() { |
| 60 | 60 | |
| 61 | 61 | // Schedule cleanup of expired transients |
| 62 | - add_action( 'wp', array( $this, 'schedule_transient_cleanup' ) ); |
|
| 62 | + add_action('wp', array($this, 'schedule_transient_cleanup')); |
|
| 63 | 63 | |
| 64 | 64 | // Hook in to the scheduled cleanup, if scheduled |
| 65 | - add_action( 'gravityview-expired-transients', array( $this, 'delete_expired_transients' ) ); |
|
| 65 | + add_action('gravityview-expired-transients', array($this, 'delete_expired_transients')); |
|
| 66 | 66 | |
| 67 | 67 | // Trigger this when you need to prevent any results from being cached with forms that have been modified |
| 68 | - add_action( 'gravityview_clear_form_cache', array( $this, 'blacklist_add' ) ); |
|
| 68 | + add_action('gravityview_clear_form_cache', array($this, 'blacklist_add')); |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @since 1.14 |
| 72 | 72 | */ |
| 73 | - add_action( 'gravityview_clear_entry_cache', array( $this, 'entry_status_changed' ) ); |
|
| 73 | + add_action('gravityview_clear_entry_cache', array($this, 'entry_status_changed')); |
|
| 74 | 74 | |
| 75 | - add_action( 'gform_after_update_entry', array( $this, 'entry_updated' ), 10, 2 ); |
|
| 75 | + add_action('gform_after_update_entry', array($this, 'entry_updated'), 10, 2); |
|
| 76 | 76 | |
| 77 | - add_action( 'gform_entry_created', array( $this, 'entry_created' ), 10, 2 ); |
|
| 77 | + add_action('gform_entry_created', array($this, 'entry_created'), 10, 2); |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * @see RGFormsModel::update_lead_property() Trigger when any entry property changes |
| 81 | 81 | */ |
| 82 | - foreach( $this->lead_db_columns as $column ) { |
|
| 83 | - add_action( 'gform_update_' . $column, array( $this, 'entry_status_changed' ), 10, 3 ); |
|
| 82 | + foreach ($this->lead_db_columns as $column) { |
|
| 83 | + add_action('gform_update_'.$column, array($this, 'entry_status_changed'), 10, 3); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - add_action( 'gform_delete_lead', array( $this, 'entry_status_changed' ), 10 ); |
|
| 86 | + add_action('gform_delete_lead', array($this, 'entry_status_changed'), 10); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -99,22 +99,22 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | - public function entry_status_changed( $lead_id, $property_value = '', $previous_value = '' ) { |
|
| 102 | + public function entry_status_changed($lead_id, $property_value = '', $previous_value = '') { |
|
| 103 | 103 | |
| 104 | 104 | /** @var array $entry */ |
| 105 | - $entry = GFAPI::get_entry( $lead_id ); |
|
| 105 | + $entry = GFAPI::get_entry($lead_id); |
|
| 106 | 106 | |
| 107 | - if ( is_wp_error( $entry ) ) { |
|
| 107 | + if (is_wp_error($entry)) { |
|
| 108 | 108 | |
| 109 | 109 | /** @var WP_Error $entry */ |
| 110 | - do_action( 'gravityview_log_error', __METHOD__ . ' Could not retrieve entry ' . $lead_id . ' to delete it: ' . $entry->get_error_message() ); |
|
| 110 | + do_action('gravityview_log_error', __METHOD__.' Could not retrieve entry '.$lead_id.' to delete it: '.$entry->get_error_message()); |
|
| 111 | 111 | |
| 112 | 112 | return; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - do_action( 'gravityview_log_debug', __METHOD__ . ' adding form ' . $entry['form_id'] . ' to blacklist because entry #' . $lead_id . ' was deleted', array( 'value' => $property_value, 'previous' => $previous_value ) ); |
|
| 115 | + do_action('gravityview_log_debug', __METHOD__.' adding form '.$entry['form_id'].' to blacklist because entry #'.$lead_id.' was deleted', array('value' => $property_value, 'previous' => $previous_value)); |
|
| 116 | 116 | |
| 117 | - $this->blacklist_add( $entry['form_id'] ); |
|
| 117 | + $this->blacklist_add($entry['form_id']); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -125,11 +125,11 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return void |
| 127 | 127 | */ |
| 128 | - public function entry_updated( $form, $lead_id ) { |
|
| 128 | + public function entry_updated($form, $lead_id) { |
|
| 129 | 129 | |
| 130 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form ' . $form['id'] . ' to blacklist because entry #' . $lead_id . ' was updated' ); |
|
| 130 | + do_action('gravityview_log_debug', 'GravityView_Cache[entry_updated] adding form '.$form['id'].' to blacklist because entry #'.$lead_id.' was updated'); |
|
| 131 | 131 | |
| 132 | - $this->blacklist_add( $form['id'] ); |
|
| 132 | + $this->blacklist_add($form['id']); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | * |
| 143 | 143 | * @return void |
| 144 | 144 | */ |
| 145 | - public function entry_created( $entry, $form ) { |
|
| 145 | + public function entry_created($entry, $form) { |
|
| 146 | 146 | |
| 147 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[entry_created] adding form ' . $form['id'] . ' to blacklist because entry #' . $entry['id'] . ' was created' ); |
|
| 147 | + do_action('gravityview_log_debug', 'GravityView_Cache[entry_created] adding form '.$form['id'].' to blacklist because entry #'.$entry['id'].' was created'); |
|
| 148 | 148 | |
| 149 | - $this->blacklist_add( $form['id'] ); |
|
| 149 | + $this->blacklist_add($form['id']); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -156,20 +156,20 @@ discard block |
||
| 156 | 156 | * |
| 157 | 157 | * @return string Prefix for the cache string used in set_key() |
| 158 | 158 | */ |
| 159 | - protected function get_cache_key_prefix( $form_ids = NULL ) { |
|
| 159 | + protected function get_cache_key_prefix($form_ids = NULL) { |
|
| 160 | 160 | |
| 161 | - if ( is_null( $form_ids ) ) { |
|
| 161 | + if (is_null($form_ids)) { |
|
| 162 | 162 | $form_ids = $this->form_ids; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Normally just one form, but supports multiple forms |
| 166 | 166 | // |
| 167 | 167 | // Array of IDs 12, 5, 14 would result in `f-12f-5f-14` |
| 168 | - $forms = 'f:' . implode( '&f:', (array) $form_ids ); |
|
| 168 | + $forms = 'f:'.implode('&f:', (array)$form_ids); |
|
| 169 | 169 | |
| 170 | 170 | // Prefix for transient keys |
| 171 | 171 | // Now the prefix would be: `gv-cache-f-12f-5f-14` |
| 172 | - return 'gv-cache-' . $forms . '-'; |
|
| 172 | + return 'gv-cache-'.$forms.'-'; |
|
| 173 | 173 | |
| 174 | 174 | } |
| 175 | 175 | |
@@ -179,17 +179,17 @@ discard block |
||
| 179 | 179 | protected function set_key() { |
| 180 | 180 | |
| 181 | 181 | // Don't set key if no forms have been set. |
| 182 | - if ( empty( $this->form_ids ) ) { |
|
| 182 | + if (empty($this->form_ids)) { |
|
| 183 | 183 | return; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $key = $this->get_cache_key_prefix() . sha1( serialize( $this->args ) ); |
|
| 186 | + $key = $this->get_cache_key_prefix().sha1(serialize($this->args)); |
|
| 187 | 187 | |
| 188 | 188 | // The transient name column can handle up to 64 characters. |
| 189 | 189 | // The `_transient_timeout_` prefix that is prepended to the string is 11 characters. |
| 190 | 190 | // 64 - 19 = 45 |
| 191 | 191 | // We make sure the key isn't too long or else WP doesn't store data. |
| 192 | - $this->key = substr( $key, 0, 45 ); |
|
| 192 | + $this->key = substr($key, 0, 45); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -210,24 +210,24 @@ discard block |
||
| 210 | 210 | * |
| 211 | 211 | * @return boolean False if value was not updated and true if value was updated. |
| 212 | 212 | */ |
| 213 | - public function blacklist_add( $form_ids ) { |
|
| 213 | + public function blacklist_add($form_ids) { |
|
| 214 | 214 | |
| 215 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
| 215 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
| 216 | 216 | |
| 217 | - $form_ids = is_array( $form_ids ) ? $form_ids : array( $form_ids ); |
|
| 217 | + $form_ids = is_array($form_ids) ? $form_ids : array($form_ids); |
|
| 218 | 218 | |
| 219 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array( |
|
| 219 | + do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_add] Adding form IDs to cache blacklist', array( |
|
| 220 | 220 | '$form_ids' => $form_ids, |
| 221 | 221 | '$blacklist' => $blacklist |
| 222 | - ) ); |
|
| 222 | + )); |
|
| 223 | 223 | |
| 224 | 224 | // Add the passed form IDs |
| 225 | - $blacklist = array_merge( $blacklist, $form_ids ); |
|
| 225 | + $blacklist = array_merge($blacklist, $form_ids); |
|
| 226 | 226 | |
| 227 | 227 | // Don't duplicate |
| 228 | - $blacklist = array_unique( $blacklist ); |
|
| 228 | + $blacklist = array_unique($blacklist); |
|
| 229 | 229 | |
| 230 | - return update_option( self::BLACKLIST_OPTION_NAME, $blacklist ); |
|
| 230 | + return update_option(self::BLACKLIST_OPTION_NAME, $blacklist); |
|
| 231 | 231 | |
| 232 | 232 | } |
| 233 | 233 | |
@@ -238,19 +238,19 @@ discard block |
||
| 238 | 238 | * |
| 239 | 239 | * @return boolean Whether the removal was successful |
| 240 | 240 | */ |
| 241 | - public function blacklist_remove( $form_ids ) { |
|
| 241 | + public function blacklist_remove($form_ids) { |
|
| 242 | 242 | |
| 243 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
| 243 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
| 244 | 244 | |
| 245 | - $updated_list = array_diff( $blacklist, (array) $form_ids ); |
|
| 245 | + $updated_list = array_diff($blacklist, (array)$form_ids); |
|
| 246 | 246 | |
| 247 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
|
| 247 | + do_action('gravityview_log_debug', 'GravityView_Cache[blacklist_remove] Removing form IDs from cache blacklist', array( |
|
| 248 | 248 | '$form_ids' => $form_ids, |
| 249 | 249 | '$blacklist' => $blacklist, |
| 250 | 250 | '$updated_list' => $updated_list |
| 251 | - ) ); |
|
| 251 | + )); |
|
| 252 | 252 | |
| 253 | - return update_option( self::BLACKLIST_OPTION_NAME, $updated_list ); |
|
| 253 | + return update_option(self::BLACKLIST_OPTION_NAME, $updated_list); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
@@ -261,25 +261,25 @@ discard block |
||
| 261 | 261 | * |
| 262 | 262 | * @return [type] [description] |
| 263 | 263 | */ |
| 264 | - function in_blacklist( $form_ids = NULL ) { |
|
| 264 | + function in_blacklist($form_ids = NULL) { |
|
| 265 | 265 | |
| 266 | - $blacklist = get_option( self::BLACKLIST_OPTION_NAME, array() ); |
|
| 266 | + $blacklist = get_option(self::BLACKLIST_OPTION_NAME, array()); |
|
| 267 | 267 | |
| 268 | 268 | // Use object var if exists |
| 269 | - $form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids; |
|
| 269 | + $form_ids = is_null($form_ids) ? $this->form_ids : $form_ids; |
|
| 270 | 270 | |
| 271 | - if ( empty( $form_ids ) ) { |
|
| 271 | + if (empty($form_ids)) { |
|
| 272 | 272 | |
| 273 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids ); |
|
| 273 | + do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Did not add form to blacklist; empty form ID', $form_ids); |
|
| 274 | 274 | |
| 275 | 275 | return false; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | - foreach ( (array) $form_ids as $form_id ) { |
|
| 278 | + foreach ((array)$form_ids as $form_id) { |
|
| 279 | 279 | |
| 280 | - if ( in_array( $form_id, $blacklist ) ) { |
|
| 280 | + if (in_array($form_id, $blacklist)) { |
|
| 281 | 281 | |
| 282 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #' . esc_attr( $form_id ) . ' is in the cache blacklist' ); |
|
| 282 | + do_action('gravityview_log_debug', 'GravityView_Cache[in_blacklist] Form #'.esc_attr($form_id).' is in the cache blacklist'); |
|
| 283 | 283 | |
| 284 | 284 | return true; |
| 285 | 285 | } |
@@ -296,35 +296,35 @@ discard block |
||
| 296 | 296 | * |
| 297 | 297 | * @return mixed False: Not using cache or cache was a WP_Error object; NULL: no results found; Mixed: cache value |
| 298 | 298 | */ |
| 299 | - public function get( $key = NULL ) { |
|
| 299 | + public function get($key = NULL) { |
|
| 300 | 300 | |
| 301 | - $key = is_null( $key ) ? $this->key : $key; |
|
| 301 | + $key = is_null($key) ? $this->key : $key; |
|
| 302 | 302 | |
| 303 | - if ( ! $this->use_cache() ) { |
|
| 303 | + if (!$this->use_cache()) { |
|
| 304 | 304 | |
| 305 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results' ); |
|
| 305 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Not using cached results because of GravityView_Cache->use_cache() results'); |
|
| 306 | 306 | |
| 307 | 307 | return false; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key ' . $key ); |
|
| 310 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request with transient key '.$key); |
|
| 311 | 311 | |
| 312 | - $result = get_transient( $key ); |
|
| 312 | + $result = get_transient($key); |
|
| 313 | 313 | |
| 314 | - if ( is_wp_error( $result ) ) { |
|
| 314 | + if (is_wp_error($result)) { |
|
| 315 | 315 | |
| 316 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result ); |
|
| 316 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Fetching request resulted in error:', $result); |
|
| 317 | 317 | |
| 318 | 318 | return false; |
| 319 | 319 | |
| 320 | - } elseif ( $result ) { |
|
| 320 | + } elseif ($result) { |
|
| 321 | 321 | |
| 322 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] Cached results found for transient key ' . $key ); |
|
| 322 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] Cached results found for transient key '.$key); |
|
| 323 | 323 | |
| 324 | 324 | return $result; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[get] No cached results found for transient key ' . $key ); |
|
| 327 | + do_action('gravityview_log_debug', 'GravityView_Cache[get] No cached results found for transient key '.$key); |
|
| 328 | 328 | |
| 329 | 329 | return NULL; |
| 330 | 330 | |
@@ -338,24 +338,24 @@ discard block |
||
| 338 | 338 | * @param [type] $content [description] |
| 339 | 339 | * @param [type] $filter_name Name used to modify the cache time. Will be set to `gravityview_cache_time_{$filter_name}`. |
| 340 | 340 | */ |
| 341 | - public function set( $content, $filter_name = '' ) { |
|
| 341 | + public function set($content, $filter_name = '') { |
|
| 342 | 342 | |
| 343 | 343 | // Don't cache empty results |
| 344 | - if ( ! empty( $content ) ) { |
|
| 344 | + if (!empty($content)) { |
|
| 345 | 345 | |
| 346 | 346 | /** |
| 347 | 347 | * @filter `gravityview_cache_time_{$filter_name}` Modify the cache time for a type of cache |
| 348 | 348 | * @param int $time_in_seconds Default: `DAY_IN_SECONDS` |
| 349 | 349 | */ |
| 350 | - $cache_time = (int) apply_filters( 'gravityview_cache_time_' . $filter_name, DAY_IN_SECONDS ); |
|
| 350 | + $cache_time = (int)apply_filters('gravityview_cache_time_'.$filter_name, DAY_IN_SECONDS); |
|
| 351 | 351 | |
| 352 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key ' . $this->key . ' for ' . $cache_time . ' seconds' ); |
|
| 352 | + do_action('gravityview_log_debug', 'GravityView_Cache[set] Setting cache with transient key '.$this->key.' for '.$cache_time.' seconds'); |
|
| 353 | 353 | |
| 354 | - return set_transient( $this->key, $content, $cache_time ); |
|
| 354 | + return set_transient($this->key, $content, $cache_time); |
|
| 355 | 355 | |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty' ); |
|
| 358 | + do_action('gravityview_log_debug', 'GravityView_Cache[set] Cache not set; content is empty'); |
|
| 359 | 359 | |
| 360 | 360 | return false; |
| 361 | 361 | |
@@ -371,39 +371,39 @@ discard block |
||
| 371 | 371 | * |
| 372 | 372 | * @return [type] [description] |
| 373 | 373 | */ |
| 374 | - public function delete( $form_ids = NULL ) { |
|
| 374 | + public function delete($form_ids = NULL) { |
|
| 375 | 375 | global $wpdb; |
| 376 | 376 | |
| 377 | 377 | // Use object var if exists |
| 378 | - $form_ids = is_null( $form_ids ) ? $this->form_ids : $form_ids; |
|
| 378 | + $form_ids = is_null($form_ids) ? $this->form_ids : $form_ids; |
|
| 379 | 379 | |
| 380 | - if ( empty( $form_ids ) ) { |
|
| 381 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs' ); |
|
| 380 | + if (empty($form_ids)) { |
|
| 381 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete] Did not delete cache; empty form IDs'); |
|
| 382 | 382 | |
| 383 | 383 | return; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - foreach ( (array) $form_ids as $form_id ) { |
|
| 386 | + foreach ((array)$form_ids as $form_id) { |
|
| 387 | 387 | |
| 388 | - $key = $this->get_cache_key_prefix( $form_id ); |
|
| 388 | + $key = $this->get_cache_key_prefix($form_id); |
|
| 389 | 389 | |
| 390 | 390 | // WordPress 4.0+ |
| 391 | - if ( is_callable( array( $wpdb, 'esc_like' ) ) ) { |
|
| 392 | - $key = $wpdb->esc_like( $key ); |
|
| 391 | + if (is_callable(array($wpdb, 'esc_like'))) { |
|
| 392 | + $key = $wpdb->esc_like($key); |
|
| 393 | 393 | } else { |
| 394 | - $key = like_escape( $key ); |
|
| 394 | + $key = like_escape($key); |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - $key = "%" . $key . "%"; |
|
| 397 | + $key = "%".$key."%"; |
|
| 398 | 398 | |
| 399 | - $sql = $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key ); |
|
| 399 | + $sql = $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE `option_name` LIKE %s", $key); |
|
| 400 | 400 | |
| 401 | - $result = $wpdb->query( $sql ); |
|
| 401 | + $result = $wpdb->query($sql); |
|
| 402 | 402 | |
| 403 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #' . $form_id, array( |
|
| 403 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete] Deleting cache for form #'.$form_id, array( |
|
| 404 | 404 | $sql, |
| 405 | - sprintf( 'Deleted results: %d', $result ) |
|
| 406 | - ) ); |
|
| 405 | + sprintf('Deleted results: %d', $result) |
|
| 406 | + )); |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | } |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | * @filter `gravityview_cleanup_transients` Override GravityView cleanup of transients by setting this to false |
| 422 | 422 | * @param boolean $cleanup Whether to run the GravityView auto-cleanup of transients. Default: `true` |
| 423 | 423 | */ |
| 424 | - $cleanup = apply_filters( 'gravityview_cleanup_transients', true ); |
|
| 424 | + $cleanup = apply_filters('gravityview_cleanup_transients', true); |
|
| 425 | 425 | |
| 426 | - if ( ! $cleanup ) { |
|
| 426 | + if (!$cleanup) { |
|
| 427 | 427 | return; |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | - if ( ! wp_next_scheduled( 'gravityview-expired-transients' ) ) { |
|
| 431 | - wp_schedule_event( time(), 'daily', 'gravityview-expired-transients' ); |
|
| 430 | + if (!wp_next_scheduled('gravityview-expired-transients')) { |
|
| 431 | + wp_schedule_event(time(), 'daily', 'gravityview-expired-transients'); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | $threshold = time() - 60; |
| 454 | 454 | |
| 455 | 455 | // get table name for options on specified blog |
| 456 | - $table = $wpdb->get_blog_prefix( $blog_id ) . 'options'; |
|
| 456 | + $table = $wpdb->get_blog_prefix($blog_id).'options'; |
|
| 457 | 457 | |
| 458 | 458 | // delete expired transients, using the paired timeout record to find them |
| 459 | 459 | $sql = " |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | and t1.option_value < '$threshold' |
| 465 | 465 | "; |
| 466 | 466 | |
| 467 | - $num_results = $wpdb->query( $sql ); |
|
| 467 | + $num_results = $wpdb->query($sql); |
|
| 468 | 468 | |
| 469 | 469 | // delete orphaned transient expirations |
| 470 | 470 | // also delete NextGEN Gallery 2.x display cache timeout aliases |
@@ -479,9 +479,9 @@ discard block |
||
| 479 | 479 | and option_value < '$threshold' |
| 480 | 480 | "; |
| 481 | 481 | |
| 482 | - $num_results += $wpdb->query( $sql ); |
|
| 482 | + $num_results += $wpdb->query($sql); |
|
| 483 | 483 | |
| 484 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted ' . $num_results . ' expired transient records from the database' ); |
|
| 484 | + do_action('gravityview_log_debug', 'GravityView_Cache[delete_expired_transients] Deleted '.$num_results.' expired transient records from the database'); |
|
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | /** |
@@ -495,11 +495,11 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | $use_cache = true; |
| 497 | 497 | |
| 498 | - if ( GVCommon::has_cap( 'edit_gravityviews' ) ) { |
|
| 498 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
| 499 | 499 | |
| 500 | - if ( isset( $_GET['cache'] ) || isset( $_GET['nocache'] ) ) { |
|
| 500 | + if (isset($_GET['cache']) || isset($_GET['nocache'])) { |
|
| 501 | 501 | |
| 502 | - do_action( 'gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL' ); |
|
| 502 | + do_action('gravityview_log_debug', 'GravityView_Cache[use_cache] Not using cache: ?cache or ?nocache is in the URL'); |
|
| 503 | 503 | |
| 504 | 504 | $use_cache = false; |
| 505 | 505 | } |
@@ -507,13 +507,13 @@ discard block |
||
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | // Has the form been flagged as having changed items in it? |
| 510 | - if ( $this->in_blacklist() ) { |
|
| 510 | + if ($this->in_blacklist()) { |
|
| 511 | 511 | |
| 512 | 512 | // Delete caches for all items with form IDs XYZ |
| 513 | - $this->delete( $this->form_ids ); |
|
| 513 | + $this->delete($this->form_ids); |
|
| 514 | 514 | |
| 515 | 515 | // Remove the form from |
| 516 | - $this->blacklist_remove( $this->form_ids ); |
|
| 516 | + $this->blacklist_remove($this->form_ids); |
|
| 517 | 517 | |
| 518 | 518 | } |
| 519 | 519 | |
@@ -524,9 +524,9 @@ discard block |
||
| 524 | 524 | * @param[out,in] boolean $use_cache Previous setting |
| 525 | 525 | * @param[out] GravityView_Cache $this The GravityView_Cache object |
| 526 | 526 | */ |
| 527 | - $use_cache = apply_filters( 'gravityview_use_cache', $use_cache, $this ); |
|
| 527 | + $use_cache = apply_filters('gravityview_use_cache', $use_cache, $this); |
|
| 528 | 528 | |
| 529 | - return (boolean) $use_cache; |
|
| 529 | + return (boolean)$use_cache; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | } |
@@ -213,13 +213,13 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
| 215 | 215 | foreach ( $field['inputs'] as $input ) { |
| 216 | - /** |
|
| 217 | - * @hack |
|
| 218 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 219 | - */ |
|
| 220 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
| 221 | - continue; |
|
| 222 | - } |
|
| 216 | + /** |
|
| 217 | + * @hack |
|
| 218 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
| 219 | + */ |
|
| 220 | + if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
| 221 | + continue; |
|
| 222 | + } |
|
| 223 | 223 | $fields[ (string)$input['id'] ] = array( |
| 224 | 224 | 'label' => rgar( $input, 'label' ), |
| 225 | 225 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
| 467 | 467 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
| 468 | 468 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
| 469 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 469 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
| 470 | 470 | $criteria['context_view_id'] = null; |
| 471 | 471 | } |
| 472 | 472 | |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | ), |
| 1083 | 1083 | ); |
| 1084 | 1084 | |
| 1085 | - $fields = $date_created + $fields; |
|
| 1085 | + $fields = $date_created + $fields; |
|
| 1086 | 1086 | |
| 1087 | 1087 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
| 1088 | 1088 | |
@@ -1094,13 +1094,13 @@ discard block |
||
| 1094 | 1094 | } |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - /** |
|
| 1098 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1099 | - * @since 1.12 |
|
| 1100 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1101 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1102 | - */ |
|
| 1103 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1097 | + /** |
|
| 1098 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
| 1099 | + * @since 1.12 |
|
| 1100 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
| 1101 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
| 1102 | + */ |
|
| 1103 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1104 | 1104 | |
| 1105 | 1105 | return $fields; |
| 1106 | 1106 | } |
@@ -1365,17 +1365,17 @@ discard block |
||
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | 1367 | |
| 1368 | - /** |
|
| 1369 | - * Display updated/error notice |
|
| 1370 | - * |
|
| 1371 | - * @param string $notice text/HTML of notice |
|
| 1372 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1373 | - * |
|
| 1374 | - * @return string |
|
| 1375 | - */ |
|
| 1376 | - public static function generate_notice( $notice, $class = '' ) { |
|
| 1377 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1378 | - } |
|
| 1368 | + /** |
|
| 1369 | + * Display updated/error notice |
|
| 1370 | + * |
|
| 1371 | + * @param string $notice text/HTML of notice |
|
| 1372 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
| 1373 | + * |
|
| 1374 | + * @return string |
|
| 1375 | + */ |
|
| 1376 | + public static function generate_notice( $notice, $class = '' ) { |
|
| 1377 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1378 | + } |
|
| 1379 | 1379 | |
| 1380 | 1380 | |
| 1381 | 1381 | |
@@ -167,7 +167,6 @@ discard block |
||
| 167 | 167 | * Returns the list of available forms |
| 168 | 168 | * |
| 169 | 169 | * @access public |
| 170 | - * @param mixed $form_id |
|
| 171 | 170 | * @return array Empty array if GFAPI isn't available or no forms. Otherwise, associative array with id, title keys |
| 172 | 171 | */ |
| 173 | 172 | public static function get_forms() { |
@@ -188,7 +187,7 @@ discard block |
||
| 188 | 187 | * Return array of fields' id and label, for a given Form ID |
| 189 | 188 | * |
| 190 | 189 | * @access public |
| 191 | - * @param string|array $form_id (default: '') or $form object |
|
| 190 | + * @param string|array $form (default: '') or $form object |
|
| 192 | 191 | * @return array |
| 193 | 192 | */ |
| 194 | 193 | public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | /** If this file is called directly, abort. */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -25,18 +25,18 @@ discard block |
||
| 25 | 25 | * @param mixed $form_id |
| 26 | 26 | * @return mixed False: no form ID specified or Gravity Forms isn't active. Array: Form returned from Gravity Forms |
| 27 | 27 | */ |
| 28 | - public static function get_form( $form_id ) { |
|
| 29 | - if ( empty( $form_id ) ) { |
|
| 28 | + public static function get_form($form_id) { |
|
| 29 | + if (empty($form_id)) { |
|
| 30 | 30 | return false; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Only get_form_meta is cached. ::facepalm:: |
| 34 | - if ( class_exists( 'RGFormsModel' ) ) { |
|
| 35 | - return GFFormsModel::get_form_meta( $form_id ); |
|
| 34 | + if (class_exists('RGFormsModel')) { |
|
| 35 | + return GFFormsModel::get_form_meta($form_id); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if ( class_exists( 'GFAPI' ) ) { |
|
| 39 | - return GFAPI::get_form( $form_id ); |
|
| 38 | + if (class_exists('GFAPI')) { |
|
| 39 | + return GFAPI::get_form($form_id); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | return false; |
@@ -55,8 +55,8 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return bool True: user has at least one passed capability; False: user does not have any defined capabilities |
| 57 | 57 | */ |
| 58 | - public static function has_cap( $caps = '', $object_id = null, $user_id = null ) { |
|
| 59 | - return GravityView_Roles_Capabilities::has_cap( $caps, $object_id, $user_id ); |
|
| 58 | + public static function has_cap($caps = '', $object_id = null, $user_id = null) { |
|
| 59 | + return GravityView_Roles_Capabilities::has_cap($caps, $object_id, $user_id); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | * @param array|GF_Fields $field Gravity Forms field or array |
| 68 | 68 | * @return array Array version of $field |
| 69 | 69 | */ |
| 70 | - public static function get_field_array( $field ) { |
|
| 70 | + public static function get_field_array($field) { |
|
| 71 | 71 | |
| 72 | - if ( class_exists( 'GF_Fields' ) ) { |
|
| 72 | + if (class_exists('GF_Fields')) { |
|
| 73 | 73 | |
| 74 | - $field_object = GF_Fields::create( $field ); |
|
| 74 | + $field_object = GF_Fields::create($field); |
|
| 75 | 75 | |
| 76 | 76 | // Convert the field object in 1.9 to an array for backward compatibility |
| 77 | - $field_array = get_object_vars( $field_object ); |
|
| 77 | + $field_array = get_object_vars($field_object); |
|
| 78 | 78 | |
| 79 | 79 | } else { |
| 80 | 80 | $field_array = $field; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * |
| 94 | 94 | * @return array Array of Views as `WP_Post`. Empty array if none found. |
| 95 | 95 | */ |
| 96 | - public static function get_all_views( $args = array() ) { |
|
| 96 | + public static function get_all_views($args = array()) { |
|
| 97 | 97 | |
| 98 | 98 | $default_params = array( |
| 99 | 99 | 'post_type' => 'gravityview', |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | 'post_status' => 'publish', |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | - $params = wp_parse_args( $args, $default_params ); |
|
| 104 | + $params = wp_parse_args($args, $default_params); |
|
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @filter `gravityview/get_all_views/params` Modify the parameters sent to get all views. |
| 108 | 108 | * @param[in,out] array $params Array of parameters to pass to `get_posts()` |
| 109 | 109 | */ |
| 110 | - $views_params = apply_filters( 'gravityview/get_all_views/params', $params ); |
|
| 110 | + $views_params = apply_filters('gravityview/get_all_views/params', $params); |
|
| 111 | 111 | |
| 112 | - $views = get_posts( $views_params ); |
|
| 112 | + $views = get_posts($views_params); |
|
| 113 | 113 | |
| 114 | 114 | return $views; |
| 115 | 115 | } |
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | * @param int|string $entry_slug Entry slug |
| 121 | 121 | * @return array Gravity Forms form array |
| 122 | 122 | */ |
| 123 | - public static function get_form_from_entry_id( $entry_slug ) { |
|
| 123 | + public static function get_form_from_entry_id($entry_slug) { |
|
| 124 | 124 | |
| 125 | - $entry = self::get_entry( $entry_slug, true ); |
|
| 125 | + $entry = self::get_entry($entry_slug, true); |
|
| 126 | 126 | |
| 127 | - $form = self::get_form( $entry['form_id'] ); |
|
| 127 | + $form = self::get_form($entry['form_id']); |
|
| 128 | 128 | |
| 129 | 129 | return $form; |
| 130 | 130 | } |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return bool|GF_Field[] |
| 140 | 140 | */ |
| 141 | - public static function has_product_field( $form = array() ) { |
|
| 141 | + public static function has_product_field($form = array()) { |
|
| 142 | 142 | |
| 143 | - $product_fields = apply_filters( 'gform_product_field_types', array( 'option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price' ) ); |
|
| 143 | + $product_fields = apply_filters('gform_product_field_types', array('option', 'quantity', 'product', 'total', 'shipping', 'calculation', 'price')); |
|
| 144 | 144 | |
| 145 | - $fields = GFAPI::get_fields_by_type( $form, $product_fields ); |
|
| 145 | + $fields = GFAPI::get_fields_by_type($form, $product_fields); |
|
| 146 | 146 | |
| 147 | - return empty( $fields ) ? false : $fields; |
|
| 147 | + return empty($fields) ? false : $fields; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string $slug The entry slug, as returned by GravityView_API::get_entry_slug() |
| 155 | 155 | * @return int|null The entry ID, if exists; `NULL` if not |
| 156 | 156 | */ |
| 157 | - public static function get_entry_id_from_slug( $slug ) { |
|
| 157 | + public static function get_entry_id_from_slug($slug) { |
|
| 158 | 158 | global $wpdb; |
| 159 | 159 | |
| 160 | 160 | $search_criteria = array( |
@@ -173,9 +173,9 @@ discard block |
||
| 173 | 173 | 'page_size' => 1, |
| 174 | 174 | ); |
| 175 | 175 | |
| 176 | - $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
|
| 176 | + $results = GFAPI::get_entries(0, $search_criteria, null, $paging); |
|
| 177 | 177 | |
| 178 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
| 178 | + $result = (!empty($results) && !empty($results[0]['id'])) ? $results[0]['id'] : null; |
|
| 179 | 179 | |
| 180 | 180 | return $result; |
| 181 | 181 | } |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public static function get_forms() { |
| 192 | 192 | $forms = array(); |
| 193 | - if ( class_exists( 'GFAPI' ) ) { |
|
| 193 | + if (class_exists('GFAPI')) { |
|
| 194 | 194 | $gf_forms = GFAPI::get_forms(); |
| 195 | - foreach ( $gf_forms as $form ) { |
|
| 195 | + foreach ($gf_forms as $form) { |
|
| 196 | 196 | $forms[] = array( |
| 197 | 197 | 'id' => $form['id'], |
| 198 | 198 | 'title' => $form['title'], |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | * @param string|array $form_id (default: '') or $form object |
| 210 | 210 | * @return array |
| 211 | 211 | */ |
| 212 | - public static function get_form_fields( $form = '', $add_default_properties = false, $include_parent_field = true ) { |
|
| 212 | + public static function get_form_fields($form = '', $add_default_properties = false, $include_parent_field = true) { |
|
| 213 | 213 | |
| 214 | - if ( ! is_array( $form ) ) { |
|
| 215 | - $form = self::get_form( $form ); |
|
| 214 | + if (!is_array($form)) { |
|
| 215 | + $form = self::get_form($form); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | $fields = array(); |
@@ -222,56 +222,56 @@ discard block |
||
| 222 | 222 | $has_poll_fields = false; |
| 223 | 223 | |
| 224 | 224 | // If GF_Field exists, we're using GF 1.9+, where add_default_properties has been deprecated. |
| 225 | - if ( false === class_exists( 'GF_Field' ) && $add_default_properties ) { |
|
| 226 | - $form = RGFormsModel::add_default_properties( $form ); |
|
| 225 | + if (false === class_exists('GF_Field') && $add_default_properties) { |
|
| 226 | + $form = RGFormsModel::add_default_properties($form); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - if ( $form ) { |
|
| 230 | - foreach ( $form['fields'] as $field ) { |
|
| 231 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
| 232 | - $fields[ $field['id'] ] = array( |
|
| 233 | - 'label' => rgar( $field, 'label' ), |
|
| 229 | + if ($form) { |
|
| 230 | + foreach ($form['fields'] as $field) { |
|
| 231 | + if ($include_parent_field || empty($field['inputs'])) { |
|
| 232 | + $fields[$field['id']] = array( |
|
| 233 | + 'label' => rgar($field, 'label'), |
|
| 234 | 234 | 'parent' => null, |
| 235 | - 'type' => rgar( $field, 'type' ), |
|
| 236 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
| 237 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
| 235 | + 'type' => rgar($field, 'type'), |
|
| 236 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
| 237 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
| 238 | 238 | ); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
| 242 | - foreach ( $field['inputs'] as $input ) { |
|
| 241 | + if ($add_default_properties && !empty($field['inputs'])) { |
|
| 242 | + foreach ($field['inputs'] as $input) { |
|
| 243 | 243 | /** |
| 244 | 244 | * @hack |
| 245 | 245 | * In case of email/email confirmation, the input for email has the same id as the parent field |
| 246 | 246 | */ |
| 247 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
| 247 | + if ('email' == rgar($field, 'type') && false === strpos($input['id'], '.')) { |
|
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | - $fields[ (string)$input['id'] ] = array( |
|
| 251 | - 'label' => rgar( $input, 'label' ), |
|
| 252 | - 'customLabel' => rgar( $input, 'customLabel' ), |
|
| 250 | + $fields[(string)$input['id']] = array( |
|
| 251 | + 'label' => rgar($input, 'label'), |
|
| 252 | + 'customLabel' => rgar($input, 'customLabel'), |
|
| 253 | 253 | 'parent' => $field, |
| 254 | - 'type' => rgar( $field, 'type' ), |
|
| 255 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
| 256 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
| 254 | + 'type' => rgar($field, 'type'), |
|
| 255 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
| 256 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
| 257 | 257 | ); |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** @since 1.14 */ |
| 262 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
| 262 | + if ('list' === $field['type'] && !empty($field['enableColumns'])) { |
|
| 263 | 263 | |
| 264 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
| 264 | + foreach ((array)$field['choices'] as $key => $input) { |
|
| 265 | 265 | |
| 266 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
| 266 | + $input_id = sprintf('%d.%d', $field['id'], $key); // {field_id}.{column_key} |
|
| 267 | 267 | |
| 268 | - $fields[ $input_id ] = array( |
|
| 269 | - 'label' => rgar( $input, 'text' ), |
|
| 268 | + $fields[$input_id] = array( |
|
| 269 | + 'label' => rgar($input, 'text'), |
|
| 270 | 270 | 'customLabel' => '', |
| 271 | 271 | 'parent' => $field, |
| 272 | - 'type' => rgar( $field, 'type' ), |
|
| 273 | - 'adminLabel' => rgar( $field, 'adminLabel' ), |
|
| 274 | - 'adminOnly' => rgar( $field, 'adminOnly' ), |
|
| 272 | + 'type' => rgar($field, 'type'), |
|
| 273 | + 'adminLabel' => rgar($field, 'adminLabel'), |
|
| 274 | + 'adminOnly' => rgar($field, 'adminOnly'), |
|
| 275 | 275 | ); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -279,27 +279,27 @@ discard block |
||
| 279 | 279 | /** |
| 280 | 280 | * @since 1.8 |
| 281 | 281 | */ |
| 282 | - if( 'quiz' === $field['type'] ) { |
|
| 282 | + if ('quiz' === $field['type']) { |
|
| 283 | 283 | $has_quiz_fields = true; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | /** |
| 287 | 287 | * @since 1.8 |
| 288 | 288 | */ |
| 289 | - if( 'poll' === $field['type'] ) { |
|
| 289 | + if ('poll' === $field['type']) { |
|
| 290 | 290 | $has_poll_fields = true; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
| 293 | + if (GFCommon::is_product_field($field['type'])) { |
|
| 294 | 294 | $has_product_fields = true; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
| 298 | 298 | * @hack Version 1.9 |
| 299 | 299 | */ |
| 300 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
| 300 | + $field_for_is_post_field = class_exists('GF_Fields') ? (object)$field : (array)$field; |
|
| 301 | 301 | |
| 302 | - if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
|
| 302 | + if (GFCommon::is_post_field($field_for_is_post_field)) { |
|
| 303 | 303 | $has_post_fields = true; |
| 304 | 304 | } |
| 305 | 305 | } |
@@ -308,47 +308,47 @@ discard block |
||
| 308 | 308 | /** |
| 309 | 309 | * @since 1.7 |
| 310 | 310 | */ |
| 311 | - if ( $has_post_fields ) { |
|
| 311 | + if ($has_post_fields) { |
|
| 312 | 312 | $fields['post_id'] = array( |
| 313 | - 'label' => __( 'Post ID', 'gravityview' ), |
|
| 313 | + 'label' => __('Post ID', 'gravityview'), |
|
| 314 | 314 | 'type' => 'post_id', |
| 315 | 315 | ); |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( $has_product_fields ) { |
|
| 318 | + if ($has_product_fields) { |
|
| 319 | 319 | |
| 320 | 320 | $fields['payment_status'] = array( |
| 321 | - 'label' => __( 'Payment Status', 'gravityview' ), |
|
| 321 | + 'label' => __('Payment Status', 'gravityview'), |
|
| 322 | 322 | 'type' => 'payment_status', |
| 323 | 323 | ); |
| 324 | 324 | |
| 325 | 325 | $fields['payment_date'] = array( |
| 326 | - 'label' => __( 'Payment Date', 'gravityview' ), |
|
| 326 | + 'label' => __('Payment Date', 'gravityview'), |
|
| 327 | 327 | 'type' => 'payment_date', |
| 328 | 328 | ); |
| 329 | 329 | |
| 330 | 330 | $fields['payment_amount'] = array( |
| 331 | - 'label' => __( 'Payment Amount', 'gravityview' ), |
|
| 331 | + 'label' => __('Payment Amount', 'gravityview'), |
|
| 332 | 332 | 'type' => 'payment_amount', |
| 333 | 333 | ); |
| 334 | 334 | |
| 335 | 335 | $fields['payment_method'] = array( |
| 336 | - 'label' => __( 'Payment Method', 'gravityview' ), |
|
| 336 | + 'label' => __('Payment Method', 'gravityview'), |
|
| 337 | 337 | 'type' => 'payment_method', |
| 338 | 338 | ); |
| 339 | 339 | |
| 340 | 340 | $fields['is_fulfilled'] = array( |
| 341 | - 'label' => __( 'Is Fulfilled', 'gravityview' ), |
|
| 341 | + 'label' => __('Is Fulfilled', 'gravityview'), |
|
| 342 | 342 | 'type' => 'is_fulfilled', |
| 343 | 343 | ); |
| 344 | 344 | |
| 345 | 345 | $fields['transaction_id'] = array( |
| 346 | - 'label' => __( 'Transaction ID', 'gravityview' ), |
|
| 346 | + 'label' => __('Transaction ID', 'gravityview'), |
|
| 347 | 347 | 'type' => 'transaction_id', |
| 348 | 348 | ); |
| 349 | 349 | |
| 350 | 350 | $fields['transaction_type'] = array( |
| 351 | - 'label' => __( 'Transaction Type', 'gravityview' ), |
|
| 351 | + 'label' => __('Transaction Type', 'gravityview'), |
|
| 352 | 352 | 'type' => 'transaction_type', |
| 353 | 353 | ); |
| 354 | 354 | |
@@ -357,27 +357,27 @@ discard block |
||
| 357 | 357 | /** |
| 358 | 358 | * @since 1.8 |
| 359 | 359 | */ |
| 360 | - if( $has_quiz_fields ) { |
|
| 360 | + if ($has_quiz_fields) { |
|
| 361 | 361 | |
| 362 | - $fields['gquiz_score'] = array( |
|
| 363 | - 'label' => __( 'Quiz Score Total', 'gravityview' ), |
|
| 362 | + $fields['gquiz_score'] = array( |
|
| 363 | + 'label' => __('Quiz Score Total', 'gravityview'), |
|
| 364 | 364 | 'type' => 'quiz_score', |
| 365 | - 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
|
| 365 | + 'desc' => __('Displays the number of correct Quiz answers the user submitted.', 'gravityview'), |
|
| 366 | 366 | ); |
| 367 | 367 | $fields['gquiz_percent'] = array( |
| 368 | - 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
|
| 368 | + 'label' => __('Quiz Percentage Grade', 'gravityview'), |
|
| 369 | 369 | 'type' => 'quiz_percent', |
| 370 | - 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
|
| 370 | + 'desc' => __('Displays the percentage of correct Quiz answers the user submitted.', 'gravityview'), |
|
| 371 | 371 | ); |
| 372 | - $fields['gquiz_grade'] = array( |
|
| 373 | - 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
|
| 372 | + $fields['gquiz_grade'] = array( |
|
| 373 | + 'label' => __('Quiz Letter Grade', 'gravityview'), |
|
| 374 | 374 | 'type' => 'quiz_grade', |
| 375 | - 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
|
| 375 | + 'desc' => __('Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview'), |
|
| 376 | 376 | ); |
| 377 | 377 | $fields['gquiz_is_pass'] = array( |
| 378 | - 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
|
| 378 | + 'label' => __('Quiz Pass/Fail', 'gravityview'), |
|
| 379 | 379 | 'type' => 'quiz_is_pass', |
| 380 | - 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
|
| 380 | + 'desc' => __('Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview'), |
|
| 381 | 381 | ); |
| 382 | 382 | } |
| 383 | 383 | |
@@ -390,15 +390,15 @@ discard block |
||
| 390 | 390 | * @param string $form_id (default: '') |
| 391 | 391 | * @return array |
| 392 | 392 | */ |
| 393 | - public static function get_entry_meta( $form_id, $only_default_column = true ) { |
|
| 393 | + public static function get_entry_meta($form_id, $only_default_column = true) { |
|
| 394 | 394 | |
| 395 | - $extra_fields = GFFormsModel::get_entry_meta( $form_id ); |
|
| 395 | + $extra_fields = GFFormsModel::get_entry_meta($form_id); |
|
| 396 | 396 | |
| 397 | 397 | $fields = array(); |
| 398 | 398 | |
| 399 | - foreach ( $extra_fields as $key => $field ){ |
|
| 400 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
| 401 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
| 399 | + foreach ($extra_fields as $key => $field) { |
|
| 400 | + if (!empty($only_default_column) && !empty($field['is_default_column'])) { |
|
| 401 | + $fields[$key] = array('label' => $field['label'], 'type' => 'entry_meta'); |
|
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
@@ -414,13 +414,13 @@ discard block |
||
| 414 | 414 | * @since 1.1.6 |
| 415 | 415 | * @return array|void Array of entry IDs. Void if Gravity Forms isn't active. |
| 416 | 416 | */ |
| 417 | - public static function get_entry_ids( $form_id, $search_criteria = array() ) { |
|
| 417 | + public static function get_entry_ids($form_id, $search_criteria = array()) { |
|
| 418 | 418 | |
| 419 | - if ( ! class_exists( 'GFFormsModel' ) ) { |
|
| 419 | + if (!class_exists('GFFormsModel')) { |
|
| 420 | 420 | return; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - return GFFormsModel::search_lead_ids( $form_id, $search_criteria ); |
|
| 423 | + return GFFormsModel::search_lead_ids($form_id, $search_criteria); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | /** |
@@ -432,33 +432,33 @@ discard block |
||
| 432 | 432 | * @param array $form_ids array Gravity Forms form IDs |
| 433 | 433 | * @return array |
| 434 | 434 | */ |
| 435 | - public static function calculate_get_entries_criteria( $passed_criteria = array(), $form_ids = array() ) { |
|
| 435 | + public static function calculate_get_entries_criteria($passed_criteria = array(), $form_ids = array()) { |
|
| 436 | 436 | |
| 437 | 437 | $search_criteria_defaults = array( |
| 438 | 438 | 'search_criteria' => null, |
| 439 | 439 | 'sorting' => null, |
| 440 | 440 | 'paging' => null, |
| 441 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
| 441 | + 'cache' => (isset($passed_criteria['cache']) ? $passed_criteria['cache'] : true), |
|
| 442 | 442 | ); |
| 443 | 443 | |
| 444 | - $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
|
| 444 | + $criteria = wp_parse_args($passed_criteria, $search_criteria_defaults); |
|
| 445 | 445 | |
| 446 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
| 447 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
| 446 | + if (!empty($criteria['search_criteria']['field_filters'])) { |
|
| 447 | + foreach ($criteria['search_criteria']['field_filters'] as &$filter) { |
|
| 448 | 448 | |
| 449 | - if ( ! is_array( $filter ) ) { |
|
| 449 | + if (!is_array($filter)) { |
|
| 450 | 450 | continue; |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | // By default, we want searches to be wildcard for each field. |
| 454 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
| 454 | + $filter['operator'] = empty($filter['operator']) ? 'contains' : $filter['operator']; |
|
| 455 | 455 | |
| 456 | 456 | /** |
| 457 | 457 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
| 458 | 458 | * @param string $operator Existing search operator |
| 459 | 459 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
| 460 | 460 | */ |
| 461 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
| 461 | + $filter['operator'] = apply_filters('gravityview_search_operator', $filter['operator'], $filter); |
|
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | |
@@ -466,32 +466,32 @@ discard block |
||
| 466 | 466 | * Prepare date formats to be in Gravity Forms DB format; |
| 467 | 467 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
| 468 | 468 | */ |
| 469 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
| 469 | + foreach (array('start_date', 'end_date') as $key) { |
|
| 470 | 470 | |
| 471 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
| 471 | + if (!empty($criteria['search_criteria'][$key])) { |
|
| 472 | 472 | |
| 473 | 473 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
| 474 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
| 474 | + $date = date_create($criteria['search_criteria'][$key]); |
|
| 475 | 475 | |
| 476 | - if ( $date ) { |
|
| 476 | + if ($date) { |
|
| 477 | 477 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
| 478 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
| 478 | + $criteria['search_criteria'][$key] = $date->format('Y-m-d H:i:s'); |
|
| 479 | 479 | } else { |
| 480 | 480 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
| 481 | - unset( $criteria['search_criteria'][ $key ] ); |
|
| 481 | + unset($criteria['search_criteria'][$key]); |
|
| 482 | 482 | |
| 483 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
| 483 | + do_action('gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][$key]); |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
| 490 | - if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
|
| 490 | + if (class_exists('GravityView_View_Data') && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry()) { |
|
| 491 | 491 | $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
| 492 | - } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
|
| 493 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
| 494 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
| 492 | + } elseif ('delete' === RGForms::get('action')) { |
|
| 493 | + $criteria['context_view_id'] = isset($_GET['view_id']) ? $_GET['view_id'] : null; |
|
| 494 | + } elseif (!isset($criteria['context_view_id'])) { |
|
| 495 | 495 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
| 496 | 496 | $criteria['context_view_id'] = null; |
| 497 | 497 | } |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | * @param array $form_ids Forms to search |
| 503 | 503 | * @param int $view_id ID of the view being used to search |
| 504 | 504 | */ |
| 505 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
| 505 | + $criteria = apply_filters('gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id']); |
|
| 506 | 506 | |
| 507 | 507 | return (array)$criteria; |
| 508 | 508 | |
@@ -520,35 +520,35 @@ discard block |
||
| 520 | 520 | * @param mixed &$total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null) |
| 521 | 521 | * @return mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays |
| 522 | 522 | */ |
| 523 | - public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) { |
|
| 523 | + public static function get_entries($form_ids = null, $passed_criteria = null, &$total = null) { |
|
| 524 | 524 | |
| 525 | 525 | // Filter the criteria before query (includes Adv Filter) |
| 526 | - $criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids ); |
|
| 526 | + $criteria = self::calculate_get_entries_criteria($passed_criteria, $form_ids); |
|
| 527 | 527 | |
| 528 | - do_action( 'gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria ); |
|
| 528 | + do_action('gravityview_log_debug', '[gravityview_get_entries] Final Parameters', $criteria); |
|
| 529 | 529 | |
| 530 | 530 | // Return value |
| 531 | 531 | $return = null; |
| 532 | 532 | |
| 533 | 533 | /** Reduce # of database calls */ |
| 534 | - add_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
| 534 | + add_filter('gform_is_encrypted_field', '__return_false'); |
|
| 535 | 535 | |
| 536 | - if ( ! empty( $criteria['cache'] ) ) { |
|
| 536 | + if (!empty($criteria['cache'])) { |
|
| 537 | 537 | |
| 538 | - $Cache = new GravityView_Cache( $form_ids, $criteria ); |
|
| 538 | + $Cache = new GravityView_Cache($form_ids, $criteria); |
|
| 539 | 539 | |
| 540 | - if ( $entries = $Cache->get() ) { |
|
| 540 | + if ($entries = $Cache->get()) { |
|
| 541 | 541 | |
| 542 | 542 | // Still update the total count when using cached results |
| 543 | - if ( ! is_null( $total ) ) { |
|
| 544 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
| 543 | + if (!is_null($total)) { |
|
| 544 | + $total = GFAPI::count_entries($form_ids, $criteria['search_criteria']); |
|
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | $return = $entries; |
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - if ( is_null( $return ) && class_exists( 'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) { |
|
| 551 | + if (is_null($return) && class_exists('GFAPI') && (is_numeric($form_ids) || is_array($form_ids))) { |
|
| 552 | 552 | |
| 553 | 553 | /** |
| 554 | 554 | * @filter `gravityview_pre_get_entries` Define entries to be used before GFAPI::get_entries() is called |
@@ -558,24 +558,24 @@ discard block |
||
| 558 | 558 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
| 559 | 559 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
| 560 | 560 | */ |
| 561 | - $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
|
| 561 | + $entries = apply_filters('gravityview_before_get_entries', null, $criteria, $passed_criteria, $total); |
|
| 562 | 562 | |
| 563 | 563 | // No entries returned from gravityview_before_get_entries |
| 564 | - if( is_null( $entries ) ) { |
|
| 564 | + if (is_null($entries)) { |
|
| 565 | 565 | |
| 566 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
| 566 | + $entries = GFAPI::get_entries($form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total); |
|
| 567 | 567 | |
| 568 | - if ( is_wp_error( $entries ) ) { |
|
| 569 | - do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
|
| 568 | + if (is_wp_error($entries)) { |
|
| 569 | + do_action('gravityview_log_error', $entries->get_error_message(), $entries); |
|
| 570 | 570 | |
| 571 | 571 | return false; |
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
| 575 | + if (!empty($criteria['cache']) && isset($Cache)) { |
|
| 576 | 576 | |
| 577 | 577 | // Cache results |
| 578 | - $Cache->set( $entries, 'entries' ); |
|
| 578 | + $Cache->set($entries, 'entries'); |
|
| 579 | 579 | |
| 580 | 580 | } |
| 581 | 581 | |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** Remove filter added above */ |
| 586 | - remove_filter( 'gform_is_encrypted_field', '__return_false' ); |
|
| 586 | + remove_filter('gform_is_encrypted_field', '__return_false'); |
|
| 587 | 587 | |
| 588 | 588 | /** |
| 589 | 589 | * @filter `gravityview_entries` Modify the array of entries returned to GravityView after it has been fetched from the cache or from `GFAPI::get_entries()`. |
@@ -592,7 +592,7 @@ discard block |
||
| 592 | 592 | * @param array $passed_criteria The original search criteria passed to `GVCommon::get_entries()` |
| 593 | 593 | * @param int|null $total Optional. An output parameter containing the total number of entries. Pass a non-null value to generate |
| 594 | 594 | */ |
| 595 | - $return = apply_filters( 'gravityview_entries', $return, $criteria, $passed_criteria, $total ); |
|
| 595 | + $return = apply_filters('gravityview_entries', $return, $criteria, $passed_criteria, $total); |
|
| 596 | 596 | |
| 597 | 597 | return $return; |
| 598 | 598 | } |
@@ -609,15 +609,15 @@ discard block |
||
| 609 | 609 | * @param boolean $check_entry_display Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} |
| 610 | 610 | * @return array|boolean |
| 611 | 611 | */ |
| 612 | - public static function get_entry( $entry_slug, $force_allow_ids = false, $check_entry_display = true ) { |
|
| 612 | + public static function get_entry($entry_slug, $force_allow_ids = false, $check_entry_display = true) { |
|
| 613 | 613 | |
| 614 | - if ( class_exists( 'GFAPI' ) && ! empty( $entry_slug ) ) { |
|
| 614 | + if (class_exists('GFAPI') && !empty($entry_slug)) { |
|
| 615 | 615 | |
| 616 | 616 | /** |
| 617 | 617 | * @filter `gravityview_custom_entry_slug` Whether to enable and use custom entry slugs. |
| 618 | 618 | * @param boolean True: Allow for slugs based on entry values. False: always use entry IDs (default) |
| 619 | 619 | */ |
| 620 | - $custom_slug = apply_filters( 'gravityview_custom_entry_slug', false ); |
|
| 620 | + $custom_slug = apply_filters('gravityview_custom_entry_slug', false); |
|
| 621 | 621 | |
| 622 | 622 | /** |
| 623 | 623 | * @filter `gravityview_custom_entry_slug_allow_id` When using a custom slug, allow access to the entry using the original slug (the Entry ID). |
@@ -625,38 +625,38 @@ discard block |
||
| 625 | 625 | * - If enabled, you could access using the custom slug OR the entry id (example: `/entry/custom-slug/` OR `/entry/123/`) |
| 626 | 626 | * @param boolean $custom_slug_id_access True: allow accessing the slug by ID; False: only use the slug passed to the method. |
| 627 | 627 | */ |
| 628 | - $custom_slug_id_access = $force_allow_ids || apply_filters( 'gravityview_custom_entry_slug_allow_id', false ); |
|
| 628 | + $custom_slug_id_access = $force_allow_ids || apply_filters('gravityview_custom_entry_slug_allow_id', false); |
|
| 629 | 629 | |
| 630 | 630 | /** |
| 631 | 631 | * If we're using custom entry slugs, we do a meta value search |
| 632 | 632 | * instead of doing a straightup ID search. |
| 633 | 633 | */ |
| 634 | - if ( $custom_slug ) { |
|
| 634 | + if ($custom_slug) { |
|
| 635 | 635 | |
| 636 | - $entry_id = self::get_entry_id_from_slug( $entry_slug ); |
|
| 636 | + $entry_id = self::get_entry_id_from_slug($entry_slug); |
|
| 637 | 637 | |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | // If custom slug is off, search using the entry ID |
| 641 | 641 | // ID allow ID access is on, also use entry ID as a backup |
| 642 | - if ( empty( $custom_slug ) || ! empty( $custom_slug_id_access ) ) { |
|
| 642 | + if (empty($custom_slug) || !empty($custom_slug_id_access)) { |
|
| 643 | 643 | // Search for IDs matching $entry_slug |
| 644 | 644 | $entry_id = $entry_slug; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - if ( empty( $entry_id ) ) { |
|
| 647 | + if (empty($entry_id)) { |
|
| 648 | 648 | return false; |
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | // fetch the entry |
| 652 | - $entry = GFAPI::get_entry( $entry_id ); |
|
| 652 | + $entry = GFAPI::get_entry($entry_id); |
|
| 653 | 653 | |
| 654 | - if( $check_entry_display ) { |
|
| 654 | + if ($check_entry_display) { |
|
| 655 | 655 | // Is the entry allowed |
| 656 | - $entry = self::check_entry_display( $entry ); |
|
| 656 | + $entry = self::check_entry_display($entry); |
|
| 657 | 657 | } |
| 658 | 658 | |
| 659 | - return is_wp_error( $entry ) ? false : $entry; |
|
| 659 | + return is_wp_error($entry) ? false : $entry; |
|
| 660 | 660 | |
| 661 | 661 | } |
| 662 | 662 | |
@@ -680,51 +680,51 @@ discard block |
||
| 680 | 680 | * |
| 681 | 681 | * @return bool True: matches, false: not matches |
| 682 | 682 | */ |
| 683 | - public static function matches_operation( $val1, $val2, $operation ) { |
|
| 683 | + public static function matches_operation($val1, $val2, $operation) { |
|
| 684 | 684 | |
| 685 | 685 | $value = false; |
| 686 | 686 | |
| 687 | - if( 'context' === $val1 ) { |
|
| 687 | + if ('context' === $val1) { |
|
| 688 | 688 | |
| 689 | - $matching_contexts = array( $val2 ); |
|
| 689 | + $matching_contexts = array($val2); |
|
| 690 | 690 | |
| 691 | 691 | // We allow for non-standard contexts. |
| 692 | - switch( $val2 ) { |
|
| 692 | + switch ($val2) { |
|
| 693 | 693 | // Check for either single or edit |
| 694 | 694 | case 'singular': |
| 695 | - $matching_contexts = array( 'single', 'edit' ); |
|
| 695 | + $matching_contexts = array('single', 'edit'); |
|
| 696 | 696 | break; |
| 697 | 697 | // Use multiple as alias for directory for consistency |
| 698 | 698 | case 'multiple': |
| 699 | - $matching_contexts = array( 'directory' ); |
|
| 699 | + $matching_contexts = array('directory'); |
|
| 700 | 700 | break; |
| 701 | 701 | } |
| 702 | 702 | |
| 703 | - $val1 = in_array( gravityview_get_context(), $matching_contexts ) ? $val2 : false; |
|
| 703 | + $val1 = in_array(gravityview_get_context(), $matching_contexts) ? $val2 : false; |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | - switch ( $operation ) { |
|
| 706 | + switch ($operation) { |
|
| 707 | 707 | case 'equals': |
| 708 | - $value = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
| 708 | + $value = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
| 709 | 709 | break; |
| 710 | 710 | case 'greater_than_or_is': |
| 711 | 711 | case 'greater_than_or_equals': |
| 712 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
| 713 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'greater_than' ); |
|
| 714 | - $value = ( $is || $gt ); |
|
| 712 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
| 713 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'greater_than'); |
|
| 714 | + $value = ($is || $gt); |
|
| 715 | 715 | break; |
| 716 | 716 | case 'less_than_or_is': |
| 717 | 717 | case 'less_than_or_equals': |
| 718 | - $is = GFFormsModel::matches_operation( $val1, $val2, 'is' ); |
|
| 719 | - $gt = GFFormsModel::matches_operation( $val1, $val2, 'less_than' ); |
|
| 720 | - $value = ( $is || $gt ); |
|
| 718 | + $is = GFFormsModel::matches_operation($val1, $val2, 'is'); |
|
| 719 | + $gt = GFFormsModel::matches_operation($val1, $val2, 'less_than'); |
|
| 720 | + $value = ($is || $gt); |
|
| 721 | 721 | break; |
| 722 | 722 | case 'not_contains': |
| 723 | - $contains = GFFormsModel::matches_operation( $val1, $val2, 'contains' ); |
|
| 724 | - $value = ! $contains; |
|
| 723 | + $contains = GFFormsModel::matches_operation($val1, $val2, 'contains'); |
|
| 724 | + $value = !$contains; |
|
| 725 | 725 | break; |
| 726 | 726 | default: |
| 727 | - $value = GFFormsModel::matches_operation( $val1, $val2, $operation ); |
|
| 727 | + $value = GFFormsModel::matches_operation($val1, $val2, $operation); |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | return $value; |
@@ -742,41 +742,41 @@ discard block |
||
| 742 | 742 | * @param array $entry Gravity Forms Entry object |
| 743 | 743 | * @return bool|array Returns 'false' if entry is not valid according to the view search filters (Adv Filter) |
| 744 | 744 | */ |
| 745 | - public static function check_entry_display( $entry ) { |
|
| 745 | + public static function check_entry_display($entry) { |
|
| 746 | 746 | |
| 747 | - if ( ! $entry || is_wp_error( $entry ) ) { |
|
| 748 | - do_action( 'gravityview_log_debug', __METHOD__ . ' Entry was not found.', $entry ); |
|
| 747 | + if (!$entry || is_wp_error($entry)) { |
|
| 748 | + do_action('gravityview_log_debug', __METHOD__.' Entry was not found.', $entry); |
|
| 749 | 749 | return false; |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | - if ( empty( $entry['form_id'] ) ) { |
|
| 753 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
|
| 752 | + if (empty($entry['form_id'])) { |
|
| 753 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry); |
|
| 754 | 754 | return false; |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | $criteria = self::calculate_get_entries_criteria(); |
| 758 | 758 | |
| 759 | 759 | // Make sure the current View is connected to the same form as the Entry |
| 760 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
| 761 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
| 762 | - $context_form_id = gravityview_get_form_id( $context_view_id ); |
|
| 763 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
| 764 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
| 760 | + if (!empty($criteria['context_view_id'])) { |
|
| 761 | + $context_view_id = intval($criteria['context_view_id']); |
|
| 762 | + $context_form_id = gravityview_get_form_id($context_view_id); |
|
| 763 | + if (intval($context_form_id) !== intval($entry['form_id'])) { |
|
| 764 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id']), $criteria['context_view_id']); |
|
| 765 | 765 | return false; |
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
| 770 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
|
| 769 | + if (empty($criteria['search_criteria']) || !is_array($criteria['search_criteria'])) { |
|
| 770 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria); |
|
| 771 | 771 | return $entry; |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | $search_criteria = $criteria['search_criteria']; |
| 775 | - unset( $criteria ); |
|
| 775 | + unset($criteria); |
|
| 776 | 776 | |
| 777 | 777 | // check entry status |
| 778 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
| 779 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
| 778 | + if (array_key_exists('status', $search_criteria) && $search_criteria['status'] != $entry['status']) { |
|
| 779 | + do_action('gravityview_log_debug', sprintf('[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status']), $search_criteria); |
|
| 780 | 780 | return false; |
| 781 | 781 | } |
| 782 | 782 | |
@@ -784,53 +784,53 @@ discard block |
||
| 784 | 784 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
| 785 | 785 | |
| 786 | 786 | // field_filters |
| 787 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
| 788 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
|
| 787 | + if (empty($search_criteria['field_filters']) || !is_array($search_criteria['field_filters'])) { |
|
| 788 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria); |
|
| 789 | 789 | return $entry; |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | $filters = $search_criteria['field_filters']; |
| 793 | - unset( $search_criteria ); |
|
| 793 | + unset($search_criteria); |
|
| 794 | 794 | |
| 795 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
| 796 | - unset( $filters['mode'] ); |
|
| 795 | + $mode = array_key_exists('mode', $filters) ? strtolower($filters['mode']) : 'all'; |
|
| 796 | + unset($filters['mode']); |
|
| 797 | 797 | |
| 798 | - $form = self::get_form( $entry['form_id'] ); |
|
| 798 | + $form = self::get_form($entry['form_id']); |
|
| 799 | 799 | |
| 800 | - foreach ( $filters as $filter ) { |
|
| 800 | + foreach ($filters as $filter) { |
|
| 801 | 801 | |
| 802 | - if ( ! isset( $filter['key'] ) ) { |
|
| 802 | + if (!isset($filter['key'])) { |
|
| 803 | 803 | continue; |
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | $k = $filter['key']; |
| 807 | 807 | |
| 808 | - if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
|
| 809 | - $field_value = $entry[ $k ]; |
|
| 808 | + if (in_array($k, array('created_by', 'payment_status'))) { |
|
| 809 | + $field_value = $entry[$k]; |
|
| 810 | 810 | $field = null; |
| 811 | 811 | } else { |
| 812 | - $field = self::get_field( $form, $k ); |
|
| 813 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
| 812 | + $field = self::get_field($form, $k); |
|
| 813 | + $field_value = GFFormsModel::get_lead_field_value($entry, $field); |
|
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
| 817 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
| 816 | + $operator = isset($filter['operator']) ? strtolower($filter['operator']) : 'is'; |
|
| 817 | + $is_value_match = GFFormsModel::is_value_match($field_value, $filter['value'], $operator, $field); |
|
| 818 | 818 | |
| 819 | 819 | // verify if we are already free to go! |
| 820 | - if ( ! $is_value_match && 'all' === $mode ) { |
|
| 821 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter ); |
|
| 820 | + if (!$is_value_match && 'all' === $mode) { |
|
| 821 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed one criteria for ALL mode', $filter); |
|
| 822 | 822 | return false; |
| 823 | - } elseif ( $is_value_match && 'any' === $mode ) { |
|
| 823 | + } elseif ($is_value_match && 'any' === $mode) { |
|
| 824 | 824 | return $entry; |
| 825 | 825 | } |
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | // at this point, if in ALL mode, then entry is approved - all conditions were met. |
| 829 | 829 | // Or, for ANY mode, means none of the conditions were satisfied, so entry is not approved |
| 830 | - if ( 'all' === $mode ) { |
|
| 830 | + if ('all' === $mode) { |
|
| 831 | 831 | return $entry; |
| 832 | 832 | } else { |
| 833 | - do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters ); |
|
| 833 | + do_action('gravityview_log_debug', '[apply_filters_to_entry] Entry cannot be displayed. Failed all the criteria for ANY mode', $filters); |
|
| 834 | 834 | return false; |
| 835 | 835 | } |
| 836 | 836 | |
@@ -845,14 +845,14 @@ discard block |
||
| 845 | 845 | * @param string $field_id |
| 846 | 846 | * @return string |
| 847 | 847 | */ |
| 848 | - public static function get_field_label( $form = array(), $field_id = '' ) { |
|
| 848 | + public static function get_field_label($form = array(), $field_id = '') { |
|
| 849 | 849 | |
| 850 | - if ( empty( $form ) || empty( $field_id ) ) { |
|
| 850 | + if (empty($form) || empty($field_id)) { |
|
| 851 | 851 | return ''; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | - $field = self::get_field( $form, $field_id ); |
|
| 855 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
| 854 | + $field = self::get_field($form, $field_id); |
|
| 855 | + return isset($field['label']) ? $field['label'] : ''; |
|
| 856 | 856 | |
| 857 | 857 | } |
| 858 | 858 | |
@@ -869,9 +869,9 @@ discard block |
||
| 869 | 869 | * @param string|int $field_id |
| 870 | 870 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
| 871 | 871 | */ |
| 872 | - public static function get_field( $form, $field_id ) { |
|
| 873 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
| 874 | - return GFFormsModel::get_field( $form, $field_id ); |
|
| 872 | + public static function get_field($form, $field_id) { |
|
| 873 | + if (class_exists('GFFormsModel')) { |
|
| 874 | + return GFFormsModel::get_field($form, $field_id); |
|
| 875 | 875 | } else { |
| 876 | 876 | return null; |
| 877 | 877 | } |
@@ -887,16 +887,16 @@ discard block |
||
| 887 | 887 | * @param WP_Post $post WordPress post object |
| 888 | 888 | * @return boolean True: yep, GravityView; No: not! |
| 889 | 889 | */ |
| 890 | - public static function has_gravityview_shortcode( $post = null ) { |
|
| 891 | - if ( ! is_a( $post, 'WP_Post' ) ) { |
|
| 890 | + public static function has_gravityview_shortcode($post = null) { |
|
| 891 | + if (!is_a($post, 'WP_Post')) { |
|
| 892 | 892 | return false; |
| 893 | 893 | } |
| 894 | 894 | |
| 895 | - if ( 'gravityview' === get_post_type( $post ) ) { |
|
| 895 | + if ('gravityview' === get_post_type($post)) { |
|
| 896 | 896 | return true; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - return self::has_shortcode_r( $post->post_content, 'gravityview' ) ? true : false; |
|
| 899 | + return self::has_shortcode_r($post->post_content, 'gravityview') ? true : false; |
|
| 900 | 900 | |
| 901 | 901 | } |
| 902 | 902 | |
@@ -907,27 +907,27 @@ discard block |
||
| 907 | 907 | * @param string $content Content to check whether there's a shortcode |
| 908 | 908 | * @param string $tag Current shortcode tag |
| 909 | 909 | */ |
| 910 | - public static function has_shortcode_r( $content, $tag = 'gravityview' ) { |
|
| 911 | - if ( false === strpos( $content, '[' ) ) { |
|
| 910 | + public static function has_shortcode_r($content, $tag = 'gravityview') { |
|
| 911 | + if (false === strpos($content, '[')) { |
|
| 912 | 912 | return false; |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - if ( shortcode_exists( $tag ) ) { |
|
| 915 | + if (shortcode_exists($tag)) { |
|
| 916 | 916 | |
| 917 | 917 | $shortcodes = array(); |
| 918 | 918 | |
| 919 | - preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
|
| 920 | - if ( empty( $matches ) ){ |
|
| 919 | + preg_match_all('/'.get_shortcode_regex().'/s', $content, $matches, PREG_SET_ORDER); |
|
| 920 | + if (empty($matches)) { |
|
| 921 | 921 | return false; |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - foreach ( $matches as $shortcode ) { |
|
| 925 | - if ( $tag === $shortcode[2] ) { |
|
| 924 | + foreach ($matches as $shortcode) { |
|
| 925 | + if ($tag === $shortcode[2]) { |
|
| 926 | 926 | |
| 927 | 927 | // Changed this to $shortcode instead of true so we get the parsed atts. |
| 928 | 928 | $shortcodes[] = $shortcode; |
| 929 | 929 | |
| 930 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
| 930 | + } else if (isset($shortcode[5]) && $result = self::has_shortcode_r($shortcode[5], $tag)) { |
|
| 931 | 931 | $shortcodes = $result; |
| 932 | 932 | } |
| 933 | 933 | } |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | * |
| 952 | 952 | * @return array Array with view details, as returned by get_posts() |
| 953 | 953 | */ |
| 954 | - public static function get_connected_views( $form_id, $args = array() ) { |
|
| 954 | + public static function get_connected_views($form_id, $args = array()) { |
|
| 955 | 955 | |
| 956 | 956 | $defaults = array( |
| 957 | 957 | 'post_type' => 'gravityview', |
@@ -960,9 +960,9 @@ discard block |
||
| 960 | 960 | 'meta_value' => (int)$form_id, |
| 961 | 961 | ); |
| 962 | 962 | |
| 963 | - $args = wp_parse_args( $args, $defaults ); |
|
| 963 | + $args = wp_parse_args($args, $defaults); |
|
| 964 | 964 | |
| 965 | - $views = get_posts( $args ); |
|
| 965 | + $views = get_posts($args); |
|
| 966 | 966 | |
| 967 | 967 | return $views; |
| 968 | 968 | } |
@@ -974,8 +974,8 @@ discard block |
||
| 974 | 974 | * |
| 975 | 975 | * @return string ID of the connected Form, if exists. Empty string if not. |
| 976 | 976 | */ |
| 977 | - public static function get_meta_form_id( $view_id ) { |
|
| 978 | - return get_post_meta( $view_id, '_gravityview_form_id', true ); |
|
| 977 | + public static function get_meta_form_id($view_id) { |
|
| 978 | + return get_post_meta($view_id, '_gravityview_form_id', true); |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | 981 | /** |
@@ -987,8 +987,8 @@ discard block |
||
| 987 | 987 | * |
| 988 | 988 | * @return string GravityView_Template::template_id value. Empty string if not. |
| 989 | 989 | */ |
| 990 | - public static function get_meta_template_id( $view_id ) { |
|
| 991 | - return get_post_meta( $view_id, '_gravityview_directory_template', true ); |
|
| 990 | + public static function get_meta_template_id($view_id) { |
|
| 991 | + return get_post_meta($view_id, '_gravityview_directory_template', true); |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | |
@@ -999,15 +999,15 @@ discard block |
||
| 999 | 999 | * @param int $post_id View ID |
| 1000 | 1000 | * @return array Associative array of settings with plugin defaults used if not set by the View |
| 1001 | 1001 | */ |
| 1002 | - public static function get_template_settings( $post_id ) { |
|
| 1002 | + public static function get_template_settings($post_id) { |
|
| 1003 | 1003 | |
| 1004 | - $settings = get_post_meta( $post_id, '_gravityview_template_settings', true ); |
|
| 1004 | + $settings = get_post_meta($post_id, '_gravityview_template_settings', true); |
|
| 1005 | 1005 | |
| 1006 | - if ( class_exists( 'GravityView_View_Data' ) ) { |
|
| 1006 | + if (class_exists('GravityView_View_Data')) { |
|
| 1007 | 1007 | |
| 1008 | 1008 | $defaults = GravityView_View_Data::get_default_args(); |
| 1009 | 1009 | |
| 1010 | - return wp_parse_args( (array)$settings, $defaults ); |
|
| 1010 | + return wp_parse_args((array)$settings, $defaults); |
|
| 1011 | 1011 | |
| 1012 | 1012 | } |
| 1013 | 1013 | |
@@ -1024,12 +1024,12 @@ discard block |
||
| 1024 | 1024 | * @param string $key Key for the setting |
| 1025 | 1025 | * @return mixed|null Setting value, or NULL if not set. |
| 1026 | 1026 | */ |
| 1027 | - public static function get_template_setting( $post_id, $key ) { |
|
| 1027 | + public static function get_template_setting($post_id, $key) { |
|
| 1028 | 1028 | |
| 1029 | - $settings = self::get_template_settings( $post_id ); |
|
| 1029 | + $settings = self::get_template_settings($post_id); |
|
| 1030 | 1030 | |
| 1031 | - if ( isset( $settings[ $key ] ) ) { |
|
| 1032 | - return $settings[ $key ]; |
|
| 1031 | + if (isset($settings[$key])) { |
|
| 1032 | + return $settings[$key]; |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | return null; |
@@ -1065,8 +1065,8 @@ discard block |
||
| 1065 | 1065 | * @param int $post_id View ID |
| 1066 | 1066 | * @return array Multi-array of fields with first level being the field zones. See code comment. |
| 1067 | 1067 | */ |
| 1068 | - public static function get_directory_fields( $post_id ) { |
|
| 1069 | - return get_post_meta( $post_id, '_gravityview_directory_fields', true ); |
|
| 1068 | + public static function get_directory_fields($post_id) { |
|
| 1069 | + return get_post_meta($post_id, '_gravityview_directory_fields', true); |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | |
@@ -1077,25 +1077,25 @@ discard block |
||
| 1077 | 1077 | * @param int $formid Form ID |
| 1078 | 1078 | * @return string html |
| 1079 | 1079 | */ |
| 1080 | - public static function get_sortable_fields( $formid, $current = '' ) { |
|
| 1081 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
| 1080 | + public static function get_sortable_fields($formid, $current = '') { |
|
| 1081 | + $output = '<option value="" '.selected('', $current, false).'>'.esc_html__('Default', 'gravityview').'</option>'; |
|
| 1082 | 1082 | |
| 1083 | - if ( empty( $formid ) ) { |
|
| 1083 | + if (empty($formid)) { |
|
| 1084 | 1084 | return $output; |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | - $fields = self::get_sortable_fields_array( $formid ); |
|
| 1087 | + $fields = self::get_sortable_fields_array($formid); |
|
| 1088 | 1088 | |
| 1089 | - if ( ! empty( $fields ) ) { |
|
| 1089 | + if (!empty($fields)) { |
|
| 1090 | 1090 | |
| 1091 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
|
| 1091 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array('list', 'textarea'), null); |
|
| 1092 | 1092 | |
| 1093 | - foreach ( $fields as $id => $field ) { |
|
| 1094 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1093 | + foreach ($fields as $id => $field) { |
|
| 1094 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
| 1095 | 1095 | continue; |
| 1096 | 1096 | } |
| 1097 | 1097 | |
| 1098 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
| 1098 | + $output .= '<option value="'.$id.'" '.selected($id, $current, false).'>'.esc_attr($field['label']).'</option>'; |
|
| 1099 | 1099 | } |
| 1100 | 1100 | } |
| 1101 | 1101 | |
@@ -1113,27 +1113,27 @@ discard block |
||
| 1113 | 1113 | * |
| 1114 | 1114 | * @return array |
| 1115 | 1115 | */ |
| 1116 | - public static function get_sortable_fields_array( $formid, $blacklist = array( 'list', 'textarea' ) ) { |
|
| 1116 | + public static function get_sortable_fields_array($formid, $blacklist = array('list', 'textarea')) { |
|
| 1117 | 1117 | |
| 1118 | 1118 | // Get fields with sub-inputs and no parent |
| 1119 | - $fields = self::get_form_fields( $formid, true, false ); |
|
| 1119 | + $fields = self::get_form_fields($formid, true, false); |
|
| 1120 | 1120 | |
| 1121 | 1121 | $date_created = array( |
| 1122 | 1122 | 'date_created' => array( |
| 1123 | 1123 | 'type' => 'date_created', |
| 1124 | - 'label' => __( 'Date Created', 'gravityview' ), |
|
| 1124 | + 'label' => __('Date Created', 'gravityview'), |
|
| 1125 | 1125 | ), |
| 1126 | 1126 | ); |
| 1127 | 1127 | |
| 1128 | 1128 | $fields = $date_created + $fields; |
| 1129 | 1129 | |
| 1130 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
|
| 1130 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', $blacklist, NULL); |
|
| 1131 | 1131 | |
| 1132 | 1132 | // TODO: Convert to using array_filter |
| 1133 | - foreach( $fields as $id => $field ) { |
|
| 1133 | + foreach ($fields as $id => $field) { |
|
| 1134 | 1134 | |
| 1135 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
| 1136 | - unset( $fields[ $id ] ); |
|
| 1135 | + if (in_array($field['type'], $blacklist_field_types)) { |
|
| 1136 | + unset($fields[$id]); |
|
| 1137 | 1137 | } |
| 1138 | 1138 | } |
| 1139 | 1139 | |
@@ -1143,7 +1143,7 @@ discard block |
||
| 1143 | 1143 | * @param array $fields Sub-set of GF form fields that are sortable |
| 1144 | 1144 | * @param int $formid The Gravity Forms form ID that the fields are from |
| 1145 | 1145 | */ |
| 1146 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
| 1146 | + $fields = apply_filters('gravityview/common/sortable_fields', $fields, $formid); |
|
| 1147 | 1147 | |
| 1148 | 1148 | return $fields; |
| 1149 | 1149 | } |
@@ -1154,15 +1154,15 @@ discard block |
||
| 1154 | 1154 | * @param mixed $field_id Field ID or Field array |
| 1155 | 1155 | * @return string field type |
| 1156 | 1156 | */ |
| 1157 | - public static function get_field_type( $form = null, $field_id = '' ) { |
|
| 1157 | + public static function get_field_type($form = null, $field_id = '') { |
|
| 1158 | 1158 | |
| 1159 | - if ( ! empty( $field_id ) && ! is_array( $field_id ) ) { |
|
| 1160 | - $field = self::get_field( $form, $field_id ); |
|
| 1159 | + if (!empty($field_id) && !is_array($field_id)) { |
|
| 1160 | + $field = self::get_field($form, $field_id); |
|
| 1161 | 1161 | } else { |
| 1162 | 1162 | $field = $field_id; |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | - return class_exists( 'RGFormsModel' ) ? RGFormsModel::get_input_type( $field ) : ''; |
|
| 1165 | + return class_exists('RGFormsModel') ? RGFormsModel::get_input_type($field) : ''; |
|
| 1166 | 1166 | |
| 1167 | 1167 | } |
| 1168 | 1168 | |
@@ -1173,17 +1173,17 @@ discard block |
||
| 1173 | 1173 | * @param int|array $field field key or field array |
| 1174 | 1174 | * @return boolean |
| 1175 | 1175 | */ |
| 1176 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
| 1176 | + public static function is_field_numeric($form = null, $field = '') { |
|
| 1177 | 1177 | |
| 1178 | - if ( ! is_array( $form ) && ! is_array( $field ) ) { |
|
| 1179 | - $form = self::get_form( $form ); |
|
| 1178 | + if (!is_array($form) && !is_array($field)) { |
|
| 1179 | + $form = self::get_form($form); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | // If entry meta, it's a string. Otherwise, numeric |
| 1183 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
| 1183 | + if (!is_numeric($field) && is_string($field)) { |
|
| 1184 | 1184 | $type = $field; |
| 1185 | 1185 | } else { |
| 1186 | - $type = self::get_field_type( $form, $field ); |
|
| 1186 | + $type = self::get_field_type($form, $field); |
|
| 1187 | 1187 | } |
| 1188 | 1188 | |
| 1189 | 1189 | /** |
@@ -1191,16 +1191,16 @@ discard block |
||
| 1191 | 1191 | * @since 1.5.2 |
| 1192 | 1192 | * @param array $numeric_types Fields that are numeric. Default: `[ number, time ]` |
| 1193 | 1193 | */ |
| 1194 | - $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
|
| 1194 | + $numeric_types = apply_filters('gravityview/common/numeric_types', array('number', 'time')); |
|
| 1195 | 1195 | |
| 1196 | 1196 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
| 1197 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
| 1198 | - if( true === $gv_field->is_numeric ) { |
|
| 1197 | + if ($gv_field = GravityView_Fields::get($type)) { |
|
| 1198 | + if (true === $gv_field->is_numeric) { |
|
| 1199 | 1199 | $numeric_types[] = $gv_field->is_numeric; |
| 1200 | 1200 | } |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | - $return = in_array( $type, $numeric_types ); |
|
| 1203 | + $return = in_array($type, $numeric_types); |
|
| 1204 | 1204 | |
| 1205 | 1205 | return $return; |
| 1206 | 1206 | } |
@@ -1219,19 +1219,19 @@ discard block |
||
| 1219 | 1219 | * |
| 1220 | 1220 | * @return string Content, encrypted |
| 1221 | 1221 | */ |
| 1222 | - public static function js_encrypt( $content, $message = '' ) { |
|
| 1222 | + public static function js_encrypt($content, $message = '') { |
|
| 1223 | 1223 | |
| 1224 | 1224 | $output = $content; |
| 1225 | 1225 | |
| 1226 | - if ( ! class_exists( 'StandalonePHPEnkoder' ) ) { |
|
| 1227 | - include_once( GRAVITYVIEW_DIR . 'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php' ); |
|
| 1226 | + if (!class_exists('StandalonePHPEnkoder')) { |
|
| 1227 | + include_once(GRAVITYVIEW_DIR.'includes/lib/standalone-phpenkoder/StandalonePHPEnkoder.php'); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | - if ( class_exists( 'StandalonePHPEnkoder' ) ) { |
|
| 1230 | + if (class_exists('StandalonePHPEnkoder')) { |
|
| 1231 | 1231 | |
| 1232 | 1232 | $enkoder = new StandalonePHPEnkoder; |
| 1233 | 1233 | |
| 1234 | - $message = empty( $message ) ? __( 'Email hidden; Javascript is required.', 'gravityview' ) : $message; |
|
| 1234 | + $message = empty($message) ? __('Email hidden; Javascript is required.', 'gravityview') : $message; |
|
| 1235 | 1235 | |
| 1236 | 1236 | /** |
| 1237 | 1237 | * @filter `gravityview/phpenkoder/msg` Modify the message shown when Javascript is disabled and an encrypted email field is displayed |
@@ -1239,9 +1239,9 @@ discard block |
||
| 1239 | 1239 | * @param string $message Existing message |
| 1240 | 1240 | * @param string $content Content to encrypt |
| 1241 | 1241 | */ |
| 1242 | - $enkoder->enkode_msg = apply_filters( 'gravityview/phpenkoder/msg', $message, $content ); |
|
| 1242 | + $enkoder->enkode_msg = apply_filters('gravityview/phpenkoder/msg', $message, $content); |
|
| 1243 | 1243 | |
| 1244 | - $output = $enkoder->enkode( $content ); |
|
| 1244 | + $output = $enkoder->enkode($content); |
|
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | return $output; |
@@ -1258,25 +1258,25 @@ discard block |
||
| 1258 | 1258 | * |
| 1259 | 1259 | * @author rubo77 at https://gist.github.com/rubo77/6821632 |
| 1260 | 1260 | **/ |
| 1261 | - public static function gv_parse_str( $string, &$result ) { |
|
| 1262 | - if ( empty( $string ) ) { |
|
| 1261 | + public static function gv_parse_str($string, &$result) { |
|
| 1262 | + if (empty($string)) { |
|
| 1263 | 1263 | return false; |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | $result = array(); |
| 1267 | 1267 | |
| 1268 | 1268 | // find the pairs "name=value" |
| 1269 | - $pairs = explode( '&', $string ); |
|
| 1269 | + $pairs = explode('&', $string); |
|
| 1270 | 1270 | |
| 1271 | - foreach ( $pairs as $pair ) { |
|
| 1271 | + foreach ($pairs as $pair) { |
|
| 1272 | 1272 | // use the original parse_str() on each element |
| 1273 | - parse_str( $pair, $params ); |
|
| 1273 | + parse_str($pair, $params); |
|
| 1274 | 1274 | |
| 1275 | - $k = key( $params ); |
|
| 1276 | - if ( ! isset( $result[ $k ] ) ) { |
|
| 1275 | + $k = key($params); |
|
| 1276 | + if (!isset($result[$k])) { |
|
| 1277 | 1277 | $result += $params; |
| 1278 | - } elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) { |
|
| 1279 | - $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] ); |
|
| 1278 | + } elseif (array_key_exists($k, $params) && is_array($params[$k])) { |
|
| 1279 | + $result[$k] = self::array_merge_recursive_distinct($result[$k], $params[$k]); |
|
| 1280 | 1280 | } |
| 1281 | 1281 | } |
| 1282 | 1282 | return true; |
@@ -1298,7 +1298,7 @@ discard block |
||
| 1298 | 1298 | * |
| 1299 | 1299 | * @return string HTML output of anchor link. If empty $href, returns NULL |
| 1300 | 1300 | */ |
| 1301 | - public static function get_link_html( $href = '', $anchor_text = '', $atts = array() ) { |
|
| 1301 | + public static function get_link_html($href = '', $anchor_text = '', $atts = array()) { |
|
| 1302 | 1302 | |
| 1303 | 1303 | // Supported attributes for anchor tags. HREF left out intentionally. |
| 1304 | 1304 | $allowed_atts = array( |
@@ -1334,31 +1334,31 @@ discard block |
||
| 1334 | 1334 | * @filter `gravityview/get_link/allowed_atts` Modify the attributes that are allowed to be used in generating links |
| 1335 | 1335 | * @param array $allowed_atts Array of attributes allowed |
| 1336 | 1336 | */ |
| 1337 | - $allowed_atts = apply_filters( 'gravityview/get_link/allowed_atts', $allowed_atts ); |
|
| 1337 | + $allowed_atts = apply_filters('gravityview/get_link/allowed_atts', $allowed_atts); |
|
| 1338 | 1338 | |
| 1339 | 1339 | // Make sure the attributes are formatted as array |
| 1340 | - $passed_atts = wp_parse_args( $atts ); |
|
| 1340 | + $passed_atts = wp_parse_args($atts); |
|
| 1341 | 1341 | |
| 1342 | 1342 | // Make sure the allowed attributes are only the ones in the $allowed_atts list |
| 1343 | - $final_atts = shortcode_atts( $allowed_atts, $passed_atts ); |
|
| 1343 | + $final_atts = shortcode_atts($allowed_atts, $passed_atts); |
|
| 1344 | 1344 | |
| 1345 | 1345 | // Remove attributes with empty values |
| 1346 | - $final_atts = array_filter( $final_atts ); |
|
| 1346 | + $final_atts = array_filter($final_atts); |
|
| 1347 | 1347 | |
| 1348 | 1348 | // If the href wasn't passed as an attribute, use the value passed to the function |
| 1349 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
| 1349 | + if (empty($final_atts['href']) && !empty($href)) { |
|
| 1350 | 1350 | $final_atts['href'] = $href; |
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | - $final_atts['href'] = esc_url_raw( $href ); |
|
| 1353 | + $final_atts['href'] = esc_url_raw($href); |
|
| 1354 | 1354 | |
| 1355 | 1355 | // For each attribute, generate the code |
| 1356 | 1356 | $output = ''; |
| 1357 | - foreach ( $final_atts as $attr => $value ) { |
|
| 1358 | - $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
|
| 1357 | + foreach ($final_atts as $attr => $value) { |
|
| 1358 | + $output .= sprintf(' %s="%s"', $attr, esc_attr($value)); |
|
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | - $output = '<a'. $output .'>'. $anchor_text .'</a>'; |
|
| 1361 | + $output = '<a'.$output.'>'.$anchor_text.'</a>'; |
|
| 1362 | 1362 | |
| 1363 | 1363 | return $output; |
| 1364 | 1364 | } |
@@ -1377,14 +1377,14 @@ discard block |
||
| 1377 | 1377 | * @author Daniel <daniel (at) danielsmedegaardbuus (dot) dk> |
| 1378 | 1378 | * @author Gabriel Sobrinho <gabriel (dot) sobrinho (at) gmail (dot) com> |
| 1379 | 1379 | */ |
| 1380 | - public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
|
| 1380 | + public static function array_merge_recursive_distinct(array &$array1, array &$array2) { |
|
| 1381 | 1381 | $merged = $array1; |
| 1382 | 1382 | |
| 1383 | - foreach ( $array2 as $key => &$value ) { |
|
| 1384 | - if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
|
| 1385 | - $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
|
| 1383 | + foreach ($array2 as $key => &$value) { |
|
| 1384 | + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
|
| 1385 | + $merged[$key] = self::array_merge_recursive_distinct($merged[$key], $value); |
|
| 1386 | 1386 | } else { |
| 1387 | - $merged[ $key ] = $value; |
|
| 1387 | + $merged[$key] = $value; |
|
| 1388 | 1388 | } |
| 1389 | 1389 | } |
| 1390 | 1390 | |
@@ -1398,26 +1398,26 @@ discard block |
||
| 1398 | 1398 | * @param array $args Arguments to modify the user query. See get_users() {@since 1.14} |
| 1399 | 1399 | * @return array Array of WP_User objects. |
| 1400 | 1400 | */ |
| 1401 | - public static function get_users( $context = 'change_entry_creator', $args = array() ) { |
|
| 1401 | + public static function get_users($context = 'change_entry_creator', $args = array()) { |
|
| 1402 | 1402 | |
| 1403 | 1403 | $default_args = array( |
| 1404 | 1404 | 'number' => 2000, |
| 1405 | 1405 | 'orderby' => 'display_name', |
| 1406 | 1406 | 'order' => 'ASC', |
| 1407 | - 'fields' => array( 'ID', 'display_name', 'user_login', 'user_nicename' ) |
|
| 1407 | + 'fields' => array('ID', 'display_name', 'user_login', 'user_nicename') |
|
| 1408 | 1408 | ); |
| 1409 | 1409 | |
| 1410 | 1410 | // Merge in the passed arg |
| 1411 | - $get_users_settings = wp_parse_args( $args, $default_args ); |
|
| 1411 | + $get_users_settings = wp_parse_args($args, $default_args); |
|
| 1412 | 1412 | |
| 1413 | 1413 | /** |
| 1414 | 1414 | * @filter `gravityview/get_users/{$context}` There are issues with too many users using [get_users()](http://codex.wordpress.org/Function_Reference/get_users) where it breaks the select. We try to keep it at a reasonable number. \n |
| 1415 | 1415 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
| 1416 | 1416 | * @param array $settings Settings array, with `number` key defining the # of users to display |
| 1417 | 1417 | */ |
| 1418 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
| 1418 | + $get_users_settings = apply_filters('gravityview/get_users/'.$context, apply_filters('gravityview_change_entry_creator_user_parameters', $get_users_settings)); |
|
| 1419 | 1419 | |
| 1420 | - return get_users( $get_users_settings ); |
|
| 1420 | + return get_users($get_users_settings); |
|
| 1421 | 1421 | } |
| 1422 | 1422 | |
| 1423 | 1423 | |
@@ -1429,8 +1429,8 @@ discard block |
||
| 1429 | 1429 | * |
| 1430 | 1430 | * @return string |
| 1431 | 1431 | */ |
| 1432 | - public static function generate_notice( $notice, $class = '' ) { |
|
| 1433 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
| 1432 | + public static function generate_notice($notice, $class = '') { |
|
| 1433 | + return '<div class="gv-notice '.gravityview_sanitize_html_class($class).'">'.$notice.'</div>'; |
|
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | 1436 | |
@@ -1452,6 +1452,6 @@ discard block |
||
| 1452 | 1452 | * |
| 1453 | 1453 | * @return string HTML output of anchor link. If empty $href, returns NULL |
| 1454 | 1454 | */ |
| 1455 | -function gravityview_get_link( $href = '', $anchor_text = '', $atts = array() ) { |
|
| 1456 | - return GVCommon::get_link_html( $href, $anchor_text, $atts ); |
|
| 1455 | +function gravityview_get_link($href = '', $anchor_text = '', $atts = array()) { |
|
| 1456 | + return GVCommon::get_link_html($href, $anchor_text, $atts); |
|
| 1457 | 1457 | } |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * @since 1.13 |
| 24 | 24 | */ |
| 25 | 25 | private function add_hooks() { |
| 26 | - add_action( 'add_admin_bar_menus', array( $this, 'remove_links' ), 80 ); |
|
| 27 | - add_action( 'admin_bar_menu', array( $this, 'add_links' ), 85 ); |
|
| 26 | + add_action('add_admin_bar_menus', array($this, 'remove_links'), 80); |
|
| 27 | + add_action('admin_bar_menu', array($this, 'add_links'), 85); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | $entry_id = $this->gravityview_view->getSingleEntry(); |
| 57 | 57 | |
| 58 | - if ( $entry_id && GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ), $entry_id ) ) { |
|
| 58 | + if ($entry_id && GVCommon::has_cap(array('gravityforms_edit_entries', 'gravityview_edit_entries'), $entry_id)) { |
|
| 59 | 59 | |
| 60 | 60 | $entry = $this->gravityview_view->getEntry(); |
| 61 | 61 | |
| 62 | - $wp_admin_bar->add_menu( array( |
|
| 62 | + $wp_admin_bar->add_menu(array( |
|
| 63 | 63 | 'id' => 'edit-entry', |
| 64 | - 'title' => __( 'Edit Entry', 'gravityview' ), |
|
| 65 | - 'href' => esc_url_raw( admin_url( sprintf( 'admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id'] ) ) ), |
|
| 66 | - ) ); |
|
| 64 | + 'title' => __('Edit Entry', 'gravityview'), |
|
| 65 | + 'href' => esc_url_raw(admin_url(sprintf('admin.php?page=gf_entries&screen_mode=edit&view=entry&id=%d&lid=%d', $entry['form_id'], $entry['id']))), |
|
| 66 | + )); |
|
| 67 | 67 | |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | /** @var WP_Admin_Bar $wp_admin_bar */ |
| 79 | 79 | global $wp_admin_bar; |
| 80 | 80 | |
| 81 | - if( GVCommon::has_cap('edit_gravityviews') ) { |
|
| 81 | + if (GVCommon::has_cap('edit_gravityviews')) { |
|
| 82 | 82 | |
| 83 | 83 | $view_data = GravityView_View_Data::getInstance(); |
| 84 | 84 | |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | // If there is a View embed, shor Edit View link. |
| 88 | 88 | // todo: Support multiple View embeds with a drop-down menu |
| 89 | - if ( ! $this->gravityview_view->isGravityviewPostType() && ! empty( $views ) && ! $view_data->has_multiple_views() ) { |
|
| 90 | - $view = reset( $views ); |
|
| 89 | + if (!$this->gravityview_view->isGravityviewPostType() && !empty($views) && !$view_data->has_multiple_views()) { |
|
| 90 | + $view = reset($views); |
|
| 91 | 91 | |
| 92 | - if( GVCommon::has_cap( 'edit_gravityview', $view['id'] ) ) { |
|
| 93 | - $wp_admin_bar->add_menu( array( |
|
| 92 | + if (GVCommon::has_cap('edit_gravityview', $view['id'])) { |
|
| 93 | + $wp_admin_bar->add_menu(array( |
|
| 94 | 94 | 'id' => 'edit-view', |
| 95 | - 'title' => __( 'Edit View', 'gravityview' ), |
|
| 96 | - 'href' => esc_url_raw( admin_url( sprintf( 'post.php?post=%d&action=edit', $view['id'] ) ) ), |
|
| 97 | - ) ); |
|
| 95 | + 'title' => __('Edit View', 'gravityview'), |
|
| 96 | + 'href' => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id']))), |
|
| 97 | + )); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | function remove_links() { |
| 109 | 109 | |
| 110 | 110 | // If we're on the single entry page, we don't want to cause confusion. |
| 111 | - if ( is_admin() || ( $this->gravityview_view->getSingleEntry() && ! $this->gravityview_view->isGravityviewPostType() ) ) { |
|
| 112 | - remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); |
|
| 111 | + if (is_admin() || ($this->gravityview_view->getSingleEntry() && !$this->gravityview_view->isGravityviewPostType())) { |
|
| 112 | + remove_action('admin_bar_menu', 'wp_admin_bar_edit_menu', 80); |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * When the plugin is activated, flush dismissed notices |
| 16 | 16 | * @since 1.15.1 |
| 17 | 17 | */ |
| 18 | -register_activation_hook( GRAVITYVIEW_FILE, array( 'GravityView_Admin_Notices', 'flush_dismissed_notices' ) ); |
|
| 18 | +register_activation_hook(GRAVITYVIEW_FILE, array('GravityView_Admin_Notices', 'flush_dismissed_notices')); |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Handle displaying and storing of admin notices for GravityView |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | function add_hooks() { |
| 36 | - add_action( 'network_admin_notices', array( $this, 'dismiss_notice' ), 50 ); |
|
| 37 | - add_action( 'admin_notices', array( $this, 'dismiss_notice' ), 50 ); |
|
| 38 | - add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 ); |
|
| 39 | - add_action( 'network_admin_notices', array( $this, 'admin_notice' ), 100 ); |
|
| 36 | + add_action('network_admin_notices', array($this, 'dismiss_notice'), 50); |
|
| 37 | + add_action('admin_notices', array($this, 'dismiss_notice'), 50); |
|
| 38 | + add_action('admin_notices', array($this, 'admin_notice'), 100); |
|
| 39 | + add_action('network_admin_notices', array($this, 'admin_notice'), 100); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | 48 | static public function flush_dismissed_notices() { |
| 49 | - delete_transient( 'gravityview_dismissed_notices' ); |
|
| 49 | + delete_transient('gravityview_dismissed_notices'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -57,26 +57,26 @@ discard block |
||
| 57 | 57 | public function dismiss_notice() { |
| 58 | 58 | |
| 59 | 59 | // No dismiss sent |
| 60 | - if( empty( $_GET['gv-dismiss'] ) ) { |
|
| 60 | + if (empty($_GET['gv-dismiss'])) { |
|
| 61 | 61 | return; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Invalid nonce |
| 65 | - if( !wp_verify_nonce( $_GET['gv-dismiss'], 'dismiss' ) ) { |
|
| 65 | + if (!wp_verify_nonce($_GET['gv-dismiss'], 'dismiss')) { |
|
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $notice_id = esc_attr( $_GET['notice'] ); |
|
| 69 | + $notice_id = esc_attr($_GET['notice']); |
|
| 70 | 70 | |
| 71 | 71 | //don't display a message if use has dismissed the message for this version |
| 72 | - $dismissed_notices = (array)get_transient( 'gravityview_dismissed_notices' ); |
|
| 72 | + $dismissed_notices = (array)get_transient('gravityview_dismissed_notices'); |
|
| 73 | 73 | |
| 74 | 74 | $dismissed_notices[] = $notice_id; |
| 75 | 75 | |
| 76 | - $dismissed_notices = array_unique( $dismissed_notices ); |
|
| 76 | + $dismissed_notices = array_unique($dismissed_notices); |
|
| 77 | 77 | |
| 78 | 78 | // Remind users every 16 weeks |
| 79 | - set_transient( 'gravityview_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16 ); |
|
| 79 | + set_transient('gravityview_dismissed_notices', $dismissed_notices, WEEK_IN_SECONDS * 16); |
|
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
@@ -91,15 +91,15 @@ discard block |
||
| 91 | 91 | * @param string $notice Notice array, set using `add_notice()`. |
| 92 | 92 | * @return boolean True: show notice; False: hide notice |
| 93 | 93 | */ |
| 94 | - private function is_notice_dismissed( $notice ) { |
|
| 94 | + private function is_notice_dismissed($notice) { |
|
| 95 | 95 | |
| 96 | 96 | // There are no dismissed notices. |
| 97 | - if( empty( self::$dismissed_notices ) ) { |
|
| 97 | + if (empty(self::$dismissed_notices)) { |
|
| 98 | 98 | return false; |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // Has the |
| 102 | - $is_dismissed = !empty( $notice['dismiss'] ) && in_array( $notice['dismiss'], self::$dismissed_notices ); |
|
| 102 | + $is_dismissed = !empty($notice['dismiss']) && in_array($notice['dismiss'], self::$dismissed_notices); |
|
| 103 | 103 | |
| 104 | 104 | return $is_dismissed ? true : false; |
| 105 | 105 | } |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | private function check_show_multisite_notices() { |
| 126 | 126 | |
| 127 | - if( ! is_multisite() ) { |
|
| 127 | + if (!is_multisite()) { |
|
| 128 | 128 | return true; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // It's network activated but the user can't manage network plugins; they can't do anything about it. |
| 132 | - if( GravityView_Plugin::is_network_activated() && ! is_main_site() ) { |
|
| 132 | + if (GravityView_Plugin::is_network_activated() && !is_main_site()) { |
|
| 133 | 133 | return false; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // or they don't have admin capabilities |
| 137 | - if( ! is_super_admin() ) { |
|
| 137 | + if (!is_super_admin()) { |
|
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -155,53 +155,53 @@ discard block |
||
| 155 | 155 | * @filter `gravityview/admin/notices` Modify the notices displayed in the admin |
| 156 | 156 | * @since 1.12 |
| 157 | 157 | */ |
| 158 | - $notices = apply_filters( 'gravityview/admin/notices', self::$admin_notices ); |
|
| 158 | + $notices = apply_filters('gravityview/admin/notices', self::$admin_notices); |
|
| 159 | 159 | |
| 160 | - if( empty( $notices ) || ! $this->check_show_multisite_notices() ) { |
|
| 160 | + if (empty($notices) || !$this->check_show_multisite_notices()) { |
|
| 161 | 161 | return; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | //don't display a message if use has dismissed the message for this version |
| 165 | 165 | // TODO: Use get_user_meta instead of get_transient |
| 166 | - self::$dismissed_notices = isset( $_GET['show-dismissed-notices'] ) ? array() : (array)get_transient( 'gravityview_dismissed_notices' ); |
|
| 166 | + self::$dismissed_notices = isset($_GET['show-dismissed-notices']) ? array() : (array)get_transient('gravityview_dismissed_notices'); |
|
| 167 | 167 | |
| 168 | 168 | $output = ''; |
| 169 | 169 | |
| 170 | - foreach( $notices as $notice ) { |
|
| 170 | + foreach ($notices as $notice) { |
|
| 171 | 171 | |
| 172 | 172 | // If the user doesn't have the capability to see the warning |
| 173 | - if( isset( $notice['cap'] ) && false === GVCommon::has_cap( $notice['cap'] ) ) { |
|
| 174 | - do_action( 'gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice ); |
|
| 173 | + if (isset($notice['cap']) && false === GVCommon::has_cap($notice['cap'])) { |
|
| 174 | + do_action('gravityview_log_debug', 'Notice not shown because user does not have the capability to view it.', $notice); |
|
| 175 | 175 | continue; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if( true === $this->is_notice_dismissed( $notice ) ) { |
|
| 179 | - do_action( 'gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice ); |
|
| 178 | + if (true === $this->is_notice_dismissed($notice)) { |
|
| 179 | + do_action('gravityview_log_debug', 'Notice not shown because the notice has already been dismissed.', $notice); |
|
| 180 | 180 | continue; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $output .= '<div id="message" style="position:relative" class="notice '. gravityview_sanitize_html_class( $notice['class'] ).'">'; |
|
| 183 | + $output .= '<div id="message" style="position:relative" class="notice '.gravityview_sanitize_html_class($notice['class']).'">'; |
|
| 184 | 184 | |
| 185 | 185 | // Too cute to leave out. |
| 186 | 186 | $output .= gravityview_get_floaty(); |
| 187 | 187 | |
| 188 | - if( !empty( $notice['title'] ) ) { |
|
| 189 | - $output .= '<h3>'.esc_html( $notice['title'] ) .'</h3>'; |
|
| 188 | + if (!empty($notice['title'])) { |
|
| 189 | + $output .= '<h3>'.esc_html($notice['title']).'</h3>'; |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $message = isset( $notice['message'] ) ? $notice['message'] : ''; |
|
| 192 | + $message = isset($notice['message']) ? $notice['message'] : ''; |
|
| 193 | 193 | |
| 194 | - if( !empty( $notice['dismiss'] ) ) { |
|
| 194 | + if (!empty($notice['dismiss'])) { |
|
| 195 | 195 | |
| 196 | 196 | $dismiss = esc_attr($notice['dismiss']); |
| 197 | 197 | |
| 198 | - $url = esc_url( add_query_arg( array( 'gv-dismiss' => wp_create_nonce( 'dismiss' ), 'notice' => $dismiss ) ) ); |
|
| 198 | + $url = esc_url(add_query_arg(array('gv-dismiss' => wp_create_nonce('dismiss'), 'notice' => $dismiss))); |
|
| 199 | 199 | |
| 200 | 200 | $align = is_rtl() ? 'alignleft' : 'alignright'; |
| 201 | - $message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="' . $align . ' button button-link">'.esc_html__('Dismiss', 'gravityview' ).'</a></p>'; |
|
| 201 | + $message .= '<a href="'.$url.'" data-notice="'.$dismiss.'" class="'.$align.' button button-link">'.esc_html__('Dismiss', 'gravityview').'</a></p>'; |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - $output .= wpautop( $message ); |
|
| 204 | + $output .= wpautop($message); |
|
| 205 | 205 | |
| 206 | 206 | $output .= '<div class="clear"></div>'; |
| 207 | 207 | $output .= '</div>'; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | |
| 211 | 211 | echo $output; |
| 212 | 212 | |
| 213 | - unset( $output, $align, $message, $notices ); |
|
| 213 | + unset($output, $align, $message, $notices); |
|
| 214 | 214 | |
| 215 | 215 | //reset the notices handler |
| 216 | 216 | self::$admin_notices = array(); |
@@ -223,14 +223,14 @@ discard block |
||
| 223 | 223 | * @param array $notice Array with `class`, `message`, `dismiss` and `cap` keys. The message is not escaped. |
| 224 | 224 | * @return void |
| 225 | 225 | */ |
| 226 | - public static function add_notice( $notice = array() ) { |
|
| 226 | + public static function add_notice($notice = array()) { |
|
| 227 | 227 | |
| 228 | - if( !isset( $notice['message'] ) ) { |
|
| 229 | - do_action( 'gravityview_log_error', 'GravityView_Admin[add_notice] Notice not set', $notice ); |
|
| 228 | + if (!isset($notice['message'])) { |
|
| 229 | + do_action('gravityview_log_error', 'GravityView_Admin[add_notice] Notice not set', $notice); |
|
| 230 | 230 | return; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
| 233 | + $notice['class'] = empty($notice['class']) ? 'error' : $notice['class']; |
|
| 234 | 234 | |
| 235 | 235 | self::$admin_notices[] = $notice; |
| 236 | 236 | } |