[ Index ]

PHP Cross Reference of BackPress

title

Body

[close]

/includes/ -> functions.wp-styles.php (source)

   1  <?php
   2  /**
   3   * BackPress styles procedural API.
   4   *
   5   * @package BackPress
   6   * @since r79
   7   */
   8  
   9  /**
  10   * Display styles that are in the queue or part of $handles.
  11   *
  12   * @since r79
  13   * @uses do_action() Calls 'wp_print_styles' hook.
  14   * @global object $wp_styles The WP_Styles object for printing styles.
  15   *
  16   * @param array|bool $handles Styles to be printed. An empty array prints the queue,
  17   *  an array with one string prints that style, and an array of strings prints those styles.
  18   * @return bool True on success, false on failure.
  19   */
  20  function wp_print_styles( $handles = false ) {
  21      do_action( 'wp_print_styles' );
  22      if ( '' === $handles ) // for wp_head
  23          $handles = false;
  24  
  25      global $wp_styles;
  26      if ( !is_a($wp_styles, 'WP_Styles') ) {
  27          if ( !$handles )
  28              return array(); // No need to instantiate if nothing's there.
  29          else
  30              $wp_styles = new WP_Styles();
  31      }
  32  
  33      return $wp_styles->do_items( $handles );
  34  }
  35  
  36  /**
  37   * Register CSS style file.
  38   *
  39   * @since r79
  40   * @see WP_Styles::add() For additional information.
  41   * @global object $wp_styles The WP_Styles object for printing styles.
  42   * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
  43   *
  44   * @param string $handle Name of the stylesheet.
  45   * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
  46   * @param array $deps Array of handles of any stylesheet that this stylesheet depends on.
  47   *  (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
  48   * @param string|bool $ver String specifying the stylesheet version number. Set to NULL to disable.
  49   *  Used to ensure that the correct version is sent to the client regardless of caching.
  50   * @param string $media The media for which this stylesheet has been defined.
  51   */
  52  function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
  53      global $wp_styles;
  54      if ( !is_a($wp_styles, 'WP_Styles') )
  55          $wp_styles = new WP_Styles();
  56  
  57      $wp_styles->add( $handle, $src, $deps, $ver, $media );
  58  }
  59  
  60  /**
  61   * Remove a registered CSS file.
  62   *
  63   * @since r79
  64   * @see WP_Styles::remove() For additional information.
  65   * @global object $wp_styles The WP_Styles object for printing styles.
  66   *
  67   * @param string $handle Name of the stylesheet.
  68   */
  69  function wp_deregister_style( $handle ) {
  70      global $wp_styles;
  71      if ( !is_a($wp_styles, 'WP_Styles') )
  72          $wp_styles = new WP_Styles();
  73  
  74      $wp_styles->remove( $handle );
  75  }
  76  
  77  /**
  78   * Enqueue a CSS style file.
  79   *
  80   * Registers the style if src provided (does NOT overwrite) and enqueues.
  81   *
  82   * @since r79
  83   * @see WP_Styles::add(), WP_Styles::enqueue()
  84   * @global object $wp_styles The WP_Styles object for printing styles.
  85   * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
  86   *
  87   * @param string $handle Name of the stylesheet.
  88   * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
  89   * @param array $deps Array of handles (names) of any stylesheet that this stylesheet depends on.
  90   *  (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
  91   * @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter
  92   *  is used to ensure that the correct version is sent to the client regardless of caching, and so should be included
  93   *  if a version number is available and makes sense for the stylesheet.
  94   * @param string $media The media for which this stylesheet has been defined.
  95   */
  96  function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = false ) {
  97      global $wp_styles;
  98      if ( !is_a($wp_styles, 'WP_Styles') )
  99          $wp_styles = new WP_Styles();
 100  
 101      if ( $src ) {
 102          $_handle = explode('?', $handle);
 103          $wp_styles->add( $_handle[0], $src, $deps, $ver, $media );
 104      }
 105      $wp_styles->enqueue( $handle );
 106  }
 107  
 108  /**
 109   * Check whether style has been added to WordPress Styles.
 110   *
 111   * The values for list defaults to 'queue', which is the same as wp_enqueue_style().
 112   *
 113   * @since WP unknown; BP unknown
 114   * @global object $wp_styles The WP_Styles object for printing styles.
 115   *
 116   * @param string $handle Name of the stylesheet.
 117   * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'.
 118   * @return bool True on success, false on failure.
 119   */
 120  function wp_style_is( $handle, $list = 'queue' ) {
 121      global $wp_styles;
 122      if ( !is_a($wp_styles, 'WP_Styles') )
 123          $wp_styles = new WP_Styles();
 124  
 125      $query = $wp_styles->query( $handle, $list );
 126  
 127      if ( is_object( $query ) )
 128          return true;
 129  
 130      return $query;
 131  }


Generated: Wed Dec 19 01:01:51 2018 Cross-referenced by PHPXref 0.7.1