Changeset 18498 for trunk/wp-includes/general-template.php
- Timestamp:
- 08/03/2011 10:19:00 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/general-template.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/general-template.php
r18461 r18498 1751 1751 1752 1752 /** 1753 * Find out which editor should be displayed by default. 1754 * 1755 * Works out which of the two editors to display as the current editor for a 1756 * user. 1757 * 1758 * @since 2.5.0 1759 * 1760 * @return string Either 'tinymce', or 'html', or 'test' 1761 */ 1762 function wp_default_editor() { 1763 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults 1764 if ( $user = wp_get_current_user() ) { // look for cookie 1765 $ed = get_user_setting('editor', 'tinymce'); 1766 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; 1767 } 1768 return apply_filters( 'wp_default_editor', $r ); // filter 1769 } 1770 1771 /** 1772 * Display visual editor forms: TinyMCE, or HTML, or both. 1773 * 1774 * The amount of rows the text area will have for the content has to be between 1775 * 3 and 100 or will default at 12. There is only one option used for all users, 1776 * named 'default_post_edit_rows'. 1777 * 1778 * If the user can not use the rich editor (TinyMCE), then the switch button 1779 * will not be displayed. 1780 * 1781 * @since 2.1.0 1782 * 1783 * @param string $content Textarea content. 1784 * @param string $id Optional, default is 'content'. HTML ID attribute value. 1785 * @param string $prev_id Optional, default is 'title'. HTML ID name for switching back and forth between visual editors. 1786 * @param bool $media_buttons Optional, default is true. Whether to display media buttons. 1787 * @param int $tab_index Optional, default is 2. Tabindex for textarea element. 1788 */ 1789 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) { 1790 $rows = get_option('default_post_edit_rows'); 1791 if (($rows < 3) || ($rows > 100)) 1792 $rows = 12; 1793 1794 if ( !current_user_can( 'upload_files' ) ) 1795 $media_buttons = false; 1796 1797 $richedit = user_can_richedit(); 1798 $class = ''; 1799 1800 if ( $richedit || $media_buttons ) { ?> 1801 <div id="editor-toolbar"> 1802 <?php 1803 if ( $richedit ) { 1804 $wp_default_editor = wp_default_editor(); ?> 1805 <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div> 1806 <?php if ( 'html' == $wp_default_editor ) { 1807 add_filter('the_editor_content', 'wp_htmledit_pre'); ?> 1808 <a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a> 1809 <a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a> 1810 <?php } else { 1811 $class = " class='theEditor'"; 1812 add_filter('the_editor_content', 'wp_richedit_pre'); ?> 1813 <a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a> 1814 <a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a> 1815 <?php } 1816 } 1817 1818 if ( $media_buttons ) { ?> 1819 <div id="media-buttons" class="hide-if-no-js"> 1820 <?php do_action( 'media_buttons' ); ?> 1821 </div> 1822 <?php 1823 } ?> 1824 </div> 1825 <?php 1826 } 1827 ?> 1828 <div id="quicktags"><?php 1829 wp_print_scripts( 'quicktags' ); ?> 1830 <script type="text/javascript">edToolbar()</script> 1831 </div> 1832 1833 <?php 1834 $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n"); 1835 $the_editor_content = apply_filters('the_editor_content', $content); 1836 1837 printf($the_editor, $the_editor_content); 1838 1839 ?> 1840 <script type="text/javascript"> 1841 edCanvas = document.getElementById('<?php echo $id; ?>'); 1842 <?php if ( ! $extended ) { ?> jQuery('#ed_fullscreen, #ed_more').hide();<?php } ?> 1843 </script> 1844 <?php 1845 // queue scripts 1846 if ( $richedit ) 1847 add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 ); 1848 elseif ( $extended ) 1849 add_action( 'admin_print_footer_scripts', 'wp_quicktags', 25 ); 1850 1753 * Loads and initializes WP_Editor class if needed, passes the settings for an instance of the editor 1754 * 1755 * @see wp-includes/class-wp-editor.php 1756 * @since 3.3 1757 * 1758 * @param string $content Initial content for the editor. 1759 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. 1760 * @param array $settings See WP_Editor::editor(). 1761 */ 1762 function wp_editor( $content, $editor_id, $settings = array() ) { 1763 global $wp_editor; 1764 1765 if ( !is_a($wp_editor, 'WP_Editor') ) { 1766 require( ABSPATH . WPINC . '/class-wp-editor.php' ); 1767 $wp_editor = new WP_Editor; 1768 } 1769 1770 $wp_editor->editor($content, $editor_id, $settings); 1851 1771 } 1852 1772
Note: See TracChangeset
for help on using the changeset viewer.