get_var( 'show tables like "'.$table_name.'"' ) === $table_name ); } /** * Determines if the user is currently looking at a specific screen - * typically used in the Administrative area. * * Here are some IDs of popular screens: * nav-menus => Appearance > Menus * widgets => Appearance > Widgets * * Note: This does not work with the Customizer. Use "is_customizer" instead. * * * @param string $screen_id The ID of the screen to test * @return boolean true if on the screen with the desired ID; otherwise, false */ public static function is_admin_screen( $screen_id ) { $screen = get_current_screen(); if ( $screen != null ) { return ( $screen->id == $screen_id ); } return false; } /** * Determines if the user is currently looking at the Theme Customizer * typically found under Appearance >> Customize. * * Note: the API for "get_current_screen" appears to be undefined when * in the Customizer, so the test for a customizer is different than * calling "is_admin_screen". * * @return boolean */ public static function is_customizer() { return ( array_key_exists( 'HTTP_REFERER', $_SERVER ) && string::contains( $_SERVER['HTTP_REFERER'], 'wp-admin/customize.php' ) ); } /** * Determines if the a given plugin has been installed and activated. * @param type $plugin Something like 'my-plugin/my-plugin.php' * @return boolean */ public static function is_plugin_active( $plugin ) { $active_plugins = get_option( 'active_plugins' ); return in_array( $plugin, $active_plugins ); } /** * This is a copy of thr 3.9.1 version of WP's locate_template - * the primary difference here makes the use of: * get_xxx_directory_uri * * Instead of: * get_xxx_directory (or the XXXPATH constant) * * For the return value. This was put into place because file_exists does not work * with the 'http://' (uri example), but does work with 'c:\' (local example). It is * a subtle difference, but one that works in cases where the return value will not * necessarily be used in a 'require' call. * * @param string|array $template_names Template file(s) to search for, in order. * @return string The template filename if one is located. */ public static function locate_template_uri( $template_names ) { $located = ''; foreach ( (array) $template_names as $template_name ) { if ( !$template_name ) continue; if ( file_exists( get_stylesheet_directory().'/'.$template_name ) ) { $located = get_stylesheet_directory_uri().'/'.$template_name; break; } if ( file_exists( get_template_directory().'/'.$template_name ) ) { $located = get_template_directory_uri().'/'.$template_name; break; } } return $located; } /* PRIVATE */ /** * Only use this class as a utility.. */ private function __construct() { // Intentionally blank.. } } ?>