Skip to content
Snippets Groups Projects
Commit 5fb2128c authored by Lauren's avatar Lauren
Browse files

In progress: full width button option fix

parent 69eee3cb
No related branches found
No related tags found
No related merge requests found
...@@ -9,33 +9,35 @@ ...@@ -9,33 +9,35 @@
*/ */
/* our main shortcode function */ /* our main shortcode function */
function lbdesign_button($atts, $content = null) { function lbdesign_button_shortcode($atts, $content = null) {
$atts = shortcode_atts(array( $atts = shortcode_atts(array(
'link' => null, 'link' => null,
'type' => 'default', 'type' => 'default',
'color' => 'default', 'color' => 'default',
'size' => 'default', 'size' => 'default',
'style' => 'default', 'style' => 'default',
'full_width' => 'off',
'custom_class' => null, 'custom_class' => null,
), $atts, 'lbdesign_button'); ), $atts, 'lbdesign_button');
// check if we want the button to be full width. if yes, set up lbdesign_full_width class. if not, leave empty // check if we want the button to be full width. if yes, set up lbdesign_full_width class. if not, leave empty
if ($atts['full_width'] == "true" ) { if( $atts['full_width'] == 'on' ) $full_width = 1;
$full_width = 'lbdesign_full_width'; if( $atts['full_width'] == 'off' ) $full_width = 0;
} else {
$full_width = '';
}
foreach ($atts as $key => $att) { foreach ($atts as $key => $att) {
if( $key !== 'link' && $att !== null && $att !== '' && $att !== 'default' ) { if( $key !== 'link' && $att !== null && $att !== '' && $att !== 'default' ) {
$classes[] = 'lbdesign_'.$att; $classes[] = 'lbdesign_'.$att;
if( $key == 'full_width') {
$classes[] = 'lbdesign_full_width';
}
} }
} }
return '<a class="lbdesign_button '.implode($classes, " ").' '.$full_width.'" href="'.$atts['link'].'">'.do_shortcode($content).'</a>'; return '<a class="lbdesign_button '.implode($classes, " ").'" href="'.$atts['link'].'">'.$content.'</a>';
} }
add_shortcode('button', 'lbdesign_button'); add_shortcode('lbdesign_button', 'lbdesign_button_shortcode');
/* enqueue the default button styles */ /* enqueue the default button styles */
...@@ -52,7 +54,7 @@ add_action( 'wp_enqueue_scripts', 'lbdesign_button_styles' ); ...@@ -52,7 +54,7 @@ add_action( 'wp_enqueue_scripts', 'lbdesign_button_styles' );
add_action( 'init', 'lbdesign_tinymce_buttons' ); add_action( 'init', 'lbdesign_tinymce_buttons' );
function lbdesign_tinymce_buttons() { function lbdesign_tinymce_buttons() {
add_filter( "mce_external_plugins", "lbdesign_add_buttons" ); // hooks plugin to TinyMCE add_filter( 'mce_external_plugins', 'lbdesign_add_buttons' ); // hooks plugin to TinyMCE
add_filter( 'mce_buttons', 'lbdesign_register_buttons' ); // used to show which buttons to show on TinyMCE add_filter( 'mce_buttons', 'lbdesign_register_buttons' ); // used to show which buttons to show on TinyMCE
} }
/* add custom button to wp editor */ /* add custom button to wp editor */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment