|
@@ -35,7 +35,7 @@ discard block |
|
|
block discarded – undo |
|
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 |
|
|
block discarded – undo |
|
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(); |
|
@@ -86,8 +86,8 @@ discard block |
|
|
block discarded – undo |
|
86
|
86
|
* @return void |
|
87
|
87
|
*/ |
|
88
|
88
|
function render_provider_request() { |
|
89
|
|
- if ( ! empty( $_GET['url'] ) ) { |
|
90
|
|
- $url = $_GET['url']; |
|
|
89
|
+ if ( ! empty( $_GET[ 'url' ] ) ) { |
|
|
90
|
+ $url = $_GET[ 'url' ]; |
|
91
|
91
|
} else { |
|
92
|
92
|
header( 'HTTP/1.0 404 Not Found' ); |
|
93
|
93
|
exit; |
|
@@ -96,16 +96,16 @@ discard block |
|
|
block discarded – undo |
|
96
|
96
|
preg_match( $this->get_handler_regex(), $url, $matches ); |
|
97
|
97
|
|
|
98
|
98
|
// If not using permalinks, re-assign values for matching groups |
|
99
|
|
- if ( ! empty( $matches['entry_slug2'] ) ) { |
|
100
|
|
- $matches['is_cpt'] = $matches['is_cpt2']; |
|
101
|
|
- $matches['slug'] = $matches['slug2']; |
|
102
|
|
- $matches['entry_slug'] = $matches['entry_slug2']; |
|
103
|
|
- unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
|
99
|
+ if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
|
100
|
+ $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
|
101
|
+ $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
|
102
|
+ $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
|
103
|
+ unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
104
|
104
|
} |
|
105
|
105
|
|
|
106
|
106
|
// No Entry was found |
|
107
|
|
- if ( empty( $matches['entry_slug'] ) ) { |
|
108
|
|
- do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
|
107
|
+ if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
|
108
|
+ do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
109
|
109
|
header( 'HTTP/1.0 404 Not Found' ); |
|
110
|
110
|
exit; |
|
111
|
111
|
} |
|
@@ -158,7 +158,7 @@ discard block |
|
|
block discarded – undo |
|
158
|
158
|
// Catch either |
|
159
|
159
|
$match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})"; |
|
160
|
160
|
|
|
161
|
|
- return '#'.$match_regex.'#i'; |
|
|
161
|
+ return '#' . $match_regex . '#i'; |
|
162
|
162
|
} |
|
163
|
163
|
|
|
164
|
164
|
/** |
|
@@ -177,18 +177,18 @@ discard block |
|
|
block discarded – undo |
|
177
|
177
|
|
|
178
|
178
|
$post_id = url_to_postid( $url ); |
|
179
|
179
|
|
|
180
|
|
- if( empty( $post_id ) ) { |
|
|
180
|
+ if ( empty( $post_id ) ) { |
|
181
|
181
|
|
|
182
|
182
|
$args = array( |
|
183
|
183
|
'post_status' => 'publish', |
|
184
|
184
|
'name' => $slug, |
|
185
|
|
- 'post_type' => array('any', 'gravityview'), |
|
|
185
|
+ 'post_type' => array( 'any', 'gravityview' ), |
|
186
|
186
|
); |
|
187
|
187
|
|
|
188
|
188
|
$posts = get_posts( $args ); |
|
189
|
189
|
|
|
190
|
|
- if( !empty( $posts ) ) { |
|
191
|
|
- $post_id = $posts[0]->ID; |
|
|
190
|
+ if ( ! empty( $posts ) ) { |
|
|
191
|
+ $post_id = $posts[ 0 ]->ID; |
|
192
|
192
|
} |
|
193
|
193
|
} |
|
194
|
194
|
|
|
@@ -221,17 +221,17 @@ discard block |
|
|
block discarded – undo |
|
221
|
221
|
public function render_handler( $matches, $attr, $url, $rawattr ) { |
|
222
|
222
|
|
|
223
|
223
|
// If not using permalinks, re-assign values for matching groups |
|
224
|
|
- if( !empty( $matches['entry_slug2'] ) ) { |
|
225
|
|
- $matches['is_cpt'] = $matches['is_cpt2']; |
|
226
|
|
- $matches['slug'] = $matches['slug2']; |
|
227
|
|
- $matches['entry_slug'] = $matches['entry_slug2']; |
|
228
|
|
- unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] ); |
|
|
224
|
+ if ( ! empty( $matches[ 'entry_slug2' ] ) ) { |
|
|
225
|
+ $matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ]; |
|
|
226
|
+ $matches[ 'slug' ] = $matches[ 'slug2' ]; |
|
|
227
|
+ $matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ]; |
|
|
228
|
+ unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] ); |
|
229
|
229
|
} |
|
230
|
230
|
|
|
231
|
231
|
// No Entry was found |
|
232
|
|
- if( empty( $matches['entry_slug'] ) ) { |
|
|
232
|
+ if ( empty( $matches[ 'entry_slug' ] ) ) { |
|
233
|
233
|
|
|
234
|
|
- do_action('gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
|
234
|
+ do_action( 'gravityview_log_error', 'GravityView_oEmbed[render_handler] $entry_slug not parsed by regex.', $matches ); |
|
235
|
235
|
|
|
236
|
236
|
return ''; |
|
237
|
237
|
} |
|
@@ -241,11 +241,11 @@ discard block |
|
|
block discarded – undo |
|
241
|
241
|
// Setup the data used |
|
242
|
242
|
$this->set_vars( $matches, $attr, $url, $rawattr ); |
|
243
|
243
|
|
|
244
|
|
- if( is_admin() && !$this->is_full_oembed_preview ) { |
|
|
244
|
+ if ( is_admin() && ! $this->is_full_oembed_preview ) { |
|
245
|
245
|
$return = $this->render_admin( $matches, $attr, $url, $rawattr ); |
|
246
|
246
|
} else { |
|
247
|
247
|
|
|
248
|
|
- if( $this->is_full_oembed_preview ) { |
|
|
248
|
+ if ( $this->is_full_oembed_preview ) { |
|
249
|
249
|
$return .= $this->generate_preview_notice(); |
|
250
|
250
|
} |
|
251
|
251
|
|
|
@@ -264,8 +264,8 @@ discard block |
|
|
block discarded – undo |
|
264
|
264
|
private function generate_preview_notice() { |
|
265
|
265
|
$floaty = GravityView_Admin::get_floaty(); |
|
266
|
266
|
$title = esc_html__( 'This will look better when it is embedded.', 'gravityview' ); |
|
267
|
|
- $message = esc_html__('Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview'); |
|
268
|
|
- return '<div class="updated notice">'. $floaty. '<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>'; |
|
|
267
|
+ $message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' ); |
|
|
268
|
+ return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>'; |
|
269
|
269
|
} |
|
270
|
270
|
|
|
271
|
271
|
/** |
|
@@ -278,14 +278,14 @@ discard block |
|
|
block discarded – undo |
|
278
|
278
|
*/ |
|
279
|
279
|
private function set_vars( $matches, $attr, $url, $rawattr ) { |
|
280
|
280
|
|
|
281
|
|
- $this->entry_id = $matches['entry_slug']; |
|
|
281
|
+ $this->entry_id = $matches[ 'entry_slug' ]; |
|
282
|
282
|
|
|
283
|
|
- $post_id = $this->get_postid_from_url_and_slug( $url, $matches['slug'] ); |
|
|
283
|
+ $post_id = $this->get_postid_from_url_and_slug( $url, $matches[ 'slug' ] ); |
|
284
|
284
|
|
|
285
|
285
|
// The URL didn't have the View Custom Post Type structure. |
|
286
|
|
- if( empty( $matches['is_cpt'] ) || $matches['is_cpt'] !== 'gravityview' ) { |
|
|
286
|
+ if ( empty( $matches[ 'is_cpt' ] ) || $matches[ 'is_cpt' ] !== 'gravityview' ) { |
|
287
|
287
|
|
|
288
|
|
- do_action('gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
|
288
|
+ do_action( 'gravityview_log_debug', 'GravityView_oEmbed[render_handler] Embedding an entry inside a post or page', $matches ); |
|
289
|
289
|
|
|
290
|
290
|
if ( defined( 'GRAVITYVIEW_FUTURE_CORE_LOADED' ) && $post = get_post( $post_id ) ) { |
|
291
|
291
|
$views = \GV\View_Collection::from_post( $post ); |
|
@@ -298,7 +298,7 @@ discard block |
|
|
block discarded – undo |
|
298
|
298
|
} |
|
299
|
299
|
} |
|
300
|
300
|
|
|
301
|
|
- $this->view_id = $views[0]->ID; |
|
|
301
|
+ $this->view_id = $views[ 0 ]->ID; |
|
302
|
302
|
} |
|
303
|
303
|
} else { |
|
304
|
304
|
/** Deprecated. */ |
|
@@ -312,7 +312,7 @@ discard block |
|
|
block discarded – undo |
|
312
|
312
|
} |
|
313
|
313
|
|
|
314
|
314
|
// The inline content has $_POST['type'] set to "embed", while the "Add Media" modal doesn't set that. |
|
315
|
|
- $this->is_full_oembed_preview = ( isset( $_POST['action'] ) && $_POST['action'] === 'parse-embed' && !isset( $_POST['type'] ) ); |
|
|
315
|
+ $this->is_full_oembed_preview = ( isset( $_POST[ 'action' ] ) && $_POST[ 'action' ] === 'parse-embed' && ! isset( $_POST[ 'type' ] ) ); |
|
316
|
316
|
} |
|
317
|
317
|
|
|
318
|
318
|
/** |
|
@@ -330,15 +330,15 @@ discard block |
|
|
block discarded – undo |
|
330
|
330
|
// Floaty the astronaut |
|
331
|
331
|
$image = GravityView_Admin::get_floaty(); |
|
332
|
332
|
|
|
333
|
|
- $embed_heading = sprintf( esc_html__('Embed Entry %d', 'gravityview'), $this->entry_id ); |
|
|
333
|
+ $embed_heading = sprintf( esc_html__( 'Embed Entry %d', 'gravityview' ), $this->entry_id ); |
|
334
|
334
|
|
|
335
|
|
- $embed_text = sprintf( esc_html__('This entry will be displayed as it is configured in View %d', 'gravityview'), $this->view_id ); |
|
|
335
|
+ $embed_text = sprintf( esc_html__( 'This entry will be displayed as it is configured in View %d', 'gravityview' ), $this->view_id ); |
|
336
|
336
|
|
|
337
|
337
|
return ' |
|
338
|
338
|
<div class="loading-placeholder" style="background-color:#e6f0f5;"> |
|
339
|
|
- <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> |
|
|
339
|
+ <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> |
|
340
|
340
|
<p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;"> |
|
341
|
|
- '.$embed_text.' |
|
|
341
|
+ '.$embed_text . ' |
|
342
|
342
|
</p> |
|
343
|
343
|
<br style="clear: both;"> |
|
344
|
344
|
</div>'; |
|
@@ -393,14 +393,14 @@ discard block |
|
|
block discarded – undo |
|
393
|
393
|
private function render_frontend( $matches, $attr, $url, $rawattr ) { |
|
394
|
394
|
|
|
395
|
395
|
// If it's already been parsed, don't re-output it. |
|
396
|
|
- if( !empty( $this->output[ $this->entry_id ] ) ) { |
|
|
396
|
+ if ( ! empty( $this->output[ $this->entry_id ] ) ) { |
|
397
|
397
|
return $this->output[ $this->entry_id ]; |
|
398
|
398
|
} |
|
399
|
399
|
|
|
400
|
400
|
$entry_output = $this->generate_entry_output(); |
|
401
|
401
|
|
|
402
|
402
|
// Wrap a container div around the output to allow for custom styling |
|
403
|
|
- $output = sprintf('<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-'.$this->entry_id.'">%s</div>', $entry_output ); |
|
|
403
|
+ $output = sprintf( '<div class="gravityview-oembed gravityview-oembed-entry gravityview-oembed-entry-' . $this->entry_id . '">%s</div>', $entry_output ); |
|
404
|
404
|
|
|
405
|
405
|
/** |
|
406
|
406
|
* @filter `gravityview/oembed/entry` Filter the output of the oEmbed entry embed |
|
@@ -413,7 +413,7 @@ discard block |
|
|
block discarded – undo |
|
413
|
413
|
* @var string $url The original URL that was matched by the regex. \n |
|
414
|
414
|
* @var array $rawattr The original unmodified attributes. |
|
415
|
415
|
*/ |
|
416
|
|
- $output = apply_filters('gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
|
416
|
+ $output = apply_filters( 'gravityview/oembed/entry', $output, $this, compact( $entry_output, $matches, $attr, $url, $rawattr ) ); |
|
417
|
417
|
|
|
418
|
418
|
unset( $entry_output ); |
|
419
|
419
|
|