Created
August 29, 2017 19:07
-
-
Save raftaar1191/905ca4430d6a4457bb248f0b3ebc67fb to your computer and use it in GitHub Desktop.
Adding script with Shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Register Scripts | |
* | |
*/ | |
function be_register_scripts() { | |
wp_register_style( 'be-shortcode', get_stylesheet_directory_uri() . '/assets/css/shortcode.css' ); | |
wp_register_style( 'be-shortcode-color1', get_stylesheet_directory_uri() . '/assets/css/color1-shortcode.css' ); | |
wp_register_style( 'be-shortcode-color2', get_stylesheet_directory_uri() . '/assets/css/color2-shortcode.css' ); | |
wp_register_style( 'be-shortcode-color3', get_stylesheet_directory_uri() . '/assets/css/color3-shortcode.css' ); | |
wp_register_style( 'be-shortcode-color4', get_stylesheet_directory_uri() . '/assets/css/color4-shortcode.css' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'be_register_scripts' ); | |
/** | |
* My Shortcode | |
* | |
*/ | |
function be_shortcode( $atts = array() ) { | |
$color = ''; | |
if ( $atts['color'] ) { | |
$color = '-' . $atts['color']; | |
} | |
wp_enqueue_style( 'be-shortcode' . $color ); | |
return 'Hello World'; | |
} | |
add_shortcode( 'be_shortcode', 'be_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment