1 | <?php |
||
8 | class GravityView_GFFormsModel extends GFFormsModel { |
||
9 | |||
10 | /** |
||
11 | * Make sure the method exists, regardless of GF version |
||
12 | * |
||
13 | * @since 1.22.2 |
||
14 | * |
||
15 | * @return string|false False if not set, version string otherwise |
||
16 | */ |
||
17 | public static function get_database_version() { |
||
18 | |||
19 | if ( is_callable( 'parent::get_database_version' ) ) { |
||
20 | return parent::get_database_version(); |
||
21 | } |
||
22 | |||
23 | return get_option( 'gf_db_version' ); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Determines if the field value matches the conditional logic rule value. |
||
28 | * |
||
29 | * @since 1.22.3 |
||
30 | * |
||
31 | * @param mixed $field_value The field value to be checked. |
||
32 | * @param mixed $target_value The conditional logic rule value. |
||
33 | * @param string $operation The conditional logic rule operator. |
||
34 | * @param null|GF_Field|string $source_field The field the rule is based on, or the entry meta |
||
35 | * @param null|array $rule The conditional logic rule properties. |
||
36 | * @param null|array $form The current form. |
||
37 | * |
||
38 | * @return bool |
||
39 | */ |
||
40 | 1 | public static function is_value_match( $field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null ) { |
|
41 | |||
42 | 1 | if ( 'date_created' === $source_field ) { |
|
43 | $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
||
44 | $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
||
45 | } |
||
46 | |||
47 | 1 | return parent::is_value_match( $field_value, $target_value, $operation, $source_field, $rule, $form ); // TODO: Change the autogenerated stub |
|
48 | } |
||
49 | |||
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 ) { |
||
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 ) { |
||
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 ) { |
||
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() ) { |
||
178 | |||
179 | } |