@@ -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 | /** If this file is called directly, abort. */ |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if (!defined('ABSPATH')) { |
|
| 16 | 16 | die; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -22,40 +22,40 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | function __construct() { |
| 24 | 24 | |
| 25 | - add_action( 'save_post', array( $this, 'save_postdata' ) ); |
|
| 25 | + add_action('save_post', array($this, 'save_postdata')); |
|
| 26 | 26 | |
| 27 | 27 | // set the blacklist field types across the entire plugin |
| 28 | - add_filter( 'gravityview_blacklist_field_types', array( $this, 'default_field_blacklist' ), 10, 2 ); |
|
| 28 | + add_filter('gravityview_blacklist_field_types', array($this, 'default_field_blacklist'), 10, 2); |
|
| 29 | 29 | |
| 30 | 30 | // Tooltips |
| 31 | - add_filter( 'gform_tooltips', array( $this, 'tooltips') ); |
|
| 31 | + add_filter('gform_tooltips', array($this, 'tooltips')); |
|
| 32 | 32 | |
| 33 | 33 | // adding styles and scripts |
| 34 | - add_action( 'admin_enqueue_scripts', array( 'GravityView_Admin_Views', 'add_scripts_and_styles'), 999 ); |
|
| 35 | - add_filter( 'gform_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
| 36 | - add_filter( 'gform_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
| 37 | - add_filter( 'gravityview_noconflict_styles', array( $this, 'register_no_conflict') ); |
|
| 38 | - add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict') ); |
|
| 39 | - |
|
| 40 | - add_action( 'gravityview_render_directory_active_areas', array( $this, 'render_directory_active_areas'), 10, 4 ); |
|
| 41 | - add_action( 'gravityview_render_widgets_active_areas', array( $this, 'render_widgets_active_areas'), 10, 3 ); |
|
| 42 | - add_action( 'gravityview_render_available_fields', array( $this, 'render_available_fields'), 10, 2 ); |
|
| 43 | - add_action( 'gravityview_render_available_widgets', array( $this, 'render_available_widgets') ); |
|
| 44 | - add_action( 'gravityview_render_active_areas', array( $this, 'render_active_areas'), 10, 5 ); |
|
| 34 | + add_action('admin_enqueue_scripts', array('GravityView_Admin_Views', 'add_scripts_and_styles'), 999); |
|
| 35 | + add_filter('gform_noconflict_styles', array($this, 'register_no_conflict')); |
|
| 36 | + add_filter('gform_noconflict_scripts', array($this, 'register_no_conflict')); |
|
| 37 | + add_filter('gravityview_noconflict_styles', array($this, 'register_no_conflict')); |
|
| 38 | + add_filter('gravityview_noconflict_scripts', array($this, 'register_no_conflict')); |
|
| 39 | + |
|
| 40 | + add_action('gravityview_render_directory_active_areas', array($this, 'render_directory_active_areas'), 10, 4); |
|
| 41 | + add_action('gravityview_render_widgets_active_areas', array($this, 'render_widgets_active_areas'), 10, 3); |
|
| 42 | + add_action('gravityview_render_available_fields', array($this, 'render_available_fields'), 10, 2); |
|
| 43 | + add_action('gravityview_render_available_widgets', array($this, 'render_available_widgets')); |
|
| 44 | + add_action('gravityview_render_active_areas', array($this, 'render_active_areas'), 10, 5); |
|
| 45 | 45 | |
| 46 | 46 | // @todo check if this hook is needed.. |
| 47 | 47 | //add_action( 'gravityview_render_field_options', array( $this, 'render_field_options'), 10, 9 ); |
| 48 | 48 | |
| 49 | 49 | // Add Connected Form column |
| 50 | - add_filter('manage_gravityview_posts_columns' , array( $this, 'add_post_type_columns' ) ); |
|
| 50 | + add_filter('manage_gravityview_posts_columns', array($this, 'add_post_type_columns')); |
|
| 51 | 51 | |
| 52 | - add_filter( 'gform_toolbar_menu', array( 'GravityView_Admin_Views', 'gform_toolbar_menu' ), 10, 2 ); |
|
| 52 | + add_filter('gform_toolbar_menu', array('GravityView_Admin_Views', 'gform_toolbar_menu'), 10, 2); |
|
| 53 | 53 | |
| 54 | - add_action( 'manage_gravityview_posts_custom_column', array( $this, 'add_custom_column_content'), 10, 2 ); |
|
| 54 | + add_action('manage_gravityview_posts_custom_column', array($this, 'add_custom_column_content'), 10, 2); |
|
| 55 | 55 | |
| 56 | - add_action( 'restrict_manage_posts', array( $this, 'add_view_dropdown' ) ); |
|
| 56 | + add_action('restrict_manage_posts', array($this, 'add_view_dropdown')); |
|
| 57 | 57 | |
| 58 | - add_action( 'pre_get_posts', array( $this, 'filter_pre_get_posts_by_gravityview_form_id' ) ); |
|
| 58 | + add_action('pre_get_posts', array($this, 'filter_pre_get_posts_by_gravityview_form_id')); |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -63,42 +63,42 @@ discard block |
||
| 63 | 63 | * @since 1.15 |
| 64 | 64 | * @param WP_Query $query |
| 65 | 65 | */ |
| 66 | - public function filter_pre_get_posts_by_gravityview_form_id( &$query ) { |
|
| 66 | + public function filter_pre_get_posts_by_gravityview_form_id(&$query) { |
|
| 67 | 67 | global $pagenow; |
| 68 | 68 | |
| 69 | - if ( !is_admin() ) { |
|
| 69 | + if (!is_admin()) { |
|
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if( 'edit.php' !== $pagenow || ! rgget( 'gravityview_form_id' ) || ! isset( $query->query_vars[ 'post_type' ] ) ) { |
|
| 73 | + if ('edit.php' !== $pagenow || !rgget('gravityview_form_id') || !isset($query->query_vars['post_type'])) { |
|
| 74 | 74 | return; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( $query->query_vars[ 'post_type' ] == 'gravityview' ) { |
|
| 78 | - $query->set( 'meta_query', array( |
|
| 77 | + if ($query->query_vars['post_type'] == 'gravityview') { |
|
| 78 | + $query->set('meta_query', array( |
|
| 79 | 79 | array( |
| 80 | 80 | 'key' => '_gravityview_form_id', |
| 81 | - 'value' => rgget( 'gravityview_form_id' ), |
|
| 81 | + 'value' => rgget('gravityview_form_id'), |
|
| 82 | 82 | ) |
| 83 | - ) ); |
|
| 83 | + )); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | function add_view_dropdown() { |
| 88 | 88 | $current_screen = get_current_screen(); |
| 89 | 89 | |
| 90 | - if( 'gravityview' !== $current_screen->post_type ) { |
|
| 90 | + if ('gravityview' !== $current_screen->post_type) { |
|
| 91 | 91 | return; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $forms = gravityview_get_forms(); |
| 95 | - $current_form = rgget( 'gravityview_form_id' ); |
|
| 95 | + $current_form = rgget('gravityview_form_id'); |
|
| 96 | 96 | // If there are no forms to select, show no forms. |
| 97 | - if( !empty( $forms ) ) { ?> |
|
| 97 | + if (!empty($forms)) { ?> |
|
| 98 | 98 | <select name="gravityview_form_id" id="gravityview_form_id"> |
| 99 | - <option value="" <?php selected( '', $current_form, true ); ?>><?php esc_html_e( 'All forms', 'gravityview' ); ?></option> |
|
| 100 | - <?php foreach( $forms as $form ) { ?> |
|
| 101 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
| 99 | + <option value="" <?php selected('', $current_form, true); ?>><?php esc_html_e('All forms', 'gravityview'); ?></option> |
|
| 100 | + <?php foreach ($forms as $form) { ?> |
|
| 101 | + <option value="<?php echo $form['id']; ?>" <?php selected($form['id'], $current_form, true); ?>><?php echo esc_html($form['title']); ?></option> |
|
| 102 | 102 | <?php } ?> |
| 103 | 103 | </select> |
| 104 | 104 | <?php } |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | * @deprecated since 1.2 |
| 110 | 110 | * Start using GravityView_Render_Settings::render_setting_row |
| 111 | 111 | */ |
| 112 | - public static function render_setting_row( $key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s' ) { |
|
| 113 | - _deprecated_function( 'GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row' ); |
|
| 114 | - GravityView_Render_Settings::render_setting_row( $key, $current_settings, $override_input, $name , $id ); |
|
| 112 | + public static function render_setting_row($key = '', $current_settings = array(), $override_input = null, $name = 'template_settings[%s]', $id = 'gravityview_se_%s') { |
|
| 113 | + _deprecated_function('GravityView_Admin_Views::render_setting_row', '1.1.7', 'GravityView_Render_Settings::render_setting_row'); |
|
| 114 | + GravityView_Render_Settings::render_setting_row($key, $current_settings, $override_input, $name, $id); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * @deprecated since 1.2 |
| 119 | 119 | * Start using GravityView_Render_Settings::render_field_option |
| 120 | 120 | */ |
| 121 | - public static function render_field_option( $name = '', $option, $curr_value = NULL ) { |
|
| 122 | - _deprecated_function( 'GravityView_Admin_Views::render_field_option', '1.1.7', 'GravityView_Render_Settings::render_field_option' ); |
|
| 123 | - return GravityView_Render_Settings::render_field_option( $name, $option, $curr_value ); |
|
| 121 | + public static function render_field_option($name = '', $option, $curr_value = NULL) { |
|
| 122 | + _deprecated_function('GravityView_Admin_Views::render_field_option', '1.1.7', 'GravityView_Render_Settings::render_field_option'); |
|
| 123 | + return GravityView_Render_Settings::render_field_option($name, $option, $curr_value); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -130,31 +130,31 @@ discard block |
||
| 130 | 130 | * @param int $id ID of the current Gravity form |
| 131 | 131 | * @return array Modified array |
| 132 | 132 | */ |
| 133 | - static function gform_toolbar_menu( $menu_items = array(), $id = NULL ) { |
|
| 133 | + static function gform_toolbar_menu($menu_items = array(), $id = NULL) { |
|
| 134 | 134 | |
| 135 | - $connected_views = gravityview_get_connected_views( $id ); |
|
| 135 | + $connected_views = gravityview_get_connected_views($id); |
|
| 136 | 136 | |
| 137 | - if( empty( $connected_views ) ) { |
|
| 137 | + if (empty($connected_views)) { |
|
| 138 | 138 | return $menu_items; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | $sub_menu_items = array(); |
| 142 | - foreach ( (array)$connected_views as $view ) { |
|
| 142 | + foreach ((array)$connected_views as $view) { |
|
| 143 | 143 | |
| 144 | - if( ! GVCommon::has_cap( 'edit_gravityview', $view->ID ) ) { |
|
| 144 | + if (!GVCommon::has_cap('edit_gravityview', $view->ID)) { |
|
| 145 | 145 | continue; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $label = empty( $view->post_title ) ? sprintf( __('No Title (View #%d)', 'gravityview' ), $view->ID ) : $view->post_title; |
|
| 148 | + $label = empty($view->post_title) ? sprintf(__('No Title (View #%d)', 'gravityview'), $view->ID) : $view->post_title; |
|
| 149 | 149 | |
| 150 | 150 | $sub_menu_items[] = array( |
| 151 | - 'label' => esc_attr( $label ), |
|
| 152 | - 'url' => admin_url( 'post.php?action=edit&post='.$view->ID ), |
|
| 151 | + 'label' => esc_attr($label), |
|
| 152 | + 'url' => admin_url('post.php?action=edit&post='.$view->ID), |
|
| 153 | 153 | ); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | // If there were no items added, then let's create the parent menu |
| 157 | - if( $sub_menu_items ) { |
|
| 157 | + if ($sub_menu_items) { |
|
| 158 | 158 | |
| 159 | 159 | // Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown |
| 160 | 160 | $sub_menu_items[] = array( |
@@ -165,16 +165,16 @@ discard block |
||
| 165 | 165 | ); |
| 166 | 166 | |
| 167 | 167 | $menu_items['gravityview'] = array( |
| 168 | - 'label' => __( 'Connected Views', 'gravityview' ), |
|
| 168 | + 'label' => __('Connected Views', 'gravityview'), |
|
| 169 | 169 | 'icon' => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>', |
| 170 | - 'title' => __( 'GravityView Views using this form as a data source', 'gravityview' ), |
|
| 170 | + 'title' => __('GravityView Views using this form as a data source', 'gravityview'), |
|
| 171 | 171 | 'url' => '#', |
| 172 | 172 | 'onclick' => 'return false;', |
| 173 | 173 | 'menu_class' => 'gv_connected_forms gf_form_toolbar_settings', |
| 174 | - 'link_class' => ( 1 === 1 ? '' : 'gf_toolbar_disabled' ), |
|
| 174 | + 'link_class' => (1 === 1 ? '' : 'gf_toolbar_disabled'), |
|
| 175 | 175 | 'sub_menu_items' => $sub_menu_items, |
| 176 | 176 | 'priority' => 0, |
| 177 | - 'capabilities' => array( 'edit_gravityviews' ), |
|
| 177 | + 'capabilities' => array('edit_gravityviews'), |
|
| 178 | 178 | ); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -189,16 +189,16 @@ discard block |
||
| 189 | 189 | * @access public |
| 190 | 190 | * @return array Default blacklist fields merged with existing blacklist fields |
| 191 | 191 | */ |
| 192 | - function default_field_blacklist( $array = array(), $context = NULL ) { |
|
| 192 | + function default_field_blacklist($array = array(), $context = NULL) { |
|
| 193 | 193 | |
| 194 | - $add = array( 'captcha', 'page' ); |
|
| 194 | + $add = array('captcha', 'page'); |
|
| 195 | 195 | |
| 196 | 196 | // Don't allowing editing the following values: |
| 197 | - if( $context === 'edit' ) { |
|
| 197 | + if ($context === 'edit') { |
|
| 198 | 198 | $add[] = 'post_id'; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - $return = array_merge( $array, $add ); |
|
| 201 | + $return = array_merge($array, $add); |
|
| 202 | 202 | |
| 203 | 203 | return $return; |
| 204 | 204 | } |
@@ -208,33 +208,33 @@ discard block |
||
| 208 | 208 | * @param array $tooltips Array of Gravity Forms tooltips |
| 209 | 209 | * @return array Modified tooltips array |
| 210 | 210 | */ |
| 211 | - public function tooltips( $tooltips = array() ) { |
|
| 211 | + public function tooltips($tooltips = array()) { |
|
| 212 | 212 | |
| 213 | 213 | $gv_tooltips = array(); |
| 214 | 214 | |
| 215 | 215 | // Generate tooltips for View settings |
| 216 | - $default_args = GravityView_View_Data::get_default_args( true ); |
|
| 216 | + $default_args = GravityView_View_Data::get_default_args(true); |
|
| 217 | 217 | |
| 218 | - foreach ( $default_args as $key => $arg ) { |
|
| 218 | + foreach ($default_args as $key => $arg) { |
|
| 219 | 219 | |
| 220 | 220 | // If an arg has `tooltip` defined, but it's false, don't display a tooltip |
| 221 | - if( isset( $arg['tooltip'] ) && empty( $arg['tooltip'] ) ) { continue; } |
|
| 221 | + if (isset($arg['tooltip']) && empty($arg['tooltip'])) { continue; } |
|
| 222 | 222 | |
| 223 | 223 | // By default, use `tooltip` if defined. |
| 224 | - $tooltip = empty( $arg['tooltip'] ) ? NULL : $arg['tooltip']; |
|
| 224 | + $tooltip = empty($arg['tooltip']) ? NULL : $arg['tooltip']; |
|
| 225 | 225 | |
| 226 | 226 | // Otherwise, use the description as a tooltip. |
| 227 | - if( empty( $tooltip ) && !empty( $arg['desc'] ) ) { |
|
| 227 | + if (empty($tooltip) && !empty($arg['desc'])) { |
|
| 228 | 228 | $tooltip = $arg['desc']; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // If there's no tooltip set, continue |
| 232 | - if( empty( $tooltip ) ) { |
|
| 232 | + if (empty($tooltip)) { |
|
| 233 | 233 | continue; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // Add the tooltip |
| 237 | - $gv_tooltips[ 'gv_'.$key ] = array( |
|
| 237 | + $gv_tooltips['gv_'.$key] = array( |
|
| 238 | 238 | 'title' => $arg['label'], |
| 239 | 239 | 'value' => $tooltip, |
| 240 | 240 | ); |
@@ -243,20 +243,20 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $gv_tooltips['gv_css_merge_tags'] = array( |
| 245 | 245 | 'title' => __('CSS Merge Tags', 'gravityview'), |
| 246 | - 'value' => sprintf( __( 'Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>' ) |
|
| 246 | + 'value' => sprintf(__('Developers: The CSS classes will be sanitized using the %ssanitize_title_with_dashes()%s function.', 'gravityview'), '<code>', '</code>') |
|
| 247 | 247 | ); |
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * @filter `gravityview_tooltips` The tooltips GravityView adds to the Gravity Forms tooltip array |
| 251 | 251 | * @param array $gv_tooltips Associative array with unique keys containing array of `title` and `value` keys, as expected by `gform_tooltips` filter |
| 252 | 252 | */ |
| 253 | - $gv_tooltips = apply_filters( 'gravityview_tooltips', $gv_tooltips ); |
|
| 253 | + $gv_tooltips = apply_filters('gravityview_tooltips', $gv_tooltips); |
|
| 254 | 254 | |
| 255 | - foreach ( $gv_tooltips as $key => $tooltip ) { |
|
| 255 | + foreach ($gv_tooltips as $key => $tooltip) { |
|
| 256 | 256 | |
| 257 | - $title = empty( $tooltip['title'] ) ? '' : '<h6>'.esc_html( $tooltip['title'] ) .'</h6>'; |
|
| 257 | + $title = empty($tooltip['title']) ? '' : '<h6>'.esc_html($tooltip['title']).'</h6>'; |
|
| 258 | 258 | |
| 259 | - $tooltips[ $key ] = $title . wpautop( esc_html( $tooltip['value'] ) ); |
|
| 259 | + $tooltips[$key] = $title.wpautop(esc_html($tooltip['value'])); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | return $tooltips; |
@@ -270,27 +270,27 @@ discard block |
||
| 270 | 270 | * |
| 271 | 271 | * @return void |
| 272 | 272 | */ |
| 273 | - public function add_custom_column_content( $column_name = NULL, $post_id ) { |
|
| 273 | + public function add_custom_column_content($column_name = NULL, $post_id) { |
|
| 274 | 274 | |
| 275 | 275 | $output = ''; |
| 276 | 276 | |
| 277 | - switch ( $column_name ) { |
|
| 277 | + switch ($column_name) { |
|
| 278 | 278 | case 'gv_template': |
| 279 | 279 | |
| 280 | - $template_id = gravityview_get_template_id( $post_id ); |
|
| 280 | + $template_id = gravityview_get_template_id($post_id); |
|
| 281 | 281 | |
| 282 | 282 | // All Views should have a connected form. If it doesn't, that's not right. |
| 283 | - if ( empty( $template_id ) ) { |
|
| 284 | - do_action( 'gravityview_log_error', sprintf( __METHOD__ . ' View ID %s does not have a connected template.', $post_id ) ); |
|
| 283 | + if (empty($template_id)) { |
|
| 284 | + do_action('gravityview_log_error', sprintf(__METHOD__.' View ID %s does not have a connected template.', $post_id)); |
|
| 285 | 285 | break; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $templates = gravityview_get_registered_templates(); |
| 289 | 289 | |
| 290 | - $template = isset( $templates[ $template_id ] ) ? $templates[ $template_id ] : false; |
|
| 290 | + $template = isset($templates[$template_id]) ? $templates[$template_id] : false; |
|
| 291 | 291 | |
| 292 | 292 | // Generate backup if label doesn't exist: `example_name` => `Example Name` |
| 293 | - $template_id_pretty = ucwords( implode( ' ', explode( '_', $template_id ) ) ); |
|
| 293 | + $template_id_pretty = ucwords(implode(' ', explode('_', $template_id))); |
|
| 294 | 294 | |
| 295 | 295 | $output = $template ? $template['label'] : $template_id_pretty; |
| 296 | 296 | |
@@ -298,24 +298,24 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | case 'gv_connected_form': |
| 300 | 300 | |
| 301 | - $form_id = gravityview_get_form_id( $post_id ); |
|
| 301 | + $form_id = gravityview_get_form_id($post_id); |
|
| 302 | 302 | |
| 303 | 303 | // All Views should have a connected form. If it doesn't, that's not right. |
| 304 | - if ( empty( $form_id ) ) { |
|
| 305 | - do_action( 'gravityview_log_error', sprintf( '[add_data_source_column_content] View ID %s does not have a connected GF form.', $post_id ) ); |
|
| 306 | - $output = __( 'Not connected.', 'gravityview' ); |
|
| 304 | + if (empty($form_id)) { |
|
| 305 | + do_action('gravityview_log_error', sprintf('[add_data_source_column_content] View ID %s does not have a connected GF form.', $post_id)); |
|
| 306 | + $output = __('Not connected.', 'gravityview'); |
|
| 307 | 307 | break; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $form = gravityview_get_form( $form_id ); |
|
| 310 | + $form = gravityview_get_form($form_id); |
|
| 311 | 311 | |
| 312 | - if ( ! $form ) { |
|
| 313 | - do_action( 'gravityview_log_error', sprintf( '[add_data_source_column_content] Connected form not found: Form #%d', $form_id ) ); |
|
| 312 | + if (!$form) { |
|
| 313 | + do_action('gravityview_log_error', sprintf('[add_data_source_column_content] Connected form not found: Form #%d', $form_id)); |
|
| 314 | 314 | |
| 315 | - $output = __( 'The connected form can not be found; it may no longer exist.', 'gravityview' ); |
|
| 315 | + $output = __('The connected form can not be found; it may no longer exist.', 'gravityview'); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - $output = self::get_connected_form_links( $form ); |
|
| 318 | + $output = self::get_connected_form_links($form); |
|
| 319 | 319 | |
| 320 | 320 | break; |
| 321 | 321 | } |
@@ -330,47 +330,47 @@ discard block |
||
| 330 | 330 | * @param boolean $include_form_link Whether to include the bold name of the form in the output |
| 331 | 331 | * @return string HTML links |
| 332 | 332 | */ |
| 333 | - static public function get_connected_form_links( $form, $include_form_link = true ) { |
|
| 333 | + static public function get_connected_form_links($form, $include_form_link = true) { |
|
| 334 | 334 | |
| 335 | 335 | // Either the form is empty or the form ID is 0, not yet set. |
| 336 | - if( empty( $form ) ) { |
|
| 336 | + if (empty($form)) { |
|
| 337 | 337 | return ''; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | // The $form is passed as the form ID |
| 341 | - if( !is_array( $form ) ) { |
|
| 342 | - $form = gravityview_get_form( $form ); |
|
| 341 | + if (!is_array($form)) { |
|
| 342 | + $form = gravityview_get_form($form); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | $form_id = $form['id']; |
| 346 | 346 | $links = array(); |
| 347 | 347 | |
| 348 | - if( GVCommon::has_cap( 'gravityforms_edit_forms' ) ) { |
|
| 349 | - $form_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&id=%d', $form_id ) ); |
|
| 350 | - $form_link = '<strong class="gv-form-title">'.gravityview_get_link( $form_url, $form['title'], 'class=row-title' ).'</strong>'; |
|
| 351 | - $links[] = '<span>'.gravityview_get_link( $form_url, __('Edit Form', 'gravityview') ).'</span>'; |
|
| 348 | + if (GVCommon::has_cap('gravityforms_edit_forms')) { |
|
| 349 | + $form_url = admin_url(sprintf('admin.php?page=gf_edit_forms&id=%d', $form_id)); |
|
| 350 | + $form_link = '<strong class="gv-form-title">'.gravityview_get_link($form_url, $form['title'], 'class=row-title').'</strong>'; |
|
| 351 | + $links[] = '<span>'.gravityview_get_link($form_url, __('Edit Form', 'gravityview')).'</span>'; |
|
| 352 | 352 | } else { |
| 353 | - $form_link = '<strong class="gv-form-title">'. esc_html( $form['title'] ). '</strong>'; |
|
| 353 | + $form_link = '<strong class="gv-form-title">'.esc_html($form['title']).'</strong>'; |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | - if( GVCommon::has_cap( 'gravityforms_view_entries' ) ) { |
|
| 357 | - $entries_url = admin_url( sprintf( 'admin.php?page=gf_entries&id=%d', $form_id ) ); |
|
| 358 | - $links[] = '<span>'.gravityview_get_link( $entries_url, __('Entries', 'gravityview') ).'</span>'; |
|
| 356 | + if (GVCommon::has_cap('gravityforms_view_entries')) { |
|
| 357 | + $entries_url = admin_url(sprintf('admin.php?page=gf_entries&id=%d', $form_id)); |
|
| 358 | + $links[] = '<span>'.gravityview_get_link($entries_url, __('Entries', 'gravityview')).'</span>'; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if( GVCommon::has_cap( array( 'gravityforms_edit_settings', 'gravityview_view_settings' ) ) ) { |
|
| 362 | - $settings_url = admin_url( sprintf( 'admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id ) ); |
|
| 363 | - $links[] = '<span>'.gravityview_get_link( $settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview') ).'</span>'; |
|
| 361 | + if (GVCommon::has_cap(array('gravityforms_edit_settings', 'gravityview_view_settings'))) { |
|
| 362 | + $settings_url = admin_url(sprintf('admin.php?page=gf_edit_forms&view=settings&id=%d', $form_id)); |
|
| 363 | + $links[] = '<span>'.gravityview_get_link($settings_url, __('Settings', 'gravityview'), 'title='.__('Edit settings for this form', 'gravityview')).'</span>'; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | - if( GVCommon::has_cap( array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms") ) ) { |
|
| 367 | - $preview_url = site_url( sprintf( '?gf_page=preview&id=%d', $form_id ) ); |
|
| 368 | - $links[] = '<span>'.gravityview_get_link( $preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview') ).'</span>'; |
|
| 366 | + if (GVCommon::has_cap(array("gravityforms_edit_forms", "gravityforms_create_form", "gravityforms_preview_forms"))) { |
|
| 367 | + $preview_url = site_url(sprintf('?gf_page=preview&id=%d', $form_id)); |
|
| 368 | + $links[] = '<span>'.gravityview_get_link($preview_url, __('Preview Form', 'gravityview'), 'title='.__('Preview this form', 'gravityview')).'</span>'; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | $output = ''; |
| 372 | 372 | |
| 373 | - if( !empty( $include_form_link ) ) { |
|
| 373 | + if (!empty($include_form_link)) { |
|
| 374 | 374 | $output .= $form_link; |
| 375 | 375 | } |
| 376 | 376 | |
@@ -380,9 +380,9 @@ discard block |
||
| 380 | 380 | * @param array $links Links to show |
| 381 | 381 | * @param array $form Gravity Forms form array |
| 382 | 382 | */ |
| 383 | - $links = apply_filters( 'gravityview_connected_form_links', $links, $form ); |
|
| 383 | + $links = apply_filters('gravityview_connected_form_links', $links, $form); |
|
| 384 | 384 | |
| 385 | - $output .= '<div class="row-actions">'. implode( ' | ', $links ) .'</div>'; |
|
| 385 | + $output .= '<div class="row-actions">'.implode(' | ', $links).'</div>'; |
|
| 386 | 386 | |
| 387 | 387 | return $output; |
| 388 | 388 | } |
@@ -391,13 +391,13 @@ discard block |
||
| 391 | 391 | * Add the Data Source column to the Views page |
| 392 | 392 | * @param array $columns Columns array |
| 393 | 393 | */ |
| 394 | - public function add_post_type_columns( $columns ) { |
|
| 394 | + public function add_post_type_columns($columns) { |
|
| 395 | 395 | |
| 396 | 396 | // Get the date column and save it for later to add back in. |
| 397 | 397 | // This adds it after the Data Source column. |
| 398 | 398 | // This way, we don't need to do array_slice, array_merge, etc. |
| 399 | 399 | $date = $columns['date']; |
| 400 | - unset( $columns['date'] ); |
|
| 400 | + unset($columns['date']); |
|
| 401 | 401 | |
| 402 | 402 | $data_source_required_caps = array( |
| 403 | 403 | 'gravityforms_edit_forms', |
@@ -408,11 +408,11 @@ discard block |
||
| 408 | 408 | 'gravityforms_preview_forms', |
| 409 | 409 | ); |
| 410 | 410 | |
| 411 | - if( GVCommon::has_cap( $data_source_required_caps ) ) { |
|
| 412 | - $columns['gv_connected_form'] = __( 'Data Source', 'gravityview' ); |
|
| 411 | + if (GVCommon::has_cap($data_source_required_caps)) { |
|
| 412 | + $columns['gv_connected_form'] = __('Data Source', 'gravityview'); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $columns['gv_template'] = _x( 'Template', 'Column title that shows what template is being used for Views', 'gravityview' ); |
|
| 415 | + $columns['gv_template'] = _x('Template', 'Column title that shows what template is being used for Views', 'gravityview'); |
|
| 416 | 416 | |
| 417 | 417 | // Add the date back in. |
| 418 | 418 | $columns['date'] = $date; |
@@ -427,91 +427,91 @@ discard block |
||
| 427 | 427 | * @param int $post_id Currently saved Post ID |
| 428 | 428 | * @return void |
| 429 | 429 | */ |
| 430 | - function save_postdata( $post_id ) { |
|
| 430 | + function save_postdata($post_id) { |
|
| 431 | 431 | |
| 432 | - if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){ |
|
| 432 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 433 | 433 | return; |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | // validate post_type |
| 437 | - if ( ! isset( $_POST['post_type'] ) || 'gravityview' != $_POST['post_type'] ) { |
|
| 437 | + if (!isset($_POST['post_type']) || 'gravityview' != $_POST['post_type']) { |
|
| 438 | 438 | return; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | // validate user can edit and save View |
| 442 | - if ( ! GVCommon::has_cap( 'edit_gravityview', $post_id ) ) { |
|
| 443 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to edit View #' . $post_id, wp_get_current_user() ); |
|
| 442 | + if (!GVCommon::has_cap('edit_gravityview', $post_id)) { |
|
| 443 | + do_action('gravityview_log_error', __METHOD__.' - Current user does not have the capability to edit View #'.$post_id, wp_get_current_user()); |
|
| 444 | 444 | return; |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - do_action( 'gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST ); |
|
| 447 | + do_action('gravityview_log_debug', '[save_postdata] Saving View post type.', $_POST); |
|
| 448 | 448 | |
| 449 | 449 | $statii = array(); |
| 450 | 450 | |
| 451 | 451 | // check if this is a start fresh View |
| 452 | - if ( isset( $_POST['gravityview_select_form_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_form_nonce'], 'gravityview_select_form' ) ) { |
|
| 452 | + if (isset($_POST['gravityview_select_form_nonce']) && wp_verify_nonce($_POST['gravityview_select_form_nonce'], 'gravityview_select_form')) { |
|
| 453 | 453 | |
| 454 | - $form_id = !empty( $_POST['gravityview_form_id'] ) ? $_POST['gravityview_form_id'] : ''; |
|
| 454 | + $form_id = !empty($_POST['gravityview_form_id']) ? $_POST['gravityview_form_id'] : ''; |
|
| 455 | 455 | // save form id |
| 456 | - $statii['form_id'] = update_post_meta( $post_id, '_gravityview_form_id', $form_id ); |
|
| 456 | + $statii['form_id'] = update_post_meta($post_id, '_gravityview_form_id', $form_id); |
|
| 457 | 457 | |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if( false === GVCommon::has_cap( 'gravityforms_create_form' ) && empty( $statii['form_id'] ) ) { |
|
| 461 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Current user does not have the capability to create a new Form.', wp_get_current_user() ); |
|
| 460 | + if (false === GVCommon::has_cap('gravityforms_create_form') && empty($statii['form_id'])) { |
|
| 461 | + do_action('gravityview_log_error', __METHOD__.' - Current user does not have the capability to create a new Form.', wp_get_current_user()); |
|
| 462 | 462 | return; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // Was this a start fresh? |
| 466 | - if ( ! empty( $_POST['gravityview_form_id_start_fresh'] ) ) { |
|
| 467 | - $statii['start_fresh'] = add_post_meta( $post_id, '_gravityview_start_fresh', 1 ); |
|
| 466 | + if (!empty($_POST['gravityview_form_id_start_fresh'])) { |
|
| 467 | + $statii['start_fresh'] = add_post_meta($post_id, '_gravityview_start_fresh', 1); |
|
| 468 | 468 | } else { |
| 469 | - $statii['start_fresh'] = delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
| 469 | + $statii['start_fresh'] = delete_post_meta($post_id, '_gravityview_start_fresh'); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | // Check if we have a template id |
| 473 | - if ( isset( $_POST['gravityview_select_template_nonce'] ) && wp_verify_nonce( $_POST['gravityview_select_template_nonce'], 'gravityview_select_template' ) ) { |
|
| 473 | + if (isset($_POST['gravityview_select_template_nonce']) && wp_verify_nonce($_POST['gravityview_select_template_nonce'], 'gravityview_select_template')) { |
|
| 474 | 474 | |
| 475 | - $template_id = !empty( $_POST['gravityview_directory_template'] ) ? $_POST['gravityview_directory_template'] : ''; |
|
| 475 | + $template_id = !empty($_POST['gravityview_directory_template']) ? $_POST['gravityview_directory_template'] : ''; |
|
| 476 | 476 | |
| 477 | 477 | // now save template id |
| 478 | - $statii['directory_template'] = update_post_meta( $post_id, '_gravityview_directory_template', $template_id ); |
|
| 478 | + $statii['directory_template'] = update_post_meta($post_id, '_gravityview_directory_template', $template_id); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | |
| 482 | 482 | // save View Configuration metabox |
| 483 | - if ( isset( $_POST['gravityview_view_configuration_nonce'] ) && wp_verify_nonce( $_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration' ) ) { |
|
| 483 | + if (isset($_POST['gravityview_view_configuration_nonce']) && wp_verify_nonce($_POST['gravityview_view_configuration_nonce'], 'gravityview_view_configuration')) { |
|
| 484 | 484 | |
| 485 | 485 | // template settings |
| 486 | - if( empty( $_POST['template_settings'] ) ) { |
|
| 486 | + if (empty($_POST['template_settings'])) { |
|
| 487 | 487 | $_POST['template_settings'] = array(); |
| 488 | 488 | } |
| 489 | - $statii['template_settings'] = update_post_meta( $post_id, '_gravityview_template_settings', $_POST['template_settings'] ); |
|
| 489 | + $statii['template_settings'] = update_post_meta($post_id, '_gravityview_template_settings', $_POST['template_settings']); |
|
| 490 | 490 | |
| 491 | 491 | $fields = array(); |
| 492 | 492 | |
| 493 | 493 | // Directory&single Visible Fields |
| 494 | - if( !empty( $preset_fields ) ) { |
|
| 494 | + if (!empty($preset_fields)) { |
|
| 495 | 495 | |
| 496 | 496 | $fields = $preset_fields; |
| 497 | 497 | |
| 498 | - } elseif( !empty( $_POST['fields'] ) ) { |
|
| 498 | + } elseif (!empty($_POST['fields'])) { |
|
| 499 | 499 | |
| 500 | - if( !is_array( $_POST['fields'] ) ) { |
|
| 500 | + if (!is_array($_POST['fields'])) { |
|
| 501 | 501 | |
| 502 | 502 | // Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method |
| 503 | 503 | // Not using parse_str due to max_input_vars limitation |
| 504 | 504 | $fields_holder = array(); |
| 505 | - GVCommon::gv_parse_str( $_POST['fields'], $fields_holder ); |
|
| 505 | + GVCommon::gv_parse_str($_POST['fields'], $fields_holder); |
|
| 506 | 506 | |
| 507 | - if( isset( $fields_holder['fields'] ) ) { |
|
| 507 | + if (isset($fields_holder['fields'])) { |
|
| 508 | 508 | |
| 509 | 509 | // When parsed, there's a m |
| 510 | 510 | $fields = $fields_holder['fields']; |
| 511 | 511 | |
| 512 | 512 | } else { |
| 513 | 513 | |
| 514 | - do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder ); |
|
| 514 | + do_action('gravityview_log_error', '[save_postdata] No `fields` key was found after parsing $fields string', $fields_holder); |
|
| 515 | 515 | |
| 516 | 516 | } |
| 517 | 517 | |
@@ -522,24 +522,24 @@ discard block |
||
| 522 | 522 | } |
| 523 | 523 | } |
| 524 | 524 | |
| 525 | - $statii['directory_fields'] = update_post_meta( $post_id, '_gravityview_directory_fields', $fields ); |
|
| 525 | + $statii['directory_fields'] = update_post_meta($post_id, '_gravityview_directory_fields', $fields); |
|
| 526 | 526 | |
| 527 | 527 | // Directory Visible Widgets |
| 528 | - if( empty( $_POST['widgets'] ) ) { |
|
| 528 | + if (empty($_POST['widgets'])) { |
|
| 529 | 529 | $_POST['widgets'] = array(); |
| 530 | 530 | } |
| 531 | - $statii['directory_widgets'] = update_post_meta( $post_id, '_gravityview_directory_widgets', $_POST['widgets'] ); |
|
| 531 | + $statii['directory_widgets'] = update_post_meta($post_id, '_gravityview_directory_widgets', $_POST['widgets']); |
|
| 532 | 532 | |
| 533 | 533 | } // end save view configuration |
| 534 | 534 | |
| 535 | - do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map( 'intval', $statii ) ); |
|
| 535 | + do_action('gravityview_log_debug', '[save_postdata] Update Post Meta Statuses (also returns false if nothing changed)', array_map('intval', $statii)); |
|
| 536 | 536 | } |
| 537 | 537 | |
| 538 | 538 | /** |
| 539 | 539 | * @deprecated 1.1.6 |
| 540 | 540 | */ |
| 541 | 541 | function render_label() { |
| 542 | - _deprecated_function( 'GravityView_Admin_Views::render_label()', '1.1.6', 'Use the GravityView_Admin_View_Field class instead.' ); |
|
| 542 | + _deprecated_function('GravityView_Admin_Views::render_label()', '1.1.6', 'Use the GravityView_Admin_View_Field class instead.'); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -551,33 +551,33 @@ discard block |
||
| 551 | 551 | * @param string $context (default: 'single') |
| 552 | 552 | * @return void |
| 553 | 553 | */ |
| 554 | - function render_available_fields( $form = '', $context = 'single' ) { |
|
| 554 | + function render_available_fields($form = '', $context = 'single') { |
|
| 555 | 555 | |
| 556 | 556 | /** |
| 557 | 557 | * @filter `gravityview_blacklist_field_types` Modify the types of fields that shouldn't be shown in a View. |
| 558 | 558 | * @param[in,out] array $blacklist_field_types Array of field types to block for this context. |
| 559 | 559 | * @param[in] string $context View context ('single', 'directory', or 'edit') |
| 560 | 560 | */ |
| 561 | - $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array(), $context ); |
|
| 561 | + $blacklist_field_types = apply_filters('gravityview_blacklist_field_types', array(), $context); |
|
| 562 | 562 | |
| 563 | - $fields = $this->get_available_fields( $form, $context ); |
|
| 563 | + $fields = $this->get_available_fields($form, $context); |
|
| 564 | 564 | |
| 565 | 565 | $output = ''; |
| 566 | 566 | |
| 567 | - if( !empty( $fields ) ) { |
|
| 567 | + if (!empty($fields)) { |
|
| 568 | 568 | |
| 569 | - foreach( $fields as $id => $details ) { |
|
| 569 | + foreach ($fields as $id => $details) { |
|
| 570 | 570 | |
| 571 | - if( in_array( $details['type'], $blacklist_field_types ) ) { |
|
| 571 | + if (in_array($details['type'], $blacklist_field_types)) { |
|
| 572 | 572 | continue; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | // Edit mode only allows editing the parent fields, not single inputs. |
| 576 | - if( $context === 'edit' && !empty( $details['parent'] ) ) { |
|
| 576 | + if ($context === 'edit' && !empty($details['parent'])) { |
|
| 577 | 577 | continue; |
| 578 | 578 | } |
| 579 | 579 | |
| 580 | - $output .= new GravityView_Admin_View_Field( $details['label'], $id, $details ); |
|
| 580 | + $output .= new GravityView_Admin_View_Field($details['label'], $id, $details); |
|
| 581 | 581 | |
| 582 | 582 | } // End foreach |
| 583 | 583 | } |
@@ -585,22 +585,22 @@ discard block |
||
| 585 | 585 | echo $output; |
| 586 | 586 | |
| 587 | 587 | // For the EDIT view we only want to allow the form fields. |
| 588 | - if( $context === 'edit' ) { |
|
| 588 | + if ($context === 'edit') { |
|
| 589 | 589 | return; |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | - $this->render_additional_fields( $form, $context ); |
|
| 592 | + $this->render_additional_fields($form, $context); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - function render_additional_fields( $form, $context ) { |
|
| 595 | + function render_additional_fields($form, $context) { |
|
| 596 | 596 | |
| 597 | 597 | /** |
| 598 | 598 | * @filter `gravityview_additional_fields` non-standard Fields to show at the bottom of the field picker |
| 599 | 599 | * @param array $additional_fields Associative array of field arrays, with `label_text`, `desc`, `field_id`, `label_type`, `input_type`, `field_options`, and `settings_html` keys |
| 600 | 600 | */ |
| 601 | - $additional_fields = apply_filters( 'gravityview_additional_fields', array( |
|
| 601 | + $additional_fields = apply_filters('gravityview_additional_fields', array( |
|
| 602 | 602 | array( |
| 603 | - 'label_text' => __( '+ Add All Fields', 'gravityview' ), |
|
| 603 | + 'label_text' => __('+ Add All Fields', 'gravityview'), |
|
| 604 | 604 | 'desc' => __('Add all the available fields at once.', 'gravityview'), |
| 605 | 605 | 'field_id' => 'all-fields', |
| 606 | 606 | 'label_type' => 'field', |
@@ -610,11 +610,11 @@ discard block |
||
| 610 | 610 | ) |
| 611 | 611 | )); |
| 612 | 612 | |
| 613 | - if( !empty( $additional_fields )) { |
|
| 614 | - foreach ( (array)$additional_fields as $item ) { |
|
| 613 | + if (!empty($additional_fields)) { |
|
| 614 | + foreach ((array)$additional_fields as $item) { |
|
| 615 | 615 | |
| 616 | 616 | // Prevent items from not having index set |
| 617 | - $item = wp_parse_args( $item, array( |
|
| 617 | + $item = wp_parse_args($item, array( |
|
| 618 | 618 | 'label_text' => NULL, |
| 619 | 619 | 'field_id' => NULL, |
| 620 | 620 | 'label_type' => NULL, |
@@ -624,13 +624,13 @@ discard block |
||
| 624 | 624 | )); |
| 625 | 625 | |
| 626 | 626 | // Backward compat. |
| 627 | - if( !empty( $item['field_options'] ) ) { |
|
| 627 | + if (!empty($item['field_options'])) { |
|
| 628 | 628 | // Use settings_html from now on. |
| 629 | 629 | $item['settings_html'] = $item['field_options']; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // Render a label for each of them |
| 633 | - echo new GravityView_Admin_View_Field( $item['label_text'], $item['field_id'], $item ); |
|
| 633 | + echo new GravityView_Admin_View_Field($item['label_text'], $item['field_id'], $item); |
|
| 634 | 634 | |
| 635 | 635 | } |
| 636 | 636 | } |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | |
| 648 | 648 | $entry_default_fields = array(); |
| 649 | 649 | |
| 650 | - if( in_array( $zone, array( 'directory', 'single' ) ) ) { |
|
| 650 | + if (in_array($zone, array('directory', 'single'))) { |
|
| 651 | 651 | |
| 652 | 652 | $entry_default_fields = array( |
| 653 | 653 | 'id' => array( |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | ); |
| 697 | 697 | |
| 698 | 698 | |
| 699 | - if( 'single' !== $zone) { |
|
| 699 | + if ('single' !== $zone) { |
|
| 700 | 700 | |
| 701 | 701 | $entry_default_fields['entry_link'] = array( |
| 702 | 702 | 'label' => __('Link to Entry', 'gravityview'), |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | * @param string|array $form form_ID or form object |
| 715 | 715 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
| 716 | 716 | */ |
| 717 | - return apply_filters( 'gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
| 717 | + return apply_filters('gravityview_entry_default_fields', $entry_default_fields, $form, $zone); |
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | /** |
@@ -723,25 +723,25 @@ discard block |
||
| 723 | 723 | * @param string $zone Either 'single', 'directory', 'header', 'footer' |
| 724 | 724 | * @return array fields |
| 725 | 725 | */ |
| 726 | - function get_available_fields( $form = '', $zone = NULL ) { |
|
| 726 | + function get_available_fields($form = '', $zone = NULL) { |
|
| 727 | 727 | |
| 728 | - if( empty( $form ) ) { |
|
| 729 | - do_action( 'gravityview_log_error', '[get_available_fields] $form is empty' ); |
|
| 728 | + if (empty($form)) { |
|
| 729 | + do_action('gravityview_log_error', '[get_available_fields] $form is empty'); |
|
| 730 | 730 | return array(); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | // get form fields |
| 734 | - $fields = gravityview_get_form_fields( $form, true ); |
|
| 734 | + $fields = gravityview_get_form_fields($form, true); |
|
| 735 | 735 | |
| 736 | 736 | // get meta fields ( only if form was already created ) |
| 737 | - if( !is_array( $form ) ) { |
|
| 738 | - $meta_fields = gravityview_get_entry_meta( $form ); |
|
| 737 | + if (!is_array($form)) { |
|
| 738 | + $meta_fields = gravityview_get_entry_meta($form); |
|
| 739 | 739 | } else { |
| 740 | 740 | $meta_fields = array(); |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | // get default fields |
| 744 | - $default_fields = $this->get_entry_default_fields( $form, $zone ); |
|
| 744 | + $default_fields = $this->get_entry_default_fields($form, $zone); |
|
| 745 | 745 | |
| 746 | 746 | //merge without loosing the keys |
| 747 | 747 | $fields = $fields + $meta_fields + $default_fields; |
@@ -758,11 +758,11 @@ discard block |
||
| 758 | 758 | |
| 759 | 759 | $widgets = $this->get_registered_widgets(); |
| 760 | 760 | |
| 761 | - if( !empty( $widgets ) ) { |
|
| 761 | + if (!empty($widgets)) { |
|
| 762 | 762 | |
| 763 | - foreach( $widgets as $id => $details ) { |
|
| 763 | + foreach ($widgets as $id => $details) { |
|
| 764 | 764 | |
| 765 | - echo new GravityView_Admin_View_Widget( $details['label'], $id, $details ); |
|
| 765 | + echo new GravityView_Admin_View_Widget($details['label'], $id, $details); |
|
| 766 | 766 | |
| 767 | 767 | } |
| 768 | 768 | } |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | * @filter `gravityview_register_directory_widgets` Get the list of registered widgets. Each item is used to instantiate a GravityView_Admin_View_Widget object |
| 780 | 780 | * @param array $registered_widgets Empty array |
| 781 | 781 | */ |
| 782 | - $registered_widgets = apply_filters( 'gravityview_register_directory_widgets', array() ); |
|
| 782 | + $registered_widgets = apply_filters('gravityview_register_directory_widgets', array()); |
|
| 783 | 783 | |
| 784 | 784 | return $registered_widgets; |
| 785 | 785 | } |
@@ -792,67 +792,67 @@ discard block |
||
| 792 | 792 | * @param array $values Saved objects |
| 793 | 793 | * @return void |
| 794 | 794 | */ |
| 795 | - function render_active_areas( $template_id, $type, $zone, $rows, $values ) { |
|
| 795 | + function render_active_areas($template_id, $type, $zone, $rows, $values) { |
|
| 796 | 796 | global $post; |
| 797 | 797 | |
| 798 | - if( $type === 'widget' ) { |
|
| 799 | - $button_label = __( 'Add Widget', 'gravityview' ); |
|
| 798 | + if ($type === 'widget') { |
|
| 799 | + $button_label = __('Add Widget', 'gravityview'); |
|
| 800 | 800 | } else { |
| 801 | - $button_label = __( 'Add Field', 'gravityview' ); |
|
| 801 | + $button_label = __('Add Field', 'gravityview'); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | $available_items = array(); |
| 805 | 805 | |
| 806 | 806 | // if saved values, get available fields to label everyone |
| 807 | - if( !empty( $values ) && ( !empty( $post->ID ) || !empty( $_POST['template_id'] ) ) ) { |
|
| 807 | + if (!empty($values) && (!empty($post->ID) || !empty($_POST['template_id']))) { |
|
| 808 | 808 | |
| 809 | - if( !empty( $_POST['template_id'] ) ) { |
|
| 810 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 809 | + if (!empty($_POST['template_id'])) { |
|
| 810 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
| 811 | 811 | } else { |
| 812 | - $form = gravityview_get_form_id( $post->ID ); |
|
| 812 | + $form = gravityview_get_form_id($post->ID); |
|
| 813 | 813 | } |
| 814 | 814 | |
| 815 | - if( 'field' === $type ) { |
|
| 816 | - $available_items = $this->get_available_fields( $form, $zone ); |
|
| 815 | + if ('field' === $type) { |
|
| 816 | + $available_items = $this->get_available_fields($form, $zone); |
|
| 817 | 817 | } else { |
| 818 | 818 | $available_items = $this->get_registered_widgets(); |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | - foreach( $rows as $row ) : |
|
| 824 | - foreach( $row as $col => $areas ) : |
|
| 823 | + foreach ($rows as $row) : |
|
| 824 | + foreach ($row as $col => $areas) : |
|
| 825 | 825 | $column = ($col == '2-2') ? '1-2' : $col; ?> |
| 826 | 826 | |
| 827 | - <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
|
| 827 | + <div class="gv-grid-col-<?php echo esc_attr($column); ?>"> |
|
| 828 | 828 | |
| 829 | - <?php foreach( $areas as $area ) : ?> |
|
| 829 | + <?php foreach ($areas as $area) : ?> |
|
| 830 | 830 | |
| 831 | 831 | <div class="gv-droppable-area"> |
| 832 | - <div class="active-drop active-drop-<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>"> |
|
| 832 | + <div class="active-drop active-drop-<?php echo esc_attr($type); ?>" data-areaid="<?php echo esc_attr($zone.'_'.$area['areaid']); ?>"> |
|
| 833 | 833 | |
| 834 | 834 | <?php // render saved fields |
| 835 | 835 | |
| 836 | - if( !empty( $values[ $zone .'_'. $area['areaid'] ] ) ) { |
|
| 836 | + if (!empty($values[$zone.'_'.$area['areaid']])) { |
|
| 837 | 837 | |
| 838 | - foreach( $values[ $zone .'_'. $area['areaid'] ] as $uniqid => $field ) { |
|
| 838 | + foreach ($values[$zone.'_'.$area['areaid']] as $uniqid => $field) { |
|
| 839 | 839 | |
| 840 | 840 | $input_type = NULL; |
| 841 | - $original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ; |
|
| 841 | + $original_item = isset($available_items[$field['id']]) ? $available_items[$field['id']] : false; |
|
| 842 | 842 | |
| 843 | - if( !$original_item ) { |
|
| 843 | + if (!$original_item) { |
|
| 844 | 844 | |
| 845 | - do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field )); |
|
| 845 | + do_action('gravityview_log_error', 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array('available_items' => $available_items, 'field' => $field)); |
|
| 846 | 846 | |
| 847 | 847 | $original_item = $field; |
| 848 | 848 | } else { |
| 849 | 849 | |
| 850 | - $input_type = isset( $original_item['type'] ) ? $original_item['type'] : NULL; |
|
| 850 | + $input_type = isset($original_item['type']) ? $original_item['type'] : NULL; |
|
| 851 | 851 | |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | // Field options dialog box |
| 855 | - $field_options = GravityView_Render_Settings::render_field_options( $type, $template_id, $field['id'], $original_item['label'], $zone .'_'. $area['areaid'], $input_type, $uniqid, $field, $zone, $original_item ); |
|
| 855 | + $field_options = GravityView_Render_Settings::render_field_options($type, $template_id, $field['id'], $original_item['label'], $zone.'_'.$area['areaid'], $input_type, $uniqid, $field, $zone, $original_item); |
|
| 856 | 856 | |
| 857 | 857 | $item = array( |
| 858 | 858 | 'input_type' => $input_type, |
@@ -861,16 +861,16 @@ discard block |
||
| 861 | 861 | ); |
| 862 | 862 | |
| 863 | 863 | // Merge the values with the current item to pass things like widget descriptions and original field names |
| 864 | - if( $original_item ) { |
|
| 865 | - $item = wp_parse_args( $item, $original_item ); |
|
| 864 | + if ($original_item) { |
|
| 865 | + $item = wp_parse_args($item, $original_item); |
|
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - switch( $type ) { |
|
| 868 | + switch ($type) { |
|
| 869 | 869 | case 'widget': |
| 870 | - echo new GravityView_Admin_View_Widget( $item['label'], $field['id'], $item, $field ); |
|
| 870 | + echo new GravityView_Admin_View_Widget($item['label'], $field['id'], $item, $field); |
|
| 871 | 871 | break; |
| 872 | 872 | default: |
| 873 | - echo new GravityView_Admin_View_Field( $item['label'], $field['id'], $item, $field ); |
|
| 873 | + echo new GravityView_Admin_View_Field($item['label'], $field['id'], $item, $field); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | |
@@ -880,11 +880,11 @@ discard block |
||
| 880 | 880 | |
| 881 | 881 | } // End if zone is not empty ?> |
| 882 | 882 | |
| 883 | - <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type ); ?></span> |
|
| 883 | + <span class="drop-message"><?php echo sprintf(esc_attr__('"+ %s" or drag existing %ss here.', 'gravityview'), $button_label, $type); ?></span> |
|
| 884 | 884 | </div> |
| 885 | 885 | <div class="gv-droppable-area-action"> |
| 886 | - <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr( $type ); ?>" data-areaid="<?php echo esc_attr( $zone .'_'. $area['areaid'] ); ?>" data-context="<?php echo esc_attr( $zone ); ?>"><?php echo '+ '.esc_html( $button_label ); ?></a> |
|
| 887 | - <p class="gv-droppable-area-title"><strong><?php echo esc_html( $area['title'] ); ?></strong><?php if( !empty( $area['subtitle'] ) ) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html( $area['subtitle'] ); ?></span><?php } ?></p> |
|
| 886 | + <a href="#" class="gv-add-field button-secondary" title="" data-objecttype="<?php echo esc_attr($type); ?>" data-areaid="<?php echo esc_attr($zone.'_'.$area['areaid']); ?>" data-context="<?php echo esc_attr($zone); ?>"><?php echo '+ '.esc_html($button_label); ?></a> |
|
| 887 | + <p class="gv-droppable-area-title"><strong><?php echo esc_html($area['title']); ?></strong><?php if (!empty($area['subtitle'])) { ?><span class="gv-droppable-area-subtitle"> – <?php echo esc_html($area['subtitle']); ?></span><?php } ?></p> |
|
| 888 | 888 | </div> |
| 889 | 889 | </div> |
| 890 | 890 | |
@@ -901,13 +901,13 @@ discard block |
||
| 901 | 901 | * @param string $post_id Current Post ID (view) |
| 902 | 902 | * @return string html |
| 903 | 903 | */ |
| 904 | - function render_widgets_active_areas( $template_id = '', $zone, $post_id = '' ) { |
|
| 904 | + function render_widgets_active_areas($template_id = '', $zone, $post_id = '') { |
|
| 905 | 905 | |
| 906 | 906 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
| 907 | 907 | |
| 908 | 908 | $widgets = array(); |
| 909 | - if( !empty( $post_id ) ) { |
|
| 910 | - $widgets = get_post_meta( $post_id, '_gravityview_directory_widgets', true ); |
|
| 909 | + if (!empty($post_id)) { |
|
| 910 | + $widgets = get_post_meta($post_id, '_gravityview_directory_widgets', true); |
|
| 911 | 911 | |
| 912 | 912 | } |
| 913 | 913 | |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | ?> |
| 916 | 916 | |
| 917 | 917 | <div class="gv-grid gv-grid-pad gv-grid-border" id="directory-<?php echo $zone; ?>-widgets"> |
| 918 | - <?php $this->render_active_areas( $template_id, 'widget', $zone, $default_widget_areas, $widgets ); ?> |
|
| 918 | + <?php $this->render_active_areas($template_id, 'widget', $zone, $default_widget_areas, $widgets); ?> |
|
| 919 | 919 | </div> |
| 920 | 920 | |
| 921 | 921 | <?php |
@@ -935,36 +935,36 @@ discard block |
||
| 935 | 935 | * @param string $context (default: 'single') |
| 936 | 936 | * @return string HTML of the active areas |
| 937 | 937 | */ |
| 938 | - function render_directory_active_areas( $template_id = '', $context = 'single', $post_id = '', $echo = false ) { |
|
| 938 | + function render_directory_active_areas($template_id = '', $context = 'single', $post_id = '', $echo = false) { |
|
| 939 | 939 | |
| 940 | - if( empty( $template_id ) ) { |
|
| 941 | - do_action( 'gravityview_log_debug', '[render_directory_active_areas] $template_id is empty' ); |
|
| 940 | + if (empty($template_id)) { |
|
| 941 | + do_action('gravityview_log_debug', '[render_directory_active_areas] $template_id is empty'); |
|
| 942 | 942 | return; |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | - $template_areas = apply_filters( 'gravityview_template_active_areas', array(), $template_id, $context ); |
|
| 945 | + $template_areas = apply_filters('gravityview_template_active_areas', array(), $template_id, $context); |
|
| 946 | 946 | |
| 947 | - if( empty( $template_areas ) ) { |
|
| 947 | + if (empty($template_areas)) { |
|
| 948 | 948 | |
| 949 | - do_action( 'gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id ); |
|
| 949 | + do_action('gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id); |
|
| 950 | 950 | $output = '<div>'; |
| 951 | - $output .= '<h2 class="description" style="font-size: 16px; margin:0">'. sprintf( esc_html__( 'This View is configured using the %s View type, which is disabled.', 'gravityview' ), '<em>'.$template_id.'</em>' ) .'</h2>'; |
|
| 951 | + $output .= '<h2 class="description" style="font-size: 16px; margin:0">'.sprintf(esc_html__('This View is configured using the %s View type, which is disabled.', 'gravityview'), '<em>'.$template_id.'</em>').'</h2>'; |
|
| 952 | 952 | $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">'.esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview').'</p>'; |
| 953 | 953 | $output .= '</div>'; |
| 954 | 954 | } else { |
| 955 | 955 | |
| 956 | 956 | $fields = ''; |
| 957 | - if ( ! empty( $post_id ) ) { |
|
| 958 | - $fields = gravityview_get_directory_fields( $post_id ); |
|
| 957 | + if (!empty($post_id)) { |
|
| 958 | + $fields = gravityview_get_directory_fields($post_id); |
|
| 959 | 959 | } |
| 960 | 960 | |
| 961 | 961 | ob_start(); |
| 962 | - $this->render_active_areas( $template_id, 'field', $context, $template_areas, $fields ); |
|
| 962 | + $this->render_active_areas($template_id, 'field', $context, $template_areas, $fields); |
|
| 963 | 963 | $output = ob_get_clean(); |
| 964 | 964 | |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - if( $echo ) { |
|
| 967 | + if ($echo) { |
|
| 968 | 968 | echo $output; |
| 969 | 969 | } |
| 970 | 970 | |
@@ -978,46 +978,46 @@ discard block |
||
| 978 | 978 | * @param mixed $hook |
| 979 | 979 | * @return void |
| 980 | 980 | */ |
| 981 | - static function add_scripts_and_styles( $hook ) { |
|
| 981 | + static function add_scripts_and_styles($hook) { |
|
| 982 | 982 | global $plugin_page, $pagenow; |
| 983 | 983 | |
| 984 | - $is_widgets_page = ( $pagenow === 'widgets.php' ); |
|
| 984 | + $is_widgets_page = ($pagenow === 'widgets.php'); |
|
| 985 | 985 | |
| 986 | 986 | // Add the GV font (with the Astronaut) |
| 987 | - wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version ); |
|
| 987 | + wp_enqueue_style('gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), GravityView_Plugin::version); |
|
| 988 | 988 | |
| 989 | - wp_register_script( 'gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array( 'jquery' ), GravityView_Plugin::version, true ); |
|
| 989 | + wp_register_script('gravityview-jquery-cookie', plugins_url('includes/lib/jquery-cookie/jquery_cookie.js', GRAVITYVIEW_FILE), array('jquery'), GravityView_Plugin::version, true); |
|
| 990 | 990 | |
| 991 | 991 | // Don't process any scripts below here if it's not a GravityView page. |
| 992 | - if( !gravityview_is_admin_page($hook) && !$is_widgets_page ) { return; } |
|
| 992 | + if (!gravityview_is_admin_page($hook) && !$is_widgets_page) { return; } |
|
| 993 | 993 | |
| 994 | 994 | // Only enqueue the following on single pages |
| 995 | - if( gravityview_is_admin_page($hook, 'single') || $is_widgets_page ) { |
|
| 995 | + if (gravityview_is_admin_page($hook, 'single') || $is_widgets_page) { |
|
| 996 | 996 | |
| 997 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
| 998 | - wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version ); |
|
| 997 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 998 | + wp_enqueue_style('gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), GravityView_Plugin::version); |
|
| 999 | 999 | |
| 1000 | 1000 | $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
| 1001 | 1001 | |
| 1002 | 1002 | //enqueue scripts |
| 1003 | - wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), GravityView_Plugin::version ); |
|
| 1003 | + wp_enqueue_script('gravityview_views_scripts', plugins_url('assets/js/admin-views'.$script_debug.'.js', GRAVITYVIEW_FILE), array('jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore'), GravityView_Plugin::version); |
|
| 1004 | 1004 | |
| 1005 | 1005 | wp_localize_script('gravityview_views_scripts', 'gvGlobals', array( |
| 1006 | 1006 | 'cookiepath' => COOKIEPATH, |
| 1007 | - 'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ), |
|
| 1008 | - 'label_viewname' => __( 'Enter View name here', 'gravityview' ), |
|
| 1009 | - 'label_close' => __( 'Close', 'gravityview' ), |
|
| 1010 | - 'label_cancel' => __( 'Cancel', 'gravityview' ), |
|
| 1011 | - 'label_continue' => __( 'Continue', 'gravityview' ), |
|
| 1012 | - 'label_ok' => __( 'Ok', 'gravityview' ), |
|
| 1013 | - 'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ), |
|
| 1014 | - 'loading_text' => esc_html__( 'Loading…', 'gravityview' ), |
|
| 1015 | - 'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ), |
|
| 1016 | - 'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ), |
|
| 1017 | - 'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ), |
|
| 1007 | + 'nonce' => wp_create_nonce('gravityview_ajaxviews'), |
|
| 1008 | + 'label_viewname' => __('Enter View name here', 'gravityview'), |
|
| 1009 | + 'label_close' => __('Close', 'gravityview'), |
|
| 1010 | + 'label_cancel' => __('Cancel', 'gravityview'), |
|
| 1011 | + 'label_continue' => __('Continue', 'gravityview'), |
|
| 1012 | + 'label_ok' => __('Ok', 'gravityview'), |
|
| 1013 | + 'label_publisherror' => __('Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview'), |
|
| 1014 | + 'loading_text' => esc_html__('Loading…', 'gravityview'), |
|
| 1015 | + 'loading_error' => esc_html__('There was an error loading dynamic content.', 'gravityview'), |
|
| 1016 | + 'field_loaderror' => __('Error while adding the field. Please try again or contact GravityView support.', 'gravityview'), |
|
| 1017 | + 'remove_all_fields' => __('Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview'), |
|
| 1018 | 1018 | )); |
| 1019 | 1019 | |
| 1020 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array('dashicons', 'wp-jquery-ui-dialog' ), GravityView_Plugin::version ); |
|
| 1020 | + wp_enqueue_style('gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons', 'wp-jquery-ui-dialog'), GravityView_Plugin::version); |
|
| 1021 | 1021 | |
| 1022 | 1022 | self::enqueue_gravity_forms_scripts(); |
| 1023 | 1023 | |
@@ -1035,25 +1035,25 @@ discard block |
||
| 1035 | 1035 | 'jquery-ui-autocomplete' |
| 1036 | 1036 | ); |
| 1037 | 1037 | |
| 1038 | - if ( wp_is_mobile() ) |
|
| 1038 | + if (wp_is_mobile()) |
|
| 1039 | 1039 | $scripts[] = 'jquery-touch-punch'; |
| 1040 | 1040 | |
| 1041 | 1041 | foreach ($scripts as $script) { |
| 1042 | - wp_enqueue_script( $script ); |
|
| 1042 | + wp_enqueue_script($script); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | } |
| 1045 | 1045 | |
| 1046 | - function register_no_conflict( $registered ) { |
|
| 1046 | + function register_no_conflict($registered) { |
|
| 1047 | 1047 | |
| 1048 | 1048 | $filter = current_filter(); |
| 1049 | 1049 | |
| 1050 | - if( preg_match('/script/ism', $filter ) ) { |
|
| 1051 | - $allow_scripts = array( 'jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'gravityview_views_scripts', 'gravityview-support', 'gravityview-jquery-cookie', 'gravityview_views_datepicker', |
|
| 1052 | - 'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete' ); |
|
| 1053 | - $registered = array_merge( $registered, $allow_scripts ); |
|
| 1054 | - } elseif( preg_match('/style/ism', $filter ) ) { |
|
| 1055 | - $allow_styles = array( 'dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker' ); |
|
| 1056 | - $registered = array_merge( $registered, $allow_styles ); |
|
| 1050 | + if (preg_match('/script/ism', $filter)) { |
|
| 1051 | + $allow_scripts = array('jquery-ui-core', 'jquery-ui-dialog', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'gravityview_views_scripts', 'gravityview-support', 'gravityview-jquery-cookie', 'gravityview_views_datepicker', |
|
| 1052 | + 'sack', 'gform_gravityforms', 'gform_forms', 'gform_form_admin', 'jquery-ui-autocomplete'); |
|
| 1053 | + $registered = array_merge($registered, $allow_scripts); |
|
| 1054 | + } elseif (preg_match('/style/ism', $filter)) { |
|
| 1055 | + $allow_styles = array('dashicons', 'wp-jquery-ui-dialog', 'gravityview_views_styles', 'gravityview_global', 'gravityview_views_datepicker'); |
|
| 1056 | + $registered = array_merge($registered, $allow_styles); |
|
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | 1059 | return $registered; |
@@ -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,10 +4,10 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | function __construct() { |
| 6 | 6 | |
| 7 | - if( ! is_admin() ) { return; } |
|
| 7 | + if (!is_admin()) { return; } |
|
| 8 | 8 | |
| 9 | 9 | // If Gravity Forms isn't active or compatibile, stop loading |
| 10 | - if( false === GravityView_Compatibility::is_valid() ) { |
|
| 10 | + if (false === GravityView_Compatibility::is_valid()) { |
|
| 11 | 11 | return; |
| 12 | 12 | } |
| 13 | 13 | |
@@ -22,22 +22,22 @@ discard block |
||
| 22 | 22 | private function include_required_files() { |
| 23 | 23 | |
| 24 | 24 | // Migrate Class |
| 25 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' ); |
|
| 25 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-migrate.php'); |
|
| 26 | 26 | |
| 27 | 27 | // Don't load tooltips if on Gravity Forms, otherwise it overrides translations |
| 28 | - if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) { |
|
| 29 | - require_once( GFCommon::get_base_path() . '/tooltips.php' ); |
|
| 28 | + if (class_exists('GFCommon') && class_exists('GFForms') && !GFForms::is_gravity_page()) { |
|
| 29 | + require_once(GFCommon::get_base_path().'/tooltips.php'); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php' ); |
|
| 33 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/entry-list.php' ); |
|
| 34 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
|
| 32 | + require_once(GRAVITYVIEW_DIR.'includes/admin/metaboxes/class-gravityview-admin-metaboxes.php'); |
|
| 33 | + require_once(GRAVITYVIEW_DIR.'includes/admin/entry-list.php'); |
|
| 34 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-change-entry-creator.php'); |
|
| 35 | 35 | |
| 36 | 36 | /** @since 1.15 **/ |
| 37 | - require_once( GRAVITYVIEW_DIR . 'includes/admin/class-gravityview-support-port.php' ); |
|
| 37 | + require_once(GRAVITYVIEW_DIR.'includes/admin/class-gravityview-support-port.php'); |
|
| 38 | 38 | |
| 39 | 39 | /** @since 1.6 */ |
| 40 | - require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-duplicate-view.php' ); |
|
| 40 | + require_once(GRAVITYVIEW_DIR.'includes/class-gravityview-admin-duplicate-view.php'); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,21 +47,21 @@ discard block |
||
| 47 | 47 | private function add_hooks() { |
| 48 | 48 | |
| 49 | 49 | // Filter Admin messages |
| 50 | - add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
| 51 | - add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) ); |
|
| 50 | + add_filter('post_updated_messages', array($this, 'post_updated_messages')); |
|
| 51 | + add_filter('bulk_post_updated_messages', array($this, 'post_updated_messages')); |
|
| 52 | 52 | |
| 53 | - add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) ); |
|
| 53 | + add_filter('plugin_action_links_'.plugin_basename(GRAVITYVIEW_FILE), array($this, 'plugin_action_links')); |
|
| 54 | 54 | |
| 55 | - add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 ); |
|
| 55 | + add_action('plugins_loaded', array($this, 'backend_actions'), 100); |
|
| 56 | 56 | |
| 57 | 57 | //Hooks for no-conflict functionality |
| 58 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
| 59 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
| 58 | + add_action('wp_print_scripts', array($this, 'no_conflict_scripts'), 1000); |
|
| 59 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_scripts'), 9); |
|
| 60 | 60 | |
| 61 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
| 62 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
| 63 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
| 64 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
| 61 | + add_action('wp_print_styles', array($this, 'no_conflict_styles'), 1000); |
|
| 62 | + add_action('admin_print_styles', array($this, 'no_conflict_styles'), 11); |
|
| 63 | + add_action('admin_print_footer_scripts', array($this, 'no_conflict_styles'), 1); |
|
| 64 | + add_action('admin_footer', array($this, 'no_conflict_styles'), 1); |
|
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | public function backend_actions() { |
| 75 | 75 | |
| 76 | 76 | /** @define "GRAVITYVIEW_DIR" "../" */ |
| 77 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' ); |
|
| 78 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' ); |
|
| 79 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-label.php' ); |
|
| 80 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' ); |
|
| 81 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' ); |
|
| 82 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' ); |
|
| 83 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 77 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.field.type.php'); |
|
| 78 | + include_once(GRAVITYVIEW_DIR.'includes/admin/class.render.settings.php'); |
|
| 79 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-label.php'); |
|
| 80 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-views.php'); |
|
| 81 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-welcome.php'); |
|
| 82 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-add-shortcode.php'); |
|
| 83 | + include_once(GRAVITYVIEW_DIR.'includes/class-admin-approve-entries.php'); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded |
@@ -99,19 +99,19 @@ discard block |
||
| 99 | 99 | * @param array $links Array of action links under GravityView on the plugin page |
| 100 | 100 | * @return array Action links with Settings and Support included, if the user has the appropriate caps |
| 101 | 101 | */ |
| 102 | - public static function plugin_action_links( $links ) { |
|
| 102 | + public static function plugin_action_links($links) { |
|
| 103 | 103 | |
| 104 | 104 | $actions = array(); |
| 105 | 105 | |
| 106 | - if( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
| 107 | - $actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
| 106 | + if (GVCommon::has_cap('gravityview_view_settings')) { |
|
| 107 | + $actions[] = sprintf('<a href="%s">%s</a>', admin_url('edit.php?post_type=gravityview&page=gravityview_settings'), esc_html__('Settings', 'gravityview')); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
| 111 | - $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
| 110 | + if (GVCommon::has_cap('gravityview_support_port')) { |
|
| 111 | + $actions[] = '<a href="http://docs.gravityview.co">'.esc_html__('Support', 'gravityview').'</a>'; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - return array_merge( $actions, $links ); |
|
| 114 | + return array_merge($actions, $links); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -128,70 +128,70 @@ discard block |
||
| 128 | 128 | * @param array $messages Existing messages |
| 129 | 129 | * @return array Messages with GravityView views! |
| 130 | 130 | */ |
| 131 | - function post_updated_messages( $messages, $bulk_counts = NULL ) { |
|
| 131 | + function post_updated_messages($messages, $bulk_counts = NULL) { |
|
| 132 | 132 | global $post; |
| 133 | 133 | |
| 134 | - $post_id = isset($_GET['post']) ? intval($_GET['post']) : ( is_object( $post ) && isset( $post->ID ) ? $post->ID : NULL ); |
|
| 134 | + $post_id = isset($_GET['post']) ? intval($_GET['post']) : (is_object($post) && isset($post->ID) ? $post->ID : NULL); |
|
| 135 | 135 | |
| 136 | 136 | // By default, there will only be one item being modified. |
| 137 | 137 | // When in the `bulk_post_updated_messages` filter, there will be passed a number |
| 138 | 138 | // of modified items that will override this array. |
| 139 | - $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
| 139 | + $bulk_counts = is_null($bulk_counts) ? array('updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1) : $bulk_counts; |
|
| 140 | 140 | |
| 141 | 141 | |
| 142 | 142 | // If we're starting fresh, a new form was created. |
| 143 | 143 | // We should let the user know this is the case. |
| 144 | - $start_fresh = get_post_meta( $post_id, '_gravityview_start_fresh', true ); |
|
| 144 | + $start_fresh = get_post_meta($post_id, '_gravityview_start_fresh', true); |
|
| 145 | 145 | |
| 146 | 146 | $new_form_text = ''; |
| 147 | 147 | |
| 148 | - if( !empty( $start_fresh ) ) { |
|
| 148 | + if (!empty($start_fresh)) { |
|
| 149 | 149 | |
| 150 | 150 | // Get the form that was created |
| 151 | - $connected_form = gravityview_get_form_id( $post_id ); |
|
| 151 | + $connected_form = gravityview_get_form_id($post_id); |
|
| 152 | 152 | |
| 153 | - if( !empty( $connected_form ) ) { |
|
| 154 | - $form = gravityview_get_form( $connected_form ); |
|
| 155 | - $form_name = esc_attr( $form['title'] ); |
|
| 153 | + if (!empty($connected_form)) { |
|
| 154 | + $form = gravityview_get_form($connected_form); |
|
| 155 | + $form_name = esc_attr($form['title']); |
|
| 156 | 156 | $image = self::get_floaty(); |
| 157 | - $new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>'; |
|
| 158 | - $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
| 157 | + $new_form_text .= '<h3>'.$image.sprintf(__('A new form was created for this View: "%s"', 'gravityview'), $form_name).'</h3>'; |
|
| 158 | + $new_form_text .= sprintf(__('%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
| 159 | 159 | |
| 160 | 160 | You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don’t forget to %scustomize the form settings%s. |
| 161 | - ', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&view=settings&id='.$connected_form ).'">', '</a>'); |
|
| 162 | - $new_form_text = wpautop( $new_form_text ); |
|
| 161 | + ', 'gravityview'), '<strong>', '</strong>', '<a href="'.site_url('?gf_page=preview&id='.$connected_form).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&id='.$connected_form).'">', '</a>', '<a href="'.admin_url('admin.php?page=gf_edit_forms&view=settings&id='.$connected_form).'">', '</a>'); |
|
| 162 | + $new_form_text = wpautop($new_form_text); |
|
| 163 | 163 | |
| 164 | - delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
|
| 164 | + delete_post_meta($post_id, '_gravityview_start_fresh'); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | $messages['gravityview'] = array( |
| 169 | 169 | 0 => '', // Unused. Messages start at index 1. |
| 170 | - 1 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 171 | - 2 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 172 | - 3 => __( 'View deleted.', 'gravityview' ), |
|
| 173 | - 4 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 170 | + 1 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 171 | + 2 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 172 | + 3 => __('View deleted.', 'gravityview'), |
|
| 173 | + 4 => sprintf(__('View updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 174 | 174 | /* translators: %s: date and time of the revision */ |
| 175 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
| 176 | - 6 => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
| 177 | - 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
| 178 | - 8 => __( 'View submitted.', 'gravityview' ), |
|
| 175 | + 5 => isset($_GET['revision']) ? sprintf(__('View restored to revision from %s', 'gravityview'), wp_post_revision_title((int)$_GET['revision'], false)) : false, |
|
| 176 | + 6 => sprintf(__('View published. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
| 177 | + 7 => sprintf(__('View saved. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>').$new_form_text, |
|
| 178 | + 8 => __('View submitted.', 'gravityview'), |
|
| 179 | 179 | 9 => sprintf( |
| 180 | - __( 'View scheduled for: %1$s.', 'gravityview' ), |
|
| 180 | + __('View scheduled for: %1$s.', 'gravityview'), |
|
| 181 | 181 | // translators: Publish box date format, see http://php.net/date |
| 182 | - date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
| 183 | - ) . $new_form_text, |
|
| 184 | - 10 => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
| 182 | + date_i18n(__('M j, Y @ G:i', 'gravityview'), strtotime((isset($post->post_date) ? $post->post_date : NULL))) |
|
| 183 | + ).$new_form_text, |
|
| 184 | + 10 => sprintf(__('View draft updated. %sView on website.%s', 'gravityview'), '<a href="'.get_permalink($post_id).'">', '</a>'), |
|
| 185 | 185 | |
| 186 | 186 | /** |
| 187 | 187 | * These apply to `bulk_post_updated_messages` |
| 188 | 188 | * @file wp-admin/edit.php |
| 189 | 189 | */ |
| 190 | - 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ), |
|
| 191 | - 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ), |
|
| 192 | - 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ), |
|
| 193 | - 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ), |
|
| 194 | - 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ), |
|
| 190 | + 'updated' => _n('%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview'), |
|
| 191 | + 'locked' => _n('%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview'), |
|
| 192 | + 'deleted' => _n('%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview'), |
|
| 193 | + 'trashed' => _n('%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview'), |
|
| 194 | + 'untrashed' => _n('%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview'), |
|
| 195 | 195 | ); |
| 196 | 196 | |
| 197 | 197 | return $messages; |
@@ -204,13 +204,13 @@ discard block |
||
| 204 | 204 | function no_conflict_scripts() { |
| 205 | 205 | global $wp_scripts; |
| 206 | 206 | |
| 207 | - if( ! gravityview_is_admin_page() ) { |
|
| 207 | + if (!gravityview_is_admin_page()) { |
|
| 208 | 208 | return; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
| 212 | 212 | |
| 213 | - if( empty( $no_conflict_mode ) ) { |
|
| 213 | + if (empty($no_conflict_mode)) { |
|
| 214 | 214 | return; |
| 215 | 215 | } |
| 216 | 216 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | 'jquery-ui-accordion', |
| 251 | 251 | ); |
| 252 | 252 | |
| 253 | - $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
|
| 253 | + $this->remove_conflicts($wp_scripts, $wp_allowed_scripts, 'scripts'); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -260,16 +260,16 @@ discard block |
||
| 260 | 260 | function no_conflict_styles() { |
| 261 | 261 | global $wp_styles; |
| 262 | 262 | |
| 263 | - if( ! gravityview_is_admin_page() ) { |
|
| 263 | + if (!gravityview_is_admin_page()) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // Dequeue other jQuery styles even if no-conflict is off. |
| 268 | 268 | // Terrible-looking tabs help no one. |
| 269 | - if( !empty( $wp_styles->registered ) ) { |
|
| 269 | + if (!empty($wp_styles->registered)) { |
|
| 270 | 270 | foreach ($wp_styles->registered as $key => $style) { |
| 271 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
| 272 | - wp_dequeue_style( $key ); |
|
| 271 | + if (preg_match('/^(?:wp\-)?jquery/ism', $key)) { |
|
| 272 | + wp_dequeue_style($key); |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | } |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
| 278 | 278 | |
| 279 | 279 | // If no conflict is off, jQuery will suffice. |
| 280 | - if( empty( $no_conflict_mode ) ) { |
|
| 280 | + if (empty($no_conflict_mode)) { |
|
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | 'jquery-qtip.js', |
| 300 | 300 | ); |
| 301 | 301 | |
| 302 | - $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
|
| 302 | + $this->remove_conflicts($wp_styles, $wp_allowed_styles, 'styles'); |
|
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
@@ -315,31 +315,31 @@ discard block |
||
| 315 | 315 | * @param string $type Either 'styles' or 'scripts' |
| 316 | 316 | * @return void |
| 317 | 317 | */ |
| 318 | - private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
|
| 318 | + private function remove_conflicts(&$wp_objects, $required_objects, $type = 'scripts') { |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
| 322 | 322 | * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
| 323 | 323 | * @param array $required_objects |
| 324 | 324 | */ |
| 325 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
| 325 | + $required_objects = apply_filters("gravityview_noconflict_{$type}", $required_objects); |
|
| 326 | 326 | |
| 327 | 327 | //reset queue |
| 328 | 328 | $queue = array(); |
| 329 | - foreach( $wp_objects->queue as $object ) { |
|
| 330 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
| 329 | + foreach ($wp_objects->queue as $object) { |
|
| 330 | + if (in_array($object, $required_objects) || preg_match('/gravityview|gf_|gravityforms/ism', $object)) { |
|
| 331 | 331 | $queue[] = $object; |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | $wp_objects->queue = $queue; |
| 335 | 335 | |
| 336 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
| 336 | + $required_objects = $this->add_script_dependencies($wp_objects->registered, $required_objects); |
|
| 337 | 337 | |
| 338 | 338 | //unregistering scripts |
| 339 | 339 | $registered = array(); |
| 340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
| 341 | - if( in_array( $handle, $required_objects ) ){ |
|
| 342 | - $registered[ $handle ] = $script_registration; |
|
| 340 | + foreach ($wp_objects->registered as $handle => $script_registration) { |
|
| 341 | + if (in_array($handle, $required_objects)) { |
|
| 342 | + $registered[$handle] = $script_registration; |
|
| 343 | 343 | } |
| 344 | 344 | } |
| 345 | 345 | $wp_objects->registered = $registered; |
@@ -356,16 +356,16 @@ discard block |
||
| 356 | 356 | //gets all dependent scripts linked to the $scripts array passed |
| 357 | 357 | do { |
| 358 | 358 | $dependents = array(); |
| 359 | - foreach ( $scripts as $script ) { |
|
| 360 | - $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
|
| 361 | - foreach ( $deps as $dep ) { |
|
| 362 | - if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
|
| 359 | + foreach ($scripts as $script) { |
|
| 360 | + $deps = isset($registered[$script]) && is_array($registered[$script]->deps) ? $registered[$script]->deps : array(); |
|
| 361 | + foreach ($deps as $dep) { |
|
| 362 | + if (!in_array($dep, $scripts) && !in_array($dep, $dependents)) { |
|
| 363 | 363 | $dependents[] = $dep; |
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | } |
| 367 | - $scripts = array_merge( $scripts, $dependents ); |
|
| 368 | - } while ( ! empty( $dependents ) ); |
|
| 367 | + $scripts = array_merge($scripts, $dependents); |
|
| 368 | + } while (!empty($dependents)); |
|
| 369 | 369 | |
| 370 | 370 | return $scripts; |
| 371 | 371 | } |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | * @deprecated since 1.12 |
| 386 | 386 | * @param array $notice Array with `class` and `message` keys. The message is not escaped. |
| 387 | 387 | */ |
| 388 | - public static function add_notice( $notice = array() ) { |
|
| 389 | - GravityView_Admin_Notices::add_notice( $notice ); |
|
| 388 | + public static function add_notice($notice = array()) { |
|
| 389 | + GravityView_Admin_Notices::add_notice($notice); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
@@ -408,8 +408,8 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
| 410 | 410 | */ |
| 411 | - static function get_plugin_status( $location = '' ) { |
|
| 412 | - return GravityView_Compatibility::get_plugin_status( $location ); |
|
| 411 | + static function get_plugin_status($location = '') { |
|
| 412 | + return GravityView_Compatibility::get_plugin_status($location); |
|
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | /** |
@@ -421,10 +421,10 @@ discard block |
||
| 421 | 421 | * |
| 422 | 422 | * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`) |
| 423 | 423 | */ |
| 424 | - static function is_admin_page( $hook = '', $page = NULL ) { |
|
| 424 | + static function is_admin_page($hook = '', $page = NULL) { |
|
| 425 | 425 | global $current_screen, $plugin_page, $pagenow, $post; |
| 426 | 426 | |
| 427 | - if( ! is_admin() ) { return false; } |
|
| 427 | + if (!is_admin()) { return false; } |
|
| 428 | 428 | |
| 429 | 429 | $is_page = false; |
| 430 | 430 | |
@@ -432,21 +432,21 @@ discard block |
||
| 432 | 432 | |
| 433 | 433 | $is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview'); |
| 434 | 434 | |
| 435 | - $is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings'; |
|
| 435 | + $is_gv_settings_get = isset($_GET['page']) && $_GET['page'] === 'gravityview_settings'; |
|
| 436 | 436 | |
| 437 | - if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) { |
|
| 438 | - $gv_post = get_post( intval( $_GET['post'] ) ); |
|
| 437 | + if (empty($post) && $pagenow === 'post.php' && !empty($_GET['post'])) { |
|
| 438 | + $gv_post = get_post(intval($_GET['post'])); |
|
| 439 | 439 | $is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview'); |
| 440 | 440 | } else { |
| 441 | 441 | $is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview'); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
| 444 | + if ($is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get) { |
|
| 445 | 445 | |
| 446 | 446 | // $_GET `post_type` variable |
| 447 | - if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) { |
|
| 447 | + if (in_array($pagenow, array('post.php', 'post-new.php'))) { |
|
| 448 | 448 | $is_page = 'single'; |
| 449 | - } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) { |
|
| 449 | + } else if (in_array($plugin_page, array('gravityview_settings', 'gravityview_page_gravityview_settings')) || (!empty($_GET['page']) && $_GET['page'] === 'gravityview_settings')) { |
|
| 450 | 450 | $is_page = 'settings'; |
| 451 | 451 | } else { |
| 452 | 452 | $is_page = 'views'; |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | * @param[in,out] string|bool $is_page If false, no. If string, the name of the page (`single`, `settings`, or `views`) |
| 459 | 459 | * @param[in] string $hook The name of the page to check against. Is passed to the method. |
| 460 | 460 | */ |
| 461 | - $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook ); |
|
| 461 | + $is_page = apply_filters('gravityview_is_admin_page', $is_page, $hook); |
|
| 462 | 462 | |
| 463 | 463 | // If the current page is the same as the compared page |
| 464 | - if( !empty( $page ) ) { |
|
| 464 | + if (!empty($page)) { |
|
| 465 | 465 | return $is_page === $page; |
| 466 | 466 | } |
| 467 | 467 | |
@@ -473,5 +473,5 @@ discard block |
||
| 473 | 473 | new GravityView_Admin; |
| 474 | 474 | |
| 475 | 475 | function gravityview_is_admin_page($hook = '', $page = NULL) { |
| 476 | - return GravityView_Admin::is_admin_page( $hook, $page ); |
|
| 476 | + return GravityView_Admin::is_admin_page($hook, $page); |
|
| 477 | 477 | } |
@@ -5,21 +5,21 @@ discard block |
||
| 5 | 5 | function __construct() { |
| 6 | 6 | |
| 7 | 7 | //get field options |
| 8 | - add_action( 'wp_ajax_gv_field_options', array( $this, 'get_field_options' ) ); |
|
| 8 | + add_action('wp_ajax_gv_field_options', array($this, 'get_field_options')); |
|
| 9 | 9 | |
| 10 | 10 | // get available fields |
| 11 | - add_action( 'wp_ajax_gv_available_fields', array( $this, 'get_available_fields_html' ) ); |
|
| 11 | + add_action('wp_ajax_gv_available_fields', array($this, 'get_available_fields_html')); |
|
| 12 | 12 | |
| 13 | 13 | // get active areas |
| 14 | - add_action( 'wp_ajax_gv_get_active_areas', array( $this, 'get_active_areas' ) ); |
|
| 14 | + add_action('wp_ajax_gv_get_active_areas', array($this, 'get_active_areas')); |
|
| 15 | 15 | |
| 16 | 16 | // get preset fields |
| 17 | - add_action( 'wp_ajax_gv_get_preset_fields', array( $this, 'get_preset_fields_config' ) ); |
|
| 17 | + add_action('wp_ajax_gv_get_preset_fields', array($this, 'get_preset_fields_config')); |
|
| 18 | 18 | |
| 19 | 19 | // get preset fields |
| 20 | - add_action( 'wp_ajax_gv_set_preset_form', array( $this, 'create_preset_form' ) ); |
|
| 20 | + add_action('wp_ajax_gv_set_preset_form', array($this, 'create_preset_form')); |
|
| 21 | 21 | |
| 22 | - add_action( 'wp_ajax_gv_sortable_fields_form', array( $this, 'get_sortable_fields' ) ); |
|
| 22 | + add_action('wp_ajax_gv_sortable_fields_form', array($this, 'get_sortable_fields')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool |
| 32 | 32 | */ |
| 33 | - private function _exit( $mixed = NULL ) { |
|
| 33 | + private function _exit($mixed = NULL) { |
|
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * Don't exit if we're running test suite. |
| 37 | 37 | * @since 1.15 |
| 38 | 38 | */ |
| 39 | - if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) { |
|
| 39 | + if (defined('DOING_GRAVITYVIEW_TESTS') && DOING_GRAVITYVIEW_TESTS) { |
|
| 40 | 40 | return $mixed; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - exit( $mixed ); |
|
| 43 | + exit($mixed); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** -------- AJAX ---------- */ |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | 52 | function check_ajax_nonce() { |
| 53 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) { |
|
| 54 | - $this->_exit( false ); |
|
| 53 | + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'gravityview_ajaxviews')) { |
|
| 54 | + $this->_exit(false); |
|
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
@@ -67,20 +67,20 @@ discard block |
||
| 67 | 67 | //check nonce |
| 68 | 68 | $this->check_ajax_nonce(); |
| 69 | 69 | |
| 70 | - $context = isset($_POST['context']) ? esc_attr( $_POST['context'] ) : 'directory'; |
|
| 70 | + $context = isset($_POST['context']) ? esc_attr($_POST['context']) : 'directory'; |
|
| 71 | 71 | |
| 72 | 72 | // If Form was changed, JS sends form ID, if start fresh, JS sends template_id |
| 73 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 74 | - do_action( 'gravityview_render_available_fields', (int) $_POST['form_id'], $context ); |
|
| 73 | + if (!empty($_POST['form_id'])) { |
|
| 74 | + do_action('gravityview_render_available_fields', (int)$_POST['form_id'], $context); |
|
| 75 | 75 | $this->_exit(); |
| 76 | - } elseif( !empty( $_POST['template_id'] ) ) { |
|
| 77 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 78 | - do_action( 'gravityview_render_available_fields', $form, $context ); |
|
| 76 | + } elseif (!empty($_POST['template_id'])) { |
|
| 77 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
| 78 | + do_action('gravityview_render_available_fields', $form, $context); |
|
| 79 | 79 | $this->_exit(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | //if everything fails.. |
| 83 | - $this->_exit( false ); |
|
| 83 | + $this->_exit(false); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | |
@@ -94,21 +94,21 @@ discard block |
||
| 94 | 94 | function get_active_areas() { |
| 95 | 95 | $this->check_ajax_nonce(); |
| 96 | 96 | |
| 97 | - if( empty( $_POST['template_id'] ) ) { |
|
| 98 | - $this->_exit( false ); |
|
| 97 | + if (empty($_POST['template_id'])) { |
|
| 98 | + $this->_exit(false); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | ob_start(); |
| 102 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true ); |
|
| 102 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true); |
|
| 103 | 103 | $response['directory'] = ob_get_clean(); |
| 104 | 104 | |
| 105 | 105 | ob_start(); |
| 106 | - do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true ); |
|
| 106 | + do_action('gravityview_render_directory_active_areas', $_POST['template_id'], 'single', '', true); |
|
| 107 | 107 | $response['single'] = ob_get_clean(); |
| 108 | 108 | |
| 109 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
| 109 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
| 110 | 110 | |
| 111 | - $this->_exit( json_encode( $response ) ); |
|
| 111 | + $this->_exit(json_encode($response)); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -119,49 +119,49 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $this->check_ajax_nonce(); |
| 121 | 121 | |
| 122 | - if( empty( $_POST['template_id'] ) ) { |
|
| 123 | - $this->_exit( false ); |
|
| 122 | + if (empty($_POST['template_id'])) { |
|
| 123 | + $this->_exit(false); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // get the fields xml config file for this specific preset |
| 127 | - $preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] ); |
|
| 127 | + $preset_fields_path = apply_filters('gravityview_template_fieldsxml', array(), $_POST['template_id']); |
|
| 128 | 128 | // import fields |
| 129 | - if( !empty( $preset_fields_path ) ) { |
|
| 130 | - $presets = $this->import_fields( $preset_fields_path ); |
|
| 129 | + if (!empty($preset_fields_path)) { |
|
| 130 | + $presets = $this->import_fields($preset_fields_path); |
|
| 131 | 131 | } else { |
| 132 | - $presets = array( 'widgets' => array(), 'fields' => array() ); |
|
| 132 | + $presets = array('widgets' => array(), 'fields' => array()); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $template_id = esc_attr( $_POST['template_id'] ); |
|
| 135 | + $template_id = esc_attr($_POST['template_id']); |
|
| 136 | 136 | |
| 137 | 137 | // template areas |
| 138 | - $template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' ); |
|
| 139 | - $template_areas_single = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'single' ); |
|
| 138 | + $template_areas_directory = apply_filters('gravityview_template_active_areas', array(), $template_id, 'directory'); |
|
| 139 | + $template_areas_single = apply_filters('gravityview_template_active_areas', array(), $template_id, 'single'); |
|
| 140 | 140 | |
| 141 | 141 | // widget areas |
| 142 | 142 | $default_widget_areas = GravityView_Plugin::get_default_widget_areas(); |
| 143 | 143 | |
| 144 | 144 | ob_start(); |
| 145 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] ); |
|
| 145 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets']); |
|
| 146 | 146 | $response['header'] = ob_get_clean(); |
| 147 | 147 | |
| 148 | 148 | ob_start(); |
| 149 | - do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] ); |
|
| 149 | + do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets']); |
|
| 150 | 150 | $response['footer'] = ob_get_clean(); |
| 151 | 151 | |
| 152 | 152 | ob_start(); |
| 153 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] ); |
|
| 153 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields']); |
|
| 154 | 154 | $response['directory'] = ob_get_clean(); |
| 155 | 155 | |
| 156 | 156 | ob_start(); |
| 157 | - do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] ); |
|
| 157 | + do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields']); |
|
| 158 | 158 | $response['single'] = ob_get_clean(); |
| 159 | 159 | |
| 160 | - $response = array_map( 'gravityview_strip_whitespace', $response ); |
|
| 160 | + $response = array_map('gravityview_strip_whitespace', $response); |
|
| 161 | 161 | |
| 162 | - do_action( 'gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response ); |
|
| 162 | + do_action('gravityview_log_debug', '[get_preset_fields_config] AJAX Response', $response); |
|
| 163 | 163 | |
| 164 | - $this->_exit( json_encode( $response ) ); |
|
| 164 | + $this->_exit(json_encode($response)); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -173,26 +173,26 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | $this->check_ajax_nonce(); |
| 175 | 175 | |
| 176 | - if( empty( $_POST['template_id'] ) ) { |
|
| 177 | - do_action( 'gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.' ); |
|
| 178 | - $this->_exit( false ); |
|
| 176 | + if (empty($_POST['template_id'])) { |
|
| 177 | + do_action('gravityview_log_error', '[create_preset_form] Cannot create preset form; the template_id is empty.'); |
|
| 178 | + $this->_exit(false); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // get the xml for this specific template_id |
| 182 | - $preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] ); |
|
| 182 | + $preset_form_xml_path = apply_filters('gravityview_template_formxml', '', $_POST['template_id']); |
|
| 183 | 183 | |
| 184 | 184 | // import form |
| 185 | - $form = $this->import_form( $preset_form_xml_path ); |
|
| 185 | + $form = $this->import_form($preset_form_xml_path); |
|
| 186 | 186 | |
| 187 | 187 | // get the form ID |
| 188 | - if( false === $form ) { |
|
| 188 | + if (false === $form) { |
|
| 189 | 189 | // send error to user |
| 190 | - do_action( 'gravityview_log_error', '[create_preset_form] Error importing form for template id: ' . (int) $_POST['template_id'] ); |
|
| 190 | + do_action('gravityview_log_error', '[create_preset_form] Error importing form for template id: '.(int)$_POST['template_id']); |
|
| 191 | 191 | |
| 192 | - $this->_exit( false ); |
|
| 192 | + $this->_exit(false); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - $this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' ); |
|
| 195 | + $this->_exit('<option value="'.esc_attr($form['id']).'" selected="selected">'.esc_html($form['title']).'</option>'); |
|
| 196 | 196 | |
| 197 | 197 | } |
| 198 | 198 | |
@@ -202,24 +202,24 @@ discard block |
||
| 202 | 202 | * @param string $xml_or_json_path Path to form XML or JSON file |
| 203 | 203 | * @return int|bool Imported form ID or false |
| 204 | 204 | */ |
| 205 | - function import_form( $xml_or_json_path = '' ) { |
|
| 205 | + function import_form($xml_or_json_path = '') { |
|
| 206 | 206 | |
| 207 | - do_action( 'gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path ); |
|
| 207 | + do_action('gravityview_log_debug', '[import_form] Import Preset Form. (File)', $xml_or_json_path); |
|
| 208 | 208 | |
| 209 | - if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) { |
|
| 210 | - do_action( 'gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path ); |
|
| 209 | + if (empty($xml_or_json_path) || !class_exists('GFExport') || !file_exists($xml_or_json_path)) { |
|
| 210 | + do_action('gravityview_log_error', '[import_form] Class GFExport or file not found. file: ', $xml_or_json_path); |
|
| 211 | 211 | return false; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // import form |
| 215 | 215 | $forms = ''; |
| 216 | - $count = GFExport::import_file( $xml_or_json_path, $forms ); |
|
| 216 | + $count = GFExport::import_file($xml_or_json_path, $forms); |
|
| 217 | 217 | |
| 218 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Result)', $count ); |
|
| 219 | - do_action( 'gravityview_log_debug', '[import_form] Importing form (Form) ', $forms ); |
|
| 218 | + do_action('gravityview_log_debug', '[import_form] Importing form (Result)', $count); |
|
| 219 | + do_action('gravityview_log_debug', '[import_form] Importing form (Form) ', $forms); |
|
| 220 | 220 | |
| 221 | - if( $count != 1 || empty( $forms[0]['id'] ) ) { |
|
| 222 | - do_action( 'gravityview_log_error', '[import_form] Form Import Failed!' ); |
|
| 221 | + if ($count != 1 || empty($forms[0]['id'])) { |
|
| 222 | + do_action('gravityview_log_error', '[import_form] Form Import Failed!'); |
|
| 223 | 223 | return false; |
| 224 | 224 | } |
| 225 | 225 | |
@@ -238,26 +238,26 @@ discard block |
||
| 238 | 238 | function get_field_options() { |
| 239 | 239 | $this->check_ajax_nonce(); |
| 240 | 240 | |
| 241 | - if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) { |
|
| 242 | - do_action( 'gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. ' ); |
|
| 243 | - $this->_exit( false ); |
|
| 241 | + if (empty($_POST['template']) || empty($_POST['area']) || empty($_POST['field_id']) || empty($_POST['field_type'])) { |
|
| 242 | + do_action('gravityview_log_error', '[get_field_options] Required fields were not set in the $_POST request. '); |
|
| 243 | + $this->_exit(false); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | // Fix apostrophes added by JSON response |
| 247 | - $_post = array_map( 'stripslashes_deep', $_POST ); |
|
| 247 | + $_post = array_map('stripslashes_deep', $_POST); |
|
| 248 | 248 | |
| 249 | 249 | // Sanitize |
| 250 | - $_post = array_map( 'esc_attr', $_post ); |
|
| 250 | + $_post = array_map('esc_attr', $_post); |
|
| 251 | 251 | |
| 252 | 252 | // The GF type of field: `product`, `name`, `creditcard`, `id`, `text` |
| 253 | - $input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL; |
|
| 254 | - $context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL; |
|
| 253 | + $input_type = isset($_post['input_type']) ? esc_attr($_post['input_type']) : NULL; |
|
| 254 | + $context = isset($_post['context']) ? esc_attr($_post['context']) : NULL; |
|
| 255 | 255 | |
| 256 | - $response = GravityView_Render_Settings::render_field_options( $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context ); |
|
| 256 | + $response = GravityView_Render_Settings::render_field_options($_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context); |
|
| 257 | 257 | |
| 258 | - $response = gravityview_strip_whitespace( $response ); |
|
| 258 | + $response = gravityview_strip_whitespace($response); |
|
| 259 | 259 | |
| 260 | - $this->_exit( $response ); |
|
| 260 | + $this->_exit($response); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -274,23 +274,23 @@ discard block |
||
| 274 | 274 | $form = ''; |
| 275 | 275 | |
| 276 | 276 | // if form id is set, use it, else, get form from preset |
| 277 | - if( !empty( $_POST['form_id'] ) ) { |
|
| 277 | + if (!empty($_POST['form_id'])) { |
|
| 278 | 278 | |
| 279 | - $form = (int) $_POST['form_id']; |
|
| 279 | + $form = (int)$_POST['form_id']; |
|
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | // get form from preset |
| 283 | - elseif( !empty( $_POST['template_id'] ) ) { |
|
| 283 | + elseif (!empty($_POST['template_id'])) { |
|
| 284 | 284 | |
| 285 | - $form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] ); |
|
| 285 | + $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); |
|
| 286 | 286 | |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $response = gravityview_get_sortable_fields( $form ); |
|
| 289 | + $response = gravityview_get_sortable_fields($form); |
|
| 290 | 290 | |
| 291 | - $response = gravityview_strip_whitespace( $response ); |
|
| 291 | + $response = gravityview_strip_whitespace($response); |
|
| 292 | 292 | |
| 293 | - $this->_exit( $response ); |
|
| 293 | + $this->_exit($response); |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | /** |
@@ -298,35 +298,35 @@ discard block |
||
| 298 | 298 | * @param string $template_id Preset template |
| 299 | 299 | * |
| 300 | 300 | */ |
| 301 | - static function pre_get_form_fields( $template_id = '') { |
|
| 301 | + static function pre_get_form_fields($template_id = '') { |
|
| 302 | 302 | |
| 303 | - if( empty( $template_id ) ) { |
|
| 304 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Template ID not set.' ); |
|
| 303 | + if (empty($template_id)) { |
|
| 304 | + do_action('gravityview_log_error', __METHOD__.' - Template ID not set.'); |
|
| 305 | 305 | return false; |
| 306 | 306 | } else { |
| 307 | - $form_file = apply_filters( 'gravityview_template_formxml', '', $template_id ); |
|
| 308 | - if( !file_exists( $form_file ) ) { |
|
| 309 | - do_action( 'gravityview_log_error', __METHOD__ . ' - Importing Form Fields for preset ['. $template_id .']. File not found. file: ' . $form_file ); |
|
| 307 | + $form_file = apply_filters('gravityview_template_formxml', '', $template_id); |
|
| 308 | + if (!file_exists($form_file)) { |
|
| 309 | + do_action('gravityview_log_error', __METHOD__.' - Importing Form Fields for preset ['.$template_id.']. File not found. file: '.$form_file); |
|
| 310 | 310 | return false; |
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | // Load xml parser (from GravityForms) |
| 315 | - if( class_exists( 'GFCommon' ) ) { |
|
| 316 | - $xml_parser = GFCommon::get_base_path() . '/xml.php'; |
|
| 315 | + if (class_exists('GFCommon')) { |
|
| 316 | + $xml_parser = GFCommon::get_base_path().'/xml.php'; |
|
| 317 | 317 | } else { |
| 318 | - $xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php'; |
|
| 318 | + $xml_parser = trailingslashit(WP_PLUGIN_DIR).'gravityforms/xml.php'; |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if( file_exists( $xml_parser ) ) { |
|
| 322 | - require_once( $xml_parser ); |
|
| 321 | + if (file_exists($xml_parser)) { |
|
| 322 | + require_once($xml_parser); |
|
| 323 | 323 | } else { |
| 324 | - do_action( 'gravityview_log_debug', __METHOD__ . ' - Gravity Forms XML Parser not found.', $xml_parser ); |
|
| 324 | + do_action('gravityview_log_debug', __METHOD__.' - Gravity Forms XML Parser not found.', $xml_parser); |
|
| 325 | 325 | return false; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // load file |
| 329 | - $xmlstr = file_get_contents( $form_file ); |
|
| 329 | + $xmlstr = file_get_contents($form_file); |
|
| 330 | 330 | |
| 331 | 331 | $options = array( |
| 332 | 332 | "page" => array("unserialize_as_array" => true), |
@@ -345,21 +345,21 @@ discard block |
||
| 345 | 345 | $xml = new RGXML($options); |
| 346 | 346 | $forms = $xml->unserialize($xmlstr); |
| 347 | 347 | |
| 348 | - if( !$forms ) { |
|
| 349 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. Error importing file. (File)', $form_file ); |
|
| 348 | + if (!$forms) { |
|
| 349 | + do_action('gravityview_log_error', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. Error importing file. (File)', $form_file); |
|
| 350 | 350 | return false; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - if( !empty( $forms[0] ) && is_array( $forms[0] ) ) { |
|
| 353 | + if (!empty($forms[0]) && is_array($forms[0])) { |
|
| 354 | 354 | $form = $forms[0]; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | - if( empty( $form ) ) { |
|
| 358 | - do_action( 'gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms ); |
|
| 357 | + if (empty($form)) { |
|
| 358 | + do_action('gravityview_log_error', '[pre_get_available_fields] $form not set.', $forms); |
|
| 359 | 359 | return false; |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - do_action( 'gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['. $template_id .']. (Form)', $form ); |
|
| 362 | + do_action('gravityview_log_debug', '[pre_get_available_fields] Importing Form Fields for preset ['.$template_id.']. (Form)', $form); |
|
| 363 | 363 | |
| 364 | 364 | return $form; |
| 365 | 365 | |
@@ -371,46 +371,46 @@ discard block |
||
| 371 | 371 | * @param string $file path to file |
| 372 | 372 | * @return array Fields config array (unserialized) |
| 373 | 373 | */ |
| 374 | - function import_fields( $file ) { |
|
| 374 | + function import_fields($file) { |
|
| 375 | 375 | |
| 376 | - if( empty( $file ) || !file_exists( $file ) ) { |
|
| 377 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file ); |
|
| 376 | + if (empty($file) || !file_exists($file)) { |
|
| 377 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields. File not found. (File)', $file); |
|
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if( !class_exists('WXR_Parser') ) { |
|
| 382 | - include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php'; |
|
| 381 | + if (!class_exists('WXR_Parser')) { |
|
| 382 | + include_once GRAVITYVIEW_DIR.'includes/lib/xml-parsers/parsers.php'; |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | $parser = new WXR_Parser(); |
| 386 | - $presets = $parser->parse( $file ); |
|
| 386 | + $presets = $parser->parse($file); |
|
| 387 | 387 | |
| 388 | - if(is_wp_error( $presets )) { |
|
| 389 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets ); |
|
| 388 | + if (is_wp_error($presets)) { |
|
| 389 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Threw WP_Error.', $presets); |
|
| 390 | 390 | return false; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) { |
|
| 394 | - do_action( 'gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file ); |
|
| 393 | + if (empty($presets['posts'][0]['postmeta']) && !is_array($presets['posts'][0]['postmeta'])) { |
|
| 394 | + do_action('gravityview_log_error', '[import_fields] Importing Preset Fields failed. Meta not found in file.', $file); |
|
| 395 | 395 | return false; |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | - do_action( 'gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta'] ); |
|
| 398 | + do_action('gravityview_log_debug', '[import_fields] postmeta', $presets['posts'][0]['postmeta']); |
|
| 399 | 399 | |
| 400 | 400 | $fields = $widgets = array(); |
| 401 | - foreach( $presets['posts'][0]['postmeta'] as $meta ) { |
|
| 401 | + foreach ($presets['posts'][0]['postmeta'] as $meta) { |
|
| 402 | 402 | switch ($meta['key']) { |
| 403 | 403 | case '_gravityview_directory_fields': |
| 404 | - $fields = maybe_unserialize( $meta['value'] ); |
|
| 404 | + $fields = maybe_unserialize($meta['value']); |
|
| 405 | 405 | break; |
| 406 | 406 | case '_gravityview_directory_widgets': |
| 407 | - $widgets = maybe_unserialize( $meta['value'] ); |
|
| 407 | + $widgets = maybe_unserialize($meta['value']); |
|
| 408 | 408 | break; |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields ); |
|
| 413 | - do_action( 'gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets ); |
|
| 412 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Fields)', $fields); |
|
| 413 | + do_action('gravityview_log_debug', '[import_fields] Imported Preset (Widgets)', $widgets); |
|
| 414 | 414 | |
| 415 | 415 | return array( |
| 416 | 416 | 'fields' => $fields, |
@@ -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 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | /** If this file is called directly, abort. */ |
| 4 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 4 | +if (!defined('ABSPATH')) { |
|
| 5 | 5 | die; |
| 6 | 6 | } |
| 7 | 7 | |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @param null $passed_post |
| 17 | 17 | */ |
| 18 | - private function __construct( $passed_post = NULL ) { |
|
| 18 | + private function __construct($passed_post = NULL) { |
|
| 19 | 19 | |
| 20 | - if( !empty( $passed_post ) ) { |
|
| 20 | + if (!empty($passed_post)) { |
|
| 21 | 21 | |
| 22 | - $id_or_id_array = $this->maybe_get_view_id( $passed_post ); |
|
| 22 | + $id_or_id_array = $this->maybe_get_view_id($passed_post); |
|
| 23 | 23 | |
| 24 | - if( !empty( $id_or_id_array ) ) { |
|
| 25 | - $this->add_view( $id_or_id_array ); |
|
| 24 | + if (!empty($id_or_id_array)) { |
|
| 25 | + $this->add_view($id_or_id_array); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public function has_multiple_views() { |
| 35 | 35 | |
| 36 | 36 | //multiple views |
| 37 | - return count( $this->get_views() ) > 1 ? true : false; |
|
| 37 | + return count($this->get_views()) > 1 ? true : false; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
@@ -52,37 +52,37 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return int|null|array ID of the View. If there are multiple views in the content, array of IDs parsed. |
| 54 | 54 | */ |
| 55 | - public function maybe_get_view_id( $passed_post ) { |
|
| 55 | + public function maybe_get_view_id($passed_post) { |
|
| 56 | 56 | |
| 57 | 57 | $ids = array(); |
| 58 | 58 | |
| 59 | - if( ! empty( $passed_post ) ) { |
|
| 59 | + if (!empty($passed_post)) { |
|
| 60 | 60 | |
| 61 | - if( is_numeric( $passed_post ) ) { |
|
| 62 | - $passed_post = get_post( $passed_post ); |
|
| 61 | + if (is_numeric($passed_post)) { |
|
| 62 | + $passed_post = get_post($passed_post); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Convert WP_Posts into WP_Posts[] array |
| 66 | - if( $passed_post instanceof WP_Post ) { |
|
| 67 | - $passed_post = array( $passed_post ); |
|
| 66 | + if ($passed_post instanceof WP_Post) { |
|
| 67 | + $passed_post = array($passed_post); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if( is_array( $passed_post ) ) { |
|
| 70 | + if (is_array($passed_post)) { |
|
| 71 | 71 | |
| 72 | - foreach ( $passed_post as &$post) { |
|
| 73 | - if( ( get_post_type( $post ) === 'gravityview' ) ) { |
|
| 72 | + foreach ($passed_post as &$post) { |
|
| 73 | + if ((get_post_type($post) === 'gravityview')) { |
|
| 74 | 74 | $ids[] = $post->ID; |
| 75 | - } else{ |
|
| 75 | + } else { |
|
| 76 | 76 | // Parse the Post Content |
| 77 | - $id = $this->parse_post_content( $post->post_content ); |
|
| 78 | - if( $id ) { |
|
| 79 | - $ids = array_merge( $ids, (array) $id ); |
|
| 77 | + $id = $this->parse_post_content($post->post_content); |
|
| 78 | + if ($id) { |
|
| 79 | + $ids = array_merge($ids, (array)$id); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | // Parse the Post Meta |
| 83 | - $id = $this->parse_post_meta( $post->ID ); |
|
| 84 | - if( $id ) { |
|
| 85 | - $ids = array_merge( $ids, (array) $id ); |
|
| 83 | + $id = $this->parse_post_meta($post->ID); |
|
| 84 | + if ($id) { |
|
| 85 | + $ids = array_merge($ids, (array)$id); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -90,33 +90,33 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | } else { |
| 92 | 92 | |
| 93 | - if ( is_string( $passed_post ) ) { |
|
| 93 | + if (is_string($passed_post)) { |
|
| 94 | 94 | |
| 95 | - $id = $this->parse_post_content( $passed_post ); |
|
| 96 | - if( $id ) { |
|
| 97 | - $ids = array_merge( $ids, (array) $id ); |
|
| 95 | + $id = $this->parse_post_content($passed_post); |
|
| 96 | + if ($id) { |
|
| 97 | + $ids = array_merge($ids, (array)$id); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } else { |
| 101 | - $id = $this->get_id_from_atts( $passed_post ); |
|
| 102 | - $ids[] = intval( $id ); |
|
| 101 | + $id = $this->get_id_from_atts($passed_post); |
|
| 102 | + $ids[] = intval($id); |
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if( empty($ids) ) { |
|
| 107 | + if (empty($ids)) { |
|
| 108 | 108 | return NULL; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // If it's just one ID, return that. |
| 112 | 112 | // Otherwise, return array of IDs |
| 113 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 113 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public static function getInstance( $passed_post = NULL ) { |
|
| 116 | + public static function getInstance($passed_post = NULL) { |
|
| 117 | 117 | |
| 118 | - if( empty( self::$instance ) ) { |
|
| 119 | - self::$instance = new GravityView_View_Data( $passed_post ); |
|
| 118 | + if (empty(self::$instance)) { |
|
| 119 | + self::$instance = new GravityView_View_Data($passed_post); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | return self::$instance; |
@@ -126,25 +126,25 @@ discard block |
||
| 126 | 126 | return $this->views; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - function get_view( $view_id, $atts = NULL ) { |
|
| 129 | + function get_view($view_id, $atts = NULL) { |
|
| 130 | 130 | |
| 131 | - if( ! is_numeric( $view_id) ) { |
|
| 132 | - do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id) ); |
|
| 131 | + if (!is_numeric($view_id)) { |
|
| 132 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[get_view] $view_id passed is not numeric.', $view_id)); |
|
| 133 | 133 | return false; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // Backup: the view hasn't been fetched yet. Doing it now. |
| 137 | - if ( ! isset( $this->views[ $view_id ] ) ) { |
|
| 138 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id) ); |
|
| 139 | - return $this->add_view( $view_id, $atts ); |
|
| 137 | + if (!isset($this->views[$view_id])) { |
|
| 138 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] View #%s not set yet.', $view_id)); |
|
| 139 | + return $this->add_view($view_id, $atts); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ( empty( $this->views[ $view_id ] ) ) { |
|
| 143 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id) ); |
|
| 142 | + if (empty($this->views[$view_id])) { |
|
| 143 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[get_view] Returning; View #%s was empty.', $view_id)); |
|
| 144 | 144 | return false; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - return $this->views[ $view_id ]; |
|
| 147 | + return $this->views[$view_id]; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | * @return bool True if the post exists; otherwise, false. |
| 157 | 157 | * @since 1.0.0 |
| 158 | 158 | */ |
| 159 | - function view_exists( $view_id ) { |
|
| 160 | - return is_string( get_post_status( $view_id ) ); |
|
| 159 | + function view_exists($view_id) { |
|
| 160 | + return is_string(get_post_status($view_id)); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -168,56 +168,56 @@ discard block |
||
| 168 | 168 | * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional) |
| 169 | 169 | * @return type |
| 170 | 170 | */ |
| 171 | - function add_view( $view_id, $atts = NULL ) { |
|
| 171 | + function add_view($view_id, $atts = NULL) { |
|
| 172 | 172 | |
| 173 | 173 | // Handle array of IDs |
| 174 | - if( is_array( $view_id ) ) { |
|
| 175 | - foreach( $view_id as $id ) { |
|
| 174 | + if (is_array($view_id)) { |
|
| 175 | + foreach ($view_id as $id) { |
|
| 176 | 176 | |
| 177 | - $this->add_view( $id, $atts ); |
|
| 177 | + $this->add_view($id, $atts); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | return $this->views; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | // The view has been set already; returning stored view. |
| 184 | - if ( !empty( $this->views[ $view_id ] ) ) { |
|
| 185 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id) ); |
|
| 186 | - return $this->views[ $view_id ]; |
|
| 184 | + if (!empty($this->views[$view_id])) { |
|
| 185 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id)); |
|
| 186 | + return $this->views[$view_id]; |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if( ! $this->view_exists( $view_id ) ) { |
|
| 190 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id) ); |
|
| 189 | + if (!$this->view_exists($view_id)) { |
|
| 190 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id)); |
|
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $form_id = gravityview_get_form_id( $view_id ); |
|
| 194 | + $form_id = gravityview_get_form_id($view_id); |
|
| 195 | 195 | |
| 196 | - if( empty( $form_id ) ) { |
|
| 196 | + if (empty($form_id)) { |
|
| 197 | 197 | |
| 198 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id) ); |
|
| 198 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id)); |
|
| 199 | 199 | |
| 200 | 200 | return false; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | // Get the settings for the View ID |
| 204 | - $view_settings = gravityview_get_template_settings( $view_id ); |
|
| 204 | + $view_settings = gravityview_get_template_settings($view_id); |
|
| 205 | 205 | |
| 206 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings ); |
|
| 206 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings); |
|
| 207 | 207 | |
| 208 | 208 | // Merge the view settings with the defaults |
| 209 | - $view_defaults = wp_parse_args( $view_settings, self::get_default_args() ); |
|
| 209 | + $view_defaults = wp_parse_args($view_settings, self::get_default_args()); |
|
| 210 | 210 | |
| 211 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults ); |
|
| 211 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults); |
|
| 212 | 212 | |
| 213 | - if( ! empty( $atts ) && is_array( $atts ) ) { |
|
| 213 | + if (!empty($atts) && is_array($atts)) { |
|
| 214 | 214 | |
| 215 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts ); |
|
| 215 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts); |
|
| 216 | 216 | |
| 217 | 217 | // Get the settings from the shortcode and merge them with defaults. |
| 218 | - $atts = shortcode_atts( $view_defaults, $atts ); |
|
| 218 | + $atts = shortcode_atts($view_defaults, $atts); |
|
| 219 | 219 | |
| 220 | - do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts ); |
|
| 220 | + do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts); |
|
| 221 | 221 | |
| 222 | 222 | } else { |
| 223 | 223 | |
@@ -226,24 +226,24 @@ discard block |
||
| 226 | 226 | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - unset( $atts['id'], $view_defaults, $view_settings ); |
|
| 229 | + unset($atts['id'], $view_defaults, $view_settings); |
|
| 230 | 230 | |
| 231 | 231 | $data = array( |
| 232 | 232 | 'id' => $view_id, |
| 233 | 233 | 'view_id' => $view_id, |
| 234 | 234 | 'form_id' => $form_id, |
| 235 | - 'template_id' => gravityview_get_template_id( $view_id ), |
|
| 235 | + 'template_id' => gravityview_get_template_id($view_id), |
|
| 236 | 236 | 'atts' => $atts, |
| 237 | - 'fields' => $this->get_fields( $view_id ), |
|
| 238 | - 'widgets' => get_post_meta( $view_id, '_gravityview_directory_widgets', true ), |
|
| 239 | - 'form' => gravityview_get_form( $form_id ), |
|
| 237 | + 'fields' => $this->get_fields($view_id), |
|
| 238 | + 'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true), |
|
| 239 | + 'form' => gravityview_get_form($form_id), |
|
| 240 | 240 | ); |
| 241 | 241 | |
| 242 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data ); |
|
| 242 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data); |
|
| 243 | 243 | |
| 244 | - $this->views[ $view_id ] = $data; |
|
| 244 | + $this->views[$view_id] = $data; |
|
| 245 | 245 | |
| 246 | - return $this->views[ $view_id ]; |
|
| 246 | + return $this->views[$view_id]; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -253,14 +253,14 @@ discard block |
||
| 253 | 253 | * @param int $view_id View ID |
| 254 | 254 | * @return array Array of fields as passed by `gravityview_get_directory_fields()` |
| 255 | 255 | */ |
| 256 | - function get_fields( $view_id ) { |
|
| 256 | + function get_fields($view_id) { |
|
| 257 | 257 | |
| 258 | - $dir_fields = gravityview_get_directory_fields( $view_id ); |
|
| 259 | - do_action( 'gravityview_log_debug', '[render_view] Fields: ', $dir_fields ); |
|
| 258 | + $dir_fields = gravityview_get_directory_fields($view_id); |
|
| 259 | + do_action('gravityview_log_debug', '[render_view] Fields: ', $dir_fields); |
|
| 260 | 260 | |
| 261 | 261 | // remove fields according to visitor visibility permissions (if logged-in) |
| 262 | - $dir_fields = $this->filter_fields( $dir_fields ); |
|
| 263 | - do_action( 'gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields ); |
|
| 262 | + $dir_fields = $this->filter_fields($dir_fields); |
|
| 263 | + do_action('gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields); |
|
| 264 | 264 | |
| 265 | 265 | return $dir_fields; |
| 266 | 266 | } |
@@ -272,18 +272,18 @@ discard block |
||
| 272 | 272 | * @param array $dir_fields |
| 273 | 273 | * @return array |
| 274 | 274 | */ |
| 275 | - private function filter_fields( $dir_fields ) { |
|
| 275 | + private function filter_fields($dir_fields) { |
|
| 276 | 276 | |
| 277 | - if( empty( $dir_fields ) || !is_array( $dir_fields ) ) { |
|
| 277 | + if (empty($dir_fields) || !is_array($dir_fields)) { |
|
| 278 | 278 | return $dir_fields; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - foreach( $dir_fields as $area => $fields ) { |
|
| 281 | + foreach ($dir_fields as $area => $fields) { |
|
| 282 | 282 | |
| 283 | - foreach( (array)$fields as $uniqid => $properties ) { |
|
| 283 | + foreach ((array)$fields as $uniqid => $properties) { |
|
| 284 | 284 | |
| 285 | - if( $this->hide_field_check_conditions( $properties ) ) { |
|
| 286 | - unset( $dir_fields[ $area ][ $uniqid ] ); |
|
| 285 | + if ($this->hide_field_check_conditions($properties)) { |
|
| 286 | + unset($dir_fields[$area][$uniqid]); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | } |
@@ -301,31 +301,31 @@ discard block |
||
| 301 | 301 | * @param array $properties |
| 302 | 302 | * @return void|boolean (field should be hidden) or false (field should be presented) |
| 303 | 303 | */ |
| 304 | - private function hide_field_check_conditions( $properties ) { |
|
| 304 | + private function hide_field_check_conditions($properties) { |
|
| 305 | 305 | |
| 306 | 306 | // logged-in visibility |
| 307 | - if( ! empty( $properties['only_loggedin'] ) && ! GVCommon::has_cap( $properties['only_loggedin_cap'] ) ) { |
|
| 307 | + if (!empty($properties['only_loggedin']) && !GVCommon::has_cap($properties['only_loggedin_cap'])) { |
|
| 308 | 308 | return true; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | return false; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - function get_id_from_atts( $atts ) { |
|
| 314 | + function get_id_from_atts($atts) { |
|
| 315 | 315 | |
| 316 | - $atts = is_array( $atts ) ? $atts : shortcode_parse_atts( $atts ); |
|
| 316 | + $atts = is_array($atts) ? $atts : shortcode_parse_atts($atts); |
|
| 317 | 317 | |
| 318 | 318 | // Get the settings from the shortcode and merge them with defaults. |
| 319 | - $atts = wp_parse_args( $atts, self::get_default_args() ); |
|
| 319 | + $atts = wp_parse_args($atts, self::get_default_args()); |
|
| 320 | 320 | |
| 321 | - $view_id = ! empty( $atts['view_id'] ) ? (int)$atts['view_id'] : NULL; |
|
| 321 | + $view_id = !empty($atts['view_id']) ? (int)$atts['view_id'] : NULL; |
|
| 322 | 322 | |
| 323 | - if( empty( $view_id ) && !empty( $atts['id'] ) ) { |
|
| 323 | + if (empty($view_id) && !empty($atts['id'])) { |
|
| 324 | 324 | $view_id = (int)$atts['id']; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - if( empty( $view_id ) ) { |
|
| 328 | - do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts ); |
|
| 327 | + if (empty($view_id)) { |
|
| 328 | + do_action('gravityview_log_error', 'GravityView_View_Data[get_id_from_atts] Returning; no ID defined (Atts)', $atts); |
|
| 329 | 329 | return; |
| 330 | 330 | } |
| 331 | 331 | |
@@ -341,50 +341,50 @@ discard block |
||
| 341 | 341 | * @param string $content $post->post_content content |
| 342 | 342 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, NULL |
| 343 | 343 | */ |
| 344 | - function parse_post_content( $content ) { |
|
| 344 | + function parse_post_content($content) { |
|
| 345 | 345 | |
| 346 | 346 | /** |
| 347 | 347 | * @hack This is so that the shortcode is registered for the oEmbed preview in the Admin |
| 348 | 348 | * @since 1.6 |
| 349 | 349 | */ |
| 350 | - if( ! shortcode_exists('gravityview') && class_exists( 'GravityView_Shortcode' ) ) { |
|
| 350 | + if (!shortcode_exists('gravityview') && class_exists('GravityView_Shortcode')) { |
|
| 351 | 351 | new GravityView_Shortcode; |
| 352 | 352 | } |
| 353 | 353 | |
| 354 | - $shortcodes = gravityview_has_shortcode_r( $content, 'gravityview' ); |
|
| 354 | + $shortcodes = gravityview_has_shortcode_r($content, 'gravityview'); |
|
| 355 | 355 | |
| 356 | - if( empty( $shortcodes ) ) { |
|
| 356 | + if (empty($shortcodes)) { |
|
| 357 | 357 | return NULL; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes ); |
|
| 360 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_content] Parsing content, found shortcodes:', $shortcodes); |
|
| 361 | 361 | |
| 362 | 362 | $ids = array(); |
| 363 | 363 | |
| 364 | 364 | foreach ($shortcodes as $key => $shortcode) { |
| 365 | 365 | |
| 366 | - $args = shortcode_parse_atts( $shortcode[3] ); |
|
| 366 | + $args = shortcode_parse_atts($shortcode[3]); |
|
| 367 | 367 | |
| 368 | - if( empty( $args['id'] ) ) { |
|
| 369 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID ), $shortcode ); |
|
| 368 | + if (empty($args['id'])) { |
|
| 369 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_content] Returning; no ID defined in shortcode atts for Post #%s (Atts)', $post->ID), $shortcode); |
|
| 370 | 370 | continue; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args ); |
|
| 373 | + do_action('gravityview_log_debug', sprintf('GravityView_View_Data[parse_post_content] Adding view #%s with shortcode args', $args['id']), $args); |
|
| 374 | 374 | |
| 375 | 375 | // Store the View to the object for later fetching. |
| 376 | - $this->add_view( $args['id'], $args ); |
|
| 376 | + $this->add_view($args['id'], $args); |
|
| 377 | 377 | |
| 378 | 378 | $ids[] = $args['id']; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if( empty($ids) ) { |
|
| 381 | + if (empty($ids)) { |
|
| 382 | 382 | return NULL; |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | // If it's just one ID, return that. |
| 386 | 386 | // Otherwise, return array of IDs |
| 387 | - return ( sizeof( $ids ) === 1 ) ? $ids[0] : $ids; |
|
| 387 | + return (sizeof($ids) === 1) ? $ids[0] : $ids; |
|
| 388 | 388 | |
| 389 | 389 | } |
| 390 | 390 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | * @param int $post_id WP_Post ID |
| 396 | 396 | * @return int|null|array If a single View is found, the ID of the View. If there are multiple views in the content, array of IDs parsed. If not found, or meta not parsed, NULL |
| 397 | 397 | */ |
| 398 | - private function parse_post_meta( $post_id ) { |
|
| 398 | + private function parse_post_meta($post_id) { |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | 401 | * @filter `gravityview/data/parse/meta_keys` Define meta keys to parse to check for GravityView shortcode content |
@@ -403,32 +403,32 @@ discard block |
||
| 403 | 403 | * @param[in,out] array $meta_keys Array of key values to check. If empty, do not check. Default: empty array |
| 404 | 404 | * @param[in] int $post_id ID of the post being checked |
| 405 | 405 | */ |
| 406 | - $meta_keys = (array)apply_filters( 'gravityview/data/parse/meta_keys', array(), $post_id ); |
|
| 406 | + $meta_keys = (array)apply_filters('gravityview/data/parse/meta_keys', array(), $post_id); |
|
| 407 | 407 | |
| 408 | - if( empty( $meta_keys ) ) { |
|
| 408 | + if (empty($meta_keys)) { |
|
| 409 | 409 | return NULL; |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys ); |
|
| 412 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Search for GravityView shortcodes on the following custom fields keys:', $meta_keys); |
|
| 413 | 413 | |
| 414 | 414 | $meta_content = ''; |
| 415 | 415 | |
| 416 | - foreach( $meta_keys as $key ) { |
|
| 417 | - $meta = get_post_meta( $post_id, $key , true ); |
|
| 418 | - if( ! is_string( $meta ) ) { |
|
| 416 | + foreach ($meta_keys as $key) { |
|
| 417 | + $meta = get_post_meta($post_id, $key, true); |
|
| 418 | + if (!is_string($meta)) { |
|
| 419 | 419 | continue; |
| 420 | 420 | } |
| 421 | - $meta_content .= $meta . ' '; |
|
| 421 | + $meta_content .= $meta.' '; |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - if( empty( $meta_content ) ) { |
|
| 425 | - do_action('gravityview_log_error', sprintf( 'GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id ), $meta_keys ); |
|
| 424 | + if (empty($meta_content)) { |
|
| 425 | + do_action('gravityview_log_error', sprintf('GravityView_View_Data[parse_post_meta] Returning; Empty custom fields for Post #%s (Custom fields keys:)', $post_id), $meta_keys); |
|
| 426 | 426 | return NULL; |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - do_action( 'gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content ); |
|
| 429 | + do_action('gravityview_log_debug', 'GravityView_View_Data[parse_post_meta] Combined content retrieved from custom fields:', $meta_content); |
|
| 430 | 430 | |
| 431 | - return $this->parse_post_content( $meta_content ); |
|
| 431 | + return $this->parse_post_content($meta_content); |
|
| 432 | 432 | |
| 433 | 433 | } |
| 434 | 434 | |
@@ -444,61 +444,61 @@ discard block |
||
| 444 | 444 | * |
| 445 | 445 | * @return bool|WP_Error If valid, returns true. If invalid, returns WP_Error containing error message. |
| 446 | 446 | */ |
| 447 | - public static function is_valid_embed_id( $post_id = '', $view_id = '', $empty_is_valid = true ) { |
|
| 447 | + public static function is_valid_embed_id($post_id = '', $view_id = '', $empty_is_valid = true) { |
|
| 448 | 448 | |
| 449 | 449 | $message = NULL; |
| 450 | 450 | |
| 451 | 451 | // Not invalid if not set! |
| 452 | - if( empty( $post_id ) || empty( $view_id ) ) { |
|
| 452 | + if (empty($post_id) || empty($view_id)) { |
|
| 453 | 453 | |
| 454 | - if( $empty_is_valid ) { |
|
| 454 | + if ($empty_is_valid) { |
|
| 455 | 455 | return true; |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - $message = esc_html__( 'The ID is required.', 'gravityview' ); |
|
| 458 | + $message = esc_html__('The ID is required.', 'gravityview'); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - if( ! $message ) { |
|
| 462 | - $status = get_post_status( $post_id ); |
|
| 461 | + if (!$message) { |
|
| 462 | + $status = get_post_status($post_id); |
|
| 463 | 463 | |
| 464 | 464 | // Nothing exists with that post ID. |
| 465 | - if ( ! is_numeric( $post_id ) ) { |
|
| 466 | - $message = esc_html__( 'You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview' ); |
|
| 465 | + if (!is_numeric($post_id)) { |
|
| 466 | + $message = esc_html__('You did not enter a number. The value entered should be a number, representing the ID of the post or page the View is embedded on.', 'gravityview'); |
|
| 467 | 467 | |
| 468 | 468 | // @todo Convert to generic article about Embed IDs |
| 469 | - $message .= ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
| 469 | + $message .= ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview'), 'target=_blank'); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - if( ! $message ) { |
|
| 473 | + if (!$message) { |
|
| 474 | 474 | |
| 475 | 475 | // Nothing exists with that post ID. |
| 476 | - if ( empty( $status ) || in_array( $status, array( 'revision', 'attachment' ) ) ) { |
|
| 477 | - $message = esc_html__( 'There is no post or page with that ID.', 'gravityview' ); |
|
| 476 | + if (empty($status) || in_array($status, array('revision', 'attachment'))) { |
|
| 477 | + $message = esc_html__('There is no post or page with that ID.', 'gravityview'); |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - if( ! $message ) { |
|
| 483 | - $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id( $post_id ); |
|
| 482 | + if (!$message) { |
|
| 483 | + $view_ids_in_post = GravityView_View_Data::getInstance()->maybe_get_view_id($post_id); |
|
| 484 | 484 | |
| 485 | 485 | // The post or page specified does not contain the shortcode. |
| 486 | - if ( false === in_array( $view_id, (array) $view_ids_in_post ) ) { |
|
| 487 | - $message = sprintf( esc_html__( 'The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview' ), '<br /><code>[gravityview id="' . intval( $view_id ) . '"]</code>' ); |
|
| 486 | + if (false === in_array($view_id, (array)$view_ids_in_post)) { |
|
| 487 | + $message = sprintf(esc_html__('The Post ID entered is not valid. You may have entered a post or page that does not contain the selected View. Make sure the post contains the following shortcode: %s', 'gravityview'), '<br /><code>[gravityview id="'.intval($view_id).'"]</code>'); |
|
| 488 | 488 | } |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | - if( ! $message ) { |
|
| 491 | + if (!$message) { |
|
| 492 | 492 | |
| 493 | 493 | // It's a View |
| 494 | - if( 'gravityview' === get_post_type( $post_id ) ) { |
|
| 495 | - $message = esc_html__( 'The ID is already a View.', 'gravityview' );; |
|
| 494 | + if ('gravityview' === get_post_type($post_id)) { |
|
| 495 | + $message = esc_html__('The ID is already a View.', 'gravityview'); ; |
|
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | - if( $message ) { |
|
| 501 | - return new WP_Error( 'invalid_embed_id', $message ); |
|
| 500 | + if ($message) { |
|
| 501 | + return new WP_Error('invalid_embed_id', $message); |
|
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | return true; |
@@ -510,13 +510,13 @@ discard block |
||
| 510 | 510 | * @param boolean $with_details Include details |
| 511 | 511 | * @return mixed|array If using $with_details, return array. Otherwise, mixed. |
| 512 | 512 | */ |
| 513 | - public static function get_default_arg( $key, $with_details = false ) { |
|
| 513 | + public static function get_default_arg($key, $with_details = false) { |
|
| 514 | 514 | |
| 515 | - $args = self::get_default_args( $with_details ); |
|
| 515 | + $args = self::get_default_args($with_details); |
|
| 516 | 516 | |
| 517 | - if( !isset( $args[ $key ] ) ) { return NULL; } |
|
| 517 | + if (!isset($args[$key])) { return NULL; } |
|
| 518 | 518 | |
| 519 | - return $args[ $key ]; |
|
| 519 | + return $args[$key]; |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -535,13 +535,13 @@ discard block |
||
| 535 | 535 | * @param[out] array $options Array of values to use when generating select, multiselect, radio, or checkboxes fields |
| 536 | 536 | * @param[out] boolean $full_width True: Display the input and label together when rendering. False: Display label and input in separate columns when rendering. |
| 537 | 537 | */ |
| 538 | - public static function get_default_args( $with_details = false, $group = NULL ) { |
|
| 538 | + public static function get_default_args($with_details = false, $group = NULL) { |
|
| 539 | 539 | |
| 540 | 540 | /** |
| 541 | 541 | * @filter `gravityview_default_args` Modify the default settings for new Views |
| 542 | 542 | * @param[in,out] array $default_args Array of default args. |
| 543 | 543 | */ |
| 544 | - $default_settings = apply_filters( 'gravityview_default_args', array( |
|
| 544 | + $default_settings = apply_filters('gravityview_default_args', array( |
|
| 545 | 545 | 'id' => array( |
| 546 | 546 | 'label' => __('View ID', 'gravityview'), |
| 547 | 547 | 'type' => 'number', |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | 'show_in_shortcode' => true, |
| 560 | 560 | ), |
| 561 | 561 | 'lightbox' => array( |
| 562 | - 'label' => __( 'Enable lightbox for images', 'gravityview' ), |
|
| 562 | + 'label' => __('Enable lightbox for images', 'gravityview'), |
|
| 563 | 563 | 'type' => 'checkbox', |
| 564 | 564 | 'group' => 'default', |
| 565 | 565 | 'value' => 1, |
@@ -567,29 +567,29 @@ discard block |
||
| 567 | 567 | 'show_in_shortcode' => true, |
| 568 | 568 | ), |
| 569 | 569 | 'show_only_approved' => array( |
| 570 | - 'label' => __( 'Show only approved entries', 'gravityview' ), |
|
| 570 | + 'label' => __('Show only approved entries', 'gravityview'), |
|
| 571 | 571 | 'type' => 'checkbox', |
| 572 | 572 | 'group' => 'default', |
| 573 | 573 | 'value' => 0, |
| 574 | 574 | 'show_in_shortcode' => false, |
| 575 | 575 | ), |
| 576 | 576 | 'hide_until_searched' => array( |
| 577 | - 'label' => __( 'Hide View data until search is performed', 'gravityview' ), |
|
| 577 | + 'label' => __('Hide View data until search is performed', 'gravityview'), |
|
| 578 | 578 | 'type' => 'checkbox', |
| 579 | 579 | 'group' => 'default', |
| 580 | - 'tooltip' => __( 'When enabled it will only show any View entries after a search is performed.', 'gravityview' ), |
|
| 580 | + 'tooltip' => __('When enabled it will only show any View entries after a search is performed.', 'gravityview'), |
|
| 581 | 581 | 'value' => 0, |
| 582 | 582 | 'show_in_shortcode' => false, |
| 583 | 583 | ), |
| 584 | 584 | 'hide_empty' => array( |
| 585 | - 'label' => __( 'Hide empty fields', 'gravityview' ), |
|
| 585 | + 'label' => __('Hide empty fields', 'gravityview'), |
|
| 586 | 586 | 'group' => 'default', |
| 587 | 587 | 'type' => 'checkbox', |
| 588 | 588 | 'value' => 1, |
| 589 | 589 | 'show_in_shortcode' => false, |
| 590 | 590 | ), |
| 591 | 591 | 'user_edit' => array( |
| 592 | - 'label' => __( 'Allow User Edit', 'gravityview' ), |
|
| 592 | + 'label' => __('Allow User Edit', 'gravityview'), |
|
| 593 | 593 | 'group' => 'default', |
| 594 | 594 | 'desc' => __('Allow logged-in users to edit entries they created.', 'gravityview'), |
| 595 | 595 | 'value' => 0, |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | 'show_in_shortcode' => true, |
| 599 | 599 | ), |
| 600 | 600 | 'user_delete' => array( |
| 601 | - 'label' => __( 'Allow User Delete', 'gravityview' ), |
|
| 601 | + 'label' => __('Allow User Delete', 'gravityview'), |
|
| 602 | 602 | 'group' => 'default', |
| 603 | 603 | 'desc' => __('Allow logged-in users to delete entries they created.', 'gravityview'), |
| 604 | 604 | 'value' => 0, |
@@ -612,8 +612,8 @@ discard block |
||
| 612 | 612 | 'value' => '', |
| 613 | 613 | 'group' => 'sort', |
| 614 | 614 | 'options' => array( |
| 615 | - '' => __( 'Default', 'gravityview'), |
|
| 616 | - 'date_created' => __( 'Date Created', 'gravityview'), |
|
| 615 | + '' => __('Default', 'gravityview'), |
|
| 616 | + 'date_created' => __('Date Created', 'gravityview'), |
|
| 617 | 617 | ), |
| 618 | 618 | 'show_in_shortcode' => true, |
| 619 | 619 | ), |
@@ -630,19 +630,19 @@ discard block |
||
| 630 | 630 | 'show_in_shortcode' => true, |
| 631 | 631 | ), |
| 632 | 632 | 'sort_columns' => array( |
| 633 | - 'label' => __( 'Enable sorting by column', 'gravityview' ), |
|
| 634 | - 'left_label' => __( 'Column Sorting', 'gravityview' ), |
|
| 633 | + 'label' => __('Enable sorting by column', 'gravityview'), |
|
| 634 | + 'left_label' => __('Column Sorting', 'gravityview'), |
|
| 635 | 635 | 'type' => 'checkbox', |
| 636 | 636 | 'value' => false, |
| 637 | 637 | 'group' => 'sort', |
| 638 | 638 | 'tooltip' => NULL, |
| 639 | 639 | 'show_in_shortcode' => true, |
| 640 | - 'show_in_template' => array( 'default_table' ), |
|
| 640 | + 'show_in_template' => array('default_table'), |
|
| 641 | 641 | ), |
| 642 | 642 | 'start_date' => array( |
| 643 | 643 | 'label' => __('Filter by Start Date', 'gravityview'), |
| 644 | 644 | 'class' => 'gv-datepicker', |
| 645 | - 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview' ), |
|
| 645 | + 'desc' => __('Show entries submitted after this date. Supports relative dates, such as "-1 week" or "-1 month".', 'gravityview'), |
|
| 646 | 646 | 'type' => 'text', |
| 647 | 647 | 'value' => '', |
| 648 | 648 | 'group' => 'filter', |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | 'end_date' => array( |
| 652 | 652 | 'label' => __('Filter by End Date', 'gravityview'), |
| 653 | 653 | 'class' => 'gv-datepicker', |
| 654 | - 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview' ), |
|
| 654 | + 'desc' => __('Show entries submitted before this date. Supports relative dates, such as "now" or "-3 days".', 'gravityview'), |
|
| 655 | 655 | 'type' => 'text', |
| 656 | 656 | 'value' => '', |
| 657 | 657 | 'group' => 'filter', |
@@ -711,12 +711,12 @@ discard block |
||
| 711 | 711 | )); |
| 712 | 712 | |
| 713 | 713 | // By default, we only want the key => value pairing, not the whole array. |
| 714 | - if( empty( $with_details ) ) { |
|
| 714 | + if (empty($with_details)) { |
|
| 715 | 715 | |
| 716 | 716 | $defaults = array(); |
| 717 | 717 | |
| 718 | - foreach( $default_settings as $key => $value ) { |
|
| 719 | - $defaults[ $key ] = $value['value']; |
|
| 718 | + foreach ($default_settings as $key => $value) { |
|
| 719 | + $defaults[$key] = $value['value']; |
|
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | return $defaults; |
@@ -729,9 +729,9 @@ discard block |
||
| 729 | 729 | |
| 730 | 730 | // If the $group argument is set for the method, |
| 731 | 731 | // ignore any settings that aren't in that group. |
| 732 | - if( !empty( $group ) && is_string( $group ) ) { |
|
| 733 | - if( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
| 734 | - unset( $default_settings[ $key ] ); |
|
| 732 | + if (!empty($group) && is_string($group)) { |
|
| 733 | + if (empty($value['group']) || $value['group'] !== $group) { |
|
| 734 | + unset($default_settings[$key]); |
|
| 735 | 735 | } |
| 736 | 736 | } |
| 737 | 737 | |
@@ -21,12 +21,12 @@ discard block |
||
| 21 | 21 | function init() { |
| 22 | 22 | |
| 23 | 23 | $icon = is_admin() ? '<i class="icon gv-icon-astronaut-head"></i> ' : NULL; |
| 24 | - $this->title( $icon . __('GravityView', 'gravityview') ); |
|
| 24 | + $this->title($icon.__('GravityView', 'gravityview')); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | function get_warnings() { |
| 28 | 28 | |
| 29 | - if( is_null( $this->warnings ) ) { |
|
| 29 | + if (is_null($this->warnings)) { |
|
| 30 | 30 | $this->warnings = GravityView_Logging::get_errors(); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | function get_notices() { |
| 37 | 37 | |
| 38 | - if( is_null( $this->notices ) ) { |
|
| 38 | + if (is_null($this->notices)) { |
|
| 39 | 39 | $this->notices = GravityView_Logging::get_notices(); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * Should the panel be shown? If there are notices or warnings, yes. |
| 51 | 51 | * @return boolean true: show panel; false: hide panel |
| 52 | 52 | */ |
| 53 | - function set_visible( $visible = '' ) { |
|
| 54 | - $this->_visible = ( count( $this->get_notices() ) || count( $this->get_warnings() ) ); |
|
| 53 | + function set_visible($visible = '') { |
|
| 54 | + $this->_visible = (count($this->get_notices()) || count($this->get_warnings())); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -83,42 +83,42 @@ discard block |
||
| 83 | 83 | </style> |
| 84 | 84 | <div id='debug-bar-gravityview'>"; |
| 85 | 85 | |
| 86 | - $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="alignright" alt="" width="100" height="132" />'; |
|
| 86 | + $output .= '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE).'" class="alignright" alt="" width="100" height="132" />'; |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | $warnings = $this->get_warnings(); |
| 90 | 90 | $notices = $this->get_notices(); |
| 91 | 91 | |
| 92 | - if(count($warnings)) { |
|
| 92 | + if (count($warnings)) { |
|
| 93 | 93 | $output .= '<h3><span>'.__('Warnings', 'gravityview').'</span></h3>'; |
| 94 | 94 | $output .= '<ol>'; |
| 95 | - foreach ( $warnings as $key => $notice) { |
|
| 96 | - if(empty($notice['message'])) { continue; } |
|
| 97 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-warning-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 95 | + foreach ($warnings as $key => $notice) { |
|
| 96 | + if (empty($notice['message'])) { continue; } |
|
| 97 | + $output .= '<li><a href="#'.sanitize_html_class('gv-warning-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 98 | 98 | } |
| 99 | 99 | $output .= '</ol><hr />'; |
| 100 | 100 | } |
| 101 | - if(count($notices)) { |
|
| 101 | + if (count($notices)) { |
|
| 102 | 102 | $output .= '<h3><span>'.__('Logs', 'gravityview').'</span></h3>'; |
| 103 | 103 | $output .= '<ol>'; |
| 104 | - foreach ( $notices as $key => $notice) { |
|
| 105 | - if(empty($notice['message'])) { continue; } |
|
| 106 | - $output .= '<li><a href="#'.sanitize_html_class( 'gv-notice-' . $key ).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 104 | + foreach ($notices as $key => $notice) { |
|
| 105 | + if (empty($notice['message'])) { continue; } |
|
| 106 | + $output .= '<li><a href="#'.sanitize_html_class('gv-notice-'.$key).'">'.strip_tags($notice['message']).'</a></li>'; |
|
| 107 | 107 | } |
| 108 | 108 | $output .= '</ol><hr />'; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - if ( count( $warnings ) ) { |
|
| 111 | + if (count($warnings)) { |
|
| 112 | 112 | $output .= '<h3>Warnings</h3>'; |
| 113 | 113 | $output .= '<ol class="debug-bar-php-list">'; |
| 114 | - foreach ( $warnings as $key => $notice) { $output .= $this->render_item( $notice, 'gv-warning-' . $key ); } |
|
| 114 | + foreach ($warnings as $key => $notice) { $output .= $this->render_item($notice, 'gv-warning-'.$key); } |
|
| 115 | 115 | $output .= '</ol>'; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if ( count( $notices ) ) { |
|
| 118 | + if (count($notices)) { |
|
| 119 | 119 | $output .= '<h3>Notices</h3>'; |
| 120 | 120 | $output .= '<ol class="debug-bar-php-list">'; |
| 121 | - foreach ( $notices as $key => $notice) { $output .= $this->render_item( $notice, 'gv-notice-' . $key ); } |
|
| 121 | + foreach ($notices as $key => $notice) { $output .= $this->render_item($notice, 'gv-notice-'.$key); } |
|
| 122 | 122 | $output .= '</ol>'; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | * @return string Escaped HTML |
| 134 | 134 | */ |
| 135 | 135 | function esc_html_recursive($item) { |
| 136 | - if(is_object($item)) { |
|
| 137 | - foreach($item as $key => $value) { |
|
| 136 | + if (is_object($item)) { |
|
| 137 | + foreach ($item as $key => $value) { |
|
| 138 | 138 | $item->{$key} = $this->esc_html_recursive($value); |
| 139 | 139 | } |
| 140 | - } else if(is_array($item)) { |
|
| 141 | - foreach($item as $key => $value) { |
|
| 140 | + } else if (is_array($item)) { |
|
| 141 | + foreach ($item as $key => $value) { |
|
| 142 | 142 | $item[$key] = $this->esc_html_recursive($value); |
| 143 | 143 | } |
| 144 | 144 | } else { |
@@ -154,31 +154,31 @@ discard block |
||
| 154 | 154 | * @param string $anchor The anchor ID for the item |
| 155 | 155 | * @return string HTML output |
| 156 | 156 | */ |
| 157 | - function render_item( $notice, $anchor = '' ) { |
|
| 157 | + function render_item($notice, $anchor = '') { |
|
| 158 | 158 | |
| 159 | 159 | $output = ''; |
| 160 | 160 | |
| 161 | - if(!empty($notice['message'])) { |
|
| 162 | - $output .= '<a id="'.sanitize_html_class( $anchor ).'"></a>'; |
|
| 161 | + if (!empty($notice['message'])) { |
|
| 162 | + $output .= '<a id="'.sanitize_html_class($anchor).'"></a>'; |
|
| 163 | 163 | $output .= "<li class='debug-bar-php-notice'>"; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | $output .= '<div class="clear"></div>'; |
| 167 | 167 | |
| 168 | 168 | // Title |
| 169 | - $output .= '<div class="gravityview-debug-bar-title">'.esc_attr( $notice['message'] ).'</div>'; |
|
| 169 | + $output .= '<div class="gravityview-debug-bar-title">'.esc_attr($notice['message']).'</div>'; |
|
| 170 | 170 | |
| 171 | 171 | // Debugging Output |
| 172 | - if( empty( $notice['data'] ) ) { |
|
| 173 | - if( !is_null( $notice['data'] ) ) { |
|
| 174 | - $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview' ).'</em>'; |
|
| 172 | + if (empty($notice['data'])) { |
|
| 173 | + if (!is_null($notice['data'])) { |
|
| 174 | + $output .= '<em>'._x('Empty', 'Debugging output data is empty.', 'gravityview').'</em>'; |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | else { |
| 178 | - $output .= sprintf( '<pre>%s</pre>', print_r($this->esc_html_recursive( $notice['data'] ), true) ); |
|
| 178 | + $output .= sprintf('<pre>%s</pre>', print_r($this->esc_html_recursive($notice['data']), true)); |
|
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if(!empty($notice['message'])) { |
|
| 181 | + if (!empty($notice['message'])) { |
|
| 182 | 182 | $output .= '</li>'; |
| 183 | 183 | } |
| 184 | 184 | |
@@ -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 | } |