Completed
Pull Request — master (#677)
by Zack
06:49 queued 02:49
created
includes/admin/metaboxes/views/single-entry.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @package GravityView
4
- * @subpackage Gravityview/admin/metaboxes/views
5
- * @global $post
6
- */
3
+		 * @package GravityView
4
+		 * @subpackage Gravityview/admin/metaboxes/views
5
+		 * @global $post
6
+		 */
7 7
 global $post;
8 8
 
9 9
 // View template settings
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-post-tags.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-checkbox.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-multiselect.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
includes/class-gravityview-settings.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -301,6 +301,7 @@
 block discarded – undo
301 301
 	 * Make protected public
302 302
 	 * @inheritDoc
303 303
 	 * @access public
304
+	 * @param string $setting_name
304 305
 	 */
305 306
 	public function get_app_setting( $setting_name ) {
306 307
 
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
                     type="' . $field['type'] . '"
419 419
                     name="' . esc_attr( $name ) . '"
420 420
                     value="' . $value . '" ' .
421
-		        implode( ' ', $attributes ) .
422
-		        ' />';
421
+				implode( ' ', $attributes ) .
422
+				' />';
423 423
 
424 424
 		if ( $echo ) {
425 425
 			echo $html;
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
 					array(
649 649
 						'label' => _x( 'Permanently Delete', 'Setting: what to do when uninstalling plugin', 'gravityview' ),
650 650
 						'value' => 'delete',
651
-					    'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ),
651
+						'tooltip' => sprintf( '<h6>%s</h6><p><span class="howto">%s</span></p><p>%s</p>', __( 'Delete all GravityView content and settings', 'gravityview' ), __( 'If you delete then re-install GravityView, it will be like installing GravityView for the first time.', 'gravityview' ), __( 'When GravityView is uninstalled and deleted, delete all Views, GravityView entry approvals, GravityView-generated entry notes (including approval and entry creator changes), and GravityView plugin settings. No Gravity Forms data will be touched.', 'gravityview' ) ),
652 652
 					),
653 653
 				),
654 654
 				'description'   => sprintf( __( 'Should GravityView content and entry approval status be removed from the site when the GravityView plugin is deleted?', 'gravityview' ), __( 'Permanently Delete', 'gravityview' ) ),
@@ -674,36 +674,36 @@  discard block
 block discarded – undo
674 674
 		}
675 675
 
676 676
 
677
-        $sections = array(
678
-            array(
679
-                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
680
-                'fields'      => $fields,
681
-            )
682
-        );
677
+		$sections = array(
678
+			array(
679
+				'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
680
+				'fields'      => $fields,
681
+			)
682
+		);
683 683
 
684
-        // custom 'update settings' button
685
-        $button = array(
686
-            'class' => 'button button-primary button-hero',
687
-            'type'     => 'save',
688
-        );
684
+		// custom 'update settings' button
685
+		$button = array(
686
+			'class' => 'button button-primary button-hero',
687
+			'type'     => 'save',
688
+		);
689 689
 
690 690
 		if( $disabled_attribute ) {
691 691
 			$button['disabled'] = $disabled_attribute;
692 692
 		}
693 693
 
694 694
 
695
-        /**
696
-         * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
697
-         * Extensions can tap in here to insert their own section and settings.
698
-         * <code>
699
-         *   $sections[] = array(
700
-         *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
701
-         *      'fields' => $settings,
702
-         *   );
703
-         * </code>
704
-         * @param array $extension_settings Empty array, ready for extension settings!
705
-         */
706
-        $extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() );
695
+		/**
696
+		 * @filter `gravityview/settings/extension/sections` Modify the GravityView settings page
697
+		 * Extensions can tap in here to insert their own section and settings.
698
+		 * <code>
699
+		 *   $sections[] = array(
700
+		 *      'title' => __( 'GravityView My Extension Settings', 'gravityview' ),
701
+		 *      'fields' => $settings,
702
+		 *   );
703
+		 * </code>
704
+		 * @param array $extension_settings Empty array, ready for extension settings!
705
+		 */
706
+		$extension_sections = apply_filters( 'gravityview/settings/extension/sections', array() );
707 707
 
708 708
 		// If there are extensions, add a section for them
709 709
 		if ( ! empty( $extension_sections ) ) {
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 				}
717 717
 			}
718 718
 
719
-            $k = count( $extension_sections ) - 1 ;
720
-            $extension_sections[ $k ]['fields'][] = $button;
719
+			$k = count( $extension_sections ) - 1 ;
720
+			$extension_sections[ $k ]['fields'][] = $button;
721 721
 			$sections = array_merge( $sections, $extension_sections );
722 722
 		} else {
723
-            // add the 'update settings' button to the general section
724
-            $sections[0]['fields'][] = $button;
725
-        }
723
+			// add the 'update settings' button to the general section
724
+			$sections[0]['fields'][] = $button;
725
+		}
726 726
 
727 727
 		return $sections;
728 728
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -441,8 +441,9 @@
 block discarded – undo
441 441
 		$field['name']  = 'gform-settings-save';
442 442
 		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
443 443
 
444
-		if ( ! rgar( $field, 'value' ) )
445
-			$field['value'] = __( 'Update Settings', 'gravityview' );
444
+		if ( ! rgar( $field, 'value' ) ) {
445
+					$field['value'] = __( 'Update Settings', 'gravityview' );
446
+		}
446 447
 
447 448
 		$output = $this->settings_submit( $field, false );
