$wp = new WP(); /** * WordPress Widget Factory Object * @global object $wp_widget_factory * @since 2.8.0 */ $GLOBALS['wp_widget_factory'] = new WP_Widget_Factory(); /** * WordPress User Roles * @global object $wp_roles * @since 2.0.0 */ $GLOBALS['wp_roles'] = new WP_Roles(); do_action('setup_theme'); // Define the template related constants. wp_templating_constants(); // Load the default text localization domain. load_default_textdomain(); $locale = get_locale(); $locale_file = WP_LANG_DIR . "/{$locale}.php"; if (0 === validate_file($locale) && is_readable($locale_file)) { require $locale_file; } unset($locale_file); // Pull in locale data after loading text domain. require_once ABSPATH . WPINC . '/locale.php'; /** * WordPress Locale object for loading locale domain date and various strings. * @global object $wp_locale * @since 2.1.0 */
/** * Include only the WP files needed * * This brilliant piece of code (cough) is from the dsIDXpress plugin. * * @since 1.3 */ function bootstrap_wp_for_direct_access() { /** @define "$bootstrap_dir" "/srv/www/wordpress-default" */ $bootstrap_dir = dirname($_SERVER['SCRIPT_FILENAME']); /** @define "$bootstrap_dir" "/srv/www" */ $document_root = dirname(isset($_SERVER['APPL_PHYSICAL_PATH']) ? $_SERVER['APPL_PHYSICAL_PATH'] : $_SERVER['DOCUMENT_ROOT']); // Loop through folders and keep looking up the directories until you find a directory that has wp-load.php while (!file_exists($bootstrap_dir . '/wp-load.php')) { $bootstrap_dir = dirname($bootstrap_dir); // The base is no longer part of the path. We're in the weeds. // Let's fall back to default relative path to this file from wordpress // (wp-content/plugins/gravityview-datatables/includes/) if (false === strpos($bootstrap_dir, $document_root)) { $bootstrap_dir = "../../../../.."; break; } } require $bootstrap_dir . '/wp-load.php'; // Only load what we need. if (!function_exists('get_locale')) { require_once ABSPATH . WPINC . '/locale.php'; // is_rtl() require_once ABSPATH . WPINC . '/class-wp-walker.php'; // Needed for GF require_once ABSPATH . WPINC . '/plugin.php'; require_once ABSPATH . WPINC . '/load.php'; require_once ABSPATH . WPINC . '/l10n.php'; require_once ABSPATH . WPINC . '/general-template.php'; require_once ABSPATH . WPINC . '/link-template.php'; require_once ABSPATH . WPINC . '/formatting.php'; require_once ABSPATH . WPINC . '/kses.php'; require_once ABSPATH . WPINC . '/pluggable.php'; require_once ABSPATH . WPINC . '/capabilities.php'; require_once ABSPATH . WPINC . '/user.php'; require_once ABSPATH . WPINC . '/meta.php'; require_once ABSPATH . WPINC . '/session.php'; require_once ABSPATH . WPINC . '/shortcodes.php'; require_once ABSPATH . WPINC . '/theme.php'; require_once ABSPATH . WPINC . '/template.php'; require_once ABSPATH . WPINC . '/widgets.php'; require_once ABSPATH . WPINC . '/rewrite.php'; require_once ABSPATH . WPINC . '/query.php'; } // Setup WP_PLUGIN_URL, WP_PLUGIN_DIR, etc. if (function_exists('wp_plugin_directory_constants')) { wp_plugin_directory_constants(); } // USER_COOKIE, AUTH_COOKIE, etc. if (function_exists('wp_cookie_constants')) { wp_cookie_constants(); } // TEMPLATEPATH, STYLESHEETPATH, etc. if (function_exists('wp_templating_constants')) { wp_templating_constants(); } }