private $settings = array();
function __construct( $params ) {
$this->settings = array(
'tiny_prefix' => 'wpbc_tiny'
, 'tiny_icon_url' => WPBC_PLUGIN_URL . '/assets/img/bc_black-16x16.png'
, 'tiny_js_plugin' => WPBC_PLUGIN_URL . '/js/wpbc_tinymce_btn.js'
, 'tiny_js_function' => 'wpbc_init_tinymce_buttons' // This function NAME exist inside of this JS file: ['tiny_js_plugin']
, 'tiny_btn_row' => 1
, 'pages_where_insert' => array( 'post-new.php', 'page-new.php', 'post.php', 'page.php', 'widgets.php', 'customize.php' ) //FixIn: 8.8.2.12
, 'buttons' => array(
'booking_insert' => array(
'hint' => __('Insert booking calendar' ,'booking')
, 'title' => __('Booking calendar' ,'booking')
, 'img' => WPBC_PLUGIN_URL . '/assets/img/bc_black-16x16.png'
, 'class' => 'bookig_buttons'
, 'js_func_name_click' => 'wpbc_tiny_btn_click'
, 'bookmark' => 'booking'
, 'is_close_bookmark' => 0
)
)
);
$this->settings = wp_parse_args( $params, $this->settings );
add_action( 'init', array( $this, 'define_init_hooks' ) ); // Define init hooks
}
/** Init all hooks for showing Button in Tiny Toolbar */
public function define_init_hooks() {
if ( wpbc_can_i_load_on_this_page__shortcode_config() ) {
// Load JS file - TinyMCE plugin
add_filter( 'mce_external_plugins', array( $this, 'load_tiny_js_plugin' ) );
// Add the custom TinyMCE buttons
if ( 1 === $this->settings['tiny_btn_row'] ) {
add_filter( 'mce_buttons', array( $this, 'add_tiny_button' ) );
} else {
add_filter( 'mce_buttons_' . $this->settings['tiny_btn_row'], array( $this, 'add_tiny_button' ) );
}
// Add the old style button to the non-TinyMCE editor views //Fix: 8.4.2.10 - compatibility with Gutenberg 4.1- 4.3 ( or newer ) at edit post page.
add_action( 'edit_page_form', array( $this, 'add_html_button' ) );
add_action( 'admin_head', array( $this, 'insert_button') ); // Tiny Button
add_action( 'admin_footer', array( $this, 'modal_content' ) ); // Modal Content
// JS & CSS
wpbc_load_js__required_for_modals();
add_action( 'customize_controls_print_footer_scripts', array( $this, 'add_html_button' ) ); //FixIn: 8.8.2.12
add_action( 'customize_controls_print_footer_scripts', array( $this, 'insert_button' ) );
add_action( 'customize_controls_print_footer_scripts', array( $this, 'modal_content' ) ); // Modal Content
}
}
//
//
/**
* Load JS file - TinyMCE plugin
*
* @param array $plugins
* @return array
*/
public function load_tiny_js_plugin( $plugins ){
$plugins[ $this->settings['tiny_prefix'] . '_quicktags'] = $this->settings['tiny_js_plugin'];
return $plugins;
}
/**
* Add the custom TinyMCE buttons
*
* @param array $buttons
* @return array
*/
public function add_tiny_button( $buttons ) {
array_push( $buttons, "separator" );
foreach ( $this->settings['buttons'] as $type => $strings ) {
array_push( $buttons, $this->settings['tiny_prefix'] . '_' . $type );
}
return $buttons;
}
/** Add the old style button to the non-TinyMCE editor views */
public function add_html_button() {
$buttonshtml = '';
$datajs='';
foreach ( $this->settings['buttons'] as $type => $props ) {
$buttonshtml .= '';
$datajs.= " wpbc_tiny_btn_data['$type'] = {\n";
$datajs.= ' title: "' . esc_js( $props['title'] ) . '",' . "\n";
$datajs.= ' tag: "' . esc_js( $props['bookmark'] ) . '",' . "\n";
$datajs.= ' tag_close: "' . esc_js( $props['is_close_bookmark'] ) . '",' . "\n";
$datajs.= ' cal_count: "' . get_bk_option( 'booking_client_cal_count' ) . '"' . "\n";
$datajs.= "\n };\n";
}
?>'
. ''
. ''
. '';
$mune_icon_url = sprintf( 'data:image/svg+xml;base64,%s', base64_encode( $svg_icon_integarted ) );
if ( ! empty( $this->settings['buttons'] ) ){
$script .= '';
echo $script;
}
}
//
//
public function modal_content() {
?>
}
$wpbc_pages_where_insert_btn = array( 'post-new.php', 'page-new.php', 'post.php', 'page.php', 'widgets.php', 'customize.php' ); //FixIn: 8.8.2.11 //FixIn: 8.8.2.12
if (
( in_array( basename( $_SERVER['PHP_SELF'] ), $wpbc_pages_where_insert_btn ) )
|| (
( isset( $_REQUEST['page'] )
&& ( $_REQUEST['page'] == 'wpbc-resources' ) ) // Check if this Booking > Resources page
)
){
new WPBC_TinyMCE_Buttons(
array(
'tiny_prefix' => 'wpbc_tiny'
, 'tiny_icon_url' => WPBC_PLUGIN_URL . '/assets/img/bc_black-16x16.png'
, 'tiny_js_plugin' => WPBC_PLUGIN_URL . '/js/wpbc_tinymce_btn.js'
, 'tiny_js_function' => 'wpbc_init_tinymce_buttons' // This function NAME exist inside of this file: ['tiny_js_plugin']
, 'tiny_btn_row' => 1
, 'pages_where_insert' => $wpbc_pages_where_insert_btn
, 'buttons' => array(
'booking_insert' => array(
'hint' => __('Insert WP Booking Calendar' ,'booking')
, 'title' => __('Booking calendar' ,'booking')
, 'img' => WPBC_PLUGIN_URL . '/assets/img/bc_black-16x16.png'
, 'class' => 'bookig_buttons'
, 'js_func_name_click' => 'wpbc_tiny_btn_click'
, 'bookmark' => 'booking'
, 'is_close_bookmark' => 0
)
)
)
);
}