Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragipostolovski/ffb1ecb135805e29072125fa9f22ed6c to your computer and use it in GitHub Desktop.
Save dragipostolovski/ffb1ecb135805e29072125fa9f22ed6c to your computer and use it in GitHub Desktop.
<?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');
<?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