Completed
Pull Request — master (#1038)
by Zack
16:56
created
includes/class-api.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
 
162 162
 		if( !empty( $field['custom_class'] ) ) {
163 163
 
164
-            $custom_class = $field['custom_class'];
164
+			$custom_class = $field['custom_class'];
165 165
 
166
-            if( !empty( $entry ) ) {
166
+			if( !empty( $entry ) ) {
167 167
 
168
-                // We want the merge tag to be formatted as a class. The merge tag may be
169
-                // replaced by a multiple-word value that should be output as a single class.
170
-                // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
171
-                add_filter('gform_merge_tag_filter', 'sanitize_html_class');
168
+				// We want the merge tag to be formatted as a class. The merge tag may be
169
+				// replaced by a multiple-word value that should be output as a single class.
170
+				// "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
171
+				add_filter('gform_merge_tag_filter', 'sanitize_html_class');
172 172
 
173
-                $custom_class = self::replace_variables( $custom_class, $form, $entry);
173
+				$custom_class = self::replace_variables( $custom_class, $form, $entry);
174 174
 
175
-                // And then we want life to return to normal
176
-                remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
177
-            }
175
+				// And then we want life to return to normal
176
+				remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
177
+			}
178 178
 
179 179
 			// And now we want the spaces to be handled nicely.
180 180
 			$classes[] = gravityview_sanitize_html_class( $custom_class );
@@ -531,32 +531,32 @@  discard block
 block discarded – undo
531 531
 		return sanitize_title( $slug );
532 532
 	}
533 533
 
534
-    /**
535
-     * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta
536
-     *
537
-     * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
538
-     *
539
-     * @param $entry array Gravity Forms entry object
540
-     * @param $form array Gravity Forms form object
541
-     */
542
-    public static function entry_create_custom_slug( $entry, $form ) {
543
-        /**
544
-         * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
545
-         * @param boolean $custom Should we process the custom entry slug?
546
-         */
547
-        $custom = apply_filters( 'gravityview_custom_entry_slug', false );
548
-        if( $custom ) {
549
-            // create the gravityview_unique_id and save it
534
+	/**
535
+	 * If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta
536
+	 *
537
+	 * Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );
538
+	 *
539
+	 * @param $entry array Gravity Forms entry object
540
+	 * @param $form array Gravity Forms form object
541
+	 */
542
+	public static function entry_create_custom_slug( $entry, $form ) {
543
+		/**
544
+		 * @filter `gravityview_custom_entry_slug` On entry creation, check if we are using the custom entry slug feature and update the meta
545
+		 * @param boolean $custom Should we process the custom entry slug?
546
+		 */
547
+		$custom = apply_filters( 'gravityview_custom_entry_slug', false );
548
+		if( $custom ) {
549
+			// create the gravityview_unique_id and save it
550 550
 
551
-            // Get the entry hash
552
-            $hash = self::get_custom_entry_slug( $entry['id'], $entry );
551
+			// Get the entry hash
552
+			$hash = self::get_custom_entry_slug( $entry['id'], $entry );
553 553
 
554
-	        gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry['id'], 'hash' => $hash ) );
554
+			gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry['id'], 'hash' => $hash ) );
555 555
 
556
-            gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) );
556
+			gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) );
557 557
 
558
-        }
559
-    }
558
+		}
559
+	}
560 560
 
561 561
 
562 562
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 
900 900
 			// If there was an error, continue to the next term.
901 901
 			if ( is_wp_error( $term_link ) ) {
902
-			    continue;
902
+				continue;
903 903
 			}
904 904
 
905 905
 			$output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
Please login to merge, or discard this patch.
includes/class-gravityview-gfformsmodel.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -48,132 +48,132 @@
 block discarded – undo
48 48
 	}
49 49
 
