WpContext.php
20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
<?php
namespace AIOSEO\Plugin\Common\Traits\Helpers;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains all context related helper methods.
* This includes methods to check the context of the current request, but also get WP objects.
*
* @since 4.1.4
*/
trait WpContext {
/**
* The original main query.
*
* @since 4.3.0
*
* @var WP_Query
*/
public $originalQuery;
/**
* The original main post variable.
*
* @since 4.3.0
*
* @var WP_Post
*/
public $originalPost;
/**
* Get the home page object.
*
* @since 4.1.1
*
* @return WP_Post|null The home page.
*/
public function getHomePage() {
$homePageId = $this->getHomePageId();
return $homePageId ? get_post( $homePageId ) : null;
}
/**
* Get the ID of the home page.
*
* @since 4.0.0
*
* @return integer|null The home page ID.
*/
public function getHomePageId() {
$pageShowOnFront = ( 'page' === get_option( 'show_on_front' ) );
$pageOnFrontId = get_option( 'page_on_front' );
return $pageShowOnFront && $pageOnFrontId ? (int) $pageOnFrontId : null;
}
/**
* Returns the blog page.
*
* @since 4.0.0
*
* @return WP_Post|null The blog page.
*/
public function getBlogPage() {
$blogPageId = $this->getBlogPageId();
return $blogPageId ? get_post( $blogPageId ) : null;
}
/**
* Gets the current blog page id if it's configured.
*
* @since 4.1.1
*
* @return int|null
*/
public function getBlogPageId() {
$pageShowOnFront = ( 'page' === get_option( 'show_on_front' ) );
$blogPageId = (int) get_option( 'page_for_posts' );
return $pageShowOnFront && $blogPageId ? $blogPageId : null;
}
/**
* Checks whether the current page is a taxonomy term archive.
*
* @since 4.0.0
*
* @return bool Whether the current page is a taxonomy term archive.
*/
public function isTaxTerm() {
$object = get_queried_object();
return $object instanceof \WP_Term;
}
/**
* Checks whether the current page is a static one.
*
* @since 4.0.0
*
* @return bool Whether the current page is a static one.
*/
public function isStaticPage() {
return $this->isStaticHomePage() || $this->isStaticPostsPage() || $this->isWooCommerceShopPage();
}
/**
* Checks whether the current page is the static homepage.
*
* @since 4.0.0
*
* @param mixed $post Pass in an optional post to check if its the static home page.
* @return bool Whether the current page is the static homepage.
*/
public function isStaticHomePage( $post = null ) {
static $isHomePage = null;
if ( null !== $isHomePage ) {
return $isHomePage;
}
$post = aioseo()->helpers->getPost( $post );
return ( 'page' === get_option( 'show_on_front' ) && ! empty( $post->ID ) && (int) get_option( 'page_on_front' ) === $post->ID );
}
/**
* Checks whether the current page is the dynamic homepage.
*
* @since 4.2.3
*
* @return bool Whether the current page is the dynamic homepage.
*/
public function isDynamicHomePage() {
return is_front_page() && is_home();
}
/**
* Checks whether the current page is the static posts page.
*
* @since 4.0.0
*
* @return bool Whether the current page is the static posts page.
*/
public function isStaticPostsPage() {
return is_home() && ( 0 !== (int) get_option( 'page_for_posts' ) );
}
/**
* Checks whether current page supports meta.
*
* @since 4.0.0
*
* @return bool Whether the current page supports meta.
*/
public function supportsMeta() {
return ! is_date() && ! is_author() && ! is_search() && ! is_404();
}
/**
* Returns the current post object.
*
* @since 4.0.0
*
* @param WP_Post|int $postId The post ID.
* @return WP_Post|null The post object.
*/
public function getPost( $postId = false ) {
$postId = is_a( $postId, 'WP_Post' ) ? $postId->ID : $postId;
if ( aioseo()->helpers->isWooCommerceShopPage( $postId ) ) {
return get_post( wc_get_page_id( 'shop' ) );
}
if ( is_front_page() || is_home() ) {
$showOnFront = 'page' === get_option( 'show_on_front' );
if ( $showOnFront ) {
if ( is_front_page() ) {
$pageOnFront = (int) get_option( 'page_on_front' );
return get_post( $pageOnFront );
} elseif ( is_home() ) {
$pageForPosts = (int) get_option( 'page_for_posts' );
return get_post( $pageForPosts );
}
}
}
// Learnpress lessons load the course. So here we need to switch to the lesson.
$learnPressLesson = aioseo()->helpers->getLearnPressLesson();
if ( ! $postId && $learnPressLesson ) {
$postId = $learnPressLesson;
}
// We need to check these conditions and cannot always return get_post() because we'll return the first post on archive pages (dynamic homepage, term pages, etc.).
if (
$this->isScreenBase( 'post' ) ||
$postId ||
is_singular()
) {
return get_post( $postId );
}
return null;
}
/**
* Returns the current post ID.
*
* @since 4.3.1
*
* @return int|null The post ID.
*/
public function getPostId() {
$post = $this->getPost();
return is_object( $post ) && property_exists( $post, 'ID' ) ? $post->ID : null;
}
/**
* Returns the post content after parsing it.
*
* @since 4.1.5
*
* @param WP_Post|int $post The post (optional).
* @return string The post content.
*/
public function getPostContent( $post = null ) {
$post = is_a( $post, 'WP_Post' ) ? $post : $this->getPost( $post );
static $content = [];
if ( isset( $content[ $post->ID ] ) ) {
return $content[ $post->ID ];
}
$content[ $post->ID ] = $this->theContent( $post->post_content );
if ( apply_filters( 'aioseo_description_include_custom_fields', true, $post ) ) {
$content[ $post->ID ] .= $this->theContent( $this->getPostCustomFieldsContent( $post ) );
}
return $content[ $post->ID ];
}
/**
* Gets the content from configured custom fields.
*
* @since 4.2.7
*
* @param WP_Post|int $post A post object or ID.
* @return string The content.
*/
public function getPostCustomFieldsContent( $post = null ) {
$post = is_a( $post, 'WP_Post' ) ? $post : $this->getPost( $post );
if ( ! aioseo()->dynamicOptions->searchAppearance->postTypes->has( $post->post_type ) ) {
return '';
}
$customFieldKeys = aioseo()->dynamicOptions->searchAppearance->postTypes->{$post->post_type}->customFields;
if ( empty( $customFieldKeys ) ) {
return '';
}
$customFieldKeys = explode( ' ', sanitize_text_field( $customFieldKeys ) );
return aioseo()->helpers->getCustomFieldsContent( $post, $customFieldKeys );
}
/**
* Returns the post content after parsing shortcodes and blocks.
* We avoid using the "the_content" hook because it breaks stuff if we call it outside the loop or main query.
* See https://developer.wordpress.org/reference/hooks/the_content/
*
* @since 4.1.5.2
*
* @param string $postContent The post content.
* @return string The parsed post content.
*/
public function theContent( $postContent ) {
if ( ! aioseo()->options->searchAppearance->advanced->runShortcodes ) {
return $postContent;
}
// The order of the function calls below is intentional and should NOT change.
$postContent = function_exists( 'do_blocks' ) ? do_blocks( $postContent ) : $postContent; // phpcs:ignore AIOSEO.WpFunctionUse.NewFunctions.do_blocksFound
$postContent = wpautop( $postContent );
$postContent = $this->doShortcodes( $postContent );
return $postContent;
}
/**
* Returns the description based on the post content.
*
* @since 4.0.0
*
* @param WP_Post|int $post The post (optional).
* @return string The description.
*/
public function getDescriptionFromContent( $post = null ) {
$post = is_a( $post, 'WP_Post' ) ? $post : $this->getPost( $post );
static $content = [];
if ( isset( $content[ $post->ID ] ) ) {
return $content[ $post->ID ];
}
$content[ $post->ID ] = '';
if ( ! empty( $post->post_password ) ) {
return $content[ $post->ID ];
}
$postContent = $this->getPostContent( $post );
// Strip images, captions and WP oembed wrappers (e.g. YouTube URLs) from the post content.
$postContent = preg_replace( '/(<figure.*?\/figure>|<img.*?\/>|<div.*?class="wp-block-embed__wrapper".*?>.*?<\/div>)/s', '', $postContent );
$postContent = str_replace( ']]>', ']]>', $postContent );
$postContent = trim( wp_strip_all_tags( strip_shortcodes( $postContent ) ) );
$content[ $post->ID ] = wp_trim_words( $postContent, 55, '' );
return $content[ $post->ID ];
}
/**
* Returns custom fields as a string.
*
* @since 4.0.6
*
* @param WP_Post|int $post The post.
* @param array $keys The post meta_keys to check for values.
* @return string The custom field content.
*/
public function getCustomFieldsContent( $post = null, $keys = [] ) {
$post = is_a( $post, 'WP_Post' ) ? $post : $this->getPost( $post );
$customFieldContent = '';
$acfFields = $this->getAcfContent( $post );
foreach ( $keys as $key ) {
// Try ACF.
if ( isset( $acfFields[ $key ] ) ) {
$customFieldContent .= "{$acfFields[$key]} ";
continue;
}
// Fallback to post meta.
$value = get_post_meta( $post->ID, $key, true );
if ( $value ) {
if ( ! is_string( $value ) ) {
$value = strval( $value );
}
$customFieldContent .= "{$value} ";
}
}
return $customFieldContent;
}
/**
* Returns if the page is a special type (WooCommerce pages, Privacy page).
*
* @since 4.0.0
*
* @param int $postId The post ID.
* @return bool If the page is special or not.
*/
public function isSpecialPage( $postId = false ) {
if (
(int) get_option( 'page_for_posts' ) === (int) $postId ||
(int) get_option( 'wp_page_for_privacy_policy' ) === (int) $postId ||
$this->isBuddyPressPage( $postId ) ||
$this->isWooCommercePage( $postId )
) {
return true;
}
return false;
}
/**
* Returns the page number of the current page.
*
* @since 4.0.0
*
* @return int The page number.
*/
public function getPageNumber() {
$page = get_query_var( 'page' );
if ( ! empty( $page ) ) {
return (int) $page;
}
$paged = get_query_var( 'paged' );
if ( ! empty( $paged ) ) {
return (int) $paged;
}
return 1;
}
/**
* Returns the page number for the comment page.
*
* @since 4.2.1
*
* @return int|false The page number or false if we're not on a comment page.
*/
public function getCommentPageNumber() {
$cpage = get_query_var( 'cpage' );
return ! empty( $cpage ) ? (int) $cpage : false;
}
/**
* Check if the post passed in is a valid post, not a revision or autosave.
*
* @since 4.0.5
*
* @param WP_Post $post The Post object to check.
* @param array $allowedPostStatuses Allowed post statuses.
* @return bool True if valid, false if not.
*/
public function isValidPost( $post, $allowedPostStatuses = [ 'publish' ] ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return false;
}
if ( ! is_object( $post ) ) {
$post = get_post( $post );
}
// No post, no go.
if ( empty( $post ) ) {
return false;
}
// In order to prevent recursion, we are skipping scheduled-action posts and revisions.
if (
'scheduled-action' === $post->post_type ||
'revision' === $post->post_type
) {
return false;
}
// Ensure this post has the proper post status.
if (
! in_array( $post->post_status, $allowedPostStatuses, true ) &&
! in_array( 'all', $allowedPostStatuses, true )
) {
return false;
}
return true;
}
/**
* Checks whether the given URL is a valid attachment.
*
* @since 4.0.13
*
* @param string $url The URL.
* @return bool Whether the URL is a valid attachment.
*/
public function isValidAttachment( $url ) {
$uploadDirUrl = aioseo()->helpers->escapeRegex( $this->getWpContentUrl() );
return preg_match( "/$uploadDirUrl.*/", $url );
}
/**
* Tries to convert an attachment URL into a post ID.
*
* This our own optimized version of attachment_url_to_postid().
*
* @since 4.0.13
*
* @param string $url The attachment URL.
* @return int|bool The attachment ID or false if no attachment could be found.
*/
public function attachmentUrlToPostId( $url ) {
$cacheName = 'attachment_url_to_post_id_' . sha1( "aioseo_attachment_url_to_post_id_$url" );
$cachedId = aioseo()->core->cache->get( $cacheName );
if ( $cachedId ) {
return 'none' !== $cachedId && is_numeric( $cachedId ) ? (int) $cachedId : false;
}
$path = $url;
$uploadDirInfo = wp_get_upload_dir();
$siteUrl = wp_parse_url( $uploadDirInfo['url'] );
$imagePath = wp_parse_url( $path );
// Force the protocols to match if needed.
if ( isset( $imagePath['scheme'] ) && ( $imagePath['scheme'] !== $siteUrl['scheme'] ) ) {
$path = str_replace( $imagePath['scheme'], $siteUrl['scheme'], $path );
}
if ( ! $this->isValidAttachment( $path ) ) {
aioseo()->core->cache->update( $cacheName, 'none' );
return false;
}
if ( 0 === strpos( $path, $uploadDirInfo['baseurl'] . '/' ) ) {
$path = substr( $path, strlen( $uploadDirInfo['baseurl'] . '/' ) );
}
$results = aioseo()->core->db->start( 'postmeta' )
->select( 'post_id' )
->where( 'meta_key', '_wp_attached_file' )
->where( 'meta_value', $path )
->limit( 1 )
->run()
->result();
if ( empty( $results[0]->post_id ) ) {
aioseo()->core->cache->update( $cacheName, 'none' );
return false;
}
aioseo()->core->cache->update( $cacheName, $results[0]->post_id );
return $results[0]->post_id;
}
/**
* Returns true if the request is a non-legacy REST API request.
* This function was copied from WooCommerce and improved.
*
* @since 4.1.2
*
* @return bool True if this is a REST API request.
*/
public function isRestApiRequest() {
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
return true;
}
global $wp_rewrite;
if ( empty( $wp_rewrite ) ) {
return false;
}
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
return false;
}
$restUrl = wp_parse_url( get_rest_url() );
$restUrl = $restUrl['path'] . ( ! empty( $restUrl['query'] ) ? '?' . $restUrl['query'] : '' );
$isRestApiRequest = ( 0 === strpos( $_SERVER['REQUEST_URI'], $restUrl ) );
return apply_filters( 'aioseo_is_rest_api_request', $isRestApiRequest );
}
/**
* Checks whether the current request is an AJAX, CRON or REST request.
*
* @since 4.1.3
*
* @return bool Wether the request is an AJAX, CRON or REST request.
*/
public function isAjaxCronRestRequest() {
return wp_doing_ajax() || wp_doing_cron() || $this->isRestApiRequest();
}
/**
* Check if we are in the middle of a WP-CLI call.
*
* @since 4.2.8
*
* @return bool True if we are in the WP_CLI context.
*/
public function isDoingWpCli() {
return defined( 'WP_CLI' ) && WP_CLI;
}
/**
* Checks whether we're on the given screen.
*
* @since 4.0.7
* @version 4.3.1
*
* @param string $screenName The screen name.
* @param string $comparison Check as a prefix.
* @return bool Whether we're on the given screen.
*/
public function isScreenBase( $screenName, $comparison = '' ) {
$screen = $this->getCurrentScreen();
if ( ! $screen || ! isset( $screen->base ) ) {
return false;
}
if ( 'prefix' === $comparison ) {
return 0 === stripos( $screen->base, $screenName );
}
return $screen->base === $screenName;
}
/**
* Returns if current screen is of a post type
*
* @since 4.0.17
*
* @param string $postType Post type slug
* @return bool True if the current screen is a post type screen.
*/
public function isScreenPostType( $postType ) {
$screen = $this->getCurrentScreen();
if ( ! $screen || ! isset( $screen->post_type ) ) {
return false;
}
return $screen->post_type === $postType;
}
/**
* Returns if current screen is a post list, optionaly of a post type.
*
* @since 4.2.4
*
* @param string $postType Post type slug.
* @return bool Is a post list.
*/
public function isScreenPostList( $postType = '' ) {
$screen = $this->getCurrentScreen();
if (
! $this->isScreenBase( 'edit' ) ||
empty( $screen->post_type )
) {
return false;
}
if ( ! empty( $postType ) && $screen->post_type !== $postType ) {
return false;
}
return true;
}
/**
* Returns if current screen is a post edit screen, optionaly of a post type.
*
* @since 4.2.4
*
* @param string $postType Post type slug.
* @return bool Is a post editing screen.
*/
public function isScreenPostEdit( $postType = '' ) {
$screen = $this->getCurrentScreen();
if (
! $this->isScreenBase( 'post' ) ||
empty( $screen->post_type )
) {
return false;
}
if ( ! empty( $postType ) && $screen->post_type !== $postType ) {
return false;
}
return true;
}
/**
* Gets current admin screen.
*
* @since 4.0.17
*
* @return false|\WP_Screen|null
*/
public function getCurrentScreen() {
if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) {
return false;
}
return get_current_screen();
}
/**
* Checks whether the current site is a multisite subdomain.
*
* @since 4.1.9
*
* @return bool Whether the current site is a subdomain.
*/
public function isSubdomain() {
if ( ! is_multisite() ) {
return false;
}
return apply_filters( 'aioseo_multisite_subdomain', is_subdomain_install() );
}
/**
* Returns if the current page is the login or register page.
*
* @since 4.2.1
*
* @return bool Login or register page.
*/
public function isWpLoginPage() {
$self = ! empty( $_SERVER['PHP_SELF'] ) ? wp_unslash( $_SERVER['PHP_SELF'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
if ( preg_match( '/wp-login\.php$|wp-register\.php$/', $self ) ) {
return true;
}
return false;
}
/**
* Returns which type of WordPress page we're seeing.
* It will only work if {@see \WP_Query::$queried_object} has been set.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#filter-hierarchy
*
* @since 4.2.8
*
* @return string|null The template type or `null` if no match.
*/
public function getTemplateType() {
static $type = null;
if ( ! empty( $type ) ) {
return $type;
}
if ( is_attachment() ) {
$type = 'attachment';
} elseif ( is_single() ) {
$type = 'single';
} elseif (
is_page() ||
$this->isStaticPostsPage() ||
$this->isWooCommerceShopPage()
) {
$type = 'page';
} elseif ( is_author() ) { // An author page is an archive page, so it needs to be checked before `is_archive()`.
$type = 'author';
} elseif (
is_tax() ||
is_category() ||
is_tag()
) { // A taxonomy term page is an archive page, so it needs to be checked before `is_archive()`.
$type = 'taxonomy';
} elseif ( is_date() ) { // A date page is an archive page, so it needs to be checked before `is_archive()`.
$type = 'date';
} elseif ( is_archive() ) {
$type = 'archive';
} elseif ( is_home() && is_front_page() ) {
$type = 'dynamic_home';
} elseif ( is_search() ) {
$type = 'search';
}
return $type;
}
/**
* Sets the given post as the queried object of the main query.
*
* @since 4.3.0
*
* @param \WP_Post $post The post object.
* @return void
*/
public function setWpQueryPost( $wpPost ) {
global $wp_query, $post;
$this->originalQuery = clone $wp_query;
$this->originalPost = $post;
$wp_query->posts = [ $wpPost ];
$wp_query->post = $wpPost;
$wp_query->post_count = 1;
$wp_query->get_queried_object_id = (int) $wpPost->ID;
$wp_query->queried_object = $wpPost;
$wp_query->is_single = true;
$wp_query->is_singular = true;
if ( 'page' === $wpPost->post_type ) {
$wp_query->is_page = true;
}
$post = $wpPost;
}
/**
* Sets the given term as the queried object of the main query.
*
* @since 1.0.0
*
* @param \WP_Term $term The term object.
* @return void
*/
public function setWpQueryTerm( $term ) {
global $wp_query;
$this->originalQuery = clone $wp_query;
$term->term_id = $term->id;
$wp_query->get_queried_object_id = (int) $term->id;
$wp_query->queried_object = $term;
$wp_query->is_tax = true;
switch ( $term->taxonomy ) {
case 'category':
$wp_query->is_category = true;
break;
case 'post_tag':
$wp_query->is_tag = true;
break;
default:
break;
}
}
/**
* Restores the main query back to the original query.
*
* @since 4.3.0
*
* @return void
*/
public function restoreWpQuery() {
if ( null === $this->originalQuery ) {
return;
}
global $wp_query, $post;
$wp_query = clone $this->originalQuery;
if ( null !== $this->originalPost ) {
$post = $this->originalPost;
}
$this->originalQuery = null;
$this->originalPost = null;
}
}