socialsnap_get_social_follow_networks(), 'share_networks' => socialsnap_get_social_share_networks(), 'ctt_default_style' => socialsnap_settings( 'ss_ctt_preview_style' ), 'icons' => socialsnap()->icons->get_all_svg_icons(), 'is_pro' => socialsnap()->pro, ); wp_localize_script( 'socialsnap-block-editor-js', 'socialsnap_block_editor', $strings ); // Include assets for TinyMCE $this->enqueue_assets(); } /** * Allow easy shortcode insertion via a custom media button. * * @since 1.0.0 * @param string $editor * @return */ public function media_button( $editor ) { // Setup the icon $icon = ''; printf( '%s %s', esc_attr( $editor ), esc_attr__( 'Social Snap', 'socialsnap' ), $icon, // phpcs:ignore esc_html__( 'Social Snap', 'socialsnap' ) ); // Include assets for TinyMCE $this->enqueue_assets(); } /** * Enqueue assets and add modal to footer if neccessary. * * @since 1.0.0 * @param string $editor * @return */ public function enqueue_assets() { $this->fields = require SOCIALSNAP_PLUGIN_DIR . 'includes/admin/settings/config-editor.php'; if ( ! is_array( $this->fields ) || empty( $this->fields ) ) { return; } add_action( 'admin_footer', array( $this, 'media_modal' ), 99 ); if ( ! wp_style_is( 'socialsnap-editor-style', 'enqueued' ) ) { wp_enqueue_style( 'socialsnap-editor-style', SOCIALSNAP_PLUGIN_URL . 'assets/css/admin-editor.css', array(), SOCIALSNAP_VERSION, 'all' ); } if ( ! wp_script_is( 'socialsnap-settings-js', 'enqueued' ) && ! wp_script_is( 'socialsnap-editor-js', 'enqueued' ) ) { wp_enqueue_script( 'socialsnap-editor-js', SOCIALSNAP_PLUGIN_URL . 'assets/js/admin-editor.js', array( 'jquery' ), SOCIALSNAP_VERSION, true ); // Localize variables to be used in plugin JavaScript files. $localize = array( 'l10n' => array( 'upload_title' => esc_html__( 'Choose or upload a file', 'socialsnap' ), 'use_file' => esc_html__( 'Use this file', 'socialsnap' ), ), ); wp_localize_script( 'socialsnap-editor-js', 'socialsnap_editor', $localize ); } } /** * Add filters to extend TinyMCE toolbar * * @since 1.0.0 */ public function add_tinymce_filters() { add_filter( 'mce_external_plugins', array( $this, 'add_mce_button' ) ); add_filter( 'mce_buttons', array( $this, 'register_mce_button' ) ); } /** * Add filters to extend TinyMCE toolbar * * @since 1.0.0 */ public function add_mce_button( $plugin_array ) { $plugin_array['socialsnap'] = SOCIALSNAP_PLUGIN_URL . 'assets/js/admin-editor-mce.js'; return $plugin_array; } /** * Allow easy shortcode insertion via a custom media button. * * @since 1.0.0 * @param string $editor * @return */ public function register_mce_button( $buttons ) { array_push( $buttons, 'ss_shortcode_generator' ); return $buttons; } /** * Modal window for inserting the form shortcode into TinyMCE. * * @since 1.0.0 */ public function media_modal() { $this->fields = require SOCIALSNAP_PLUGIN_DIR . 'includes/admin/settings/config-editor.php'; if ( ! is_array( $this->fields ) || empty( $this->fields ) ) { return; } ?>