50 50
 	/**
51
-     * Given information provided in an entry, get array of media IDs
52
-     *
53
-     * This is necessary because GF doesn't expect to need to update post images, only to create them.
54
-     *
55
-     * @see GFFormsModel::create_post()
56
-     *
57
-     * @since 1.17
58
-     *
59
-     * @param array $form Gravity Forms form array
60
-     * @param array $entry Gravity Forms entry array
61
-     *
62
-     * @return array Array of "Field ID" => "Media IDs"
63
-     */
64
-    public static function get_post_field_images( $form, $entry ) {
65
-
66
-        $post_data = self::get_post_fields( $form, $entry );
67
-
68
-        $media = get_attached_media( 'image', $entry['post_id'] );
69
-
70
-        $post_images = array();
71
-
72
-        foreach ( $media as $media_item ) {
73
-            foreach( (array) $post_data['images'] as $post_data_item ) {
74
-                if(
75
-                    \GV\Utils::get( $post_data_item, 'title' ) === $media_item->post_title &&
76
-                    \GV\Utils::get( $post_data_item, 'description' ) === $media_item->post_content &&
77
-                    \GV\Utils::get( $post_data_item, 'caption' ) === $media_item->post_excerpt
78
-                ) {
79
-                    $post_images["{$post_data_item['field_id']}"] = $media_item->ID;
80
-                }
81
-            }
82
-        }
83
-
84
-        return $post_images;
85
-    }
86
-
87
-    /**
88
-     * Alias of GFFormsModel::get_post_fields(); just making it public
89
-     *
90
-     * @see GFFormsModel::get_post_fields()
91
-     *
92
-     * @since 1.17
93
-     *
94
-     * @param array $form Gravity Forms form array
95
-     * @param array $entry Gravity Forms entry array
96
-     *
97
-     * @return array
98
-     */
99
-    public static function get_post_fields( $form, $entry ) {
100
-
101
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' );
102
-
103
-        /**
104
-         * If the method changes to public, use Gravity Forms' method
105
-         * @todo: If/when the method is public, remove the unneeded copied code.
106
-         */
107
-        if( $reflection->isPublic() ) {
108
-            return parent::get_post_fields( $form, $entry );
109
-        }
110
-
111
-        // It was private; let's make it public
112
-        $reflection->setAccessible( true );
113
-
114
-        return $reflection->invoke( new GFFormsModel, $form, $entry );
115
-    }
116
-
117
-    /**
118
-     * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private.
119
-     *
120
-     * @since 1.16.2
121
-     *
122
-     * @param string $url URL of the post image to update
123
-     * @param int $post_id ID of the post image to update
124
-     * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path.
125
-     */
126
-    public static function copy_post_image( $url, $post_id ) {
127
-
128
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' );
129
-
130
-        /**
131
-         * If the method changes to public, use Gravity Forms' method
132
-         * @todo: If/when the method is public, remove the unneeded copied code.
133
-         */
134
-        if( $reflection->isPublic() ) {
135
-            return parent::copy_post_image( $url, $post_id );
136
-        }
137
-
138
-        // It was private; let's make it public
139
-        $reflection->setAccessible( true );
140
-
141
-        return $reflection->invoke( new GFFormsModel, $url, $post_id );
142
-    }
143
-
144
-    /**
145
-     * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private.
146
-     *
147
-     * Note: The method became public in GF 1.9.17.7
148
-     *
149
-     * @see GFFormsModel::media_handle_upload
150
-     * @see GravityView_Edit_Entry_Render::maybe_update_post_fields
151
-     *
152
-     * @uses copy_post_image
153
-     * @uses wp_insert_attachment
154
-     * @uses wp_update_attachment_metadata
155
-     *
156
-     * @param string $url URL of the post image to update
157
-     * @param int $post_id ID of the post image to update
158
-     * @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.
159
-     * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image
160
-     */
161
-    public static function media_handle_upload( $url, $post_id, $post_data = array() ) {
162
-
163
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' );
164
-
165
-        /**
166
-         * If the method changes to public, use Gravity Forms' method
167
-         * @todo: If/when the method is public, remove the unneeded copied code.
168
-         */
169
-        if( $reflection->isPublic() ) {
170
-            return parent::media_handle_upload( $url, $post_id, $post_data );
171
-        }
172
-
173
-        // It was private; let's make it public
174
-        $reflection->setAccessible( true );
175
-
176
-        return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data );
177
-    }
51
+	 * Given information provided in an entry, get array of media IDs
52
+	 *
53
+	 * This is necessary because GF doesn't expect to need to update post images, only to create them.
54
+	 *
55
+	 * @see GFFormsModel::create_post()
56
+	 *
57
+	 * @since 1.17
58
+	 *
59
+	 * @param array $form Gravity Forms form array
60
+	 * @param array $entry Gravity Forms entry array
61
+	 *
62
+	 * @return array Array of "Field ID" => "Media IDs"
63
+	 */
64
+	public static function get_post_field_images( $form, $entry ) {
65
+
66
+		$post_data = self::get_post_fields( $form, $entry );
67
+
68
+		$media = get_attached_media( 'image', $entry['post_id'] );
69
+
70
+		$post_images = array();
71
+
72
+		foreach ( $media as $media_item ) {
73
+			foreach( (array) $post_data['images'] as $post_data_item ) {
74
+				if(
75
+					\GV\Utils::get( $post_data_item, 'title' ) === $media_item->post_title &&
76
+					\GV\Utils::get( $post_data_item, 'description' ) === $media_item->post_content &&
77
+					\GV\Utils::get( $post_data_item, 'caption' ) === $media_item->post_excerpt
78
+				) {
79
+					$post_images["{$post_data_item['field_id']}"] = $media_item->ID;
80
+				}
81
+			}
82
+		}
83
+
84
+		return $post_images;
85
+	}
86
+
87
+	/**
88
+	 * Alias of GFFormsModel::get_post_fields(); just making it public
89
+	 *
90
+	 * @see GFFormsModel::get_post_fields()
91
+	 *
92
+	 * @since 1.17
93
+	 *
94
+	 * @param array $form Gravity Forms form array
95
+	 * @param array $entry Gravity Forms entry array
96
+	 *
97
+	 * @return array
98
+	 */
99
+	public static function get_post_fields( $form, $entry ) {
100
+
101
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' );
102
+
103
+		/**
104
+		 * If the method changes to public, use Gravity Forms' method
105
+		 * @todo: If/when the method is public, remove the unneeded copied code.
106
+		 */
107
+		if( $reflection->isPublic() ) {
108
+			return parent::get_post_fields( $form, $entry );
109
+		}
110
+
111
+		// It was private; let's make it public
112
+		$reflection->setAccessible( true );
113
+
114
+		return $reflection->invoke( new GFFormsModel, $form, $entry );
115
+	}
116
+
117
+	/**
118
+	 * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private.
119
+	 *
120
+	 * @since 1.16.2
121
+	 *
122
+	 * @param string $url URL of the post image to update
123
+	 * @param int $post_id ID of the post image to update
124
+	 * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path.
125
+	 */
126
+	public static function copy_post_image( $url, $post_id ) {
127
+
128
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' );
129
+
130
+		/**
131
+		 * If the method changes to public, use Gravity Forms' method
132
+		 * @todo: If/when the method is public, remove the unneeded copied code.
133
+		 */
134
+		if( $reflection->isPublic() ) {
135
+			return parent::copy_post_image( $url, $post_id );
136
+		}
137
+
138
+		// It was private; let's make it public
139
+		$reflection->setAccessible( true );
140
+
141
+		return $reflection->invoke( new GFFormsModel, $url, $post_id );
142
+	}
143
+
144
+	/**
145
+	 * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private.
146
+	 *
147
+	 * Note: The method became public in GF 1.9.17.7
148
+	 *
149
+	 * @see GFFormsModel::media_handle_upload
150
+	 * @see GravityView_Edit_Entry_Render::maybe_update_post_fields
151
+	 *
152
+	 * @uses copy_post_image
153
+	 * @uses wp_insert_attachment
154
+	 * @uses wp_update_attachment_metadata
155
+	 *
156
+	 * @param string $url URL of the post image to update
157
+	 * @param int $post_id ID of the post image to update
158
+	 * @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.
159
+	 * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image
160
+	 */
161
+	public static function media_handle_upload( $url, $post_id, $post_data = array() ) {
162
+
163
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' );
164
+
165
+		/**
166
+		 * If the method changes to public, use Gravity Forms' method
167
+		 * @todo: If/when the method is public, remove the unneeded copied code.
168
+		 */
169
+		if( $reflection->isPublic() ) {
170
+			return parent::media_handle_upload( $url, $post_id, $post_data );
171
+		}
172
+
173
+		// It was private; let's make it public
174
+		$reflection->setAccessible( true );
175
+
176
+		return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data );
177
+	}
178 178
 
