function js_wp_editor($settings = array())
{
    if (!class_exists('_WP_Editors')) {
        require ABSPATH . WPINC . '/class-wp-editor.php';
    }
    $set = _WP_Editors::parse_settings('apid', $settings);
    if (!current_user_can('upload_files')) {
        $set['media_buttons'] = false;
    }
    if ($set['media_buttons']) {
        wp_enqueue_script('thickbox');
        wp_enqueue_style('thickbox');
        wp_enqueue_script('media-upload');
        $post = get_post();
        if (!$post && !empty($GLOBALS['post_ID'])) {
            $post = $GLOBALS['post_ID'];
        }
        wp_enqueue_media(array('post' => $post));
    }
    _WP_Editors::editor_settings('apid', $set);
    $ap_vars = array('url' => get_home_url(), 'includes_url' => includes_url());
    wp_register_script('ap_wpeditor_init', get_template_directory_uri() . '/functions/js-wp-editor.js', array('jquery'), '1.1', true);
    wp_localize_script('ap_wpeditor_init', 'ap_vars', $ap_vars);
    wp_enqueue_script('ap_wpeditor_init');
}
        function load_mce_translation()
        {
            if (!class_exists('_WP_Editors')) {
                require ABSPATH . WPINC . '/class-wp-editor.php';
            }
            ?>
		<script>var tadvTranslation = <?php 
            echo _WP_Editors::wp_mce_translation('', true);
            ?>
;</script>
		<?php 
        }
Exemple #3
0
 protected function __loadTinyMce()
 {
     if (!class_exists('_WP_Editors', false)) {
         require_once ABSPATH . WPINC . '/class-wp-editor.php';
     }
     /*
      * _WP_Editors shouldn't be used directly, but in this case
      * it's the best way to load WordPress RTE stuff and handle
      * RTE editors in Javascript
      */
     $set = \_WP_Editors::parse_settings(null, array('tinymce' => true, 'quicktags' => false));
     \_WP_Editors::editor_settings('woodlets_tiny_mce', $set);
 }
