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