179 179
 }
180 180
\ No newline at end of file
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/search-field-link.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -41,22 +41,22 @@
 block discarded – undo
41 41
 
42 42
         <?php
43 43
 
44
-        $search_value = \GV\Utils::_GET( $search_field['name'] );
44
+		$search_value = \GV\Utils::_GET( $search_field['name'] );
45 45
 
46
-        foreach ( $search_field['choices'] as $k => $choice ) {
46
+		foreach ( $search_field['choices'] as $k => $choice ) {
47 47
 
48
-            if ( 0 != $k ) {
49
-                echo esc_html( $links_sep );
50
-            }
48
+			if ( 0 != $k ) {
49
+				echo esc_html( $links_sep );
50
+			}
51 51
 
52
-            $active = ( '' !== $search_value && in_array( $search_value, array( $choice['text'], $choice['value'] ) ) ) ? ' class="active"' : false;
52
+			$active = ( '' !== $search_value && in_array( $search_value, array( $choice['text'], $choice['value'] ) ) ) ? ' class="active"' : false;
53 53
 
54
-            if ( $active ) {
55
-                $link = remove_query_arg( array( 'pagenum', $search_field['name'] ), $base_url );
56
-            } else {
57
-                $link = add_query_arg( array( $search_field['name'] => urlencode( $choice['value'] ) ), remove_query_arg( array('pagenum'), $base_url ) );
58
-            }
59
-            ?>
54
+			if ( $active ) {
55
+				$link = remove_query_arg( array( 'pagenum', $search_field['name'] ), $base_url );
56
+			} else {
57
+				$link = add_query_arg( array( $search_field['name'] => urlencode( $choice['value'] ) ), remove_query_arg( array('pagenum'), $base_url ) );
58
+			}
59
+			?>
60 60
 
61 61
 			<a href="<?php echo esc_url_raw( $link ); ?>" <?php echo $active; ?>><?php echo esc_html( $choice['text'] ); ?></a>
62 62
 
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/widget-search.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 		/**
32 32
 		 * @action `gravityview_search_widget_field_before` Before each search input is rendered (other than the submit button)
33 33
 		 * @param GravityView_Widget_Search $this GravityView Widget instance
34
-         * @param array $search_field
34
+		 * @param array $search_field
35 35
 		 */
36 36
 		do_action( 'gravityview_search_widget_field_before', $this, $search_field );
37 37
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		/**
47 47
 		 * @action `gravityview_search_widget_field_after` After each search input is rendered (other than the submit button)
48 48
 		 * @param GravityView_Widget_Search $this GravityView Widget instance
49
-         * @param array $search_field
49
+		 * @param array $search_field
50 50
 		 */
51 51
 		do_action( 'gravityview_search_widget_field_after', $this, $search_field );
52 52
 	}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	do_action( 'gravityview_search_widget_fields_after', $this );
59 59
 
60 60
 	if( $has_inputs ) {
61
-	    $this->render( 'search-field', 'submit', false );
62
-    }
61
+		$this->render( 'search-field', 'submit', false );
62
+	}
63 63
 ?>
64 64
 </form>
Please login to merge, or discard this patch.
includes/admin/class-gravityview-support-port.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			'payment_id'       => '',
105 105
 			'customer_name'    => '',
106 106
 			'customer_email'   => '',
107
-            'price_id'         => '0',
107
+			'price_id'         => '0',
108 108
 		) );
109 109
 
110 110
 		// This is just HTML we don't need.
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 			case 3:
122 122
 				$package = 'Galactic';
123 123
 				break;
124
-            case 4:
125
-                $package = 'Lifetime';
126
-                break;
124
+			case 4:
125
+				$package = 'Lifetime';
126
+				break;
127 127
 		}
128 128
 
129 129
 		$data = array(
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 			'contactEnabled' => (int)GVCommon::has_cap( 'gravityview_contact_support' ),
153 153
 			'data' => $data,
154 154
 			'translation' => $translation,
155
-            'suggest' => array(),
155
+			'suggest' => array(),
156 156
 		);
157 157
 
158 158
 		/**
159
-         * @filter `gravityview/support_port/localization_data` Filter data passed to the Support Port, before localize_script is run
159
+		 * @filter `gravityview/support_port/localization_data` Filter data passed to the Support Port, before localize_script is run
160 160
 		 * @since 2.0
161
-         * @param array $localization_data {
162
-         *   @type int $contactEnabled Can the user contact support?
163
-         *   @type array $data Support/license info
164
-         *   @type array $translation i18n strings
165
-         *   @type array $suggest Article IDs to recommend to the user (per page in the admin
166
-         * }
161
+		 * @param array $localization_data {
162
+		 *   @type int $contactEnabled Can the user contact support?
163
+		 *   @type array $data Support/license info
164
+		 *   @type array $translation i18n strings
165
+		 *   @type array $suggest Article IDs to recommend to the user (per page in the admin
166
+		 * }
167 167
 		 */
168 168
 		$localization_data = apply_filters( 'gravityview/support_port/localization_data', $localization_data );
169 169
 
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * If the user doesn't have the `gravityview_support_port` capability, returns false; then
179 179
 	 * If global setting is "hide", returns false; then
180
-     * If user preference is not set, return global setting; then
181
-     * If user preference is set, return that setting.
180
+	 * If user preference is not set, return global setting; then
181
+	 * If user preference is set, return that setting.
182 182
 	 *
183 183
 	 * @since 1.15
184
-     * @since 1.17.5 Changed behavior to respect global setting
184
+	 * @since 1.17.5 Changed behavior to respect global setting
185 185
 	 *
186 186
 	 * @param int $user Optional. ID of the user to check, defaults to 0 for current user.
187 187
 	 *
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		$global_setting = gravityview()->plugin->settings->get( 'support_port' );
197 197
 
