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