Last active
May 15, 2021 06:26
-
-
Save dragipostolovski/ffb1ecb135805e29072125fa9f22ed6c to your computer and use it in GitHub Desktop.
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 | |
/** Enqueuing the Stylesheet for two shortcode */ | |
function pe_cta_enqueue_scripts() { | |
global $post; | |
$has_shortcode = has_shortcode( $post->post_content, 'pe_cta_button_shortcode' ) || has_shortcode( $post->post_content, 'boxed' ); | |
if( is_a( $post, 'WP_Post' ) && $has_shortcode ) { | |
wp_register_style( 'pe-cta-stylesheet', plugin_dir_url( __FILE__ ) . 'css/pe-cta-style.css' ); | |
wp_enqueue_style( 'pe-cta-stylesheett' ); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'pe_cta_enqueue_scripts'); |
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 | |
/** | |
* [boxed] returns the HTML code for a content box with colored titles. | |
* @return string HTML code for boxed content | |
*/ | |
add_shortcode( 'boxed', 'pe_content_boxed' ); | |
/** | |
* Shortcode Using $content | |
* | |
* @param $atts | |
* @param null $content | |
* @param string $tag | |
* | |
* @return string | |
*/ | |
function pe_content_boxed( $atts, $content = null, $tag = '' ) { | |
$a = shortcode_atts( array( | |
'title' => 'Title', | |
'title_color' => 'white', | |
'color' => 'blue', | |
), $atts ); | |
return '<div class="pe-content-boxed" style="border:2px solid ' . esc_attr( $a['color'] ) . ';">' . '<div class="pe-boxed-title" style="background-color:' . esc_attr( $a['color'] ) . ';"><h3 style="color:' . esc_attr( $a['title_color'] ) . ';">' . esc_attr( $a['title'] ) . '</h3></div>' . '<div class="pe-boxed-content"><p>' . esc_attr( $content ) . '</p></div>' . '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment