@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | |
72 | 72 | add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
73 | 73 | |
74 | - add_action( 'admin_init', array( $this, 'settings') ); |
|
74 | + add_action( 'admin_init', array( $this, 'settings' ) ); |
|
75 | 75 | |
76 | 76 | add_action( 'admin_notices', array( $this, 'admin_notice' ), 100 ); |
77 | 77 | |
78 | 78 | add_action( 'gravityview/metaboxes/before_render', array( $this, 'add_metabox_tab' ) ); |
79 | 79 | |
80 | - if( false === $this->is_extension_supported() ) { |
|
80 | + if ( false === $this->is_extension_supported() ) { |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | $tab_settings = $this->tab_settings(); |
117 | 117 | |
118 | 118 | // Don't add a tab if it's empty. |
119 | - if( empty( $tab_settings ) ) { |
|
119 | + if ( empty( $tab_settings ) ) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | $tab = wp_parse_args( $tab_settings, $tab_defaults ); |
135 | 135 | |
136 | 136 | // Force the screen to be GravityView |
137 | - $tab['screen'] = 'gravityview'; |
|
137 | + $tab[ 'screen' ] = 'gravityview'; |
|
138 | 138 | |
139 | - if( class_exists('GravityView_Metabox_Tab') ) { |
|
139 | + if ( class_exists( 'GravityView_Metabox_Tab' ) ) { |
|
140 | 140 | |
141 | - $metabox = new GravityView_Metabox_Tab( $tab['id'], $tab['title'], $tab['file'], $tab['icon-class'], $tab['callback'], $tab['callback_args'] ); |
|
141 | + $metabox = new GravityView_Metabox_Tab( $tab[ 'id' ], $tab[ 'title' ], $tab[ 'file' ], $tab[ 'icon-class' ], $tab[ 'callback' ], $tab[ 'callback_args' ] ); |
|
142 | 142 | |
143 | 143 | GravityView_Metabox_Tabs::add( $metabox ); |
144 | 144 | |
145 | 145 | } else { |
146 | 146 | |
147 | - add_meta_box( 'gravityview_'.$tab['id'], $tab['title'], $tab['callback'], $tab['screen'], $tab['context'], $tab['priority'] ); |
|
147 | + add_meta_box( 'gravityview_' . $tab[ 'id' ], $tab[ 'title' ], $tab[ 'callback' ], $tab[ 'screen' ], $tab[ 'context' ], $tab[ 'priority' ] ); |
|
148 | 148 | |
149 | 149 | } |
150 | 150 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function load_plugin_textdomain() { |
162 | 162 | |
163 | - if( empty( $this->_text_domain ) ) { |
|
163 | + if ( empty( $this->_text_domain ) ) { |
|
164 | 164 | do_action( 'gravityview_log_debug', __METHOD__ . ': Extension translation cannot be loaded; the `_text_domain` variable is not defined', $this ); |
165 | 165 | return; |
166 | 166 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | $lang_dir = dirname( plugin_basename( $path ) ) . '/languages/'; |
173 | 173 | |
174 | 174 | // Traditional WordPress plugin locale filter |
175 | - $locale = apply_filters( 'plugin_locale', get_locale(), $this->_text_domain ); |
|
175 | + $locale = apply_filters( 'plugin_locale', get_locale(), $this->_text_domain ); |
|
176 | 176 | |
177 | 177 | $mofile = sprintf( '%1$s-%2$s.mo', $this->_text_domain, $locale ); |
178 | 178 | |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | */ |
203 | 203 | protected function get_license() { |
204 | 204 | |
205 | - if( !class_exists( 'GravityView_Settings' ) ) { |
|
205 | + if ( ! class_exists( 'GravityView_Settings' ) ) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | |
209 | - $license = GravityView_Settings::getSetting('license'); |
|
209 | + $license = GravityView_Settings::getSetting( 'license' ); |
|
210 | 210 | |
211 | 211 | return $license; |
212 | 212 | } |
@@ -219,16 +219,16 @@ discard block |
||
219 | 219 | public function settings() { |
220 | 220 | |
221 | 221 | // If doing ajax, get outta here |
222 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
222 | + if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | - if( !class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
226 | + if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) { |
|
227 | 227 | |
228 | 228 | $file_path = plugin_dir_path( __FILE__ ) . 'lib/EDD_SL_Plugin_Updater.php'; |
229 | 229 | |
230 | 230 | // This file may be in the lib/ directory already |
231 | - if( ! file_exists( $file_path ) ) { |
|
231 | + if ( ! file_exists( $file_path ) ) { |
|
232 | 232 | $file_path = plugin_dir_path( __FILE__ ) . '/EDD_SL_Plugin_Updater.php'; |
233 | 233 | } |
234 | 234 | |
@@ -238,16 +238,16 @@ discard block |
||
238 | 238 | $license = $this->get_license(); |
239 | 239 | |
240 | 240 | // Don't update if invalid license. |
241 | - if( false === $license || empty( $license['status'] ) || strtolower( $license['status'] ) !== 'valid' ) { return; } |
|
241 | + if ( false === $license || empty( $license[ 'status' ] ) || strtolower( $license[ 'status' ] ) !== 'valid' ) { return; } |
|
242 | 242 | |
243 | 243 | new EDD_SL_Plugin_Updater( |
244 | 244 | $this->_remote_update_url, |
245 | 245 | $this->_path, |
246 | 246 | array( |
247 | 247 | 'version' => $this->_version, // current version number |
248 | - 'license' => $license['license'], |
|
248 | + 'license' => $license[ 'license' ], |
|
249 | 249 | 'item_id' => $this->_item_id, // The ID of the download on _remote_update_url |
250 | - 'item_name' => $this->_title, // name of this plugin |
|
250 | + 'item_name' => $this->_title, // name of this plugin |
|
251 | 251 | 'author' => strip_tags( $this->_author ) // author of this plugin |
252 | 252 | ) |
253 | 253 | ); |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function admin_notice() { |
262 | 262 | |
263 | - if( empty( self::$admin_notices ) ) { |
|
263 | + if ( empty( self::$admin_notices ) ) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | - foreach( self::$admin_notices as $key => $notice ) { |
|
267 | + foreach ( self::$admin_notices as $key => $notice ) { |
|
268 | 268 | |
269 | - echo '<div id="message" class="'. esc_attr( $notice['class'] ).'">'; |
|
270 | - echo wpautop( $notice['message'] ); |
|
269 | + echo '<div id="message" class="' . esc_attr( $notice[ 'class' ] ) . '">'; |
|
270 | + echo wpautop( $notice[ 'message' ] ); |
|
271 | 271 | echo '<div class="clear"></div>'; |
272 | 272 | echo '</div>'; |
273 | 273 | } |
@@ -282,16 +282,16 @@ discard block |
||
282 | 282 | */ |
283 | 283 | public static function add_notice( $notice = array() ) { |
284 | 284 | |
285 | - if( is_array( $notice ) && !isset( $notice['message'] ) ) { |
|
286 | - do_action( 'gravityview_log_error', __CLASS__.'[add_notice] Notice not set', $notice ); |
|
285 | + if ( is_array( $notice ) && ! isset( $notice[ 'message' ] ) ) { |
|
286 | + do_action( 'gravityview_log_error', __CLASS__ . '[add_notice] Notice not set', $notice ); |
|
287 | 287 | return; |
288 | - } else if( is_string( $notice ) ) { |
|
288 | + } else if ( is_string( $notice ) ) { |
|
289 | 289 | $notice = array( 'message' => $notice ); |
290 | 290 | } |
291 | 291 | |
292 | - $notice['class'] = empty( $notice['class'] ) ? 'error' : $notice['class']; |
|
292 | + $notice[ 'class' ] = empty( $notice[ 'class' ] ) ? 'error' : $notice[ 'class' ]; |
|
293 | 293 | |
294 | - self::$admin_notices[] = $notice; |
|
294 | + self::$admin_notices[ ] = $notice; |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -346,17 +346,17 @@ discard block |
||
346 | 346 | |
347 | 347 | $message = ''; |
348 | 348 | |
349 | - if( !class_exists( 'GravityView_Plugin' ) ) { |
|
349 | + if ( ! class_exists( 'GravityView_Plugin' ) ) { |
|
350 | 350 | |
351 | - $message = sprintf( __('Could not activate the %s Extension; GravityView is not active.', 'gravityview'), $this->_title ); |
|
351 | + $message = sprintf( __( 'Could not activate the %s Extension; GravityView is not active.', 'gravityview' ), $this->_title ); |
|
352 | 352 | |
353 | - } else if( false === version_compare(GravityView_Plugin::version, $this->_min_gravityview_version , ">=") ) { |
|
353 | + } else if ( false === version_compare( GravityView_Plugin::version, $this->_min_gravityview_version, ">=" ) ) { |
|
354 | 354 | |
355 | - $message = sprintf( __('The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_gravityview_version.'</tt>' ); |
|
355 | + $message = sprintf( __( 'The %s Extension requires GravityView Version %s or newer.', 'gravityview' ), $this->_title, '<tt>' . $this->_min_gravityview_version . '</tt>' ); |
|
356 | 356 | |
357 | - } else if( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version , ">=") ) { |
|
357 | + } else if ( isset( $this->_min_php_version ) && false === version_compare( phpversion(), $this->_min_php_version, ">=" ) ) { |
|
358 | 358 | |
359 | - $message = sprintf( __('The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>'.$this->_min_php_version.'</tt>' ); |
|
359 | + $message = sprintf( __( 'The %s Extension requires PHP Version %s or newer. Please ask your host to upgrade your server\'s PHP.', 'gravityview' ), $this->_title, '<tt>' . $this->_min_php_version . '</tt>' ); |
|
360 | 360 | |
361 | 361 | } else { |
362 | 362 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | |
369 | 369 | self::add_notice( $message ); |
370 | 370 | |
371 | - do_action( 'gravityview_log_error', __METHOD__. ' ' . $message ); |
|
371 | + do_action( 'gravityview_log_error', __METHOD__ . ' ' . $message ); |
|
372 | 372 | |
373 | 373 | self::$is_compatible = false; |
374 | 374 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | function __construct( ) { |
14 | 14 | |
15 | - $name = __('GravityView Recent Entries', 'gravityview'); |
|
15 | + $name = __( 'GravityView Recent Entries', 'gravityview' ); |
|
16 | 16 | |
17 | 17 | $widget_options = array( |
18 | 18 | 'description' => __( 'Display the most recent entries for a View', 'gravityview' ), |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | private function initialize() { |
27 | 27 | |
28 | - add_action('admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts') ); |
|
28 | + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
29 | 29 | |
30 | 30 | add_action( 'wp_ajax_gv_get_view_merge_tag_data', array( $this, 'ajax_get_view_merge_tag_data' ) ); |
31 | 31 | |
@@ -38,21 +38,21 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function ajax_get_view_merge_tag_data() { |
40 | 40 | |
41 | - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajax_widget' ) ) { |
|
41 | + if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajax_widget' ) ) { |
|
42 | 42 | exit( false ); |
43 | 43 | } |
44 | 44 | |
45 | - $form_id = gravityview_get_form_id( $_POST['view_id'] ); |
|
45 | + $form_id = gravityview_get_form_id( $_POST[ 'view_id' ] ); |
|
46 | 46 | |
47 | 47 | $form = RGFormsModel::get_form_meta( $form_id ); |
48 | 48 | |
49 | 49 | $output = array( |
50 | 50 | 'form' => array( |
51 | - 'id' => $form['id'], |
|
52 | - 'title' => $form['title'], |
|
53 | - 'fields' => $form['fields'], |
|
51 | + 'id' => $form[ 'id' ], |
|
52 | + 'title' => $form[ 'title' ], |
|
53 | + 'fields' => $form[ 'fields' ], |
|
54 | 54 | ), |
55 | - 'mergeTags' => GFCommon::get_merge_tags( $form['fields'], '', false ), |
|
55 | + 'mergeTags' => GFCommon::get_merge_tags( $form[ 'fields' ], '', false ), |
|
56 | 56 | ); |
57 | 57 | |
58 | 58 | echo json_encode( $output ); |
@@ -68,19 +68,19 @@ discard block |
||
68 | 68 | function admin_enqueue_scripts() { |
69 | 69 | global $pagenow; |
70 | 70 | |
71 | - if( $pagenow === 'widgets.php' ) { |
|
71 | + if ( $pagenow === 'widgets.php' ) { |
|
72 | 72 | |
73 | - $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
|
73 | + $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
|
74 | 74 | |
75 | 75 | GravityView_Admin_Views::enqueue_gravity_forms_scripts(); |
76 | 76 | |
77 | - wp_enqueue_script( 'gravityview_widgets', plugins_url('assets/js/admin-widgets'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
77 | + wp_enqueue_script( 'gravityview_widgets', plugins_url( 'assets/js/admin-widgets' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery', 'gform_gravityforms' ), GravityView_Plugin::version ); |
|
78 | 78 | |
79 | 79 | wp_localize_script( 'gravityview_widgets', 'GVWidgets', array( |
80 | 80 | 'nonce' => wp_create_nonce( 'gravityview_ajax_widget' ) |
81 | - )); |
|
81 | + ) ); |
|
82 | 82 | |
83 | - wp_enqueue_style( 'gravityview_views_styles', plugins_url('assets/css/admin-views.css', GRAVITYVIEW_FILE), array('dashicons' ), GravityView_Plugin::version ); |
|
83 | + wp_enqueue_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons' ), GravityView_Plugin::version ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | } |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | function widget( $args, $instance ) { |
96 | 96 | |
97 | 97 | // Don't have the Customizer render too soon. |
98 | - if( empty( $instance['view_id'] ) ) { |
|
98 | + if ( empty( $instance[ 'view_id' ] ) ) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $args['id'] = ( isset( $args['id'] ) ) ? $args['id'] : 'gv_recent_entries'; |
|
103 | - $instance['title'] = ( isset( $instance['title'] ) ) ? $instance['title'] : ''; |
|
102 | + $args[ 'id' ] = ( isset( $args[ 'id' ] ) ) ? $args[ 'id' ] : 'gv_recent_entries'; |
|
103 | + $instance[ 'title' ] = ( isset( $instance[ 'title' ] ) ) ? $instance[ 'title' ] : ''; |
|
104 | 104 | |
105 | - $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args['id'] ); |
|
105 | + $title = apply_filters( 'widget_title', $instance[ 'title' ], $instance, $args[ 'id' ] ); |
|
106 | 106 | |
107 | - echo $args['before_widget']; |
|
107 | + echo $args[ 'before_widget' ]; |
|
108 | 108 | |
109 | - if ( !empty( $title ) ) { |
|
110 | - echo $args['before_title'] . $title . $args['after_title']; |
|
109 | + if ( ! empty( $title ) ) { |
|
110 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | */ |
128 | 128 | do_action( 'gravityview/widget/recent-entries/after_widget', $args, $instance ); |
129 | 129 | |
130 | - echo $args['after_widget']; |
|
130 | + echo $args[ 'after_widget' ]; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | private function get_output( $instance ) { |
143 | 143 | |
144 | - $form_id = gravityview_get_form_id( $instance['view_id'] ); |
|
144 | + $form_id = gravityview_get_form_id( $instance[ 'view_id' ] ); |
|
145 | 145 | |
146 | 146 | $form = gravityview_get_form( $form_id ); |
147 | 147 | |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * @since 1.6.1 |
152 | 152 | * @var int $entry_link_post_id The ID to use as the parent post for the entry |
153 | 153 | */ |
154 | - $entry_link_post_id = ( empty( $instance['error_post_id'] ) && !empty( $instance['post_id'] ) ) ? $instance['post_id'] : $instance['view_id']; |
|
154 | + $entry_link_post_id = ( empty( $instance[ 'error_post_id' ] ) && ! empty( $instance[ 'post_id' ] ) ) ? $instance[ 'post_id' ] : $instance[ 'view_id' ]; |
|
155 | 155 | |
156 | 156 | /** |
157 | 157 | * Generate list output |
158 | 158 | * @since 1.7.2 |
159 | 159 | */ |
160 | - $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance['link_format'], $instance['after_link'], 'recent-entries-widget' ); |
|
160 | + $List = new GravityView_Entry_List( $entries, $entry_link_post_id, $form, $instance[ 'link_format' ], $instance[ 'after_link' ], 'recent-entries-widget' ); |
|
161 | 161 | |
162 | 162 | $output = $List->get_output(); |
163 | 163 | |
@@ -182,30 +182,30 @@ discard block |
||
182 | 182 | private function get_entries( $instance, $form_id ) { |
183 | 183 | |
184 | 184 | // Get the settings for the View ID |
185 | - $view_settings = gravityview_get_template_settings( $instance['view_id'] ); |
|
185 | + $view_settings = gravityview_get_template_settings( $instance[ 'view_id' ] ); |
|
186 | 186 | |
187 | 187 | // Set the context view ID to avoid conflicts with the Advanced Filter extension. |
188 | - $criteria['context_view_id'] = $instance['view_id']; |
|
188 | + $criteria[ 'context_view_id' ] = $instance[ 'view_id' ]; |
|
189 | 189 | |
190 | - $instance['limit'] = isset( $instance['limit'] ) ? $instance['limit'] : 10; |
|
191 | - $view_settings['id'] = $instance['view_id']; |
|
192 | - $view_settings['page_size'] = $instance['limit']; |
|
190 | + $instance[ 'limit' ] = isset( $instance[ 'limit' ] ) ? $instance[ 'limit' ] : 10; |
|
191 | + $view_settings[ 'id' ] = $instance[ 'view_id' ]; |
|
192 | + $view_settings[ 'page_size' ] = $instance[ 'limit' ]; |
|
193 | 193 | |
194 | 194 | // Prepare paging criteria |
195 | - $criteria['paging'] = array( |
|
195 | + $criteria[ 'paging' ] = array( |
|
196 | 196 | 'offset' => 0, |
197 | - 'page_size' => $instance['limit'] |
|
197 | + 'page_size' => $instance[ 'limit' ] |
|
198 | 198 | ); |
199 | 199 | |
200 | 200 | // Prepare Search Criteria |
201 | - $criteria['search_criteria'] = array( 'field_filters' => array() ); |
|
202 | - $criteria['search_criteria'] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria['search_criteria']); |
|
203 | - $criteria['search_criteria']['status'] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
201 | + $criteria[ 'search_criteria' ] = array( 'field_filters' => array() ); |
|
202 | + $criteria[ 'search_criteria' ] = GravityView_frontend::process_search_only_approved( $view_settings, $criteria[ 'search_criteria' ] ); |
|
203 | + $criteria[ 'search_criteria' ][ 'status' ] = apply_filters( 'gravityview_status', 'active', $view_settings ); |
|
204 | 204 | |
205 | 205 | /** |
206 | 206 | * Modify the search parameters before the entries are fetched |
207 | 207 | */ |
208 | - $criteria = apply_filters('gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
208 | + $criteria = apply_filters( 'gravityview/widget/recent-entries/criteria', $criteria, $instance, $form_id ); |
|
209 | 209 | |
210 | 210 | $results = GVCommon::get_entries( $form_id, $criteria ); |
211 | 211 | |
@@ -226,23 +226,23 @@ discard block |
||
226 | 226 | $instance = $new_instance; |
227 | 227 | |
228 | 228 | // Force positive number |
229 | - $instance['limit'] = empty( $instance['limit'] ) ? 10 : absint( $instance['limit'] ); |
|
229 | + $instance[ 'limit' ] = empty( $instance[ 'limit' ] ) ? 10 : absint( $instance[ 'limit' ] ); |
|
230 | 230 | |
231 | - $instance['view_id'] = intval( $instance['view_id'] ); |
|
231 | + $instance[ 'view_id' ] = intval( $instance[ 'view_id' ] ); |
|
232 | 232 | |
233 | - $instance['link_format'] = trim( rtrim( $instance['link_format'] ) ); |
|
233 | + $instance[ 'link_format' ] = trim( rtrim( $instance[ 'link_format' ] ) ); |
|
234 | 234 | |
235 | - $instance['link_format'] = empty( $instance['link_format'] ) ? $old_instance['link_format'] : $instance['link_format']; |
|
235 | + $instance[ 'link_format' ] = empty( $instance[ 'link_format' ] ) ? $old_instance[ 'link_format' ] : $instance[ 'link_format' ]; |
|
236 | 236 | |
237 | - $instance['post_id'] = empty( $instance['post_id'] ) ? '' : intval( $instance['post_id'] ); |
|
237 | + $instance[ 'post_id' ] = empty( $instance[ 'post_id' ] ) ? '' : intval( $instance[ 'post_id' ] ); |
|
238 | 238 | |
239 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance['post_id'], $instance['view_id'] ); |
|
239 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $instance[ 'post_id' ], $instance[ 'view_id' ] ); |
|
240 | 240 | |
241 | 241 | //check if post_id is a valid post with embedded View |
242 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
242 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
243 | 243 | |
244 | 244 | // Share that the widget isn't brand new |
245 | - $instance['updated'] = 1; |
|
245 | + $instance[ 'updated' ] = 1; |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Modify the updated instance. This will allow for validating any added instance settings externally. |
@@ -264,22 +264,22 @@ discard block |
||
264 | 264 | |
265 | 265 | // Set up some default widget settings. |
266 | 266 | $defaults = array( |
267 | - 'title' => __('Recent Entries', 'gravityview'), |
|
267 | + 'title' => __( 'Recent Entries', 'gravityview' ), |
|
268 | 268 | 'view_id' => NULL, |
269 | 269 | 'post_id' => NULL, |
270 | 270 | 'limit' => 10, |
271 | - 'link_format' => __('Entry #{entry_id}', 'gravityview'), |
|
271 | + 'link_format' => __( 'Entry #{entry_id}', 'gravityview' ), |
|
272 | 272 | 'after_link' => '' |
273 | 273 | ); |
274 | 274 | |
275 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
275 | + $instance = wp_parse_args( (array)$instance, $defaults ); |
|
276 | 276 | |
277 | 277 | ?> |
278 | 278 | |
279 | 279 | <!-- Title --> |
280 | 280 | <p> |
281 | 281 | <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title:', 'gravityview' ) ?></label> |
282 | - <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
|
282 | + <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'title' ] ); ?>" /> |
|
283 | 283 | </p> |
284 | 284 | |
285 | 285 | <!-- Download --> |
@@ -292,8 +292,8 @@ discard block |
||
292 | 292 | $views = get_posts( $args ); |
293 | 293 | |
294 | 294 | // If there are no views set up yet, we get outta here. |
295 | - if( empty( $views ) ) { |
|
296 | - echo '<div id="select_gravityview_view"><div class="wrap">'. GravityView_Post_Types::no_views_text() .'</div></div>'; |
|
295 | + if ( empty( $views ) ) { |
|
296 | + echo '<div id="select_gravityview_view"><div class="wrap">' . GravityView_Post_Types::no_views_text() . '</div></div>'; |
|
297 | 297 | return; |
298 | 298 | } |
299 | 299 | |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | * Display errors generated for invalid embed IDs |
305 | 305 | * @see GravityView_View_Data::is_valid_embed_id |
306 | 306 | */ |
307 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
307 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
308 | 308 | ?> |
309 | 309 | <div class="error inline hide-on-view-change"> |
310 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
310 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
311 | 311 | </div> |
312 | 312 | <?php |
313 | 313 | unset ( $error ); |
@@ -315,14 +315,14 @@ discard block |
||
315 | 315 | ?> |
316 | 316 | |
317 | 317 | <p> |
318 | - <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e('Select a View', 'gravityview'); ?></label> |
|
318 | + <label for="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"><?php esc_html_e( 'Select a View', 'gravityview' ); ?></label> |
|
319 | 319 | <select class="widefat gv-recent-entries-select-view" name="<?php echo esc_attr( $this->get_field_name( 'view_id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'view_id' ) ); ?>"> |
320 | 320 | <option value=""><?php esc_html_e( '— Select a View as Entries Source —', 'gravityview' ); ?></option> |
321 | 321 | <?php |
322 | 322 | |
323 | - foreach( $views as $view ) { |
|
324 | - $title = empty( $view->post_title ) ? __('(no title)', 'gravityview') : $view->post_title; |
|
325 | - echo '<option value="'. $view->ID .'"'.selected( absint( $instance['view_id'] ), $view->ID ).'>'. esc_html( sprintf('%s #%d', $title, $view->ID ) ) .'</option>'; |
|
323 | + foreach ( $views as $view ) { |
|
324 | + $title = empty( $view->post_title ) ? __( '(no title)', 'gravityview' ) : $view->post_title; |
|
325 | + echo '<option value="' . $view->ID . '"' . selected( absint( $instance[ 'view_id' ] ), $view->ID ) . '>' . esc_html( sprintf( '%s #%d', $title, $view->ID ) ) . '</option>'; |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | ?> |
@@ -334,10 +334,10 @@ discard block |
||
334 | 334 | * Display errors generated for invalid embed IDs |
335 | 335 | * @see GravityView_View_Data::is_valid_embed_id |
336 | 336 | */ |
337 | - if( !empty( $instance['error_post_id'] ) ) { |
|
337 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
338 | 338 | ?> |
339 | 339 | <div class="error inline"> |
340 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
340 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
341 | 341 | </div> |
342 | 342 | <?php |
343 | 343 | unset ( $error ); |
@@ -345,11 +345,11 @@ discard block |
||
345 | 345 | ?> |
346 | 346 | |
347 | 347 | <p> |
348 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
349 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $instance['post_id'] ); ?>" /> |
|
348 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
349 | + <input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'post_id' ] ); ?>" /> |
|
350 | 350 | <span class="howto"><?php |
351 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
352 | - echo ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
351 | + esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
352 | + echo ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
353 | 353 | ?></span> |
354 | 354 | </p> |
355 | 355 | |
@@ -357,21 +357,21 @@ discard block |
||
357 | 357 | <label for="<?php echo $this->get_field_id( 'limit' ); ?>"> |
358 | 358 | <span><?php _e( 'Number of entries to show:', 'gravityview' ); ?></span> |
359 | 359 | </label> |
360 | - <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance['limit'] ); ?>" size="3" /> |
|
360 | + <input class="code" id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" type="number" value="<?php echo intval( $instance[ 'limit' ] ); ?>" size="3" /> |
|
361 | 361 | </p> |
362 | 362 | |
363 | 363 | <p> |
364 | 364 | <label for="<?php echo $this->get_field_id( 'link_format' ); ?>"> |
365 | 365 | <span><?php _e( 'Entry link text (required)', 'gravityview' ); ?></span> |
366 | 366 | </label> |
367 | - <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance['link_format'] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
367 | + <input id="<?php echo $this->get_field_id( 'link_format' ); ?>" name="<?php echo $this->get_field_name( 'link_format' ); ?>" type="text" value="<?php echo esc_attr( $instance[ 'link_format' ] ); ?>" class="widefat merge-tag-support mt-position-right mt-hide_all_fields" /> |
|
368 | 368 | </p> |
369 | 369 | |
370 | 370 | <p> |
371 | 371 | <label for="<?php echo $this->get_field_id( 'after_link' ); ?>"> |
372 | 372 | <span><?php _e( 'Text or HTML to display after the link (optional)', 'gravityview' ); ?></span> |
373 | 373 | </label> |
374 | - <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance['after_link'] ); ?></textarea> |
|
374 | + <textarea id="<?php echo $this->get_field_id( 'after_link' ); ?>" name="<?php echo $this->get_field_name( 'after_link' ); ?>" rows="5" class="widefat code merge-tag-support mt-position-right mt-hide_all_fields"><?php echo esc_textarea( $instance[ 'after_link' ] ); ?></textarea> |
|
375 | 375 | </p> |
376 | 376 | |
377 | 377 | <?php |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | * @param GravityView_Recent_Entries_Widget $this WP_Widget object |
382 | 382 | * @param array $instance Current widget instance |
383 | 383 | */ |
384 | - do_action( 'gravityview_recent_entries_widget_form' , $this, $instance ); |
|
384 | + do_action( 'gravityview_recent_entries_widget_form', $this, $instance ); |
|
385 | 385 | |
386 | 386 | ?> |
387 | 387 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | $widget_ops = array( |
13 | 13 | 'classname' => 'widget_gravityview_search', |
14 | - 'description' => __( 'A search form for a specific GravityView.', 'gravityview') |
|
14 | + 'description' => __( 'A search form for a specific GravityView.', 'gravityview' ) |
|
15 | 15 | ); |
16 | 16 | |
17 | 17 | $widget_display = array( |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | private function load_required_files() { |
37 | - if( !class_exists( 'GravityView_Widget_Search' ) ) { |
|
37 | + if ( ! class_exists( 'GravityView_Widget_Search' ) ) { |
|
38 | 38 | gravityview_register_gravityview_widgets(); |
39 | 39 | } |
40 | 40 | } |
@@ -42,30 +42,30 @@ discard block |
||
42 | 42 | public function widget( $args, $instance ) { |
43 | 43 | |
44 | 44 | // Don't show unless a View ID has been set. |
45 | - if( empty( $instance['view_id'] ) ) { |
|
45 | + if ( empty( $instance[ 'view_id' ] ) ) { |
|
46 | 46 | |
47 | - do_action('gravityview_log_debug', sprintf( '%s[widget]: No View ID has been defined. Not showing the widget.', get_class($this)), $instance ); |
|
47 | + do_action( 'gravityview_log_debug', sprintf( '%s[widget]: No View ID has been defined. Not showing the widget.', get_class( $this ) ), $instance ); |
|
48 | 48 | |
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | /** This filter is documented in wp-includes/default-widgets.php */ |
53 | - $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); |
|
53 | + $title = apply_filters( 'widget_title', empty( $instance[ 'title' ] ) ? '' : $instance[ 'title' ], $instance, $this->id_base ); |
|
54 | 54 | |
55 | - echo $args['before_widget']; |
|
55 | + echo $args[ 'before_widget' ]; |
|
56 | 56 | |
57 | 57 | if ( $title ) { |
58 | - echo $args['before_title'] . $title . $args['after_title']; |
|
58 | + echo $args[ 'before_title' ] . $title . $args[ 'after_title' ]; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | // @todo Add to the widget configuration form |
62 | - $instance['search_layout'] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance ); |
|
62 | + $instance[ 'search_layout' ] = apply_filters( 'gravityview/widget/search/layout', 'vertical', $instance ); |
|
63 | 63 | |
64 | - $instance['context'] = 'wp_widget'; |
|
64 | + $instance[ 'context' ] = 'wp_widget'; |
|
65 | 65 | |
66 | 66 | // form |
67 | - $instance['form_id'] = GVCommon::get_meta_form_id( $instance['view_id'] ); |
|
68 | - $instance['form'] = GVCommon::get_form( $instance['form_id'] ); |
|
67 | + $instance[ 'form_id' ] = GVCommon::get_meta_form_id( $instance[ 'view_id' ] ); |
|
68 | + $instance[ 'form' ] = GVCommon::get_form( $instance[ 'form_id' ] ); |
|
69 | 69 | |
70 | 70 | // We don't want to overwrite existing context, etc. |
71 | 71 | $previous_view = GravityView_View::getInstance(); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | new GravityView_View( $previous_view ); |
83 | 83 | |
84 | - echo $args['after_widget']; |
|
84 | + echo $args[ 'after_widget' ]; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $instance = $old_instance; |
93 | 93 | |
94 | - if( $this->is_preview() ) { |
|
94 | + if ( $this->is_preview() ) { |
|
95 | 95 | //Oh! Sorry but still not fully compatible with customizer |
96 | 96 | return $instance; |
97 | 97 | } |
@@ -104,21 +104,21 @@ discard block |
||
104 | 104 | 'search_clear' => 0 |
105 | 105 | ); |
106 | 106 | |
107 | - $new_instance = wp_parse_args( (array) $new_instance, $defaults ); |
|
107 | + $new_instance = wp_parse_args( (array)$new_instance, $defaults ); |
|
108 | 108 | |
109 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
110 | - $instance['view_id'] = absint( $new_instance['view_id'] ); |
|
111 | - $instance['search_fields'] = $new_instance['search_fields']; |
|
112 | - $instance['post_id'] = $new_instance['post_id']; |
|
113 | - $instance['search_clear'] = $new_instance['search_clear']; |
|
109 | + $instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] ); |
|
110 | + $instance[ 'view_id' ] = absint( $new_instance[ 'view_id' ] ); |
|
111 | + $instance[ 'search_fields' ] = $new_instance[ 'search_fields' ]; |
|
112 | + $instance[ 'post_id' ] = $new_instance[ 'post_id' ]; |
|
113 | + $instance[ 'search_clear' ] = $new_instance[ 'search_clear' ]; |
|
114 | 114 | |
115 | - $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $new_instance['post_id'], $instance['view_id'] ); |
|
115 | + $is_valid_embed_id = GravityView_View_Data::is_valid_embed_id( $new_instance[ 'post_id' ], $instance[ 'view_id' ] ); |
|
116 | 116 | |
117 | 117 | //check if post_id is a valid post with embedded View |
118 | - $instance['error_post_id'] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
118 | + $instance[ 'error_post_id' ] = is_wp_error( $is_valid_embed_id ) ? $is_valid_embed_id->get_error_message() : NULL; |
|
119 | 119 | |
120 | 120 | // Share that the widget isn't brand new |
121 | - $instance['updated'] = 1; |
|
121 | + $instance[ 'updated' ] = 1; |
|
122 | 122 | |
123 | 123 | return $instance; |
124 | 124 | } |
@@ -129,9 +129,9 @@ discard block |
||
129 | 129 | public function form( $instance ) { |
130 | 130 | |
131 | 131 | // @todo Make compatible with Customizer |
132 | - if( $this->is_preview() ) { |
|
132 | + if ( $this->is_preview() ) { |
|
133 | 133 | |
134 | - $warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="'.admin_url('widgets.php').'">', '</a>' ); |
|
134 | + $warning = sprintf( esc_html__( 'This widget is not configurable from this screen. Please configure it on the %sWidgets page%s.', 'gravityview' ), '<a href="' . admin_url( 'widgets.php' ) . '">', '</a>' ); |
|
135 | 135 | |
136 | 136 | echo wpautop( GravityView_Admin::get_floaty() . $warning ); |
137 | 137 | |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | 'search_clear' => 0 |
147 | 147 | ); |
148 | 148 | |
149 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
149 | + $instance = wp_parse_args( (array)$instance, $defaults ); |
|
150 | 150 | |
151 | - $title = $instance['title']; |
|
152 | - $view_id = $instance['view_id']; |
|
153 | - $post_id = $instance['post_id']; |
|
154 | - $search_fields = $instance['search_fields']; |
|
155 | - $search_clear = $instance['search_clear']; |
|
151 | + $title = $instance[ 'title' ]; |
|
152 | + $view_id = $instance[ 'view_id' ]; |
|
153 | + $post_id = $instance[ 'post_id' ]; |
|
154 | + $search_fields = $instance[ 'search_fields' ]; |
|
155 | + $search_clear = $instance[ 'search_clear' ]; |
|
156 | 156 | |
157 | 157 | $views = GVCommon::get_all_views(); |
158 | 158 | |
159 | 159 | // If there are no views set up yet, we get outta here. |
160 | - if( empty( $views ) ) { ?> |
|
160 | + if ( empty( $views ) ) { ?> |
|
161 | 161 | <div id="select_gravityview_view"> |
162 | 162 | <div class="wrap"><?php echo GravityView_Post_Types::no_views_text(); ?></div> |
163 | 163 | </div> |
@@ -165,17 +165,17 @@ discard block |
||
165 | 165 | } |
166 | 166 | ?> |
167 | 167 | |
168 | - <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'gravityview'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> |
|
168 | + <p><label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'gravityview' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></label></p> |
|
169 | 169 | |
170 | 170 | <?php |
171 | 171 | /** |
172 | 172 | * Display errors generated for invalid embed IDs |
173 | 173 | * @see GravityView_View_Data::is_valid_embed_id |
174 | 174 | */ |
175 | - if( isset( $instance['updated'] ) && empty( $instance['view_id'] ) ) { |
|
175 | + if ( isset( $instance[ 'updated' ] ) && empty( $instance[ 'view_id' ] ) ) { |
|
176 | 176 | ?> |
177 | 177 | <div class="error inline hide-on-view-change"> |
178 | - <p><?php esc_html_e('Please select a View to search.', 'gravityview'); ?></p> |
|
178 | + <p><?php esc_html_e( 'Please select a View to search.', 'gravityview' ); ?></p> |
|
179 | 179 | </div> |
180 | 180 | <?php |
181 | 181 | unset ( $error ); |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | |
185 | 185 | <p> |
186 | 186 | <label for="gravityview_view_id"><?php _e( 'View:', 'gravityview' ); ?></label> |
187 | - <select id="gravityview_view_id" name="<?php echo $this->get_field_name('view_id'); ?>" class="widefat"> |
|
187 | + <select id="gravityview_view_id" name="<?php echo $this->get_field_name( 'view_id' ); ?>" class="widefat"> |
|
188 | 188 | <option value=""><?php esc_html_e( '— Select a View —', 'gravityview' ); ?></option> |
189 | 189 | <?php |
190 | - foreach( $views as $view_option ) { |
|
191 | - $title = empty( $view_option->post_title ) ? __('(no title)', 'gravityview') : $view_option->post_title; |
|
192 | - echo '<option value="'. $view_option->ID .'" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>'. esc_html( sprintf('%s #%d', $title, $view_option->ID ) ) .'</option>'; |
|
190 | + foreach ( $views as $view_option ) { |
|
191 | + $title = empty( $view_option->post_title ) ? __( '(no title)', 'gravityview' ) : $view_option->post_title; |
|
192 | + echo '<option value="' . $view_option->ID . '" ' . selected( esc_attr( $view_id ), $view_option->ID, false ) . '>' . esc_html( sprintf( '%s #%d', $title, $view_option->ID ) ) . '</option>'; |
|
193 | 193 | } |
194 | 194 | ?> |
195 | 195 | </select> |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | * Display errors generated for invalid embed IDs |
202 | 202 | * @see GravityView_View_Data::is_valid_embed_id |
203 | 203 | */ |
204 | - if( !empty( $instance['error_post_id'] ) ) { |
|
204 | + if ( ! empty( $instance[ 'error_post_id' ] ) ) { |
|
205 | 205 | ?> |
206 | 206 | <div class="error inline"> |
207 | - <p><?php echo $instance['error_post_id']; ?></p> |
|
207 | + <p><?php echo $instance[ 'error_post_id' ]; ?></p> |
|
208 | 208 | </div> |
209 | 209 | <?php |
210 | 210 | unset ( $error ); |
@@ -212,27 +212,27 @@ discard block |
||
212 | 212 | ?> |
213 | 213 | |
214 | 214 | <p> |
215 | - <label for="<?php echo $this->get_field_id('post_id'); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
216 | - <input class="code" size="3" id="<?php echo $this->get_field_id('post_id'); ?>" name="<?php echo $this->get_field_name('post_id'); ?>" type="text" value="<?php echo esc_attr( $post_id ); ?>" /> |
|
215 | + <label for="<?php echo $this->get_field_id( 'post_id' ); ?>"><?php esc_html_e( 'If Embedded, Page ID:', 'gravityview' ); ?></label> |
|
216 | + <input class="code" size="3" id="<?php echo $this->get_field_id( 'post_id' ); ?>" name="<?php echo $this->get_field_name( 'post_id' ); ?>" type="text" value="<?php echo esc_attr( $post_id ); ?>" /> |
|
217 | 217 | <span class="howto"><?php |
218 | - esc_html_e('To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
219 | - echo ' '.gravityview_get_link('http://docs.gravityview.co/article/222-the-search-widget', __('Learn more…', 'gravityview' ), 'target=_blank' ); |
|
218 | + esc_html_e( 'To have a search performed on an embedded View, enter the ID of the post or page where the View is embedded.', 'gravityview' ); |
|
219 | + echo ' ' . gravityview_get_link( 'http://docs.gravityview.co/article/222-the-search-widget', __( 'Learn more…', 'gravityview' ), 'target=_blank' ); |
|
220 | 220 | ?></span> |
221 | 221 | </p> |
222 | 222 | |
223 | 223 | <p> |
224 | - <label for="<?php echo $this->get_field_id('search_clear'); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label> |
|
225 | - <input name="<?php echo $this->get_field_name('search_clear'); ?>" type="hidden" value="0"> |
|
226 | - <input id="<?php echo $this->get_field_id('search_clear'); ?>" name="<?php echo $this->get_field_name('search_clear'); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>> |
|
224 | + <label for="<?php echo $this->get_field_id( 'search_clear' ); ?>"><?php esc_html_e( 'Show Clear button', 'gravityview' ); ?>:</label> |
|
225 | + <input name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="hidden" value="0"> |
|
226 | + <input id="<?php echo $this->get_field_id( 'search_clear' ); ?>" name="<?php echo $this->get_field_name( 'search_clear' ); ?>" type="checkbox" class="checkbox" value="1" <?php checked( $search_clear, 1, true ); ?>> |
|
227 | 227 | </p> |
228 | 228 | |
229 | 229 | <hr /> |
230 | 230 | |
231 | 231 | <?php // @todo: move style to CSS ?> |
232 | 232 | <div style="margin-bottom: 1em;"> |
233 | - <label class="screen-reader-text" for="<?php echo $this->get_field_id('search_fields'); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label> |
|
234 | - <div class="gv-widget-search-fields" title="<?php esc_html_e('Search Fields', 'gravityview'); ?>"> |
|
235 | - <input id="<?php echo $this->get_field_id('search_fields'); ?>" name="<?php echo $this->get_field_name('search_fields'); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value"> |
|
233 | + <label class="screen-reader-text" for="<?php echo $this->get_field_id( 'search_fields' ); ?>"><?php _e( 'Searchable fields:', 'gravityview' ); ?></label> |
|
234 | + <div class="gv-widget-search-fields" title="<?php esc_html_e( 'Search Fields', 'gravityview' ); ?>"> |
|
235 | + <input id="<?php echo $this->get_field_id( 'search_fields' ); ?>" name="<?php echo $this->get_field_name( 'search_fields' ); ?>" type="hidden" value="<?php echo esc_attr( $search_fields ); ?>" class="gv-search-fields-value"> |
|
236 | 236 | </div> |
237 | 237 | |
238 | 238 | </div> |
@@ -10,17 +10,17 @@ discard block |
||
10 | 10 | /** |
11 | 11 | * @since 1.5.1 |
12 | 12 | */ |
13 | - add_action('gform_user_registered', array( $this, 'assign_new_user_to_lead'), 10, 4 ); |
|
13 | + add_action( 'gform_user_registered', array( $this, 'assign_new_user_to_lead' ), 10, 4 ); |
|
14 | 14 | |
15 | 15 | // ONLY ADMIN FROM HERE ON. |
16 | - if( !is_admin() ) { return; } |
|
16 | + if ( ! is_admin() ) { return; } |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @filter `gravityview_disable_change_entry_creator` Disable the Change Entry Creator functionality |
20 | 20 | * @since 1.7.4 |
21 | 21 | * @param boolean $disable Disable the Change Entry Creator functionality. Default: false. |
22 | 22 | */ |
23 | - if( apply_filters('gravityview_disable_change_entry_creator', false ) ) { |
|
23 | + if ( apply_filters( 'gravityview_disable_change_entry_creator', false ) ) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | * Use `init` to fix bbPress warning |
29 | 29 | * @see https://bbpress.trac.wordpress.org/ticket/2309 |
30 | 30 | */ |
31 | - add_action('init', array( $this, 'load'), 100 ); |
|
31 | + add_action( 'init', array( $this, 'load' ), 100 ); |
|
32 | 32 | |
33 | - add_action('plugins_loaded', array( $this, 'prevent_conflicts') ); |
|
33 | + add_action( 'plugins_loaded', array( $this, 'prevent_conflicts' ) ); |
|
34 | 34 | |
35 | 35 | } |
36 | 36 | |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | $assign_to_lead = apply_filters( 'gravityview_assign_new_user_to_entry', true, $user_id, $config, $entry ); |
57 | 57 | |
58 | 58 | // If filter returns false, do not process |
59 | - if( empty( $assign_to_lead ) ) { |
|
59 | + if ( empty( $assign_to_lead ) ) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // Update the entry. The `false` prevents checking Akismet; `true` disables the user updated hook from firing |
64 | - $result = RGFormsModel::update_lead_property( $entry['id'], 'created_by', $user_id, false, true ); |
|
64 | + $result = RGFormsModel::update_lead_property( $entry[ 'id' ], 'created_by', $user_id, false, true ); |
|
65 | 65 | |
66 | - if( empty( $result ) ) { |
|
67 | - $status = __('Error', 'gravityview'); |
|
66 | + if ( empty( $result ) ) { |
|
67 | + $status = __( 'Error', 'gravityview' ); |
|
68 | 68 | } else { |
69 | - $status = __('Success', 'gravityview'); |
|
69 | + $status = __( 'Success', 'gravityview' ); |
|
70 | 70 | } |
71 | 71 | |
72 | - $note = sprintf( _x('%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview'), $status, $user_id ); |
|
72 | + $note = sprintf( _x( '%s: Assigned User ID #%d as the entry creator.', 'First parameter: Success or error of the action. Second: User ID number', 'gravityview' ), $status, $user_id ); |
|
73 | 73 | |
74 | - do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - '.$note ); |
|
74 | + do_action( 'gravityview_log_debug', 'GravityView_Change_Entry_Creator[assign_new_user_to_lead] - ' . $note ); |
|
75 | 75 | |
76 | - GravityView_Entry_Notes::add_note( $entry['id'], -1, 'GravityView', $note, 'gravityview' ); |
|
76 | + GravityView_Entry_Notes::add_note( $entry[ 'id' ], -1, 'GravityView', $note, 'gravityview' ); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -85,20 +85,20 @@ discard block |
||
85 | 85 | |
86 | 86 | // Plugin that was provided here: |
87 | 87 | // @link https://gravityview.co/support/documentation/201991205/ |
88 | - remove_action("gform_entry_info", 'gravityview_change_entry_creator_form', 10, 2); |
|
89 | - remove_action("gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2); |
|
88 | + remove_action( "gform_entry_info", 'gravityview_change_entry_creator_form', 10, 2 ); |
|
89 | + remove_action( "gform_after_update_entry", 'gravityview_update_entry_creator', 10, 2 ); |
|
90 | 90 | |
91 | 91 | // Disable for Gravity Forms Add-ons 3.6.2 and lower |
92 | - if( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
92 | + if ( class_exists( 'KWS_GF_Change_Lead_Creator' ) ) { |
|
93 | 93 | |
94 | 94 | $Old_Lead_Creator = new KWS_GF_Change_Lead_Creator; |
95 | 95 | |
96 | 96 | // Now, no validation is required in the methods; let's hook in. |
97 | - remove_action('admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
97 | + remove_action( 'admin_init', array( $Old_Lead_Creator, 'set_screen_mode' ) ); |
|
98 | 98 | |
99 | - remove_action("gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2); |
|
99 | + remove_action( "gform_entry_info", array( $Old_Lead_Creator, 'add_select' ), 10, 2 ); |
|
100 | 100 | |
101 | - remove_action("gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2); |
|
101 | + remove_action( "gform_after_update_entry", array( $Old_Lead_Creator, 'update_entry_creator' ), 10, 2 ); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | } |
@@ -110,26 +110,26 @@ discard block |
||
110 | 110 | function load() { |
111 | 111 | |
112 | 112 | // Does GF exist? |
113 | - if( !class_exists('GFCommon') ) { |
|
113 | + if ( ! class_exists( 'GFCommon' ) ) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | 117 | // Can the user edit entries? |
118 | - if( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
118 | + if ( ! GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_entries' ) ) ) { |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | 122 | // If screen mode isn't set, then we're in the wrong place. |
123 | - if( empty( $_REQUEST['screen_mode'] ) ) { |
|
123 | + if ( empty( $_REQUEST[ 'screen_mode' ] ) ) { |
|
124 | 124 | return; |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Now, no validation is required in the methods; let's hook in. |
128 | - add_action('admin_init', array( &$this, 'set_screen_mode' ) ); |
|
128 | + add_action( 'admin_init', array( &$this, 'set_screen_mode' ) ); |
|
129 | 129 | |
130 | - add_action("gform_entry_info", array( &$this, 'add_select' ), 10, 2); |
|
130 | + add_action( "gform_entry_info", array( &$this, 'add_select' ), 10, 2 ); |
|
131 | 131 | |
132 | - add_action("gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2); |
|
132 | + add_action( "gform_after_update_entry", array( &$this, 'update_entry_creator' ), 10, 2 ); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | function set_screen_mode() { |
141 | 141 | |
142 | 142 | // If $_GET['screen_mode'] is set to edit, set $_POST value |
143 | - if( rgget('screen_mode') === 'edit' ) { |
|
144 | - $_POST["screen_mode"] = 'edit'; |
|
143 | + if ( rgget( 'screen_mode' ) === 'edit' ) { |
|
144 | + $_POST[ "screen_mode" ] = 'edit'; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | } |
@@ -152,42 +152,42 @@ discard block |
||
152 | 152 | * @param int $entry_id Entry ID |
153 | 153 | * @return void |
154 | 154 | */ |
155 | - function update_entry_creator($form, $entry_id) { |
|
155 | + function update_entry_creator( $form, $entry_id ) { |
|
156 | 156 | global $current_user; |
157 | 157 | |
158 | 158 | // Update the entry |
159 | - $created_by = absint( rgpost('created_by') ); |
|
159 | + $created_by = absint( rgpost( 'created_by' ) ); |
|
160 | 160 | |
161 | 161 | RGFormsModel::update_lead_property( $entry_id, 'created_by', $created_by ); |
162 | 162 | |
163 | 163 | // If the creator has changed, let's add a note about who it used to be. |
164 | - $originally_created_by = rgpost('originally_created_by'); |
|
164 | + $originally_created_by = rgpost( 'originally_created_by' ); |
|
165 | 165 | |
166 | 166 | // If there's no owner and there didn't used to be, keep going |
167 | - if( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
167 | + if ( empty( $originally_created_by ) && empty( $created_by ) ) { |
|
168 | 168 | return; |
169 | 169 | } |
170 | 170 | |
171 | 171 | // If the values have changed |
172 | - if( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
172 | + if ( absint( $originally_created_by ) !== absint( $created_by ) ) { |
|
173 | 173 | |
174 | - $user_data = get_userdata($current_user->ID); |
|
174 | + $user_data = get_userdata( $current_user->ID ); |
|
175 | 175 | |
176 | - $user_format = _x('%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview'); |
|
176 | + $user_format = _x( '%s (ID #%d)', 'The name and the ID of users who initiated changes to entry ownership', 'gravityview' ); |
|
177 | 177 | |
178 | - $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview'); |
|
178 | + $original_name = $created_by_name = esc_attr_x( 'No User', 'To show that the entry was unassigned from an actual user to no user.', 'gravityview' ); |
|
179 | 179 | |
180 | - if( !empty( $originally_created_by ) ) { |
|
181 | - $originally_created_by_user_data = get_userdata($originally_created_by); |
|
180 | + if ( ! empty( $originally_created_by ) ) { |
|
181 | + $originally_created_by_user_data = get_userdata( $originally_created_by ); |
|
182 | 182 | $original_name = sprintf( $user_format, $originally_created_by_user_data->display_name, $originally_created_by_user_data->ID ); |
183 | 183 | } |
184 | 184 | |
185 | - if( !empty( $created_by ) ) { |
|
186 | - $created_by_user_data = get_userdata($created_by); |
|
185 | + if ( ! empty( $created_by ) ) { |
|
186 | + $created_by_user_data = get_userdata( $created_by ); |
|
187 | 187 | $created_by_name = sprintf( $user_format, $created_by_user_data->display_name, $created_by_user_data->ID ); |
188 | 188 | } |
189 | 189 | |
190 | - GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __('Changed entry creator from %s to %s', 'gravityview'), $original_name, $created_by_name ), 'note' ); |
|
190 | + GravityView_Entry_Notes::add_note( $entry_id, $current_user->ID, $user_data->display_name, sprintf( __( 'Changed entry creator from %s to %s', 'gravityview' ), $original_name, $created_by_name ), 'note' ); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | } |
@@ -198,24 +198,24 @@ discard block |
||
198 | 198 | * @param array $entry GF entry array |
199 | 199 | * @return void |
200 | 200 | */ |
201 | - function add_select($form_id, $entry ) { |
|
201 | + function add_select( $form_id, $entry ) { |
|
202 | 202 | |
203 | - if( rgpost('screen_mode') !== 'edit' ) { |
|
203 | + if ( rgpost( 'screen_mode' ) !== 'edit' ) { |
|
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | 207 | $users = GVCommon::get_users( 'change_entry_creator' ); |
208 | 208 | |
209 | 209 | $output = '<label for="change_created_by">'; |
210 | - $output .= esc_html__('Change Entry Creator:', 'gravityview'); |
|
210 | + $output .= esc_html__( 'Change Entry Creator:', 'gravityview' ); |
|
211 | 211 | $output .= '</label> |
212 | 212 | <select name="created_by" id="change_created_by" class="widefat">'; |
213 | - $output .= '<option value=""> — '.esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview').' — </option>'; |
|
214 | - foreach($users as $user) { |
|
215 | - $output .= '<option value="'. $user->ID .'"'. selected( $entry['created_by'], $user->ID, false ).'>'.esc_attr( $user->display_name.' ('.$user->user_nicename.')' ).'</option>'; |
|
213 | + $output .= '<option value=""> — ' . esc_attr_x( 'No User', 'No user assigned to the entry', 'gravityview' ) . ' — </option>'; |
|
214 | + foreach ( $users as $user ) { |
|
215 | + $output .= '<option value="' . $user->ID . '"' . selected( $entry[ 'created_by' ], $user->ID, false ) . '>' . esc_attr( $user->display_name . ' (' . $user->user_nicename . ')' ) . '</option>'; |
|
216 | 216 | } |
217 | 217 | $output .= '</select>'; |
218 | - $output .= '<input name="originally_created_by" value="'.esc_attr( $entry['created_by'] ).'" type="hidden" />'; |
|
218 | + $output .= '<input name="originally_created_by" value="' . esc_attr( $entry[ 'created_by' ] ) . '" type="hidden" />'; |
|
219 | 219 | echo $output; |
220 | 220 | |
221 | 221 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | $entry = self::get_entry( $entry_slug, true ); |
126 | 126 | |
127 | - $form = self::get_form( $entry['form_id'] ); |
|
127 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
128 | 128 | |
129 | 129 | return $form; |
130 | 130 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $results = GFAPI::get_entries( 0, $search_criteria, null, $paging ); |
177 | 177 | |
178 | - $result = ( ! empty( $results ) && ! empty( $results[0]['id'] ) ) ? $results[0]['id'] : null; |
|
178 | + $result = ( ! empty( $results ) && ! empty( $results[ 0 ][ 'id' ] ) ) ? $results[ 0 ][ 'id' ] : null; |
|
179 | 179 | |
180 | 180 | return $result; |
181 | 181 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | if ( class_exists( 'GFAPI' ) ) { |
194 | 194 | $gf_forms = GFAPI::get_forms(); |
195 | 195 | foreach ( $gf_forms as $form ) { |
196 | - $forms[] = array( |
|
197 | - 'id' => $form['id'], |
|
198 | - 'title' => $form['title'], |
|
196 | + $forms[ ] = array( |
|
197 | + 'id' => $form[ 'id' ], |
|
198 | + 'title' => $form[ 'title' ], |
|
199 | 199 | ); |
200 | 200 | } |
201 | 201 | } |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | } |
228 | 228 | |
229 | 229 | if ( $form ) { |
230 | - foreach ( $form['fields'] as $field ) { |
|
231 | - if ( $include_parent_field || empty( $field['inputs'] ) ) { |
|
232 | - $fields[ $field['id'] ] = array( |
|
230 | + foreach ( $form[ 'fields' ] as $field ) { |
|
231 | + if ( $include_parent_field || empty( $field[ 'inputs' ] ) ) { |
|
232 | + $fields[ $field[ 'id' ] ] = array( |
|
233 | 233 | 'label' => rgar( $field, 'label' ), |
234 | 234 | 'parent' => null, |
235 | 235 | 'type' => rgar( $field, 'type' ), |
@@ -238,16 +238,16 @@ discard block |
||
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
241 | - if ( $add_default_properties && ! empty( $field['inputs'] ) ) { |
|
242 | - foreach ( $field['inputs'] as $input ) { |
|
241 | + if ( $add_default_properties && ! empty( $field[ 'inputs' ] ) ) { |
|
242 | + foreach ( $field[ 'inputs' ] as $input ) { |
|
243 | 243 | /** |
244 | 244 | * @hack |
245 | 245 | * In case of email/email confirmation, the input for email has the same id as the parent field |
246 | 246 | */ |
247 | - if( 'email' == rgar( $field, 'type' ) && false === strpos( $input['id'], '.' ) ) { |
|
247 | + if ( 'email' == rgar( $field, 'type' ) && false === strpos( $input[ 'id' ], '.' ) ) { |
|
248 | 248 | continue; |
249 | 249 | } |
250 | - $fields[ (string)$input['id'] ] = array( |
|
250 | + $fields[ (string)$input[ 'id' ] ] = array( |
|
251 | 251 | 'label' => rgar( $input, 'label' ), |
252 | 252 | 'customLabel' => rgar( $input, 'customLabel' ), |
253 | 253 | 'parent' => $field, |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | } |
260 | 260 | |
261 | 261 | /** @since 1.14 */ |
262 | - if( 'list' === $field['type'] && !empty( $field['enableColumns'] ) ) { |
|
262 | + if ( 'list' === $field[ 'type' ] && ! empty( $field[ 'enableColumns' ] ) ) { |
|
263 | 263 | |
264 | - foreach ( (array)$field['choices'] as $key => $input ) { |
|
264 | + foreach ( (array)$field[ 'choices' ] as $key => $input ) { |
|
265 | 265 | |
266 | - $input_id = sprintf( '%d.%d', $field['id'], $key ); // {field_id}.{column_key} |
|
266 | + $input_id = sprintf( '%d.%d', $field[ 'id' ], $key ); // {field_id}.{column_key} |
|
267 | 267 | |
268 | 268 | $fields[ $input_id ] = array( |
269 | 269 | 'label' => rgar( $input, 'text' ), |
@@ -279,25 +279,25 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * @since 1.8 |
281 | 281 | */ |
282 | - if( 'quiz' === $field['type'] ) { |
|
282 | + if ( 'quiz' === $field[ 'type' ] ) { |
|
283 | 283 | $has_quiz_fields = true; |
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
287 | 287 | * @since 1.8 |
288 | 288 | */ |
289 | - if( 'poll' === $field['type'] ) { |
|
289 | + if ( 'poll' === $field[ 'type' ] ) { |
|
290 | 290 | $has_poll_fields = true; |
291 | 291 | } |
292 | 292 | |
293 | - if( GFCommon::is_product_field( $field['type'] ) ){ |
|
293 | + if ( GFCommon::is_product_field( $field[ 'type' ] ) ) { |
|
294 | 294 | $has_product_fields = true; |
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
298 | 298 | * @hack Version 1.9 |
299 | 299 | */ |
300 | - $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object) $field : (array) $field; |
|
300 | + $field_for_is_post_field = class_exists( 'GF_Fields' ) ? (object)$field : (array)$field; |
|
301 | 301 | |
302 | 302 | if ( GFCommon::is_post_field( $field_for_is_post_field ) ) { |
303 | 303 | $has_post_fields = true; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @since 1.7 |
310 | 310 | */ |
311 | 311 | if ( $has_post_fields ) { |
312 | - $fields['post_id'] = array( |
|
312 | + $fields[ 'post_id' ] = array( |
|
313 | 313 | 'label' => __( 'Post ID', 'gravityview' ), |
314 | 314 | 'type' => 'post_id', |
315 | 315 | ); |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | $payment_fields = GravityView_Fields::get_all( 'pricing' ); |
321 | 321 | |
322 | 322 | foreach ( $payment_fields as $payment_field ) { |
323 | - if( isset( $fields["{$payment_field->name}"] ) ) { |
|
323 | + if ( isset( $fields[ "{$payment_field->name}" ] ) ) { |
|
324 | 324 | continue; |
325 | 325 | } |
326 | - $fields["{$payment_field->name}"] = array( |
|
326 | + $fields[ "{$payment_field->name}" ] = array( |
|
327 | 327 | 'label' => $payment_field->label, |
328 | 328 | 'desc' => $payment_field->description, |
329 | 329 | 'type' => $payment_field->name, |
@@ -334,24 +334,24 @@ discard block |
||
334 | 334 | /** |
335 | 335 | * @since 1.8 |
336 | 336 | */ |
337 | - if( $has_quiz_fields ) { |
|
337 | + if ( $has_quiz_fields ) { |
|
338 | 338 | |
339 | - $fields['gquiz_score'] = array( |
|
339 | + $fields[ 'gquiz_score' ] = array( |
|
340 | 340 | 'label' => __( 'Quiz Score Total', 'gravityview' ), |
341 | 341 | 'type' => 'quiz_score', |
342 | 342 | 'desc' => __( 'Displays the number of correct Quiz answers the user submitted.', 'gravityview' ), |
343 | 343 | ); |
344 | - $fields['gquiz_percent'] = array( |
|
344 | + $fields[ 'gquiz_percent' ] = array( |
|
345 | 345 | 'label' => __( 'Quiz Percentage Grade', 'gravityview' ), |
346 | 346 | 'type' => 'quiz_percent', |
347 | 347 | 'desc' => __( 'Displays the percentage of correct Quiz answers the user submitted.', 'gravityview' ), |
348 | 348 | ); |
349 | - $fields['gquiz_grade'] = array( |
|
349 | + $fields[ 'gquiz_grade' ] = array( |
|
350 | 350 | 'label' => __( 'Quiz Letter Grade', 'gravityview' ), |
351 | 351 | 'type' => 'quiz_grade', |
352 | 352 | 'desc' => __( 'Displays the Grade the user achieved based on Letter Grading configured in the Quiz Settings.', 'gravityview' ), |
353 | 353 | ); |
354 | - $fields['gquiz_is_pass'] = array( |
|
354 | + $fields[ 'gquiz_is_pass' ] = array( |
|
355 | 355 | 'label' => __( 'Quiz Pass/Fail', 'gravityview' ), |
356 | 356 | 'type' => 'quiz_is_pass', |
357 | 357 | 'desc' => __( 'Displays either Passed or Failed based on the Pass/Fail settings configured in the Quiz Settings.', 'gravityview' ), |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | |
374 | 374 | $fields = array(); |
375 | 375 | |
376 | - foreach ( $extra_fields as $key => $field ){ |
|
377 | - if ( ! empty( $only_default_column ) && ! empty( $field['is_default_column'] ) ) { |
|
378 | - $fields[ $key ] = array( 'label' => $field['label'], 'type' => 'entry_meta' ); |
|
376 | + foreach ( $extra_fields as $key => $field ) { |
|
377 | + if ( ! empty( $only_default_column ) && ! empty( $field[ 'is_default_column' ] ) ) { |
|
378 | + $fields[ $key ] = array( 'label' => $field[ 'label' ], 'type' => 'entry_meta' ); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -415,27 +415,27 @@ discard block |
||
415 | 415 | 'search_criteria' => null, |
416 | 416 | 'sorting' => null, |
417 | 417 | 'paging' => null, |
418 | - 'cache' => (isset( $passed_criteria['cache'] ) ? $passed_criteria['cache'] : true), |
|
418 | + 'cache' => ( isset( $passed_criteria[ 'cache' ] ) ? $passed_criteria[ 'cache' ] : true ), |
|
419 | 419 | ); |
420 | 420 | |
421 | 421 | $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults ); |
422 | 422 | |
423 | - if ( ! empty( $criteria['search_criteria']['field_filters'] ) ) { |
|
424 | - foreach ( $criteria['search_criteria']['field_filters'] as &$filter ) { |
|
423 | + if ( ! empty( $criteria[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
424 | + foreach ( $criteria[ 'search_criteria' ][ 'field_filters' ] as &$filter ) { |
|
425 | 425 | |
426 | 426 | if ( ! is_array( $filter ) ) { |
427 | 427 | continue; |
428 | 428 | } |
429 | 429 | |
430 | 430 | // By default, we want searches to be wildcard for each field. |
431 | - $filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator']; |
|
431 | + $filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ]; |
|
432 | 432 | |
433 | 433 | /** |
434 | 434 | * @filter `gravityview_search_operator` Modify the search operator for the field (contains, is, isnot, etc) |
435 | 435 | * @param string $operator Existing search operator |
436 | 436 | * @param array $filter array with `key`, `value`, `operator`, `type` keys |
437 | 437 | */ |
438 | - $filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter ); |
|
438 | + $filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter ); |
|
439 | 439 | } |
440 | 440 | } |
441 | 441 | |
@@ -443,21 +443,21 @@ discard block |
||
443 | 443 | * Prepare date formats to be in Gravity Forms DB format; |
444 | 444 | * $passed_criteria may include date formats incompatible with Gravity Forms. |
445 | 445 | */ |
446 | - foreach ( array('start_date', 'end_date' ) as $key ) { |
|
446 | + foreach ( array( 'start_date', 'end_date' ) as $key ) { |
|
447 | 447 | |
448 | - if ( ! empty( $criteria['search_criteria'][ $key ] ) ) { |
|
448 | + if ( ! empty( $criteria[ 'search_criteria' ][ $key ] ) ) { |
|
449 | 449 | |
450 | 450 | // Use date_create instead of new DateTime so it returns false if invalid date format. |
451 | - $date = date_create( $criteria['search_criteria'][ $key ] ); |
|
451 | + $date = date_create( $criteria[ 'search_criteria' ][ $key ] ); |
|
452 | 452 | |
453 | 453 | if ( $date ) { |
454 | 454 | // Gravity Forms wants dates in the `Y-m-d H:i:s` format. |
455 | - $criteria['search_criteria'][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
455 | + $criteria[ 'search_criteria' ][ $key ] = $date->format( 'Y-m-d H:i:s' ); |
|
456 | 456 | } else { |
457 | 457 | // If it's an invalid date, unset it. Gravity Forms freaks out otherwise. |
458 | - unset( $criteria['search_criteria'][ $key ] ); |
|
458 | + unset( $criteria[ 'search_criteria' ][ $key ] ); |
|
459 | 459 | |
460 | - do_action( 'gravityview_log_error', '[filter_get_entries_criteria] '.$key.' Date format not valid:', $criteria['search_criteria'][ $key ] ); |
|
460 | + do_action( 'gravityview_log_error', '[filter_get_entries_criteria] ' . $key . ' Date format not valid:', $criteria[ 'search_criteria' ][ $key ] ); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | } |
@@ -465,12 +465,12 @@ discard block |
||
465 | 465 | |
466 | 466 | // When multiple views are embedded, OR single entry, calculate the context view id and send it to the advanced filter |
467 | 467 | if ( class_exists( 'GravityView_View_Data' ) && GravityView_View_Data::getInstance()->has_multiple_views() || GravityView_frontend::getInstance()->getSingleEntry() ) { |
468 | - $criteria['context_view_id'] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
468 | + $criteria[ 'context_view_id' ] = GravityView_frontend::getInstance()->get_context_view_id(); |
|
469 | 469 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
470 | - $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? $_GET['view_id'] : null; |
|
471 | - } elseif( !isset( $criteria['context_view_id'] ) ) { |
|
470 | + $criteria[ 'context_view_id' ] = isset( $_GET[ 'view_id' ] ) ? $_GET[ 'view_id' ] : null; |
|
471 | + } elseif ( ! isset( $criteria[ 'context_view_id' ] ) ) { |
|
472 | 472 | // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
473 | - $criteria['context_view_id'] = null; |
|
473 | + $criteria[ 'context_view_id' ] = null; |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @param array $form_ids Forms to search |
480 | 480 | * @param int $view_id ID of the view being used to search |
481 | 481 | */ |
482 | - $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria['context_view_id'] ); |
|
482 | + $criteria = apply_filters( 'gravityview_search_criteria', $criteria, $form_ids, $criteria[ 'context_view_id' ] ); |
|
483 | 483 | |
484 | 484 | return (array)$criteria; |
485 | 485 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | /** Reduce # of database calls */ |
511 | 511 | add_filter( 'gform_is_encrypted_field', '__return_false' ); |
512 | 512 | |
513 | - if ( ! empty( $criteria['cache'] ) ) { |
|
513 | + if ( ! empty( $criteria[ 'cache' ] ) ) { |
|
514 | 514 | |
515 | 515 | $Cache = new GravityView_Cache( $form_ids, $criteria ); |
516 | 516 | |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | |
519 | 519 | // Still update the total count when using cached results |
520 | 520 | if ( ! is_null( $total ) ) { |
521 | - $total = GFAPI::count_entries( $form_ids, $criteria['search_criteria'] ); |
|
521 | + $total = GFAPI::count_entries( $form_ids, $criteria[ 'search_criteria' ] ); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | $return = $entries; |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | $entries = apply_filters( 'gravityview_before_get_entries', null, $criteria, $passed_criteria, $total ); |
539 | 539 | |
540 | 540 | // No entries returned from gravityview_before_get_entries |
541 | - if( is_null( $entries ) ) { |
|
541 | + if ( is_null( $entries ) ) { |
|
542 | 542 | |
543 | - $entries = GFAPI::get_entries( $form_ids, $criteria['search_criteria'], $criteria['sorting'], $criteria['paging'], $total ); |
|
543 | + $entries = GFAPI::get_entries( $form_ids, $criteria[ 'search_criteria' ], $criteria[ 'sorting' ], $criteria[ 'paging' ], $total ); |
|
544 | 544 | |
545 | 545 | if ( is_wp_error( $entries ) ) { |
546 | 546 | do_action( 'gravityview_log_error', $entries->get_error_message(), $entries ); |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - if ( ! empty( $criteria['cache'] ) && isset( $Cache ) ) { |
|
552 | + if ( ! empty( $criteria[ 'cache' ] ) && isset( $Cache ) ) { |
|
553 | 553 | |
554 | 554 | // Cache results |
555 | 555 | $Cache->set( $entries, 'entries' ); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | // fetch the entry |
629 | 629 | $entry = GFAPI::get_entry( $entry_id ); |
630 | 630 | |
631 | - if( $check_entry_display ) { |
|
631 | + if ( $check_entry_display ) { |
|
632 | 632 | // Is the entry allowed |
633 | 633 | $entry = self::check_entry_display( $entry ); |
634 | 634 | } |
@@ -661,12 +661,12 @@ discard block |
||
661 | 661 | |
662 | 662 | $value = false; |
663 | 663 | |
664 | - if( 'context' === $val1 ) { |
|
664 | + if ( 'context' === $val1 ) { |
|
665 | 665 | |
666 | 666 | $matching_contexts = array( $val2 ); |
667 | 667 | |
668 | 668 | // We allow for non-standard contexts. |
669 | - switch( $val2 ) { |
|
669 | + switch ( $val2 ) { |
|
670 | 670 | // Check for either single or edit |
671 | 671 | case 'singular': |
672 | 672 | $matching_contexts = array( 'single', 'edit' ); |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | return false; |
727 | 727 | } |
728 | 728 | |
729 | - if ( empty( $entry['form_id'] ) ) { |
|
729 | + if ( empty( $entry[ 'form_id' ] ) ) { |
|
730 | 730 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry is empty! Entry:', $entry ); |
731 | 731 | return false; |
732 | 732 | } |
@@ -734,26 +734,26 @@ discard block |
||
734 | 734 | $criteria = self::calculate_get_entries_criteria(); |
735 | 735 | |
736 | 736 | // Make sure the current View is connected to the same form as the Entry |
737 | - if( ! empty( $criteria['context_view_id'] ) ) { |
|
738 | - $context_view_id = intval( $criteria['context_view_id'] ); |
|
737 | + if ( ! empty( $criteria[ 'context_view_id' ] ) ) { |
|
738 | + $context_view_id = intval( $criteria[ 'context_view_id' ] ); |
|
739 | 739 | $context_form_id = gravityview_get_form_id( $context_view_id ); |
740 | - if( intval( $context_form_id ) !== intval( $entry['form_id'] ) ) { |
|
741 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry['form_id'] ), $criteria['context_view_id'] ); |
|
740 | + if ( intval( $context_form_id ) !== intval( $entry[ 'form_id' ] ) ) { |
|
741 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry form ID does not match current View connected form ID:', $entry[ 'form_id' ] ), $criteria[ 'context_view_id' ] ); |
|
742 | 742 | return false; |
743 | 743 | } |
744 | 744 | } |
745 | 745 | |
746 | - if ( empty( $criteria['search_criteria'] ) || ! is_array( $criteria['search_criteria'] ) ) { |
|
746 | + if ( empty( $criteria[ 'search_criteria' ] ) || ! is_array( $criteria[ 'search_criteria' ] ) ) { |
|
747 | 747 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No search criteria found:', $criteria ); |
748 | 748 | return $entry; |
749 | 749 | } |
750 | 750 | |
751 | - $search_criteria = $criteria['search_criteria']; |
|
751 | + $search_criteria = $criteria[ 'search_criteria' ]; |
|
752 | 752 | unset( $criteria ); |
753 | 753 | |
754 | 754 | // check entry status |
755 | - if ( array_key_exists( 'status', $search_criteria ) && $search_criteria['status'] != $entry['status'] ) { |
|
756 | - do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry['status'] ), $search_criteria ); |
|
755 | + if ( array_key_exists( 'status', $search_criteria ) && $search_criteria[ 'status' ] != $entry[ 'status' ] ) { |
|
756 | + do_action( 'gravityview_log_debug', sprintf( '[apply_filters_to_entry] Entry status - %s - is not valid according to filter:', $entry[ 'status' ] ), $search_criteria ); |
|
757 | 757 | return false; |
758 | 758 | } |
759 | 759 | |
@@ -761,37 +761,37 @@ discard block |
||
761 | 761 | // @todo: Does it make sense to apply the Date create filters to the single entry? |
762 | 762 | |
763 | 763 | // field_filters |
764 | - if ( empty( $search_criteria['field_filters'] ) || ! is_array( $search_criteria['field_filters'] ) ) { |
|
764 | + if ( empty( $search_criteria[ 'field_filters' ] ) || ! is_array( $search_criteria[ 'field_filters' ] ) ) { |
|
765 | 765 | do_action( 'gravityview_log_debug', '[apply_filters_to_entry] Entry approved! No field filters criteria found:', $search_criteria ); |
766 | 766 | return $entry; |
767 | 767 | } |
768 | 768 | |
769 | - $filters = $search_criteria['field_filters']; |
|
769 | + $filters = $search_criteria[ 'field_filters' ]; |
|
770 | 770 | unset( $search_criteria ); |
771 | 771 | |
772 | - $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters['mode'] ) : 'all'; |
|
773 | - unset( $filters['mode'] ); |
|
772 | + $mode = array_key_exists( 'mode', $filters ) ? strtolower( $filters[ 'mode' ] ) : 'all'; |
|
773 | + unset( $filters[ 'mode' ] ); |
|
774 | 774 | |
775 | - $form = self::get_form( $entry['form_id'] ); |
|
775 | + $form = self::get_form( $entry[ 'form_id' ] ); |
|
776 | 776 | |
777 | 777 | foreach ( $filters as $filter ) { |
778 | 778 | |
779 | - if ( ! isset( $filter['key'] ) ) { |
|
779 | + if ( ! isset( $filter[ 'key' ] ) ) { |
|
780 | 780 | continue; |
781 | 781 | } |
782 | 782 | |
783 | - $k = $filter['key']; |
|
783 | + $k = $filter[ 'key' ]; |
|
784 | 784 | |
785 | 785 | if ( in_array( $k, array( 'created_by', 'payment_status' ) ) ) { |
786 | 786 | $field_value = $entry[ $k ]; |
787 | 787 | $field = null; |
788 | 788 | } else { |
789 | 789 | $field = self::get_field( $form, $k ); |
790 | - $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
790 | + $field_value = GFFormsModel::get_lead_field_value( $entry, $field ); |
|
791 | 791 | } |
792 | 792 | |
793 | - $operator = isset( $filter['operator'] ) ? strtolower( $filter['operator'] ) : 'is'; |
|
794 | - $is_value_match = GFFormsModel::is_value_match( $field_value, $filter['value'], $operator, $field ); |
|
793 | + $operator = isset( $filter[ 'operator' ] ) ? strtolower( $filter[ 'operator' ] ) : 'is'; |
|
794 | + $is_value_match = GFFormsModel::is_value_match( $field_value, $filter[ 'value' ], $operator, $field ); |
|
795 | 795 | |
796 | 796 | // verify if we are already free to go! |
797 | 797 | if ( ! $is_value_match && 'all' === $mode ) { |
@@ -849,25 +849,25 @@ discard block |
||
849 | 849 | * Gravity Forms code to adjust date to locally-configured Time Zone |
850 | 850 | * @see GFCommon::format_date() for original code |
851 | 851 | */ |
852 | - $date_gmt_time = mysql2date( 'G', $date_string ); |
|
852 | + $date_gmt_time = mysql2date( 'G', $date_string ); |
|
853 | 853 | $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time ); |
854 | 854 | |
855 | - $format = rgar( $atts, 'format' ); |
|
856 | - $is_human = ! empty( $atts['human'] ); |
|
857 | - $is_diff = ! empty( $atts['diff'] ); |
|
858 | - $is_raw = ! empty( $atts['raw'] ); |
|
859 | - $is_timestamp = ! empty( $atts['timestamp'] ); |
|
860 | - $include_time = ! empty( $atts['time'] ); |
|
855 | + $format = rgar( $atts, 'format' ); |
|
856 | + $is_human = ! empty( $atts[ 'human' ] ); |
|
857 | + $is_diff = ! empty( $atts[ 'diff' ] ); |
|
858 | + $is_raw = ! empty( $atts[ 'raw' ] ); |
|
859 | + $is_timestamp = ! empty( $atts[ 'timestamp' ] ); |
|
860 | + $include_time = ! empty( $atts[ 'time' ] ); |
|
861 | 861 | |
862 | 862 | // If we're using time diff, we want to have a different default format |
863 | - if( empty( $format ) ) { |
|
863 | + if ( empty( $format ) ) { |
|
864 | 864 | $format = $is_diff ? esc_html__( '%s ago', 'gravityview' ) : get_option( 'date_format' ); |
865 | 865 | } |
866 | 866 | |
867 | 867 | // If raw was specified, don't modify the stored value |
868 | 868 | if ( $is_raw ) { |
869 | 869 | $formatted_date = $date_string; |
870 | - } elseif( $is_timestamp ) { |
|
870 | + } elseif ( $is_timestamp ) { |
|
871 | 871 | $formatted_date = $date_local_timestamp; |
872 | 872 | } elseif ( $is_diff ) { |
873 | 873 | $formatted_date = sprintf( $format, human_time_diff( $date_gmt_time ) ); |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | } |
896 | 896 | |
897 | 897 | $field = self::get_field( $form, $field_id ); |
898 | - return isset( $field['label'] ) ? $field['label'] : ''; |
|
898 | + return isset( $field[ 'label' ] ) ? $field[ 'label' ] : ''; |
|
899 | 899 | |
900 | 900 | } |
901 | 901 | |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | * @return array|null Array: Gravity Forms field array; NULL: Gravity Forms GFFormsModel does not exist |
914 | 914 | */ |
915 | 915 | public static function get_field( $form, $field_id ) { |
916 | - if ( class_exists( 'GFFormsModel' ) ){ |
|
916 | + if ( class_exists( 'GFFormsModel' ) ) { |
|
917 | 917 | return GFFormsModel::get_field( $form, $field_id ); |
918 | 918 | } else { |
919 | 919 | return null; |
@@ -960,17 +960,17 @@ discard block |
||
960 | 960 | $shortcodes = array(); |
961 | 961 | |
962 | 962 | preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER ); |
963 | - if ( empty( $matches ) ){ |
|
963 | + if ( empty( $matches ) ) { |
|
964 | 964 | return false; |
965 | 965 | } |
966 | 966 | |
967 | 967 | foreach ( $matches as $shortcode ) { |
968 | - if ( $tag === $shortcode[2] ) { |
|
968 | + if ( $tag === $shortcode[ 2 ] ) { |
|
969 | 969 | |
970 | 970 | // Changed this to $shortcode instead of true so we get the parsed atts. |
971 | - $shortcodes[] = $shortcode; |
|
971 | + $shortcodes[ ] = $shortcode; |
|
972 | 972 | |
973 | - } else if ( isset( $shortcode[5] ) && $result = self::has_shortcode_r( $shortcode[5], $tag ) ) { |
|
973 | + } else if ( isset( $shortcode[ 5 ] ) && $result = self::has_shortcode_r( $shortcode[ 5 ], $tag ) ) { |
|
974 | 974 | $shortcodes = $result; |
975 | 975 | } |
976 | 976 | } |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | * @return string html |
1122 | 1122 | */ |
1123 | 1123 | public static function get_sortable_fields( $formid, $current = '' ) { |
1124 | - $output = '<option value="" ' . selected( '', $current, false ).'>' . esc_html__( 'Default', 'gravityview' ) .'</option>'; |
|
1124 | + $output = '<option value="" ' . selected( '', $current, false ) . '>' . esc_html__( 'Default', 'gravityview' ) . '</option>'; |
|
1125 | 1125 | |
1126 | 1126 | if ( empty( $formid ) ) { |
1127 | 1127 | return $output; |
@@ -1134,11 +1134,11 @@ discard block |
||
1134 | 1134 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', array( 'list', 'textarea' ), null ); |
1135 | 1135 | |
1136 | 1136 | foreach ( $fields as $id => $field ) { |
1137 | - if ( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1137 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1138 | 1138 | continue; |
1139 | 1139 | } |
1140 | 1140 | |
1141 | - $output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'>'. esc_attr( $field['label'] ) .'</option>'; |
|
1141 | + $output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . '>' . esc_attr( $field[ 'label' ] ) . '</option>'; |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 | |
@@ -1173,9 +1173,9 @@ discard block |
||
1173 | 1173 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1174 | 1174 | |
1175 | 1175 | // TODO: Convert to using array_filter |
1176 | - foreach( $fields as $id => $field ) { |
|
1176 | + foreach ( $fields as $id => $field ) { |
|
1177 | 1177 | |
1178 | - if( in_array( $field['type'], $blacklist_field_types ) ) { |
|
1178 | + if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) { |
|
1179 | 1179 | unset( $fields[ $id ] ); |
1180 | 1180 | } |
1181 | 1181 | } |
@@ -1216,14 +1216,14 @@ discard block |
||
1216 | 1216 | * @param int|array $field field key or field array |
1217 | 1217 | * @return boolean |
1218 | 1218 | */ |
1219 | - public static function is_field_numeric( $form = null, $field = '' ) { |
|
1219 | + public static function is_field_numeric( $form = null, $field = '' ) { |
|
1220 | 1220 | |
1221 | 1221 | if ( ! is_array( $form ) && ! is_array( $field ) ) { |
1222 | 1222 | $form = self::get_form( $form ); |
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | // If entry meta, it's a string. Otherwise, numeric |
1226 | - if( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1226 | + if ( ! is_numeric( $field ) && is_string( $field ) ) { |
|
1227 | 1227 | $type = $field; |
1228 | 1228 | } else { |
1229 | 1229 | $type = self::get_field_type( $form, $field ); |
@@ -1237,9 +1237,9 @@ discard block |
||
1237 | 1237 | $numeric_types = apply_filters( 'gravityview/common/numeric_types', array( 'number', 'time' ) ); |
1238 | 1238 | |
1239 | 1239 | // Defer to GravityView_Field setting, if the field type is registered and `is_numeric` is true |
1240 | - if( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1241 | - if( true === $gv_field->is_numeric ) { |
|
1242 | - $numeric_types[] = $gv_field->is_numeric; |
|
1240 | + if ( $gv_field = GravityView_Fields::get( $type ) ) { |
|
1241 | + if ( true === $gv_field->is_numeric ) { |
|
1242 | + $numeric_types[ ] = $gv_field->is_numeric; |
|
1243 | 1243 | } |
1244 | 1244 | } |
1245 | 1245 | |
@@ -1389,11 +1389,11 @@ discard block |
||
1389 | 1389 | $final_atts = array_filter( $final_atts ); |
1390 | 1390 | |
1391 | 1391 | // If the href wasn't passed as an attribute, use the value passed to the function |
1392 | - if ( empty( $final_atts['href'] ) && ! empty( $href ) ) { |
|
1393 | - $final_atts['href'] = $href; |
|
1392 | + if ( empty( $final_atts[ 'href' ] ) && ! empty( $href ) ) { |
|
1393 | + $final_atts[ 'href' ] = $href; |
|
1394 | 1394 | } |
1395 | 1395 | |
1396 | - $final_atts['href'] = esc_url_raw( $href ); |
|
1396 | + $final_atts[ 'href' ] = esc_url_raw( $href ); |
|
1397 | 1397 | |
1398 | 1398 | // For each attribute, generate the code |
1399 | 1399 | $output = ''; |
@@ -1401,7 +1401,7 @@ discard block |
||
1401 | 1401 | $output .= sprintf( ' %s="%s"', $attr, esc_attr( $value ) ); |
1402 | 1402 | } |
1403 | 1403 | |
1404 | - $output = '<a'. $output .'>'. $anchor_text .'</a>'; |
|
1404 | + $output = '<a' . $output . '>' . $anchor_text . '</a>'; |
|
1405 | 1405 | |
1406 | 1406 | return $output; |
1407 | 1407 | } |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | public static function array_merge_recursive_distinct( array &$array1, array &$array2 ) { |
1424 | 1424 | $merged = $array1; |
1425 | 1425 | |
1426 | - foreach ( $array2 as $key => &$value ) { |
|
1426 | + foreach ( $array2 as $key => &$value ) { |
|
1427 | 1427 | if ( is_array( $value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) { |
1428 | 1428 | $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ], $value ); |
1429 | 1429 | } else { |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | * `$context` is where are we using this information (e.g. change_entry_creator, search_widget ..) |
1459 | 1459 | * @param array $settings Settings array, with `number` key defining the # of users to display |
1460 | 1460 | */ |
1461 | - $get_users_settings = apply_filters( 'gravityview/get_users/'. $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1461 | + $get_users_settings = apply_filters( 'gravityview/get_users/' . $context, apply_filters( 'gravityview_change_entry_creator_user_parameters', $get_users_settings ) ); |
|
1462 | 1462 | |
1463 | 1463 | return get_users( $get_users_settings ); |
1464 | 1464 | } |
@@ -1473,7 +1473,7 @@ discard block |
||
1473 | 1473 | * @return string |
1474 | 1474 | */ |
1475 | 1475 | public static function generate_notice( $notice, $class = '' ) { |
1476 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1476 | + return '<div class="gv-notice ' . gravityview_sanitize_html_class( $class ) . '">' . $notice . '</div>'; |
|
1477 | 1477 | } |
1478 | 1478 | |
1479 | 1479 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | var $name = 'post_category'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Post_Category'; |
15 | 15 | |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | |
23 | 23 | function field_options( $field_options, $template_id, $field_id, $context, $input_type ) { |
24 | 24 | |
25 | - if( 'edit' === $context ) { |
|
25 | + if ( 'edit' === $context ) { |
|
26 | 26 | return $field_options; |
27 | 27 | } |
28 | 28 | |
29 | - $this->add_field_support('dynamic_data', $field_options ); |
|
30 | - $this->add_field_support('link_to_term', $field_options ); |
|
29 | + $this->add_field_support( 'dynamic_data', $field_options ); |
|
30 | + $this->add_field_support( 'link_to_term', $field_options ); |
|
31 | 31 | |
32 | 32 | return $field_options; |
33 | 33 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | var $name = 'radio'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Radio'; |
15 | 15 |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | var $name = 'radio'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Radio'; |
15 | 15 |
@@ -91,16 +91,16 @@ discard block |
||
91 | 91 | function load() { |
92 | 92 | |
93 | 93 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
94 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
94 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
95 | 95 | |
96 | 96 | // Don't display an embedded form when editing an entry |
97 | 97 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
98 | 98 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
99 | 99 | |
100 | 100 | // Stop Gravity Forms processing what is ours! |
101 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
101 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
102 | 102 | |
103 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
103 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
104 | 104 | |
105 | 105 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
106 | 106 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
112 | 112 | |
113 | 113 | // Add fields expected by GFFormDisplay::validate() |
114 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
114 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @return void |
127 | 127 | */ |
128 | 128 | function prevent_render_form() { |
129 | - if( $this->is_edit_entry() ) { |
|
130 | - if( 'wp_head' === current_filter() ) { |
|
129 | + if ( $this->is_edit_entry() ) { |
|
130 | + if ( 'wp_head' === current_filter() ) { |
|
131 | 131 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
132 | 132 | } else { |
133 | 133 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -142,10 +142,10 @@ discard block |
||
142 | 142 | */ |
143 | 143 | function prevent_maybe_process_form() { |
144 | 144 | |
145 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
145 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
146 | 146 | |
147 | - if( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
148 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
147 | + if ( $this->is_edit_entry_submission() && $this->verify_nonce() ) { |
|
148 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | $gf_page = ( 'entry' === RGForms::get( 'view' ) ); |
159 | 159 | |
160 | - return ( $gf_page && isset( $_GET['edit'] ) || RGForms::post( 'action' ) === 'update' ); |
|
160 | + return ( $gf_page && isset( $_GET[ 'edit' ] ) || RGForms::post( 'action' ) === 'update' ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return boolean |
167 | 167 | */ |
168 | 168 | public function is_edit_entry_submission() { |
169 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
169 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | $entries = $gravityview_view->getEntries(); |
180 | - $this->entry = $entries[0]; |
|
180 | + $this->entry = $entries[ 0 ]; |
|
181 | 181 | |
182 | 182 | |
183 | 183 | $this->form = $gravityview_view->getForm(); |
184 | 184 | $this->form_id = $gravityview_view->getFormId(); |
185 | 185 | $this->view_id = $gravityview_view->getViewId(); |
186 | 186 | |
187 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
187 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | $this->setup_vars(); |
205 | 205 | |
206 | 206 | // Multiple Views embedded, don't proceed if nonce fails |
207 | - if( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET['edit'], self::$nonce_key ) ) { |
|
207 | + if ( $gv_data->has_multiple_views() && ! wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ) ) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | 211 | // Sorry, you're not allowed here. |
212 | - if( false === $this->user_can_edit_entry( true ) ) { |
|
212 | + if ( false === $this->user_can_edit_entry( true ) ) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | function print_scripts() { |
230 | 230 | $gravityview_view = GravityView_View::getInstance(); |
231 | 231 | |
232 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
232 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
233 | 233 | |
234 | - GFFormDisplay::enqueue_form_scripts($gravityview_view->getForm(), false); |
|
234 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
235 | 235 | |
236 | 236 | // Sack is required for images |
237 | 237 | wp_print_scripts( array( 'sack', 'gform_gravityforms' ) ); |
@@ -243,32 +243,32 @@ discard block |
||
243 | 243 | */ |
244 | 244 | function process_save() { |
245 | 245 | |
246 | - if( empty( $_POST ) ) { |
|
246 | + if ( empty( $_POST ) ) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | |
250 | 250 | // Make sure the entry, view, and form IDs are all correct |
251 | 251 | $valid = $this->verify_nonce(); |
252 | 252 | |
253 | - if( !$valid ) { |
|
254 | - do_action('gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
253 | + if ( ! $valid ) { |
|
254 | + do_action( 'gravityview_log_error', __METHOD__ . ' Nonce validation failed.' ); |
|
255 | 255 | return; |
256 | 256 | } |
257 | 257 | |
258 | - if( $this->entry['id'] !== $_POST['lid'] ) { |
|
259 | - do_action('gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
258 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
259 | + do_action( 'gravityview_log_error', __METHOD__ . ' Entry ID did not match posted entry ID.' ); |
|
260 | 260 | return; |
261 | 261 | } |
262 | 262 | |
263 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
263 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
264 | 264 | |
265 | 265 | $this->process_save_process_files( $this->form_id ); |
266 | 266 | |
267 | 267 | $this->validate(); |
268 | 268 | |
269 | - if( $this->is_valid ) { |
|
269 | + if ( $this->is_valid ) { |
|
270 | 270 | |
271 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' ); |
|
271 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[process_save] Submission is valid.' ); |
|
272 | 272 | |
273 | 273 | /** |
274 | 274 | * @hack This step is needed to unset the adminOnly from form fields |
@@ -278,12 +278,12 @@ discard block |
||
278 | 278 | /** |
279 | 279 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
280 | 280 | */ |
281 | - unset( $_GET['page'] ); |
|
281 | + unset( $_GET[ 'page' ] ); |
|
282 | 282 | |
283 | 283 | GFFormsModel::save_lead( $form, $this->entry ); |
284 | 284 | |
285 | 285 | // If there's a post associated with the entry, process post fields |
286 | - if( !empty( $this->entry['post_id'] ) ) { |
|
286 | + if ( ! empty( $this->entry[ 'post_id' ] ) ) { |
|
287 | 287 | $this->maybe_update_post_fields( $form ); |
288 | 288 | } |
289 | 289 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * @param array $form Gravity Forms form array |
296 | 296 | * @param string $entry_id Numeric ID of the entry that was updated |
297 | 297 | */ |
298 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'] ); |
|
298 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ] ); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | } // process_save |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @return mixed |
330 | 330 | */ |
331 | 331 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
332 | - if( ! $this->is_edit_entry() ) { |
|
332 | + if ( ! $this->is_edit_entry() ) { |
|
333 | 333 | return $plupload_init; |
334 | 334 | } |
335 | 335 | |
336 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
336 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
337 | 337 | |
338 | 338 | return $plupload_init; |
339 | 339 | } |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | private function form_prepare_for_save() { |
347 | 347 | $form = $this->form; |
348 | 348 | |
349 | - foreach( $form['fields'] as &$field ) { |
|
349 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
350 | 350 | |
351 | 351 | $field->adminOnly = false; |
352 | 352 | |
353 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
354 | - foreach( $field->inputs as $key => $input ) { |
|
355 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
353 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
354 | + foreach ( $field->inputs as $key => $input ) { |
|
355 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | } |
@@ -370,11 +370,11 @@ discard block |
||
370 | 370 | */ |
371 | 371 | function maybe_update_post_fields( $form ) { |
372 | 372 | |
373 | - $post_id = $this->entry['post_id']; |
|
373 | + $post_id = $this->entry[ 'post_id' ]; |
|
374 | 374 | |
375 | 375 | // Security check |
376 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
377 | - do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #'.$post_id ); |
|
376 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
377 | + do_action( 'gravityview_log_error', 'The current user does not have the ability to edit Post #' . $post_id ); |
|
378 | 378 | return; |
379 | 379 | } |
380 | 380 | |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | |
389 | 389 | $field = RGFormsModel::get_field( $form, $field_id ); |
390 | 390 | |
391 | - if( class_exists('GF_Fields') ) { |
|
391 | + if ( class_exists( 'GF_Fields' ) ) { |
|
392 | 392 | $field = GF_Fields::create( $field ); |
393 | 393 | } |
394 | 394 | |
395 | - if( GFCommon::is_post_field( $field ) ) { |
|
395 | + if ( GFCommon::is_post_field( $field ) ) { |
|
396 | 396 | |
397 | 397 | // Get the value of the field, including $_POSTed value |
398 | 398 | $value = RGFormsModel::get_field_value( $field ); |
@@ -400,12 +400,12 @@ discard block |
||
400 | 400 | // Convert the field object in 1.9 to an array for backward compatibility |
401 | 401 | $field_array = GVCommon::get_field_array( $field ); |
402 | 402 | |
403 | - switch( $field_array['type'] ) { |
|
403 | + switch ( $field_array[ 'type' ] ) { |
|
404 | 404 | |
405 | 405 | case 'post_title': |
406 | 406 | case 'post_content': |
407 | 407 | case 'post_excerpt': |
408 | - $updated_post->{$field_array['type']} = $value; |
|
408 | + $updated_post->{$field_array[ 'type' ]} = $value; |
|
409 | 409 | break; |
410 | 410 | case 'post_tags': |
411 | 411 | wp_set_post_tags( $post_id, $value, false ); |
@@ -421,24 +421,24 @@ discard block |
||
421 | 421 | $field = GFCommon::add_categories_as_choices( $field, '' ); |
422 | 422 | |
423 | 423 | // if post_category is type checkbox, then value is an array of inputs |
424 | - if( isset( $value[ strval( $field_id ) ] ) ) { |
|
425 | - foreach( $value as $input_id => $val ) { |
|
424 | + if ( isset( $value[ strval( $field_id ) ] ) ) { |
|
425 | + foreach ( $value as $input_id => $val ) { |
|
426 | 426 | $input_name = 'input_' . str_replace( '.', '_', $input_id ); |
427 | - $this->entry[ strval( $input_id ) ] = RGFormsModel::prepare_value( $form, $field, $val, $input_name, $this->entry['id'] ); |
|
427 | + $this->entry[ strval( $input_id ) ] = RGFormsModel::prepare_value( $form, $field, $val, $input_name, $this->entry[ 'id' ] ); |
|
428 | 428 | } |
429 | 429 | } else { |
430 | 430 | $input_name = 'input_' . str_replace( '.', '_', $field_id ); |
431 | - $this->entry[ strval( $field_id ) ] = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $this->entry['id'] ); |
|
431 | + $this->entry[ strval( $field_id ) ] = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $this->entry[ 'id' ] ); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | break; |
435 | 435 | case 'post_custom_field': |
436 | 436 | |
437 | 437 | $input_type = RGFormsModel::get_input_type( $field ); |
438 | - $custom_field_name = $field_array['postCustomFieldName']; |
|
438 | + $custom_field_name = $field_array[ 'postCustomFieldName' ]; |
|
439 | 439 | |
440 | 440 | // Only certain custom field types are supported |
441 | - if( !in_array( $input_type, array( 'list', 'fileupload' ) ) ) { |
|
441 | + if ( ! in_array( $input_type, array( 'list', 'fileupload' ) ) ) { |
|
442 | 442 | update_post_meta( $post_id, $custom_field_name, $value ); |
443 | 443 | } |
444 | 444 | |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | } |
453 | 453 | |
454 | 454 | //ignore fields that have not changed |
455 | - if ( $value === rgget( (string) $field_id, $this->entry ) ) { |
|
455 | + if ( $value === rgget( (string)$field_id, $this->entry ) ) { |
|
456 | 456 | continue; |
457 | 457 | } |
458 | 458 | |
459 | 459 | // update entry |
460 | - if( 'post_category' !== $field->type ) { |
|
460 | + if ( 'post_category' !== $field->type ) { |
|
461 | 461 | $this->entry[ strval( $field_id ) ] = $value; |
462 | 462 | } |
463 | 463 | |
@@ -467,24 +467,24 @@ discard block |
||
467 | 467 | |
468 | 468 | } |
469 | 469 | |
470 | - if( $update_entry ) { |
|
470 | + if ( $update_entry ) { |
|
471 | 471 | |
472 | 472 | $return_entry = GFAPI::update_entry( $this->entry ); |
473 | 473 | |
474 | - if( is_wp_error( $return_entry ) ) { |
|
474 | + if ( is_wp_error( $return_entry ) ) { |
|
475 | 475 | do_action( 'gravityview_log_error', 'Updating the entry post fields failed', $return_entry ); |
476 | 476 | } else { |
477 | - do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #'.$post_id.' succeeded' ); |
|
477 | + do_action( 'gravityview_log_debug', 'Updating the entry post fields for post #' . $post_id . ' succeeded' ); |
|
478 | 478 | } |
479 | 479 | |
480 | 480 | } |
481 | 481 | |
482 | 482 | $return_post = wp_update_post( $updated_post, true ); |
483 | 483 | |
484 | - if( is_wp_error( $return_post ) ) { |
|
484 | + if ( is_wp_error( $return_post ) ) { |
|
485 | 485 | do_action( 'gravityview_log_error', 'Updating the post content failed', $return_post ); |
486 | 486 | } else { |
487 | - do_action( 'gravityview_log_debug', 'Updating the post content for post #'.$post_id.' succeeded' ); |
|
487 | + do_action( 'gravityview_log_debug', 'Updating the post content for post #' . $post_id . ' succeeded' ); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | } |
@@ -500,18 +500,18 @@ discard block |
||
500 | 500 | */ |
501 | 501 | function after_update() { |
502 | 502 | |
503 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'] ); |
|
504 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'] ); |
|
503 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ] ); |
|
504 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ] ); |
|
505 | 505 | |
506 | 506 | // Re-define the entry now that we've updated it. |
507 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
507 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
508 | 508 | |
509 | 509 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
510 | 510 | |
511 | 511 | // We need to clear the cache because Gravity Forms caches the field values, which |
512 | 512 | // we have just updated. |
513 | - foreach ($this->form['fields'] as $key => $field) { |
|
514 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
513 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
514 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | $this->entry = $entry; |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | |
532 | 532 | <div class="gv-edit-entry-wrapper"><?php |
533 | 533 | |
534 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
534 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
535 | 535 | |
536 | 536 | /** |
537 | 537 | * Fixes weird wpautop() issue |
@@ -547,7 +547,7 @@ discard block |
||
547 | 547 | * @param string $edit_entry_title Modify the "Edit Entry" title |
548 | 548 | * @param GravityView_Edit_Entry_Render $this This object |
549 | 549 | */ |
550 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
550 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
551 | 551 | |
552 | 552 | echo esc_attr( $edit_entry_title ); |
553 | 553 | ?></span> |
@@ -556,18 +556,18 @@ discard block |
||
556 | 556 | <?php |
557 | 557 | |
558 | 558 | // Display the success message |
559 | - if( rgpost('action') === 'update' ) { |
|
559 | + if ( rgpost( 'action' ) === 'update' ) { |
|
560 | 560 | |
561 | - if( ! $this->is_valid ){ |
|
561 | + if ( ! $this->is_valid ) { |
|
562 | 562 | |
563 | 563 | // Keeping this compatible with Gravity Forms. |
564 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
565 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
564 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
565 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
566 | 566 | |
567 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
567 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
568 | 568 | |
569 | 569 | } else { |
570 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. $back_link .'">', '</a>' ); |
|
570 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . $back_link . '">', '</a>' ); |
|
571 | 571 | |
572 | 572 | /** |
573 | 573 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @param array $entry Gravity Forms entry array |
578 | 578 | * @param string $back_link URL to return to the original entry. @since 1.6 |
579 | 579 | */ |
580 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
580 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
581 | 581 | |
582 | 582 | echo GVCommon::generate_notice( $message ); |
583 | 583 | } |
@@ -634,13 +634,13 @@ discard block |
||
634 | 634 | */ |
635 | 635 | private function render_edit_form() { |
636 | 636 | |
637 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
638 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
637 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
638 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
639 | 639 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
640 | 640 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
641 | 641 | |
642 | 642 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
643 | - unset( $_GET['page'] ); |
|
643 | + unset( $_GET[ 'page' ] ); |
|
644 | 644 | |
645 | 645 | // TODO: Make sure validation isn't handled by GF |
646 | 646 | // TODO: Include CSS for file upload fields |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | // TODO: Product fields are not editable |
649 | 649 | // TODO: Check Updated and Error messages |
650 | 650 | |
651 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
651 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
652 | 652 | |
653 | 653 | remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
654 | 654 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * @return string |
665 | 665 | */ |
666 | 666 | public function render_form_buttons() { |
667 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
667 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | |
@@ -684,17 +684,17 @@ discard block |
||
684 | 684 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
685 | 685 | |
686 | 686 | // In case we have validated the form, use it to inject the validation results into the form render |
687 | - if( isset( $this->form_after_validation ) ) { |
|
687 | + if ( isset( $this->form_after_validation ) ) { |
|
688 | 688 | $form = $this->form_after_validation; |
689 | 689 | } else { |
690 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
690 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | $form = $this->filter_conditional_logic( $form ); |
694 | 694 | |
695 | 695 | // for now we don't support Save and Continue feature. |
696 | - if( ! self::$supports_save_and_continue ) { |
|
697 | - unset( $form['save'] ); |
|
696 | + if ( ! self::$supports_save_and_continue ) { |
|
697 | + unset( $form[ 'save' ] ); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | return $form; |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | |
718 | 718 | // If the form has been submitted, then we don't need to pre-fill the values, |
719 | 719 | // Except for fileupload type - run always!! |
720 | - if( |
|
720 | + if ( |
|
721 | 721 | $this->is_edit_entry_submission() && 'fileupload' !== $field->type |
722 | 722 | || GFCommon::is_product_field( $field->type ) // Prevent product fields from appearing editable |
723 | 723 | ) { |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | // Turn on Admin-style display for file upload fields only |
728 | - if( 'fileupload' === $field->type ) { |
|
729 | - $_GET['page'] = 'gf_entries'; |
|
728 | + if ( 'fileupload' === $field->type ) { |
|
729 | + $_GET[ 'page' ] = 'gf_entries'; |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -746,7 +746,7 @@ discard block |
||
746 | 746 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
747 | 747 | |
748 | 748 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
749 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
749 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
750 | 750 | |
751 | 751 | $field_value = array(); |
752 | 752 | |
@@ -755,10 +755,10 @@ discard block |
||
755 | 755 | |
756 | 756 | foreach ( (array)$field->inputs as $input ) { |
757 | 757 | |
758 | - $input_id = strval( $input['id'] ); |
|
758 | + $input_id = strval( $input[ 'id' ] ); |
|
759 | 759 | |
760 | 760 | if ( ! empty( $this->entry[ $input_id ] ) ) { |
761 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
761 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
762 | 762 | $allow_pre_populated = false; |
763 | 763 | } |
764 | 764 | |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | |
767 | 767 | $pre_value = $field->get_value_submission( array(), false ); |
768 | 768 | |
769 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !empty( $pre_value ) ) ? $field_value : $pre_value; |
|
769 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! empty( $pre_value ) ) ? $field_value : $pre_value; |
|
770 | 770 | |
771 | 771 | } else { |
772 | 772 | |
@@ -777,13 +777,13 @@ discard block |
||
777 | 777 | |
778 | 778 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
779 | 779 | // or pre-populated value if not empty and set to override saved value |
780 | - $field_value = !empty( $this->entry[ $id ] ) && ! ( $override_saved_value && !empty( $pre_value ) ) ? $this->entry[ $id ] : $pre_value; |
|
780 | + $field_value = ! empty( $this->entry[ $id ] ) && ! ( $override_saved_value && ! empty( $pre_value ) ) ? $this->entry[ $id ] : $pre_value; |
|
781 | 781 | |
782 | 782 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
783 | - if ( 'post_category' === $field->type && !empty( $field_value ) ) { |
|
783 | + if ( 'post_category' === $field->type && ! empty( $field_value ) ) { |
|
784 | 784 | $categories = array(); |
785 | 785 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
786 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
786 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
787 | 787 | } |
788 | 788 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
789 | 789 | } |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | // If there was output, it's an error |
810 | 810 | $warnings = ob_get_clean(); |
811 | 811 | |
812 | - if( !empty( $warnings ) ) { |
|
812 | + if ( ! empty( $warnings ) ) { |
|
813 | 813 | do_action( 'gravityview_log_error', __METHOD__ . $warnings, $field_value ); |
814 | 814 | } |
815 | 815 | |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | * We need the fileupload html field to render with the proper id |
819 | 819 | * ( <li id="field_80_16" ... > ) |
820 | 820 | */ |
821 | - unset( $_GET['page'] ); |
|
821 | + unset( $_GET[ 'page' ] ); |
|
822 | 822 | |
823 | 823 | return $return; |
824 | 824 | } |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | public function get_field_value( $value, $lead, $field ) { |
838 | 838 | |
839 | 839 | // The form's not being edited; use the original value |
840 | - if( ! $this->is_edit_entry_submission() ) { |
|
840 | + if ( ! $this->is_edit_entry_submission() ) { |
|
841 | 841 | return $value; |
842 | 842 | } |
843 | 843 | |
@@ -858,12 +858,12 @@ discard block |
||
858 | 858 | */ |
859 | 859 | function gform_pre_validation( $form ) { |
860 | 860 | |
861 | - if( ! $this->verify_nonce() ) { |
|
861 | + if ( ! $this->verify_nonce() ) { |
|
862 | 862 | return $form; |
863 | 863 | } |
864 | 864 | |
865 | 865 | // Fix PHP warning regarding undefined index. |
866 | - foreach ( $form['fields'] as &$field) { |
|
866 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
867 | 867 | |
868 | 868 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
869 | 869 | // expects certain field array items to be set. |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | $field['emailConfirmEnabled'] = ''; |
877 | 877 | }*/ |
878 | 878 | |
879 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
879 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
880 | 880 | |
881 | 881 | /** |
882 | 882 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -891,38 +891,38 @@ discard block |
||
891 | 891 | // Set the previous value |
892 | 892 | $entry = $this->get_entry(); |
893 | 893 | |
894 | - $input_name = 'input_'.$field->id; |
|
895 | - $form_id = $form['id']; |
|
894 | + $input_name = 'input_' . $field->id; |
|
895 | + $form_id = $form[ 'id' ]; |
|
896 | 896 | |
897 | 897 | $value = NULL; |
898 | 898 | |
899 | 899 | // Use the previous entry value as the default. |
900 | - if( isset( $entry[ $field->id ] ) ) { |
|
900 | + if ( isset( $entry[ $field->id ] ) ) { |
|
901 | 901 | $value = $entry[ $field->id ]; |
902 | 902 | } |
903 | 903 | |
904 | 904 | // If this is a single upload file |
905 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
906 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
907 | - $value = $file_path['url']; |
|
905 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
906 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
907 | + $value = $file_path[ 'url' ]; |
|
908 | 908 | |
909 | 909 | } else { |
910 | 910 | |
911 | 911 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
912 | 912 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
913 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
913 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
914 | 914 | |
915 | 915 | } |
916 | 916 | |
917 | - if( rgar($field, "multipleFiles") ) { |
|
917 | + if ( rgar( $field, "multipleFiles" ) ) { |
|
918 | 918 | |
919 | 919 | // If there are fresh uploads, process and merge them. |
920 | 920 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
921 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
921 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
922 | 922 | |
923 | 923 | $value = empty( $value ) ? '[]' : $value; |
924 | 924 | $value = stripslashes_deep( $value ); |
925 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
925 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | } else { |
@@ -938,14 +938,14 @@ discard block |
||
938 | 938 | break; |
939 | 939 | case 'number': |
940 | 940 | // Fix "undefined index" issue at line 1286 in form_display.php |
941 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
942 | - $_POST['input_'.$field->id ] = NULL; |
|
941 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
942 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
943 | 943 | } |
944 | 944 | break; |
945 | 945 | case 'captcha': |
946 | 946 | // Fix issue with recaptcha_check_answer() on line 1458 in form_display.php |
947 | - $_POST['recaptcha_challenge_field'] = NULL; |
|
948 | - $_POST['recaptcha_response_field'] = NULL; |
|
947 | + $_POST[ 'recaptcha_challenge_field' ] = NULL; |
|
948 | + $_POST[ 'recaptcha_response_field' ] = NULL; |
|
949 | 949 | break; |
950 | 950 | } |
951 | 951 | |
@@ -974,7 +974,7 @@ discard block |
||
974 | 974 | * You can enter whatever you want! |
975 | 975 | * We try validating, and customize the results using `self::custom_validation()` |
976 | 976 | */ |
977 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
977 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
978 | 978 | |
979 | 979 | // Needed by the validate funtion |
980 | 980 | $failed_validation_page = NULL; |
@@ -982,14 +982,14 @@ discard block |
||
982 | 982 | |
983 | 983 | // Prevent entry limit from running when editing an entry, also |
984 | 984 | // prevent form scheduling from preventing editing |
985 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
985 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
986 | 986 | |
987 | 987 | // Hide fields depending on Edit Entry settings |
988 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
988 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
989 | 989 | |
990 | 990 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
991 | 991 | |
992 | - remove_filter( 'gform_validation_'.$this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
992 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | |
@@ -1006,13 +1006,13 @@ discard block |
||
1006 | 1006 | */ |
1007 | 1007 | function custom_validation( $validation_results ) { |
1008 | 1008 | |
1009 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
1009 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results: ', $validation_results ); |
|
1010 | 1010 | |
1011 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
1011 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] $_POSTed data (sanitized): ', esc_html( print_r( $_POST, true ) ) ); |
|
1012 | 1012 | |
1013 | 1013 | $gv_valid = true; |
1014 | 1014 | |
1015 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1015 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1016 | 1016 | |
1017 | 1017 | $value = RGFormsModel::get_field_value( $field ); |
1018 | 1018 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1024,35 +1024,35 @@ discard block |
||
1024 | 1024 | case 'fileupload' : |
1025 | 1025 | |
1026 | 1026 | // in case nothing is uploaded but there are already files saved |
1027 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1027 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1028 | 1028 | $field->failed_validation = false; |
1029 | 1029 | unset( $field->validation_message ); |
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1033 | - if( rgar( $field, 'maxFiles') && rgar( $field, 'multipleFiles') ) { |
|
1033 | + if ( rgar( $field, 'maxFiles' ) && rgar( $field, 'multipleFiles' ) ) { |
|
1034 | 1034 | |
1035 | 1035 | $input_name = 'input_' . $field->id; |
1036 | 1036 | //uploaded |
1037 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1037 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1038 | 1038 | |
1039 | 1039 | //existent |
1040 | 1040 | $entry = $this->get_entry(); |
1041 | 1041 | $value = NULL; |
1042 | - if( isset( $entry[ $field->id ] ) ) { |
|
1042 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1043 | 1043 | $value = json_decode( $entry[ $field->id ], true ); |
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | // count uploaded files and existent entry files |
1047 | 1047 | $count_files = count( $file_names ) + count( $value ); |
1048 | 1048 | |
1049 | - if( $count_files > $field->maxFiles ) { |
|
1049 | + if ( $count_files > $field->maxFiles ) { |
|
1050 | 1050 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1051 | 1051 | $field->failed_validation = 1; |
1052 | 1052 | $gv_valid = false; |
1053 | 1053 | |
1054 | 1054 | // in case of error make sure the newest upload files are removed from the upload input |
1055 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1055 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | } |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | // This field has failed validation. |
1066 | - if( !empty( $field->failed_validation ) ) { |
|
1066 | + if ( ! empty( $field->failed_validation ) ) { |
|
1067 | 1067 | |
1068 | 1068 | do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'field' => $field, 'value' => $value ) ); |
1069 | 1069 | |
@@ -1081,32 +1081,32 @@ discard block |
||
1081 | 1081 | } |
1082 | 1082 | |
1083 | 1083 | // You can't continue inside a switch, so we do it after. |
1084 | - if( empty( $field->failed_validation ) ) { |
|
1084 | + if ( empty( $field->failed_validation ) ) { |
|
1085 | 1085 | continue; |
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | // checks if the No Duplicates option is not validating entry against itself, since |
1089 | 1089 | // we're editing a stored entry, it would also assume it's a duplicate. |
1090 | - if( !empty( $field->noDuplicates ) ) { |
|
1090 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1091 | 1091 | |
1092 | 1092 | $entry = $this->get_entry(); |
1093 | 1093 | |
1094 | 1094 | // If the value of the entry is the same as the stored value |
1095 | 1095 | // Then we can assume it's not a duplicate, it's the same. |
1096 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1096 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1097 | 1097 | //if value submitted was not changed, then don't validate |
1098 | 1098 | $field->failed_validation = false; |
1099 | 1099 | |
1100 | 1100 | unset( $field->validation_message ); |
1101 | 1101 | |
1102 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
1102 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', $entry ); |
|
1103 | 1103 | |
1104 | 1104 | continue; |
1105 | 1105 | } |
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1109 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1109 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1110 | 1110 | unset( $field->validation_message ); |
1111 | 1111 | $field->validation_message = false; |
1112 | 1112 | continue; |
@@ -1118,12 +1118,12 @@ discard block |
||
1118 | 1118 | |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - $validation_results['is_valid'] = $gv_valid; |
|
1121 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1122 | 1122 | |
1123 | - do_action('gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
1123 | + do_action( 'gravityview_log_debug', 'GravityView_Edit_Entry[custom_validation] Validation results.', $validation_results ); |
|
1124 | 1124 | |
1125 | 1125 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1126 | - $this->form_after_validation = $validation_results['form']; |
|
1126 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1127 | 1127 | |
1128 | 1128 | return $validation_results; |
1129 | 1129 | } |
@@ -1136,7 +1136,7 @@ discard block |
||
1136 | 1136 | */ |
1137 | 1137 | private function get_entry() { |
1138 | 1138 | |
1139 | - if( empty( $this->entry ) ) { |
|
1139 | + if ( empty( $this->entry ) ) { |
|
1140 | 1140 | // Get the database value of the entry that's being edited |
1141 | 1141 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1142 | 1142 | } |
@@ -1163,13 +1163,13 @@ discard block |
||
1163 | 1163 | $properties = GravityView_View_Data::getInstance()->get_fields( $view_id ); |
1164 | 1164 | |
1165 | 1165 | // If edit tab not yet configured, show all fields |
1166 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1166 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1167 | 1167 | |
1168 | 1168 | // Show hidden fields as text fields |
1169 | 1169 | $form = $this->fix_hidden_fields( $form ); |
1170 | 1170 | |
1171 | 1171 | // Hide fields depending on admin settings |
1172 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1172 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1173 | 1173 | |
1174 | 1174 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1175 | 1175 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1187,11 +1187,11 @@ discard block |
||
1187 | 1187 | private function fix_hidden_fields( $form ) { |
1188 | 1188 | |
1189 | 1189 | /** @var GF_Field $field */ |
1190 | - foreach( $form['fields'] as $key => $field ) { |
|
1191 | - if( 'hidden' === $field->type ) { |
|
1190 | + foreach ( $form[ 'fields' ] as $key => $field ) { |
|
1191 | + if ( 'hidden' === $field->type ) { |
|
1192 | 1192 | $text_field = new GF_Field_Text( $field ); |
1193 | 1193 | $text_field->type = 'text'; |
1194 | - $form['fields'][ $key ] = $text_field; |
|
1194 | + $form[ 'fields' ][ $key ] = $text_field; |
|
1195 | 1195 | } |
1196 | 1196 | } |
1197 | 1197 | |
@@ -1211,7 +1211,7 @@ discard block |
||
1211 | 1211 | */ |
1212 | 1212 | private function filter_fields( $fields, $configured_fields ) { |
1213 | 1213 | |
1214 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1214 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1215 | 1215 | return $fields; |
1216 | 1216 | } |
1217 | 1217 | |
@@ -1228,24 +1228,24 @@ discard block |
||
1228 | 1228 | */ |
1229 | 1229 | $hide_product_fields = apply_filters( 'gravityview/edit_entry/hide-product-fields', empty( self::$supports_product_fields ) ); |
1230 | 1230 | |
1231 | - if( $hide_product_fields ) { |
|
1232 | - $field_type_blacklist[] = 'option'; |
|
1233 | - $field_type_blacklist[] = 'quantity'; |
|
1234 | - $field_type_blacklist[] = 'product'; |
|
1235 | - $field_type_blacklist[] = 'total'; |
|
1236 | - $field_type_blacklist[] = 'shipping'; |
|
1237 | - $field_type_blacklist[] = 'calculation'; |
|
1231 | + if ( $hide_product_fields ) { |
|
1232 | + $field_type_blacklist[ ] = 'option'; |
|
1233 | + $field_type_blacklist[ ] = 'quantity'; |
|
1234 | + $field_type_blacklist[ ] = 'product'; |
|
1235 | + $field_type_blacklist[ ] = 'total'; |
|
1236 | + $field_type_blacklist[ ] = 'shipping'; |
|
1237 | + $field_type_blacklist[ ] = 'calculation'; |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | // First, remove blacklist |
1241 | 1241 | foreach ( $fields as $key => $field ) { |
1242 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1242 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1243 | 1243 | unset( $fields[ $key ] ); |
1244 | 1244 | } |
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | // The Edit tab has not been configured, so we return all fields by default. |
1248 | - if( empty( $configured_fields ) ) { |
|
1248 | + if ( empty( $configured_fields ) ) { |
|
1249 | 1249 | return $fields; |
1250 | 1250 | } |
1251 | 1251 | |
@@ -1255,8 +1255,8 @@ discard block |
||
1255 | 1255 | /** @var GF_Field $field */ |
1256 | 1256 | foreach ( $fields as $field ) { |
1257 | 1257 | |
1258 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1259 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1258 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1259 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1260 | 1260 | break; |
1261 | 1261 | } |
1262 | 1262 | |
@@ -1279,14 +1279,14 @@ discard block |
||
1279 | 1279 | |
1280 | 1280 | $return_field = $field; |
1281 | 1281 | |
1282 | - if( empty( $field_setting['show_label'] ) ) { |
|
1282 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1283 | 1283 | $return_field->label = ''; |
1284 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1285 | - $return_field->label = $field_setting['custom_label']; |
|
1284 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1285 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1289 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1288 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1289 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1290 | 1290 | } |
1291 | 1291 | |
1292 | 1292 | /** |
@@ -1324,11 +1324,11 @@ discard block |
||
1324 | 1324 | */ |
1325 | 1325 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1326 | 1326 | |
1327 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1327 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1328 | 1328 | return $fields; |
1329 | 1329 | } |
1330 | 1330 | |
1331 | - foreach( $fields as &$field ) { |
|
1331 | + foreach ( $fields as &$field ) { |
|
1332 | 1332 | $field->adminOnly = false; |
1333 | 1333 | } |
1334 | 1334 | |
@@ -1355,16 +1355,16 @@ discard block |
||
1355 | 1355 | */ |
1356 | 1356 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
1357 | 1357 | |
1358 | - if( $use_conditional_logic ) { |
|
1358 | + if ( $use_conditional_logic ) { |
|
1359 | 1359 | return $form; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - foreach( $form['fields'] as &$field ) { |
|
1362 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1363 | 1363 | /* @var GF_Field $field */ |
1364 | 1364 | $field->conditionalLogic = null; |
1365 | 1365 | } |
1366 | 1366 | |
1367 | - unset( $form['button']['conditionalLogic'] ); |
|
1367 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
1368 | 1368 | |
1369 | 1369 | return $form; |
1370 | 1370 | |
@@ -1381,7 +1381,7 @@ discard block |
||
1381 | 1381 | */ |
1382 | 1382 | function manage_conditional_logic( $has_conditional_logic, $form ) { |
1383 | 1383 | |
1384 | - if( ! $this->is_edit_entry() ) { |
|
1384 | + if ( ! $this->is_edit_entry() ) { |
|
1385 | 1385 | return $has_conditional_logic; |
1386 | 1386 | } |
1387 | 1387 | |
@@ -1413,44 +1413,44 @@ discard block |
||
1413 | 1413 | * 2. There are two entries embedded using oEmbed |
1414 | 1414 | * 3. One of the entries has just been saved |
1415 | 1415 | */ |
1416 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
1416 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
1417 | 1417 | |
1418 | 1418 | $error = true; |
1419 | 1419 | |
1420 | 1420 | } |
1421 | 1421 | |
1422 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
1422 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
1423 | 1423 | |
1424 | 1424 | $error = true; |
1425 | 1425 | |
1426 | - } elseif( ! $this->verify_nonce() ) { |
|
1426 | + } elseif ( ! $this->verify_nonce() ) { |
|
1427 | 1427 | |
1428 | 1428 | /** |
1429 | 1429 | * If the Entry is embedded, there may be two entries on the same page. |
1430 | 1430 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
1431 | 1431 | */ |
1432 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1432 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
1433 | 1433 | $error = true; |
1434 | 1434 | } else { |
1435 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
1435 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | } |
1439 | 1439 | |
1440 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1441 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
1440 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
1441 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
1442 | 1442 | } |
1443 | 1443 | |
1444 | - if( $this->entry['status'] === 'trash' ) { |
|
1445 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1444 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
1445 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
1446 | 1446 | } |
1447 | 1447 | |
1448 | 1448 | // No errors; everything's fine here! |
1449 | - if( empty( $error ) ) { |
|
1449 | + if ( empty( $error ) ) { |
|
1450 | 1450 | return true; |
1451 | 1451 | } |
1452 | 1452 | |
1453 | - if( $echo && $error !== true ) { |
|
1453 | + if ( $echo && $error !== true ) { |
|
1454 | 1454 | |
1455 | 1455 | $error = esc_html( $error ); |
1456 | 1456 | |
@@ -1458,13 +1458,13 @@ discard block |
||
1458 | 1458 | * @since 1.9 |
1459 | 1459 | */ |
1460 | 1460 | if ( ! empty( $this->entry ) ) { |
1461 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1461 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
1462 | 1462 | } |
1463 | 1463 | |
1464 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
1464 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
1465 | 1465 | } |
1466 | 1466 | |
1467 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
1467 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_entry]' . $error ); |
|
1468 | 1468 | |
1469 | 1469 | return false; |
1470 | 1470 | } |
@@ -1481,20 +1481,20 @@ discard block |
||
1481 | 1481 | |
1482 | 1482 | $error = NULL; |
1483 | 1483 | |
1484 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1485 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
1484 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
1485 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
1486 | 1486 | } |
1487 | 1487 | |
1488 | 1488 | // No errors; everything's fine here! |
1489 | - if( empty( $error ) ) { |
|
1489 | + if ( empty( $error ) ) { |
|
1490 | 1490 | return true; |
1491 | 1491 | } |
1492 | 1492 | |
1493 | - if( $echo ) { |
|
1494 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
1493 | + if ( $echo ) { |
|
1494 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | - do_action('gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
1497 | + do_action( 'gravityview_log_error', 'GravityView_Edit_Entry[user_can_edit_field]' . $error ); |
|
1498 | 1498 | |
1499 | 1499 | return false; |
1500 | 1500 | |
@@ -1512,15 +1512,15 @@ discard block |
||
1512 | 1512 | private function check_user_cap_edit_field( $field ) { |
1513 | 1513 | |
1514 | 1514 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
1515 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1515 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
1516 | 1516 | return true; |
1517 | 1517 | } |
1518 | 1518 | |
1519 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
1519 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
1520 | 1520 | |
1521 | 1521 | // If the field has custom editing capaibilities set, check those |
1522 | - if( $field_cap ) { |
|
1523 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
1522 | + if ( $field_cap ) { |
|
1523 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
1524 | 1524 | } |
1525 | 1525 | |
1526 | 1526 | return false; |
@@ -1534,17 +1534,17 @@ discard block |
||
1534 | 1534 | public function verify_nonce() { |
1535 | 1535 | |
1536 | 1536 | // Verify form submitted for editing single |
1537 | - if( $this->is_edit_entry_submission() ) { |
|
1537 | + if ( $this->is_edit_entry_submission() ) { |
|
1538 | 1538 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | // Verify |
1542 | - else if( ! $this->is_edit_entry() ) { |
|
1542 | + else if ( ! $this->is_edit_entry() ) { |
|
1543 | 1543 | $valid = false; |
1544 | 1544 | } |
1545 | 1545 | |
1546 | 1546 | else { |
1547 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
1547 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
1548 | 1548 | } |
1549 | 1549 | |
1550 | 1550 | /** |