@@ -12,19 +12,19 @@ |
||
12 | 12 | </div> |
13 | 13 | <?php |
14 | 14 | echo $this->get_tooltip(); |
15 | - echo $this->get_field_desc().' '; |
|
15 | + echo $this->get_field_desc() . ' '; |
|
16 | 16 | |
17 | 17 | $this->render_input(); |
18 | 18 | |
19 | 19 | } |
20 | 20 | |
21 | 21 | function render_input( $override_input = null ) { |
22 | - if( isset( $override_input ) ) { |
|
22 | + if ( isset( $override_input ) ) { |
|
23 | 23 | echo $override_input; |
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | - foreach( $this->field['options'] as $value => $label ) : ?> |
|
27 | + foreach ( $this->field[ 'options' ] as $value => $label ) : ?> |
|
28 | 28 | <label class="<?php echo $this->get_label_class(); ?>"> |
29 | 29 | <input name="<?php echo esc_attr( $this->name ); ?>" id="<?php echo $this->get_field_id(); ?>-<?php echo esc_attr( $value ); ?>" type="radio" value="<?php echo esc_attr( $value ); ?>" <?php checked( $value, $this->value, true ); ?> /> <?php echo esc_html( $label ); ?> |
30 | 30 | </label> |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | |
267 | 267 | // Dequeue other jQuery styles even if no-conflict is off. |
268 | 268 | // Terrible-looking tabs help no one. |
269 | - if( !empty( $wp_styles->registered ) ) { |
|
269 | + if( !empty( $wp_styles->registered ) ) { |
|
270 | 270 | foreach ($wp_styles->registered as $key => $style) { |
271 | 271 | if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
272 | 272 | wp_dequeue_style( $key ); |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | |
338 | 338 | //unregistering scripts |
339 | 339 | $registered = array(); |
340 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
341 | - if( in_array( $handle, $required_objects ) ){ |
|
340 | + foreach( $wp_objects->registered as $handle => $script_registration ) { |
|
341 | + if( in_array( $handle, $required_objects ) ) { |
|
342 | 342 | $registered[ $handle ] = $script_registration; |
343 | 343 | } |
344 | 344 | } |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
183 | 183 | 8 => __( 'View submitted.', 'gravityview' ), |
184 | 184 | 9 => sprintf( |
185 | - /* translators: Date and time the View is scheduled to be published */ |
|
185 | + /* translators: Date and time the View is scheduled to be published */ |
|
186 | 186 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
187 | 187 | // translators: Publish box date format, see http://php.net/date |
188 | 188 | date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
@@ -222,39 +222,39 @@ discard block |
||
222 | 222 | } |
223 | 223 | |
224 | 224 | $wp_allowed_scripts = array( |
225 | - 'common', |
|
226 | - 'admin-bar', |
|
227 | - 'autosave', |
|
228 | - 'post', |
|
225 | + 'common', |
|
226 | + 'admin-bar', |
|
227 | + 'autosave', |
|
228 | + 'post', |
|
229 | 229 | 'inline-edit-post', |
230 | - 'utils', |
|
231 | - 'svg-painter', |
|
232 | - 'wp-auth-check', |
|
233 | - 'heartbeat', |
|
230 | + 'utils', |
|
231 | + 'svg-painter', |
|
232 | + 'wp-auth-check', |
|
233 | + 'heartbeat', |
|
234 | 234 | 'media-editor', |
235 | 235 | 'media-upload', |
236 | - 'thickbox', |
|
236 | + 'thickbox', |
|
237 | 237 | 'wp-color-picker', |
238 | 238 | |
239 | - // Settings |
|
239 | + // Settings |
|
240 | 240 | 'gv-admin-edd-license', |
241 | 241 | |
242 | - // Common |
|
243 | - 'select2-js', |
|
244 | - 'qtip-js', |
|
242 | + // Common |
|
243 | + 'select2-js', |
|
244 | + 'qtip-js', |
|
245 | 245 | |
246 | - // jQuery |
|
246 | + // jQuery |
|
247 | 247 | 'jquery', |
248 | - 'jquery-ui-core', |
|
249 | - 'jquery-ui-sortable', |
|
250 | - 'jquery-ui-datepicker', |
|
251 | - 'jquery-ui-dialog', |
|
252 | - 'jquery-ui-slider', |
|
248 | + 'jquery-ui-core', |
|
249 | + 'jquery-ui-sortable', |
|
250 | + 'jquery-ui-datepicker', |
|
251 | + 'jquery-ui-dialog', |
|
252 | + 'jquery-ui-slider', |
|
253 | 253 | 'jquery-ui-dialog', |
254 | 254 | 'jquery-ui-tabs', |
255 | 255 | 'jquery-ui-draggable', |
256 | 256 | 'jquery-ui-droppable', |
257 | - 'jquery-ui-accordion', |
|
257 | + 'jquery-ui-accordion', |
|
258 | 258 | ); |
259 | 259 | |
260 | 260 | $this->remove_conflicts( $wp_scripts, $wp_allowed_scripts, 'scripts' ); |
@@ -288,23 +288,23 @@ discard block |
||
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | - $wp_allowed_styles = array( |
|
292 | - 'admin-bar', |
|
293 | - 'colors', |
|
294 | - 'ie', |
|
295 | - 'wp-auth-check', |
|
296 | - 'media-views', |
|
291 | + $wp_allowed_styles = array( |
|
292 | + 'admin-bar', |
|
293 | + 'colors', |
|
294 | + 'ie', |
|
295 | + 'wp-auth-check', |
|
296 | + 'media-views', |
|
297 | 297 | 'thickbox', |
298 | 298 | 'dashicons', |
299 | - 'wp-jquery-ui-dialog', |
|
300 | - 'jquery-ui-sortable', |
|
299 | + 'wp-jquery-ui-dialog', |
|
300 | + 'jquery-ui-sortable', |
|
301 | 301 | |
302 | - // Settings |
|
303 | - 'gravityview_settings', |
|
302 | + // Settings |
|
303 | + 'gravityview_settings', |
|
304 | 304 | |
305 | - // @todo qTip styles not loading for some reason! |
|
306 | - 'jquery-qtip.js', |
|
307 | - ); |
|
305 | + // @todo qTip styles not loading for some reason! |
|
306 | + 'jquery-qtip.js', |
|
307 | + ); |
|
308 | 308 | |
309 | 309 | $this->remove_conflicts( $wp_styles, $wp_allowed_styles, 'styles' ); |
310 | 310 | |
@@ -324,32 +324,32 @@ discard block |
||
324 | 324 | */ |
325 | 325 | private function remove_conflicts( &$wp_objects, $required_objects, $type = 'scripts' ) { |
326 | 326 | |
327 | - /** |
|
328 | - * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
329 | - * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
330 | - * @param array $required_objects |
|
331 | - */ |
|
332 | - $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
333 | - |
|
334 | - //reset queue |
|
335 | - $queue = array(); |
|
336 | - foreach( $wp_objects->queue as $object ) { |
|
337 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
338 | - $queue[] = $object; |
|
339 | - } |
|
340 | - } |
|
341 | - $wp_objects->queue = $queue; |
|
342 | - |
|
343 | - $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
344 | - |
|
345 | - //unregistering scripts |
|
346 | - $registered = array(); |
|
347 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
348 | - if( in_array( $handle, $required_objects ) ){ |
|
349 | - $registered[ $handle ] = $script_registration; |
|
350 | - } |
|
351 | - } |
|
352 | - $wp_objects->registered = $registered; |
|
327 | + /** |
|
328 | + * @filter `gravityview_noconflict_{$type}` Modify the list of no conflict scripts or styles\n |
|
329 | + * Filter is `gravityview_noconflict_scripts` or `gravityview_noconflict_styles` |
|
330 | + * @param array $required_objects |
|
331 | + */ |
|
332 | + $required_objects = apply_filters( "gravityview_noconflict_{$type}", $required_objects ); |
|
333 | + |
|
334 | + //reset queue |
|
335 | + $queue = array(); |
|
336 | + foreach( $wp_objects->queue as $object ) { |
|
337 | + if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
338 | + $queue[] = $object; |
|
339 | + } |
|
340 | + } |
|
341 | + $wp_objects->queue = $queue; |
|
342 | + |
|
343 | + $required_objects = $this->add_script_dependencies( $wp_objects->registered, $required_objects ); |
|
344 | + |
|
345 | + //unregistering scripts |
|
346 | + $registered = array(); |
|
347 | + foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
348 | + if( in_array( $handle, $required_objects ) ){ |
|
349 | + $registered[ $handle ] = $script_registration; |
|
350 | + } |
|
351 | + } |
|
352 | + $wp_objects->registered = $registered; |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | /** |
@@ -412,7 +412,6 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @deprecated since 1.12 |
414 | 414 | * @see GravityView_Compatibility::get_plugin_status() |
415 | - |
|
416 | 415 | * @return boolean|string True: plugin is active; False: plugin file doesn't exist at path; 'inactive' it's inactive |
417 | 416 | */ |
418 | 417 | static function get_plugin_status( $location = '' ) { |
@@ -4,10 +4,10 @@ discard block |
||
4 | 4 | |
5 | 5 | function __construct() { |
6 | 6 | |
7 | - if( ! is_admin() ) { return; } |
|
7 | + if ( ! is_admin() ) { return; } |
|
8 | 8 | |
9 | 9 | // If Gravity Forms isn't active or compatibile, stop loading |
10 | - if( false === GravityView_Compatibility::is_valid() ) { |
|
10 | + if ( false === GravityView_Compatibility::is_valid() ) { |
|
11 | 11 | return; |
12 | 12 | } |
13 | 13 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-migrate.php' ); |
26 | 26 | |
27 | 27 | // Don't load tooltips if on Gravity Forms, otherwise it overrides translations |
28 | - if( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && !GFForms::is_gravity_page() ) { |
|
28 | + if ( class_exists( 'GFCommon' ) && class_exists( 'GFForms' ) && ! GFForms::is_gravity_page() ) { |
|
29 | 29 | require_once( GFCommon::get_base_path() . '/tooltips.php' ); |
30 | 30 | } |
31 | 31 | |
@@ -50,18 +50,18 @@ discard block |
||
50 | 50 | add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) ); |
51 | 51 | add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) ); |
52 | 52 | |
53 | - add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) ); |
|
53 | + add_filter( 'plugin_action_links_' . plugin_basename( GRAVITYVIEW_FILE ), array( $this, 'plugin_action_links' ) ); |
|
54 | 54 | |
55 | 55 | add_action( 'plugins_loaded', array( $this, 'backend_actions' ), 100 ); |
56 | 56 | |
57 | 57 | //Hooks for no-conflict functionality |
58 | - add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000); |
|
59 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9); |
|
58 | + add_action( 'wp_print_scripts', array( $this, 'no_conflict_scripts' ), 1000 ); |
|
59 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_scripts' ), 9 ); |
|
60 | 60 | |
61 | - add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000); |
|
62 | - add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11); |
|
63 | - add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1); |
|
64 | - add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1); |
|
61 | + add_action( 'wp_print_styles', array( $this, 'no_conflict_styles' ), 1000 ); |
|
62 | + add_action( 'admin_print_styles', array( $this, 'no_conflict_styles' ), 11 ); |
|
63 | + add_action( 'admin_print_footer_scripts', array( $this, 'no_conflict_styles' ), 1 ); |
|
64 | + add_action( 'admin_footer', array( $this, 'no_conflict_styles' ), 1 ); |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | public function backend_actions() { |
75 | 75 | |
76 | 76 | /** @define "GRAVITYVIEW_DIR" "../" */ |
77 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.field.type.php' ); |
|
78 | - include_once( GRAVITYVIEW_DIR .'includes/admin/class.render.settings.php' ); |
|
79 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-label.php' ); |
|
80 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-views.php' ); |
|
81 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-welcome.php' ); |
|
82 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-add-shortcode.php' ); |
|
83 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
77 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class.field.type.php' ); |
|
78 | + include_once( GRAVITYVIEW_DIR . 'includes/admin/class.render.settings.php' ); |
|
79 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-label.php' ); |
|
80 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-views.php' ); |
|
81 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-welcome.php' ); |
|
82 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-add-shortcode.php' ); |
|
83 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @action `gravityview_include_backend_actions` Triggered after all GravityView admin files are loaded |
87 | 87 | * |
88 | 88 | * Nice place to insert extensions' backend stuff |
89 | 89 | */ |
90 | - do_action('gravityview_include_backend_actions'); |
|
90 | + do_action( 'gravityview_include_backend_actions' ); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | |
104 | 104 | $actions = array(); |
105 | 105 | |
106 | - if( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
107 | - $actions[] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
106 | + if ( GVCommon::has_cap( 'gravityview_view_settings' ) ) { |
|
107 | + $actions[ ] = sprintf( '<a href="%s">%s</a>', admin_url( 'edit.php?post_type=gravityview&page=gravityview_settings' ), esc_html__( 'Settings', 'gravityview' ) ); |
|
108 | 108 | } |
109 | 109 | |
110 | - if( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
111 | - $actions[] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
110 | + if ( GVCommon::has_cap( 'gravityview_support_port' ) ) { |
|
111 | + $actions[ ] = '<a href="http://docs.gravityview.co">' . esc_html__( 'Support', 'gravityview' ) . '</a>'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | return array_merge( $actions, $links ); |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | function post_updated_messages( $messages, $bulk_counts = NULL ) { |
132 | 132 | global $post; |
133 | 133 | |
134 | - $post_id = isset($_GET['post']) ? intval($_GET['post']) : ( is_object( $post ) && isset( $post->ID ) ? $post->ID : NULL ); |
|
134 | + $post_id = isset( $_GET[ 'post' ] ) ? intval( $_GET[ 'post' ] ) : ( is_object( $post ) && isset( $post->ID ) ? $post->ID : NULL ); |
|
135 | 135 | |
136 | 136 | // By default, there will only be one item being modified. |
137 | 137 | // When in the `bulk_post_updated_messages` filter, there will be passed a number |
138 | 138 | // of modified items that will override this array. |
139 | - $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1 , 'locked' => 1 , 'deleted' => 1 , 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
139 | + $bulk_counts = is_null( $bulk_counts ) ? array( 'updated' => 1, 'locked' => 1, 'deleted' => 1, 'trashed' => 1, 'untrashed' => 1 ) : $bulk_counts; |
|
140 | 140 | |
141 | 141 | |
142 | 142 | // If we're starting fresh, a new form was created. |
@@ -145,60 +145,60 @@ discard block |
||
145 | 145 | |
146 | 146 | $new_form_text = ''; |
147 | 147 | |
148 | - if( !empty( $start_fresh ) ) { |
|
148 | + if ( ! empty( $start_fresh ) ) { |
|
149 | 149 | |
150 | 150 | // Get the form that was created |
151 | 151 | $connected_form = gravityview_get_form_id( $post_id ); |
152 | 152 | |
153 | - if( !empty( $connected_form ) ) { |
|
153 | + if ( ! empty( $connected_form ) ) { |
|
154 | 154 | $form = gravityview_get_form( $connected_form ); |
155 | - $form_name = esc_attr( $form['title'] ); |
|
155 | + $form_name = esc_attr( $form[ 'title' ] ); |
|
156 | 156 | $image = self::get_floaty(); |
157 | - $new_form_text .= '<h3>'.$image.sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ).'</h3>'; |
|
158 | - $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
157 | + $new_form_text .= '<h3>' . $image . sprintf( __( 'A new form was created for this View: "%s"', 'gravityview' ), $form_name ) . '</h3>'; |
|
158 | + $new_form_text .= sprintf( __( '%sThere are no entries for the new form, so the View will also be empty.%s To start collecting entries, you can add submissions through %sthe preview form%s and also embed the form on a post or page using this code: %s |
|
159 | 159 | |
160 | 160 | You can %sedit the form%s in Gravity Forms and the updated fields will be available here. Don’t forget to %scustomize the form settings%s. |
161 | - ', 'gravityview' ), '<strong>', '</strong>', '<a href="'.site_url( '?gf_page=preview&id='.$connected_form ).'">', '</a>', '<code>[gravityform id="'.$connected_form.'" name="'.$form_name.'"]</code>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&id='.$connected_form ).'">', '</a>', '<a href="'.admin_url( 'admin.php?page=gf_edit_forms&view=settings&id='.$connected_form ).'">', '</a>'); |
|
161 | + ', 'gravityview' ), '<strong>', '</strong>', '<a href="' . site_url( '?gf_page=preview&id=' . $connected_form ) . '">', '</a>', '<code>[gravityform id="' . $connected_form . '" name="' . $form_name . '"]</code>', '<a href="' . admin_url( 'admin.php?page=gf_edit_forms&id=' . $connected_form ) . '">', '</a>', '<a href="' . admin_url( 'admin.php?page=gf_edit_forms&view=settings&id=' . $connected_form ) . '">', '</a>' ); |
|
162 | 162 | $new_form_text = wpautop( $new_form_text ); |
163 | 163 | |
164 | 164 | delete_post_meta( $post_id, '_gravityview_start_fresh' ); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - $messages['gravityview'] = array( |
|
168 | + $messages[ 'gravityview' ] = array( |
|
169 | 169 | 0 => '', // Unused. Messages start at index 1. |
170 | 170 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
171 | - 1 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
171 | + 1 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
172 | 172 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
173 | - 2 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
173 | + 2 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
174 | 174 | 3 => __( 'View deleted.', 'gravityview' ), |
175 | 175 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
176 | - 4 => sprintf(__( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
176 | + 4 => sprintf( __( 'View updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
177 | 177 | /* translators: %s: date and time of the revision */ |
178 | - 5 => isset( $_GET['revision'] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
178 | + 5 => isset( $_GET[ 'revision' ] ) ? sprintf( __( 'View restored to revision from %s', 'gravityview' ), wp_post_revision_title( (int)$_GET[ 'revision' ], false ) ) : false, |
|
179 | 179 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
180 | - 6 => sprintf(__( 'View published. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
180 | + 6 => sprintf( __( 'View published. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
181 | 181 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
182 | - 7 => sprintf(__( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>') . $new_form_text, |
|
182 | + 7 => sprintf( __( 'View saved. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ) . $new_form_text, |
|
183 | 183 | 8 => __( 'View submitted.', 'gravityview' ), |
184 | 184 | 9 => sprintf( |
185 | 185 | /* translators: Date and time the View is scheduled to be published */ |
186 | 186 | __( 'View scheduled for: %1$s.', 'gravityview' ), |
187 | 187 | // translators: Publish box date format, see http://php.net/date |
188 | - date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
188 | + date_i18n( __( 'M j, Y @ G:i', 'gravityview' ), strtotime( ( isset( $post->post_date ) ? $post->post_date : NULL ) ) ) |
|
189 | 189 | ) . $new_form_text, |
190 | 190 | /* translators: %s and %s are HTML tags linking to the View on the website */ |
191 | - 10 => sprintf(__( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="'.get_permalink( $post_id ).'">', '</a>'), |
|
191 | + 10 => sprintf( __( 'View draft updated. %sView on website.%s', 'gravityview' ), '<a href="' . get_permalink( $post_id ) . '">', '</a>' ), |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * These apply to `bulk_post_updated_messages` |
195 | 195 | * @file wp-admin/edit.php |
196 | 196 | */ |
197 | - 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts['updated'], 'gravityview' ), |
|
198 | - 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts['locked'], 'gravityview' ), |
|
199 | - 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts['deleted'], 'gravityview' ), |
|
200 | - 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts['trashed'], 'gravityview' ), |
|
201 | - 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts['untrashed'], 'gravityview' ), |
|
197 | + 'updated' => _n( '%s View updated.', '%s Views updated.', $bulk_counts[ 'updated' ], 'gravityview' ), |
|
198 | + 'locked' => _n( '%s View not updated, somebody is editing it.', '%s Views not updated, somebody is editing them.', $bulk_counts[ 'locked' ], 'gravityview' ), |
|
199 | + 'deleted' => _n( '%s View permanently deleted.', '%s Views permanently deleted.', $bulk_counts[ 'deleted' ], 'gravityview' ), |
|
200 | + 'trashed' => _n( '%s View moved to the Trash.', '%s Views moved to the Trash.', $bulk_counts[ 'trashed' ], 'gravityview' ), |
|
201 | + 'untrashed' => _n( '%s View restored from the Trash.', '%s Views restored from the Trash.', $bulk_counts[ 'untrashed' ], 'gravityview' ), |
|
202 | 202 | ); |
203 | 203 | |
204 | 204 | return $messages; |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | function no_conflict_scripts() { |
212 | 212 | global $wp_scripts; |
213 | 213 | |
214 | - if( ! gravityview_is_admin_page() ) { |
|
214 | + if ( ! gravityview_is_admin_page() ) { |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
|
218 | + $no_conflict_mode = GravityView_Settings::getSetting( 'no-conflict-mode' ); |
|
219 | 219 | |
220 | - if( empty( $no_conflict_mode ) ) { |
|
220 | + if ( empty( $no_conflict_mode ) ) { |
|
221 | 221 | return; |
222 | 222 | } |
223 | 223 | |
@@ -267,24 +267,24 @@ discard block |
||
267 | 267 | function no_conflict_styles() { |
268 | 268 | global $wp_styles; |
269 | 269 | |
270 | - if( ! gravityview_is_admin_page() ) { |
|
270 | + if ( ! gravityview_is_admin_page() ) { |
|
271 | 271 | return; |
272 | 272 | } |
273 | 273 | |
274 | 274 | // Dequeue other jQuery styles even if no-conflict is off. |
275 | 275 | // Terrible-looking tabs help no one. |
276 | - if( !empty( $wp_styles->registered ) ) { |
|
277 | - foreach ($wp_styles->registered as $key => $style) { |
|
278 | - if( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
276 | + if ( ! empty( $wp_styles->registered ) ) { |
|
277 | + foreach ( $wp_styles->registered as $key => $style ) { |
|
278 | + if ( preg_match( '/^(?:wp\-)?jquery/ism', $key ) ) { |
|
279 | 279 | wp_dequeue_style( $key ); |
280 | 280 | } |
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | - $no_conflict_mode = GravityView_Settings::getSetting('no-conflict-mode'); |
|
284 | + $no_conflict_mode = GravityView_Settings::getSetting( 'no-conflict-mode' ); |
|
285 | 285 | |
286 | 286 | // If no conflict is off, jQuery will suffice. |
287 | - if( empty( $no_conflict_mode ) ) { |
|
287 | + if ( empty( $no_conflict_mode ) ) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | /** |
312 | 312 | * @action `gravityview_remove_conflicts_after` Runs after no-conflict styles are removed. You can re-add styles here. |
313 | 313 | */ |
314 | - do_action('gravityview_remove_conflicts_after'); |
|
314 | + do_action( 'gravityview_remove_conflicts_after' ); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | |
334 | 334 | //reset queue |
335 | 335 | $queue = array(); |
336 | - foreach( $wp_objects->queue as $object ) { |
|
337 | - if( in_array( $object, $required_objects ) || preg_match('/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
338 | - $queue[] = $object; |
|
336 | + foreach ( $wp_objects->queue as $object ) { |
|
337 | + if ( in_array( $object, $required_objects ) || preg_match( '/gravityview|gf_|gravityforms/ism', $object ) ) { |
|
338 | + $queue[ ] = $object; |
|
339 | 339 | } |
340 | 340 | } |
341 | 341 | $wp_objects->queue = $queue; |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | |
345 | 345 | //unregistering scripts |
346 | 346 | $registered = array(); |
347 | - foreach( $wp_objects->registered as $handle => $script_registration ){ |
|
348 | - if( in_array( $handle, $required_objects ) ){ |
|
347 | + foreach ( $wp_objects->registered as $handle => $script_registration ) { |
|
348 | + if ( in_array( $handle, $required_objects ) ) { |
|
349 | 349 | $registered[ $handle ] = $script_registration; |
350 | 350 | } |
351 | 351 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param [type] $registered [description] |
359 | 359 | * @param [type] $scripts [description] |
360 | 360 | */ |
361 | - private function add_script_dependencies($registered, $scripts) { |
|
361 | + private function add_script_dependencies( $registered, $scripts ) { |
|
362 | 362 | |
363 | 363 | //gets all dependent scripts linked to the $scripts array passed |
364 | 364 | do { |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | $deps = isset( $registered[ $script ] ) && is_array( $registered[ $script ]->deps ) ? $registered[ $script ]->deps : array(); |
368 | 368 | foreach ( $deps as $dep ) { |
369 | 369 | if ( ! in_array( $dep, $scripts ) && ! in_array( $dep, $dependents ) ) { |
370 | - $dependents[] = $dep; |
|
370 | + $dependents[ ] = $dep; |
|
371 | 371 | } |
372 | 372 | } |
373 | 373 | } |
@@ -431,29 +431,29 @@ discard block |
||
431 | 431 | static function is_admin_page( $hook = '', $page = NULL ) { |
432 | 432 | global $current_screen, $plugin_page, $pagenow, $post; |
433 | 433 | |
434 | - if( ! is_admin() ) { return false; } |
|
434 | + if ( ! is_admin() ) { return false; } |
|
435 | 435 | |
436 | 436 | $is_page = false; |
437 | 437 | |
438 | - $is_gv_screen = (!empty($current_screen) && isset($current_screen->post_type) && $current_screen->post_type === 'gravityview'); |
|
438 | + $is_gv_screen = ( ! empty( $current_screen ) && isset( $current_screen->post_type ) && $current_screen->post_type === 'gravityview' ); |
|
439 | 439 | |
440 | - $is_gv_post_type_get = (isset($_GET['post_type']) && $_GET['post_type'] === 'gravityview'); |
|
440 | + $is_gv_post_type_get = ( isset( $_GET[ 'post_type' ] ) && $_GET[ 'post_type' ] === 'gravityview' ); |
|
441 | 441 | |
442 | - $is_gv_settings_get = isset( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings'; |
|
442 | + $is_gv_settings_get = isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'gravityview_settings'; |
|
443 | 443 | |
444 | - if( empty( $post ) && $pagenow === 'post.php' && !empty( $_GET['post'] ) ) { |
|
445 | - $gv_post = get_post( intval( $_GET['post'] ) ); |
|
446 | - $is_gv_post_type = (!empty($gv_post) && !empty($gv_post->post_type) && $gv_post->post_type === 'gravityview'); |
|
444 | + if ( empty( $post ) && $pagenow === 'post.php' && ! empty( $_GET[ 'post' ] ) ) { |
|
445 | + $gv_post = get_post( intval( $_GET[ 'post' ] ) ); |
|
446 | + $is_gv_post_type = ( ! empty( $gv_post ) && ! empty( $gv_post->post_type ) && $gv_post->post_type === 'gravityview' ); |
|
447 | 447 | } else { |
448 | - $is_gv_post_type = (!empty($post) && !empty($post->post_type) && $post->post_type === 'gravityview'); |
|
448 | + $is_gv_post_type = ( ! empty( $post ) && ! empty( $post->post_type ) && $post->post_type === 'gravityview' ); |
|
449 | 449 | } |
450 | 450 | |
451 | - if( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
451 | + if ( $is_gv_screen || $is_gv_post_type || $is_gv_post_type || $is_gv_post_type_get || $is_gv_settings_get ) { |
|
452 | 452 | |
453 | 453 | // $_GET `post_type` variable |
454 | - if(in_array($pagenow, array( 'post.php' , 'post-new.php' )) ) { |
|
454 | + if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) { |
|
455 | 455 | $is_page = 'single'; |
456 | - } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( !empty( $_GET['page'] ) && $_GET['page'] === 'gravityview_settings' ) ) { |
|
456 | + } else if ( in_array( $plugin_page, array( 'gravityview_settings', 'gravityview_page_gravityview_settings' ) ) || ( ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'gravityview_settings' ) ) { |
|
457 | 457 | $is_page = 'settings'; |
458 | 458 | } else { |
459 | 459 | $is_page = 'views'; |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $is_page = apply_filters( 'gravityview_is_admin_page', $is_page, $hook ); |
469 | 469 | |
470 | 470 | // If the current page is the same as the compared page |
471 | - if( !empty( $page ) ) { |
|
471 | + if ( ! empty( $page ) ) { |
|
472 | 472 | return $is_page === $page; |
473 | 473 | } |
474 | 474 | |
@@ -489,6 +489,6 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return bool|string|void If `false`, not a GravityView page. `true` if $page is passed and is the same as current page. Otherwise, the name of the page (`single`, `settings`, or `views`) |
491 | 491 | */ |
492 | -function gravityview_is_admin_page($hook = '', $page = NULL) { |
|
492 | +function gravityview_is_admin_page( $hook = '', $page = NULL ) { |
|
493 | 493 | return GravityView_Admin::is_admin_page( $hook, $page ); |
494 | 494 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | // Make sure the keys are all set |
53 | 53 | $note = wp_parse_args( $note, $default_note ); |
54 | 54 | |
55 | - GFFormsModel::add_note( intval( $note['lead_id'] ), intval( $note['user_id'] ), esc_attr( $note['user_name'] ), $note['note'], esc_attr( $note['note_type'] ) ); |
|
55 | + GFFormsModel::add_note( intval( $note[ 'lead_id' ] ), intval( $note[ 'user_id' ] ), esc_attr( $note[ 'user_name' ] ), $note[ 'note' ], esc_attr( $note[ 'note_type' ] ) ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public static function delete_notes( $note_ids = array() ) { |
74 | 74 | |
75 | - if( !is_array( $note_ids ) ) { |
|
75 | + if ( ! is_array( $note_ids ) ) { |
|
76 | 76 | do_action( 'gravityview_log_error', __METHOD__ . ' - Note IDs not an array', $note_ids ); |
77 | 77 | } |
78 | 78 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public static function filter_avatar( $avatar = '', $note ) { |
113 | 113 | |
114 | - if( 'gravityview' === $note->note_type && -1 === (int)$note->user_id ) { |
|
115 | - $avatar = sprintf( '<img src="%s" width="48" height="48" alt="GravityView" class="avatar avatar-48 gravityview-avatar" />', esc_url_raw( plugins_url( 'assets/images/floaty-avatar.png', GRAVITYVIEW_FILE ) ) ); |
|
114 | + if ( 'gravityview' === $note->note_type && -1 === (int)$note->user_id ) { |
|
115 | + $avatar = sprintf( '<img src="%s" width="48" height="48" alt="GravityView" class="avatar avatar-48 gravityview-avatar" />', esc_url_raw( plugins_url( 'assets/images/floaty-avatar.png', GRAVITYVIEW_FILE ) ) ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | return $avatar; |
@@ -11,10 +11,10 @@ |
||
11 | 11 | ?> |
12 | 12 | |
13 | 13 | <div class="gv-search-box"> |
14 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
15 | - <label for=search-box-<?php echo esc_attr( $search_field['name'] ); ?>><?php echo esc_html( $search_field['label'] ); ?></label> |
|
14 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { ?> |
|
15 | + <label for=search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
16 | 16 | <?php } ?> |
17 | 17 | <p> |
18 | - <input type="text" name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $search_field['value'] ); ?>" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" > |
|
18 | + <input type="text" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="<?php echo esc_attr( $search_field[ 'value' ] ); ?>" class="<?php echo esc_html( $gravityview_view->datepicker_class ); ?>" > |
|
19 | 19 | </p> |
20 | 20 | </div> |
21 | 21 | \ No newline at end of file |
@@ -11,10 +11,10 @@ |
||
11 | 11 | ?> |
12 | 12 | |
13 | 13 | <div class="gv-search-box"> |
14 | - <?php if( ! gv_empty( $search_field['label'], false ) ) { ?> |
|
15 | - <label for=search-box-<?php echo esc_attr( $search_field['name'] ); ?>><?php echo esc_html( $search_field['label'] ); ?></label> |
|
14 | + <?php if ( ! gv_empty( $search_field[ 'label' ], false ) ) { ?> |
|
15 | + <label for=search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>><?php echo esc_html( $search_field[ 'label' ] ); ?></label> |
|
16 | 16 | <?php } ?> |
17 | 17 | <p> |
18 | - <input type="text" name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>" value="<?php echo esc_attr( $search_field['value'] ); ?>"> |
|
18 | + <input type="text" name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>" value="<?php echo esc_attr( $search_field[ 'value' ] ); ?>"> |
|
19 | 19 | </p> |
20 | 20 | </div> |
21 | 21 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $base_url = GravityView_Widget_Search::get_search_form_action(); |
14 | 14 | |
15 | 15 | // Make sure that there are choices to display |
16 | -if ( empty( $search_field['choices'] ) ) { |
|
16 | +if ( empty( $search_field[ 'choices' ] ) ) { |
|
17 | 17 | do_action( 'gravityview_log_debug', 'search-field-link.php - No choices for field' ); |
18 | 18 | return; |
19 | 19 | } |
@@ -39,24 +39,24 @@ discard block |
||
39 | 39 | |
40 | 40 | <?php |
41 | 41 | |
42 | - $search_value = rgget( $search_field['name'] ); |
|
42 | + $search_value = rgget( $search_field[ 'name' ] ); |
|
43 | 43 | |
44 | - foreach ( $search_field['choices'] as $k => $choice ) { |
|
44 | + foreach ( $search_field[ 'choices' ] as $k => $choice ) { |
|
45 | 45 | |
46 | 46 | if ( 0 != $k ) { |
47 | 47 | echo esc_html( $links_sep ); |
48 | 48 | } |
49 | 49 | |
50 | - $active = ( '' !== $search_value && in_array( $search_value, array( $choice['text'], $choice['value'] ) ) ) ? ' class="active"' : false; |
|
50 | + $active = ( '' !== $search_value && in_array( $search_value, array( $choice[ 'text' ], $choice[ 'value' ] ) ) ) ? ' class="active"' : false; |
|
51 | 51 | |
52 | 52 | if ( $active ) { |
53 | - $link = remove_query_arg( array( 'pagenum', $search_field['name'] ), $base_url ); |
|
53 | + $link = remove_query_arg( array( 'pagenum', $search_field[ 'name' ] ), $base_url ); |
|
54 | 54 | } else { |
55 | - $link = add_query_arg( array( $search_field['name'] => urlencode( $choice['value'] ) ), remove_query_arg( array('pagenum'), $base_url ) ); |
|
55 | + $link = add_query_arg( array( $search_field[ 'name' ] => urlencode( $choice[ 'value' ] ) ), remove_query_arg( array( 'pagenum' ), $base_url ) ); |
|
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | |
59 | - <a href="<?php echo esc_url_raw( $link ); ?>" <?php echo $active; ?>><?php echo esc_html( $choice['text'] ); ?></a> |
|
59 | + <a href="<?php echo esc_url_raw( $link ); ?>" <?php echo $active; ?>><?php echo esc_html( $choice[ 'text' ] ); ?></a> |
|
60 | 60 | |
61 | 61 | <?php } ?> |
62 | 62 | </p> |
@@ -9,7 +9,7 @@ |
||
9 | 9 | |
10 | 10 | var $name = 'radio'; |
11 | 11 | |
12 | - var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains'); |
|
12 | + var $search_operators = array( 'is', 'in', 'not in', 'isnot', 'contains' ); |
|
13 | 13 | |
14 | 14 | var $_gf_field_class_name = 'GF_Field_Radio'; |
15 | 15 |
@@ -66,20 +66,20 @@ discard block |
||
66 | 66 | |
67 | 67 | /** Load common & connector functions */ |
68 | 68 | require_once( GRAVITYVIEW_DIR . 'includes/helper-functions.php' ); |
69 | -require_once( GRAVITYVIEW_DIR . 'includes/class-common.php'); |
|
70 | -require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php'); |
|
69 | +require_once( GRAVITYVIEW_DIR . 'includes/class-common.php' ); |
|
70 | +require_once( GRAVITYVIEW_DIR . 'includes/connector-functions.php' ); |
|
71 | 71 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-compatibility.php' ); |
72 | 72 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-roles-capabilities.php' ); |
73 | 73 | require_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-notices.php' ); |
74 | 74 | |
75 | 75 | /** Register Post Types and Rewrite Rules */ |
76 | -require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php'); |
|
76 | +require_once( GRAVITYVIEW_DIR . 'includes/class-post-types.php' ); |
|
77 | 77 | |
78 | 78 | /** Add Cache Class */ |
79 | -require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php'); |
|
79 | +require_once( GRAVITYVIEW_DIR . 'includes/class-cache.php' ); |
|
80 | 80 | |
81 | 81 | /** Register hooks that are fired when the plugin is activated and deactivated. */ |
82 | -if( is_admin() ) { |
|
82 | +if ( is_admin() ) { |
|
83 | 83 | register_activation_hook( __FILE__, array( 'GravityView_Plugin', 'activate' ) ); |
84 | 84 | register_deactivation_hook( __FILE__, array( 'GravityView_Plugin', 'deactivate' ) ); |
85 | 85 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public static function getInstance() { |
102 | 102 | |
103 | - if( empty( self::$instance ) ) { |
|
103 | + if ( empty( self::$instance ) ) { |
|
104 | 104 | self::$instance = new self; |
105 | 105 | } |
106 | 106 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | private function __construct() { |
111 | 111 | |
112 | 112 | |
113 | - if( ! GravityView_Compatibility::is_valid() ) { |
|
113 | + if ( ! GravityView_Compatibility::is_valid() ) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function include_files() { |
141 | 141 | |
142 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin.php' ); |
|
142 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin.php' ); |
|
143 | 143 | |
144 | 144 | // Load fields |
145 | 145 | include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-fields.php' ); |
@@ -150,19 +150,19 @@ discard block |
||
150 | 150 | include_once( $gv_field_filename ); |
151 | 151 | } |
152 | 152 | |
153 | - include_once( GRAVITYVIEW_DIR .'includes/class-gravityview-entry-notes.php' ); |
|
154 | - include_once( GRAVITYVIEW_DIR .'includes/load-plugin-and-theme-hooks.php' ); |
|
153 | + include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-notes.php' ); |
|
154 | + include_once( GRAVITYVIEW_DIR . 'includes/load-plugin-and-theme-hooks.php' ); |
|
155 | 155 | |
156 | 156 | // Load Extensions |
157 | 157 | // @todo: Convert to a scan of the directory or a method where this all lives |
158 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' ); |
|
159 | - include_once( GRAVITYVIEW_DIR .'includes/extensions/delete-entry/class-delete-entry.php' ); |
|
158 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/edit-entry/class-edit-entry.php' ); |
|
159 | + include_once( GRAVITYVIEW_DIR . 'includes/extensions/delete-entry/class-delete-entry.php' ); |
|
160 | 160 | |
161 | 161 | // Load WordPress Widgets |
162 | - include_once( GRAVITYVIEW_DIR .'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
|
162 | + include_once( GRAVITYVIEW_DIR . 'includes/wordpress-widgets/register-wordpress-widgets.php' ); |
|
163 | 163 | |
164 | 164 | // Load GravityView Widgets |
165 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/register-gravityview-widgets.php' ); |
|
165 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/register-gravityview-widgets.php' ); |
|
166 | 166 | |
167 | 167 | // Add oEmbed |
168 | 168 | include_once( GRAVITYVIEW_DIR . 'includes/class-oembed.php' ); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
176 | 176 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-admin-bar.php' ); |
177 | 177 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-list.php' ); |
178 | - include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php'); /** @since 1.8.4 */ |
|
178 | + include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-merge-tags.php' ); /** @since 1.8.4 */ |
|
179 | 179 | include_once( GRAVITYVIEW_DIR . 'includes/class-data.php' ); |
180 | 180 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-shortcode.php' ); |
181 | 181 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-entry-link-shortcode.php' ); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return bool |
191 | 191 | */ |
192 | 192 | public static function is_network_activated() { |
193 | - return is_multisite() && ( function_exists('is_plugin_active_for_network') && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
|
193 | + return is_multisite() && ( function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( 'gravityview/gravityview.php' ) ); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @since 1.7.5.1 |
256 | 256 | */ |
257 | 257 | public static function include_widget_class() { |
258 | - include_once( GRAVITYVIEW_DIR .'includes/widgets/class-gravityview-widget.php' ); |
|
258 | + include_once( GRAVITYVIEW_DIR . 'includes/widgets/class-gravityview-widget.php' ); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | } |
277 | 277 | if ( ! $loaded ) { |
278 | 278 | $locale = apply_filters( 'plugin_locale', get_locale(), 'gravityview' ); |
279 | - $mofile = dirname( __FILE__ ) . '/languages/gravityview-'. $locale .'.mo'; |
|
279 | + $mofile = dirname( __FILE__ ) . '/languages/gravityview-' . $locale . '.mo'; |
|
280 | 280 | load_textdomain( 'gravityview', $mofile ); |
281 | 281 | } |
282 | 282 | |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function frontend_actions() { |
304 | 304 | |
305 | - if( self::is_admin() ) { return; } |
|
305 | + if ( self::is_admin() ) { return; } |
|
306 | 306 | |
307 | 307 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-image.php' ); |
308 | - include_once( GRAVITYVIEW_DIR .'includes/class-template.php' ); |
|
309 | - include_once( GRAVITYVIEW_DIR .'includes/class-api.php' ); |
|
310 | - include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' ); |
|
308 | + include_once( GRAVITYVIEW_DIR . 'includes/class-template.php' ); |
|
309 | + include_once( GRAVITYVIEW_DIR . 'includes/class-api.php' ); |
|
310 | + include_once( GRAVITYVIEW_DIR . 'includes/class-frontend-views.php' ); |
|
311 | 311 | include_once( GRAVITYVIEW_DIR . 'includes/class-gravityview-change-entry-creator.php' ); |
312 | 312 | |
313 | 313 | |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public static function get_default_widget_areas() { |
334 | 334 | $default_areas = array( |
335 | - array( '1-1' => array( array( 'areaid' => 'top', 'title' => __('Top', 'gravityview' ) , 'subtitle' => '' ) ) ), |
|
336 | - array( '1-2' => array( array( 'areaid' => 'left', 'title' => __('Left', 'gravityview') , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __('Right', 'gravityview') , 'subtitle' => '' ) ) ), |
|
335 | + array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
336 | + array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ), 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
337 | 337 | ); |
338 | 338 | |
339 | 339 | /** |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | * @param mixed $data Additional data to display |
352 | 352 | * @return void |
353 | 353 | */ |
354 | - public static function log_debug( $message, $data = null ){ |
|
354 | + public static function log_debug( $message, $data = null ) { |
|
355 | 355 | /** |
356 | 356 | * @action `gravityview_log_debug` Log a debug message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
357 | 357 | * @param string $message Message to display |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param string $message log message |
366 | 366 | * @return void |
367 | 367 | */ |
368 | - public static function log_error( $message, $data = null ){ |
|
368 | + public static function log_error( $message, $data = null ) { |
|
369 | 369 | /** |
370 | 370 | * @action `gravityview_log_error` Log an error message that shows up in the Gravity Forms Logging Addon and also the Debug Bar plugin output |
371 | 371 | * @param string $message Error message to display |
@@ -376,4 +376,4 @@ discard block |
||
376 | 376 | |
377 | 377 | } // end class GravityView_Plugin |
378 | 378 | |
379 | -add_action('plugins_loaded', array('GravityView_Plugin', 'getInstance'), 1); |
|
379 | +add_action( 'plugins_loaded', array( 'GravityView_Plugin', 'getInstance' ), 1 ); |
@@ -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 |