@@ -22,13 +22,13 @@ |
||
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 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $self = new self(); |
56 | 56 | $self->form = $form; |
57 | 57 | |
58 | - $self->ID = $self->form['id']; |
|
58 | + $self->ID = $self->form[ 'id' ]; |
|
59 | 59 | |
60 | 60 | return $self; |
61 | 61 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | |
99 | 99 | /** The offset and limit */ |
100 | 100 | if ( ! empty( $offset->limit ) ) { |
101 | - $paging['page_size'] = $offset->limit; |
|
101 | + $paging[ 'page_size' ] = $offset->limit; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if ( ! empty( $offset->offset ) ) { |
105 | - $paging['offset'] = $offset->offset; |
|
105 | + $paging[ 'offset' ] = $offset->offset; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | foreach ( \GFAPI::get_entries( $form->ID, $search_criteria, $sorting, $paging ) as $entry ) { |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @return bool Whether the offset exists or not. |
139 | 139 | */ |
140 | 140 | public function offsetExists( $offset ) { |
141 | - return isset( $this->form[$offset] ); |
|
141 | + return isset( $this->form[ $offset ] ); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return mixed The value of the requested form data. |
154 | 154 | */ |
155 | 155 | public function offsetGet( $offset ) { |
156 | - return $this->form[$offset]; |
|
156 | + return $this->form[ $offset ]; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | wp_nonce_field( 'gravityview_select_form', 'gravityview_select_form_nonce' ); |
11 | 11 | |
12 | 12 | //current value |
13 | -$current_form = (int) rgar( (array) $_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
13 | +$current_form = (int)rgar( (array)$_GET, 'form_id', gravityview_get_form_id( $post->ID ) ); |
|
14 | 14 | |
15 | 15 | // check for available gravity forms |
16 | -$forms = gravityview_get_forms('any'); |
|
16 | +$forms = gravityview_get_forms( 'any' ); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * @param int $current_form Form currently selected in the View (0 if none selected) |
@@ -32,24 +32,24 @@ discard block |
||
32 | 32 | ?> |
33 | 33 | <a class="button button-primary" href="#gv_start_fresh" title="<?php esc_attr_e( 'Use a Form Preset', 'gravityview' ); ?>"><?php esc_html_e( 'Use a Form Preset', 'gravityview' ); ?></a> |
34 | 34 | |
35 | - <?php if( !empty( $forms ) ) { ?> |
|
35 | + <?php if ( ! empty( $forms ) ) { ?> |
|
36 | 36 | <span> <?php esc_html_e( 'or use an existing form', 'gravityview' ); ?> </span> |
37 | 37 | <?php } |
38 | 38 | } |
39 | 39 | |
40 | 40 | // If there are no forms to select, show no forms. |
41 | - if( !empty( $forms ) ) { ?> |
|
41 | + if ( ! empty( $forms ) ) { ?> |
|
42 | 42 | <select name="gravityview_form_id" id="gravityview_form_id"> |
43 | 43 | <option value="" <?php selected( '', $current_form, true ); ?>>— <?php esc_html_e( 'list of forms', 'gravityview' ); ?> —</option> |
44 | - <?php foreach( $forms as $form ) { ?> |
|
45 | - <option value="<?php echo $form['id']; ?>" <?php selected( $form['id'], $current_form, true ); ?>><?php echo esc_html( $form['title'] ); ?></option> |
|
44 | + <?php foreach ( $forms as $form ) { ?> |
|
45 | + <option value="<?php echo $form[ 'id' ]; ?>" <?php selected( $form[ 'id' ], $current_form, true ); ?>><?php echo esc_html( $form[ 'title' ] ); ?></option> |
|
46 | 46 | <?php } ?> |
47 | 47 | </select> |
48 | 48 | <?php } else { ?> |
49 | 49 | <select name="gravityview_form_id" id="gravityview_form_id" class="hidden"><option selected="selected" value=""></option></select> |
50 | 50 | <?php } ?> |
51 | 51 | |
52 | - <a class="button button-primary" <?php if( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
52 | + <a class="button button-primary" <?php if ( empty( $current_form ) ) { echo 'style="display:none;"'; } ?> id="gv_switch_view_button" href="#gv_switch_view" title="<?php esc_attr_e( 'Switch View', 'gravityview' ); ?>"><?php esc_html_e( 'Switch View Type', 'gravityview' ); ?></a> |
|
53 | 53 | </p> |
54 | 54 | |
55 | 55 | <?php // confirm dialog box ?> |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | add_action( 'init', array( $this, 'register_handler' ) ); |
36 | 36 | add_action( 'init', array( $this, 'add_provider' ) ); |
37 | 37 | |
38 | - if ( ! empty( $_GET['gv_oembed_provider'] ) && ! empty( $_GET['url'] ) ) { |
|
38 | + if ( ! empty( $_GET[ 'gv_oembed_provider' ] ) && ! empty( $_GET[ 'url' ] ) ) { |
|
39 | 39 | add_action( 'template_redirect', array( $this, 'render_provider_request' ) ); |
40 | 40 | } |
41 | 41 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | static function getInstance() { |
48 | 48 | |
49 | - if( empty( self::$instance ) ) { |
|
49 | + if ( empty( self::$instance ) ) { |
|
50 | 50 | self::$instance = new self; |
51 | 51 | |
52 | 52 | self::$instance->initialize(); |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * @return void |
91 | 91 | */ |
92 | 92 | function render_provider_request() { |
93 | - if ( ! empty( $_GET['url'] ) ) { |
|
94 | - $url = $_GET['url']; |
|
93 | + if ( ! empty( $_GET[ 'url' ] ) ) { |
|
94 | + $url = $_GET[ 'url' ]; |
|
95 | 95 | } else { |
96 | 96 | header( 'HTTP/1.0 404 Not Found' ); |
97 | 97 | exit; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | preg_match( $this->get_handler_regex(), $url, $matches ); |
101 | 101 | |
102 | 102 | // If not using permalinks, re-assign values for matching groups |
103 | - if ( ! empty( $matches['entry_slug2'] ) ) { |
|
104 | - $matches['is_cpt'] = $matches['is_cpt2']; |
|
105 | - $matches['slug'] = $matches['slug2']; |
|
106 | - $matches['entry_slug'] = $matches['entry_slug2']; |
|
107 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
103 | + if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
104 | + $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
105 | + $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
106 | + $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
107 | + unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | // No Entry was found |
111 | - if ( empty( $matches['entry_slug'] ) ) { |
|
112 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
111 | + if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
112 | + do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
113 | 113 | header( 'HTTP/1.0 404 Not Found' ); |
114 | 114 | exit; |
115 | 115 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | // Catch either |
163 | 163 | $match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
164 | 164 | |
165 | - return '#'.$match_regex.'#i'; |
|
165 | + return '#' . $match_regex . '#i'; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | |
184 | 184 | $page_on_front = get_option( 'page_on_front' ); |
185 | 185 | |
186 | - if( (int) $post_id === (int) $page_on_front || empty( $post_id ) ) { |
|
186 | + if ( (int)$post_id === (int)$page_on_front || empty( $post_id ) ) { |
|
187 | 187 | |
188 | 188 | $args = array( |
189 | 189 | 'post_status' => 'publish', |
190 | 190 | 'name' => $slug, |
191 | - 'post_type' => array('any', 'gravityview'), |
|
191 | + 'post_type' => array( 'any', 'gravityview' ), |
|
192 | 192 | ); |
193 | 193 | |
194 | 194 | $posts = get_posts( $args ); |
195 | 195 | |
196 | - if( !empty( $posts ) ) { |
|
197 | - $post_id = $posts[0]->ID; |
|
196 | + if ( ! empty( $posts ) ) { |
|
197 | + $post_id = $posts[ 0 ]->ID; |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -227,17 +227,17 @@ discard block |
||
227 | 227 | public function render_handler( $matches, $attr, $url, $rawattr ) { |
228 | 228 | |
229 | 229 | // If not using permalinks, re-assign values for matching groups |
230 | - if( !empty( $matches['entry_slug2'] ) ) { |
|
231 | - $matches['is_cpt'] = $matches['is_cpt2']; |
|
232 | - $matches['slug'] = $matches['slug2']; |
|
233 | - $matches['entry_slug'] = $matches['entry_slug2']; |
|
234 | - unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
230 | + if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
231 | + $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
232 | + $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
233 | + $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
234 | + unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | // No Entry was found |
238 | - if( empty( $matches['entry_slug'] ) ) { |
|
238 | + if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
239 | 239 | |
240 | - do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
240 | + do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
241 | 241 | |
242 | 242 | return ''; |
243 | 243 | } |
@@ -247,11 +247,11 @@ discard block |
||
247 | 247 | // Setup the data used |
248 | 248 | $this->set_vars( $matches, $attr, $url, $rawattr ); |
249 | 249 | |
250 | - if( is_admin() && !$this->is_full_oembed_preview ) { |
|
250 | + if ( is_admin() && ! $this->is_full_oembed_preview ) { |
|
251 | 251 | $return = $this->render_admin( $matches, $attr, $url, $rawattr ); |
252 | 252 | } else { |
253 | 253 | |
254 | - if( $this->is_full_oembed_preview ) { |
|
254 | + if ( $this->is_full_oembed_preview ) { |
|
255 | 255 | $return .= $this->generate_preview_notice(); |
256 | 256 | } |
257 | 257 | |
@@ -270,8 +270,8 @@ discard block |
||
270 | 270 | private function generate_preview_notice() { |
271 | 271 | $floaty = GravityView_Admin::get_floaty(); |
272 | 272 | $title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
273 | - $message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
|
274 | - return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
273 | + $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' ); |
|
274 | + return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>'; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -284,14 +284,14 @@ discard block |
||
284 | 284 | */ |
285 | 285 | private function set_vars( $matches, $attr, $url, $rawattr ) { |
286 | 286 | |
287 | - $this->entry_id = $matches['entry_slug']; |
|
287 | + $this->entry_id = $matches[ 'entry_slug' ]; |
|
288 | 288 | |
289 | - $post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] ); |
|
289 | + $post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] ); |
|
290 | 290 | |
291 | 291 | // The URL didn't have the View Custom Post Type structure. |
292 | - if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) { |
|
292 | + if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) { |
|
293 | 293 | |
294 | - do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
294 | + do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
295 | 295 | |
296 | 296 | if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) ) { |
297 | 297 | $views = \GV\View_Collection::from_post( $post ); |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - $this->view_id = $views[0]->ID; |
|
307 | + $this->view_id = $views[ 0 ]->ID; |
|
308 | 308 | } |
309 | 309 | } else { |
310 | 310 | /** Deprecated. */ |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | // The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that. |
321 | - $this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) ); |
|
321 | + $this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) ); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -336,15 +336,15 @@ discard block |
||
336 | 336 | // Floaty the astronaut |
337 | 337 | $image = GravityView_Admin::get_floaty(); |
338 | 338 | |
339 | - $embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id ); |
|
339 | + $embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id ); |
|
340 | 340 | |
341 | - $embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id ); |
|
341 | + $embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id ); |
|
342 | 342 | |
343 | 343 | return ' |
344 | 344 | <div class="loading-placeholder" style="background-color:#e6f0f5;"> |
345 | - <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3> |
|
345 | + <h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3> |
|
346 | 346 | <p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;"> |
347 | - '.$embed_text.' |
|
347 | + '.$embed_text . ' |
|
348 | 348 | </p> |
349 | 349 | <br style="clear: both;"> |
350 | 350 | </div>'; |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | private function render_frontend( $matches, $attr, $url, $rawattr ) { |
400 | 400 | |
401 | 401 | // If it's already been parsed, don't re-output it. |
402 | - if( !empty( $this->output[ $this->entry_id ] ) ) { |
|
402 | + if ( ! empty( $this->output[ $this->entry_id ] ) ) { |
|
403 | 403 | return $this->output[ $this->entry_id ]; |
404 | 404 | } |
405 | 405 | |
406 | 406 | $entry_output = $this->generate_entry_output(); |
407 | 407 | |
408 | 408 | // Wrap a container div around the output to allow for custom styling |
409 | - $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output ); |
|
409 | + $output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output ); |
|
410 | 410 | |
411 | 411 | /** |
412 | 412 | * @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * @var string $url The original URL that was matched by the regex. \n |
420 | 420 | * @var array $rawattr The original unmodified attributes. |
421 | 421 | */ |
422 | - $output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
422 | + $output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
423 | 423 | |
424 | 424 | unset( $entry_output ); |
425 | 425 |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public static function get_instance() { |
87 | 87 | |
88 | - if( empty( self::$instance ) ) { |
|
88 | + if ( empty( self::$instance ) ) { |
|
89 | 89 | self::$instance = new self; |
90 | 90 | } |
91 | 91 | |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | |
120 | 120 | $operators = array_merge( self::$SUPPORTED_ARRAY_OPERATORS, self::$SUPPORTED_NUMERIC_OPERATORS, self::$SUPPORTED_SCALAR_OPERATORS, self::$SUPPORTED_CUSTOM_OPERATORS ); |
121 | 121 | |
122 | - if( $with_values ) { |
|
122 | + if ( $with_values ) { |
|
123 | 123 | $operators_with_values = array(); |
124 | - foreach( $operators as $key ) { |
|
124 | + foreach ( $operators as $key ) { |
|
125 | 125 | $operators_with_values[ $key ] = ''; |
126 | 126 | } |
127 | 127 | return $operators_with_values; |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | */ |
139 | 139 | private function set_operation( $operation = '' ) { |
140 | 140 | |
141 | - if( empty( $operation ) ) { |
|
141 | + if ( empty( $operation ) ) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
145 | 145 | $operators = $this->get_operators( false ); |
146 | 146 | |
147 | - if( !in_array( $operation, $operators ) ) { |
|
148 | - do_action( 'gravityview_log_debug', __METHOD__ .' Attempted to add invalid operation type.', $operation ); |
|
147 | + if ( ! in_array( $operation, $operators ) ) { |
|
148 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Attempted to add invalid operation type.', $operation ); |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | */ |
166 | 166 | private function setup_operation_and_comparison() { |
167 | 167 | |
168 | - foreach( $this->atts as $key => $value ) { |
|
168 | + foreach ( $this->atts as $key => $value ) { |
|
169 | 169 | |
170 | 170 | $valid = $this->set_operation( $key ); |
171 | 171 | |
172 | - if( $valid ) { |
|
172 | + if ( $valid ) { |
|
173 | 173 | $this->comparison = $value; |
174 | 174 | return true; |
175 | 175 | } |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | return null; |
196 | 196 | } |
197 | 197 | |
198 | - if( empty( $atts ) ) { |
|
199 | - do_action( 'gravityview_log_error', __METHOD__.' $atts are empty.', $atts ); |
|
198 | + if ( empty( $atts ) ) { |
|
199 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts are empty.', $atts ); |
|
200 | 200 | return null; |
201 | 201 | } |
202 | 202 | |
@@ -210,16 +210,16 @@ discard block |
||
210 | 210 | $this->parse_atts(); |
211 | 211 | |
212 | 212 | // We need an "if" |
213 | - if( false === $this->if ) { |
|
214 | - do_action( 'gravityview_log_error', __METHOD__.' $atts->if is empty.', $this->passed_atts ); |
|
213 | + if ( false === $this->if ) { |
|
214 | + do_action( 'gravityview_log_error', __METHOD__ . ' $atts->if is empty.', $this->passed_atts ); |
|
215 | 215 | return null; |
216 | 216 | } |
217 | 217 | |
218 | 218 | $setup = $this->setup_operation_and_comparison(); |
219 | 219 | |
220 | 220 | // We need an operation and comparison value |
221 | - if( ! $setup ) { |
|
222 | - do_action( 'gravityview_log_error', __METHOD__.' No valid operators were passed.', $this->atts ); |
|
221 | + if ( ! $setup ) { |
|
222 | + do_action( 'gravityview_log_error', __METHOD__ . ' No valid operators were passed.', $this->atts ); |
|
223 | 223 | return null; |
224 | 224 | } |
225 | 225 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | private function get_output() { |
254 | 254 | |
255 | - if( $this->is_match ) { |
|
255 | + if ( $this->is_match ) { |
|
256 | 256 | $output = $this->content; |
257 | 257 | } else { |
258 | 258 | $output = $this->else_content; |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * @param string $output HTML/text output |
267 | 267 | * @param GVLogic_Shortcode $this This class |
268 | 268 | */ |
269 | - $output = apply_filters('gravityview/gvlogic/output', $output, $this ); |
|
269 | + $output = apply_filters( 'gravityview/gvlogic/output', $output, $this ); |
|
270 | 270 | |
271 | - do_action( 'gravityview_log_debug', __METHOD__ .' Output: ', $output ); |
|
271 | + do_action( 'gravityview_log_debug', __METHOD__ . ' Output: ', $output ); |
|
272 | 272 | |
273 | 273 | return $output; |
274 | 274 | } |
@@ -286,14 +286,14 @@ discard block |
||
286 | 286 | list( $before_else, $after_else ) = array_pad( explode( '[else]', $passed_content ), 2, NULL ); |
287 | 287 | list( $before_else_if, $after_else_if ) = array_pad( explode( '[else', $passed_content ), 2, NULL ); |
288 | 288 | |
289 | - $else_attr = isset( $this->atts['else'] ) ? $this->atts['else'] : NULL; |
|
289 | + $else_attr = isset( $this->atts[ 'else' ] ) ? $this->atts[ 'else' ] : NULL; |
|
290 | 290 | $else_content = isset( $after_else ) ? $after_else : $else_attr; |
291 | 291 | |
292 | 292 | // The content is everything OTHER than the [else] |
293 | 293 | $this->content = $before_else_if; |
294 | 294 | |
295 | 295 | if ( ! $this->is_match ) { |
296 | - if( $elseif_content = $this->process_elseif( $before_else ) ) { |
|
296 | + if ( $elseif_content = $this->process_elseif( $before_else ) ) { |
|
297 | 297 | $this->else_content = $elseif_content; |
298 | 298 | } else { |
299 | 299 | $this->else_content = $else_content; |
@@ -321,16 +321,16 @@ discard block |
||
321 | 321 | foreach ( $else_if_matches as $key => $else_if_match ) { |
322 | 322 | |
323 | 323 | // If $else_if_match[5] exists and has content, check for more shortcodes |
324 | - preg_match_all( '/' . $regex . '/', $else_if_match[5] . '[/else]', $recursive_matches, PREG_SET_ORDER ); |
|
324 | + preg_match_all( '/' . $regex . '/', $else_if_match[ 5 ] . '[/else]', $recursive_matches, PREG_SET_ORDER ); |
|
325 | 325 | |
326 | 326 | // If the logic passes, this is the value that should be used for $this->else_content |
327 | - $else_if_value = $else_if_match[5]; |
|
328 | - $check_elseif_match = $else_if_match[0]; |
|
327 | + $else_if_value = $else_if_match[ 5 ]; |
|
328 | + $check_elseif_match = $else_if_match[ 0 ]; |
|
329 | 329 | |
330 | 330 | // Retrieve the value of the match that is currently being checked, without any other [else] tags |
331 | - if( ! empty( $recursive_matches[0][0] ) ) { |
|
332 | - $else_if_value = str_replace( $recursive_matches[0][0], '', $else_if_value ); |
|
333 | - $check_elseif_match = str_replace( $recursive_matches[0][0], '', $check_elseif_match ); |
|
331 | + if ( ! empty( $recursive_matches[ 0 ][ 0 ] ) ) { |
|
332 | + $else_if_value = str_replace( $recursive_matches[ 0 ][ 0 ], '', $else_if_value ); |
|
333 | + $check_elseif_match = str_replace( $recursive_matches[ 0 ][ 0 ], '', $check_elseif_match ); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | $check_elseif_match = str_replace( '[else', '[gvlogicelse', $check_elseif_match ); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | } |
348 | 348 | |
349 | 349 | // Process any remaining [else] tags |
350 | - return $this->process_elseif( $else_if_match[5] ); |
|
350 | + return $this->process_elseif( $else_if_match[ 5 ] ); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | return false; |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $this->atts = function_exists( 'array_intersect_key' ) ? array_intersect_key( $this->passed_atts, $this->atts ) : $this->atts; |
374 | 374 | |
375 | 375 | // Strip whitespace if it's not default false |
376 | - $this->if = ( isset( $this->atts['if'] ) && is_string( $this->atts['if'] ) ) ? trim( $this->atts['if'] ) : false; |
|
376 | + $this->if = ( isset( $this->atts[ 'if' ] ) && is_string( $this->atts[ 'if' ] ) ) ? trim( $this->atts[ 'if' ] ) : false; |
|
377 | 377 | |
378 | 378 | /** |
379 | 379 | * @action `gravityview/gvlogic/parse_atts/after` Modify shortcode attributes after it's been parsed |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | do_action( 'gravityview/gvlogic/parse_atts/after', $this ); |
385 | 385 | |
386 | 386 | // Make sure the "if" isn't processed in self::setup_operation_and_comparison() |
387 | - unset( $this->atts['if'] ); |
|
387 | + unset( $this->atts[ 'if' ] ); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 |
@@ -42,16 +42,16 @@ discard block |
||
42 | 42 | |
43 | 43 | $args = wp_parse_args( $args, $defaults ); |
44 | 44 | |
45 | - $forms = gravityview_get_forms( (bool) $args['active'], (bool) $args['trash'] ); |
|
45 | + $forms = gravityview_get_forms( (bool)$args[ 'active' ], (bool)$args[ 'trash' ] ); |
|
46 | 46 | |
47 | - if( array() === $args['options'] ) { |
|
47 | + if ( array() === $args[ 'options' ] ) { |
|
48 | 48 | foreach ( $forms as $form ) { |
49 | 49 | |
50 | - if ( in_array( $form['id'], $args['exclude'] ) ) { |
|
50 | + if ( in_array( $form[ 'id' ], $args[ 'exclude' ] ) ) { |
|
51 | 51 | continue; |
52 | 52 | } |
53 | 53 | |
54 | - $args['options'][ $form['id'] ] = esc_html( $form['title'] ); |
|
54 | + $args[ 'options' ][ $form[ 'id' ] ] = esc_html( $form[ 'title' ] ); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | |
84 | 84 | $args = wp_parse_args( $args, $defaults ); |
85 | 85 | |
86 | - if( empty( $args['form_id'] ) ) { |
|
86 | + if ( empty( $args[ 'form_id' ] ) ) { |
|
87 | 87 | return ''; |
88 | 88 | } |
89 | 89 | |
90 | - $fields = GVCommon::get_sortable_fields_array( $args['form_id'] ); |
|
90 | + $fields = GVCommon::get_sortable_fields_array( $args[ 'form_id' ] ); |
|
91 | 91 | |
92 | - if( array() === $args['options'] ) { |
|
92 | + if ( array() === $args[ 'options' ] ) { |
|
93 | 93 | foreach ( $fields as $field_id => $field ) { |
94 | - $args['options'][ $field_id ] = esc_html( $field['label'] ); |
|
94 | + $args[ 'options' ][ $field_id ] = esc_html( $field[ 'label' ] ); |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
@@ -127,43 +127,43 @@ discard block |
||
127 | 127 | $args = wp_parse_args( $args, $defaults ); |
128 | 128 | |
129 | 129 | $data_elements = ''; |
130 | - foreach ( $args['data'] as $key => $value ) { |
|
130 | + foreach ( $args[ 'data' ] as $key => $value ) { |
|
131 | 131 | $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
132 | 132 | } |
133 | 133 | |
134 | - if( $args['multiple'] ) { |
|
134 | + if ( $args[ 'multiple' ] ) { |
|
135 | 135 | $multiple = ' MULTIPLE'; |
136 | 136 | } else { |
137 | 137 | $multiple = ''; |
138 | 138 | } |
139 | 139 | |
140 | - if( $args['placeholder'] ) { |
|
141 | - $placeholder = $args['placeholder']; |
|
140 | + if ( $args[ 'placeholder' ] ) { |
|
141 | + $placeholder = $args[ 'placeholder' ]; |
|
142 | 142 | } else { |
143 | 143 | $placeholder = ''; |
144 | 144 | } |
145 | 145 | |
146 | - $disabled = $args['disabled'] ? ' disabled="disabled"' : ''; |
|
147 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
148 | - $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( str_replace( '-', '_', $args['id'] ) ) . '" class="gravityview-select ' . $class . '"' . $multiple . $disabled . ' data-placeholder="' . $placeholder . '"'. $data_elements . '>'; |
|
146 | + $disabled = $args[ 'disabled' ] ? ' disabled="disabled"' : ''; |
|
147 | + $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args[ 'class' ] ) ) ); |
|
148 | + $output = '<select name="' . esc_attr( $args[ 'name' ] ) . '" id="' . esc_attr( str_replace( '-', '_', $args[ 'id' ] ) ) . '" class="gravityview-select ' . $class . '"' . $multiple . $disabled . ' data-placeholder="' . $placeholder . '"' . $data_elements . '>'; |
|
149 | 149 | |
150 | - if ( ! empty( $args['options'] ) ) { |
|
150 | + if ( ! empty( $args[ 'options' ] ) ) { |
|
151 | 151 | |
152 | - if ( $args['show_option_none'] ) { |
|
153 | - if( $args['multiple'] ) { |
|
154 | - $selected = selected( true, in_array( -1, $args['selected'] ), false ); |
|
152 | + if ( $args[ 'show_option_none' ] ) { |
|
153 | + if ( $args[ 'multiple' ] ) { |
|
154 | + $selected = selected( true, in_array( -1, $args[ 'selected' ] ), false ); |
|
155 | 155 | } else { |
156 | - $selected = selected( $args['selected'], -1, false ); |
|
156 | + $selected = selected( $args[ 'selected' ], -1, false ); |
|
157 | 157 | } |
158 | - $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
158 | + $output .= '<option value="-1"' . $selected . '>' . esc_html( $args[ 'show_option_none' ] ) . '</option>'; |
|
159 | 159 | } |
160 | 160 | |
161 | - foreach( $args['options'] as $key => $option ) { |
|
161 | + foreach ( $args[ 'options' ] as $key => $option ) { |
|
162 | 162 | |
163 | - if( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
164 | - $selected = selected( true, in_array( $key, $args['selected'], true ), false ); |
|
163 | + if ( $args[ 'multiple' ] && is_array( $args[ 'selected' ] ) ) { |
|
164 | + $selected = selected( true, in_array( $key, $args[ 'selected' ], true ), false ); |
|
165 | 165 | } else { |
166 | - $selected = selected( $args['selected'], $key, false ); |
|
166 | + $selected = selected( $args[ 'selected' ], $key, false ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>'; |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | function parse_um_profile_post_content( $args = array() ) { |
44 | 44 | global $ultimatemember; |
45 | 45 | |
46 | - if( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) { |
|
46 | + if ( ! $ultimatemember || ! is_object( $ultimatemember ) || ! class_exists( 'GravityView_View_Data' ) ) { |
|
47 | 47 | return; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // @todo Support Ultimate Member 2.0 - for now, prevent fatal error |
51 | - if( ! isset( $ultimatemember->profile ) ) { |
|
51 | + if ( ! isset( $ultimatemember->profile ) ) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | - GravityView_View_Data::getInstance()->parse_post_content( $active_tab[0]->post_content ); |
|
67 | + GravityView_View_Data::getInstance()->parse_post_content( $active_tab[ 0 ]->post_content ); |
|
68 | 68 | |
69 | 69 | wp_reset_postdata(); |
70 | 70 | } |
@@ -24,132 +24,132 @@ |
||
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | - * Given information provided in an entry, get array of media IDs |
|
28 | - * |
|
29 | - * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
30 | - * |
|
31 | - * @see GFFormsModel::create_post() |
|
32 | - * |
|
33 | - * @since 1.17 |
|
34 | - * |
|
35 | - * @param array $form Gravity Forms form array |
|
36 | - * @param array $entry Gravity Forms entry array |
|
37 | - * |
|
38 | - * @return array Array of "Field ID" => "Media IDs" |
|
39 | - */ |
|
40 | - public static function get_post_field_images( $form, $entry ) { |
|
41 | - |
|
42 | - $post_data = self::get_post_fields( $form, $entry ); |
|
43 | - |
|
44 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
45 | - |
|
46 | - $post_images = array(); |
|
47 | - |
|
48 | - foreach ( $media as $media_item ) { |
|
49 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
50 | - if( |
|
51 | - rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
52 | - rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
53 | - rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
54 | - ) { |
|
55 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
59 | - |
|
60 | - return $post_images; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Alias of GFFormsModel::get_post_fields(); just making it public |
|
65 | - * |
|
66 | - * @see GFFormsModel::get_post_fields() |
|
67 | - * |
|
68 | - * @since 1.17 |
|
69 | - * |
|
70 | - * @param array $form Gravity Forms form array |
|
71 | - * @param array $entry Gravity Forms entry array |
|
72 | - * |
|
73 | - * @return array |
|
74 | - */ |
|
75 | - public static function get_post_fields( $form, $entry ) { |
|
76 | - |
|
77 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
78 | - |
|
79 | - /** |
|
80 | - * If the method changes to public, use Gravity Forms' method |
|
81 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
82 | - */ |
|
83 | - if( $reflection->isPublic() ) { |
|
84 | - return parent::get_post_fields( $form, $entry ); |
|
85 | - } |
|
86 | - |
|
87 | - // It was private; let's make it public |
|
88 | - $reflection->setAccessible( true ); |
|
89 | - |
|
90 | - return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
95 | - * |
|
96 | - * @since 1.16.2 |
|
97 | - * |
|
98 | - * @param string $url URL of the post image to update |
|
99 | - * @param int $post_id ID of the post image to update |
|
100 | - * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
101 | - */ |
|
102 | - public static function copy_post_image( $url, $post_id ) { |
|
103 | - |
|
104 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
105 | - |
|
106 | - /** |
|
107 | - * If the method changes to public, use Gravity Forms' method |
|
108 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
109 | - */ |
|
110 | - if( $reflection->isPublic() ) { |
|
111 | - return parent::copy_post_image( $url, $post_id ); |
|
112 | - } |
|
113 | - |
|
114 | - // It was private; let's make it public |
|
115 | - $reflection->setAccessible( true ); |
|
116 | - |
|
117 | - return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
122 | - * |
|
123 | - * Note: The method became public in GF 1.9.17.7 |
|
124 | - * |
|
125 | - * @see GFFormsModel::media_handle_upload |
|
126 | - * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
127 | - * |
|
128 | - * @uses copy_post_image |
|
129 | - * @uses wp_insert_attachment |
|
130 | - * @uses wp_update_attachment_metadata |
|
131 | - * |
|
132 | - * @param string $url URL of the post image to update |
|
133 | - * @param int $post_id ID of the post image to update |
|
134 | - * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
135 | - * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
136 | - */ |
|
137 | - public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
138 | - |
|
139 | - $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
140 | - |
|
141 | - /** |
|
142 | - * If the method changes to public, use Gravity Forms' method |
|
143 | - * @todo: If/when the method is public, remove the unneeded copied code. |
|
144 | - */ |
|
145 | - if( $reflection->isPublic() ) { |
|
146 | - return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
147 | - } |
|
148 | - |
|
149 | - // It was private; let's make it public |
|
150 | - $reflection->setAccessible( true ); |
|
151 | - |
|
152 | - return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
153 | - } |
|
27 | + * Given information provided in an entry, get array of media IDs |
|
28 | + * |
|
29 | + * This is necessary because GF doesn't expect to need to update post images, only to create them. |
|
30 | + * |
|
31 | + * @see GFFormsModel::create_post() |
|
32 | + * |
|
33 | + * @since 1.17 |
|
34 | + * |
|
35 | + * @param array $form Gravity Forms form array |
|
36 | + * @param array $entry Gravity Forms entry array |
|
37 | + * |
|
38 | + * @return array Array of "Field ID" => "Media IDs" |
|
39 | + */ |
|
40 | + public static function get_post_field_images( $form, $entry ) { |
|
41 | + |
|
42 | + $post_data = self::get_post_fields( $form, $entry ); |
|
43 | + |
|
44 | + $media = get_attached_media( 'image', $entry['post_id'] ); |
|
45 | + |
|
46 | + $post_images = array(); |
|
47 | + |
|
48 | + foreach ( $media as $media_item ) { |
|
49 | + foreach( (array) $post_data['images'] as $post_data_item ) { |
|
50 | + if( |
|
51 | + rgar( $post_data_item, 'title' ) === $media_item->post_title && |
|
52 | + rgar( $post_data_item, 'description' ) === $media_item->post_content && |
|
53 | + rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
|
54 | + ) { |
|
55 | + $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | + |
|
60 | + return $post_images; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Alias of GFFormsModel::get_post_fields(); just making it public |
|
65 | + * |
|
66 | + * @see GFFormsModel::get_post_fields() |
|
67 | + * |
|
68 | + * @since 1.17 |
|
69 | + * |
|
70 | + * @param array $form Gravity Forms form array |
|
71 | + * @param array $entry Gravity Forms entry array |
|
72 | + * |
|
73 | + * @return array |
|
74 | + */ |
|
75 | + public static function get_post_fields( $form, $entry ) { |
|
76 | + |
|
77 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'get_post_fields' ); |
|
78 | + |
|
79 | + /** |
|
80 | + * If the method changes to public, use Gravity Forms' method |
|
81 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
82 | + */ |
|
83 | + if( $reflection->isPublic() ) { |
|
84 | + return parent::get_post_fields( $form, $entry ); |
|
85 | + } |
|
86 | + |
|
87 | + // It was private; let's make it public |
|
88 | + $reflection->setAccessible( true ); |
|
89 | + |
|
90 | + return $reflection->invoke( new GFFormsModel, $form, $entry ); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * Copied function from Gravity Forms plugin \GFFormsModel::copy_post_image since the method is private. |
|
95 | + * |
|
96 | + * @since 1.16.2 |
|
97 | + * |
|
98 | + * @param string $url URL of the post image to update |
|
99 | + * @param int $post_id ID of the post image to update |
|
100 | + * @return array|bool Array with `file`, `url` and `type` keys. False: failed to copy file to final directory path. |
|
101 | + */ |
|
102 | + public static function copy_post_image( $url, $post_id ) { |
|
103 | + |
|
104 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'copy_post_image' ); |
|
105 | + |
|
106 | + /** |
|
107 | + * If the method changes to public, use Gravity Forms' method |
|
108 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
109 | + */ |
|
110 | + if( $reflection->isPublic() ) { |
|
111 | + return parent::copy_post_image( $url, $post_id ); |
|
112 | + } |
|
113 | + |
|
114 | + // It was private; let's make it public |
|
115 | + $reflection->setAccessible( true ); |
|
116 | + |
|
117 | + return $reflection->invoke( new GFFormsModel, $url, $post_id ); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Copied function from Gravity Forms plugin \GFFormsModel::media_handle_upload since the method is private. |
|
122 | + * |
|
123 | + * Note: The method became public in GF 1.9.17.7 |
|
124 | + * |
|
125 | + * @see GFFormsModel::media_handle_upload |
|
126 | + * @see GravityView_Edit_Entry_Render::maybe_update_post_fields |
|
127 | + * |
|
128 | + * @uses copy_post_image |
|
129 | + * @uses wp_insert_attachment |
|
130 | + * @uses wp_update_attachment_metadata |
|
131 | + * |
|
132 | + * @param string $url URL of the post image to update |
|
133 | + * @param int $post_id ID of the post image to update |
|
134 | + * @param array $post_data Array of data for the eventual attachment post type that is created using {@see wp_insert_attachment}. Supports `post_mime_type`, `guid`, `post_parent`, `post_title`, `post_content` keys. |
|
135 | + * @return bool|int ID of attachment Post created. Returns false if file not created by copy_post_image |
|
136 | + */ |
|
137 | + public static function media_handle_upload( $url, $post_id, $post_data = array() ) { |
|
138 | + |
|
139 | + $reflection = new ReflectionMethod( 'GFFormsModel', 'media_handle_upload' ); |
|
140 | + |
|
141 | + /** |
|
142 | + * If the method changes to public, use Gravity Forms' method |
|
143 | + * @todo: If/when the method is public, remove the unneeded copied code. |
|
144 | + */ |
|
145 | + if( $reflection->isPublic() ) { |
|
146 | + return parent::media_handle_upload( $url, $post_id, $post_data ); |
|
147 | + } |
|
148 | + |
|
149 | + // It was private; let's make it public |
|
150 | + $reflection->setAccessible( true ); |
|
151 | + |
|
152 | + return $reflection->invoke( new GFFormsModel, $url, $post_id, $post_data ); |
|
153 | + } |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | \ No newline at end of file |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | public static function is_value_match( $field_value, $target_value, $operation = 'is', $source_field = null, $rule = null, $form = null ) { |
41 | 41 | |
42 | 42 | if ( 'date_created' === $source_field ) { |
43 | - $field_value = is_int( $field_value )? $field_value : strtotime( $field_value ); |
|
44 | - $target_value = is_int( $target_value )? $target_value : strtotime( $target_value ); |
|
43 | + $field_value = is_int( $field_value ) ? $field_value : strtotime( $field_value ); |
|
44 | + $target_value = is_int( $target_value ) ? $target_value : strtotime( $target_value ); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | return parent::is_value_match( $field_value, $target_value, $operation, $source_field, $rule, $form ); // TODO: Change the autogenerated stub |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | |
66 | 66 | $post_data = self::get_post_fields( $form, $entry ); |
67 | 67 | |
68 | - $media = get_attached_media( 'image', $entry['post_id'] ); |
|
68 | + $media = get_attached_media( 'image', $entry[ 'post_id' ] ); |
|
69 | 69 | |
70 | 70 | $post_images = array(); |
71 | 71 | |
72 | 72 | foreach ( $media as $media_item ) { |
73 | - foreach( (array) $post_data['images'] as $post_data_item ) { |
|
74 | - if( |
|
73 | + foreach ( (array)$post_data[ 'images' ] as $post_data_item ) { |
|
74 | + if ( |
|
75 | 75 | rgar( $post_data_item, 'title' ) === $media_item->post_title && |
76 | 76 | rgar( $post_data_item, 'description' ) === $media_item->post_content && |
77 | 77 | rgar( $post_data_item, 'caption' ) === $media_item->post_excerpt |
78 | 78 | ) { |
79 | - $post_images["{$post_data_item['field_id']}"] = $media_item->ID; |
|
79 | + $post_images[ "{$post_data_item[ 'field_id' ]}" ] = $media_item->ID; |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * If the method changes to public, use Gravity Forms' method |
105 | 105 | * @todo: If/when the method is public, remove the unneeded copied code. |
106 | 106 | */ |
107 | - if( $reflection->isPublic() ) { |
|
107 | + if ( $reflection->isPublic() ) { |
|
108 | 108 | return parent::get_post_fields( $form, $entry ); |
109 | 109 | } |
110 | 110 | |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * If the method changes to public, use Gravity Forms' method |
132 | 132 | * @todo: If/when the method is public, remove the unneeded copied code. |
133 | 133 | */ |
134 | - if( $reflection->isPublic() ) { |
|
134 | + if ( $reflection->isPublic() ) { |
|
135 | 135 | return parent::copy_post_image( $url, $post_id ); |
136 | 136 | } |
137 | 137 | |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * If the method changes to public, use Gravity Forms' method |
167 | 167 | * @todo: If/when the method is public, remove the unneeded copied code. |
168 | 168 | */ |
169 | - if( $reflection->isPublic() ) { |
|
169 | + if ( $reflection->isPublic() ) { |
|
170 | 170 | return parent::media_handle_upload( $url, $post_id, $post_data ); |
171 | 171 | } |
172 | 172 |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | $tables = array(); |
43 | 43 | |
44 | 44 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) ) { |
45 | - $tables []= GFFormsModel::get_entry_meta_table_name(); |
|
45 | + $tables [ ] = GFFormsModel::get_entry_meta_table_name(); |
|
46 | 46 | } |
47 | - $tables []= GFFormsModel::get_lead_meta_table_name(); |
|
47 | + $tables [ ] = GFFormsModel::get_lead_meta_table_name(); |
|
48 | 48 | |
49 | 49 | $suppress = $wpdb->suppress_errors(); |
50 | 50 | foreach ( $tables as $meta_table ) { |
@@ -70,13 +70,13 @@ discard block |
||
70 | 70 | $tables = array(); |
71 | 71 | |
72 | 72 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_notes_table_name' ) ) { |
73 | - $tables[] = GFFormsModel::get_entry_notes_table_name(); |
|
73 | + $tables[ ] = GFFormsModel::get_entry_notes_table_name(); |
|
74 | 74 | } |
75 | 75 | |
76 | - $tables[] = GFFormsModel::get_lead_notes_table_name(); |
|
76 | + $tables[ ] = GFFormsModel::get_lead_notes_table_name(); |
|
77 | 77 | |
78 | - $disapproved = __('Disapproved the Entry for GravityView', 'gravityview'); |
|
79 | - $approved = __('Approved the Entry for GravityView', 'gravityview'); |
|
78 | + $disapproved = __( 'Disapproved the Entry for GravityView', 'gravityview' ); |
|
79 | + $approved = __( 'Approved the Entry for GravityView', 'gravityview' ); |
|
80 | 80 | |
81 | 81 | $suppress = $wpdb->suppress_errors(); |
82 | 82 | foreach ( $tables as $notes_table ) { |