| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: oik [bw_button] shortcodes |
| 4 |
Plugin URI: http://www.oik-plugins.com/oik |
| 5 |
Description: [oik] button shortcodes - Call to action style buttons for Artisteer themes |
| 6 |
Version: 1.4 |
| 7 |
Author: bobbingwide |
| 8 |
Author URI: http://www.bobbingwide.com/content/herb-miller |
| 9 |
|
| 10 |
Notes & Limitations: |
| 11 |
|
| 12 |
|
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) |
| 16 |
die( "Can't load this file directly" ); |
| 17 |
require_once( "bobbfunc.inc" ); |
| 18 |
|
| 19 |
class BWButton |
| 20 |
{ |
| 21 |
function __construct() { |
| 22 |
// add_action('admin_menu', array($this, 'bw_button_create_menu')); |
| 23 |
add_action('admin_init', array($this, 'bw_button_admin_init')); |
| 24 |
add_shortcode('bw_button', array($this, 'bw_button_shortcodes')); |
| 25 |
add_shortcode('bw_contact_button', array($this, 'bw_contact_button')); |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
function bw_button_admin_init() { |
| 30 |
if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { |
| 31 |
add_filter('mce_buttons', array($this, 'filter_mce_button')); |
| 32 |
add_filter('mce_external_plugins', array($this, 'filter_mce_plugin')); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
function filter_mce_button($buttons) { |
| 37 |
array_push($buttons, '|', 'bwbutton_button' ); |
| 38 |
return $buttons; |
| 39 |
} |
| 40 |
|
| 41 |
function filter_mce_plugin($plugins) { |
| 42 |
$plugins['bwbutton'] = plugin_dir_url( __FILE__ ) . 'oik_button_plugin.js'; |
| 43 |
return $plugins; |
| 44 |
} |
| 45 |
|
| 46 |
/* [bw_button link="" text="" title="" class="" ] |
| 47 |
bw_button_shortcodes calls art_button |
| 48 |
art_button includes redundant classes for Artisteer 2.x and 3 |
| 49 |
|
| 50 |
*/ |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
function bw_button_shortcodes($atts) { |
| 56 |
$link = $atts['link']; |
| 57 |
$text = $atts['text']; |
| 58 |
$title = $atts['title']; |
| 59 |
$class = $atts['class']; |
| 60 |
bw_trace( $atts, __FUNCTION__, __LINE__, __FILE__, "atts" ); |
| 61 |
art_button( $link, $text, $title, $class ); |
| 62 |
return( bw_ret()); |
| 63 |
} |
| 64 |
|
| 65 |
/* Create a Contact me button |
| 66 |
|
| 67 |
Create a contact me button which links to the contact form page. |
| 68 |
Parameters are: |
| 69 |
[bw_contact_button link='URL' text='button text' title='button tooltip text'] |
| 70 |
|
| 71 |
Defaults: |
| 72 |
Field option field used hardcoded default |
| 73 |
link bw_contact_link /contact/ |
| 74 |
text bw_contact_text Contact |
| 75 |
title bw_contact_title Contact $contact |
| 76 |
|
| 77 |
|
| 78 |
*/ |
| 79 |
function bw_contact_button( $atts ) { |
| 80 |
bw_trace( $atts, __FUNCTION__, __LINE__, __FILE__, "atts" ); |
| 81 |
$contact = bw_default_empty_att( NULL, "contact", "me" ); |
| 82 |
|
| 83 |
|
| 84 |
$link = bw_default_empty_arr( $atts, 'link', "contact-link", "/contact/" ); |
| 85 |
|
| 86 |
bw_trace( $link, __FUNCTION__, __LINE__, __FILE__, "link" ); |
| 87 |
$text = bw_default_empty_arr( $atts, 'text', "contact-text", "Contact" ); |
| 88 |
$title = bw_default_empty_arr( $atts, 'title', "contact-title", "Contact " . $contact); |
| 89 |
|
| 90 |
$class = bw_array_get( $atts, 'class', NULL ) . "contact" ; |
| 91 |
art_button( $link, $text, $title, $class ); |
| 92 |
|
| 93 |
return( bw_ret()); |
| 94 |
} |
| 95 |
|
| 96 |
} // end of class; |
| 97 |
|
| 98 |
$bwbutton = new BWbutton(); |
| 99 |
|
| 100 |
|