198 198
 		if ( empty( $global_setting ) ) {
199
-            return false;
199
+			return false;
200 200
 		}
201 201
 
202 202
 		// Get the per-user Support Port setting
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * Modifies the output of profile.php to add GravityView Support preference
233 233
 	 *
234 234
 	 * @since 1.15
235
-     * @since 1.17.5 Only show if global setting is active
235
+	 * @since 1.17.5 Only show if global setting is active
236 236
 	 *
237 237
 	 * @param WP_User $user Current user info
238 238
 	 *
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		$global_setting = gravityview()->plugin->settings->get( 'support_port' );
244 244
 
245 245
 		if ( empty( $global_setting ) ) {
246
-            return;
246
+			return;
247 247
 		}
248 248
 
249 249
 		/**
Please login to merge, or discard this patch.
includes/admin/field-types/type_textarea.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,13 +28,13 @@
 block discarded – undo
28 28
 
29 29
 		$show_mt = $this->show_merge_tags();
30 30
 
31
-        if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
32
-            $class .= ' merge-tag-support mt-position-right ';
31
+		if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
32
+			$class .= ' merge-tag-support mt-position-right ';
33 33
 
34
-            if( empty( $this->field['show_all_fields'] ) ) {
35
-            	$class .= ' mt-hide_all_fields ';
36
-            }
37
-        }
34
+			if( empty( $this->field['show_all_fields'] ) ) {
35
+				$class .= ' mt-hide_all_fields ';
36
+			}
37
+		}
38 38
 		$class .= \GV\Utils::get( $this->field, 'class' );
39 39
 		$placeholder = \GV\Utils::get( $this->field, 'placeholder' );
40 40
 		$rows = \GV\Utils::get( $this->field, 'rows', 5 );
Please login to merge, or discard this patch.
includes/admin/field-types/type_text.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,11 +28,11 @@
 block discarded – undo
28 28
 
29 29
 		$show_mt = $this->show_merge_tags();
30 30
 
31
-        if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
32
-            $class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
33
-        }
34
-        $class .= \GV\Utils::get( $this->field, 'class', 'widefat' );
35
-        $placeholder = \GV\Utils::get( $this->field, 'placeholder' );
31
+		if( $show_mt && $this->field['merge_tags'] !== false || $this->field['merge_tags'] === 'force' ) {
32
+			$class = 'merge-tag-support mt-position-right mt-hide_all_fields ';
33
+		}
34
+		$class .= \GV\Utils::get( $this->field, 'class', 'widefat' );
35
+		$placeholder = \GV\Utils::get( $this->field, 'placeholder' );
36 36
 		?>
37 37
 		<input name="<?php echo esc_attr( $this->name ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" id="<?php echo $this->get_field_id(); ?>" type="text" value="<?php echo esc_attr( $this->value ); ?>" class="<?php echo esc_attr( $class ); ?>">
38 38
 		<?php
Please login to merge, or discard this patch.
includes/extensions/delete-entry/class-delete-entry.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 		self::getInstance()->set_entry( $entry );
241 241
 
242
-        $base = GravityView_API::directory_link( $post_id ? : $view_id, true );
242
+		$base = GravityView_API::directory_link( $post_id ? : $view_id, true );
243 243
 
244 244
 		if ( empty( $base ) ) {
245 245
 			gravityview()->log->error( 'Post ID does not exist: {post_id}', array( 'post_id' => $post_id ) );
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 			'action'	=> 'delete',
254 254
 			'entry_id'		=> $entry_slug,
255 255
 			'gvid' => $view_id,
256
-            'view_id' => $view_id,
256
+			'view_id' => $view_id,
257 257
 		), $base );
258 258
 
259 259
 		$url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 				 * @since 1.16.4
428 428
 				 * @param  int $entry_id ID of the Gravity Forms entry
429 429
 				 * @param  array $entry Deleted entry array
430
-				*/
430
+				 */
431 431
 				do_action( 'gravityview/delete-entry/deleted', $entry_id, $entry );
432 432
 			}
433 433
 
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry.php 1 patch
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -18,80 +18,80 @@  discard block
 block discarded – undo
18 18
 
19 19
 class GravityView_Edit_Entry {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
21
+	/**
22
+	 * @var string
23
+	 */
24 24
 	static $file;
25 25
 
26 26
 	static $instance;
27 27
 
28
-    /**
29
-     * Component instances.
30
-     * @var array
31
-     */
32
-    public $instances = array();
28
+	/**
29
+	 * Component instances.
30
+	 * @var array
31
+	 */
32
+	public $instances = array();
33 33
 
34 34
 
35 35
 	function __construct() {
36 36
 
37
-        self::$file = plugin_dir_path( __FILE__ );
37
+		self::$file = plugin_dir_path( __FILE__ );
38 38
 
39
-        if( is_admin() ) {
40
-            $this->load_components( 'admin' );
41
-        }
39
+		if( is_admin() ) {
40
+			$this->load_components( 'admin' );
41
+		}
42 42
 
43 43
 
44
-        $this->load_components( 'render' );
44
+		$this->load_components( 'render' );
45 45
 
46
-        // If GF User Registration Add-on exists
47
-        $this->load_components( 'user-registration' );
46
+		// If GF User Registration Add-on exists
47
+		$this->load_components( 'user-registration' );
48 48
 
49
-        $this->add_hooks();
49
+		$this->add_hooks();
50 50
 
51 51
 		// Process hooks for addons that may or may not be present
52 52
 		$this->addon_specific_hooks();
53 53
 	}
54 54
 
55 55
 
56
-    static function getInstance() {
56
+	static function getInstance() {
57 57
 
58
-        if( empty( self::$instance ) ) {
59
-            self::$instance = new GravityView_Edit_Entry;
60
-        }
58
+		if( empty( self::$instance ) ) {
59
+			self::$instance = new GravityView_Edit_Entry;
60
+		}
61 61
 
62
-        return self::$instance;
63
-    }
62
+		return self::$instance;
63
+	}
64 64
 
65 65
 
66
-    private function load_components( $component ) {
66
+	private function load_components( $component ) {
67 67
 
68
-        $dir = trailingslashit( self::$file );
68
+		$dir = trailingslashit( self::$file );
69 69
 
70
-        $filename  = $dir . 'class-edit-entry-' . $component . '.php';
71
-        $classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
70
+		$filename  = $dir . 'class-edit-entry-' . $component . '.php';
71
+		$classname = 'GravityView_Edit_Entry_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $component ) ) );
72 72
 
73
-        // Loads component and pass extension's instance so that component can
74
-        // talk each other.
75
-        require_once $filename;
76
-        $this->instances[ $component ] = new $classname( $this );
77
-        $this->instances[ $component ]->load();
73
+		// Loads component and pass extension's instance so that component can
74
+		// talk each other.
75
+		require_once $filename;
76
+		$this->instances[ $component ] = new $classname( $this );
77
+		$this->instances[ $component ]->load();
78 78
 
79
-    }
79
+	}
80 80
 
81
-    private function add_hooks() {
81
+	private function add_hooks() {
82 82
 
83
-        // Add front-end access to Gravity Forms delete file action
84
-        add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
83
+		// Add front-end access to Gravity Forms delete file action
84
+		add_action( 'wp_ajax_nopriv_rg_delete_file', array( 'GFForms', 'delete_file') );
85 85
 
86
-        // Make sure this hook is run for non-admins
87
-        add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
86
+		// Make sure this hook is run for non-admins
87
+		add_action( 'wp_ajax_rg_delete_file', array( 'GFForms', 'delete_file') );
88 88
 
89
-        add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
89
+		add_filter( 'gravityview_blacklist_field_types', array( $this, 'modify_field_blacklist' ), 10, 2 );
90 90
 
91
-        // add template path to check for field
92
-        add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
91
+		// add template path to check for field
92
+		add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
93 93
 
94
-    }
94
+	}
95 95
 
96 96
 	/**
97 97
 	 * Trigger hooks that are normally run in the admin for Addons, but need to be triggered manually because we're not in the admin
@@ -105,73 +105,73 @@  discard block
 block discarded – undo
105 105
 
106 106
 	}
107 107
 
108
-    /**
109
-     * Include this extension templates path
110
-     * @param array $file_paths List of template paths ordered
111
-     */
112
-    public function add_template_path( $file_paths ) {
113
-
114
-        // Index 100 is the default GravityView template path.
115
-        $file_paths[ 110 ] = self::$file;
116
-
117
-        return $file_paths;
118
-    }
119
-
120
-    /**
121
-     *
122
-     * Return a well formatted nonce key according to GravityView Edit Entry protocol
123
-     *
124
-     * @param $view_id int GravityView view id
125
-     * @param $form_id int Gravity Forms form id
126
-     * @param $entry_id int Gravity Forms entry id
127
-     * @return string
128
-     */
129
-    public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
130
-        return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
131
-    }
132
-
133
-
134
-    /**
135
-     * The edit entry link creates a secure link with a nonce
136
-     *
137
-     * It also mimics the URL structure Gravity Forms expects to have so that
138
-     * it formats the display of the edit form like it does in the backend, like
139
-     * "You can edit this post from the post page" fields, for example.
140
-     *
141
-     * @param $entry array Gravity Forms entry object
142
-     * @param $view_id int GravityView view id
143
-     * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
144
-     * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
145
-     * @return string
146
-     */
147
-    public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148
-
149
-        $nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
150
-
151
-        $base = gv_entry_link( $entry, $post_id ? : $view_id  );
152
-
153
-        $url = add_query_arg( array(
154
-            'edit' => wp_create_nonce( $nonce_key )
155
-        ), $base );
156
-
157
-	    /**
158
-	     * Allow passing params to dynamically populate entry with values
159
-	     * @since 1.9.2
160
-	     */
161
-	    if( !empty( $field_values ) ) {
162
-
163
-		    if( is_array( $field_values ) ) {
164
-			    // If already an array, no parse_str() needed
165
-			    $params = $field_values;
166
-		    } else {
167
-			    parse_str( $field_values, $params );
168
-		    }
169
-
170
-		    $url = add_query_arg( $params, $url );
171
-	    }
172
-
173
-        return $url;
174
-    }
108
+	/**
109
+	 * Include this extension templates path
110
+	 * @param array $file_paths List of template paths ordered
111
+	 */
112
+	public function add_template_path( $file_paths ) {
113
+
114
+		// Index 100 is the default GravityView template path.
115
+		$file_paths[ 110 ] = self::$file;
116
+
117
+		return $file_paths;
118
+	}
119
+
120
+	/**
121
+	 *
122
+	 * Return a well formatted nonce key according to GravityView Edit Entry protocol
123
+	 *
124
+	 * @param $view_id int GravityView view id
125
+	 * @param $form_id int Gravity Forms form id
126
+	 * @param $entry_id int Gravity Forms entry id
127
+	 * @return string
128
+	 */
129
+	public static function get_nonce_key( $view_id, $form_id, $entry_id ) {
130
+		return sprintf( 'edit_%d_%d_%d', $view_id, $form_id, $entry_id );
131
+	}
132
+
133
+
134
+	/**
135
+	 * The edit entry link creates a secure link with a nonce
136
+	 *
137
+	 * It also mimics the URL structure Gravity Forms expects to have so that
138
+	 * it formats the display of the edit form like it does in the backend, like
139
+	 * "You can edit this post from the post page" fields, for example.
140
+	 *
141
+	 * @param $entry array Gravity Forms entry object
142
+	 * @param $view_id int GravityView view id
143
+	 * @param $post_id int GravityView Post ID where View may be embedded {@since 1.9.2}
144
+	 * @param string|array $field_values Parameters to pass in to the Edit Entry form to prefill data. Uses the same format as Gravity Forms "Allow field to be populated dynamically" {@since 1.9.2} {@see https://www.gravityhelp.com/documentation/article/allow-field-to-be-populated-dynamically/ }
145
+	 * @return string
146
+	 */
147
+	public static function get_edit_link( $entry, $view_id, $post_id = null, $field_values = '' ) {
148
+
149
+		$nonce_key = self::get_nonce_key( $view_id, $entry['form_id'], $entry['id']  );
150
+
151
+		$base = gv_entry_link( $entry, $post_id ? : $view_id  );
152
+
153
+		$url = add_query_arg( array(
154
+			'edit' => wp_create_nonce( $nonce_key )
155
+		), $base );
156
+
157
+		/**
158
+		 * Allow passing params to dynamically populate entry with values
159
+		 * @since 1.9.2
160
+		 */
161
+		if( !empty( $field_values ) ) {
162
+
163
+			if( is_array( $field_values ) ) {
164
+				// If already an array, no parse_str() needed
165
+				$params = $field_values;
166
+			} else {
167
+				parse_str( $field_values, $params );
168
+			}
169
+
170
+			$url = add_query_arg( $params, $url );
171
+		}
172
+
173
+		return $url;
174
+	}
175 175
 
