Example #1
0
/**
 * Check if the hook is scheduled - if not, schedule it.
 *
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 * !!! If the scheduled time is in the past, wp_schedule_event() will cause this to run immediately, and then again at the scheduled time. !!!
 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 *
 * The local time you want it to run needs to be offset by the timezone that WordPress has set.
 */
function my_af_setup_daily_schedule()
{
    /* must have this check here, b/c although a new cron event won't be added without it,
     * the wp_schedule_event() function triggers the action to run immediately, even if
     * set for a different time of day. */
    if (!wp_next_scheduled('af_reset_weather_override')) {
        $local_hour_to_run = 1;
        $gmt_hour_to_run = $local_hour_to_run - wp_timezone_override_offset();
        wp_schedule_event(strtotime($gmt_hour_to_run . 'am', strtotime('yesterday')), 'daily', 'af_reset_weather_override');
    }
}
/**
 * Return local time of day.
 *
 */
function ip_geo_block_localdate($timestamp = FALSE, $fmt = NULL)
{
    static $offset = NULL;
    static $format = NULL;
    if (NULL === $offset) {
        $offset = wp_timezone_override_offset() * HOUR_IN_SECONDS;
    }
    if (NULL === $format) {
        $format = get_option('date_format') . ' ' . get_option('time_format');
    }
    return date_i18n($fmt ? $fmt : $format, $timestamp ? (int) $timestamp + $offset : FALSE);
}
 */
if (isset($GLOBALS['wpdb'])) {
    // wordpress was included some other way, accept it as it is.
    return true;
}
if (defined('WP_INSTALLING') && WP_INSTALLING !== true) {
    // we're about to include wordpress for the first time, but wp_installing is set to an incompatible value
    throw new Exception('WordPress has not been included, but WP_INSTALLING is not true: cannot proceed');
}
define('DISABLE_WP_CRON', true);
define('WP_INSTALLING', true);
define('IS_PSUWORDPRESS', true);
define('WP_CACHE', false);
define('WP_DEBUG', false);
define('SAVEQUERIES', false);
if (!defined('WP_MEMORY_LIMIT')) {
    define('WP_MEMORY_LIMIT', ini_get('memory_limit'));
}
define('DOMAIN_CURRENT_SITE', PSU::isdev() ? 'www.dev.plymouth.edu' : 'www.plymouth.edu');
define('PATH_CURRENT_SITE', '/connect/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOGID_CURRENT_SITE', 1);
require_once 'autoload.php';
require_once '/web/connect.plymouth.edu/wp-load.php';
// ask php to set the correct time zone (by default, wp changes the tz to utc)
wp_timezone_override_offset();
// in PHP 5, WordPress core is explicitly setting the timezone to UTC. (wp-settings.php line 37)
date_default_timezone_set('America/New_York');
if (!isset($GLOBALS['wpdb'])) {
    throw new Exception('Cannot find $wpdb after including WordPress. Please include from the global scope.');
}
Example #4
0
function mbbt_first()
{
    if (function_exists('wp_timezone_supported') && wp_timezone_supported()) {
        wp_timezone_override_offset();
    }
}