PluginProbe
User Access Manager / 2.2.15
User Access Manager v2.2.15
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.15, at src/Wrapper/Wordpress.php

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