Completed
Push — master ( 1fd6be...155036 )
by Zack
13s
created
includes/class-gravityview-gfformsmodel.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -24,132 +24,132 @@
 block discarded – undo
24 24
 	}
25 25
 
26 26
 	/**
27
-     * Given information provided in an entry, get array of media IDs
28
-     *
29
-     * This is necessary because GF doesn't expect to need to update post images, only to create them.
30
-     *
31
-     * @see GFFormsModel::create_post()
32
-     *
33
-     * @since 1.17
34
-     *
35
-     * @param array $form Gravity Forms form array
36
-     * @param array $entry Gravity Forms entry array
37
-     *
38
-     * @return array Array of "Field ID" => "Media IDs"
39
-     */
40
-    public static function get_post_field_images( $form, $entry ) {
41
-
42
-        $post_data = self::get_post_fields( $form, $entry );
43
-
44
-        $media = get_attached_media( 'image', $entry['post_id'] );
45
-
46
-        $post_images = array();
47
-
48
-        foreach ( $media as $media_item ) {
49
-            foreach( (array) $post_data['images'] as $post_data_item ) {
50
-                if(
51
-                    rgar( $post_data_item, 'title' ) === $media_item->post_title &&
52
-                    rgar( $post_data_item, 'description' ) === $media_item->post_content &&
53
-                    rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt
54
-                ) {
55
-                    $post_images["{$post_data_item['field_id']}"] = $media_item->ID;
56
-                }
57
-            }
58
-        }
59
-
60
-        return $post_images;
61
-    }
62
-
63
-    /**
64
-     * Alias of GFFormsModel::get_post_fields(); just making it public
65
-     *
66
-     * @see GFFormsModel::get_post_fields()
67
-     *
68
-     * @since 1.17
69
-     *
70
-     * @param array $form Gravity Forms form array
71
-     * @param array $entry Gravity Forms entry array
72
-     *
73
-     * @return array
74
-     */
75
-    public static function get_post_fields( $form, $entry ) {
76
-
77
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' );
78
-
79
-        /**
80
-         * If the method changes to public, use Gravity Forms' method
81
-         * @todo: If/when the method is public, remove the unneeded copied code.
82
-         */
83
-        if( $reflection->isPublic() ) {
84
-            return parent::get_post_fields( $form, $entry );
85
-        }
86
-
87
-        // It was private; let's make it public
88
-        $reflection->setAccessible( true );
89
-
90
-        return $reflection->invoke( new GFFormsModel, $form, $entry );
91
-    }
92
-
93
-    /**
94
-     * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private.
95
-     *
96
-     * @since 1.16.2
97
-     *
98
-     * @param string $url URL of the post image to update
99
-     * @param int $post_id ID of the post image to update
100
-     * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path.
101
-     */
102
-    public static function copy_post_image( $url, $post_id ) {
103
-
104
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' );
105
-
106
-        /**
107
-         * If the method changes to public, use Gravity Forms' method
108
-         * @todo: If/when the method is public, remove the unneeded copied code.
109
-         */
110
-        if( $reflection->isPublic() ) {
111
-            return parent::copy_post_image( $url, $post_id );
112
-        }
113
-
114
-        // It was private; let's make it public
115
-        $reflection->setAccessible( true );
116
-
117
-        return $reflection->invoke( new GFFormsModel, $url, $post_id );
118
-    }
119
-
120
-    /**
121
-     * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private.
122
-     *
123
-     * Note: The method became public in GF 1.9.17.7
124
-     *
125
-     * @see GFFormsModel::media_handle_upload
126
-     * @see GravityView_Edit_Entry_Render::maybe_update_post_fields
127
-     *
128
-     * @uses copy_post_image
129
-     * @uses wp_insert_attachment
130
-     * @uses wp_update_attachment_metadata
131
-     *
132
-     * @param string $url URL of the post image to update
133
-     * @param int $post_id ID of the post image to update
134
-     * @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.
135
-     * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image
136
-     */
137
-    public static function media_handle_upload( $url, $post_id, $post_data = array() ) {
138
-
139
-        $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' );
140
-
141
-        /**
142
-         * If the method changes to public, use Gravity Forms' method
143
-         * @todo: If/when the method is public, remove the unneeded copied code.
144
-         */
145
-        if( $reflection->isPublic() ) {
146
-            return parent::media_handle_upload( $url, $post_id, $post_data );
147
-        }
148
-
149
-        // It was private; let's make it public
150
-        $reflection->setAccessible( true );
151
-
152
-        return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data );
153
-    }
27
+	 * Given information provided in an entry, get array of media IDs
28
+	 *
29
+	 * This is necessary because GF doesn't expect to need to update post images, only to create them.
30
+	 *
31
+	 * @see GFFormsModel::create_post()
32
+	 *
33
+	 * @since 1.17
34
+	 *
35
+	 * @param array $form Gravity Forms form array
36
+	 * @param array $entry Gravity Forms entry array
37
+	 *
38
+	 * @return array Array of "Field ID" => "Media IDs"
39
+	 */
40
+	public static function get_post_field_images( $form, $entry ) {
41
+
42
+		$post_data = self::get_post_fields( $form, $entry );
43
+
44
+		$media = get_attached_media( 'image', $entry['post_id'] );
45
+
46
+		$post_images = array();
47
+
48
+		foreach ( $media as $media_item ) {
49
+			foreach( (array) $post_data['images'] as $post_data_item ) {
50
+				if(
51
+					rgar( $post_data_item, 'title' ) === $media_item->post_title &&
52
+					rgar( $post_data_item, 'description' ) === $media_item->post_content &&
53
+					rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt
54
+				) {
55
+					$post_images["{$post_data_item['field_id']}"] = $media_item->ID;
56
+				}
57
+			}
58
+		}
59
+
60
+		return $post_images;
61
+	}
62
+
63
+	/**
64
+	 * Alias of GFFormsModel::get_post_fields(); just making it public
65
+	 *
66
+	 * @see GFFormsModel::get_post_fields()
67
+	 *
68
+	 * @since 1.17
69
+	 *
70
+	 * @param array $form Gravity Forms form array
71
+	 * @param array $entry Gravity Forms entry array
72
+	 *
73
+	 * @return array
74
+	 */
75
+	public static function get_post_fields( $form, $entry ) {
76
+
77
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' );
78
+
79
+		/**
80
+		 * If the method changes to public, use Gravity Forms' method
81
+		 * @todo: If/when the method is public, remove the unneeded copied code.
82
+		 */
83
+		if( $reflection->isPublic() ) {
84
+			return parent::get_post_fields( $form, $entry );
85
+		}
86
+
87
+		// It was private; let's make it public
88
+		$reflection->setAccessible( true );
89
+
90
+		return $reflection->invoke( new GFFormsModel, $form, $entry );
91
+	}
92
+
93
+	/**
94
+	 * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private.
95
+	 *
96
+	 * @since 1.16.2
97
+	 *
98
+	 * @param string $url URL of the post image to update
99
+	 * @param int $post_id ID of the post image to update
100
+	 * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path.
101
+	 */
102
+	public static function copy_post_image( $url, $post_id ) {
103
+
104
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' );
105
+
106
+		/**
107
+		 * If the method changes to public, use Gravity Forms' method
108
+		 * @todo: If/when the method is public, remove the unneeded copied code.
109
+		 */
110
+		if( $reflection->isPublic() ) {
111
+			return parent::copy_post_image( $url, $post_id );
112
+		}
113
+
114
+		// It was private; let's make it public
115
+		$reflection->setAccessible( true );
116
+
117
+		return $reflection->invoke( new GFFormsModel, $url, $post_id );
118
+	}
119
+
120
+	/**
121
+	 * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private.
122
+	 *
123
+	 * Note: The method became public in GF 1.9.17.7
124
+	 *
125
+	 * @see GFFormsModel::media_handle_upload
126
+	 * @see GravityView_Edit_Entry_Render::maybe_update_post_fields
127
+	 *
128
+	 * @uses copy_post_image
129
+	 * @uses wp_insert_attachment
130
+	 * @uses wp_update_attachment_metadata
131
+	 *
132
+	 * @param string $url URL of the post image to update
133
+	 * @param int $post_id ID of the post image to update
134
+	 * @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.
135
+	 * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image
136
+	 */
137
+	public static function media_handle_upload( $url, $post_id, $post_data = array() ) {
138
+
139
+		$reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' );
140
+
141
+		/**
142
+		 * If the method changes to public, use Gravity Forms' method
143
+		 * @todo: If/when the method is public, remove the unneeded copied code.
144
+		 */
145
+		if( $reflection->isPublic() ) {
146
+			return parent::media_handle_upload( $url, $post_id, $post_data );
147
+		}
148
+
149
+		// It was private; let's make it public
150
+		$reflection->setAccessible( true );
151
+
152
+		return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data );
153
+	}
154 154
 
155 155
 }
156 156
\ No newline at end of file
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
 
360 360
 		/**
361 361
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
362
-         * @since 1.22.2
363
-         * @param bool $unset_hidden_field_values Default: true
364
-         * @param GravityView_Edit_Entry_Render $this This object
362
+		 * @since 1.22.2
363
+		 * @param bool $unset_hidden_field_values Default: true
364
+		 * @param GravityView_Edit_Entry_Render $this This object
365 365
 		 */
366 366
 		$unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this );
367 367
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 			return;
370 370
 		}
371 371
 
372
-        if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
372
+		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
373 373
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
374 374
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
375 375
 		} else {
Please login to merge, or discard this patch.