176 176
 	/**
177 177
 	 * Edit mode doesn't allow certain field types.
@@ -225,82 +225,82 @@  discard block
 block discarded – undo
225 225
 	}
226 226
 
227 227
 
228
-    /**
229
-     * checks if user has permissions to edit a specific entry
230
-     *
231
-     * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
232
-     *
233
-     * @param  array $entry Gravity Forms entry array
234
-     * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
235
-     * @return bool
236
-     */
237
-    public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) {
228
+	/**
229
+	 * checks if user has permissions to edit a specific entry
230
+	 *
231
+	 * Needs to be used combined with GravityView_Edit_Entry::user_can_edit_entry for maximum security!!
232
+	 *
233
+	 * @param  array $entry Gravity Forms entry array
234
+	 * @param int $view_id ID of the view you want to check visibility against {@since 1.9.2}. Required since 2.0
235
+	 * @return bool
236
+	 */
237
+	public static function check_user_cap_edit_entry( $entry, $view_id = 0 ) {
238 238
 
239
-        // No permission by default
240
-        $user_can_edit = false;
239
+		// No permission by default
240
+		$user_can_edit = false;
241 241
 
242
-        // If they can edit any entries (as defined in Gravity Forms)
243
-        // Or if they can edit other people's entries
244
-        // Then we're good.
245
-        if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
242
+		// If they can edit any entries (as defined in Gravity Forms)
243
+		// Or if they can edit other people's entries
244
+		// Then we're good.
245
+		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ), $entry['id'] ) ) {
246 246
 
247
-            gravityview()->log->debug( 'User has ability to edit all entries.' );
247
+			gravityview()->log->debug( 'User has ability to edit all entries.' );
248 248
 
249
-            $user_can_edit = true;
249
+			$user_can_edit = true;
250 250
 
251
-        } else if( !isset( $entry['created_by'] ) ) {
251
+		} else if( !isset( $entry['created_by'] ) ) {
252 252
 
253
-            gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
253
+			gravityview()->log->error( 'Entry `created_by` doesn\'t exist.');
254 254
 
255
-            $user_can_edit = false;
255
+			$user_can_edit = false;
256 256
 
257
-        } else {
257
+		} else {
258 258
 
259
-            // get user_edit setting
260
-            if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
261
-                // if View ID not specified or is the current view
259
+			// get user_edit setting
260
+			if( empty( $view_id ) || $view_id == GravityView_View::getInstance()->getViewId() ) {
261
+				// if View ID not specified or is the current view
262 262
 				// @deprecated path
263
-                $user_edit = GravityView_View::getInstance()->getAtts('user_edit');
264
-            } else {
265
-                // in case is specified and not the current view
266
-                $user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
267
-            }
263
+				$user_edit = GravityView_View::getInstance()->getAtts('user_edit');
264
+			} else {
265
+				// in case is specified and not the current view
266
+				$user_edit = GVCommon::get_template_setting( $view_id, 'user_edit' );
267
+			}
268 268
 
