コード例 #1
0
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');
}
コード例 #2
0
ファイル: RichtextEditor.php プロジェクト: neochic/woodlets
 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);
 }
コード例 #3
0
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);
}
コード例 #4
0
 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);
 }
コード例 #5
0
/**
 * @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);
}
コード例 #6
0
ファイル: class-pagebuilder.php プロジェクト: jolay/maga2.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);
     }
 }
コード例 #7
0
	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 );
	}
コード例 #8
0
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);
}
コード例 #9
0
 /**
  * We need to get
  * _WP_Editors::$qt_settings and _WP_Editors::$mce_settings, after calling
  * it's editor_settings method. And it needs to be done without any mutation
  * to the class state itself. I've tryied HARD to not leave any
  * fingerprints there.
  */
 public function get_preinit_data_for_editor()
 {
     $this->mock_wp_editors_class();
     /**
      * We are safe to do any modifications to the _WP_Editors here.
      * Any mocked data will be restored after our manipulations.
      */
     /**
      * Skip add_action()
      * https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php#L308
      */
     $this->set_static_field('first_init', array());
     /**
      * Set:
      * _WP_Editors::$qt_settings: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php#L345
      *
      * _WP_Editors::$mce_settings: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php#L740
      *
      * Then get them back using reflection class
      */
     _WP_Editors::editor_settings($this->editor_id, $this->get_set());
     $mce_settings = $this->get_static_field('mce_settings');
     $qt_settings = $this->get_static_field('qt_settings');
     $mce_settings = fw_akg($this->editor_id, $mce_settings, array());
     /**
      * https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php#L522
      *
      * _WP_Editors outputs JavaScript notation object, we want a valid JSON.
      *
      * Replace this:
      * {a: 1}
      * to
      * {"a": 1}
      */
     $mce_settings['formats'] = preg_replace("/(\\w+)\\:/", '"$1":', $mce_settings['formats']);
     $mce_settings['formats'] = json_decode($mce_settings['formats'], true);
     $mce_settings['external_plugins'] = json_decode($mce_settings['external_plugins'], true);
     $qt_settings = fw_akg($this->editor_id, $qt_settings, array());
     $preinit_data = array('mce_settings' => $mce_settings, 'qt_settings' => $qt_settings);
     $this->restore_wp_editors_class();
     return $preinit_data;
 }
コード例 #10
0
 /**
  * @internal
  **/
 public function _action_print_wp_editor()
 {
     if (!class_exists('_WP_Editors')) {
         require ABSPATH . WPINC . '/class-wp-editor.php';
         $id = 'fw-wp-editor-option-type';
         $set = _WP_Editors::parse_settings($id, array('teeny' => true, 'media_buttons' => true, 'tinymce' => true, 'editor_css' => true, 'quicktags' => true));
         _WP_Editors::editor_settings($id, $set);
         _WP_Editors::enqueue_scripts();
         _WP_Editors::editor_js();
     }
 }
コード例 #11
0
 /**
  * We need to get
  * _WP_Editors::$qt_settings and _WP_Editors::$mce_settings, after calling
  * it's editor_settings method. And it needs to be done without any mutation
  * to the class state itself. I've tryied HARD to not leave any
  * fingerprints there.
  */
 public function get_preinit_data_for_editor()
 {
     $this->attach_filters();
     /**
      * Set:
      * _WP_Editors::$qt_settings: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php#L345
      *
      * _WP_Editors::$mce_settings: https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php#L740
      *
      * Then get them back using reflection class
      */
     _WP_Editors::editor_settings($this->editor_id, $this->get_set());
     $mce_settings = $this->mce_settings;
     $qt_settings = $this->qt_settings;
     if (isset($mce_settings['formats'])) {
         /**
          * https://github.com/WordPress/WordPress/blob/master/wp-includes/class-wp-editor.php#L522
          *
          * _WP_Editors outputs JavaScript notation object, we want a valid JSON.
          *
          * Replace this:
          * {a: 1}
          * to
          * {"a": 1}
          */
         $mce_settings['formats'] = preg_replace("/(\\w+)\\:/", '"$1":', $mce_settings['formats']);
     }
     /**
      * Loop thought all settings and decode json values
      */
     if ($mce_settings) {
         foreach ($mce_settings as &$setting) {
             if (is_string($setting) && !empty($setting) && in_array($setting[0], array('[', '{'), true) && !is_null($decoded = json_decode($setting))) {
                 $setting = $decoded;
             }
         }
     }
     $preinit_data = array('mce_settings' => $mce_settings, 'qt_settings' => $qt_settings);
     $this->dettach_filters();
     return $preinit_data;
 }
