PluginProbe
User Access Manager / 2.2.1
User Access Manager v2.2.1
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.1, at src/Wrapper/Wordpress.php

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