Esempio n. 1
0
 public static function parse_settings($editor_id, $settings)
 {
     $set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true));
     self::$this_tinymce = $set['tinymce'] && user_can_richedit();
     self::$this_quicktags = (bool) $set['quicktags'];
     if (self::$this_tinymce) {
         self::$has_tinymce = true;
     }
     if (self::$this_quicktags) {
         self::$has_quicktags = true;
     }
     if (empty($set['editor_height'])) {
         return $set;
     }
     if ('content' === $editor_id) {
         // A cookie (set when a user resizes the editor) overrides the height.
         $cookie = (int) get_user_setting('ed_size');
         // Upgrade an old TinyMCE cookie if it is still around, and the new one isn't.
         if (!$cookie && isset($_COOKIE['TinyMCE_content_size'])) {
             parse_str($_COOKIE['TinyMCE_content_size'], $cookie);
             $cookie = $cookie['ch'];
         }
         if ($cookie) {
             $set['editor_height'] = $cookie;
         }
     }
     if ($set['editor_height'] < 50) {
         $set['editor_height'] = 50;
     } elseif ($set['editor_height'] > 5000) {
         $set['editor_height'] = 5000;
     }
     return $set;
 }
	public static function parse_settings($editor_id, $settings) {
		$set = wp_parse_args( $settings,  array(
			'wpautop' => true, // use wpautop?
			'media_buttons' => true, // show insert/upload button(s)
			'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
			'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
			'tabindex' => '',
			'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped".
			'editor_class' => '', // add extra class(es) to the editor textarea
			'teeny' => false, // output the minimal editor config used in Press This
			'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css)
			'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
			'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
		) );

		self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() );
		self::$this_quicktags = (bool) $set['quicktags'];

		if ( self::$this_tinymce )
			self::$has_tinymce = true;

		if ( self::$this_quicktags )
			self::$has_quicktags = true;

		return $set;
	}
Esempio n. 3
0
 /**
  * Parse default arguments for the editor instance.
  *
  * @param string $editor_id ID for the current editor instance.
  * @param array  $settings {
  *     Array of editor arguments.
  *
  *     @type bool       $wpautop           Whether to use wpautop(). Default true.
  *     @type bool       $media_buttons     Whether to show the Add Media/other media buttons.
  *     @type string     $default_editor    When both TinyMCE and Quicktags are used, set which
  *                                         editor is shown on page load. Default empty.
  *     @type bool       $drag_drop_upload  Whether to enable drag & drop on the editor uploading. Default false.
  *                                         Requires the media modal.
  *     @type string     $textarea_name     Give the textarea a unique name here. Square brackets
  *                                         can be used here. Default $editor_id.
  *     @type int        $textarea_rows     Number rows in the editor textarea. Default 20.
  *     @type string|int $tabindex          Tabindex value to use. Default empty.
  *     @type string     $tabfocus_elements The previous and next element ID to move the focus to
  *                                         when pressing the Tab key in TinyMCE. Defualt ':prev,:next'.
  *     @type string     $editor_css        Intended for extra styles for both Visual and Text editors.
  *                                         Should include <style> tags, and can use "scoped". Default empty.
  *     @type string     $editor_class      Extra classes to add to the editor textarea elemen. Default empty.
  *     @type bool       $teeny             Whether to output the minimal editor config. Examples include
  *                                         Press This and the Comment editor. Default false.
  *     @type bool       $dfw               Whether to replace the default fullscreen with "Distraction Free
  *                                         Writing". DFW requires specific DOM elements and css). Default false.
  *     @type bool|array $tinymce           Whether to load TinyMCE. Can be used to pass settings directly to
  *                                         TinyMCE using an array. Default true.
  *     @type bool|array $quicktags         Whether to load Quicktags. Can be used to pass settings directly to
  *                                         Quicktags using an array. Default true.
  * }
  * @return array Parsed arguments array.
  */
 public static function parse_settings($editor_id, $settings)
 {
     $set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'default_editor' => '', 'drag_drop_upload' => false, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true));
     self::$this_tinymce = $set['tinymce'] && user_can_richedit();
     if (self::$this_tinymce) {
         if (false !== strpos($editor_id, '[')) {
             self::$this_tinymce = false;
             _deprecated_argument('wp_editor()', '3.9', 'TinyMCE editor IDs cannot have brackets.');
         }
     }
     self::$this_quicktags = (bool) $set['quicktags'];
     if (self::$this_tinymce) {
         self::$has_tinymce = true;
     }
     if (self::$this_quicktags) {
         self::$has_quicktags = true;
     }
     if (empty($set['editor_height'])) {
         return $set;
     }
     if ('content' === $editor_id) {
         // A cookie (set when a user resizes the editor) overrides the height.
         $cookie = (int) get_user_setting('ed_size');
         if ($cookie) {
             $set['editor_height'] = $cookie;
         }
     }
     if ($set['editor_height'] < 50) {
         $set['editor_height'] = 50;
     } elseif ($set['editor_height'] > 5000) {
         $set['editor_height'] = 5000;
     }
     return $set;
 }
Esempio n. 4
0
 public static function parse_settings($editor_id, $settings)
 {
     $set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'textarea_name' => $editor_id, 'textarea_rows' => get_option('default_post_edit_rows', 10), 'tabindex' => '', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true));
     self::$this_tinymce = $set['tinymce'] && user_can_richedit();
     self::$this_quicktags = (bool) $set['quicktags'];
     if (self::$this_tinymce) {
         self::$has_tinymce = true;
     }
     if (self::$this_quicktags) {
         self::$has_quicktags = true;
     }
     return $set;
 }