Exemple #4
0
function op_tiny_mce($content, $editor_id, $settings = array())
{
    static $wysiwygs;
    if (!isset($wysiwygs)) {
        $wysiwygs = function_exists('wp_editor');
    }
    if ($wysiwygs) {
        if (!class_exists('_WP_Editors')) {
            require OP_FUNC . 'tinymce.php';
        }
        if (defined('OP_POST_PAGE')) {
            $settings['disable_init'] = true;
        }
        _WP_Editors::editor($content, $editor_id, $settings);
    } else {
        echo '<textarea name="' . op_get_var($settings, 'textarea_name', $editor_id) . '" id="' . $editor_id . '" cols="40">' . op_attr($content) . '</textarea>';
    }
}
function js_wp_editor($settings = array())
{
    if (!class_exists('_WP_Editors')) {
        require ABSPATH . WPINC . '/class-wp-editor.php';
    }
    $set = _WP_Editors::parse_settings('apid', $settings);
    if (!current_user_can('upload_files')) {
        $set['media_buttons'] = false;
    }
    if ($set['media_buttons']) {
        wp_enqueue_script('thickbox');
        wp_enqueue_style('thickbox');
        wp_enqueue_script('media-upload');
        $post = get_post();
        if (!$post && !empty($GLOBALS['post_ID'])) {
            $post = $GLOBALS['post_ID'];
        }
        wp_enqueue_media(array('post' => $post));
    }
    _WP_Editors::editor_settings('apid', $set);
}
 function js_wp_editor($settings = array())
 {
     if (!class_exists('_WP_Editors')) {
         require ABSPATH . WPINC . '/class-wp-editor.php';
     }
     $set = _WP_Editors::parse_settings('apid', $settings);
     // if ( !current_user_can( 'upload_files' ) )
     // $set['media_buttons'] = false;
     // if ( $set['media_buttons'] ) {
     // 	wp_enqueue_script( 'thickbox' );
     // 	wp_enqueue_style( 'thickbox' );
     // 	wp_enqueue_script('media-upload');
     // 	$post = get_post();
     // 	if ( ! $post && ! empty( $GLOBALS['post_ID'] ) )
     // 		$post = $GLOBALS['post_ID'];
     // 	wp_enqueue_media( array(
     // 		'post' => $post
     // 	) );
     // }
     _WP_Editors::editor_settings('apid', $set);
     $ap_vars = array('url' => get_home_url(), 'includes_url' => includes_url(), 'upload_files' => current_user_can('upload_files'));
     wp_localize_script('jquery', 'ap_vars', $ap_vars);
 }
 function hrm_tinymce($element)
 {
     if (!isset($element['content']) || !isset($element['editor_id'])) {
         return;
     }
     if (empty($element['editor_id'])) {
         return;
     }
     ob_start();
     $settings = isset($element['settings']) && is_array($element['settings']) ? $element['settings'] : array();
     $id = isset($element['id']) ? esc_attr($element['id']) : '';
     $desc = isset($element['desc']) ? esc_attr($element['desc']) : '';
     $wrap_class = isset($element['wrap_class']) ? $element['wrap_class'] : '';
     $wrap_tag = isset($element['wrap_tag']) ? $element['wrap_tag'] : 'div';
     $extra = isset($element['extra']) ? $element['extra'] : array();
     $required = isset($extra['data-hrm_required']) && $extra['data-hrm_required'] === true ? '*' : '';
     $label = isset($element['label']) ? esc_attr($element['label']) : '';
     echo $this->multiple_field_inside_this_wrap($element);
     printf('<%1$s class="hrm-form-field %2$s">', $wrap_tag, $wrap_class);
     printf('<%1$s class="hrm-form-field %2$s">', $wrap_tag, $wrap_class);
     printf('<label for="%1s">%2s<em>%3s</em></label>', $id, $label, $required);
     wp_editor($element['content'], $element['editor_id'], $settings);
     printf('<span class="hrm-clear"></span><span class="description">%s</span>', $desc);
     printf('</%s>', $wrap_tag);
     echo $this->multiple_field_inside_this_wrap_close($element);
     _WP_Editors::editor_js();
     return ob_get_clean();
 }
 function link_modal()
 {
     if (!class_exists('_WP_Editors')) {
         require ABSPATH . WPINC . '/class-wp-editor.php';
     }
     _WP_Editors::wp_link_dialog();
 }
 public static function editor_settings($editor_id, $set)
 {
     $first_run = false;
     if (empty(self::$first_init)) {
         if (is_admin()) {
             add_action('admin_print_footer_scripts', array(__CLASS__, 'editor_js'), 50);
             add_action('admin_footer', array(__CLASS__, 'enqueue_scripts'), 1);
         } else {
             add_action('wp_print_footer_scripts', array(__CLASS__, 'editor_js'), 50);
             add_action('wp_footer', array(__CLASS__, 'enqueue_scripts'), 1);
         }
     }
     if (self::$this_quicktags) {
         $qtInit = array('id' => $editor_id, 'buttons' => '');
         if (is_array($set['quicktags'])) {
             $qtInit = array_merge($qtInit, $set['quicktags']);
         }
         if (empty($qtInit['buttons'])) {
             $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close';
         }
         if ($set['dfw']) {
             $qtInit['buttons'] .= ',fullscreen';
         }
         $qtInit = apply_filters('quicktags_settings', $qtInit, $editor_id);
         self::$qt_settings[$editor_id] = $qtInit;
         self::$qt_buttons = array_merge(self::$qt_buttons, explode(',', $qtInit['buttons']));
     }
     if (self::$this_tinymce) {
         if (empty(self::$first_init)) {
             self::$baseurl = includes_url('js/tinymce');
             self::$mce_locale = $mce_locale = '' == get_locale() ? 'en' : strtolower(substr(get_locale(), 0, 2));
             // only ISO 639-1
             $no_captions = (bool) apply_filters('disable_captions', '');
             $plugins = array('inlinepopups', 'tabfocus', 'paste', 'media', 'fullscreen', 'wordpress', 'wpeditimage', 'wpgallery', 'wplink', 'wpdialogs');
             $first_run = true;
             $ext_plugins = '';
             if ($set['teeny']) {
                 self::$plugins = $plugins = apply_filters('teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs'), $editor_id);
             } else {
                 /*
                 The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
                 It adds the plugin's name to TinyMCE's plugins init and the call to PluginManager to load the plugin.
                 The url should be absolute and should include the js file name to be loaded. Example:
                 array( 'myplugin' => 'http://my-site.com/wp-content/plugins/myfolder/mce_plugin.js' )
                 If the plugin uses a button, it should be added with one of the "$mce_buttons" filters.
                 */
                 $mce_external_plugins = apply_filters('mce_external_plugins', array());
                 if (!empty($mce_external_plugins)) {
                     /*
                     The following filter loads external language files for TinyMCE plugins.
                     It takes an associative array 'plugin_name' => 'path', where path is the
                     include path to the file. The language file should follow the same format as
                     /tinymce/langs/wp-langs.php and should define a variable $strings that
                     holds all translated strings.
                     When this filter is not used, the function will try to load {mce_locale}.js.
                     If that is not found, en.js will be tried next.
                     */
                     $mce_external_languages = apply_filters('mce_external_languages', array());
                     $loaded_langs = array();
                     $strings = '';
                     if (!empty($mce_external_languages)) {
                         foreach ($mce_external_languages as $name => $path) {
                             if (@is_file($path) && @is_readable($path)) {
                                 include_once $path;
                                 $ext_plugins .= $strings . "\n";
                                 $loaded_langs[] = $name;
                             }
                         }
                     }
                     foreach ($mce_external_plugins as $name => $url) {
                         $url = set_url_scheme($url);
                         $plugins[] = '-' . $name;
                         $plugurl = dirname($url);
                         $strings = $str1 = $str2 = '';
                         if (!in_array($name, $loaded_langs)) {
                             $path = str_replace(content_url(), '', $plugurl);
                             $path = WP_CONTENT_DIR . $path . '/langs/';
                             if (function_exists('realpath')) {
                                 $path = trailingslashit(realpath($path));
                             }
                             if (@is_file($path . $mce_locale . '.js')) {
                                 $strings .= @file_get_contents($path . $mce_locale . '.js') . "\n";
                             }
                             if (@is_file($path . $mce_locale . '_dlg.js')) {
                                 $strings .= @file_get_contents($path . $mce_locale . '_dlg.js') . "\n";
                             }
                             if ('en' != $mce_locale && empty($strings)) {
                                 if (@is_file($path . 'en.js')) {
                                     $str1 = @file_get_contents($path . 'en.js');
                                     $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str1, 1) . "\n";
                                 }
                                 if (@is_file($path . 'en_dlg.js')) {
                                     $str2 = @file_get_contents($path . 'en_dlg.js');
                                     $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str2, 1) . "\n";
                                 }
                             }
                             if (!empty($strings)) {
                                 $ext_plugins .= "\n" . $strings . "\n";
                             }
                         }
                         $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
                         $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
                     }
                 }
                 $plugins = array_unique(apply_filters('tiny_mce_plugins', $plugins));
             }
             if ($set['dfw']) {
                 $plugins[] = 'wpfullscreen';
             }
             self::$plugins = $plugins;
             self::$ext_plugins = $ext_plugins;
             if (in_array('spellchecker', $plugins)) {
                 /*
                 translators: These languages show up in the spellchecker drop-down menu, in the order specified, and with the first
                 language listed being the default language. They must be comma-separated and take the format of name=code, where name
                 is the language name (which you may internationalize), and code is a valid ISO 639 language code. Please test the
                 spellchecker with your values.
                 */
                 $mce_spellchecker_languages = __('English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
                 /*
                 The following filter allows localization scripts to change the languages displayed in the spellchecker's drop-down menu.
                 By default it uses Google's spellchecker API, but can be configured to use PSpell/ASpell if installed on the server.
                 The + sign marks the default language. More: http://www.tinymce.com/wiki.php/Plugin:spellchecker.
                 */
                 $mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+' . $mce_spellchecker_languages);
             }
             self::$first_init = array('mode' => 'exact', 'width' => '100%', 'theme' => 'advanced', 'skin' => 'wp_theme', 'language' => self::$mce_locale, 'theme_advanced_toolbar_location' => 'top', 'theme_advanced_toolbar_align' => 'left', 'theme_advanced_statusbar_location' => 'bottom', 'theme_advanced_resizing' => true, 'theme_advanced_resize_horizontal' => false, 'dialog_type' => 'modal', 'formats' => "{\r\n\t\t\t\t\t\talignleft : [\r\n\t\t\t\t\t\t\t{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'left'}},\r\n\t\t\t\t\t\t\t{selector : 'img,table', classes : 'alignleft'}\r\n\t\t\t\t\t\t],\r\n\t\t\t\t\t\taligncenter : [\r\n\t\t\t\t\t\t\t{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'center'}},\r\n\t\t\t\t\t\t\t{selector : 'img,table', classes : 'aligncenter'}\r\n\t\t\t\t\t\t],\r\n\t\t\t\t\t\talignright : [\r\n\t\t\t\t\t\t\t{selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles : {textAlign : 'right'}},\r\n\t\t\t\t\t\t\t{selector : 'img,table', classes : 'alignright'}\r\n\t\t\t\t\t\t],\r\n\t\t\t\t\t\tstrikethrough : {inline : 'del'}\r\n\t\t\t\t\t}", 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => false, 'remove_linebreaks' => true, 'gecko_spellcheck' => true, 'fix_list_elements' => true, 'keep_styles' => false, 'entities' => '38,amp,60,lt,62,gt', 'accessibility_focus' => true, 'media_strict' => false, 'paste_remove_styles' => true, 'paste_remove_spans' => true, 'paste_strip_class_attributes' => 'all', 'paste_text_use_dialog' => true, 'webkit_fake_resize' => false, 'preview_styles' => 'font-family font-weight text-decoration text-transform', 'schema' => 'html5', 'wpeditimage_disable_captions' => $no_captions, 'wp_fullscreen_content_css' => self::$baseurl . '/plugins/wpfullscreen/css/wp-fullscreen.css', 'plugins' => implode(',', $plugins));
             if (in_array('spellchecker', $plugins)) {
                 self::$first_init['spellchecker_rpc_url'] = self::$baseurl . '/plugins/spellchecker/rpc.php';
                 self::$first_init['spellchecker_languages'] = $mce_spellchecker_languages;
             }
             // load editor_style.css if the current theme supports it
             if (!empty($GLOBALS['editor_styles']) && is_array($GLOBALS['editor_styles'])) {
                 $editor_styles = $GLOBALS['editor_styles'];
                 $mce_css = array();
                 $editor_styles = array_unique(array_filter($editor_styles));
                 $style_uri = get_stylesheet_directory_uri();
                 $style_dir = get_stylesheet_directory();
                 // Support externally referenced styles (like, say, fonts).
                 foreach ($editor_styles as $key => $file) {
                     if (preg_match('~^(https?:)?//~', $file)) {
                         $mce_css[] = esc_url_raw($file);
                         unset($editor_styles[$key]);
                     }
                 }
                 // Look in a parent theme first, that way child theme CSS overrides.
                 if (is_child_theme()) {
                     $template_uri = get_template_directory_uri();
                     $template_dir = get_template_directory();
                     foreach ($editor_styles as $key => $file) {
                         if ($file && file_exists("{$template_dir}/{$file}")) {
                             $mce_css[] = "{$template_uri}/{$file}";
                         }
                     }
                 }
                 foreach ($editor_styles as $file) {
                     if ($file && file_exists("{$style_dir}/{$file}")) {
                         $mce_css[] = "{$style_uri}/{$file}";
                     }
                 }
                 $mce_css = implode(',', $mce_css);
             } else {
                 $mce_css = '';
             }
             $mce_css = trim(apply_filters('mce_css', $mce_css), ' ,');
             if (!empty($mce_css)) {
                 self::$first_init['content_css'] = $mce_css;
             }
         }
         if ($set['teeny']) {
             $mce_buttons = apply_filters('teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id);
             $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array();
         } else {
             $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv'), $editor_id);
             $mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help'), $editor_id);
             $mce_buttons_3 = apply_filters('mce_buttons_3', array(), $editor_id);
             $mce_buttons_4 = apply_filters('mce_buttons_4', array(), $editor_id);
         }
         $body_class = $editor_id;
         if ($post = get_post()) {
             $body_class .= ' post-type-' . sanitize_html_class($post->post_type) . ' post-status-' . sanitize_html_class($post->post_status);
             if (post_type_supports($post->post_type, 'post-formats')) {
                 $post_format = get_post_format($post);
                 if ($post_format && !is_wp_error($post_format)) {
                     $body_class .= ' post-format-' . sanitize_html_class($post_format);
                 } else {
                     $body_class .= ' post-format-standard';
                 }
             }
         }
         if (!empty($set['tinymce']['body_class'])) {
             $body_class .= ' ' . $set['tinymce']['body_class'];
             unset($set['tinymce']['body_class']);
         }
         if ($set['dfw']) {
             // replace the first 'fullscreen' with 'wp_fullscreen'
             if (($key = array_search('fullscreen', $mce_buttons)) !== false) {
                 $mce_buttons[$key] = 'wp_fullscreen';
             } elseif (($key = array_search('fullscreen', $mce_buttons_2)) !== false) {
                 $mce_buttons_2[$key] = 'wp_fullscreen';
             } elseif (($key = array_search('fullscreen', $mce_buttons_3)) !== false) {
                 $mce_buttons_3[$key] = 'wp_fullscreen';
             } elseif (($key = array_search('fullscreen', $mce_buttons_4)) !== false) {
                 $mce_buttons_4[$key] = 'wp_fullscreen';
             }
         }
         $mceInit = array('elements' => $editor_id, 'wpautop' => (bool) $set['wpautop'], 'remove_linebreaks' => (bool) $set['wpautop'], 'apply_source_formatting' => (bool) (!$set['wpautop']), 'theme_advanced_buttons1' => implode($mce_buttons, ','), 'theme_advanced_buttons2' => implode($mce_buttons_2, ','), 'theme_advanced_buttons3' => implode($mce_buttons_3, ','), 'theme_advanced_buttons4' => implode($mce_buttons_4, ','), 'tabfocus_elements' => $set['tabfocus_elements'], 'body_class' => $body_class);
         // The main editor doesn't use the TinyMCE resizing cookie.
         $mceInit['theme_advanced_resizing_use_cookie'] = 'content' !== $editor_id || empty($set['editor_height']);
         if ($first_run) {
             $mceInit = array_merge(self::$first_init, $mceInit);
         }
         if (is_array($set['tinymce'])) {
             $mceInit = array_merge($mceInit, $set['tinymce']);
         }
         // For people who really REALLY know what they're doing with TinyMCE
         // You can modify $mceInit to add, remove, change elements of the config before tinyMCE.init
         // Setting "valid_elements", "invalid_elements" and "extended_valid_elements" can be done through this filter.
         // Best is to use the default cleanup by not specifying valid_elements, as TinyMCE contains full set of XHTML 1.0.
         if ($set['teeny']) {
             $mceInit = apply_filters('teeny_mce_before_init', $mceInit, $editor_id);
         } else {
             $mceInit = apply_filters('tiny_mce_before_init', $mceInit, $editor_id);
         }
         if (empty($mceInit['theme_advanced_buttons3']) && !empty($mceInit['theme_advanced_buttons4'])) {
             $mceInit['theme_advanced_buttons3'] = $mceInit['theme_advanced_buttons4'];
             $mceInit['theme_advanced_buttons4'] = '';
         }
         self::$mce_settings[$editor_id] = $mceInit;
     }
     // end if self::$this_tinymce
 }
