arrays.php
2 months ago
dates.php
2 months ago
general.php
2 months ago
index.php
2 months ago
screen.php
2 months ago
strings.php
2 months ago
screen.php
52 lines
| 1 | <?php |
| 2 | /* |
| 3 | * Foo Functions - Screen |
| 4 | * A bunch of common and useful functions related to WP_screen object |
| 5 | * |
| 6 | * Author: Brad Vincent |
| 7 | * Author URI: http://fooplugins.com |
| 8 | * License: GPL2 |
| 9 | */ |
| 10 | |
| 11 | if ( !function_exists( 'foo_current_screen_id' ) ) { |
| 12 | function foo_current_screen_id() { |
| 13 | $screen = get_current_screen(); |
| 14 | if ( empty($screen) ) return false; |
| 15 | |
| 16 | return $screen->id; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | if ( !function_exists( 'foo_current_screen_base' ) ) { |
| 21 | function foo_current_screen_base() { |
| 22 | $screen = get_current_screen(); |
| 23 | if ( empty($screen) ) return false; |
| 24 | |
| 25 | return $screen->base; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | if ( !function_exists( 'foo_current_screen_post_type' ) ) { |
| 30 | function foo_current_screen_post_type() { |
| 31 | $screen = get_current_screen(); |
| 32 | if ( empty($screen) ) return false; |
| 33 | |
| 34 | return $screen->post_type; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | if ( !function_exists( 'foo_check_plugin_settings_page' ) ) { |
| 39 | function foo_check_plugin_settings_page($plugin_slug) { |
| 40 | return is_admin() && 'settings_page_' . $plugin_slug === foo_current_screen_id(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | if ( !function_exists( 'foo_current_url' ) ) { |
| 45 | // returns the current URL |
| 46 | function foo_current_url() { |
| 47 | global $wp; |
| 48 | $current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) ); |
| 49 | |
| 50 | return $current_url; |
| 51 | } |
| 52 | } |