Esempio n. 5
0
	public static function parse_settings($editor_id, $settings) {
		$set = wp_parse_args( $settings,  array(
			'wpautop' => true, // use wpautop?
			'media_buttons' => true, // show insert/upload button(s)
			'textarea_name' => $editor_id, // set the textarea name to something different, square brackets [] can be used here
			'textarea_rows' => 20,
			'tabindex' => '',
			'tabfocus_elements' => ':prev,:next', // the previous and next element ID to move the focus to when pressing the Tab key in TinyMCE
			'editor_css' => '', // intended for extra styles for both visual and Text editors buttons, needs to include the <style> tags, can use "scoped".
			'editor_class' => '', // add extra class(es) to the editor textarea
			'teeny' => false, // output the minimal editor config used in Press This
			'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css)
			'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
			'quicktags' => true // load Quicktags, can be used to pass settings directly to Quicktags using an array()
		) );

		self::$this_tinymce = ( $set['tinymce'] && user_can_richedit() );
		self::$this_quicktags = (bool) $set['quicktags'];

		if ( self::$this_tinymce )
			self::$has_tinymce = true;

		if ( self::$this_quicktags )
			self::$has_quicktags = true;

		if ( empty( $set['editor_height'] ) )
			return $set;

		if ( 'content' === $editor_id ) {
			// A cookie (set when a user resizes the editor) overrides the height.
			$cookie = (int) get_user_setting( 'ed_size' );

			// Upgrade an old TinyMCE cookie if it is still around, and the new one isn't.
			if ( ! $cookie && isset( $_COOKIE['TinyMCE_content_size'] ) ) {
				parse_str( $_COOKIE['TinyMCE_content_size'], $cookie );
 				$cookie = $cookie['ch'];
			}

			if ( $cookie )
				$set['editor_height'] = $cookie;
		}

		if ( $set['editor_height'] < 50 )
			$set['editor_height'] = 50;
		elseif ( $set['editor_height'] > 5000 )
			$set['editor_height'] = 5000;

		return $set;
	}
Esempio n. 6
0
 /**
  * Parse default arguments for the editor instance.
  *
  * @static
  * @param string $editor_id ID for the current editor instance.
  * @param array  $settings {
  *     Array of editor arguments.
  *
  *     @type bool       $wpautop           Whether to use wpautop(). Default true.
  *     @type bool       $media_buttons     Whether to show the Add Media/other media buttons.
  *     @type string     $default_editor    When both TinyMCE and Quicktags are used, set which
  *                                         editor is shown on page load. Default empty.
  *     @type bool       $drag_drop_upload  Whether to enable drag & drop on the editor uploading. Default false.
  *                                         Requires the media modal.
  *     @type string     $textarea_name     Give the textarea a unique name here. Square brackets
  *                                         can be used here. Default $editor_id.
  *     @type int        $textarea_rows     Number rows in the editor textarea. Default 20.
  *     @type string|int $tabindex          Tabindex value to use. Default empty.
  *     @type string     $tabfocus_elements The previous and next element ID to move the focus to
  *                                         when pressing the Tab key in TinyMCE. Default ':prev,:next'.
  *     @type string     $editor_css        Intended for extra styles for both Visual and Text editors.
  *                                         Should include `<style>` tags, and can use "scoped". Default empty.
  *     @type string     $editor_class      Extra classes to add to the editor textarea element. Default empty.
  *     @type bool       $teeny             Whether to output the minimal editor config. Examples include
  *                                         Press This and the Comment editor. Default false.
  *     @type bool       $dfw               Deprecated in 4.1. Since 4.3 used only to enqueue wp-fullscreen-stub.js
  *                                         for backward compatibility.
  *     @type bool|array $tinymce           Whether to load TinyMCE. Can be used to pass settings directly to
  *                                         TinyMCE using an array. Default true.
  *     @type bool|array $quicktags         Whether to load Quicktags. Can be used to pass settings directly to
  *                                         Quicktags using an array. Default true.
  * }
  * @return array Parsed arguments array.
  */
 public static function parse_settings($editor_id, $settings)
 {
     /**
      * Filters the wp_editor() settings.
      *
      * @since 4.0.0
      *
      * @see _WP_Editors()::parse_settings()
      *
      * @param array  $settings  Array of editor arguments.
      * @param string $editor_id ID for the current editor instance.
      */
     $settings = apply_filters('wp_editor_settings', $settings, $editor_id);
     $set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'default_editor' => '', 'drag_drop_upload' => false, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, '_content_editor_dfw' => false, 'tinymce' => true, 'quicktags' => true));
     self::$this_tinymce = $set['tinymce'] && user_can_richedit();
     if (self::$this_tinymce) {
         if (false !== strpos($editor_id, '[')) {
             self::$this_tinymce = false;
             _deprecated_argument('wp_editor()', '3.9', 'TinyMCE editor IDs cannot have brackets.');
         }
     }
     self::$this_quicktags = (bool) $set['quicktags'];
     if (self::$this_tinymce) {
         self::$has_tinymce = true;
     }
     if (self::$this_quicktags) {
         self::$has_quicktags = true;
     }
     if ($set['dfw']) {
         self::$old_dfw_compat = true;
     }
     if (empty($set['editor_height'])) {
         return $set;
     }
     if ('content' === $editor_id && empty($set['tinymce']['wp_autoresize_on'])) {
         // A cookie (set when a user resizes the editor) overrides the height.
         $cookie = (int) get_user_setting('ed_size');
         if ($cookie) {
             $set['editor_height'] = $cookie;
         }
     }
     if ($set['editor_height'] < 50) {
         $set['editor_height'] = 50;
     } elseif ($set['editor_height'] > 5000) {
         $set['editor_height'] = 5000;
     }
     return $set;
 }