Changeset 8784
- Timestamp:
- 08/31/2008 06:34:43 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-form-advanced.php
r8767 r8784 487 487 <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea"> 488 488 489 <div id="add-media-button"><a href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div>489 <div id="add-media-button"><a id="add-media-link" href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div> 490 490 491 491 <h3><?php _e('Post') ?></h3> -
trunk/wp-admin/edit-page-form.php
r8767 r8784 359 359 <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea"> 360 360 361 <div id="add-media-button"><a href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div>361 <div id="add-media-button"><a id="add-media-link" href="<?php echo clean_url( admin_url( 'media-upload.php?post_id=' . ( $post_ID ? $post_ID : $temp_ID ) . '&type=image&TB_iframe=true' ) ); ?>" class="thickbox button"><?php _e( 'Add Media' ); ?></a></div> 362 362 363 363 <h3><?php _e('Page') ?></h3> -
trunk/wp-admin/js/editor.js
r8720 r8784 1 wpEditorInit = function() {2 var H;3 4 // Activate tinyMCE if it's the user's default editor5 if ( ( 'undefined' == typeof wpTinyMCEConfig ) || 'tinymce' == wpTinyMCEConfig.defaultEditor ) {6 try { document.getElementById('editorcontainer').style.padding = '0px'; } catch(e){};7 try { document.getElementById("quicktags").style.display = "none"; } catch(e){};8 tinyMCE.execCommand("mceAddControl", false, "content");9 } else {10 if ( H = tinymce.util.Cookie.getHash("TinyMCE_content_size") )11 try { document.getElementById('content').style.height = H.ch - 30 + 'px'; } catch(e){};12 }13 };14 1 15 2 switchEditors = { 16 3 4 I : function(e) { 5 return document.getElementById(e); 6 }, 7 8 edInit : function() { 9 var h = tinymce.util.Cookie.getHash("TinyMCE_content_size"), H = this.I('edButtonHTML'), P = this.I('edButtonPreview'); 10 11 // Activate TinyMCE if it's the user's default editor 12 if ( getUserSetting( 'editor', 'tinymce' ) == 'tinymce' ) { 13 try { P.onclick = ''; P.className = 'active'; } catch(e){}; 14 try { this.I('editorcontainer').style.padding = '0px'; } catch(e){}; 15 try { this.I("quicktags").style.display = "none"; } catch(e){}; 16 tinyMCE.execCommand("mceAddControl", false, "content"); 17 } else { 18 try { H.onclick = ''; H.className = 'active'; } catch(e){}; 19 if ( h ) 20 try { this.I('content').style.height = h.ch - 30 + 'px'; } catch(e){}; 21 } 22 }, 23 17 24 saveCallback : function(el, content, body) { 18 25 19 document.getElementById(el).style.color = '#fff';26 this.I(el).style.color = '#fff'; 20 27 if ( tinyMCE.activeEditor.isHidden() ) 21 content = document.getElementById(el).value;28 content = this.I(el).value; 22 29 else 23 30 content = this.pre_wpautop(content); … … 85 92 go : function(id) { 86 93 var ed = tinyMCE.get(id); 87 var qt = document.getElementById('quicktags');88 var H = document.getElementById('edButtonHTML');89 var P = document.getElementById('edButtonPreview');90 var ta = document.getElementById(id);91 var ec = document.getElementById('editorcontainer');94 var qt = this.I('quicktags'); 95 var H = this.I('edButtonHTML'); 96 var P = this.I('edButtonPreview'); 97 var ta = this.I(id); 98 var ec = (ta.parentNode && ta.parentNode.nodeName == 'DIV') ? ta.parentNode : ''; 92 99 93 100 if ( ! ed || ed.isHidden() ) { … … 98 105 99 106 qt.style.display = 'none'; 100 ec.style.padding = '0px';101 107 ta.style.padding = '0px'; 108 if ( ec ) 109 ec.style.padding = '0px'; 102 110 103 111 ta.value = this.wpautop(ta.value); … … 106 114 else tinyMCE.execCommand("mceAddControl", false, id); 107 115 108 this.wpSetDefaultEditor('tinymce');116 setUserSetting( 'editor', 'tinymce' ); 109 117 } else { 110 118 this.edToggle(H, P); … … 116 124 if ( tinymce.isIE6 ) { 117 125 ta.style.width = '98%'; 118 ec.style.padding = '0px'; 126 if ( ec ) 127 ec.style.padding = '0px'; 119 128 ta.style.padding = '6px'; 120 129 } else { 121 130 ta.style.width = '100%'; 122 ec.style.padding = '6px'; 131 if ( ec ) 132 ec.style.padding = '6px'; 123 133 } 124 134 125 135 ta.style.color = ''; 126 this.wpSetDefaultEditor('html');136 setUserSetting( 'editor', 'html' ); 127 137 } 128 138 }, … … 134 144 B.onclick = A.onclick; 135 145 A.onclick = null; 136 },137 138 wpSetDefaultEditor : function(editor) {139 try {140 editor = escape( editor.toString() );141 } catch(err) {142 editor = 'tinymce';143 }144 145 var userID = document.getElementById('user-id');146 var date = new Date();147 date.setTime(date.getTime()+(10*365*24*60*60*1000));148 document.cookie = "wordpress_editor_" + userID.value + "=" + editor + "; expires=" + date.toGMTString();149 146 }, 150 147 -
trunk/wp-includes/default-filters.php
r8213 r8784 193 193 add_action('edit_post', 'wp_check_for_changed_slugs'); 194 194 add_action('edit_form_advanced', 'wp_remember_old_slug'); 195 add_action('init', 'wp_user_settings', 9); 195 196 196 197 ?> -
trunk/wp-includes/functions.php
r8770 r8784 642 642 } 643 643 return true; 644 } 645 646 /** 647 * Saves and restores user interface settings stored in a cookie. 648 * 649 * @package WordPress 650 * @subpackage Option 651 * @since 2.7.0 652 * 653 * Checks if the current user-settings cookie is updated and stores it. 654 * When no cookie exists (different browser used), adds the last saved cookie restoring the settings. 655 */ 656 function wp_user_settings() { 657 658 if ( ! is_admin() ) 659 return; 660 661 if ( ! $user = wp_get_current_user() ) 662 return; 663 664 $settings = get_user_option( 'user-settings', $user->ID ); 665 666 if ( isset($_COOKIE['wp-settings-'.$user->ID]) ) { 667 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-'.$user->ID] ); 668 669 if ( ! empty($cookie) && strpos($cookie, '=') ) { 670 if ( $cookie == $settings ) 671 return; 672 673 $last_time = (int) get_user_option( 'user-settings-time', $user->ID ); 674 $saved = isset($_COOKIE['wp-settings-time-'.$user->ID]) ? preg_replace( '/[^0-9]/', '', $_COOKIE['wp-settings-time-'.$user->ID] ) : 0; 675 676 if ( $saved > $last_time ) { 677 update_user_option( $user->ID, 'user-settings', $cookie ); 678 update_user_option( $user->ID, 'user-settings-time', time() - 5 ); 679 return; 680 } 681 } 682 } 683 684 setcookie('wp-settings-'.$user->ID, $settings, time() + 31536000, SITECOOKIEPATH); 685 setcookie('wp-settings-time-'.$user->ID, time(), time() + 31536000, SITECOOKIEPATH); 686 } 687 688 /** 689 * Retrieve user interface setting value based on setting name. 690 * 691 * @package WordPress 692 * @subpackage Option 693 * @since 2.7.0 694 * 695 * @param string $name The name of the setting. 696 * @param string $default Optional default value to return when $name is not set. 697 * @return mixed the last saved user setting or the default value/false if it doesn't exist. 698 */ 699 function get_user_setting( $name, $default = false ) { 700 701 $arr = get_all_user_settings(); 702 703 return isset($arr[$name]) ? $arr[$name] : $default; 704 } 705 706 /** 707 * Delete user interface settings. 708 * 709 * @package WordPress 710 * @subpackage Option 711 * @since 2.7.0 712 * 713 * Deleting settings would reset them to the defaults. 714 * 715 * @param mixed $names The name or array of names of the setting to be deleted. 716 */ 717 function delete_user_setting( $names ) { 718 global $current_user; 719 720 $arr = get_all_user_settings(); 721 $names = (array) $names; 722 723 foreach ( $names as $name ) { 724 if ( isset($arr[$name]) ) { 725 unset($arr[$name]); 726 $settings = ''; 727 } 728 } 729 730 if ( isset($settings) ) { 731 foreach ( $arr as $k => $v ) 732 $settings .= $k . '=' . $v . '&'; 733 734 $settings = rtrim($settings, '&'); 735 736 update_user_option( $current_user->ID, 'user-settings', $settings ); 737 setcookie('wp-settings-'.$current_user->ID, $settings, time() + 31536000, SITECOOKIEPATH); 738 } 739 } 740 741 /** 742 * Retrieve all user interface settings. 743 * 744 * @package WordPress 745 * @subpackage Option 746 * @since 2.7.0 747 * 748 * @return array the last saved user settings or empty array. 749 */ 750 function get_all_user_settings() { 751 if ( ! $user = wp_get_current_user() ) 752 return array(); 753 754 if ( isset($_COOKIE['wp-settings-'.$user->ID]) ) { 755 $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE['wp-settings-'.$user->ID] ); 756 757 if ( $cookie && strpos($cookie, '=') ) { // the '=' cannot be 1st char 758 parse_str($cookie, $arr); 759 return $arr; 760 } 761 } 762 763 return array(); 764 } 765 766 function delete_all_user_settings() { 767 if ( ! $user = wp_get_current_user() ) 768 return; 769 770 delete_usermeta( $user->ID, 'user-settings' ); 771 setcookie('wp-settings-'.$user->ID, ' ', time() - 31536000, SITECOOKIEPATH); 644 772 } 645 773 -
trunk/wp-includes/general-template.php
r8721 r8784 943 943 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults 944 944 if ( $user = wp_get_current_user() ) { // look for cookie 945 if ( isset($_COOKIE['wordpress_editor_' . $user->ID]) && in_array($_COOKIE['wordpress_editor_' . $user->ID], array('tinymce', 'html', 'test') ) )946 $r = $_COOKIE['wordpress_editor_' . $user->ID];945 $ed = get_user_setting('editor', 'tinymce'); 946 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r; 947 947 } 948 948 return apply_filters( 'wp_default_editor', $r ); // filter -
trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
r8260 r8784 15 15 var nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />'; 16 16 17 if ( tinymce.util.Cookie.get('kitchenSink') == '1' )17 if ( getUserSetting('hidetb', '0') == '1' ) 18 18 ed.settings.wordpress_adv_hidden = 0; 19 19 … … 45 45 46 46 ed.addCommand('WP_Adv', function() { 47 var id = ed.controlManager.get(tbId).id, cm = ed.controlManager, cook = tinymce.util.Cookie, date; 48 49 date = new Date(); 50 date.setTime(date.getTime()+(10*365*24*60*60*1000)); 47 var id = ed.controlManager.get(tbId).id, cm = ed.controlManager; 51 48 52 49 if (DOM.isHidden(id)) { … … 55 52 t._resizeIframe(ed, tbId, -28); 56 53 ed.settings.wordpress_adv_hidden = 0; 57 cook.set('kitchenSink', '1', date);54 setUserSetting('hidetb', '1'); 58 55 } else { 59 56 cm.setActive('wp_adv', 0); … … 61 58 t._resizeIframe(ed, tbId, 28); 62 59 ed.settings.wordpress_adv_hidden = 1; 63 cook.set('kitchenSink', '0', date);60 setUserSetting('hidetb', '0'); 64 61 } 65 62 }); … … 95 92 image : url + '/img/media.gif', 96 93 onclick : function() { 97 tb_show('', tinymce.DOM.get('add_media').href); 98 tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' ); 99 } 100 }); 101 94 var a = tinymce.DOM.get('add-media-link'); 95 if ( a ) { 96 tb_show('', a.href); 97 tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' ); 98 } 99 } 100 }); 101 /* 102 102 ed.addButton('add_image', { 103 103 title : 'wordpress.add_image', … … 126 126 } 127 127 }); 128 128 */ 129 129 // Add Media buttons to fullscreen 130 130 ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) { 131 131 if ( 'mceFullScreen' != cmd ) return; 132 132 if ( 'mce_fullscreen' != ed.id ) 133 ed.settings.theme_advanced_buttons1 += ',|,add_ image,add_video,add_audio,add_media';133 ed.settings.theme_advanced_buttons1 += ',|,add_media'; 134 134 }); 135 135 -
trunk/wp-includes/js/tinymce/tiny_mce_config.php
r8686 r8784 135 135 $initArray = array ( 136 136 'mode' => 'none', 137 'onpageload' => ' wpEditorInit',137 'onpageload' => 'switchEditors.edInit', 138 138 'width' => '100%', 139 139 'theme' => 'advanced', … … 215 215 if ( $disk_cache ) { 216 216 217 $cacheKey = apply_filters('tiny_mce_version', '20080 731');217 $cacheKey = apply_filters('tiny_mce_version', '20080830'); 218 218 219 219 foreach ( $initArray as $v ) -
trunk/wp-includes/script-loader.php
r8782 r8784 36 36 */ 37 37 function wp_default_scripts( &$scripts ) { 38 global $current_user; 39 38 40 if (!$guessurl = site_url()) 39 41 $guessurl = wp_guess_url(); 42 43 $userid = isset($current_user) ? $current_user->ID : 0; 40 44 $scripts->base_url = $guessurl; 41 45 $scripts->default_version = get_bloginfo( 'version' ); 42 46 43 $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery' ), '20080318' );47 $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery', 'user-settings'), '20080318' ); 44 48 $scripts->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' ); 45 49 … … 66 70 67 71 // Modify this version when tinyMCE plugins are changed. 68 $mce_version = apply_filters('tiny_mce_version', '20080 730');72 $mce_version = apply_filters('tiny_mce_version', '20080830'); 69 73 $scripts->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('editor_functions'), $mce_version ); 70 74 … … 243 247 244 248 $scripts->add( 'farbtastic', '/wp-admin/js/farbtastic.js', array('jquery'), '1.2' ); 249 250 $scripts->add( 'user-settings', '/wp-admin/js/user-settings.js', array(), '20080829' ); 251 $scripts->localize( 'user-settings', 'userSettings', array( 252 'url' => SITECOOKIEPATH, 253 'uid' => $userid, 254 'time' => time() 255 ) ); 245 256 } 246 257 } … … 335 346 */ 336 347 function wp_just_in_time_script_localization() { 337 wp_localize_script( 'tiny_mce', 'wpTinyMCEConfig', array( 'defaultEditor' => wp_default_editor() ) );338 348 wp_localize_script( 'autosave', 'autosaveL10n', array( 339 349 'autosaveInterval' => AUTOSAVE_INTERVAL,
Note: See TracChangeset
for help on using the changeset viewer.