' . "\n";
return $html;
}
add_shortcode( 'map' , 'chimera_map' );
/**
*
* TESTIMONIAL SHORTCODE
*
* Example Usage: [testimonial thumb="http://exampleurl.com/thumb.jpg" author="John Smith" company="JS Manufacturing Ltd." url="http://authorsurl.com"]$content[/testimonial]
* ==========================================================================================================================================================================
* @since 1.0
*
*/
function chimera_testimonial( $atts , $content = null ) {
extract( shortcode_atts( array(
'thumb' => '',
'author' => '',
'company' => '',
'url' => ''
), $atts ) );
$html = '
' . "\n";
$html .= do_shortcode( $content ) . "\n";
$html .= '
' . "\n";
$html .= '
 . ')
' . "\n";
$html .= '
' . "\n";
$html .= '
' . "\n";
$html .= '
' . "\n";
$html .= '
' . "\n";
$html .= '
' . "\n";
$html .= '
' . "\n";
return $html;
}
add_shortcode( 'testimonial' , 'chimera_testimonial' );
/**
*
* SLIDER SHORTCODE
*
* Example Usage: [slider timeout="1000" effect="tileBlind"]$content[/slider]
* =========================================================================================================================================
* @since 1.0
*
*/
function chimera_slider( $atts , $content = null ) {
extract( shortcode_atts( array(
'timeout' => '5000',
'effect' => 'tileSlide'
), $atts ) );
if( ! is_numeric( $timeout ) ) {
$timeout = '5000';
}
if( ! $effect == 'tileBlind' ) {
$effect = 'tileSlide';
}
$html = '
' . "\n";
$html .= do_shortcode( $content ) . "\n";
$html .= '
' . "\n";
$html .= '
' . "\n";
return $html;
}
add_shortcode( 'slider' , 'chimera_slider' );
/**
*
* TOOLTIP SHORTCODE
*
* Example Usage: [tip text="This is some Tooltip Text!" pos="north"]$content[/tip]
* ==========================================================================================================================================================================
* @since 1.0
*
*/
function chimera_tooltip( $atts , $content = null ) {
extract( shortcode_atts( array(
'text' => '',
'pos' => ''
), $atts ) );
$position = strtolower( $pos );
$html = '
';
$html .= do_shortcode( $content );
$html .= '';
return $html;
}
add_shortcode( 'tip' , 'chimera_tooltip' );
/**
*
* Enqueue all scripts and styles for the front end
* =========================================================================================================================================
* @since 1.0
*
*/
function chimera_plugin_scripts() {
/**
* Check first to see if Unsemantic has already been enqueued
*/
if( ! wp_style_is( 'chimera-unsemantic-grid' , $list = 'enqueued' ) && ! wp_style_is( 'unsemantic-grid' , $list = 'enqueued' ) ) {
/**
* Unsemantic Grid
*
* https://github.com/nathansmith/unsemantic
*/
wp_enqueue_style( 'unsemantic-grid' , plugins_url( 'css/unsemantic-grid.css' , __FILE__ ) , array() , '1.0' , 'all' );
}
/**
* The main stylesheet
*/
wp_enqueue_style( 'chimera-shortcodes' , plugins_url( 'css/chimera-shortcodes.css' , __FILE__ ) , array() , '1.0' , 'all' );
/**
* Check first to see if Easytabs has already been enqueued
*/
if( ! wp_script_is( 'chimera-easytabs' , $list = 'enqueued' ) && ! wp_script_is( 'easytabs' , $list = 'enqueued' ) ) {
/**
* Easytabs Script
*
* http://os.alfajango.com/easytabs/
*/
wp_enqueue_script( 'easytabs' , plugins_url( 'js/jquery.easytabs.min.js' , __FILE__ ) , array( 'jquery' ) , '3.2.0' , true );
}
/**
* Cycle 2 Slider Script
*
* http://jquery.malsup.com/cycle2/
*/
wp_enqueue_script( 'cycle2-slider' , plugins_url( 'js/jquery.cycle2.min.js' , __FILE__ ) , array( 'jquery' ) , '2.1.2' , true );
wp_enqueue_script( 'cycle2-tile' , plugins_url( 'js/jquery.cycle2.tile.js' , __FILE__ ) , array( 'jquery' ) , '20140128' , true );
global $post;
if( has_shortcode( $post->post_content , 'map' ) ) :
/**
* Custom Map Scripts
*/
wp_enqueue_script( 'google-maps' , 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false' , array( 'jquery' ) , '1.0' , true );
wp_enqueue_script( 'custom-map' , plugins_url( 'js/jquery.custom-map.js' , __FILE__ ) , array( 'jquery' ) , '1.0' , true );
/**
* Fetch and sanitize some data for the Map Settings so we can run it
* through wp_localize_script();
*/
global $smof_data;
$color_regex = '/#([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?\b/';
if( is_numeric( $smof_data['chimera_map_lat'] ) ) {
$chimera_map_lat = sanitize_text_field( $smof_data['chimera_map_lat'] );
} else { $chimera_map_lat = '38.905'; }
if( is_numeric( $smof_data['chimera_map_lng'] ) ) {
$chimera_map_lng = sanitize_text_field( $smof_data['chimera_map_lng'] );
} else { $chimera_map_lng = '-77.038'; }
if( preg_match( $color_regex , $smof_data['chimera_map_hue'] ) )
{ $chimera_map_hue = $smof_data['chimera_map_hue']; }
else { $chimera_map_hue = '#000000'; }
$chimera_map_zoom_level = intval( $smof_data['chimera_map_zoom_level'] );
$chimera_map_saturation = intval( $smof_data['chimera_map_saturation'] );
$chimera_map_lightness = intval( $smof_data['chimera_map_lightness'] );
$params = array(
'chimera_lat' => $chimera_map_lat,
'chimera_lng' => $chimera_map_lng,
'chimera_hue' => $chimera_map_hue,
'chimera_zoom' => $chimera_map_zoom_level,
'chimera_sat' => $chimera_map_saturation,
'chimera_lt' => $chimera_map_lightness
);
wp_localize_script( 'custom-map' , 'chimera_map_params' , $params );
endif; // End if has_shortcode()
}
add_action( 'wp_enqueue_scripts' , 'chimera_plugin_scripts' );
if( ! function_exists( 'chimera_clean_shortcodes' ) ) :
/**
*
* Gets rid of unwanted
,
, and
tags generated by wpautop() without removing any filters.
* =========================================================================================================================================
* @since 1.0
*
*/
function chimera_clean_shortcodes( $content )
{
$array = array
(
'
[' => '[',
']
' => ']',
']
' => ']'
);
$content = strtr( $content , $array );
return $content;
}
add_filter( 'the_content' , 'chimera_clean_shortcodes' );
endif;
/**
*
* Register the button with the TinyMCE Editor.
* =========================================================================================================================================
* @since 1.0
*
*/
function chimera_add_button() {
if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) {
add_filter( 'mce_external_plugins' , 'chimera_add_plugin' );
add_filter( 'mce_buttons_3' , 'chimera_register_button' );
}
}
add_action( 'init' , 'chimera_add_button' );
function chimera_register_button( $buttons ) {
array_push( $buttons , 'chimera_shortcodes' );
return $buttons;
}
function chimera_add_plugin( $plugin_array ) {
$plugin_array['chimera_shortcodes'] = plugins_url( 'js/chimera-shortcodes.js' , __FILE__ );
return $plugin_array;
}
?>