* @link http://www.themepunch.com/
* @copyright 2015 ThemePunch
*/
if( !defined( 'ABSPATH') ) exit();
class RevSliderTinyBox {
protected static $instanceIndex = 1;
public function __construct(){
}
/**
* Add interface for custom shortcodes to tinymce
* @since: 5.1.1
*/
public static function add_tinymce_editor(){
global $typenow, $pagenow;
// check user permissions
if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) return;
$post_types = get_post_types();
if(!is_array($post_types)) $post_types = array( 'post', 'page' );
// verify the post type
if(!in_array($typenow, $post_types)) return;
if((isset($_GET['action']) && $_GET['action'] == 'edit') || (isset($_GET['vc_action']) && $_GET['vc_action'] == 'vc_inline') || $pagenow == 'post-new.php'){
// check if WYSIWYG is enabled
if(get_user_option('rich_editing') == 'true'){
add_filter('mce_external_plugins', array('RevSliderTinyBox', 'add_tinymce_shortcode_editor_plugin'));
add_filter('mce_buttons', array('RevSliderTinyBox', 'add_tinymce_shortcode_editor_button'));
}
add_action('in_admin_footer', array('RevSliderTinyBox', 'add_tiny_mce_shortcode_dialog'));
}else{
return;
}
}
/**
* Allow for VC to use this plugin
*/
public static function visual_composer_include(){
if(@is_user_logged_in()){
if(!function_exists('vc_map') || !function_exists('vc_action')) return false;
if('true' === vc_request_param('vc_editable') || 'vc_inline' === vc_action() || is_admin()){
add_action( 'init', array('RevSliderTinyBox', 'add_to_VC' ));
}
}
}
public static function add_to_VC() {
//wp_enqueue_script('revslider-admin-script', RS_PLUGIN_URL.'admin/assets/js/admin.js', array('jquery'), RevSliderGlobals::SLIDER_REVISION );
wp_enqueue_script('wpdialogs', 'jquery-ui-sortable', 'jquery-ui-dialog');
wp_enqueue_style('wp-jquery-ui-dialog');
vc_map( array(
'name' => __('Revolution Slider 5', 'revslider'),
'base' => 'rev_slider',
'icon' => 'icon-wpb-revslider',
'category' => __('Content', 'revslider'),
'show_settings_on_create' => false,
'js_view' => 'VcSliderRevolution',
'admin_enqueue_js' => RS_PLUGIN_URL.'admin/assets/js/vc.js',
'front_enqueue_js' => RS_PLUGIN_URL.'admin/assets/js/vc.js',
'params' => array(
array(
'type' => 'rev_slider_shortcode',
'heading' => __('Alias', 'revslider'),
'param_name' => 'alias',
'admin_label' => true,
'value' => ''
),
array(
'type' => 'rev_slider_shortcode',
'heading' => __('Order', 'revslider'),
'param_name' => 'order',
'admin_label' => true,
'value' => ''
)
)
) );
if(version_compare(WPB_VC_VERSION, '4.4', '>=')){ //use if 4.4 or newer
vc_add_shortcode_param('rev_slider_shortcode', array('RevSliderTinyBox', 'revslider_shortcode_settings_field'));
}else{ //use if older than 4.4
add_shortcode_param('rev_slider_shortcode', array('RevSliderTinyBox', 'revslider_shortcode_settings_field'));
}
//if ( vc_is_frontend_ajax() || vc_is_frontend_editor() ) {
// remove_filter( 'vc_revslider_shortcode', array( 'Vc_Vendor_Revslider', 'setId' ) );
//}
}
//public function setId( $output ) {
// return preg_replace( '/rev_slider_(\d+)_(\d+)/', 'rev_slider_$1_$2' . time() . '_' . self::$instanceIndex ++, $output );
//}
/**
* The Dialog for Visual Composer
* @since: 5.1.1
*/
public static function revslider_shortcode_settings_field($settings, $value) {
return '
'
.''
.'
';
}
/**
* add script tinymce shortcode script
* @since: 5.1.1
*/
public static function add_tinymce_shortcode_editor_plugin($plugin_array){
$plugin_array['revslider_sc_button'] = RS_PLUGIN_URL . 'admin/assets/js/tinymce-shortcode-script.js';
return $plugin_array;
}
/**
* Add button to tinymce
* @since: 5.1.1
*/
public static function add_tinymce_shortcode_editor_button($buttons){
array_push($buttons, "revslider_sc_button");
return $buttons;
}
/**
* Add dialog for shortcode generator
* @since: 5.1.1
*/
public static function add_tiny_mce_shortcode_dialog(){
?>
getArrSliders();
?>
-
$slider){
foreach($slider as $values){
?>
-
#