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

Version 1.1 stuff

parent 0927fcec
No related branches found
No related tags found
No related merge requests found
assets/screenshot-1.png

46.3 KiB

......@@ -56,8 +56,7 @@
],
onsubmit: function(e) {
ed.focus();
ed.selection.setContent('[button link="' + e.data.link +'" type="' + e.data.type + '" custom_class="' + e.data.custom_class + '" size="' + e.data.size + '" style="'+e.data.styles+'"]' + e.data.content + '[/button]');
console.log(e);
ed.selection.setContent('[lbdesign_button link="' + e.data.link +'" type="' + e.data.type + '" custom_class="' + e.data.custom_class + '" size="' + e.data.size + '" style="'+e.data.styles+'"]' + e.data.content + '[/lbdesign_button]');
}
});
});
......@@ -88,7 +87,7 @@
longname : 'LBDesign Button Shortcode',
author : 'Lauren Pittenger @ LBDesign',
authorurl : 'http://lbdesign.tv',
version : "1.0"
version : "1.1"
};
}
});
......
......@@ -5,64 +5,70 @@
* Author: Lauren Pittenger @ LBDesign
* Author URI: http://laurenpittenger.com
* License: GPL
* Version: 1.0
* Version: 1.1
*/
/* our main shortcode function */
function lbdesign_button_shortcode($atts, $content = null) {
$atts = shortcode_atts(array(
'link' => null,
'type' => 'default',
function lbdesign_button_shortcode( $atts, $content = null ) {
$classes[] = '';
$atts = shortcode_atts(array(
'link' => null,
'type' => 'default',
'color' => 'default',
'size' => 'default',
'size' => 'default',
'style' => 'default',
'full_width' => 'off',
'custom_class' => null,
), $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
if( $atts['full_width'] == 'on' ) $full_width = 1;
if( $atts['full_width'] == 'off' ) $full_width = 0;
), $atts, 'lbdesign_button' );
foreach ($atts as $key => $att) {
foreach ( $atts as $key => $att ) {
if( $key !== 'link' && $att !== null && $att !== '' && $att !== 'default' ) {
$classes[] = 'lbdesign_'.$att;
if( $key !== 'link' && $key !== 'custom_class' && $att !== null && $att !== '' && $att !== 'default' ) {
$classes[] = 'lbdesign_' . esc_attr( $att );
}
if( $key == 'full_width') {
$classes[] = 'lbdesign_full_width';
}
if( $key == 'custom_class' ) {
$classes[] = esc_attr( $att );
}
}
return '<a class="lbdesign_button '.implode($classes, " ").'" href="'.$atts['link'].'">'.$content.'</a>';
return '<a class="lbdesign_button ' . implode( $classes, " " ) . '" href="' . esc_url( $atts['link'] ) . '">' . do_shortcode( $content ) . '</a>';
}
add_shortcode('lbdesign_button', 'lbdesign_button_shortcode');
add_shortcode( 'lbdesign_button', 'lbdesign_button_shortcode' );
/* enqueue the default button styles */
function lbdesign_button_styles() {
/* default styles */
wp_register_style( 'lbdesign-button-shortcode', plugins_url() . '/lbdesign-button-shortcode/css/lbdesign_button_shortcode.css');
wp_register_style( 'lbdesign-button-shortcode', plugins_url() . '/lbdesign-button-shortcode/css/lbdesign_button_shortcode.css' );
wp_enqueue_style( 'lbdesign-button-shortcode' );
}
add_action( 'wp_enqueue_scripts', 'lbdesign_button_styles' );
add_action( 'init', 'lbdesign_tinymce_buttons' );
function lbdesign_tinymce_buttons() {
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_action( 'init', 'lbdesign_tinymce_buttons' );
/* add custom button to wp editor */
function lbdesign_add_buttons( $plugin_array ) {
$plugin_array['lbdesign'] = plugins_url('/js/lbdesign-button-shortcode.js',__FILE__); // LBDesignButtonShortcode is the plugin ID
$plugin_array['lbdesign'] = plugins_url( '/js/lbdesign-button-shortcode.js', __FILE__ ); // LBDesignButtonShortcode is the plugin ID
return $plugin_array;
}
function lbdesign_register_buttons( $buttons ) {
array_push( $buttons, 'buttonshortcode' ); // buttonshortcode is the button ID
array_push( $buttons, '|', 'buttonshortcode' ); // buttonshortcode is the button ID
return $buttons;
}
......@@ -3,7 +3,7 @@ Contributors: lepittenger
Tags: shortcode
Requires at least: 3.0.1
Tested up to: 4.4.1
Stable tag: 4.3
Stable tag: 1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
......@@ -37,14 +37,30 @@ Four styles:
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Add buttons to post and page content using the insert button on the WordPress editor
== Frequently Asked Questions ==
None yet.
== Screenshots ==
1. These are the styles it comes with.
== Changelog ==
= 1.1 =
* Fixed undefined variable error when not using a full width button
* Changed button shortcode name to prevent conflicts with other shortcodes
= 1.0 =
* Initial launch of the plugin
* Adds button shortcode
* Add "Insert Button" button on post/page editor
== Upgrade Notice ==
= 1.1 =
* Button shortcode syntax changes from [button] to [lbdesign_button] to prevent conflicts.
= 1.0 =
* Initial launch of the plugin. No updates available yet.
......@@ -89,7 +89,6 @@ $highlight: #FFB624;
text-align: center;
}
.lbdesign_full_width {
display: block;
width: 100%;
width: max-content;
text-align: center;
}
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