Exemple #10
0
 public function enqueue_wp_editor_scripts()
 {
     $screen = get_current_screen();
     $allowed_screens = $this->allowed_post_types;
     if (in_array($screen->id, $allowed_screens)) {
         if (!class_exists('_WP_Editors')) {
             require ABSPATH . WPINC . '/class-wp-editor.php';
         }
         $set = _WP_Editors::parse_settings('fusionb_id', array());
         if (!current_user_can('upload_files')) {
             $set['media_buttons'] = false;
         }
         if ($set['media_buttons']) {
             wp_enqueue_script('thickbox');
             wp_enqueue_style('thickbox');
             wp_enqueue_script('media-upload');
             $post = get_post();
             if (!$post && !empty($GLOBALS['post_ID'])) {
                 $post = $GLOBALS['post_ID'];
             }
             wp_enqueue_media(array('post' => $post));
         }
         _WP_Editors::editor_settings('fusionb_id', $set);
     }
 }
 /**
  * @static
  *
  * @global string $wp_version
  * @global string $tinymce_version
  *
  * @param string $editor_id
  * @param array  $set
  */
 public static function editor_settings($editor_id, $set)
 {
     global $wp_version, $tinymce_version;
     if (empty(self::$first_init)) {
         if (is_admin()) {
             add_action('admin_print_footer_scripts', array(__CLASS__, 'editor_js'), 50);
             add_action('admin_print_footer_scripts', array(__CLASS__, 'enqueue_scripts'), 1);
         } else {
             add_action('wp_print_footer_scripts', array(__CLASS__, 'editor_js'), 50);
             add_action('wp_print_footer_scripts', array(__CLASS__, 'enqueue_scripts'), 1);
         }
     }
     if (self::$this_quicktags) {
         $qtInit = array('id' => $editor_id, 'buttons' => '');
         if (is_array($set['quicktags'])) {
             $qtInit = array_merge($qtInit, $set['quicktags']);
         }
         if (empty($qtInit['buttons'])) {
             $qtInit['buttons'] = 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close';
         }
         if ($set['_content_editor_dfw']) {
             $qtInit['buttons'] .= ',dfw';
         }
         /**
          * Filters the Quicktags settings.
          *
          * @since 3.3.0
          *
          * @param array  $qtInit    Quicktags settings.
          * @param string $editor_id The unique editor ID, e.g. 'content'.
          */
         $qtInit = apply_filters('quicktags_settings', $qtInit, $editor_id);
         self::$qt_settings[$editor_id] = $qtInit;
         self::$qt_buttons = array_merge(self::$qt_buttons, explode(',', $qtInit['buttons']));
     }
     if (self::$this_tinymce) {
         if (empty(self::$first_init)) {
             self::$baseurl = includes_url('js/tinymce');
             $mce_locale = get_locale();
             self::$mce_locale = $mce_locale = empty($mce_locale) ? 'en' : strtolower(substr($mce_locale, 0, 2));
             // ISO 639-1
             /** This filter is documented in wp-admin/includes/media.php */
             $no_captions = (bool) apply_filters('disable_captions', '');
             $ext_plugins = '';
             if ($set['teeny']) {
                 /**
                  * Filters the list of teenyMCE plugins.
                  *
                  * @since 2.7.0
                  *
                  * @param array  $plugins   An array of teenyMCE plugins.
                  * @param string $editor_id Unique editor identifier, e.g. 'content'.
                  */
                 self::$plugins = $plugins = apply_filters('teeny_mce_plugins', array('colorpicker', 'lists', 'fullscreen', 'image', 'wordpress', 'wpeditimage', 'wplink'), $editor_id);
             } else {
                 /**
                  * Filters the list of TinyMCE external plugins.
                  *
                  * The filter takes an associative array of external plugins for
                  * TinyMCE in the form 'plugin_name' => 'url'.
                  *
                  * The url should be absolute, and should include the js filename
                  * to be loaded. For example:
                  * 'myplugin' => 'http://mysite.com/wp-content/plugins/myfolder/mce_plugin.js'.
                  *
                  * If the external plugin adds a button, it should be added with
                  * one of the 'mce_buttons' filters.
                  *
                  * @since 2.5.0
                  *
                  * @param array $external_plugins An array of external TinyMCE plugins.
                  */
                 $mce_external_plugins = apply_filters('mce_external_plugins', array());
                 $plugins = array('charmap', 'colorpicker', 'hr', 'lists', 'media', 'paste', 'tabfocus', 'textcolor', 'fullscreen', 'wordpress', 'wpautoresize', 'wpeditimage', 'wpemoji', 'wpgallery', 'wplink', 'wpdialogs', 'wptextpattern', 'wpview', 'wpembed');
                 if (!self::$has_medialib) {
                     $plugins[] = 'image';
                 }
                 /**
                  * Filters the list of default TinyMCE plugins.
                  *
                  * The filter specifies which of the default plugins included
                  * in WordPress should be added to the TinyMCE instance.
                  *
                  * @since 3.3.0
                  *
                  * @param array $plugins An array of default TinyMCE plugins.
                  */
                 $plugins = array_unique(apply_filters('tiny_mce_plugins', $plugins));
                 if (($key = array_search('spellchecker', $plugins)) !== false) {
                     // Remove 'spellchecker' from the internal plugins if added with 'tiny_mce_plugins' filter to prevent errors.
                     // It can be added with 'mce_external_plugins'.
                     unset($plugins[$key]);
                 }
                 if (!empty($mce_external_plugins)) {
                     /**
                      * Filters the translations loaded for external TinyMCE 3.x plugins.
                      *
                      * The filter takes an associative array ('plugin_name' => 'path')
                      * where 'path' is the include path to the file.
                      *
                      * The language file should follow the same format as wp_mce_translation(),
                      * and should define a variable ($strings) that holds all translated strings.
                      *
                      * @since 2.5.0
                      *
                      * @param array $translations Translations for external TinyMCE plugins.
                      */
                     $mce_external_languages = apply_filters('mce_external_languages', array());
                     $loaded_langs = array();
                     $strings = '';
                     if (!empty($mce_external_languages)) {
                         foreach ($mce_external_languages as $name => $path) {
                             if (@is_file($path) && @is_readable($path)) {
                                 include_once $path;
                                 $ext_plugins .= $strings . "\n";
                                 $loaded_langs[] = $name;
                             }
                         }
                     }
                     foreach ($mce_external_plugins as $name => $url) {
                         if (in_array($name, $plugins, true)) {
                             unset($mce_external_plugins[$name]);
                             continue;
                         }
                         $url = set_url_scheme($url);
                         $mce_external_plugins[$name] = $url;
                         $plugurl = dirname($url);
                         $strings = '';
                         // Try to load langs/[locale].js and langs/[locale]_dlg.js
                         if (!in_array($name, $loaded_langs, true)) {
                             $path = str_replace(content_url(), '', $plugurl);
                             $path = WP_CONTENT_DIR . $path . '/langs/';
                             if (function_exists('realpath')) {
                                 $path = trailingslashit(realpath($path));
                             }
                             if (@is_file($path . $mce_locale . '.js')) {
                                 $strings .= @file_get_contents($path . $mce_locale . '.js') . "\n";
                             }
                             if (@is_file($path . $mce_locale . '_dlg.js')) {
                                 $strings .= @file_get_contents($path . $mce_locale . '_dlg.js') . "\n";
                             }
                             if ('en' != $mce_locale && empty($strings)) {
                                 if (@is_file($path . 'en.js')) {
                                     $str1 = @file_get_contents($path . 'en.js');
                                     $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str1, 1) . "\n";
                                 }
                                 if (@is_file($path . 'en_dlg.js')) {
                                     $str2 = @file_get_contents($path . 'en_dlg.js');
                                     $strings .= preg_replace('/([\'"])en\\./', '$1' . $mce_locale . '.', $str2, 1) . "\n";
                                 }
                             }
                             if (!empty($strings)) {
                                 $ext_plugins .= "\n" . $strings . "\n";
                             }
                         }
                         $ext_plugins .= 'tinyMCEPreInit.load_ext("' . $plugurl . '", "' . $mce_locale . '");' . "\n";
                         $ext_plugins .= 'tinymce.PluginManager.load("' . $name . '", "' . $url . '");' . "\n";
                     }
                 }
             }
             self::$plugins = $plugins;
             self::$ext_plugins = $ext_plugins;
             self::$first_init = array('theme' => 'modern', 'skin' => 'lightgray', 'language' => self::$mce_locale, 'formats' => '{' . 'alignleft: [' . '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"left"}},' . '{selector: "img,table,dl.wp-caption", classes: "alignleft"}' . '],' . 'aligncenter: [' . '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"center"}},' . '{selector: "img,table,dl.wp-caption", classes: "aligncenter"}' . '],' . 'alignright: [' . '{selector: "p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li", styles: {textAlign:"right"}},' . '{selector: "img,table,dl.wp-caption", classes: "alignright"}' . '],' . 'strikethrough: {inline: "del"}' . '}', 'relative_urls' => false, 'remove_script_host' => false, 'convert_urls' => false, 'browser_spellcheck' => true, 'fix_list_elements' => true, 'entities' => '38,amp,60,lt,62,gt', 'entity_encoding' => 'raw', 'keep_styles' => false, 'cache_suffix' => 'wp-mce-' . $tinymce_version, 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', 'end_container_on_empty_block' => true, 'wpeditimage_disable_captions' => $no_captions, 'wpeditimage_html5_captions' => current_theme_supports('html5', 'caption'), 'plugins' => implode(',', $plugins), 'wp_lang_attr' => get_bloginfo('language'));
             if (!empty($mce_external_plugins)) {
                 self::$first_init['external_plugins'] = wp_json_encode($mce_external_plugins);
             }
             $suffix = SCRIPT_DEBUG ? '' : '.min';
             $version = 'ver=' . $wp_version;
             $dashicons = includes_url("css/dashicons{$suffix}.css?{$version}");
             // WordPress default stylesheet and dashicons
             $mce_css = array($dashicons, self::$baseurl . '/skins/wordpress/wp-content.css?' . $version);
             $editor_styles = get_editor_stylesheets();
             if (!empty($editor_styles)) {
                 foreach ($editor_styles as $style) {
                     $mce_css[] = $style;
                 }
             }
             /**
              * Filters the comma-delimited list of stylesheets to load in TinyMCE.
              *
              * @since 2.1.0
              *
              * @param string $stylesheets Comma-delimited list of stylesheets.
              */
             $mce_css = trim(apply_filters('mce_css', implode(',', $mce_css)), ' ,');
             if (!empty($mce_css)) {
                 self::$first_init['content_css'] = $mce_css;
             }
         }
         if ($set['teeny']) {
             /**
              * Filters the list of teenyMCE buttons (Text tab).
              *
              * @since 2.7.0
              *
              * @param array  $buttons   An array of teenyMCE buttons.
              * @param string $editor_id Unique editor identifier, e.g. 'content'.
              */
             $mce_buttons = apply_filters('teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'alignleft', 'aligncenter', 'alignright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id);
             $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = array();
         } else {
             $mce_buttons = array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker');
             if (!wp_is_mobile()) {
                 if ($set['_content_editor_dfw']) {
                     $mce_buttons[] = 'dfw';
                 } else {
                     $mce_buttons[] = 'fullscreen';
                 }
             }
             $mce_buttons[] = 'wp_adv';
             /**
              * Filters the first-row list of TinyMCE buttons (Visual tab).
              *
              * @since 2.0.0
              *
              * @param array  $buttons   First-row list of buttons.
              * @param string $editor_id Unique editor identifier, e.g. 'content'.
              */
             $mce_buttons = apply_filters('mce_buttons', $mce_buttons, $editor_id);
             $mce_buttons_2 = array('formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo');
             if (!wp_is_mobile()) {
                 $mce_buttons_2[] = 'wp_help';
             }
             /**
              * Filters the second-row list of TinyMCE buttons (Visual tab).
              *
              * @since 2.0.0
              *
              * @param array  $buttons   Second-row list of buttons.
              * @param string $editor_id Unique editor identifier, e.g. 'content'.
              */
             $mce_buttons_2 = apply_filters('mce_buttons_2', $mce_buttons_2, $editor_id);
             /**
              * Filters the third-row list of TinyMCE buttons (Visual tab).
              *
              * @since 2.0.0
              *
              * @param array  $buttons   Third-row list of buttons.
              * @param string $editor_id Unique editor identifier, e.g. 'content'.
              */
             $mce_buttons_3 = apply_filters('mce_buttons_3', array(), $editor_id);
             /**
              * Filters the fourth-row list of TinyMCE buttons (Visual tab).
              *
              * @since 2.5.0
              *
              * @param array  $buttons   Fourth-row list of buttons.
              * @param string $editor_id Unique editor identifier, e.g. 'content'.
              */
             $mce_buttons_4 = apply_filters('mce_buttons_4', array(), $editor_id);
         }
         $body_class = $editor_id;
         if ($post = get_post()) {
             $body_class .= ' post-type-' . sanitize_html_class($post->post_type) . ' post-status-' . sanitize_html_class($post->post_status);
             if (post_type_supports($post->post_type, 'post-formats')) {
                 $post_format = get_post_format($post);
                 if ($post_format && !is_wp_error($post_format)) {
                     $body_class .= ' post-format-' . sanitize_html_class($post_format);
                 } else {
                     $body_class .= ' post-format-standard';
                 }
             }
         }
         $body_class .= ' locale-' . sanitize_html_class(strtolower(str_replace('_', '-', get_locale())));
         if (!empty($set['tinymce']['body_class'])) {
             $body_class .= ' ' . $set['tinymce']['body_class'];
             unset($set['tinymce']['body_class']);
         }
         $mceInit = array('selector' => "#{$editor_id}", 'resize' => 'vertical', 'menubar' => false, 'wpautop' => (bool) $set['wpautop'], 'indent' => !$set['wpautop'], 'toolbar1' => implode($mce_buttons, ','), 'toolbar2' => implode($mce_buttons_2, ','), 'toolbar3' => implode($mce_buttons_3, ','), 'toolbar4' => implode($mce_buttons_4, ','), 'tabfocus_elements' => $set['tabfocus_elements'], 'body_class' => $body_class);
         // Merge with the first part of the init array
         $mceInit = array_merge(self::$first_init, $mceInit);
         if (is_array($set['tinymce'])) {
             $mceInit = array_merge($mceInit, $set['tinymce']);
         }
         /*
          * For people who really REALLY know what they're doing with TinyMCE
          * You can modify $mceInit to add, remove, change elements of the config
          * before tinyMCE.init. Setting "valid_elements", "invalid_elements"
          * and "extended_valid_elements" can be done through this filter. Best
          * is to use the default cleanup by not specifying valid_elements,
          * as TinyMCE checks against the full set of HTML 5.0 elements and attributes.
          */
         if ($set['teeny']) {
             /**
              * Filters the teenyMCE config before init.
              *
              * @since 2.7.0
              *
              * @param array  $mceInit   An array with teenyMCE config.
              * @param string $editor_id Unique editor identifier, e.g. 'content'.
              */
             $mceInit = apply_filters('teeny_mce_before_init', $mceInit, $editor_id);
         } else {
             /**
              * Filters the TinyMCE config before init.
              *
              * @since 2.5.0
              *
              * @param array  $mceInit   An array with TinyMCE config.
              * @param string $editor_id Unique editor identifier, e.g. 'content'.
              */
             $mceInit = apply_filters('tiny_mce_before_init', $mceInit, $editor_id);
         }
         if (empty($mceInit['toolbar3']) && !empty($mceInit['toolbar4'])) {
             $mceInit['toolbar3'] = $mceInit['toolbar4'];
             $mceInit['toolbar4'] = '';
         }
         self::$mce_settings[$editor_id] = $mceInit;
     }
     // end if self::$this_tinymce
 }
/**
 * Loads the correct fields for the selected actions under Profile > Actions.
 *
 * @since 1.0.0
 * @param $data str. The type of action being requested.
 * @return html. The fields.
 */
function bbconnect_get_post_to_edit()
{
    if (!wp_verify_nonce($_POST['bbconnect_admin_nonce'], 'bbconnect-admin-nonce')) {
        die(__('Terribly sorry.', 'bbconnect'));
    }
    if (isset($_POST['data'])) {
        $cid = $_POST['cid'];
        $type = $_POST['type'];
        $post_val = array();
        global $post;
        // WE'RE EDITING AN EXISTING FILE
        if (false !== strpos($_POST['data'], 'edit-')) {
            $post_id = (int) substr($_POST['data'], 5);
            $post = get_post($post_id);
            $post_author = $post->post_author;
            $post_type = $post->post_type;
            $action = 'edit';
            if ($post_type == 'bb_note') {
                $note_types = wp_get_post_terms($post_id, 'bb_note_type');
                foreach ($note_types as $note_type) {
                    if ($note_type->parent == 0) {
                        $parent_term = $note_type;
                    } else {
                        $child_term = $note_type;
                    }
                }
            }
        } else {
            if ('user' == $type) {
                $bbconnect_actions = bbconnect_get_user_actions();
                $post_type = 'bb_note';
                if (empty($_POST['data'])) {
                    echo '';
                    die;
                }
            } else {
                $bbconnect_actions = bbconnect_get_post_actions();
                $post_type = false;
                $post_type = $_POST['data'];
                if (false == $post_type) {
                    echo '';
                    die;
                }
            }
            $post = get_default_post_to_edit($post_type, true);
            $post_author = $_POST['uid'];
            $action = $_POST['actung'];
        }
        // SET THE NONCE
        if ('user' == $type) {
            bbconnect_user_actions_nonce_field();
        } else {
            bbconnect_post_actions_nonce_field();
        }
        $post_fields = array(array('meta' => array('source' => 'wpr', 'meta_key' => 'post_title', 'name' => __('Title', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'text', 'req' => true, 'public' => false, 'choices' => false))), array('meta' => array('source' => 'wpr', 'meta_key' => 'post_date', 'name' => __('Date', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'date', 'req' => true, 'public' => false, 'choices' => false))));
        if ('user' == $type) {
            if (!empty($parent_term)) {
                // Editing existing note
                $post_fields[] = array('post_val' => $parent_term->slug, 'meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type_parent', 'name' => __('Type', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => true, 'public' => true, 'choices' => array($parent_term->slug => $parent_term->name))));
                $post_fields[] = array('post_val' => $child_term->slug, 'meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type', 'name' => __('', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => false, 'public' => true, 'choices' => array($child_term->slug => $child_term->name))));
            } else {
                // New note
                $parent_term = get_term_by('slug', $_POST['data'], 'bb_note_type');
                $terms = get_terms('bb_note_type', array('hide_empty' => false, 'parent' => $parent_term->term_id));
                $choices = array();
                foreach ($terms as $term) {
                    $choices[$term->slug] = $term->name;
                }
                $post_fields[] = array('meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type', 'name' => __('Type', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'select', 'req' => true, 'public' => false, 'choices' => $choices)));
                $post_fields[] = array('meta' => array('source' => 'tax', 'meta_key' => 'bb_note_type_parent', 'name' => __('', 'bbconnect'), 'help' => '', 'options' => array('field_type' => 'hidden', 'req' => false, 'public' => false, 'choices' => $parent_term->slug)));
            }
        }
        foreach ($post_fields as $field) {
            $meta_key = $field['meta']['meta_key'];
            $field['type'] = 'post';
            $field['action'] = $action;
            $field['id'] = $post->ID;
            $field['swap_name'] = $meta_key;
            if (isset($post->{$meta_key})) {
                $field['post_val'] = $post->{$meta_key};
            }
            echo '<p><ul style="display: block; float: none;">';
            bbconnect_get_field($field);
            echo '</ul></p>';
        }
        if ('bulk-edit' == $action) {
            echo '<ul><li class="meta-item"><span class="bbconnect-label">';
            echo '<a class="rui off" title="' . $cid . 'bulk-edit">Enable Text</a>';
            echo '</span><span class="bbconnect-field">';
        }
        echo '<div style="width: 90%;padding: .3em;margin: .2em 0;">&nbsp;</div>';
        //echo '<p>'. __( 'Title', 'bbconnect' ) .'<br /><input type="text" name="post_title" class="regular-text" value="'.$post->post_title.'" /></p>';
        //echo '<p>'. __( 'Date', 'bbconnect' ) .'<br /><input type="text" class="bbconnect-date" name="post_date" class="regular-text" value="'.$post->post_date.'" /></p>';
        if (preg_match('/Firefox/i', $_SERVER['HTTP_USER_AGENT'])) {
            wp_editor(stripslashes($post->post_content), $cid, array('tinymce' => false, 'textarea_name' => 'post_content', 'teeny' => true, 'quicktags' => true));
        } else {
            wp_editor(stripslashes($post->post_content), $cid, array('tinymce' => true, 'textarea_name' => 'post_content', 'teeny' => false, 'quicktags' => true));
        }
        if ('bulk-edit' == $action) {
            echo '</span></li></ul>';
        }
        // SET THE META
        if ('user' == $type) {
            bbconnect_user_actions_meta_fields(array('post_id' => $post->ID, 'fields' => bbconnect_get_user_actions_meta(), 'action' => $action, 'post_val' => $post_val));
        } else {
            bbconnect_post_actions_meta_fields(array('post_id' => $post->ID, 'fields' => bbconnect_get_post_actions_meta(), 'action' => $action, 'post_val' => $post_val));
        }
        ?>
        <input type="hidden" name="post_ID" value="<?php 
        echo $post->ID;
        ?>
" />
        <input type="hidden" name="post_status" value="publish" />
        <input type="hidden" name="post_author" value="<?php 
        echo $post_author;
        ?>
" />
        <input type="hidden" name="post_type" value="<?php 
        echo $post_type;
        ?>
" />
        <?php 
        $inline_button = apply_filters('bbconnect_inline_do_action_button', array('<input type="submit" class="bbconnect-actions-save button-primary ' . $type . '" name="save" value="' . __('Save', 'bbconnect') . '" />'), $post_type, $type, $action);
        echo '<div class="tright">';
        echo implode(' ', $inline_button);
        echo '</div>';
    } else {
        echo 'error';
    }
    if ('3.9' <= get_bloginfo('version')) {
        _WP_Editors::enqueue_scripts();
        //print_footer_scripts();
        _WP_Editors::editor_js();
        echo '<script src="' . admin_url('js/editor.js') . '" />';
    }
    die;
}
 /**
  * Returns search results.
  *
  * Results returned in a format expected by the internal link manager.
  * Doesn't have support for paging.
  *
  * Multiple filters provided for either adding results or short-circuiting
  * the flow at various points.
  *
  * @since 1.1.0
  */
 public static function ajax_get_link_search_results()
 {
     global $wpdb;
     check_ajax_referer('internal-linking', '_ajax_linking_nonce');
     if (isset($_POST['search'])) {
         $results = array();
         $s = stripslashes($_POST['search']);
         $args['s'] = $s;
         $args['page'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
         $args['per_page'] = 20;
         // Default for usage in filters, otherwise, it shouldn't do anything.
         // Check to see if the request is prepended with a modifier (ex: -wikipedia interrobang, -spotify:artist willie nelson).
         if (0 === mb_strpos($s, '-')) {
             preg_match('/-([^\\s]+)\\s?(.*)?/', $s, $matches);
             $s = trim($matches[2]);
             $args['s'] = $s;
             $args['modifier'] = explode(':', trim($matches[1]));
             $results = (array) apply_filters('better_internal_link_search_modifier-' . $args['modifier'][0], array(), $args);
             if (!empty($results)) {
                 echo json_encode($results);
                 wp_die();
             }
         }
         // Allow plugins to intercept the request and add their own results or short-circuit execution.
         $pre_results = (array) apply_filters('pre_better_internal_link_search_results', array(), $args);
         if (!empty($pre_results)) {
             $results = array_merge($results, $pre_results);
         }
         // Short-circuit if this is a paged request. The first request should have returned all results.
         if (isset($_POST['page']) && $_POST['page'] > 1) {
             wp_die(0);
         }
         // Don't continue if the query length is less than three.
         if (strlen($args['s']) < 3) {
             wp_die(0);
         }
         // @see wp_link_ajax();
         require_once ABSPATH . WPINC . '/class-wp-editor.php';
         $posts = _WP_Editors::wp_link_query($args);
         if ($posts) {
             $future_status_object = get_post_status_object('future');
             $private_status_object = get_post_status_object('private');
             foreach ($posts as $key => $post) {
                 if ('future' == get_post_status($post['ID'])) {
                     $posts[$key]['info'] = $future_status_object->label;
                 } elseif ('private' == get_post_status($post['ID'])) {
                     $posts[$key]['info'] .= ' (' . $private_status_object->label . ')';
                 }
             }
             $results = array_merge($results, $posts);
         }
         if ('yes' === Better_Internal_Link_Search_Settings::get_settings('include_term_results')) {
             // Search for matching term archives.
             $search = '%' . self::esc_like($s) . '%';
             $terms = $wpdb->get_results($wpdb->prepare("SELECT t.term_id, t.name, tt.taxonomy\n\t\t\t\t\tFROM {$wpdb->terms} t\n\t\t\t\t\tINNER JOIN {$wpdb->term_taxonomy} tt ON t.term_id=tt.term_id\n\t\t\t\t\tWHERE t.name LIKE %s\n\t\t\t\t\tORDER BY name ASC", $search));
             if ($terms) {
                 foreach ($terms as $term) {
                     $taxonomy = get_taxonomy($term->taxonomy);
                     if (isset($taxonomy->query_var)) {
                         $results[] = array('title' => trim(esc_html(strip_tags($term->name))), 'permalink' => get_term_link((int) $term->term_id, $term->taxonomy), 'info' => $taxonomy->labels->singular_name);
                     }
                 }
             }
         }
         // Allow results to be filtered one last time and attempt to sort them.
         if (!empty($results)) {
             self::$s = $s;
             $results = apply_filters('better_internal_link_search_results', $results, $args);
             if (apply_filters('better_internal_link_search_sort_results', true, $results, $args)) {
                 usort($results, array(__CLASS__, 'sort_results'));
             }
         }
         // Add shortcut results.
         $shortcuts = (array) self::get_shortcuts();
         if (!empty($shortcuts)) {
             if (array_key_exists($s, $shortcuts)) {
                 array_unshift($results, $shortcuts[$s]);
             } elseif ('shortcuts' == $s) {
                 $results = array_merge($shortcuts, $results);
             }
         }
     }
     if (!isset($results) || empty($results)) {
         wp_die(0);
     }
     echo json_encode($results);
     echo "\n";
     wp_die();
 }
function js_wp_editor($settings = array())
{
    if (!class_exists('_WP_Editors')) {
        require ABSPATH . WPINC . '/class-wp-editor.php';
    }
    $set = _WP_Editors::parse_settings('apid', $settings);
    _WP_Editors::editor_settings('apid', $set);
}
/**
 * View edit screen
 */
function views_redesign_html()
{
    global $WP_Views, $post;
    if (isset($_GET['view_id']) && is_numeric($_GET['view_id'])) {
        do_action('views_edit_screen');
        $view_id = (int) $_GET['view_id'];
        $view = get_post($view_id);
        if (null == $view) {
            wpv_die_toolset_alert_error(__('You attempted to edit a View that doesn&#8217;t exist. Perhaps it was deleted?', 'wpv-views'));
        } elseif ('view' != $view->post_type) {
            wpv_die_toolset_alert_error(__('You attempted to edit a View that doesn&#8217;t exist. Perhaps it was deleted?', 'wpv-views'));
        } else {
            $view_settings = get_post_meta($_GET['view_id'], '_wpv_settings', true);
            /**
             * wpv_view_settings
             *
             * Internal filter to set some View settings that will overwrite the ones existing in the _wpv_settings postmeta
             * Only used to set default values that need to be there on the returned array, but may not be there for legacy reasons
             * Use wpv_filter_override_view_settings to override View settings - like on the Theme Frameworks integration
             *
             * @param $view_settings (array) Unserialized array of the _wpv_settings postmeta
             * @param $view_id (integer) The View ID
             *
             * @return $view_settings (array) The View settings
             *
             * @since unknown
             */
            $view_settings = apply_filters('wpv_view_settings', $view_settings, $view_id);
            $view_layout_settings = get_post_meta($_GET['view_id'], '_wpv_layout_settings', true);
            /**
             * wpv_view_layout_settings
             *
             * Internal filter to set some View layout settings that will overwrite the ones existing in the _wpv_layout_settings postmeta
             * Only used to set default values that need to be there on the returned array,, but may not be there for legacy reasons
             * Use wpv_filter_override_view_layout_settings to override View layout settings
             *
             * @param $view_layout_settings (array) Unserialized array of the _wpv_layout_settings postmeta
             * @param $view_id (integer) The View ID
             *
             * @return $view_layout_settings (array) The View layout settings
             *
             * @since 1.8.0
             */
            $view_layout_settings = apply_filters('wpv_view_layout_settings', $view_layout_settings, $view_id);
            if (isset($view_settings['view-query-mode']) && 'normal' == $view_settings['view-query-mode']) {
                $post = $view;
                if (get_post_status($view_id) == 'trash') {
                    wpv_die_toolset_alert_error(__('You can’t edit this View because it is in the Trash. Please restore it and try again.', 'wpv-views'));
                }
            } else {
                wpv_die_toolset_alert_error(__('You attempted to edit a View that doesn&#8217;t exist. Perhaps it was deleted?', 'wpv-views'));
            }
        }
    } else {
        wpv_die_toolset_alert_error(__('You attempted to edit a View that doesn&#8217;t exist. Perhaps it was deleted?', 'wpv-views'));
    }
    ?>
	<?php 
    /**
     * Screen Options tab
     */
    ?>
	<div id="screen-meta-dup" class="metabox-prefs js-screen-meta-dup hidden">
		<div id="screen-options-wrap" aria-label="<?php 
    echo esc_attr(__('Screen Options Tab'));
    ?>
" class="wpv-screen-options js-wpv-show-hide-container" 
			data-dpsneedsfilter="<?php 
    echo esc_attr(__('The parametric search settings section has unsaved changes, so you can not hide it', 'wpv-views'));
    ?>
" 
			data-pagneedsfilter="<?php 
    echo esc_attr(__('Pagination requires the Filter HTML section to be visible.', 'wpv-views'));
    ?>
" 
			data-unclickable="<?php 
    echo esc_attr(__('This section has unsaved changes, so you can not hide it', 'wpv-views'));
    ?>
">
			<h5><?php 
    _e('Show on screen', 'wpv-views');
    ?>
</h5>
			<p>
				<small><?php 
    echo __('Note that those Screen Options are set per View.', 'wpv-views');
    ?>
</small>
			</p>
			<?php 
    $sections = array();
    $sections = apply_filters('wpv_sections_query_show_hide', $sections);
    if (!empty($sections)) {
        ?>
			<div class="wpv-show-hide-section wpv-show-hide-section-query js-wpv-show-hide-section" data-metasection="wpv-query-section">
				<h6><?php 
        _e('Query section', 'wpv-views');
        ?>
</h6>
				<span class="js-wpv-screen-pref">
				<?php 
        if (isset($view_settings['metasections-hep-show-hide']) && isset($view_settings['metasections-hep-show-hide']['wpv-query-help'])) {
            $state = $view_settings['metasections-hep-show-hide']['wpv-query-help'];
        } else {
            $state = 'on';
        }
        ?>
				<label for="wpv-show-hide-query-help">
					<input type="checkbox" id="wpv-show-hide-query-help" data-metasection="query" class="js-wpv-show-hide-help js-wpv-show-hide-query-help" <?php 
        checked('on', $state);
        ?>
 autocomplete="off" />
					<?php 
        echo __('Display Query section help', 'wpv-views');
        ?>
				</label>
				<input name="wpv-query-help" type="hidden" class="js-wpv-show-hide-help-value js-wpv-show-hide-query-help-value" value="<?php 
        echo esc_attr($state);
        ?>
" autocomplete="off" />
				</span>
				<?php 
        foreach ($sections as $key => $values) {
            if (isset($view_settings['sections-show-hide']) && isset($view_settings['sections-show-hide'][$key])) {
                $values['state'] = $view_settings['sections-show-hide'][$key];
            } else {
                $values['state'] = 'on';
            }
            ?>
						<span class="js-wpv-screen-pref">
						<label for="wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
">
							<input data-section="<?php 
            echo esc_attr($key);
            ?>
" type="checkbox" id="wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
" class="js-wpv-show-hide js-wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
" <?php 
            checked('on', $values['state']);
            ?>
 autocomplete="off" />
							<?php 
            echo $values['name'];
            ?>
						</label>
						<input data-section="<?php 
            echo esc_attr($key);
            ?>
" name="<?php 
            echo esc_attr($key);
            ?>
" class="js-wpv-show-hide-value" type="hidden" value="<?php 
            echo esc_attr($values['state']);
            ?>
" autocomplete="off" />
						</span>
					<?php 
        }
        ?>
			</div>
			<?php 
    }
    ?>
			<?php 
    $sections = array();
    $sections = apply_filters('wpv_sections_filter_show_hide', $sections);
    if (!empty($sections)) {
        ?>
			<div class="wpv-show-hide-section wpv-show-hide-section-filter js-wpv-show-hide-section" data-metasection="wpv-filter-section">
				<h6><?php 
        _e('Filter section', 'wpv-views');
        ?>
</h6>
				<span class="js-wpv-screen-pref">
				<?php 
        if (isset($view_settings['metasections-hep-show-hide']) && isset($view_settings['metasections-hep-show-hide']['wpv-filter-help'])) {
            $state = $view_settings['metasections-hep-show-hide']['wpv-filter-help'];
        } else {
            $state = 'on';
        }
        ?>
				<label for="wpv-show-hide-filter-help">
					<input type="checkbox" id="wpv-show-hide-filter-help" data-metasection="filter" class="js-wpv-show-hide-help js-wpv-show-hide-filter-help" <?php 
        checked('on', $state);
        ?>
 autocomplete="off" />
					<?php 
        echo __('Display Filter section help', 'wpv-views');
        ?>
				</label>
				<input name="wpv-filter-help" type="hidden" class="js-wpv-show-hide-help-value js-wpv-show-hide-filter-help-value" value="<?php 
        echo esc_attr($state);
        ?>
" autocomplete="off" />
				</span>
				<?php 
        foreach ($sections as $key => $values) {
            if (isset($view_settings['sections-show-hide']) && isset($view_settings['sections-show-hide'][$key])) {
                $values['state'] = $view_settings['sections-show-hide'][$key];
            } else {
                $values['state'] = 'on';
            }
            ?>
						<span class="js-wpv-screen-pref">
						<label for="wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
">
							<input data-section="<?php 
            echo esc_attr($key);
            ?>
" type="checkbox" id="wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
" class="js-wpv-show-hide js-wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
" <?php 
            checked('on', $values['state']);
            ?>
 autocomplete="off" />
							<?php 
            echo $values['name'];
            ?>
						</label>
						<input data-section="<?php 
            echo esc_attr($key);
            ?>
" name="<?php 
            echo esc_attr($key);
            ?>
" class="js-wpv-show-hide-value" type="hidden" value="<?php 
            echo esc_attr($values['state']);
            ?>
" autocomplete="off" />
						</span>
					<?php 
        }
        ?>
			</div>
			<?php 
    }
    ?>
			<?php 
    $sections = array();
    $sections = apply_filters('wpv_sections_layout_show_hide', $sections);
    $js = isset($view_layout_settings['additional_js']) ? strval($view_layout_settings['additional_js']) : '';
    if ('' == $js && isset($sections['layout-settings-extra-js'])) {
        unset($sections['layout-settings-extra-js']);
    }
    if (!empty($sections)) {
        ?>
			<div class="wpv-show-hide-section wpv-show-hide-section-layout js-wpv-show-hide-section" data-metasection="wpv-layout-section">
				<h6><?php 
        _e('Loop Output section', 'wpv-views');
        ?>
</h6>
				<span class="js-wpv-screen-pref">
				<?php 
        if (isset($view_settings['metasections-hep-show-hide']) && isset($view_settings['metasections-hep-show-hide']['wpv-layout-help'])) {
            $state = $view_settings['metasections-hep-show-hide']['wpv-layout-help'];
        } else {
            $state = 'on';
        }
        ?>
				<label for="wpv-show-hide-layout-help">
					<input type="checkbox" id="wpv-show-hide-layout-help" data-metasection="layout" class="js-wpv-show-hide-help js-wpv-show-hide-layout-help" <?php 
        checked('on', $state);
        ?>
 autocomplete="off" />
					<?php 
        echo __('Display help for the Loop Output section', 'wpv-views');
        ?>
				</label>
				<input name="wpv-layout-help" type="hidden" class="js-wpv-show-hide-help-value js-wpv-show-hide-layout-help-value" value="<?php 
        echo esc_attr($state);
        ?>
" autocomplete="off" />
				</span>
				<?php 
        foreach ($sections as $key => $values) {
            if (isset($view_settings['sections-show-hide']) && isset($view_settings['sections-show-hide'][$key])) {
                $values['state'] = $view_settings['sections-show-hide'][$key];
            } else {
                $values['state'] = 'on';
            }
            ?>
						<span class="js-wpv-screen-pref">
						<label for="wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
">
							<input data-section="<?php 
            echo esc_attr($key);
            ?>
" type="checkbox" id="wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
" class="js-wpv-show-hide js-wpv-show-hide-<?php 
            echo esc_attr($key);
            ?>
" <?php 
            checked('on', $values['state']);
            ?>
 autocomplete="off" />
							<?php 
            echo $values['name'];
            ?>
						</label>
						<input data-section="<?php 
            echo esc_attr($key);
            ?>
" name="<?php 
            echo esc_attr($key);
            ?>
" class="js-wpv-show-hide-value" type="hidden" value="<?php 
            echo esc_attr($values['state']);
            ?>
" autocomplete="off" />
						</span>
					<?php 
        }
        ?>
			</div>
			<?php 
    }
    ?>
			<?php 
    if (!isset($view_settings['view_purpose']) || $view_settings['view_purpose'] == 'bootstrap-grid') {
        $view_settings['view_purpose'] = 'full';
    }
    ?>
			<p>
				<label for="wpv-view-purpose"><?php 
    echo __('View purpose', 'wpv-views');
    ?>
</label>
				<select id="wpv-view-purpose" class="js-view-purpose" autocomplete="off">
					<?php 
    $purpose_options = array('all' => __('Display all results', 'wpv-views'), 'pagination' => __('Display the results with pagination', 'wpv-views'), 'slider' => __('Display the results as a slider', 'wpv-views'), 'parametric' => __('Display the results as a parametric search', 'wpv-views'), 'full' => __('Full custom display mode', 'wwpv-views'));
    foreach ($purpose_options as $opt => $opt_name) {
        ?>
						<option id="wpv-settings-query-type-posts" <?php 
        selected($view_settings['view_purpose'], $opt);
        ?>
 value="<?php 
        echo esc_attr($opt);
        ?>
"><?php 
        echo $opt_name;
        ?>
</option>
					<?php 
    }
    ?>
				</select>
				<input type="hidden" data-nonce="<?php 
    echo wp_create_nonce('wpv_view_show_hide_nonce');
    ?>
" class="js-wpv-show-hide-update" autocomplete="off" />
			</p>
			<div class="js-wpv-toolset-messages"></div>
		</div>
	</div>
	<div id="screen-meta-links-dup" class="js-screen-meta-links-dup">
		<div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle">
			<a id="show-settings-link" class="show-settings" aria-expanded="false" aria-controls="screen-options-wrap" href="#screen-options-wrap"><?php 
    _e('Screen Options');
    ?>
</a>
		</div>
	</div>
	<?php 
    /**
     * Actual View edit page
     */
    ?>
	<div class="wrap toolset-views">
	<input id="post_ID" class="js-post_ID" type="hidden" value="<?php 
    echo esc_attr($view_id);
    ?>
" data-nonce="<?php 
    echo wp_create_nonce('wpv_view_edit_general_nonce');
    ?>
" />
    <input id="toolset-edit-data" type="hidden" value="<?php 
    echo esc_attr($view_id);
    ?>
" data-plugin="views" />
	<div id="icon-edit" class="icon32 icon32-posts-post"><br></div>
	<h2><?php 
    echo __('Edit View', 'wpv-views');
    ?>
</h2>
	<?php 
    if (isset($_GET['in-iframe-for-layout'])) {
        $in_iframe = 'yes';
    } else {
        $in_iframe = '';
    }
    $user_id = get_current_user_id();
    ?>
	<input type="hidden" class="js-wpv-display-in-iframe" value="<?php 
    echo esc_attr($in_iframe);
    ?>
" />
		<div id="js-wpv-general-actions-bar" class="wpv-settings-save-all wpv-general-actions-bar wpv-setting-container js-wpv-no-lock js-wpv-general-actions-bar">
			<p class="update-button-wrap js-wpv-update-button-wrap">
				<button class="button-secondary button button-large js-wpv-view-save-all"
						disabled="disabled"
						data-success="<?php 
    echo esc_attr(__('View saved', 'wpv-views'));
    ?>
"
						data-unsaved="<?php 
    echo esc_attr(__('View not saved', 'wpv-views'));
    ?>
">
					<?php 
    _e('Save all sections at once', 'wpv-views');
    ?>
				</button>
			</p>
			<span class="wpv-message-container js-wpv-message-container"></span>
		</div>
		<input type="hidden" name="_wpv_settings[view-query-mode]" value="normal" />
		<div class="wpv-title-section">
			<div class="wpv-setting-container wpv-settings-title-and-desc js-wpv-settings-title-and-desc js-wpv-no-lock">
				<div class="wpv-settings-header">
					<h3>
						<?php 
    _e('Title and Description', 'wpv-views');
    $section_help_pointer = WPV_Admin_Messages::edit_section_help_pointer('title_and_description');
    ?>
						<i class="icon-question-sign js-display-tooltip"
								data-header="<?php 
    echo esc_attr($section_help_pointer['title']);
    ?>
"
								data-content="<?php 
    echo esc_attr($section_help_pointer['content']);
    ?>
">
						</i>
					</h3>
				</div>
				<div class="wpv-setting">

					<div id="titlediv">
						<div id="titlewrap" class="js-wpv-titlewrap">
							<label class="screen-reader-text js-title-reader" id="title-prompt-text" for="title"><?php 
    _e('Enter title here', 'wp-views');
    ?>
</label>
							<input id="title" class="js-title" type="text" name="post_title" size="30" value="<?php 
    echo esc_attr(get_the_title($view_id));
    ?>
" id="title" autocomplete="off">
						</div>
					</div>

					<div id="edit-slug-box" class="js-wpv-slug-container">
						<label for="wpv-slug"><?php 
    _e('Slug of this View', 'wpv-views');
    ?>
						<input id="wpv-slug" class="js-wpv-slug" type="text" value="<?php 
    echo esc_attr($view->post_name);
    ?>
" />
						<span class="js-wpv-inline-trash">
							&bull;
							<button class="button-secondary js-wpv-change-view-status"
									data-statusto="trash"
									data-success="<?php 
    echo esc_attr(__('View moved to trash', 'wpv-views'));
    ?>
"
									data-unsaved="<?php 
    echo esc_attr(__('View not moved to trash', 'wpv-views'));
    ?>
"
									data-redirect="<?php 
    echo admin_url('admin.php?page=views');
    ?>
"
									data-nonce="<?php 
    echo wp_create_nonce('wpv_view_change_status');
    ?>
">
								<i class="icon-trash"></i> <?php 
    _e('Move to trash', 'wpv-views');
    ?>
							</button>
						</span>
					</div>

					<?php 
    $view_description = get_post_meta($_GET['view_id'], '_wpv_description', true);
    ?>

					<p<?php 
    echo isset($view_description) && !empty($view_description) ? ' class="hidden"' : '';
    ?>
>
						<button class="js-wpv-description-toggle button-secondary" ><?php 
    _e('Add description', 'wpv-views');
    ?>
</button>
					</p>

					<div class="js-wpv-description-container wpv-description-container<?php 
    echo isset($view_description) && !empty($view_description) ? '' : ' hidden';
    ?>
">
						<p>
							<label for="wpv-description"><?php 
    _e('Describe this View', 'wpv-views');
    ?>
</label>
						</p>
						<p>
							<textarea id="wpv-description" class="js-wpv-description" name="_wpv_settings[view_description]" cols="72" rows="4"><?php 
    echo isset($view_description) ? esc_html($view_description) : '';
    ?>
</textarea>
						</p>
					</div>

					<p class="update-button-wrap js-wpv-update-button-wrap">
						<span class="js-wpv-message-container"></span>
						<button data-success="<?php 
    echo esc_attr(__('Title and description updated', 'wpv-views'));
    ?>
" data-unsaved="<?php 
    echo esc_attr(__('Title and description not saved', 'wpv-views'));
    ?>
" data-nonce="<?php 
    echo wp_create_nonce('wpv_view_title_description_nonce');
    ?>
" class="js-wpv-title-description-update button-secondary" disabled="disabled"><?php 
    _e('Update', 'wpv-views');
    ?>
</button>
					</p>

				</div>
			</div>
		</div> <!-- .wpv-title-section -->

		<div class="wpv-query-section">
			<?php 
    wpv_get_view_introduction_data();
    ?>
			<h3 class="wpv-section-title"><?php 
    _e('The Query section determines what content the View loads from the database', 'wpv-views');
    ?>
</h3>
			<?php 
    do_action('view-editor-section-query', $view_settings, $view_id, $user_id);
    ?>
		</div>

		<?php 
    /*
     * Query type (content selection) - Priority 10
     * Query options - Priority 20
     * Ordering - Priority 30
     * Limit and offset - Priority 40
     * Filters - Priority 50
     */
    ?>

		<div class="wpv-filter-section">
			<h3 class="wpv-section-title"><?php 
    _e('The Filter section lets you set up pagination and parametric search, which let visitors control the View query', 'wpv-views');
    ?>
</h3>
			<?php 
    wpv_get_view_filter_introduction_data();
    ?>
			<?php 
    do_action('view-editor-section-filter', $view_settings, $view_id, $user_id);
    ?>
		</div>

		<?php 
    /*
     * Pagination TODO review this. https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/161787682/comments - Priority 50
     * Filters Meta HTML/CSS/JS TODO review this. https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/161787682/comments - Priority 80
     */
    ?>

		<div class="wpv-layout-section">
			<h3 class="wpv-section-title"><?php 
    _e('The Loop Output section styles the View output on the page.', 'wpv-views');
    ?>
</h3>
			<?php 
    $data = wpv_get_view_layout_introduction_data();
    wpv_toolset_help_box($data);
    ?>
			<?php 
    do_action('view-editor-section-layout', $view_settings, $view_layout_settings, $view_id, $user_id);
    ?>
			<?php 
    do_action('view-editor-section-extra', $view_settings, $view_id, $user_id);
    ?>
		</div>
		
        <?php 
    $display_help = isset($_GET['in-iframe-for-layout']) && $_GET['in-iframe-for-layout'] == 1 ? false : true;
    if ($display_help === true) {
        ?>
		<div class="wpv-help-section">
		<?php 
        wpv_display_view_howto_help_box();
        ?>
		</div>
        <?php 
    }
    ?>

		<script type="text/javascript">
			jQuery( function( $ ) {
				jQuery('li.current a').attr('href',jQuery('li.current a').attr('href')+'&view_id=<?php 
    echo esc_attr($view_id);
    ?>
');
			});
		</script>
		<?php 
    /*
     * Output (layout) type - TODO review this https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/162512599/comments - Priority 10 - To remove
     * Output fields TODO this has been reviewed and may be used as training - Priority 20 - To remove
     * Layout templates TODO insert here the new Content Templates editor. https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/161787695/comments - Priority 20 - To review
     * Layout Meta HTML/CSS/JS TODO this has been reviewed and needs some changes. https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/161787640/comments - Priority 40
     * Aditional Javascript files TODO move to its own file - Priority 50
     * Extra sections:
     * 1. Complete output (the_content)
     * 2. Module manager TODO needs to be added
     */
    ?>
	</div>
	<?php 
    /**
     * view-editor-section-hidden
     *
     * Show hidden container for dialogs, pointers and messages that need to be taken by ColorBox from an existing HTML element
     *
     * @param $view_settings
     * @param $view_laqyout_settings
     * @param $view_id
     * @param $user_id
     *
     * @note that you can use the .popup-window-container classname to hide the containers added here
     *
     * @since 1.7
     */
    do_action('view-editor-section-hidden', $view_settings, $view_layout_settings, $view_id, $user_id);
    if (!class_exists('_WP_Editors')) {
        require ABSPATH . WPINC . '/class-wp-editor.php';
    }
    _WP_Editors::wp_link_dialog();
}
Exemple #16
0
    function wp_editors()
    {
        if (function_exists('wp_editor')) {
            $init_str = '';
            ob_start();
            _WP_Editors::editor_js();
            $js = ob_get_contents();
            ob_end_clean();
            $js = explode('tinyMCEPreInit = {', $js);
            if (count($js) > 0) {
                $js[1] = explode('};', $js[1]);
                if (count($js[1]) > 0) {
                    if (preg_match('/mceInit\\s*:(.*?),\\s*qtInit/is', $js[1][0], $matches)) {
                        $init_str = $matches[1];
                        $js[1][0] = preg_replace('/mceInit\\s*:(.*?),\\s*qtInit/is', 'qtInit', $js[1][0]);
                    }
                }
                $js[1] = implode('};', $js[1]);
            }
            if ($init_str != '') {
                echo '
<script type="text/javascript">
var OP_tinyMCE = ' . $init_str . ';
</script>';
            }
            $js = implode('tinyMCEPreInit = {', $js);
            echo $js;
        }
    }
    /**
     * Add form item. Returns form item with selected arguments.
     *
     * @since 4.0.0
     * @param array $args Input argument name => argument value
     */
    public function add_form_item($args = array())
    {
        $default = array('class' => '', 'inline_style' => '', 'type' => '', 'value' => '', 'multiple' => false, 'max_value' => '100', 'min_value' => '0', 'step_value' => '1', 'default_value' => '', 'options' => '', 'placeholder' => '', 'upload_button_text' => __('Choose Media', 'cherry'), 'remove_button_text' => __('Remove Media', 'cherry'), 'return_data_type' => 'id', 'multi_upload' => true, 'display_image' => true, 'display_input' => true, 'library_type' => '', 'label' => '', 'title' => '', 'description' => '', 'hint' => '', 'toggle' => array('true_toggle' => __('On', 'cherry'), 'false_toggle' => __('Off', 'cherry')));
        extract(array_merge($default, $args));
        $value = $value == '' || $value == false && $value != 0 ? $default_value : $value;
        $item_id = $id;
        $name = $this->generate_field_name($id);
        $id = $this->generate_field_id($id);
        $item_inline_style = $inline_style ? 'style="' . $inline_style . '"' : '';
        $output = '';
        if (is_array($this->options['hidden_items']) && in_array($item_id, $this->options['hidden_items'])) {
            return;
        }
        switch ($type) {
            case 'submit':
                // $output .= '<input ' . $item_inline_style . ' class="' . $class . ' '.$this->options['class']['submit'].'" id="' . $id . '" name="' . $name . '" type="'.$type.'" value="' . esc_html( $value ) . '" >';
                $type .= ' ' . $class;
                $item_inline_style .= ' id=' . $id;
                $output .= get_submit_button($value, $type, $name, false, $item_inline_style);
                break;
            case 'reset':
                $output .= '<input ' . $item_inline_style . ' class="' . $class . ' ' . $this->options['class']['submit'] . '" id="' . $id . '" name="' . $name . '" type="reset" value="' . esc_html($value) . '" >';
                break;
            case 'text':
                $ui_text = new UI_Text(array('id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'class' => $class));
                $output .= $ui_text->render();
                break;
            case 'textarea':
                $ui_textarea = new UI_Textarea(array('id' => $id, 'name' => $name, 'value' => $value, 'placeholder' => $placeholder, 'class' => $class));
                $output .= $ui_textarea->render();
                break;
            case 'select':
                $ui_select = new UI_Select(array('id' => $id, 'name' => $name, 'multiple' => $multiple, 'value' => $value, 'options' => $options, 'class' => $class));
                $output .= $ui_select->render();
                break;
            case 'checkbox':
                $ui_checkbox = new UI_Checkbox(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class));
                $output .= $ui_checkbox->render();
                break;
            case 'radio':
                $ui_radio = new UI_Radio(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class));
                $output .= $ui_radio->render();
                break;
            case 'switcher':
                $ui_switcher = new UI_Switcher(array('id' => $id, 'name' => $name, 'value' => $value, 'toggle' => $toggle, 'class' => $class));
                $output .= $ui_switcher->render();
                break;
            case 'stepper':
                $ui_stepper = new UI_Stepper(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class));
                $output .= $ui_stepper->render();
                break;
            case 'slider':
                $ui_slider = new UI_Slider(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class));
                $output .= $ui_slider->render();
                break;
            case 'rangeslider':
                $ui_range_slider = new UI_Range_Slider(array('id' => $id, 'name' => $name, 'value' => $value, 'max_value' => $max_value, 'min_value' => $min_value, 'step_value' => $step_value, 'class' => $class));
                $output .= $ui_range_slider->render();
                break;
            case 'colorpicker':
                $ui_colorpicker = new UI_Colorpicker(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class));
                $output .= $ui_colorpicker->render();
                break;
            case 'media':
                $ui_media = new UI_Media(array('id' => $id, 'name' => $name, 'value' => $value, 'multi_upload' => $multi_upload, 'library_type' => $library_type, 'class' => $class));
                $output .= $ui_media->render();
                break;
            case 'background':
                $ui_background = new UI_Background(array('id' => $id, 'name' => $name, 'value' => $value, 'multi_upload' => $multi_upload, 'library_type' => $library_type, 'class' => $class));
                $output .= $ui_background->render();
                break;
            case 'typography':
                $ui_typography = new UI_Typography(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class));
                $output .= $ui_typography->render();
                break;
            case 'ace-editor':
                $ui_ace_editor = new UI_Ace_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class));
                $output .= $ui_ace_editor->render();
                break;
            case 'repeater':
                $ui_repeater = new UI_Repeater(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class));
                $output .= $ui_repeater->render();
                break;
            case 'static_area_editor':
                $ui_statics = new UI_Static_Area_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'options' => $options, 'class' => $class));
                $output .= $ui_statics->render();
                break;
            case 'layouteditor':
                $ui_layout_editor = new UI_Layout_Editor(array('id' => $id, 'name' => $name, 'value' => $value, 'class' => $class));
                $output .= $ui_layout_editor->render();
                break;
            case 'editor':
                //$wrap = false;
                ob_start();
                $settings = array('textarea_name' => $name, 'media_buttons' => 1, 'teeny' => 0, 'textarea_rows' => 10, 'tinymce' => array('setup' => 'function(ed) {
								ed.onChange.add(function(ed) {
									tinyMCE.triggerSave();
								});
							}'));
                wp_editor($value, $id, $settings);
                $output .= ob_get_clean();
                _WP_Editors::editor_js();
                _WP_Editors::enqueue_scripts();
                break;
        }
        return $this->wrap_item($output, $id, 'cherry-section cherry-' . $type . ' ' . $this->options['class']['section'], $title, $label, $description, $hint);
    }
 public static function enqueue_footer_js()
 {
     global $frm_vars, $frm_input_masks;
     if (empty($frm_vars['forms_loaded'])) {
         return;
     }
     FrmFormsController::register_pro_scripts();
     if (!FrmAppHelper::doing_ajax()) {
         wp_enqueue_script('formidable');
     }
     if (isset($frm_vars['tinymce_loaded']) && $frm_vars['tinymce_loaded']) {
         _WP_Editors::enqueue_scripts();
     }
     // trigger jQuery UI to be loaded on every page
     self::add_js();
     if (isset($frm_vars['datepicker_loaded']) && !empty($frm_vars['datepicker_loaded'])) {
         if (is_array($frm_vars['datepicker_loaded'])) {
             foreach ($frm_vars['datepicker_loaded'] as $fid => $o) {
                 if (!$o) {
                     unset($frm_vars['datepicker_loaded'][$fid]);
                 }
                 unset($fid, $o);
             }
         }
         if (!empty($frm_vars['datepicker_loaded'])) {
             wp_enqueue_script('jquery-ui-datepicker');
             FrmStylesHelper::enqueue_jquery_css();
         }
     }
     if (isset($frm_vars['chosen_loaded']) && $frm_vars['chosen_loaded']) {
         wp_enqueue_script('jquery-chosen');
     }
     if (isset($frm_vars['star_loaded']) && !empty($frm_vars['star_loaded'])) {
         wp_enqueue_script('jquery-frm-rating');
         wp_enqueue_style('dashicons');
         FrmStylesController::enqueue_style();
     }
     $frm_input_masks = apply_filters('frm_input_masks', $frm_input_masks, $frm_vars['forms_loaded']);
     foreach ((array) $frm_input_masks as $fid => $o) {
         if (!$o) {
             unset($frm_input_masks[$fid]);
         }
         unset($fid, $o);
     }
     if (!empty($frm_input_masks)) {
         wp_enqueue_script('jquery-maskedinput');
     }
     if (isset($frm_vars['google_graphs']) && !empty($frm_vars['google_graphs'])) {
         wp_enqueue_script('google_jsapi', 'https://www.google.com/jsapi');
     }
 }
Exemple #19
0
     if (!current_user_can('edit_theme_options')) {
         die('-1');
     }
     require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
     _wp_ajax_menu_quick_search($_REQUEST);
     exit;
     break;
 case 'wp-link-ajax':
     check_ajax_referer('internal-linking', '_ajax_linking_nonce');
     $args = array();
     if (isset($_POST['search'])) {
         $args['s'] = stripslashes($_POST['search']);
     }
     $args['pagenum'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
     require ABSPATH . WPINC . '/class-wp-editor.php';
     $results = _WP_Editors::wp_link_query($args);
     if (!isset($results)) {
         die('0');
     }
     echo json_encode($results);
     echo "\n";
     exit;
     break;
 case 'menu-locations-save':
     if (!current_user_can('edit_theme_options')) {
         die('-1');
     }
     check_ajax_referer('add-menu_item', 'menu-settings-column-nonce');
     if (!isset($_POST['menu-locations'])) {
         die('0');
     }
Exemple #20
0
            }
            ?>
                                        <?php 
        }
        ?>
                                    </td>
                                <?php 
    }
    ?>
                            </tr>
                        <?php 
}
?>
                    </tbody>
                </table>
            </div>
        </div>

    <?php 
if (!$woocommerce_wpml->settings['first_editor_call']) {
    //load editor js
    if (class_exists('_WP_Editors')) {
        _WP_Editors::editor_js();
    }
    $woocommerce_wpml->settings['first_editor_call'] = true;
    $woocommerce_wpml->update_settings();
}
?>
    </td>
