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