@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | self::getInstance()->set_entry( $entry ); |
230 | 230 | |
231 | - $base = GravityView_API::directory_link( $post_id, true ); |
|
231 | + $base = GravityView_API::directory_link( $post_id, true ); |
|
232 | 232 | |
233 | 233 | if( empty( $base ) ) { |
234 | 234 | do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id ); |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | // Use the slug instead of the ID for consistent security |
239 | 239 | $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry ); |
240 | 240 | |
241 | - $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
|
241 | + $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id; |
|
242 | 242 | |
243 | 243 | $actionurl = add_query_arg( array( |
244 | 244 | 'action' => 'delete', |
245 | 245 | 'entry_id' => $entry_slug, |
246 | 246 | 'gvid' => $view_id, |
247 | - 'view_id' => $view_id, |
|
247 | + 'view_id' => $view_id, |
|
248 | 248 | ), $base ); |
249 | 249 | |
250 | 250 | $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' ); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | * @action `gravityview/delete-entry/deleted` Triggered when an entry is deleted |
416 | 416 | * @since 1.16.4 |
417 | 417 | * @param int $entry_id ID of the Gravity Forms entry |
418 | - */ |
|
418 | + */ |
|
419 | 419 | do_action( 'gravityview/delete-entry/deleted', $entry_id ); |
420 | 420 | } |
421 | 421 |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | |
364 | 364 | $approvedcolumn = self::get_approved_column( $form['id'] ); |
365 | 365 | |
366 | - /** |
|
367 | - * If the form doesn't contain the approve field, don't assume anything. |
|
368 | - */ |
|
369 | - if( empty( $approvedcolumn ) ) { |
|
370 | - return; |
|
371 | - } |
|
366 | + /** |
|
367 | + * If the form doesn't contain the approve field, don't assume anything. |
|
368 | + */ |
|
369 | + if( empty( $approvedcolumn ) ) { |
|
370 | + return; |
|
371 | + } |
|
372 | 372 | |
373 | 373 | $entry = GFAPI::get_entry( $entry_id ); |
374 | 374 | |
@@ -481,17 +481,17 @@ discard block |
||
481 | 481 | */ |
482 | 482 | static public function get_approved_column( $form ) { |
483 | 483 | |
484 | - if( empty( $form ) ) { |
|
485 | - return null; |
|
486 | - } |
|
484 | + if( empty( $form ) ) { |
|
485 | + return null; |
|
486 | + } |
|
487 | 487 | |
488 | - if( !is_array( $form ) ) { |
|
489 | - $form = GVCommon::get_form( $form ); |
|
490 | - } |
|
488 | + if( !is_array( $form ) ) { |
|
489 | + $form = GVCommon::get_form( $form ); |
|
490 | + } |
|
491 | 491 | |
492 | 492 | foreach( $form['fields'] as $key => $field ) { |
493 | 493 | |
494 | - $field = (array) $field; |
|
494 | + $field = (array) $field; |
|
495 | 495 | |
496 | 496 | if( !empty( $field['gravityview_approved'] ) ) { |
497 | 497 | if( !empty($field['inputs'][0]['id']) ) { |
@@ -499,14 +499,14 @@ discard block |
||
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
503 | - if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
504 | - foreach ( $field['inputs'] as $key2 => $input ) { |
|
505 | - if ( strtolower( $input['label'] ) == 'approved' ) { |
|
506 | - return $input['id']; |
|
507 | - } |
|
508 | - } |
|
509 | - } |
|
502 | + // Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work.. |
|
503 | + if( 'checkbox' == $field['type'] && isset( $field['inputs'] ) && is_array( $field['inputs'] ) ) { |
|
504 | + foreach ( $field['inputs'] as $key2 => $input ) { |
|
505 | + if ( strtolower( $input['label'] ) == 'approved' ) { |
|
506 | + return $input['id']; |
|
507 | + } |
|
508 | + } |
|
509 | + } |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | return null; |
@@ -255,7 +255,6 @@ |
||
255 | 255 | * Get the default date format for a field based on the field ID and the time format setting |
256 | 256 | * |
257 | 257 | * @since 1.14 |
258 | - |
|
259 | 258 | * @param string $time_format The time format ("12" or "24"). Default: "12" {@since 1.14} |
260 | 259 | * @param int $field_id The ID of the field. Used to figure out full time/hours/minutes/am/pm {@since 1.14} |
261 | 260 | * |
@@ -40,11 +40,11 @@ |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | $field_options['link_phone'] = array( |
43 | - 'type' => 'checkbox', |
|
44 | - 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
45 | - 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
46 | - 'value' => true, |
|
47 | - ); |
|
43 | + 'type' => 'checkbox', |
|
44 | + 'label' => __( 'Make Phone Number Clickable', 'gravityview' ), |
|
45 | + 'desc' => __( 'Allow dialing a number by clicking it?', 'gravityview'), |
|
46 | + 'value' => true, |
|
47 | + ); |
|
48 | 48 | |
49 | 49 | return $field_options; |
50 | 50 | } |
@@ -123,7 +123,7 @@ |
||
123 | 123 | * |
124 | 124 | * Verify permissions. Check expected $_POST. Parse args, then send to process_delete_notes |
125 | 125 | * |
126 | - * @since 1.17 |
|
126 | + * @since 1.17 |
|
127 | 127 | * |
128 | 128 | * @see process_delete_notes |
129 | 129 | * |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $gv_modifiers = array( |
54 | 54 | 'maxwords:(\d+)' => 'modifier_maxwords', /** @see modifier_maxwords */ |
55 | 55 | 'wpautop' => 'modifier_wpautop', /** @see modifier_wpautop */ |
56 | - 'timestamp' => 'modifier_timestamp', /** @see modifier_timestamp */ |
|
56 | + 'timestamp' => 'modifier_timestamp', /** @see modifier_timestamp */ |
|
57 | 57 | ); |
58 | 58 | |
59 | 59 | $return = $value; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | $atts = array( |
255 | 255 | 'format' => self::get_format_from_modifiers( $exploded, false ), |
256 | - 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
256 | + 'human' => in_array( 'human', $exploded ), // {date_created:human} |
|
257 | 257 | 'diff' => in_array( 'diff', $exploded ), // {date_created:diff} |
258 | 258 | 'raw' => in_array( 'raw', $exploded ), // {date_created:raw} |
259 | 259 | 'timestamp' => in_array( 'timestamp', $exploded ), // {date_created:timestamp} |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
176 | 176 | 8 => __( 'View submitted.', 'gravityview' ), |
177 | 177 | 9 => sprintf( |
178 | - /* translators: Date and time the View is scheduled to be published */ |
|
178 | + /* translators: Date and time the View is scheduled to be published */ |
|
179 | 179 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
180 | 180 | // translators: Publish box date format, see http://php.net/date |
181 | 181 | date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
@@ -232,7 +232,6 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @deprecated since 1.12 |
234 | 234 | * @see GravityView_Compatibility::get_plugin_status() |
235 | - |
|
236 | 235 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
237 | 236 | */ |
238 | 237 | static function get_plugin_status( $location = '' ) { |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | |
237 | 237 | if ( $add_default_properties && ! empty( $field->inputs ) ) { |
238 | 238 | foreach ( $field->inputs as $input ) { |
239 | - /** |
|
240 | - * @hack |
|
241 | - * In case of email/email confirmation, the input for email has the same id as the parent field |
|
242 | - */ |
|
239 | + /** |
|
240 | + * @hack |
|
241 | + * In case of email/email confirmation, the input for email has the same id as the parent field |
|
242 | + */ |
|
243 | 243 | if( 'email' === $field->type && false === strpos( $input['id'], '.' ) ) { |
244 | - continue; |
|
245 | - } |
|
244 | + continue; |
|
245 | + } |
|
246 | 246 | $fields["{$input['id']}"] = array( |
247 | 247 | 'label' => rgar( $input, 'label' ), |
248 | 248 | 'customLabel' => rgar( $input, 'customLabel' ), |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | } elseif ( 'delete' === RGForms::get( 'action' ) ) { |
420 | 420 | $criteria['context_view_id'] = isset( $_GET['view_id'] ) ? intval( $_GET['view_id'] ) : null; |
421 | 421 | } elseif( !isset( $criteria['context_view_id'] ) ) { |
422 | - // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
422 | + // Prevent overriding the Context View ID: Some widgets could set the context_view_id (e.g. Recent Entries widget) |
|
423 | 423 | $criteria['context_view_id'] = null; |
424 | 424 | } |
425 | 425 | |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | ), |
1149 | 1149 | ); |
1150 | 1150 | |
1151 | - $fields = $date_created + $fields; |
|
1151 | + $fields = $date_created + $fields; |
|
1152 | 1152 | |
1153 | 1153 | $blacklist_field_types = apply_filters( 'gravityview_blacklist_field_types', $blacklist, NULL ); |
1154 | 1154 | |
@@ -1160,13 +1160,13 @@ discard block |
||
1160 | 1160 | } |
1161 | 1161 | } |
1162 | 1162 | |
1163 | - /** |
|
1164 | - * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1165 | - * @since 1.12 |
|
1166 | - * @param array $fields Sub-set of GF form fields that are sortable |
|
1167 | - * @param int $formid The Gravity Forms form ID that the fields are from |
|
1168 | - */ |
|
1169 | - $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1163 | + /** |
|
1164 | + * @filter `gravityview/common/sortable_fields` Filter the sortable fields |
|
1165 | + * @since 1.12 |
|
1166 | + * @param array $fields Sub-set of GF form fields that are sortable |
|
1167 | + * @param int $formid The Gravity Forms form ID that the fields are from |
|
1168 | + */ |
|
1169 | + $fields = apply_filters( 'gravityview/common/sortable_fields', $fields, $formid ); |
|
1170 | 1170 | |
1171 | 1171 | return $fields; |
1172 | 1172 | } |
@@ -1449,17 +1449,17 @@ discard block |
||
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | |
1452 | - /** |
|
1453 | - * Display updated/error notice |
|
1454 | - * |
|
1455 | - * @param string $notice text/HTML of notice |
|
1456 | - * @param string $class CSS class for notice (`updated` or `error`) |
|
1457 | - * |
|
1458 | - * @return string |
|
1459 | - */ |
|
1460 | - public static function generate_notice( $notice, $class = '' ) { |
|
1461 | - return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1462 | - } |
|
1452 | + /** |
|
1453 | + * Display updated/error notice |
|
1454 | + * |
|
1455 | + * @param string $notice text/HTML of notice |
|
1456 | + * @param string $class CSS class for notice (`updated` or `error`) |
|
1457 | + * |
|
1458 | + * @return string |
|
1459 | + */ |
|
1460 | + public static function generate_notice( $notice, $class = '' ) { |
|
1461 | + return '<div class="gv-notice '.gravityview_sanitize_html_class( $class ) .'">'. $notice .'</div>'; |
|
1462 | + } |
|
1463 | 1463 | |
1464 | 1464 | /** |
1465 | 1465 | * Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
@@ -7,133 +7,133 @@ |
||
7 | 7 | |
8 | 8 | class GravityView_GFFormsModel extends GFFormsModel { |
9 | 9 | |
10 | - /** |
|
11 | - * Given information provided in an entry, get array of media IDs |
|
12 | - * |
|
13 | - * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
14 | - * |
|
15 | - * @see GFFormsModel::create_post() |
|
16 | - * |
|
17 | - * @since 1.17 |
|
18 | - * |
|
19 | - * @param array $form Gravity Forms form array |
|
20 | - * @param array $entry Gravity Forms entry array |
|
21 | - * |
|
22 | - * @return array Array of "Field ID" => "Media IDs" |
|
23 | - */ |
|
24 | - public static function get_post_field_images( $form, $entry ) { |
|
25 | - |
|
26 | - $post_data = self::get_post_fields( $form, $entry ); |
|
27 | - |
|
28 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
29 | - |
|
30 | - $post_images = array(); |
|
31 | - |
|
32 | - foreach ( $media as $media_item ) { |
|
33 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | - if( |
|
35 | - rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
36 | - rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
37 | - rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
38 | - ) { |
|
39 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
40 | - } |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - return $post_images; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Alias of GFFormsModel::get_post_fields(); just making it public |
|
49 | - * |
|
50 | - * @see GFFormsModel::get_post_fields() |
|
51 | - * |
|
52 | - * @since 1.17 |
|
53 | - * |
|
54 | - * @param array $form Gravity Forms form array |
|
55 | - * @param array $entry Gravity Forms entry array |
|
56 | - * |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public static function get_post_fields( $form, $entry ) { |
|
60 | - |
|
61 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
62 | - |
|
63 | - /** |
|
64 | - * If the method changes to public, use Gravity Forms' method |
|
65 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
66 | - */ |
|
67 | - if( $reflection->isPublic() ) { |
|
68 | - return parent::get_post_fields( $form, $entry ); |
|
69 | - } |
|
70 | - |
|
71 | - // It was private; let's make it public |
|
72 | - $reflection->setAccessible( true ); |
|
73 | - |
|
74 | - return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
79 | - * |
|
80 | - * @since 1.16.2 |
|
81 | - * |
|
82 | - * @param string $url URL of the post image to update |
|
83 | - * @param int $post_id ID of the post image to update |
|
84 | - * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
85 | - */ |
|
86 | - public static function copy_post_image( $url, $post_id ) { |
|
87 | - |
|
88 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
89 | - |
|
90 | - /** |
|
91 | - * If the method changes to public, use Gravity Forms' method |
|
92 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
93 | - */ |
|
94 | - if( $reflection->isPublic() ) { |
|
95 | - return parent::copy_post_image( $url, $post_id ); |
|
96 | - } |
|
97 | - |
|
98 | - // It was private; let's make it public |
|
99 | - $reflection->setAccessible( true ); |
|
100 | - |
|
101 | - return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | - * |
|
107 | - * Note: The method became public in GF 1.9.17.7 |
|
108 | - * |
|
109 | - * @see GFFormsModel::media_handle_upload |
|
110 | - * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
111 | - * |
|
112 | - * @uses copy_post_image |
|
113 | - * @uses wp_insert_attachment |
|
114 | - * @uses wp_update_attachment_metadata |
|
115 | - * |
|
116 | - * @param string $url URL of the post image to update |
|
117 | - * @param int $post_id ID of the post image to update |
|
118 | - * @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. |
|
119 | - * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
120 | - */ |
|
121 | - public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
122 | - |
|
123 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
124 | - |
|
125 | - /** |
|
126 | - * If the method changes to public, use Gravity Forms' method |
|
127 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
128 | - */ |
|
129 | - if( $reflection->isPublic() ) { |
|
130 | - return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
131 | - } |
|
132 | - |
|
133 | - // It was private; let's make it public |
|
134 | - $reflection->setAccessible( true ); |
|
135 | - |
|
136 | - return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
137 | - } |
|
10 | + /** |
|
11 | + * Given information provided in an entry, get array of media IDs |
|
12 | + * |
|
13 | + * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
14 | + * |
|
15 | + * @see GFFormsModel::create_post() |
|
16 | + * |
|
17 | + * @since 1.17 |
|
18 | + * |
|
19 | + * @param array $form Gravity Forms form array |
|
20 | + * @param array $entry Gravity Forms entry array |
|
21 | + * |
|
22 | + * @return array Array of "Field ID" => "Media IDs" |
|
23 | + */ |
|
24 | + public static function get_post_field_images( $form, $entry ) { |
|
25 | + |
|
26 | + $post_data = self::get_post_fields( $form, $entry ); |
|
27 | + |
|
28 | + $media = get_attached_media( 'image', $entry['post_id'] ); |
|
29 | + |
|
30 | + $post_images = array(); |
|
31 | + |
|
32 | + foreach ( $media as $media_item ) { |
|
33 | + foreach( (array) $post_data['images'] as $post_data_item ) { |
|
34 | + if( |
|
35 | + rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
36 | + rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
37 | + rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
38 | + ) { |
|
39 | + $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
40 | + } |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + return $post_images; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Alias of GFFormsModel::get_post_fields(); just making it public |
|
49 | + * |
|
50 | + * @see GFFormsModel::get_post_fields() |
|
51 | + * |
|
52 | + * @since 1.17 |
|
53 | + * |
|
54 | + * @param array $form Gravity Forms form array |
|
55 | + * @param array $entry Gravity Forms entry array |
|
56 | + * |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public static function get_post_fields( $form, $entry ) { |
|
60 | + |
|
61 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
62 | + |
|
63 | + /** |
|
64 | + * If the method changes to public, use Gravity Forms' method |
|
65 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
66 | + */ |
|
67 | + if( $reflection->isPublic() ) { |
|
68 | + return parent::get_post_fields( $form, $entry ); |
|
69 | + } |
|
70 | + |
|
71 | + // It was private; let's make it public |
|
72 | + $reflection->setAccessible( true ); |
|
73 | + |
|
74 | + return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
79 | + * |
|
80 | + * @since 1.16.2 |
|
81 | + * |
|
82 | + * @param string $url URL of the post image to update |
|
83 | + * @param int $post_id ID of the post image to update |
|
84 | + * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
85 | + */ |
|
86 | + public static function copy_post_image( $url, $post_id ) { |
|
87 | + |
|
88 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
89 | + |
|
90 | + /** |
|
91 | + * If the method changes to public, use Gravity Forms' method |
|
92 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
93 | + */ |
|
94 | + if( $reflection->isPublic() ) { |
|
95 | + return parent::copy_post_image( $url, $post_id ); |
|
96 | + } |
|
97 | + |
|
98 | + // It was private; let's make it public |
|
99 | + $reflection->setAccessible( true ); |
|
100 | + |
|
101 | + return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
106 | + * |
|
107 | + * Note: The method became public in GF 1.9.17.7 |
|
108 | + * |
|
109 | + * @see GFFormsModel::media_handle_upload |
|
110 | + * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
111 | + * |
|
112 | + * @uses copy_post_image |
|
113 | + * @uses wp_insert_attachment |
|
114 | + * @uses wp_update_attachment_metadata |
|
115 | + * |
|
116 | + * @param string $url URL of the post image to update |
|
117 | + * @param int $post_id ID of the post image to update |
|
118 | + * @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. |
|
119 | + * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
120 | + */ |
|
121 | + public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
122 | + |
|
123 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
124 | + |
|
125 | + /** |
|
126 | + * If the method changes to public, use Gravity Forms' method |
|
127 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
128 | + */ |
|
129 | + if( $reflection->isPublic() ) { |
|
130 | + return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
131 | + } |
|
132 | + |
|
133 | + // It was private; let's make it public |
|
134 | + $reflection->setAccessible( true ); |
|
135 | + |
|
136 | + return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
137 | + } |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | \ No newline at end of file |