private $settings = array(); public 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(), // FixIn: 10.6.5.1. 'buttons' => array(), // FixIn: 10.6.5.1. ); $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() ) { // FixIn: 10.6.5.1. $this->settings['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 ) ); // 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 ) ); // FixIn: 10.11.3.3. $mune_icon_url = wpbc_get_svg_logo_for_background( '#000', '#aaa', '0.3' ); // '#aaa', '#aaa', '0.2' . if ( ! empty( $this->settings['buttons'] ) ){ $script .= ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $script; } } // // public function modal_content() { ?>
} function wpbc_get_pages_where_insert_tiny_mce_buttons() { return 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_get_pages_where_insert_tiny_mce_buttons() ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing || ( ( isset( $_REQUEST['page'] ) && ( 'wpbc-resources' === $_REQUEST['page'] ) ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing || wpbc_is_setup_wizard_page() // || wpbc_is_bookings_page() // FixIn: 10.6.6.2. || wpbc_is_builder_booking_form_page() ) { // FixIn: 10.6.5.1. 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_get_pages_where_insert_tiny_mce_buttons(), ) ); }