Example #1
0
/**
 * Add the scripts we want loaded in the header.
 */
function WPCW_addCustomScripts_FrontEnd()
{
    if (is_admin()) {
        return;
    }
    // Our plugin-specific scripts
    // Don't use CSS for frontend if setting says so.
    if (TidySettings_getSettingSingle(WPCW_DATABASE_SETTINGS_KEY, 'use_default_css') != 'hide_css') {
        wp_enqueue_style('wpcw-frontend', WPCW_plugin_getPluginPath() . 'css/wpcw_frontend.css', false, WPCW_DATABASE_VERSION);
    }
    // Countdown Timer
    wp_enqueue_script('wpcw-countdown-plugin', WPCW_plugin_getPluginPath() . 'js/countdown/jquery.plugin.min.js', array('jquery'), WPCW_DATABASE_VERSION);
    wp_enqueue_script('wpcw-countdown', WPCW_plugin_getPluginPath() . 'js/countdown/jquery.countdown.min.js', array('jquery', 'wpcw-countdown-plugin'), WPCW_DATABASE_VERSION);
    // AJAX Form Script for quizzes
    wp_enqueue_script('wpcw-jquery-form', WPCW_plugin_getPluginPath() . 'js/jquery.form.js', array('jquery'), WPCW_DATABASE_VERSION);
    // Plugin-specific JS
    wp_enqueue_script('wpcw-frontend', WPCW_plugin_getPluginPath() . 'js/wpcw_front.js', array('jquery', 'wpcw-jquery-form', 'wpcw-countdown'), WPCW_DATABASE_VERSION);
    // Variable declarations
    wp_localize_script('wpcw-frontend', 'wpcw_js_consts_fe', array('ajaxurl' => admin_url('admin-ajax.php'), 'progress_nonce' => wp_create_nonce('wpcw-progress-nonce'), 'str_uploading' => __('Uploading:', 'wp_courseware'), 'str_quiz_all_fields' => __('Please provide an answer for all of the questions on this page.', 'wp_courseware'), 'timer_units_hrs' => __('hrs', 'wp_courseware'), 'timer_units_mins' => __('mins', 'wp_courseware'), 'timer_units_secs' => __('secs', 'wp_courseware')));
}
Example #2
0
/**
 * Requests a thumbnail for the specified website, using the cache or a live
 * fetch, depending on if the image already exists in the cache.
 *  
 * @param Array $args The list of arguments required to request the thumbnail capture.
 */
function STWWT_fetch_thumbnail($args)
{
    // Check cache for thumbnail
    $cacheFilename = md5(serialize($args)) . '.jpg';
    $cachePath = STWWT_plugin_getCacheDirectory($cacheFilename);
    // Grab the cache length from the setting. Set a default of 7 days.
    $cacheDays = TidySettings_getSettingSingle(STWWT_SETTINGS_KEY, 'stwwt_embedded_cache_length') + 0;
    if ($cacheDays < 1) {
        $cacheDays = 7;
    }
    // Check cache if site was involved with an error of any kind....
    $useCachedThumb = false;
    $errorThumb = false;
    // Still got a cached error, so don't do anything other than
    // use the cached thumbnail.
    if (STWWT_debug_gotCachedError($args)) {
        $useCachedThumb = true;
        $errorThumb = true;
    } else {
        // Are we using the cache? If so, check file exists in the cache...
        if ($cacheDays > 0 && file_exists($cachePath)) {
            $cacheCutoffDate = time() - 86400 * $cacheDays;
            // File is still within cache date, so just use cached file
            if (filemtime($cachePath) > $cacheCutoffDate) {
                $useCachedThumb = true;
            }
        }
        // end of if cacheDays
    }
    if ($useCachedThumb) {
        return STWWT_plugin_getCacheURL($cacheFilename, $errorThumb);
    } else {
        // File is not in cache, or we need a live version, so return it.
        return STWWT_fetch_requestThumbnailCapture($args);
    }
}