Created
September 30, 2016 18:06
-
-
Save zzap/aa5f64e8baec955fdeda026e99d62c11 to your computer and use it in GitHub Desktop.
The most used WordPress core functions in one global var for easier sitewide usage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Global variables | |
* | |
* The most used WordPress core functions | |
* in one global var for easier sitewide usage. | |
* | |
* @return array Returns array | |
*/ | |
function zzap_global_site() { | |
$site = array( | |
// domain/site related | |
'home' => esc_url( home_url( '/' ) ), | |
'name' => get_bloginfo( 'name' ), | |
'description' => get_bloginfo( 'description' ), | |
'language' => get_bloginfo( 'language' ), | |
'wpurl' => get_bloginfo( 'wpurl' ), | |
'url' => get_bloginfo( 'url' ), | |
'rss_url' => get_bloginfo( 'rss_url' ), | |
'rss2_url' => get_bloginfo( 'rss2_url' ), | |
// settings related | |
'blog' => get_option( 'page_for_posts', true ), | |
'posts_per_page' => get_option( 'posts_per_page' ), | |
'upload_dir' => wp_upload_dir(), | |
// template related | |
'theme_name' => function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_current_theme(), | |
'theme_dir' => get_template_directory_uri(), | |
'template_url' => get_bloginfo( 'template_url' ), | |
// child theme related | |
'child_dir' => get_stylesheet_directory_uri(), | |
'stylesheet_url' => get_bloginfo( 'stylesheet_url' ), | |
'stylesheet_dir' => get_bloginfo( 'stylesheet_directory' ), | |
// dashboard/administration related | |
'admin' => admin_url(), | |
'admin_email' => get_bloginfo( 'admin_email' ), | |
'admin_profile' => admin_url( 'profile.php' ), | |
// other | |
'version' => get_bloginfo( 'version' ), | |
); | |
// if child theme needs filtering | |
return apply_filters( 'zzap_global_site_filter', $site ); | |
} | |
/** | |
* Declare global | |
* @var array | |
*/ | |
$globalSite = zzap_global_site(); | |
global $globalSite; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment