/**
 * Check whether style has been added to NXTClass Styles.
 *
 * The values for list defaults to 'queue', which is the same as nxt_enqueue_style().
 *
 * @since nxt unknown; BP unknown
 * @global object $nxt_styles The nxt_Styles object for printing styles.
 *
 * @param string $handle Name of the stylesheet.
 * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'.
 * @return bool True on success, false on failure.
 */
function nxt_style_is($handle, $list = 'queue')
{
    global $nxt_styles;
    if (!is_a($nxt_styles, 'nxt_Styles')) {
        $nxt_styles = new nxt_Styles();
    }
    $query = $nxt_styles->query($handle, $list);
    if (is_object($query)) {
        return true;
    }
    return $query;
}
/**
 * Check whether style has been added to NXTClass Styles.
 *
 * The values for list defaults to 'queue', which is the same as nxt_enqueue_style().
 *
 * @since nxt unknown; BP unknown
 * @global object $nxt_styles The nxt_Styles object for printing styles.
 *
 * @param string $handle Name of the stylesheet.
 * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'.
 * @return bool True on success, false on failure.
 */
function nxt_style_is($handle, $list = 'queue')
{
    global $nxt_styles;
    if (!is_a($nxt_styles, 'nxt_Styles')) {
        if (!did_action('init')) {
            _doing_it_wrong(__FUNCTION__, sprintf(__('Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.'), '<code>nxt_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>'), '3.3');
        }
        $nxt_styles = new nxt_Styles();
    }
    $query = $nxt_styles->query($handle, $list);
    if (is_object($query)) {
        return true;
    }
    return $query;
}
Example #3
0
/**
 * Prints the styles queue in the HTML head on admin pages.
 *
 * @since 2.8
 */
function print_admin_styles()
{
    global $nxt_styles, $concatenate_scripts, $compress_css;
    if (!is_a($nxt_styles, 'nxt_Styles')) {
        $nxt_styles = new nxt_Styles();
    }
    script_concat_settings();
    $nxt_styles->do_concat = $concatenate_scripts;
    $zip = $compress_css ? 1 : 0;
    if ($zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP) {
        $zip = 'gzip';
    }
    $nxt_styles->do_items(false);
    if (apply_filters('print_admin_styles', true)) {
        _print_styles();
    }
    $nxt_styles->reset();
    return $nxt_styles->done;
}
Example #4
0
/**
 * Enqueues or directly prints a stylesheet link to the specified CSS file.
 *
 * "Intelligently" decides to enqueue or to print the CSS file. If the
 * 'nxt_print_styles' action has *not* yet been called, the CSS file will be
 * enqueued. If the nxt_print_styles action *has* been called, the CSS link will
 * be printed. Printing may be forced by passing TRUE as the $force_echo
 * (second) parameter.
 *
 * For backward compatibility with NXTClass 2.3 calling method: If the $file
 * (first) parameter does not correspond to a registered CSS file, we assume
 * $file is a file relative to nxt-admin/ without its ".css" extension. A
 * stylesheet link to that generated URL is printed.
 *
 * @package NXTClass
 * @since 2.3.0
 * @uses $nxt_styles NXTClass Styles Object
 *
 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
 * 	 to nxt-admin/. Defaults to 'nxt-admin'.
 * @param bool $force_echo Optional.  Force the stylesheet link to be printed rather than enqueued.
 */
function nxt_admin_css($file = 'nxt-admin', $force_echo = false)
{
    global $nxt_styles;
    if (!is_a($nxt_styles, 'nxt_Styles')) {
        $nxt_styles = new nxt_Styles();
    }
    // For backward compatibility
    $handle = 0 === strpos($file, 'css/') ? substr($file, 4) : $file;
    if ($nxt_styles->query($handle)) {
        if ($force_echo || did_action('nxt_print_styles')) {
            // we already printed the style queue.  Print this one immediately
            nxt_print_styles($handle);
        } else {
            // Add to style queue
            nxt_enqueue_style($handle);
        }
        return;
    }
    echo apply_filters('nxt_admin_css', "<link rel='stylesheet' href='" . esc_url(nxt_admin_css_uri($file)) . "' type='text/css' />\n", $file);
    if (is_rtl()) {
        echo apply_filters('nxt_admin_css', "<link rel='stylesheet' href='" . esc_url(nxt_admin_css_uri("{$file}-rtl")) . "' type='text/css' />\n", "{$file}-rtl");
    }
}