1. Home
  2. Docs
  3. Application Framework
  4. Annotations Reference
  5. Stylesheet

Stylesheet

@MWP\WordPress\Stylesheet( deps={}, ver=false, footer=false, always=false )

Using this annotation will register a stylesheet from your plugin to be used on WordPress pages. The stylesheet will be registered with the core WordPress function wp_enqueue_style(). The value of the annotated property should be the relative path from your plugin basedir to the stylesheet resource.

@Params

deps={} (optional) / {default: {}} – Names of any dependencies that this stylesheet has
ver=false (optional) / {default: false} – Stylesheet version number, or false to generate automatically
media={"all"} (optional) / {default: {“all”}} – Which media types this stylesheet should apply to
always=false (optional) / {default: false} – If true, Stylesheet will automatically be included on every page

@Example Code

/**
 * Primary styles for the plugin
 *
 * @MWP\WordPress\Stylesheet
 *
 * @var string
 */
public $mainStyles = "assets/css/styles.css";

/**
 * Enqueue the stylesheet for the plugin
 *
 * @MWP\WordPress\Action( for="wp_enqueue_scripts" )
 * 
 * @return    void
 */
public function enqueueStyles()
{
    if ( is_page( $this->getSetting( 'plugin_page' ) ) || is_singular( 'custompost' ) )
    {
        $this->useStyle( $this->mainStyles );
    }    
}
Was this article helpful to you? Yes No

How can we help?