PluginProbe
User Access Manager / 2.2.19
User Access Manager v2.2.19
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / Wrapper / Wordpress.php

Wordpress.php in User Access Manager 2.2.19, at src/Wrapper/Wordpress.php

1,065 lines 24.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Wordpress.php
4 *
5 * The Wordpress class file.
6 *
7 * PHP versions 5
8 *
9 * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 * @copyright 2008-2017 Alexander Schneider
11 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 * @version SVN: $id$
13 * @link http://wordpress.org/extend/plugins/user-access-manager/
14 */
15
16 declare(strict_types=1);
17
18 namespace UserAccessManager\Wrapper;
19
20 use WP_Error;
21 use WP_Hook;
22 use WP_Post;
23 use WP_Post_Type;
24 use WP_Query;
25 use WP_Roles;
26 use WP_Taxonomy;
27 use WP_Term;
28 use WP_User;
29 use wpdb;
30 use function add_action;
31 use function add_filter;
32 use function add_menu_page;
33 use function add_meta_box;
34 use function add_option;
35 use function add_shortcode;
36 use function add_submenu_page;
37 use function attachment_url_to_postid;
38 use function current_time;
39 use function current_user_can;
40 use function date_i18n;
41 use function dbDelta;
42 use function delete_option;
43 use function do_action;
44 use function do_shortcode;
45 use function esc_html;
46 use function function_exists;
47 use function get_allowed_mime_types;
48 use function get_bloginfo;
49 use function get_home_path;
50 use function get_option;
51 use function get_page_by_path;
52 use function get_page_link;
53 use function get_pages;
54 use function get_post;
55 use function get_post_type_object;
56 use function get_post_types;
57 use function get_queried_object_id;
58 use function get_sites;
59 use function get_taxonomies;
60 use function get_taxonomy;
61 use function get_term;
62 use function get_userdata;
63 use function get_users;
64 use function got_mod_rewrite;
65 use function has_filter;
66 use function home_url;
67 use function is_admin;
68 use function is_feed;
69 use function is_multisite;
70 use function is_page;
71 use function is_post_type_hierarchical;
72 use function is_single;
73 use function is_super_admin;
74 use function is_taxonomy_hierarchical;
75 use function is_user_logged_in;
76 use function plugin_basename;
77 use function plugins_url;
78 use function register_widget;
79 use function remove_action;
80 use function remove_filter;
81 use function site_url;
82 use function switch_to_blog;
83 use function update_option;
84 use function wp_attachment_is_image;
85 use function wp_create_nonce;
86 use function wp_die;
87 use function wp_doing_ajax;
88 use function wp_enqueue_script;
89 use function wp_enqueue_style;
90 use function wp_get_current_user;
91 use function wp_login_url;
92 use function wp_logout_url;
93 use function wp_lostpassword_url;
94 use function wp_nonce_field;
95 use function wp_parse_id_list;
96 use function wp_redirect;
97 use function wp_register_script;
98 use function wp_register_style;
99 use function wp_registration_url;
100 use function wp_upload_dir;
101 use function wp_verify_nonce;
102
103 /**
104 * Class Wordpress
105 *
106 * @package UserAccessManager\Wrapper
107 */
108 class Wordpress
109 {
110 /**
111 * Returns the database.
112 * @return wpdb
113 */
114 public function getDatabase(): wpdb
115 {
116 global $wpdb;
117 return $wpdb;
118 }
119
120 /**
121 * Returns true if web server is nginx.
122 * @return bool
123 */
124 public function isNginx(): bool
125 {
126 global $is_nginx;
127 return $is_nginx;
128 }
129
130 /**
131 * @param string $postType
132 * @return bool
133 * @see \is_post_type_hierarchical()
134 */
135 public function isPostTypeHierarchical(string $postType): bool
136 {
137 return is_post_type_hierarchical($postType);
138 }
139
140 /**
141 * @param string $taxonomy
142 * @return bool
143 * @see \is_taxonomy_hierarchical()
144 */
145 public function isTaxonomyHierarchical(string $taxonomy): bool
146 {
147 return is_taxonomy_hierarchical($taxonomy);
148 }
149
150 /**
151 * @param int|string $id
152 * @return false|WP_User
153 * @see \get_userdata()
154 */
155 public function getUserData($id)
156 {
157 return get_userdata($id);
158 }
159
160 /**
161 * @param string|array $arguments
162 * @param string $output
163 * @param string $operator
164 * @return array
165 * @see \get_post_types()
166 */
167 public function getPostTypes($arguments = [], $output = 'names', $operator = 'and'): array
168 {
169 return get_post_types($arguments, $output, $operator);
170 }
171
172 /**
173 * @param array $arguments
174 * @param string $output
175 * @param string $operator
176 * @return array
177 * @see \get_taxonomies()
178 */
179 public function getTaxonomies(array $arguments = [], $output = 'names', $operator = 'and'): array
180 {
181 return get_taxonomies($arguments, $output, $operator);
182 }
183
184 /**
185 * @param string $taxonomy
186 * @return false|WP_Taxonomy
187 * @see \get_taxonomy()
188 */
189 public function getTaxonomy(string $taxonomy)
190 {
191 return get_taxonomy($taxonomy);
192 }
193
194 /**
195 * @param int|string $id The post id.
196 * @param string $output
197 * @param string $filter
198 * @return WP_Post|array|null
199 * @see \get_post()
200 */
201 public function getPost($id, $output = OBJECT, $filter = 'raw')
202 {
203 return get_post($id, $output, $filter);
204 }
205
206 /**
207 * @param int|string $postType
208 * @return null|WP_Post_Type
209 * @see \get_post_type_object()
210 */
211 public function getPostTypeObject($postType): ?WP_Post_Type
212 {
213 return get_post_type_object($postType);
214 }
215
216 /**
217 * @param int|string $id
218 * @param string $taxonomy
219 * @param string $output
220 * @param string $filter
221 * @return array|null|WP_Error|WP_Term
222 * @see \get_term()
223 */
224 public function getTerm($id, string $taxonomy = '', string $output = OBJECT, string $filter = 'raw')
225 {
226 return get_term($id, $taxonomy, $output, $filter);
227 }
228
229
230 /**
231 * @param array|string $queries
232 * @param bool $execute
233 * @return array
234 * @see \dbDelta()
235 */
236 public function dbDelta($queries = '', $execute = true): array
237 {
238 if (function_exists('\dbDelta') === false) {
239 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
240 }
241
242 return dbDelta($queries, $execute);
243 }
244
245 /**
246 * @param integer $blogId
247 * @return int|string
248 * @see \switch_to_blog()
249 */
250 public function switchToBlog($blogId)
251 {
252 if (function_exists('\switch_to_blog') === true) {
253 return switch_to_blog($blogId);
254 }
255
256 return true;
257 }
258
259 /**
260 * @return bool
261 * @see \restore_current_blog()
262 */
263 public function restoreCurrentBlog(): bool
264 {
265 if (function_exists('\restore_current_blog') === true) {
266 return restore_current_blog();
267 }
268
269 return true;
270 }
271
272 /**
273 * @return bool
274 * @see \is_multisite()
275 */
276 public function isMultiSite(): bool
277 {
278 return is_multisite();
279 }
280
281 /**
282 * @param string $tag
283 * @param mixed $arguments
284 * @see \do_action()
285 */
286 public function doAction(string $tag, $arguments = '')
287 {
288 do_action($tag, $arguments);
289 }
290
291 /**
292 * @param string $tag
293 * @param callable $functionToAdd
294 * @param int $priority
295 * @param int $acceptedArguments
296 * @return true
297 * @see \add_action()
298 */
299 public function addAction(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
300 {
301 return add_action($tag, $functionToAdd, $priority, $acceptedArguments);
302 }
303
304 /**
305 * @param string $hookName
306 * @param callable $callback
307 * @param $priority
308 * @return bool
309 * @see \remove_action()
310 */
311 public function removeAction(string $hookName, callable $callback, $priority = 10)
312 {
313 return remove_action($hookName, $callback, $priority);
314 }
315
316 /**
317 * @param string $tag
318 * @param bool|callable $functionToCheck
319 * @return bool|false|int
320 * @see \has_filter()
321 */
322 public function hasFilter(string $tag, $functionToCheck = false)
323 {
324 return has_filter($tag, $functionToCheck);
325 }
326
327 /**
328 * @param string $tag
329 * @param callable $functionToAdd
330 * @param int $priority
331 * @param int $acceptedArguments
332 * @return true
333 * @see \add_filter()
334 */
335 public function addFilter(string $tag, callable $functionToAdd, $priority = 10, $acceptedArguments = 1)
336 {
337 return add_filter($tag, $functionToAdd, $priority, $acceptedArguments);
338 }
339
340 /**
341 * @param string $tag
342 * @param callable $functionToRemove
343 * @param int $priority
344 * @return bool
345 * @see \remove_filter()
346 */
347 public function removeFilter(string $tag, callable $functionToRemove, $priority = 10): bool
348 {
349 return remove_filter($tag, $functionToRemove, $priority);
350 }
351
352 /**
353 * @param string $option
354 * @param mixed $value
355 * @param string $deprecated
356 * @param string|bool $autoload
357 * @return bool
358 * @see \add_option()
359 */
360 public function addOption(string $option, $value = '', $deprecated = '', $autoload = 'yes'): bool
361 {
362 return add_option($option, $value, $deprecated, $autoload);
363 }
364
365 /**
366 * @param string $option
367 * @return bool
368 * @see \delete_option()
369 */
370 public function deleteOption(string $option): bool
371 {
372 return delete_option($option);
373 }
374
375 /**
376 * @param string $option
377 * @param mixed $value
378 * @param string|bool $autoload
379 * @return bool
380 * @see \update_option()
381 */
382 public function updateOption(string $option, $value = '', $autoload = 'yes'): bool
383 {
384 return update_option($option, $value, $autoload);
385 }
386
387 /**
388 * @param string $option
389 * @param mixed $default
390 * @return mixed
391 * @see \get_option()
392 */
393 public function getOption(string $option, $default = false)
394 {
395 return get_option($option, $default);
396 }
397
398 /**
399 * @param int|bool $userId
400 * @return bool
401 * @see \is_super_admin()
402 */
403 public function isSuperAdmin($userId = false): bool
404 {
405 return is_super_admin($userId);
406 }
407
408 /**
409 * @return WP_User
410 * @see \wp_get_current_user()
411 */
412 public function getCurrentUser(): WP_User
413 {
414 if (function_exists('\wp_get_current_user') === false) {
415 require_once(ABSPATH . 'wp-includes/pluggable.php');
416 }
417
418 return wp_get_current_user();
419 }
420
421 /**
422 * @param int|WP_User $user
423 * @return array
424 * @see \get_allowed_mime_types()
425 */
426 public function getAllowedMimeTypes($user = null): array
427 {
428 return get_allowed_mime_types($user);
429 }
430
431 /**
432 * @param string $time
433 * @param bool $createDir
434 * @param bool $refreshCache
435 * @return array
436 * @see \wp_upload_dir()
437 */
438 public function getUploadDir($time = null, $createDir = true, $refreshCache = false): array
439 {
440 return wp_upload_dir($time, $createDir, $refreshCache);
441 }
442
443 /**
444 * @param string $path
445 * @param null|string $scheme
446 * @return string
447 * @see \home_url()
448 */
449 public function getHomeUrl($path = '', $scheme = null): string
450 {
451 return home_url($path, $scheme);
452 }
453
454 /**
455 * @param string $path
456 * @param null|string $scheme
457 * @return string
458 * @see \site_url();
459 */
460 public function getSiteUrl($path = '', $scheme = null): string
461 {
462 return site_url($path, $scheme);
463 }
464
465 /**
466 * @return string
467 * @see \get_home_path()
468 */
469 public function getHomePath(): string
470 {
471 if (function_exists('\get_home_path') === false) {
472 require_once(ABSPATH . 'wp-admin/includes/file.php');
473 }
474
475 return get_home_path();
476 }
477
478 /**
479 * @param array|string $list
480 * @return array
481 * @see \wp_parse_id_list()
482 */
483 public function parseIdList($list): array
484 {
485 return wp_parse_id_list($list);
486 }
487
488 /**
489 * @param string $message
490 * @param string $title
491 * @param array $arguments
492 * @see \wp_die()
493 */
494 public function wpDie($message = '', $title = '', array $arguments = [])
495 {
496 wp_die($message, $title, $arguments);
497 }
498
499 /**
500 * @param string|array $feeds
501 * @return bool
502 * @see \is_feed()
503 */
504 public function isFeed($feeds = ''): bool
505 {
506 return is_feed($feeds);
507 }
508
509 /**
510 * @return bool
511 * @see \is_user_logged_in()
512 */
513 public function isUserLoggedIn(): bool
514 {
515 return is_user_logged_in();
516 }
517
518 /**
519 * @param string $pagePath
520 * @param string $output
521 * @param string $postType
522 * @return array|null|WP_Post
523 * @see \get_page_by_path()
524 */
525 public function getPageByPath(string $pagePath, $output = OBJECT, $postType = 'page')
526 {
527 return get_page_by_path($pagePath, $output, $postType);
528 }
529
530 /**
531 * @param string $location
532 * @param int $status
533 * @return bool
534 * @see \wp_redirect()
535 */
536 public function wpRedirect(string $location, $status = 302): bool
537 {
538 return wp_redirect($location, $status);
539 }
540
541 /**
542 * @param bool|int|WP_Post $post
543 * @param bool $leaveName
544 * @param bool $sample
545 * @return string The page permalink.
546 */
547 public function getPageLink($post = false, $leaveName = false, $sample = false): string
548 {
549 return get_page_link($post, $leaveName, $sample);
550 }
551
552 /**
553 * Returns the wp_query object.
554 * @return WP_Query
555 */
556 public function getWpQuery(): WP_Query
557 {
558 global $wp_query;
559 return $wp_query;
560 }
561
562 /**
563 * @return bool
564 * @see \is_admin()
565 */
566 public function isAdmin(): bool
567 {
568 //Ajax request are always identified as administrative interface page
569 if (wp_doing_ajax() === true || defined('REST_REQUEST') && REST_REQUEST) {
570 //So let's check if we are calling the ajax data for the frontend or backend
571 //If the referer is an admin url we are requesting the data for the backend
572 $adminUrl = get_admin_url();
573 return (substr((string) ($_SERVER['HTTP_REFERER'] ?? ''), 0, strlen((string) $adminUrl)) === $adminUrl);
574 }
575
576 //No ajax request just use the normal function
577 return is_admin();
578 }
579
580 /**
581 * @param int|string $action
582 * @return string
583 * @see \wp_create_nonce()
584 */
585 public function createNonce($action): string
586 {
587 return wp_create_nonce($action);
588 }
589
590 /**
591 * @param int|string $action
592 * @param string $name
593 * @param bool $referrer
594 * @param bool $echo
595 * @return string
596 * @see \wp_nonce_field()
597 */
598 public function getNonceField($action = -1, $name = '_wpnonce', $referrer = true, $echo = true): string
599 {
600 return wp_nonce_field($action, $name, $referrer, $echo);
601 }
602
603 /**
604 * @param string|null $nonce
605 * @param string|int $action
606 * @return false|int
607 * @see \wp_verify_nonce()
608 */
609 public function verifyNonce(?string $nonce, $action = -1)
610 {
611 return wp_verify_nonce($nonce, $action);
612 }
613
614 /**
615 * Returns the wordpress roles.
616 * @return WP_Roles
617 */
618 public function getRoles(): WP_Roles
619 {
620 global $wp_roles;
621 return $wp_roles;
622 }
623
624 /**
625 * @param string $pageTitle
626 * @param string $menuTitle
627 * @param string $capability
628 * @param string $menuSlug
629 * @param mixed $function
630 * @param string $iconUrl
631 * @param null $position
632 * @return string
633 * @see \add_menu_page()
634 */
635 public function addMenuPage(
636 string $pageTitle,
637 string $menuTitle,
638 string $capability,
639 string $menuSlug,
640 $function = '',
641 $iconUrl = '',
642 $position = null
643 ): string {
644 return add_menu_page($pageTitle, $menuTitle, $capability, $menuSlug, $function, $iconUrl, $position);
645 }
646
647 /**
648 * @param string $parentSlug
649 * @param string $pageTitle
650 * @param string $menuTitle
651 * @param string $capability
652 * @param string $menuSlug
653 * @param string|callable $function
654 * @return false|string
655 * @see \add_submenu_page()
656 */
657 public function addSubMenuPage(
658 string $parentSlug,
659 string $pageTitle,
660 string $menuTitle,
661 string $capability,
662 string $menuSlug,
663 $function = ''
664 ) {
665 return add_submenu_page($parentSlug, $pageTitle, $menuTitle, $capability, $menuSlug, $function);
666 }
667
668 /**
669 * @param string $id
670 * @param string $title
671 * @param callable $callback
672 * @param null $screen
673 * @param string $context
674 * @param string $priority
675 * @param null $callbackArguments
676 * @see \add_meta_box()
677 */
678 public function addMetaBox(
679 string $id,
680 string $title,
681 callable $callback,
682 $screen = null,
683 $context = 'advanced',
684 $priority = 'default',
685 $callbackArguments = null
686 ) {
687 add_meta_box($id, $title, $callback, $screen, $context, $priority, $callbackArguments);
688 }
689
690 /**
691 * @param array|string $arguments
692 * @return array|false
693 * @see \get_pages()
694 */
695 public function getPages($arguments)
696 {
697 return get_pages($arguments);
698 }
699
700 /**
701 * @param string $handle
702 * @param string $source
703 * @param array $depends
704 * @param string|bool|null $version
705 * @param string $media
706 * @return bool
707 * @see \wp_register_style()
708 */
709 public function registerStyle(string $handle, string $source, $depends = [], $version = false, $media = 'all'): bool
710 {
711 return wp_register_style($handle, $source, $depends, $version, $media);
712 }
713
714 /**
715 * @param string $handle
716 * @param string $source
717 * @param array $depends
718 * @param string|bool|null $version
719 * @param bool $inFooter
720 * @return bool
721 * @see \wp_register_script()
722 */
723 public function registerScript(
724 string $handle,
725 string $source,
726 $depends = [],
727 $version = false,
728 $inFooter = false
729 ): bool {
730 return wp_register_script($handle, $source, $depends, $version, $inFooter);
731 }
732
733 /**
734 * @param string $handle
735 * @param string $source
736 * @param array $depends
737 * @param string|bool|null $version
738 * @param string $media
739 * @see \wp_enqueue_style()
740 */
741 public function enqueueStyle(string $handle, $source = '', $depends = [], $version = false, $media = 'all')
742 {
743 wp_enqueue_style($handle, $source, $depends, $version, $media);
744 }
745
746 /**
747 * @param string $handle
748 * @param string $source
749 * @param array $depends
750 * @param string|bool|null $version
751 * @param bool $inFooter
752 * @see \wp_enqueue_script()
753 */
754 public function enqueueScript(string $handle, $source = '', $depends = [], $version = false, $inFooter = false)
755 {
756 wp_enqueue_script($handle, $source, $depends, $version, $inFooter);
757 }
758
759 /**
760 * Returns the wordpress meta boxes.
761 * @return array
762 */
763 public function getMetaBoxes(): array
764 {
765 global $wp_meta_boxes;
766 return $wp_meta_boxes;
767 }
768
769 /**
770 * Sets the wordpress meta boxes.
771 * @param array $wpMetaBoxes
772 */
773 public function setMetaBoxes(array $wpMetaBoxes)
774 {
775 global $wp_meta_boxes;
776 $wp_meta_boxes = $wpMetaBoxes;
777 }
778
779 /**
780 * @param array $arguments
781 * @return array
782 * @see \get_sites()
783 */
784 public function getSites(array $arguments = []): array
785 {
786 if (function_exists('\get_sites') === true && class_exists('\WP_Site_Query') === true) {
787 return get_sites($arguments);
788 }
789
790 return [];
791 }
792
793 /**
794 * @param string $tag
795 * @param mixed $value
796 * @return mixed
797 * @see \apply_filters()
798 */
799 public function applyFilters(string $tag, $value)
800 {
801 return call_user_func_array('\apply_filters', func_get_args());
802 }
803
804 /**
805 * @param string $show
806 * @param string $filter
807 * @return string
808 * @see \get_bloginfo()
809 */
810 public function getBlogInfo($show = '', $filter = 'raw'): string
811 {
812 return get_bloginfo($show, $filter);
813 }
814
815 /**
816 * @param string $text
817 * @return string
818 * @see \esc_html()
819 */
820 public function escHtml(string $text): string
821 {
822 return esc_html($text);
823 }
824
825 /**
826 * @param int|string|array $post
827 * @return bool
828 * @see \is_single()
829 */
830 public function isSingle($post = ''): bool
831 {
832 return is_single($post);
833 }
834
835 /**
836 * @param int|string|array $page
837 * @return bool
838 * @see \is_page()
839 */
840 public function isPage($page = ''): bool
841 {
842 return is_page($page);
843 }
844
845 /**
846 * @return string
847 * @see \WP_PLUGIN_DIR
848 */
849 public function getPluginDir(): string
850 {
851 return WP_PLUGIN_DIR;
852 }
853
854 /**
855 * @param string $path
856 * @param string $plugin
857 * @return string
858 * @see \plugins_url()
859 */
860 public function pluginsUrl($path = '', $plugin = ''): string
861 {
862 return plugins_url($path, $plugin);
863 }
864
865 /**
866 * @param $file
867 * @return string
868 * @see \plugin_basename()
869 */
870 public function pluginBasename($file): string
871 {
872 return plugin_basename($file);
873 }
874
875 /**
876 * @param int|WP_Post $post
877 * @return bool
878 * @see \wp_attachment_is_image()
879 */
880 public function attachmentIsImage($post): bool
881 {
882 return wp_attachment_is_image($post);
883 }
884
885 /**
886 * @param string $capability
887 * @return bool
888 * @see \current_user_can()
889 */
890 public function currentUserCan(string $capability): bool
891 {
892 return current_user_can($capability);
893 }
894
895 /**
896 * @param array $arguments
897 * @return array
898 * @see \get_users()
899 */
900 public function getUsers(array $arguments = []): array
901 {
902 return get_users($arguments);
903 }
904
905 /**
906 * @return WP_Hook[]
907 */
908 public function getFilters(): array
909 {
910 global $wp_filter;
911 return $wp_filter;
912 }
913
914 /**
915 * @param array $filters
916 */
917 public function setFilters(array $filters)
918 {
919 global $wp_filter;
920 $wp_filter = $filters;
921 }
922
923 /**
924 * @param string $type
925 * @param int $gmt
926 * @return int|string
927 * @see \current_time()
928 */
929 public function currentTime(string $type, $gmt = 0)
930 {
931 return current_time($type, $gmt);
932 }
933
934 /**
935 * Formats the date like wordpress does it.
936 * @param string $date
937 * @return string
938 */
939 public function formatDate(string $date): string
940 {
941 $dateFormat = __('M j, Y @ H:i');
942 return date_i18n($dateFormat, strtotime($date));
943 }
944
945 /**
946 * @param mixed $widgetClass
947 * @see \register_widget()
948 */
949 public function registerWidget($widgetClass)
950 {
951 register_widget($widgetClass);
952 }
953
954 /**
955 * @param string $redirect
956 * @param bool $forceReauth
957 * @return string
958 * @see \wp_login_url()
959 */
960 public function wpLoginUrl($redirect = '', $forceReauth = false): string
961 {
962 return wp_login_url($redirect, $forceReauth);
963 }
964
965 /**
966 * @param string $redirect
967 * @return string
968 * @see \wp_logout_url()
969 */
970 public function wpLogoutUrl($redirect = ''): string
971 {
972 return wp_logout_url($redirect);
973 }
974
975 /**
976 * @return string
977 * @see \wp_registration_url()
978 */
979 public function wpRegistrationUrl(): string
980 {
981 return wp_registration_url();
982 }
983
984 /**
985 * @param string $redirect
986 * @return string
987 * @see \wp_lostpassword_url()
988 */
989 public function wpLostPasswordUrl($redirect = ''): string
990 {
991 return wp_lostpassword_url($redirect);
992 }
993
994 /**
995 * @param string $tag
996 * @param callable $function
997 * @see \add_shortcode()
998 */
999 public function addShortCode(string $tag, callable $function)
1000 {
1001 add_shortcode($tag, $function);
1002 }
1003
1004 /**
1005 * @param string $content
1006 * @param bool $ignoreHtml
1007 * @return string
1008 * @see \do_shortcode()
1009 */
1010 public function doShortCode(string $content, $ignoreHtml = false): string
1011 {
1012 return do_shortcode($content, $ignoreHtml);
1013 }
1014
1015 /**
1016 * @param string $url
1017 * @return int
1018 * @see \attachment_url_to_postid()
1019 */
1020 public function attachmentUrlToPostId(string $url): int
1021 {
1022 return attachment_url_to_postid($url);
1023 }
1024
1025 /**
1026 * @return bool
1027 * @see \got_mod_rewrite()
1028 */
1029 public function gotModRewrite(): bool
1030 {
1031 if (function_exists('\got_mod_rewirte') === false) {
1032 require_once(ABSPATH . 'wp-admin/includes/misc.php');
1033 }
1034
1035 return got_mod_rewrite();
1036 }
1037
1038 /**
1039 * @return bool
1040 * @see \is_user_member_of_blog()
1041 */
1042 public function isUserMemberOfBlog(): bool
1043 {
1044 return (bool) is_user_member_of_blog();
1045 }
1046
1047 /**
1048 * @return int
1049 * @see \get_queried_object_id()
1050 */
1051 public function getQueriedObjectId(): int
1052 {
1053 return (int) get_queried_object_id();
1054 }
1055
1056 /**
1057 * @return WP_Post|array|null
1058 */
1059 public function getCurrentPost()
1060 {
1061 global $post;
1062 return $post;
1063 }
1064 }
1065