?AlkantarClanX12
| Current Path : /home/r/a/n/rankinh/leblogauto/wp-content/plugins/rubik-shortcode/ |
| Current File : /home/r/a/n/rankinh/leblogauto/wp-content/plugins/rubik-shortcode/rubik-shortcode.php |
<?php
/*
Plugin Name: Rubik Shortcode
Plugin URI: http://bk-ninja.com
Description:
Author: BKNinja
Version: 1.2
Author URI: http://bk-ninja.com
*/
?>
<?php
define( 'BKSC_URL', plugin_dir_url( __FILE__ ) );
define( 'BKSC_CSS_URL', trailingslashit( BKSC_URL . 'css' ) );
define( 'BKSC_JS_URL', trailingslashit( BKSC_URL . 'js' ) );
add_action('admin_head', 'bk_insert_shortcode_button');
function bk_insert_shortcode_button() {
global $typenow;
// sprawdzamy czy user ma uprawnienia do edycji post�w/podstron
if ( !current_user_can('edit_posts') && !current_user_can('edit_pages') ) {
return;
}
// weryfikujemy typ wpisu
if( ! in_array( $typenow, array( 'post', 'page' ) ) )
return;
// sprawdzamy czy user ma wlaczony edytor WYSIWYG
if ( get_user_option('rich_editing') == 'true') {
add_filter('mce_external_plugins', 'bk_add_tinymce_script');
add_filter('mce_buttons', 'bk_register_shortcode_button');
}
}
function bk_add_tinymce_script($plugin_array) {
$plugin_array['bk_shortcode_button'] = BKSC_JS_URL.'panel.js';
return $plugin_array;
}
function bk_register_shortcode_button($buttons) {
array_push($buttons, "bk_shortcode_button");
return $buttons;
}
if ( ! function_exists( 'bksc_scripts_method' ) ) {
function bksc_scripts_method() {
wp_enqueue_style( 'bkswcss', BKSC_CSS_URL . 'shortcode.css', array(), '' );
wp_enqueue_script( 'bkswjs', BKSC_JS_URL . 'shortcode.js', array( 'jquery' ), false, true );
}
}
add_action('wp_enqueue_scripts', 'bksc_scripts_method');
/**
* Youtube ShortCode
*/
function register_youtube_embed_shortcode($atts, $content = null) {
$yt_id = rubik_core::parse_youtube(do_shortcode($content));
return '
<div class="video-wrap-sc bk-shortcode hide">
<iframe width="1050" height="591" src="http://www.youtube.com/embed/'.$yt_id.'" allowFullScreen ></iframe>
</div>
';
}
add_shortcode('youtube_embed', 'register_youtube_embed_shortcode');
/**
* Vimeo ShortCode
*/
function register_vimeo_embed_shortcode($atts, $content = null) {
$vimeo_id = rubik_core::parse_vimeo(do_shortcode($content));
return '
<div class="video-wrap-sc bk-shortcode hide">
<iframe src="http://player.vimeo.com/video/'.$vimeo_id.'?api=1&title=0&byline=0&portrait=0&color=ffffff"></iframe>
</div>
';
}
add_shortcode('vimeo_embed', 'register_vimeo_embed_shortcode');
/**
* GA ShortCode
*/
function register_googleads_shortcode($atts, $content = null) {
$atts = shortcode_atts (
array (
'float' => '',
), $atts );
if ($atts["float"] != 'right') {
$float_str = 'bk-float-left';
}else {
$float_str = 'bk-float-right';
}
return '
<div class="bkadsense bk-shortcode '.$float_str.'">
<div class="bkadsense-content">
'.do_shortcode($content).'
</div>
</div>
';
}
add_shortcode('bkga', 'register_googleads_shortcode');
/**
* Haft col ShortCode
*/
function register_onehalfs_shortcode($atts, $content = null) {
$ret = '';
$ret = '<div class="bk_onehalfs bk-shortcode clearfix">';
if (!preg_match_all("/(.?)\[(one_half)\b(.*?)(?:(\/))?\](?:(.+?)\[\/one_half\])?(.?)/s", $content, $matches)) {
// if content has no accordion
return do_shortcode($content);
}else {
for($i = 0; $i < count($matches[0]); $i++) {
$ret .= '<div class="column one_half halfsc">
'.do_shortcode(trim($matches[5][$i])).'
</div>';
}
}
$ret .= '</div>';
return $ret;
}
add_shortcode('one_halfs', 'register_onehalfs_shortcode');
/**
* 1/3 col ShortCode
*/
function register_onethirds_shortcode($atts, $content = null) {
$ret = '';
$ret = '<div class="bk_onethirds bk-shortcode clearfix">';
if (!preg_match_all("/(.?)\[(one_third)\b(.*?)(?:(\/))?\](?:(.+?)\[\/one_third\])?(.?)/s", $content, $matches)) {
// if content has no accordion
return do_shortcode($content);
}else {
for($i = 0; $i < count($matches[0]); $i++) {
$ret .= '<div class="column one_third thirdsc">
'.do_shortcode(trim($matches[5][$i])).'
</div>';
}
}
$ret .= '</div>';
return $ret;
}
add_shortcode('one_thirds', 'register_onethirds_shortcode');
/**
* 1/3 2/3 col ShortCode
*/
function register_twothird_onethird_shortcode($atts, $content = null) {
$ret = '';
$ret = '<div class="bk_twothird_onethird bk-shortcode clearfix">';
if (!preg_match_all("/(.?)\[(two_third)\b(.*?)(?:(\/))?\](?:(.+?)\[\/two_third\])?(.?)/s", $content, $twothird)) {
// if content has no accordion
return do_shortcode($content);
}else {
$ret .= '<div class="column two_third thirdsc">
'.do_shortcode(trim($twothird[5][0])).'
</div>';
}
if (!preg_match_all("/(.?)\[(one_third)\b(.*?)(?:(\/))?\](?:(.+?)\[\/one_third\])?(.?)/s", $content, $onethird)) {
// if content has no accordion
return do_shortcode($content);
}else {
$ret .= '<div class="column one_third thirdsc">
'.do_shortcode(trim($onethird[5][0])).'
</div>';
}
$ret .= '</div>';
return $ret;
}
add_shortcode('twothird_onethird', 'register_twothird_onethird_shortcode');
/**
* Infor Box ShortCode
*/
function register_infobox_shortcode($atts, $content = null) {
$atts = shortcode_atts (
array (
'title' => '',
'backgroundcolor' => '',
'textcolor' => '',
'infobox_align' => '',
), $atts );
return '
<div class="bkinfobox bk-shortcode '.$atts["infobox_align"].'" style="background-color: '.$atts["backgroundcolor"].'; color: '.$atts["textcolor"].';">
<h3 class="inforbox-title">'.$atts["title"].'</h3>
<div class="infobox-content">
'.do_shortcode($content).'
</div>
</div>
';
}
add_shortcode('bkinfobox', 'register_infobox_shortcode');
/**
* Accordion ShortCode
*/
function register_accordions_shortcode($atts, $content = null) {
$accordion_id = uniqid();
$ret = '';
if (!preg_match_all("/(.?)\[(accordion)\b(.*?)(?:(\/))?\](?:(.+?)\[\/accordion\])?(.?)/s", $content, $matches)) {
// if content has no accordion
return do_shortcode($content);
} else {
// content has accordions, get title and content
for($i = 0; $i < count($matches[0]); $i++) {
$matches[3][$i] = shortcode_parse_atts($matches[3][$i]);
}
// output follow jquery ui accordions
$ret = '<div class="bk_accordions bk-shortcode" id="accordions-'.$accordion_id.'">';
$accordion_id++;
for($i = 0; $i < count($matches[0]); $i++) {
$bk_tab_title = implode(' ',$matches[3][$i]);
$ret .= '<h3 class="accordion-trigger">' . $bk_tab_title . '</h3><div class="accordion-content">' . do_shortcode(trim($matches[5][$i])) . '</div>';
}
$ret .= '</div>';
}
return $ret;
}
add_shortcode('accordions', 'register_accordions_shortcode');
/**
* Tabs ShortCode
*/
function register_tabs_shortcode($atts, $content) {
$atts = shortcode_atts (
array (
'background' => '#000',
'textcolor' => '#fff',
'fontweight' => '',
), $atts
);
if ($atts['background'] !== '') {
$background = $atts['background'];
}else {
$background = '#fff';
}
if ($atts['textcolor'] !== '') {
$textcolor = $atts['textcolor'];
}else {
$textcolor = '#222';
}
if ($atts['fontweight'] !== '') {
$fontweight = $atts['fontweight'];
}else {
$fontweight = '';
}
$tab_id = uniqid();
$ret = '';
if (!preg_match_all("/(.?)\[(tab)\b(.*?)(?:(\/))?\](?:(.+?)\[\/tab\])?(.?)/s", $content, $matches)) {
// if content has no tab
return do_shortcode($content);
} else {
// content has tabs, get title and content
for($i = 0; $i < count($matches[0]); $i++) {
$matches[3][$i] = shortcode_parse_atts($matches[3][$i]);
}
// output follow jquery ui tabs
$ret = '<div class="bk_tabs bk-shortcode hide" id="bk-tabs-'.$tab_id.'"><ul style="background-color: '.$background.';">';
$tab_id++;
for($i = 0; $i < count($matches[0]); $i++) {
$bk_tab_title = implode(' ',$matches[3][$i]);
$ret .= '<li><a style="color: '.$textcolor.'; font-weight: '.$fontweight.';" href="#tabs-'.$i.'"><span>' . $bk_tab_title . '</span></a></li>';
}
$ret .= '</ul>';
for($i = 0; $i < count($matches[0]); $i++) {
$ret .= '<div id="tabs-'.$i.'">' . do_shortcode(trim($matches[5][$i])) . '</div>';
}
$ret .= '</div>';
}
return $ret;
}
add_shortcode('tabs', 'register_tabs_shortcode');
/**
* Parallax ShortCode
*/
function register_parallax_shortcode($atts, $content) {
$uid = uniqid();
$atts = shortcode_atts (
array (
'image_url' => '',
'url' => '',
'title' => '',
), $atts );
if ($atts['image_url'] !== ''){
$bg_image = 'background-image: url('.$atts["image_url"].')';
}
return '
<div id="'.$uid.'" class="bkparallaxsc bk-shortcode">
<div class="parallaximage" data-type="background" style="'.$bg_image.'"></div>
<div class="bkparallaxsc-details">
<div class="inner">
<div class="inner-cell">
<div class="innerwrap">
<h3>'.$atts["title"].'</h3>
<div class="sc-parallax-content">'.do_shortcode($content).'</div>
</div>
</div>
</div>
</div>
<a classs="bkparallaxsc-link" href="'.$atts["url"].'"></a>
</div>';
}
add_shortcode('bkparallax', 'register_parallax_shortcode');
/**
* Author box ShortCode
*/
function register_authorbox_shortcode($atts) {
$uid = uniqid();
$authorboxsc_html = '';
$atts = shortcode_atts (
array (
'authorid' => '',
), $atts );
if ($atts['authorid'] !== '') {
$authorID = $atts['authorid'];
}else {
$authorID = get_current_user_id();
}
$authorboxsc_html .= '<div class="bk-authorsc bk-shortcode clearfix">';
$authorboxsc_html .= rubik_core::bk_author_details($authorID);
$authorboxsc_html .= '</div><!-- end bk-authorsc -->';
return $authorboxsc_html;
}
add_shortcode('authorbox', 'register_authorbox_shortcode');
/**
* Button ShortCode
*/
function register_buttons_shortcode($atts, $content) {
$ret = '';
$ret = '<div class="bk_buttons bk-shortcode clearfix">';
if (!preg_match_all("/(.?)\[(button)\b(.*?)(?:(\/))?\](?:(.+?)\[\/button\])?(.?)/s", $content, $matches)) {
// if content has no accordion
return do_shortcode($content);
}else {
// content has buttons
for($i = 0; $i < count($matches[0]); $i++) {
$matches[3][$i] = shortcode_parse_atts($matches[3][$i]);
}
for($i = 0; $i < count($matches[0]); $i++) {
$ret .='<a class="buttonsc" style="color: '.$matches[3][$i]['textcolor'].'; background-color: '.$matches[3][$i]['backgroundcolor'].';" href="'. $matches[3][$i]['href'] .'" target="_blank ">'. $matches[3][$i]['name'] .'</a>';
}
}
$ret .= '</div>';
return $ret;
}
add_shortcode('buttons', 'register_buttons_shortcode');
/**
* Button ShortCode
*/
function register_blockquote_shortcode($atts, $content) {
$ret = '';
$atts = shortcode_atts (
array (
'style' => 'blockquote_style1',
'align' => '',
'textcolor' => '#fff',
'background' => '#4DB2EC',
'bordercolor' => '#4DB2EC',
), $atts );
if ($atts['style'] !== '') {
$blockquote_style = $atts['style'];
}else {
$blockquote_style = 'blockquote_style1';
}
if ($atts['align'] !== '') {
$blockquote_align = $atts['align'];
}else {
$blockquote_align = 'aligncenter';
}
if ($atts['background'] !== '') {
$background = $atts['background'];
}else {
$background = '#4DB2EC';
}
if ($atts['textcolor'] !== '') {
$textcolor = $atts['textcolor'];
}else {
$textcolor = '#fff';
}
if ($atts['bordercolor'] !== '') {
$bordercolor = $atts['bordercolor'];
}else {
$bordercolor = '#4DB2EC';
}
$ret = '<blockquote class="'.$blockquote_style.' '.$blockquote_align.'" style="color: '.$textcolor.'; background-color: '.$background.'; border-color: '.$bordercolor.';">';
$ret .= do_shortcode($content);
$ret .= '</blockquote>';
return $ret;
}
add_shortcode('blockquote', 'register_blockquote_shortcode');
/**
* Dropcap ShortCode
*/
function register_dropcap_shortcode($atts, $content) {
$ret = '';
$atts = shortcode_atts (
array (
'style' => 'dropcap_style1',
'background' => '#fff',
'textcolor' => '#222',
'fontweight' => '',
), $atts );
if ($atts['style'] !== '') {
$dropcapStyle = $atts['style'];
}else {
$dropcapStyle = 'dropcap_style1';
}
if ($atts['background'] !== '') {
$dropcapBG = $atts['background'];
}else {
$dropcapBG = '#fff';
}
if ($atts['textcolor'] !== '') {
$textcolor = $atts['textcolor'];
}else {
$textcolor = '#222';
}
if ($atts['fontweight'] !== '') {
$fontweight = $atts['fontweight'];
}else {
$fontweight = '';
}
$ret = '<span class="dropcap '.$dropcapStyle.'" style="color: '.$textcolor.'; background-color: '.$dropcapBG.'; font-weight: '.$fontweight.';">';
$ret .= do_shortcode($content);
$ret .= '</span>';
return $ret;
}
add_shortcode('dropcap', 'register_dropcap_shortcode');
/**
* Inline Posts ShortCode
*/
function register_inline_posts_shortcode($atts, $content) {
$render_modules = '';
$atts = shortcode_atts (
array (
'type' => 'IDs',
'box_title' => '',
'align' => '',
'background' => '#fff',
'textcolor' => '#222',
), $atts
);
global $post;
$bkPostId = $post->ID;
$excludeid = array();
array_push($excludeid, $bkPostId);
$bk_tags = wp_get_post_tags($bkPostId);
$tag_length = sizeof($bk_tags);
$bk_tag_check = $bk_all_cats = array();
$bk_categories = get_the_category($bkPostId);
$category_length = sizeof($bk_categories);
if ($category_length > 0){
foreach ( $bk_categories as $category_key => $bk_category ) { $bk_all_cats[$category_key] = $bk_category->term_id; }
}
foreach ( $bk_tags as $tag_key => $bk_tag ) { $bk_tag_check[$tag_key] = $bk_tag->term_id; }
if($atts['type'] == 'related') {
$args = array(
'posts_per_page' => 3,
'post__not_in' => $excludeid,
'post_status' => 'publish',
'post_type' => 'post',
'ignore_sticky_posts' => 1,
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $bk_all_cats,
'include_children' => false,
),
array(
'taxonomy' => 'post_tag',
'field' => 'term_id',
'terms' => $bk_tag_check,
)
)
);
}else if($atts['type'] == 'same_cat') {
$args = array(
'posts_per_page' => 3,
'post__not_in' => $excludeid,
'post_status' => 'publish',
'post_type' => 'post',
'ignore_sticky_posts' => 1,
'category__in' => rubik_section_parent::$rubik_ajax_c['s-cat-IDs'],
);
}else if($atts['type'] == 'same_author') {
$args = array(
'posts_per_page' => 3,
'post__not_in' => $excludeid,
'post_status' => 'publish',
'post_type' => 'post',
'ignore_sticky_posts' => 1,
'author' => $post->post_author
);
}else {
$postIDs = array();
$postIDs = explode(',',do_shortcode($content));
if($postIDs == '') {
return;
}
$args = array(
'posts_per_page' => count($postIDs),
'post_status' => 'publish',
'post_type' => 'post',
'ignore_sticky_posts' => 1,
'post__in' => $postIDs
);
}
if ($atts['box_title'] !== '') {
$box_title = $atts['box_title'];
}else {
$box_title = '';
}
if ($atts['align'] !== '') {
$inline_box_align = $atts['align'];
}else {
$inline_box_align = 'aligncenter';
}
if ($atts['background'] !== '') {
$background = $atts['background'];
}else {
$background = '#f2f2f2';
}
if ($atts['textcolor'] !== '') {
$textcolor = $atts['textcolor'];
}else {
$textcolor = '#222';
}
if (class_exists('bk_contentout3')) {
$bk_contentout3 = new bk_contentout3;
$the_query = new WP_Query( $args );
$custom_var = array (
'thumbnail' => 'rubik-90-65',
'meta' => array('date'),
);
if ( $the_query->have_posts() ) :
$render_modules .= '<div class="'.$atts['type'].' bk-inline-post-box '.$inline_box_align.'" style="color: '.$textcolor.'; background-color: '.$background.';">';
if($box_title != '') {
$render_modules .= '<div class="inline-post-box-title"><span>'.$box_title.'</span></div>';
}
$render_modules .= '<ul class="list-small-post row">';
while ( $the_query->have_posts() ): $the_query->the_post();
$render_modules .= '<li class="small-post content_out clearfix">';
$render_modules .= $bk_contentout3->render($custom_var);
$render_modules .= '</li><!-- End post -->';
endwhile;
$render_modules .= '</ul> <!-- End list-post -->';
$render_modules .= '</div>';
endif;
}
wp_reset_postdata();
return $render_modules;
}
add_shortcode('inline_posts', 'register_inline_posts_shortcode');
/**
* Youtube Playlist
*/
function register_youtube_playlist_shortcode($atts, $content = null) {
if (!class_exists('rubik_youtube')) {
return;
}
$ret = '';
$YTplaylist_URL = do_shortcode($content);
if ($YTplaylist_URL == '') {
$ret .= '<div class="bk-notice">Playlist URL is empty. Please insert the necessary data to the setting fields.</div>';
return $ret;
}
$YTplaylist = rubik_youtube::rubik_get_playlist($YTplaylist_URL);
if (!( $YTplaylist && ! empty( $YTplaylist['videos'] ) )) :
$ret .= '<div class="bk-notice">Cannot fetch URL, please check and correct it.</div>';
return $ret;
endif;
$bk_color_opt['module_bg_class'] = '';
$bk_color_opt['title_bg_class'] = '';
$bk_color_opt['title_color_class'] = '';
$ret .= '<div class="module-youtube-playlist playlist-layout3">';
$ret .= rubik_youtube::rubik_youtube_playlist_render($YTplaylist, $bk_color_opt, 'layout-3');
$ret .= '</div><!-- Close module -->';
return $ret;
}
add_shortcode('youtube_playlist', 'register_youtube_playlist_shortcode');