Introduce theme-specific stylesheets
This commit is contained in:
9
assets/css/themes/twentyfourteen.css
Normal file
9
assets/css/themes/twentyfourteen.css
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Theme-specific stylesheet.
|
||||||
|
*
|
||||||
|
* This stylesheet will automatically be loaded when a theme with the same name is active. Use the folder name of the theme as the stylesheet name. For example, twentyfourteen.css will be loaded with the Twenty Fourteen theme.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.sportspress-page .entry-content h4:first-child {
|
||||||
|
margin-top: 36px;
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
*/
|
*/
|
||||||
class SP_Frontend_Scripts {
|
class SP_Frontend_Scripts {
|
||||||
|
|
||||||
|
public $theme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
@@ -33,6 +35,21 @@ class SP_Frontend_Scripts {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add theme-specific styles to the frontend
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function add_theme_styles( $styles ) {
|
||||||
|
return array_merge( $styles, array(
|
||||||
|
'sportspress-' . $this->theme => array(
|
||||||
|
'src' => str_replace( array( 'http:', 'https:' ), '', SP()->plugin_url() ) . '/assets/css/themes/' . $this->theme . '.css',
|
||||||
|
'deps' => '',
|
||||||
|
'version' => SP_VERSION,
|
||||||
|
'media' => 'all'
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register/queue frontend scripts.
|
* Register/queue frontend scripts.
|
||||||
*
|
*
|
||||||
@@ -53,9 +70,23 @@ class SP_Frontend_Scripts {
|
|||||||
wp_localize_script( 'sp-maps', 'vars', array( 'map_type' => strtoupper( get_option( 'sportspress_map_type', 'ROADMAP' ) ) ) );
|
wp_localize_script( 'sp-maps', 'vars', array( 'map_type' => strtoupper( get_option( 'sportspress_map_type', 'ROADMAP' ) ) ) );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Localize scripts.
|
// Localize scripts
|
||||||
wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ), 'previous' => __( 'Previous', 'sportspress' ), 'next' => __( 'Next', 'sportspress' ) ) );
|
wp_localize_script( 'sportspress', 'localized_strings', array( 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ), 'previous' => __( 'Previous', 'sportspress' ), 'next' => __( 'Next', 'sportspress' ) ) );
|
||||||
|
|
||||||
|
// Theme styles
|
||||||
|
$theme = wp_get_theme();
|
||||||
|
$this->theme = $theme->stylesheet;
|
||||||
|
$dir = scandir( SP()->plugin_path() . '/assets/css/themes' );
|
||||||
|
$files = array();
|
||||||
|
if ( $dir ) {
|
||||||
|
foreach ( $dir as $key => $value ) {
|
||||||
|
if ( preg_replace('/\\.[^.\\s]{3,4}$/', '', $value ) == $this->theme ) {
|
||||||
|
add_filter( 'sportspress_enqueue_styles', array( $this, 'add_theme_styles' ) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// CSS Styles
|
// CSS Styles
|
||||||
wp_enqueue_style( 'dashicons' );
|
wp_enqueue_style( 'dashicons' );
|
||||||
$enqueue_styles = $this->get_styles();
|
$enqueue_styles = $this->get_styles();
|
||||||
|
|||||||
Reference in New Issue
Block a user