269
-            $current_user = wp_get_current_user();
269
+			$current_user = wp_get_current_user();
270 270
 
271
-            // User edit is disabled
272
-            if( empty( $user_edit ) ) {
271
+			// User edit is disabled
272
+			if( empty( $user_edit ) ) {
273 273
 
274
-                gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
274
+				gravityview()->log->debug( 'User Edit is disabled. Returning false.' );
275 275
 
276
-                $user_can_edit = false;
277
-            }
276
+				$user_can_edit = false;
277
+			}
278 278
 
279
-            // User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
280
-            else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
279
+			// User edit is enabled and the logged-in user is the same as the user who created the entry. We're good.
280
+			else if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
281 281
 
282
-                gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
282
+				gravityview()->log->debug( 'User {user_id} created the entry.', array( 'user_id', $current_user->ID ) );
283 283
 
284
-                $user_can_edit = true;
284
+				$user_can_edit = true;
285 285
 
286
-            } else if( ! is_user_logged_in() ) {
286
+			} else if( ! is_user_logged_in() ) {
287 287
 
288
-                gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
289
-            }
288
+				gravityview()->log->debug( 'No user defined; edit entry requires logged in user' );
289
+			}
290 290
 
291
-        }
291
+		}
292 292
 
293
-        /**
294
-         * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
295
-         * @since 1.15 Added `$entry` and `$view_id` parameters
296
-         * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
297
-         * @param[in] array $entry Gravity Forms entry array {@since 1.15}
298
-         * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
299
-         */
300
-        $user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
293
+		/**
294
+		 * @filter `gravityview/edit_entry/user_can_edit_entry` Modify whether user can edit an entry.
295
+		 * @since 1.15 Added `$entry` and `$view_id` parameters
296
+		 * @param[in,out] boolean $user_can_edit Can the current user edit the current entry? (Default: false)
297
+		 * @param[in] array $entry Gravity Forms entry array {@since 1.15}
298
+		 * @param[in] int $view_id ID of the view you want to check visibility against {@since 1.15}
299
+		 */
300
+		$user_can_edit = apply_filters( 'gravityview/edit_entry/user_can_edit_entry', $user_can_edit, $entry, $view_id );
301 301
 
302
-        return (bool)$user_can_edit;
303
-    }
302
+		return (bool)$user_can_edit;
303
+	}
304 304
 
305 305
 
306 306
 
Please login to merge, or discard this patch.