</tr>
Exemple #21
0
 /**
  * Adds native link modal
  */
 public function wa_fronted_footer_scripts()
 {
     if (!class_exists('_WP_Editors')) {
         require ABSPATH . WPINC . '/class-wp-editor.php';
     }
     _WP_Editors::wp_link_dialog();
     do_action('wa_fronted_footer_scripts');
 }
 public function wpLink()
 {
     if (!class_exists('_WP_Editors', false)) {
         require_once ABSPATH . WPINC . '/class-wp-editor.php';
     }
     _WP_Editors::wp_link_dialog();
 }
	function loadTinyMceSettings() {
		if ( ! class_exists( '_WP_Editors' ) )
			require( ABSPATH . WPINC . '/class-wp-editor.php' );
		$set = _WP_Editors::parse_settings( self::$content_editor_id, self::$content_editor_settings );
		_WP_Editors::editor_settings( self::$content_editor_id, $set );
	}
Exemple #24
0
 public function ckeditor_linkbrowser_search()
 {
     check_ajax_referer('internal-linking', '_ajax_linking_nonce');
     $args = array();
     if (isset($_POST['search'])) {
         $args['s'] = stripslashes($_POST['search']);
     }
     $args['pagenum'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
     $results = _WP_Editors::wp_link_query($args);
     if (!isset($results)) {
         wp_die(0);
     }
     echo json_encode($results);
     echo "\n";
     wp_die();
 }
Exemple #25
0
/**
 * Renders an editor.
 *
 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
 * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
 *
 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
 * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
 * On the post edit screen several actions can be used to include additional editors
 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
 * See https://core.trac.wordpress.org/ticket/19173 for more information.
 *
 * @see wp-includes/class-wp-editor.php
 * @since 3.3.0
 *
 * @param string $content   Initial content for the editor.
 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
 * @param array  $settings  See _WP_Editors::editor().
 */
function wp_editor($content, $editor_id, $settings = array())
{
    if (!class_exists('_WP_Editors')) {
        require ABSPATH . WPINC . '/class-wp-editor.php';
    }
    _WP_Editors::editor($content, $editor_id, $settings);
}
        function load_mce_translation()
        {
            if (!class_exists('_WP_Editors')) {
                require ABSPATH . WPINC . '/class-wp-editor.php';
            }
            $strings = _WP_Editors::wp_mce_translation();
            $strings = preg_replace('/tinymce.addI18n[^{]+/', '', $strings);
            $strings = preg_replace('/[^}]*$/', '', $strings);
            if ($strings) {
                ?>
			<script type="text/javascript">var tadvTranslation = <?php 
                echo $strings;
                ?>
;</script>
			<?php 
            }
        }
Exemple #27
0
/**
 * Ajax handler for internal linking.
 *
 * @since 3.1.0
 */
function wp_ajax_wp_link_ajax()
{
    check_ajax_referer('internal-linking', '_ajax_linking_nonce');
    $args = array();
    if (isset($_POST['search'])) {
        $args['s'] = wp_unslash($_POST['search']);
    }
    $args['pagenum'] = !empty($_POST['page']) ? absint($_POST['page']) : 1;
    require ABSPATH . WPINC . '/class-wp-editor.php';
    $results = _WP_Editors::wp_link_query($args);
    if (!isset($results)) {
        wp_die(0);
    }
    echo wp_json_encode($results);
    echo "\n";
    wp_die();
}
 function _display_wp_link_dialog()
 {
     if (!class_exists('_WP_Editors')) {
         require ABSPATH . WPINC . '/class-wp-editor.php';
     }
     if (!has_action('admin_footer', array('_WP_Editors', 'enqueue_scripts'))) {
         _WP_Editors::wp_link_dialog();
     }
 }
/**
 * @since 2.7.0
 * @deprecated 3.3.0
 * @deprecated Use wp_editor()
 * @see wp_editor()
 */
function wp_tiny_mce($teeny = false, $settings = false)
{
    _deprecated_function(__FUNCTION__, '3.3', 'wp_editor()');
    static $num = 1;
    if (!class_exists('_WP_Editors')) {
        require_once ABSPATH . WPINC . '/class-wp-editor.php';
    }
    $editor_id = 'content' . $num++;
    $set = array('teeny' => $teeny, 'tinymce' => $settings ? $settings : true, 'quicktags' => false);
    $set = _WP_Editors::parse_settings($editor_id, $set);
    _WP_Editors::editor_settings($editor_id, $set);
}
 /**
  * This function outputs the WordPress Link Dialog template.
  */
 public function wp_footer()
 {
     // WordPress Link Dialog
     if (!class_exists('_WP_Editors')) {
         require ABSPATH . WPINC . '/class-wp-editor.php';
     }
     _WP_Editors::wp_link_dialog();
 }