コード例 #12
0
ファイル: class-richtext.php プロジェクト: yemingyuen/mingsg
 /**
  * Setup an extra TinyMCE setting for use in AJAX editors
  */
 public function add_editor_settings()
 {
     $ajax_settings = _WP_Editors::parse_settings($this->get_the_ID(), $this->get_tinymce_settings());
     _WP_Editors::editor_settings($this->get_the_ID(), $ajax_settings);
 }
コード例 #13
0
 /**
  * Add JS to header edit/Add new post
  */
 function js()
 {
     wp_enqueue_script('jquery');
     wp_enqueue_script('jquery-core');
     // http://code.jquery.com/ui/1.10.3/jquery-ui.js
     //  wp_enqueue_script('jquery-ui', 'http://code.jquery.com/ui/1.10.3/jquery-ui.js', array('jquery'));
     if (function_exists('wp_enqueue_media')) {
         wp_enqueue_media();
     }
     wp_enqueue_script('jquery-ui-dialog');
     wp_enqueue_script('jquery-ui-draggable');
     wp_enqueue_script('jquery-ui-droppable');
     wp_enqueue_script('jquery-ui-sortable');
     wp_enqueue_script('jquery-ui-position');
     wp_enqueue_script('iris');
     wp_enqueue_script('wp-color-picker');
     wp_enqueue_script('quicktag');
     wp_enqueue_script('jquery.poshytip.js', $this->settings['url'] . 'assets/js/jquery.poshytip.js', array('jquery'));
     wp_enqueue_script('st-cookies', $this->settings['url'] . 'assets/js/cookies.js', array('jquery'));
     wp_enqueue_script('st-tabs-builder', $this->settings['url'] . 'assets/js/tabs-builder.js', array('jquery'));
     wp_enqueue_script('st-table-builder', $this->settings['url'] . 'assets/js/table-builder.js', array('jquery'));
     wp_enqueue_script('st-input-items', $this->settings['url'] . 'assets/js/input-items.js', array('jquery'));
     wp_enqueue_script('st-pagebuilder', $this->settings['url'] . 'assets/js/pagebuilder.js', array('jquery'));
     $l10n = array();
     $l10n[$this->nonceName] = $this->nonceValue;
     $l10n['input_name'] = ST_Page_Builder::BUILDER_SETTINGS_NAME;
     $l10n['item_sizes'] = $this->item_sizes;
     $l10n['config']['confirm_remove_row'] = __('Are you sure want to remove this row ?', 'smooththemes');
     $l10n['config']['confirm_remove_col'] = __('Are you sure want to remove this column ?', 'smooththemes');
     $l10n['config']['row_settings_title'] = __('Section settings', 'smooththemes');
     $l10n['config']['col_settings_title'] = __('Layout settings', 'smooththemes');
     $l10n['config']['loading'] = __('Loading...', 'smooththemes');
     $l10n['config']['tinymce_base'] = get_bloginfo('home') . '/wp-includes/js/tinymce';
     if (function_exists('st_get_font_icons')) {
         $l10n['font_icons'] = st_get_font_icons();
     }
     wp_localize_script('jquery-core', 'STBP', $l10n);
     if (!class_exists('_WP_Editors')) {
         require ABSPATH . WPINC . '/class-wp-editor.php';
     }
     $set = _WP_Editors::parse_settings('ap[id]', $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('ap[id]', $set);
 }
コード例 #14
0
 public function enqueue_wp_editor_scripts()
 {
     //initialize scripts for ajax text-editors
     if (!class_exists('_WP_Editors')) {
         require_once ABSPATH . WPINC . '/class-wp-editor.php';
     }
     $editor_id = 'content1';
     $set = array('teeny' => false, 'tinymce' => true, 'quicktags' => false);
     $set = _WP_Editors::parse_settings($editor_id, $set);
     _WP_Editors::editor_settings($editor_id, $set);
 }
コード例 #15
0
ファイル: deprecated.php プロジェクト: inpsyde/wordpress-dev
/**
 * Outputs the TinyMCE editor.
 *
 * @since 2.7.0
 * @deprecated 3.3.0 Use wp_editor()
 * @see wp_editor()
 *
 * @staticvar int $num
 */
function wp_tiny_mce($teeny = false, $settings = false)
{
    _deprecated_function(__FUNCTION__, '3.3.0', 'wp_editor()');
    static $num = 1;
    $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);
}