448 449
 
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if( ! class_exists('GFAddOn') ) {
3
+if ( ! class_exists( 'GFAddOn' ) ) {
4 4
 	return;
5 5
 }
6 6
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	public function __construct( $prevent_multiple_instances = '' ) {
77 77
 
78
-		if( $prevent_multiple_instances === 'get_instance' ) {
78
+		if ( $prevent_multiple_instances === 'get_instance' ) {
79 79
 			return parent::__construct();
80 80
 		}
81 81
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public static function get_instance() {
89 89
 
90
-		if( empty( self::$instance ) ) {
90
+		if ( empty( self::$instance ) ) {
91 91
 			self::$instance = new self( 'get_instance' );
92 92
 		}
93 93
 
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 		 * Prevent Gravity Forms from showing the uninstall tab on the settings page
111 111
 		 * @hack
112 112
 		 */
113
-		if( $caps === $this->_capabilities_uninstall ) {
113
+		if ( $caps === $this->_capabilities_uninstall ) {
114 114
 			return false;
115 115
 		}
116 116
 
117
-		if( empty( $caps ) ) {
117
+		if ( empty( $caps ) ) {
118 118
 			$caps = array( 'gravityview_full_access' );
119 119
 		}
120 120
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		add_filter( 'gform_addon_app_settings_menu_gravityview', array( $this, 'modify_app_settings_menu_title' ) );
138 138
 
139 139
 		/** @since 1.7.6 */
140
-		add_action('network_admin_menu', array( $this, 'add_network_menu' ) );
140
+		add_action( 'network_admin_menu', array( $this, 'add_network_menu' ) );
141 141
 
142 142
 		parent::init_admin();
143 143
 	}
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 */
152 152
 	public function modify_app_settings_menu_title( $setting_tabs ) {
153 153
 
154
-		$setting_tabs[0]['label'] = __( 'GravityView Settings', 'gravityview');
154
+		$setting_tabs[ 0 ][ 'label' ] = __( 'GravityView Settings', 'gravityview' );
155 155
 
156 156
 		return $setting_tabs;
157 157
 	}
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	private function _load_license_handler() {
170 170
 
171
-		if( !empty( $this->License_Handler ) ) {
171
+		if ( ! empty( $this->License_Handler ) ) {
172 172
 			return;
173 173
 		}
174 174
 
175
-		require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php');
175
+		require_once( GRAVITYVIEW_DIR . 'includes/class-gv-license-handler.php' );
176 176
 
177 177
 		$this->License_Handler = GV_License_Handler::get_instance( $this );
178 178
 	}
@@ -184,60 +184,60 @@  discard block
 block discarded – undo
184 184
 	function license_key_notice() {
185 185
 
186 186
 		// Only show on GravityView pages
187
-		if( ! gravityview_is_admin_page() ) {
187
+		if ( ! gravityview_is_admin_page() ) {
188 188
 			return;
189 189
 		}
190 190
 
191
-		$license_status = self::getSetting('license_key_status');
192
-		$license_id = self::getSetting('license_key');
191
+		$license_status = self::getSetting( 'license_key_status' );
192
+		$license_id = self::getSetting( 'license_key' );
193 193
 		$license_id = empty( $license_id ) ? 'license' : $license_id;
194 194
 
195
-		$message = esc_html__('Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview');
195
+		$message = esc_html__( 'Your GravityView license %s. This means you&rsquo;re missing out on updates and support! %sActivate your license%s or %sget a license here%s.', 'gravityview' );
196 196
 
197 197
 		/**
198 198
 		 * I wanted to remove the period from after the buttons in the string,
199 199
 		 * but didn't want to mess up the translation strings for the translators.
200 200
 		 */
201 201
 		$message = mb_substr( $message, 0, mb_strlen( $message ) - 1 );
202
-		$title = __('Inactive License', 'gravityview');
202
+		$title = __( 'Inactive License', 'gravityview' );
203 203
 		$status = '';
204 204
 		$update_below = false;
205 205
 		$primary_button_link = admin_url( 'edit.php?post_type=gravityview&amp;page=gravityview_settings' );
206 206
 		switch ( $license_status ) {
207 207
 			case 'invalid':
208
-				$title = __('Invalid License', 'gravityview');
209
-				$status = __('is invalid', 'gravityview');
208
+				$title = __( 'Invalid License', 'gravityview' );
209
+				$status = __( 'is invalid', 'gravityview' );
210 210
 				break;
211 211
 			case 'deactivated':
212
-				$status = __('is inactive', 'gravityview');
213
-				$update_below = __('Activate your license key below.', 'gravityview');
212
+				$status = __( 'is inactive', 'gravityview' );
213
+				$update_below = __( 'Activate your license key below.', 'gravityview' );
214 214
 				break;
215 215
 			/** @noinspection PhpMissingBreakStatementInspection */
216 216
 			case '':
217 217
 				$license_status = 'site_inactive';
218 218
 				// break intentionally left blank
219 219
 			case 'site_inactive':
220
-				$status = __('has not been activated', 'gravityview');
221
-				$update_below = __('Activate your license key below.', 'gravityview');
220
+				$status = __( 'has not been activated', 'gravityview' );
221
+				$update_below = __( 'Activate your license key below.', 'gravityview' );
222 222
 				break;
223 223
 		}
224
-		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content='.$license_status.'&utm_campaign=Admin%20Notice';
224
+		$url = 'https://gravityview.co/pricing/?utm_source=admin_notice&utm_medium=admin&utm_content=' . $license_status . '&utm_campaign=Admin%20Notice';
225 225
 
226 226
 		// Show a different notice on settings page for inactive licenses (hide the buttons)
227
-		if( $update_below && gravityview_is_admin_page( '', 'settings' ) ) {
227
+		if ( $update_below && gravityview_is_admin_page( '', 'settings' ) ) {
228 228
 			$message = sprintf( $message, $status, '<div class="hidden">', '', '', '</div><a href="#" onclick="jQuery(\'#license_key\').focus(); return false;">' . $update_below . '</a>' );
229 229
 		} else {
230 230
 			$message = sprintf( $message, $status, "\n\n" . '<a href="' . $primary_button_link . '" class="button button-primary">', '</a>', '<a href="' . esc_url( $url ) . '" class="button button-secondary">', '</a>' );
231 231
 		}
232 232
 
233
-		if( !empty( $status ) ) {
233
+		if ( ! empty( $status ) ) {
234 234
 			GravityView_Admin_Notices::add_notice( array(
235 235
 				'message' => $message,
236 236
 				'class'	=> 'updated',
237 237
 				'title' => $title,
238 238
 				'cap' => 'gravityview_edit_settings',
239
-				'dismiss' => sha1( $license_status.'_'.$license_id ),
240
-			));
239
+				'dismiss' => sha1( $license_status . '_' . $license_id ),
240
+			) );
241 241
 		}
242 242
 	}
243 243
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 		$styles = parent::styles();
251 251
 
252
-		$styles[] = array(
252
+		$styles[ ] = array(
253 253
 			'handle'  => 'gravityview_settings',
254 254
 			'src'     => plugins_url( 'assets/css/admin-settings.css', GRAVITYVIEW_FILE ),
255 255
 			'version' => GravityView_Plugin::version,
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return void
273 273
 	 */
274 274
 	public function add_network_menu() {
275
-		if( GravityView_Plugin::is_network_activated() ) {
275
+		if ( GravityView_Plugin::is_network_activated() ) {
276 276
 			add_menu_page( __( 'Settings', 'gravityview' ), __( 'GravityView', 'gravityview' ), $this->_capabilities_app_settings, "{$this->_slug}_settings", array( $this, 'app_tab_page' ), 'none' );
277 277
 		}
278 278
 	}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		 * If multisite and not network admin, we don't want the settings to show.
290 290
 		 * @since 1.7.6
291 291
 		 */
292
-		$show_submenu = !is_multisite() ||  is_main_site() || !GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() );
292
+		$show_submenu = ! is_multisite() || is_main_site() || ! GravityView_Plugin::is_network_activated() || ( is_network_admin() && GravityView_Plugin::is_network_activated() );
293 293
 
294 294
 		/**
295 295
 		 * Override whether to show the Settings menu on a per-blog basis.
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		 */
299 299
 		$show_submenu = apply_filters( 'gravityview/show-settings-menu', $show_submenu );
300 300
 
301
-		if( $show_submenu ) {
301
+		if ( $show_submenu ) {
302 302
 			add_submenu_page( 'edit.php?post_type=gravityview', __( 'Settings', 'gravityview' ), __( 'Settings', 'gravityview' ), $this->_capabilities_app_settings, $this->_slug . '_settings', array( $this, 'app_tab_page' ) );
303 303
 		}
304 304
 	}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		/**
330 330
 		 * Backward compatibility with Redux
331 331
 		 */
332
-		if( $setting_name === 'license' ) {
332
+		if ( $setting_name === 'license' ) {
333 333
 			return array(
334 334
 				'license' => parent::get_app_setting( 'license_key' ),
335 335
 				'status' => parent::get_app_setting( 'license_key_status' ),
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 
394 394
 		$return = $text . $activation;
395 395
 
396
-		if( $echo ) {
396
+		if ( $echo ) {
397 397
 			echo $return;
398 398
 		}
399 399
 
@@ -420,15 +420,15 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	public function settings_submit( $field, $echo = true ) {
422 422
 
423
-		$field['type']  = ( isset($field['type']) && in_array( $field['type'], array('submit','reset','button') ) ) ? $field['type'] : 'submit';
423
+		$field[ 'type' ] = ( isset( $field[ 'type' ] ) && in_array( $field[ 'type' ], array( 'submit', 'reset', 'button' ) ) ) ? $field[ 'type' ] : 'submit';
424 424
 
425 425
 		$attributes    = $this->get_field_attributes( $field );
426 426
 		$default_value = rgar( $field, 'value' ) ? rgar( $field, 'value' ) : rgar( $field, 'default_value' );
427
-		$value         = $this->get_setting( $field['name'], $default_value );
427
+		$value         = $this->get_setting( $field[ 'name' ], $default_value );
428 428
 
429 429
 
430
-		$attributes['class'] = isset( $attributes['class'] ) ? esc_attr( $attributes['class'] ) : 'button-primary gfbutton';
431
-		$name    = ( $field['name'] === 'gform-settings-save' ) ? $field['name'] : '_gaddon_setting_'.$field['name'];
430
+		$attributes[ 'class' ] = isset( $attributes[ 'class' ] ) ? esc_attr( $attributes[ 'class' ] ) : 'button-primary gfbutton';
431
+		$name = ( $field[ 'name' ] === 'gform-settings-save' ) ? $field[ 'name' ] : '_gaddon_setting_' . $field[ 'name' ];
432 432
 
433 433
 		if ( empty( $value ) ) {
434 434
 			$value = __( 'Update Settings', 'gravityview' );
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		$attributes = $this->get_field_attributes( $field );
438 438
 
439 439
 		$html = '<input
440
-                    type="' . $field['type'] . '"
440
+                    type="' . $field[ 'type' ] . '"
441 441
                     name="' . esc_attr( $name ) . '"
442 442
                     value="' . $value . '" ' .
443 443
 		        implode( ' ', $attributes ) .
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 	 * @return string
460 460
 	 */
461 461
 	public function settings_save( $field, $echo = true ) {
462
-		$field['type']  = 'submit';
463
-		$field['name']  = 'gform-settings-save';
464
-		$field['class'] = isset( $field['class'] ) ? $field['class'] : 'button-primary gfbutton';
462
+		$field[ 'type' ]  = 'submit';
463
+		$field[ 'name' ]  = 'gform-settings-save';
464
+		$field[ 'class' ] = isset( $field[ 'class' ] ) ? $field[ 'class' ] : 'button-primary gfbutton';
465 465
 
466 466
 		if ( ! rgar( $field, 'value' ) )
467
-			$field['value'] = __( 'Update Settings', 'gravityview' );
467
+			$field[ 'value' ] = __( 'Update Settings', 'gravityview' );
468 468
 
469 469
 		$output = $this->settings_submit( $field, false );
470 470
 
471
-		if( $echo ) {
471
+		if ( $echo ) {
472 472
 			echo $output;
473 473
 		}
474 474
 
@@ -485,8 +485,8 @@  discard block
 block discarded – undo
485 485
 		parent::single_setting_label( $field );
486 486
 
487 487
 		// Added by GravityView
488
-		if ( isset( $field['description'] ) ) {
489
-			echo '<span class="description">'. $field['description'] .'</span>';
488
+		if ( isset( $field[ 'description' ] ) ) {
489
+			echo '<span class="description">' . $field[ 'description' ] . '</span>';
490 490
 		}
491 491
 
492 492
 	}
@@ -548,11 +548,11 @@  discard block
 block discarded – undo
548 548
 
549 549
 		// If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
550 550
 		// then we assume it's changed. If it's changed, unset the status and the previous response.
551
-		if( $local_key !== $response_key ) {
551
+		if ( $local_key !== $response_key ) {
552 552
 
553
-			unset( $posted_settings['license_key_response'] );
554
-			unset( $posted_settings['license_key_status'] );
555
-			GFCommon::add_error_message( __('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
553
+			unset( $posted_settings[ 'license_key_response' ] );
554
+			unset( $posted_settings[ 'license_key_status' ] );
555
+			GFCommon::add_error_message( __( 'The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview' ) );
556 556
 		}
557 557
 
558 558
 		return $posted_settings;
@@ -587,25 +587,25 @@  discard block
 block discarded – undo
587 587
 				'label'             => __( 'License Key', 'gravityview' ),
588 588
 				'description'          => __( 'Enter the license key that was sent to you on purchase. This enables plugin updates &amp; support.', 'gravityview' ),
589 589
 				'type'              => 'edd_license',
590
-				'data-pending-text' => __('Verifying license&hellip;', 'gravityview'),
591
-				'default_value'           => $default_settings['license_key'],
590
+				'data-pending-text' => __( 'Verifying license&hellip;', 'gravityview' ),
591
+				'default_value'           => $default_settings[ 'license_key' ],
592 592
 				'class'             => ( '' == $this->get_app_setting( 'license_key' ) ) ? 'activate code regular-text edd-license-key' : 'deactivate code regular-text edd-license-key',
593 593
 			),
594 594
 			array(
595 595
 				'name'       => 'license_key_response',
596
-				'default_value'  => $default_settings['license_key_response'],
596
+				'default_value'  => $default_settings[ 'license_key_response' ],
597 597
 				'type'     => 'hidden',
598 598
 			),
599 599
 			array(
600 600
 				'name'       => 'license_key_status',
601
-				'default_value'  => $default_settings['license_key_status'],
601
+				'default_value'  => $default_settings[ 'license_key_status' ],
602 602
 				'type'     => 'hidden',
603 603
 			),
604 604
 			array(
605 605
 				'name'       => 'support-email',
606 606
 				'type'     => 'text',
607 607
 				'validate' => 'email',
608
-				'default_value'  => $default_settings['support-email'],
608
+				'default_value'  => $default_settings[ 'support-email' ],
609 609
 				'label'    => __( 'Support Email', 'gravityview' ),
610 610
 				'description' => __( 'In order to provide responses to your support requests, please provide your email address.', 'gravityview' ),
611 611
 				'class'    => 'code regular-text',
@@ -617,44 +617,44 @@  discard block
 block discarded – undo
617 617
 				'name'         => 'support_port',
618 618
 				'type'       => 'radio',
619 619
 				'label'      => __( 'Show Support Port?', 'gravityview' ),
620
-				'default_value'    => $default_settings['support_port'],
620
+				'default_value'    => $default_settings[ 'support_port' ],
621 621
 				'horizontal' => 1,
622 622
 				'choices'    => array(
623 623
 					array(
624
-						'label' => _x('Show', 'Setting: Show or Hide', 'gravityview'),
624
+						'label' => _x( 'Show', 'Setting: Show or Hide', 'gravityview' ),
625 625
 						'value' => '1',
626 626
 					),
627 627
 					array(
628
-						'label' => _x('Hide', 'Setting: Show or Hide', 'gravityview'),
628
+						'label' => _x( 'Hide', 'Setting: Show or Hide', 'gravityview' ),
629 629
 						'value' => '0',
630 630
 					),
631 631
 				),
632
-				'tooltip' => '<p><img src="' . esc_url_raw( plugins_url('assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__('The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview') . '</p>',
632
+				'tooltip' => '<p><img src="' . esc_url_raw( plugins_url( 'assets/images/screenshots/beacon.png', GRAVITYVIEW_FILE ) ) . '" alt="' . esc_attr__( 'The Support Port looks like this.', 'gravityview' ) . '" class="alignright" style="max-width:40px; margin:.5em;" />' . esc_html__( 'The Support Port provides quick access to how-to articles and tutorials. For administrators, it also makes it easy to contact support.', 'gravityview' ) . '</p>',
633 633
 				'description'   => __( 'Show the Support Port on GravityView pages?', 'gravityview' ),
634 634
 			),
635 635
 			array(
636 636
 				'name'         => 'no-conflict-mode',
637 637
 				'type'       => 'radio',
638 638
 				'label'      => __( 'No-Conflict Mode', 'gravityview' ),
639
-				'default_value'    => $default_settings['no-conflict-mode'],
639
+				'default_value'    => $default_settings[ 'no-conflict-mode' ],
640 640
 				'horizontal' => 1,
641 641
 				'choices'    => array(
642 642
 					array(
643
-						'label' => _x('On', 'Setting: On or off', 'gravityview'),
643
+						'label' => _x( 'On', 'Setting: On or off', 'gravityview' ),
644 644
 						'value' => '1',
645 645
 					),
646 646
 					array(
647
-						'label' => _x('Off', 'Setting: On or off', 'gravityview'),
647
+						'label' => _x( 'Off', 'Setting: On or off', 'gravityview' ),
648 648
 						'value' => '0',
649 649
 					),
650 650
 				),
651
-				'description'   => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __('If your Edit View tabs are ugly, enable this setting.', 'gravityview'),
651
+				'description'   => __( 'Set this to ON to prevent extraneous scripts and styles from being printed on GravityView admin pages, reducing conflicts with other plugins and themes.', 'gravityview' ) . ' ' . __( 'If your Edit View tabs are ugly, enable this setting.', 'gravityview' ),
652 652
 			),
653 653
 			array(
654 654
 				'name'       => 'delete-on-uninstall',
655 655
 				'type'       => 'radio',
656 656
 				'label'      => __( 'Remove Data on Delete?', 'gravityview' ),
657
-				'default_value'    => $default_settings['delete-on-uninstall'],
657
+				'default_value'    => $default_settings[ 'delete-on-uninstall' ],
658 658
 				'horizontal' => 1,
659 659
 				'choices'    => array(
660 660
 					array(
@@ -680,20 +680,20 @@  discard block
 block discarded – undo
680 680
 		 * @since 1.7.4
681 681
 		 */
682 682
 		foreach ( $fields as &$field ) {
683
-			$field['name']          = isset( $field['name'] ) ? $field['name'] : rgget('id', $field );
684
-			$field['label']         = isset( $field['label'] ) ? $field['label'] : rgget('title', $field );
685
-			$field['default_value'] = isset( $field['default_value'] ) ? $field['default_value'] : rgget('default', $field );
686
-			$field['description']   = isset( $field['description'] ) ? $field['description'] : rgget('subtitle', $field );
683
+			$field[ 'name' ]          = isset( $field[ 'name' ] ) ? $field[ 'name' ] : rgget( 'id', $field );
684
+			$field[ 'label' ]         = isset( $field[ 'label' ] ) ? $field[ 'label' ] : rgget( 'title', $field );
685
+			$field[ 'default_value' ] = isset( $field[ 'default_value' ] ) ? $field[ 'default_value' ] : rgget( 'default', $field );
686
+			$field[ 'description' ]   = isset( $field[ 'description' ] ) ? $field[ 'description' ] : rgget( 'subtitle', $field );
687 687
 
688
-			if( $disabled_attribute ) {
689
-				$field['disabled']  = $disabled_attribute;
688
+			if ( $disabled_attribute ) {
689
+				$field[ 'disabled' ] = $disabled_attribute;
690 690
 			}
691 691
 		}
692 692
 
693 693
 
694 694
         $sections = array(
695 695
             array(
696
-                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __('You are running GravityView version %s', 'gravityview'), GravityView_Plugin::version ) ),
696
+                'description' =>      sprintf( '<span class="version-info description">%s</span>', sprintf( __( 'You are running GravityView version %s', 'gravityview' ), GravityView_Plugin::version ) ),
697 697
                 'fields'      => $fields,
698 698
             )
699 699
         );
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
             'type'     => 'save',
705 705
         );
706 706
 
707
-		if( $disabled_attribute ) {
708
-			$button['disabled'] = $disabled_attribute;
707
+		if ( $disabled_attribute ) {
708
+			$button[ 'disabled' ] = $disabled_attribute;
709 709
 		}
710 710
 
711 711
 
@@ -725,20 +725,20 @@  discard block
 block discarded – undo
725 725
 		// If there are extensions, add a section for them
726 726
 		if ( ! empty( $extension_sections ) ) {
727 727
 
728
-			if( $disabled_attribute ) {
728
+			if ( $disabled_attribute ) {
729 729
 				foreach ( $extension_sections as &$section ) {
730
-					foreach ( $section['fields'] as &$field ) {
731
-						$field['disabled'] = $disabled_attribute;
730
+					foreach ( $section[ 'fields' ] as &$field ) {
731
+						$field[ 'disabled' ] = $disabled_attribute;
732 732
 					}
733 733
 				}
734 734
 			}
735 735
 
736
-            $k = count( $extension_sections ) - 1 ;
737
-            $extension_sections[ $k ]['fields'][] = $button;
736
+            $k = count( $extension_sections ) - 1;
737
+            $extension_sections[ $k ][ 'fields' ][ ] = $button;
738 738
 			$sections = array_merge( $sections, $extension_sections );
739 739
 		} else {
740 740
             // add the 'update settings' button to the general section
741
-            $sections[0]['fields'][] = $button;
741
+            $sections[ 0 ][ 'fields' ][ ] = $button;
742 742
         }
743 743
 
744 744
 		return $sections;
Please login to merge, or discard this patch.
includes/fields/class-gravityview-fields.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	/**
78 78
 	 * Alias for get_instance()
79 79
 	 *
80
-	 * @param $field_name
80
+	 * @param string $field_name
81 81
 	 *
82 82
 	 * @return GravityView_Field|false
83 83
 	 */
@@ -88,7 +88,6 @@  discard block
 block discarded – undo
88 88
 	/**
89 89
 	 * Alias for get_instance()
90 90
 	 *
91
-	 * @param string|GF_Field $field_name Gravity Forms field class or the class name type
92 91
 	 *
93 92
 	 * @return GravityView_Field
94 93
 	 */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @return GravityView_Field | bool
43 43
 	 */
44 44
 	public static function create( $properties ) {
45
-		$type = isset( $properties['type'] ) ? $properties['type'] : '';
46
-		$type = empty( $properties['inputType'] ) ? $type : $properties['inputType'];
45
+		$type = isset( $properties[ 'type' ] ) ? $properties[ 'type' ] : '';
46
+		$type = empty( $properties[ 'inputType' ] ) ? $type : $properties[ 'inputType' ];
47 47
 		if ( empty( $type ) || ! isset( self::$_fields[ $type ] ) ) {
48 48
 			return new GravityView_Field( $properties );
49 49
 		}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @return bool True: yes, it exists; False: nope
63 63
 	 */
64 64
 	public static function exists( $field_name ) {
65
-		return isset( self::$_fields["{$field_name}"] );
65
+		return isset( self::$_fields[ "{$field_name}" ] );
66 66
 	}
67 67
 
68 68
 	/**
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 
97 97
 		$field_type = is_a( $gf_field, 'GF_Field' ) ? get_class( $gf_field ) : $gf_field;
98 98
 
99
-		foreach( self::$_fields as $field ) {
100
-			if( $field_type === $field->_gf_field_class_name ) {
99
+		foreach ( self::$_fields as $field ) {
100
+			if ( $field_type === $field->_gf_field_class_name ) {
101 101
 				return $field;
102 102
 			}
103 103
 		}
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public static function get_all( $group = '' ) {
118 118
 
119
-		if( '' !== $group ) {
119
+		if ( '' !== $group ) {
120 120
 			$return_fields = self::$_fields;
121 121
 			foreach ( $return_fields as $key => $field ) {
122
-				if( $group !== $field->group ) {
122
+				if ( $group !== $field->group ) {
123 123
 					unset( $return_fields[ $key ] );
124 124
 				}
125 125
 			}
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-post-content.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 
23 23
 	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
24 24
 
25
-		unset( $field_options['show_as_link'] );
25
+		unset( $field_options[ 'show_as_link' ] );
26 26
 
27
-		if( 'edit' === $context ) {
27
+		if ( 'edit' === $context ) {
28 28
 			return $field_options;
29 29
 		}
30 30
 
31
-		$this->add_field_support('dynamic_data', $field_options );
31
+		$this->add_field_support( 'dynamic_data', $field_options );
32 32
 
33 33
 		return $field_options;
34 34
 	}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function get_field_input( $form, $value = '', $entry = null, GF_Field_Post_Content $field ) {
46 46
 
47
-		$id    = (int) $field->id;
47
+		$id    = (int)$field->id;
48 48
 		$input_name = "input_{$id}";
49 49
 		$class = esc_attr( $field->size );
50 50
 		$tabindex = $field->get_tabindex();
Please login to merge, or discard this patch.
includes/class-gravityview-gfformsmodel.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -7,181 +7,181 @@
 block discarded – undo
7 7
 
8 8
 class GravityView_GFFormsModel extends GFFormsModel {
9 9
 
10
-    /**
11
-     * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private.
12
-     *
13
-     * @since 1.16.2
14
-     *
15
-     * @param string $url URL of the post image to update
16
-     * @param int $post_id ID of the post image to update
17
-     * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path.
18
-     */
19
-    public static function copy_post_image( $url, $post_id ) {
20
-
21
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' );
22
-
23
-        /**
24
-         * If the method changes to public, use Gravity Forms' method
25
-         * @todo: If/when the method is public, remove the unneeded copied code.
26
-         */
27
-        if( $reflection->isPublic() ) {
28
-            return parent::copy_post_image( $url, $post_id );
29
-        }
30
-
31
-        /**
32
-         * Original Gravity Forms code below:
33
-         * ==================================
34
-         */
35
-
36
-        $time = current_time( 'mysql' );
37
-
38
-        if ( $post = get_post( $post_id ) ) {
39
-            if ( substr( $post->post_date, 0, 4 ) > 0 ) {
40
-                $time = $post->post_date;
41
-            }
42
-        }
43
-
44
-        //making sure there is a valid upload folder
45
-        if ( ! ( ( $upload_dir = wp_upload_dir( $time ) ) && false === $upload_dir['error'] ) ) {
46
-            return false;
47
-        }
48
-
49
-        $form_id = get_post_meta( $post_id, '_gform-form-id', true );
50
-
51
-        /**
52
-         * Filter the media upload location.
53
-         *
54
-         * @param array $upload_dir The current upload directory’s path and url.
55
-         * @param int $form_id The ID of the form currently being processed.
56
-         * @param int $post_id The ID of the post created from the entry currently being processed.
57
-         */
58
-        $upload_dir = gf_apply_filters( 'gform_media_upload_path', $form_id, $upload_dir, $form_id, $post_id );
59
-
60
-        if ( ! file_exists( $upload_dir['path'] ) ) {
61
-            if ( ! wp_mkdir_p( $upload_dir['path'] ) ) {
62
-                return false;
63
-            }
64
-        }
65
-
66
-        $name     = basename( $url );
67
-        $filename = wp_unique_filename( $upload_dir['path'], $name );
68
-
69
-        // the destination path
70
-        $new_file = $upload_dir['path'] . "/$filename";
71
-
72
-        // the source path
73
-        $y                = substr( $time, 0, 4 );
74
-        $m                = substr( $time, 5, 2 );
75
-        $target_root      = RGFormsModel::get_upload_path( $form_id ) . "/$y/$m/";
76
-        $target_root_url  = RGFormsModel::get_upload_url( $form_id ) . "/$y/$m/";
77
-        $upload_root_info = array( 'path' => $target_root, 'url' => $target_root_url );
78
-        $upload_root_info = gf_apply_filters( 'gform_upload_path', $form_id, $upload_root_info, $form_id );
79
-        $path             = str_replace( $upload_root_info['url'], $upload_root_info['path'], $url );
80
-
81
-        // copy the file to the destination path
82
-        if ( ! copy( $path, $new_file ) ) {
83
-            return false;
84
-        }
85
-
86
-        // Set correct file permissions
87
-        $stat  = stat( dirname( $new_file ) );
88
-        $perms = $stat['mode'] & 0000666;
89
-        @ chmod( $new_file, $perms );
90
-
91
-        // Compute the URL
92
-        $url = $upload_dir['url'] . "/$filename";
93
-
94
-        if ( is_multisite() ) {
95
-            delete_transient( 'dirsize_cache' );
96
-        }
97
-
98
-        $type = wp_check_filetype( $new_file );
99
-
100
-        return array( 'file' => $new_file, 'url' => $url, 'type' => $type['type'] );
101
-
102
-    }
103
-
104
-    /**
105
-     * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private.
106
-     *
107
-     * @see GFFormsModel::media_handle_upload
108
-     * @see GravityView_Edit_Entry_Render::maybe_update_post_fields
109
-     * 
110
-     * @uses copy_post_image
111
-     * @uses wp_insert_attachment
112
-     * @uses wp_update_attachment_metadata
113
-     *
114
-     * @param string $url URL of the post image to update
115
-     * @param int $post_id ID of the post image to update
116
-     * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys.
117
-     * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image
118
-     */
119
-    public static function media_handle_upload( $url, $post_id, $post_data = array() ) {
120
-
121
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' );
122
-
123
-        /**
124
-         * If the method changes to public, use Gravity Forms' method
125
-         * @todo: If/when the method is public, remove the unneeded copied code.
126
-         */
127
-        if( $reflection->isPublic() ) {
128
-            return parent::media_handle_upload( $url, $post_id, $post_data );
129
-        }
130
-
131
-        /**
132
-         * Original Gravity Forms code below:
133
-         * ==================================
134
-         */
135
-
136
-        //WordPress Administration API required for the media_handle_upload() function
137
-        require_once( ABSPATH . 'wp-admin/includes/image.php' );
138
-
139
-        $name = basename( $url );
140
-
141
-        $file = self::copy_post_image( $url, $post_id );
142
-
143
-        if ( ! $file ) {
144
-            return false;
145
-        }
146
-
147
-        $name_parts = pathinfo( $name );
148
-        $name       = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
149
-
150
-        $url     = $file['url'];
151
-        $type    = $file['type'];
152
-        $file    = $file['file'];
153
-        $title   = $name;
154
-        $content = '';
155
-
156
-        // use image exif/iptc data for title and caption defaults if possible
157
-        if ( $image_meta = @wp_read_image_metadata( $file ) ) {
158
-            if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
159
-                $title = $image_meta['title'];
160
-            }
161
-            if ( trim( $image_meta['caption'] ) ) {
162
-                $content = $image_meta['caption'];
163
-            }
164
-        }
165
-
166
-        // Construct the attachment array
167
-        $attachment = array_merge(
168
-            array(
169
-                'post_mime_type' => $type,
170
-                'guid'           => $url,
171
-                'post_parent'    => $post_id,
172
-                'post_title'     => $title,
173
-                'post_content'   => $content,
174
-            ), $post_data
175
-        );
176
-
177
-        // Save the data
178
-        $id = wp_insert_attachment( $attachment, $file, $post_id );
179
-        if ( ! is_wp_error( $id ) ) {
180
-            wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
181
-        }
182
-
183
-        return $id;
184
-    }
10
+	/**
11
+	 * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private.
12
+	 *
13
+	 * @since 1.16.2
14
+	 *
15
+	 * @param string $url URL of the post image to update
16
+	 * @param int $post_id ID of the post image to update
17
+	 * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path.
18
+	 */
19
+	public static function copy_post_image( $url, $post_id ) {
20
+
21
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' );
22
+
23
+		/**
24
+		 * If the method changes to public, use Gravity Forms' method
25
+		 * @todo: If/when the method is public, remove the unneeded copied code.
26
+		 */
27
+		if( $reflection->isPublic() ) {
28
+			return parent::copy_post_image( $url, $post_id );
29
+		}
30
+
31
+		/**
32
+		 * Original Gravity Forms code below:
33
+		 * ==================================
34
+		 */
35
+
36
+		$time = current_time( 'mysql' );
37
+
38
+		if ( $post = get_post( $post_id ) ) {
39
+			if ( substr( $post->post_date, 0, 4 ) > 0 ) {
40
+				$time = $post->post_date;
41
+			}
42
+		}
43
+
44
+		//making sure there is a valid upload folder
45
+		if ( ! ( ( $upload_dir = wp_upload_dir( $time ) ) && false === $upload_dir['error'] ) ) {
46
+			return false;
47
+		}
48
+
49
+		$form_id = get_post_meta( $post_id, '_gform-form-id', true );
50
+
51
+		/**
52
+		 * Filter the media upload location.
53
+		 *
54
+		 * @param array $upload_dir The current upload directory’s path and url.
55
+		 * @param int $form_id The ID of the form currently being processed.
56
+		 * @param int $post_id The ID of the post created from the entry currently being processed.
57
+		 */
58
+		$upload_dir = gf_apply_filters( 'gform_media_upload_path', $form_id, $upload_dir, $form_id, $post_id );
59
+
60
+		if ( ! file_exists( $upload_dir['path'] ) ) {
61
+			if ( ! wp_mkdir_p( $upload_dir['path'] ) ) {
62
+				return false;
63
+			}
64
+		}
65
+
66
+		$name     = basename( $url );
67
+		$filename = wp_unique_filename( $upload_dir['path'], $name );
68
+
69
+		// the destination path
70
+		$new_file = $upload_dir['path'] . "/$filename";
71
+
72
+		// the source path
73
+		$y                = substr( $time, 0, 4 );
74
+		$m                = substr( $time, 5, 2 );
75
+		$target_root      = RGFormsModel::get_upload_path( $form_id ) . "/$y/$m/";
76
+		$target_root_url  = RGFormsModel::get_upload_url( $form_id ) . "/$y/$m/";
77
+		$upload_root_info = array( 'path' => $target_root, 'url' => $target_root_url );
78
+		$upload_root_info = gf_apply_filters( 'gform_upload_path', $form_id, $upload_root_info, $form_id );
79
+		$path             = str_replace( $upload_root_info['url'], $upload_root_info['path'], $url );
80
+
81
+		// copy the file to the destination path
82
+		if ( ! copy( $path, $new_file ) ) {
83
+			return false;
84
+		}
85
+
86
+		// Set correct file permissions
87
+		$stat  = stat( dirname( $new_file ) );
88
+		$perms = $stat['mode'] & 0000666;
89
+		@ chmod( $new_file, $perms );
90
+
91
+		// Compute the URL
92
+		$url = $upload_dir['url'] . "/$filename";
93
+
94
+		if ( is_multisite() ) {
95
+			delete_transient( 'dirsize_cache' );
96
+		}
97
+
98
+		$type = wp_check_filetype( $new_file );
99
+
100
+		return array( 'file' => $new_file, 'url' => $url, 'type' => $type['type'] );
101
+
102
+	}
103
+
104
+	/**
105
+	 * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private.
106
+	 *
107
+	 * @see GFFormsModel::media_handle_upload
108
+	 * @see GravityView_Edit_Entry_Render::maybe_update_post_fields
109
+	 * 
110
+	 * @uses copy_post_image
111
+	 * @uses wp_insert_attachment
112
+	 * @uses wp_update_attachment_metadata
113
+	 *
114
+	 * @param string $url URL of the post image to update
115
+	 * @param int $post_id ID of the post image to update
116
+	 * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys.
117
+	 * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image
118
+	 */
119
+	public static function media_handle_upload( $url, $post_id, $post_data = array() ) {
120
+
121
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' );
122
+
123
+		/**
124
+		 * If the method changes to public, use Gravity Forms' method
125
+		 * @todo: If/when the method is public, remove the unneeded copied code.
126
+		 */
127
+		if( $reflection->isPublic() ) {
128
+			return parent::media_handle_upload( $url, $post_id, $post_data );
129
+		}
130
+
131
+		/**
132
+		 * Original Gravity Forms code below:
133
+		 * ==================================
134
+		 */
135
+
136
+		//WordPress Administration API required for the media_handle_upload() function
137
+		require_once( ABSPATH . 'wp-admin/includes/image.php' );
138
+
139
+		$name = basename( $url );
140
+
141
+		$file = self::copy_post_image( $url, $post_id );
142
+
143
+		if ( ! $file ) {
144
+			return false;
145
+		}
146
+
147
+		$name_parts = pathinfo( $name );
148
+		$name       = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
149
+
150
+		$url     = $file['url'];
151
+		$type    = $file['type'];
152
+		$file    = $file['file'];
153
+		$title   = $name;
154
+		$content = '';
155
+
156
+		// use image exif/iptc data for title and caption defaults if possible
157
+		if ( $image_meta = @wp_read_image_metadata( $file ) ) {
158
+			if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
159
+				$title = $image_meta['title'];
160
+			}
161
+			if ( trim( $image_meta['caption'] ) ) {
162
+				$content = $image_meta['caption'];
163
+			}
164
+		}
165
+
166
+		// Construct the attachment array
167
+		$attachment = array_merge(
168
+			array(
169
+				'post_mime_type' => $type,
170
+				'guid'           => $url,
171
+				'post_parent'    => $post_id,
172
+				'post_title'     => $title,
173
+				'post_content'   => $content,
174
+			), $post_data
175
+		);
176
+
177
+		// Save the data
178
+		$id = wp_insert_attachment( $attachment, $file, $post_id );
179
+		if ( ! is_wp_error( $id ) ) {
180
+			wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
181
+		}
182
+
183
+		return $id;
184
+	}
185 185
 
186 186
 
187 187
 }
188 188
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
          * If the method changes to public, use Gravity Forms' method
25 25
          * @todo: If/when the method is public, remove the unneeded copied code.
26 26
          */
27
-        if( $reflection->isPublic() ) {
27
+        if ( $reflection->isPublic() ) {
28 28
             return parent::copy_post_image( $url, $post_id );
29 29
         }
30 30
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         }
43 43
 
44 44
         //making sure there is a valid upload folder
45
-        if ( ! ( ( $upload_dir = wp_upload_dir( $time ) ) && false === $upload_dir['error'] ) ) {
45
+        if ( ! ( ( $upload_dir = wp_upload_dir( $time ) ) && false === $upload_dir[ 'error' ] ) ) {
46 46
             return false;
47 47
         }
48 48
 
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
          */
58 58
         $upload_dir = gf_apply_filters( 'gform_media_upload_path', $form_id, $upload_dir, $form_id, $post_id );
59 59
 
60
-        if ( ! file_exists( $upload_dir['path'] ) ) {
61
-            if ( ! wp_mkdir_p( $upload_dir['path'] ) ) {
60
+        if ( ! file_exists( $upload_dir[ 'path' ] ) ) {
61
+            if ( ! wp_mkdir_p( $upload_dir[ 'path' ] ) ) {
62 62
                 return false;
63 63
             }
64 64
         }
65 65
 
66 66
         $name     = basename( $url );
67
-        $filename = wp_unique_filename( $upload_dir['path'], $name );
67
+        $filename = wp_unique_filename( $upload_dir[ 'path' ], $name );
68 68
 
69 69
         // the destination path
70
-        $new_file = $upload_dir['path'] . "/$filename";
70
+        $new_file = $upload_dir[ 'path' ] . "/$filename";
71 71
 
72 72
         // the source path
73 73
         $y                = substr( $time, 0, 4 );
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
         $target_root_url  = RGFormsModel::get_upload_url( $form_id ) . "/$y/$m/";
77 77
         $upload_root_info = array( 'path' => $target_root, 'url' => $target_root_url );
78 78
         $upload_root_info = gf_apply_filters( 'gform_upload_path', $form_id, $upload_root_info, $form_id );
79
-        $path             = str_replace( $upload_root_info['url'], $upload_root_info['path'], $url );
79
+        $path             = str_replace( $upload_root_info[ 'url' ], $upload_root_info[ 'path' ], $url );
80 80
 
81 81
         // copy the file to the destination path
82 82
         if ( ! copy( $path, $new_file ) ) {
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 
86 86
         // Set correct file permissions
87 87
         $stat  = stat( dirname( $new_file ) );
88
-        $perms = $stat['mode'] & 0000666;
88
+        $perms = $stat[ 'mode' ] & 0000666;
89 89
         @ chmod( $new_file, $perms );
90 90
 
91 91
         // Compute the URL
92
-        $url = $upload_dir['url'] . "/$filename";
92
+        $url = $upload_dir[ 'url' ] . "/$filename";
93 93
 
94 94
         if ( is_multisite() ) {
95 95
             delete_transient( 'dirsize_cache' );
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
         $type = wp_check_filetype( $new_file );
99 99
 
100
-        return array( 'file' => $new_file, 'url' => $url, 'type' => $type['type'] );
100
+        return array( 'file' => $new_file, 'url' => $url, 'type' => $type[ 'type' ] );
101 101
 
102 102
     }
103 103
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
          * If the method changes to public, use Gravity Forms' method
125 125
          * @todo: If/when the method is public, remove the unneeded copied code.
126 126
          */
127
-        if( $reflection->isPublic() ) {
127
+        if ( $reflection->isPublic() ) {
128 128
             return parent::media_handle_upload( $url, $post_id, $post_data );
129 129
         }
130 130
 
@@ -145,21 +145,21 @@  discard block
 block discarded – undo
145 145
         }
146 146
 
147 147
         $name_parts = pathinfo( $name );
148
-        $name       = trim( substr( $name, 0, - ( 1 + strlen( $name_parts['extension'] ) ) ) );
148
+        $name       = trim( substr( $name, 0, - ( 1 + strlen( $name_parts[ 'extension' ] ) ) ) );
149 149
 
150
-        $url     = $file['url'];
151
-        $type    = $file['type'];
152
-        $file    = $file['file'];
150
+        $url     = $file[ 'url' ];
151
+        $type    = $file[ 'type' ];
152
+        $file    = $file[ 'file' ];
153 153
         $title   = $name;
154 154
         $content = '';
155 155
 
156 156
         // use image exif/iptc data for title and caption defaults if possible
157 157
         if ( $image_meta = @wp_read_image_metadata( $file ) ) {
158
-            if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
159
-                $title = $image_meta['title'];
158
+            if ( trim( $image_meta[ 'title' ] ) && ! is_numeric( sanitize_title( $image_meta[ 'title' ] ) ) ) {
159
+                $title = $image_meta[ 'title' ];
160 160
             }
161
-            if ( trim( $image_meta['caption'] ) ) {
162
-                $content = $image_meta['caption'];
161
+            if ( trim( $image_meta[ 'caption' ] ) ) {
162
+                $content = $image_meta[ 'caption' ];
163 163
             }
164 164
         }
165 165
 
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-post-image.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
 
24 24
 	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
25 25
 
26
-		unset ( $field_options['search_filter'] );
26
+		unset ( $field_options[ 'search_filter' ] );
27 27
 
28
-		if( 'edit' === $context ) {
28
+		if ( 'edit' === $context ) {
29 29
 			return $field_options;
30 30
 		}
31 31
 
32
-		$this->add_field_support('link_to_post', $field_options );
32
+		$this->add_field_support( 'link_to_post', $field_options );
33 33
 
34 34
 		// @since 1.5.4
35
-		$this->add_field_support('dynamic_data', $field_options );
35
+		$this->add_field_support( 'dynamic_data', $field_options );
36 36
 
37 37
 		return $field_options;
38 38
 	}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$url = $title = $caption = $description = '';
59 59
 
60 60
 		// If there's a |:| match, process. Otherwise, empty array!
61
-		if( preg_match( '/\|\:\|/', $value ) ) {
61
+		if ( preg_match( '/\|\:\|/', $value ) ) {
62 62
 			list( $url, $title, $caption, $description ) = array_pad( explode( '|:|', $value ), 4, false );
63 63
 		}
64 64
 
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 	 */
88 88
 	public function get_field_input( $form, $value = '', $entry = null, GF_Field_Post_Image $field ) {
89 89
 
90
-		$id = (int) $field->id;
91
-		$form_id = $form['id'];
90
+		$id = (int)$field->id;
91
+		$form_id = $form[ 'id' ];
92 92
 		$input_name = "input_{$id}";
93 93
 		$field_id = sprintf( 'input_%d_%d', $form_id, $id );
94 94
 		$img_name = null;
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
 		// Convert |:| to associative array
97 97
 		$img_array = $this->explode_value( $value );
98 98
 
99
-		if( ! empty( $img_array['url'] ) ) {
99
+		if ( ! empty( $img_array[ 'url' ] ) ) {
100 100
 
101
-			$img_name = basename( $img_array['url'] );
101
+			$img_name = basename( $img_array[ 'url' ] );
102 102
 
103 103
 			/**
104 104
 			 * Set the $uploaded_files value so that the .ginput_preview renders, and the file upload is hidden
105 105
 			 * @see GF_Field_Post_Image::get_field_input See the `<span class='ginput_preview'>` code
106 106
 			 * @see GFFormsModel::get_temp_filename See the `rgget( $input_name, self::$uploaded_files[ $form_id ] );` code
107 107
 			 */
108
-			if( empty( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
108
+			if ( empty( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
109 109
 				GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $img_name;
110 110
 			}
111 111
 		}
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 		 * @hack
135 135
 		 */
136 136
 		if ( $img_name ) {
137
-			$current_file = sprintf( "<input name='%s' id='%s' type='hidden' value='%s' />", $input_name, $field_id, esc_url_raw( $img_array['url'] ) );
138
-			$gf_post_image_field_output = str_replace('<span class=\'ginput_preview\'>', '<span class=\'ginput_preview\'>'.$current_file, $gf_post_image_field_output );
137
+			$current_file = sprintf( "<input name='%s' id='%s' type='hidden' value='%s' />", $input_name, $field_id, esc_url_raw( $img_array[ 'url' ] ) );
138
+			$gf_post_image_field_output = str_replace( '<span class=\'ginput_preview\'>', '<span class=\'ginput_preview\'>' . $current_file, $gf_post_image_field_output );
139 139
 		}
140 140
 
141 141
 		return $gf_post_image_field_output;
Please login to merge, or discard this patch.