@@ -22,13 +22,13 @@ discard block |
||
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 |
||
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(); |
@@ -7,181 +7,181 @@ |
||
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 |
@@ -24,7 +24,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -23,16 +23,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | die; |
17 | 17 | } |
18 | 18 | |
19 | -if( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
19 | +if ( ! class_exists( 'Gamajo_Template_Loader' ) ) { |
|
20 | 20 | require( GRAVITYVIEW_DIR . 'includes/lib/class-gamajo-template-loader.php' ); |
21 | 21 | } |
22 | 22 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | 'atts' => NULL, |
158 | 158 | ) ); |
159 | 159 | |
160 | - foreach ($atts as $key => $value) { |
|
161 | - if( is_null( $value ) ) { |
|
160 | + foreach ( $atts as $key => $value ) { |
|
161 | + if ( is_null( $value ) ) { |
|
162 | 162 | continue; |
163 | 163 | } |
164 | 164 | $this->{$key} = $value; |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | */ |
190 | 190 | static function getInstance( $passed_post = NULL ) { |
191 | 191 | |
192 | - if( empty( self::$instance ) ) { |
|
192 | + if ( empty( self::$instance ) ) { |
|
193 | 193 | self::$instance = new self( $passed_post ); |
194 | 194 | } |
195 | 195 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public function getCurrentField( $key = NULL ) { |
204 | 204 | |
205 | - if( !empty( $key ) ) { |
|
206 | - if( isset( $this->_current_field[ $key ] ) ) { |
|
205 | + if ( ! empty( $key ) ) { |
|
206 | + if ( isset( $this->_current_field[ $key ] ) ) { |
|
207 | 207 | return $this->_current_field[ $key ]; |
208 | 208 | } |
209 | 209 | return NULL; |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | |
215 | 215 | public function setCurrentFieldSetting( $key, $value ) { |
216 | 216 | |
217 | - if( !empty( $this->_current_field ) ) { |
|
218 | - $this->_current_field['field_settings'][ $key ] = $value; |
|
217 | + if ( ! empty( $this->_current_field ) ) { |
|
218 | + $this->_current_field[ 'field_settings' ][ $key ] = $value; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | } |
222 | 222 | |
223 | 223 | public function getCurrentFieldSetting( $key ) { |
224 | - $settings = $this->getCurrentField('field_settings'); |
|
224 | + $settings = $this->getCurrentField( 'field_settings' ); |
|
225 | 225 | |
226 | - if( $settings && !empty( $settings[ $key ] ) ) { |
|
226 | + if ( $settings && ! empty( $settings[ $key ] ) ) { |
|
227 | 227 | return $settings[ $key ]; |
228 | 228 | } |
229 | 229 | |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | */ |
255 | 255 | public function getAtts( $key = NULL ) { |
256 | 256 | |
257 | - if( !empty( $key ) ) { |
|
258 | - if( isset( $this->atts[ $key ] ) ) { |
|
257 | + if ( ! empty( $key ) ) { |
|
258 | + if ( isset( $this->atts[ $key ] ) ) { |
|
259 | 259 | return $this->atts[ $key ]; |
260 | 260 | } |
261 | 261 | return NULL; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | |
322 | 322 | $fields = empty( $this->fields ) ? NULL : $this->fields; |
323 | 323 | |
324 | - if( $fields && !empty( $key ) ) { |
|
324 | + if ( $fields && ! empty( $key ) ) { |
|
325 | 325 | $fields = isset( $fields[ $key ] ) ? $fields[ $key ] : NULL; |
326 | 326 | } |
327 | 327 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | */ |
342 | 342 | public function getField( $key ) { |
343 | 343 | |
344 | - if( !empty( $key ) ) { |
|
345 | - if( isset( $this->fields[ $key ] ) ) { |
|
344 | + if ( ! empty( $key ) ) { |
|
345 | + if ( isset( $this->fields[ $key ] ) ) { |
|
346 | 346 | return $this->fields[ $key ]; |
347 | 347 | } |
348 | 348 | } |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | public function getPaginationCounts() { |
443 | 443 | |
444 | 444 | $paging = $this->getPaging(); |
445 | - $offset = $paging['offset']; |
|
446 | - $page_size = $paging['page_size']; |
|
445 | + $offset = $paging[ 'offset' ]; |
|
446 | + $page_size = $paging[ 'page_size' ]; |
|
447 | 447 | $total = $this->getTotalEntries(); |
448 | 448 | |
449 | 449 | if ( empty( $total ) ) { |
@@ -464,7 +464,7 @@ discard block |
||
464 | 464 | */ |
465 | 465 | list( $first, $last, $total ) = apply_filters( 'gravityview_pagination_counts', array( $first, $last, $total ) ); |
466 | 466 | |
467 | - return array( 'first' => (int) $first, 'last' => (int) $last, 'total' => (int) $total ); |
|
467 | + return array( 'first' => (int)$first, 'last' => (int)$last, 'total' => (int)$total ); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -548,16 +548,16 @@ discard block |
||
548 | 548 | */ |
549 | 549 | public function getCurrentEntry() { |
550 | 550 | |
551 | - if( in_array( $this->getContext(), array( 'edit', 'single') ) ) { |
|
551 | + if ( in_array( $this->getContext(), array( 'edit', 'single' ) ) ) { |
|
552 | 552 | $entries = $this->getEntries(); |
553 | - $entry = $entries[0]; |
|
553 | + $entry = $entries[ 0 ]; |
|
554 | 554 | } else { |
555 | 555 | $entry = $this->_current_entry; |
556 | 556 | } |
557 | 557 | |
558 | 558 | /** @since 1.16 Fixes DataTables empty entry issue */ |
559 | - if ( empty( $entry ) && ! empty( $this->_current_field['entry'] ) ) { |
|
560 | - $entry = $this->_current_field['entry']; |
|
559 | + if ( empty( $entry ) && ! empty( $this->_current_field[ 'entry' ] ) ) { |
|
560 | + $entry = $this->_current_field[ 'entry' ]; |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | return $entry; |
@@ -591,8 +591,8 @@ discard block |
||
591 | 591 | */ |
592 | 592 | public function renderZone( $zone = '', $atts = array() ) { |
593 | 593 | |
594 | - if( empty( $zone ) ) { |
|
595 | - do_action('gravityview_log_error', 'GravityView_View[renderZone] No zone defined.'); |
|
594 | + if ( empty( $zone ) ) { |
|
595 | + do_action( 'gravityview_log_error', 'GravityView_View[renderZone] No zone defined.' ); |
|
596 | 596 | return NULL; |
597 | 597 | } |
598 | 598 | |
@@ -601,33 +601,33 @@ discard block |
||
601 | 601 | 'context' => $this->getContext(), |
602 | 602 | 'entry' => $this->getCurrentEntry(), |
603 | 603 | 'form' => $this->getForm(), |
604 | - 'hide_empty' => $this->getAtts('hide_empty'), |
|
604 | + 'hide_empty' => $this->getAtts( 'hide_empty' ), |
|
605 | 605 | ); |
606 | 606 | |
607 | 607 | $final_atts = wp_parse_args( $atts, $defaults ); |
608 | 608 | |
609 | 609 | $output = ''; |
610 | 610 | |
611 | - $final_atts['zone_id'] = "{$final_atts['context']}_{$final_atts['slug']}-{$zone}"; |
|
611 | + $final_atts[ 'zone_id' ] = "{$final_atts[ 'context' ]}_{$final_atts[ 'slug' ]}-{$zone}"; |
|
612 | 612 | |
613 | - $fields = $this->getField( $final_atts['zone_id'] ); |
|
613 | + $fields = $this->getField( $final_atts[ 'zone_id' ] ); |
|
614 | 614 | |
615 | 615 | // Backward compatibility |
616 | - if( 'table' === $this->getTemplatePartSlug() ) { |
|
616 | + if ( 'table' === $this->getTemplatePartSlug() ) { |
|
617 | 617 | /** |
618 | 618 | * Modify the fields displayed in the table |
619 | 619 | * @var array |
620 | 620 | */ |
621 | - $fields = apply_filters("gravityview_table_cells", $fields, $this ); |
|
621 | + $fields = apply_filters( "gravityview_table_cells", $fields, $this ); |
|
622 | 622 | } |
623 | 623 | |
624 | - if( empty( $fields ) ) { |
|
624 | + if ( empty( $fields ) ) { |
|
625 | 625 | return NULL; |
626 | 626 | } |
627 | 627 | |
628 | 628 | $field_output = ''; |
629 | 629 | foreach ( $fields as $field ) { |
630 | - $final_atts['field'] = $field; |
|
630 | + $final_atts[ 'field' ] = $field; |
|
631 | 631 | |
632 | 632 | $field_output .= gravityview_field_output( $final_atts ); |
633 | 633 | } |
@@ -638,17 +638,17 @@ discard block |
||
638 | 638 | * @since 1.7.6 |
639 | 639 | * @param boolean $hide_empty_zone Default: false |
640 | 640 | */ |
641 | - if( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
641 | + if ( empty( $field_output ) && apply_filters( 'gravityview/render/hide-empty-zone', false ) ) { |
|
642 | 642 | return NULL; |
643 | 643 | } |
644 | 644 | |
645 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
646 | - $output .= '<div class="'.gravityview_sanitize_html_class( $final_atts['wrapper_class'] ).'">'; |
|
645 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
646 | + $output .= '<div class="' . gravityview_sanitize_html_class( $final_atts[ 'wrapper_class' ] ) . '">'; |
|
647 | 647 | } |
648 | 648 | |
649 | 649 | $output .= $field_output; |
650 | 650 | |
651 | - if( !empty( $final_atts['wrapper_class'] ) ) { |
|
651 | + if ( ! empty( $final_atts[ 'wrapper_class' ] ) ) { |
|
652 | 652 | $output .= '</div>'; |
653 | 653 | } |
654 | 654 | |
@@ -668,7 +668,7 @@ discard block |
||
668 | 668 | */ |
669 | 669 | function locate_template( $template_names, $load = false, $require_once = true ) { |
670 | 670 | |
671 | - if( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
671 | + if ( is_string( $template_names ) && isset( $this->located_templates[ $template_names ] ) ) { |
|
672 | 672 | |
673 | 673 | $located = $this->located_templates[ $template_names ]; |
674 | 674 | |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | // Set $load to always false so we handle it here. |
678 | 678 | $located = parent::locate_template( $template_names, false, $require_once ); |
679 | 679 | |
680 | - if( is_string( $template_names ) ) { |
|
680 | + if ( is_string( $template_names ) ) { |
|
681 | 681 | $this->located_templates[ $template_names ] = $located; |
682 | 682 | } |
683 | 683 | } |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | * @return mixed|null The stored data. |
696 | 696 | */ |
697 | 697 | public function __get( $name ) { |
698 | - if( isset( $this->{$name} ) ) { |
|
698 | + if ( isset( $this->{$name} ) ) { |
|
699 | 699 | return $this->{$name}; |
700 | 700 | } else { |
701 | 701 | return NULL; |
@@ -724,15 +724,15 @@ discard block |
||
724 | 724 | $additional = array(); |
725 | 725 | |
726 | 726 | // form-19-table-body.php |
727 | - $additional[] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
727 | + $additional[ ] = sprintf( 'form-%d-%s-%s.php', $this->getFormId(), $slug, $name ); |
|
728 | 728 | |
729 | 729 | // view-3-table-body.php |
730 | - $additional[] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
730 | + $additional[ ] = sprintf( 'view-%d-%s-%s.php', $this->getViewId(), $slug, $name ); |
|
731 | 731 | |
732 | - if( $this->getPostId() ) { |
|
732 | + if ( $this->getPostId() ) { |
|
733 | 733 | |
734 | 734 | // page-19-table-body.php |
735 | - $additional[] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
735 | + $additional[ ] = sprintf( 'page-%d-%s-%s.php', $this->getPostId(), $slug, $name ); |
|
736 | 736 | } |
737 | 737 | |
738 | 738 | // Combine with existing table-body.php and table.php |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | |
755 | 755 | do_action( 'gravityview_log_debug', '[render] Rendering Template File', $template_file ); |
756 | 756 | |
757 | - if( !empty( $template_file) ) { |
|
757 | + if ( ! empty( $template_file ) ) { |
|
758 | 758 | |
759 | 759 | if ( $require_once ) { |
760 | 760 | require_once( $template_file ); |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | */ |
772 | 772 | public function render_widget_hooks( $view_id ) { |
773 | 773 | |
774 | - if( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
774 | + if ( empty( $view_id ) || 'single' == gravityview_get_context() ) { |
|
775 | 775 | do_action( 'gravityview_log_debug', __METHOD__ . ' - Not rendering widgets; single entry' ); |
776 | 776 | return; |
777 | 777 | } |
@@ -779,9 +779,9 @@ discard block |
||
779 | 779 | $view_data = gravityview_get_current_view_data( $view_id ); |
780 | 780 | |
781 | 781 | // get View widget configuration |
782 | - $widgets = (array)$view_data['widgets']; |
|
782 | + $widgets = (array)$view_data[ 'widgets' ]; |
|
783 | 783 | |
784 | - switch( current_filter() ) { |
|
784 | + switch ( current_filter() ) { |
|
785 | 785 | default: |
786 | 786 | case 'gravityview_before': |
787 | 787 | $zone = 'header'; |
@@ -795,9 +795,9 @@ discard block |
||
795 | 795 | * Filter widgets not in the current zone |
796 | 796 | * @since 1.16 |
797 | 797 | */ |
798 | - foreach( $widgets as $key => $widget ) { |
|
798 | + foreach ( $widgets as $key => $widget ) { |
|
799 | 799 | // The widget isn't in the current zone |
800 | - if( false === strpos( $key, $zone ) ) { |
|
800 | + if ( false === strpos( $key, $zone ) ) { |
|
801 | 801 | unset( $widgets[ $key ] ); |
802 | 802 | } |
803 | 803 | } |
@@ -812,8 +812,8 @@ discard block |
||
812 | 812 | } |
813 | 813 | |
814 | 814 | // Prevent being called twice |
815 | - if( did_action( $zone.'_'.$view_id.'_widgets' ) ) { |
|
816 | - do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__ , $zone.'_'.$view_id.'_widgets' ) ); |
|
815 | + if ( did_action( $zone . '_' . $view_id . '_widgets' ) ) { |
|
816 | + do_action( 'gravityview_log_debug', sprintf( '%s - Not rendering %s; already rendered', __METHOD__, $zone . '_' . $view_id . '_widgets' ) ); |
|
817 | 817 | return; |
818 | 818 | } |
819 | 819 | |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * @param string $zone Current widget zone, either `header` or `footer` |
830 | 830 | * @param array $widgets Array of widget configurations for the current zone, as set by `gravityview_get_current_view_data()['widgets']` |
831 | 831 | */ |
832 | - $css_class = apply_filters('gravityview/widgets/wrapper_css_class', 'gv-grid gv-widgets-' . $zone, $zone, $widgets ); |
|
832 | + $css_class = apply_filters( 'gravityview/widgets/wrapper_css_class', 'gv-grid gv-widgets-' . $zone, $zone, $widgets ); |
|
833 | 833 | |
834 | 834 | $css_class = gravityview_sanitize_html_class( $css_class ); |
835 | 835 | |
@@ -837,17 +837,17 @@ discard block |
||
837 | 837 | ?> |
838 | 838 | <div class="<?php echo $css_class; ?>"> |
839 | 839 | <?php |
840 | - foreach( $rows as $row ) { |
|
841 | - foreach( $row as $col => $areas ) { |
|
842 | - $column = ($col == '2-2') ? '1-2 gv-right' : $col.' gv-left'; |
|
840 | + foreach ( $rows as $row ) { |
|
841 | + foreach ( $row as $col => $areas ) { |
|
842 | + $column = ( $col == '2-2' ) ? '1-2 gv-right' : $col . ' gv-left'; |
|
843 | 843 | ?> |
844 | 844 | <div class="gv-grid-col-<?php echo esc_attr( $column ); ?>"> |
845 | 845 | <?php |
846 | - if( !empty( $areas ) ) { |
|
847 | - foreach( $areas as $area ) { |
|
848 | - if( !empty( $widgets[ $zone .'_'. $area['areaid'] ] ) ) { |
|
849 | - foreach( $widgets[ $zone .'_'. $area['areaid'] ] as $widget ) { |
|
850 | - do_action( "gravityview_render_widget_{$widget['id']}", $widget ); |
|
846 | + if ( ! empty( $areas ) ) { |
|
847 | + foreach ( $areas as $area ) { |
|
848 | + if ( ! empty( $widgets[ $zone . '_' . $area[ 'areaid' ] ] ) ) { |
|
849 | + foreach ( $widgets[ $zone . '_' . $area[ 'areaid' ] ] as $widget ) { |
|
850 | + do_action( "gravityview_render_widget_{$widget[ 'id' ]}", $widget ); |
|
851 | 851 | } |
852 | 852 | } |
853 | 853 | } |
@@ -863,8 +863,8 @@ discard block |
||
863 | 863 | * Prevent widgets from being called twice. |
864 | 864 | * Checking for loop_start prevents themes and plugins that pre-process shortcodes from triggering the action before displaying. Like, ahem, the Divi theme and WordPress SEO plugin |
865 | 865 | */ |
866 | - if( did_action( 'loop_start' ) ) { |
|
867 | - do_action( $zone.'_'.$view_id.'_widgets' ); |
|
866 | + if ( did_action( 'loop_start' ) ) { |
|
867 | + do_action( $zone . '_' . $view_id . '_widgets' ); |
|
868 | 868 | } |
869 | 869 | } |
870 | 870 |