Changeset 42343 for trunk/src/wp-admin/includes/misc.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/includes/misc.php (modified) (43 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/misc.php
r42199 r42343 15 15 */ 16 16 function got_mod_rewrite() { 17 $got_rewrite = apache_mod_loaded( 'mod_rewrite', true);17 $got_rewrite = apache_mod_loaded( 'mod_rewrite', true ); 18 18 19 19 /** … … 66 66 */ 67 67 function extract_from_markers( $filename, $marker ) { 68 $result = array ();68 $result = array(); 69 69 70 70 if ( ! file_exists( $filename ) ) { … … 137 137 138 138 // Split out the existing file into the preceding lines, and those that appear after the marker 139 $pre_lines = $post_lines = $existing_lines = array();139 $pre_lines = $post_lines = $existing_lines = array(); 140 140 $found_marker = $found_end_marker = false; 141 141 foreach ( $lines as $line ) { … … 165 165 166 166 // Generate the new file data 167 $new_file_data = implode( "\n", array_merge( 168 $pre_lines, 169 array( $start_marker ), 170 $insertion, 171 array( $end_marker ), 172 $post_lines 173 ) ); 167 $new_file_data = implode( 168 "\n", array_merge( 169 $pre_lines, 170 array( $start_marker ), 171 $insertion, 172 array( $end_marker ), 173 $post_lines 174 ) 175 ); 174 176 175 177 // Write to the start of the file, and truncate it to that length … … 197 199 */ 198 200 function save_mod_rewrite_rules() { 199 if ( is_multisite() ) 201 if ( is_multisite() ) { 200 202 return; 203 } 201 204 202 205 global $wp_rewrite; 203 206 204 $home_path = get_home_path();205 $htaccess_file = $home_path .'.htaccess';207 $home_path = get_home_path(); 208 $htaccess_file = $home_path . '.htaccess'; 206 209 207 210 /* … … 209 212 * and whether we have some rules. Else check for write access to the file. 210 213 */ 211 if ( (!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {214 if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || is_writable( $htaccess_file ) ) { 212 215 if ( got_mod_rewrite() ) { 213 216 $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() ); … … 229 232 * @return bool True if web.config was updated successfully 230 233 */ 231 function iis7_save_url_rewrite_rules() {232 if ( is_multisite() ) 234 function iis7_save_url_rewrite_rules() { 235 if ( is_multisite() ) { 233 236 return; 237 } 234 238 235 239 global $wp_rewrite; 236 240 237 $home_path = get_home_path();241 $home_path = get_home_path(); 238 242 $web_config_file = $home_path . 'web.config'; 239 243 240 244 // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP 241 if ( iis7_supports_permalinks() && ( ( ! file_exists( $web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) {242 $rule = $wp_rewrite->iis7_url_rewrite_rules( false, '', '');243 if ( ! empty( $rule) ) {244 return iis7_add_rewrite_rule( $web_config_file, $rule);245 if ( iis7_supports_permalinks() && ( ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable( $web_config_file ) ) ) { 246 $rule = $wp_rewrite->iis7_url_rewrite_rules( false, '', '' ); 247 if ( ! empty( $rule ) ) { 248 return iis7_add_rewrite_rule( $web_config_file, $rule ); 245 249 } else { 246 return iis7_delete_rewrite_rule( $web_config_file);250 return iis7_delete_rewrite_rule( $web_config_file ); 247 251 } 248 252 } … … 258 262 */ 259 263 function update_recently_edited( $file ) { 260 $oldfiles = (array ) get_option( 'recently_edited' );264 $oldfiles = (array) get_option( 'recently_edited' ); 261 265 if ( $oldfiles ) { 262 $oldfiles = array_reverse( $oldfiles );266 $oldfiles = array_reverse( $oldfiles ); 263 267 $oldfiles[] = $file; 264 $oldfiles = array_reverse( $oldfiles );265 $oldfiles = array_unique( $oldfiles );266 if ( 5 < count( $oldfiles ) )268 $oldfiles = array_reverse( $oldfiles ); 269 $oldfiles = array_unique( $oldfiles ); 270 if ( 5 < count( $oldfiles ) ) { 267 271 array_pop( $oldfiles ); 272 } 268 273 } else { 269 274 $oldfiles[] = $file; … … 284 289 $tree_list = array(); 285 290 foreach ( $allowed_files as $file_name => $absolute_filename ) { 286 $list = explode( '/', $file_name );291 $list = explode( '/', $file_name ); 287 292 $last_dir = &$tree_list; 288 293 foreach ( $list as $dir ) { … … 310 315 if ( is_array( $tree ) ) { 311 316 $index = 0; 312 $size = count( $tree );317 $size = count( $tree ); 313 318 foreach ( $tree as $label => $theme_file ) : 314 319 $index++; … … 329 334 } else { 330 335 $filename = $tree; 331 $url = add_query_arg(336 $url = add_query_arg( 332 337 array( 333 'file' => rawurlencode( $tree ),338 'file' => rawurlencode( $tree ), 334 339 'theme' => rawurlencode( $stylesheet ), 335 340 ), … … 373 378 $tree_list = array(); 374 379 foreach ( $plugin_editable_files as $plugin_file ) { 375 $list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) );380 $list = explode( '/', preg_replace( '#^.+?/#', '', $plugin_file ) ); 376 381 $last_dir = &$tree_list; 377 382 foreach ( $list as $dir ) { … … 399 404 if ( is_array( $tree ) ) { 400 405 $index = 0; 401 $size = count( $tree );406 $size = count( $tree ); 402 407 foreach ( $tree as $label => $plugin_file ) : 403 408 $index++; … … 419 424 $url = add_query_arg( 420 425 array( 421 'file' => rawurlencode( $tree ),426 'file' => rawurlencode( $tree ), 422 427 'plugin' => rawurlencode( $plugin ), 423 428 ), … … 453 458 */ 454 459 function update_home_siteurl( $old_value, $value ) { 455 if ( wp_installing() ) 460 if ( wp_installing() ) { 456 461 return; 462 } 457 463 458 464 if ( is_multisite() && ms_is_switched() ) { … … 496 502 * @param string|WP_Error $message 497 503 */ 498 function show_message( $message) {499 if ( is_wp_error( $message) ){500 if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) 504 function show_message( $message ) { 505 if ( is_wp_error( $message ) ) { 506 if ( $message->get_error_data() && is_string( $message->get_error_data() ) ) { 501 507 $message = $message->get_error_message() . ': ' . $message->get_error_data(); 502 else508 } else { 503 509 $message = $message->get_error_message(); 510 } 504 511 } 505 512 echo "<p>$message</p>\n"; … … 515 522 */ 516 523 function wp_doc_link_parse( $content ) { 517 if ( ! is_string( $content ) || empty( $content ) )524 if ( ! is_string( $content ) || empty( $content ) ) { 518 525 return array(); 519 520 if ( !function_exists('token_get_all') ) 526 } 527 528 if ( ! function_exists( 'token_get_all' ) ) { 521 529 return array(); 522 523 $tokens = token_get_all( $content ); 524 $count = count( $tokens ); 525 $functions = array(); 530 } 531 532 $tokens = token_get_all( $content ); 533 $count = count( $tokens ); 534 $functions = array(); 526 535 $ignore_functions = array(); 527 536 for ( $t = 0; $t < $count - 2; $t++ ) { … … 533 542 // If it's a function or class defined locally, there's not going to be any docs available 534 543 if ( ( isset( $tokens[ $t - 2 ][1] ) && in_array( $tokens[ $t - 2 ][1], array( 'function', 'class' ) ) ) || ( isset( $tokens[ $t - 2 ][0] ) && T_OBJECT_OPERATOR == $tokens[ $t - 1 ][0] ) ) { 535 $ignore_functions[] = $tokens[ $t][1];544 $ignore_functions[] = $tokens[ $t ][1]; 536 545 } 537 546 // Add this to our stack of unique references 538 $functions[] = $tokens[ $t][1];547 $functions[] = $tokens[ $t ][1]; 539 548 } 540 549 } … … 556 565 $out = array(); 557 566 foreach ( $functions as $function ) { 558 if ( in_array( $function, $ignore_functions ) ) 567 if ( in_array( $function, $ignore_functions ) ) { 559 568 continue; 569 } 560 570 $out[] = $function; 561 571 } … … 571 581 function set_screen_options() { 572 582 573 if ( isset( $_POST['wp_screen_options']) && is_array($_POST['wp_screen_options']) ) {583 if ( isset( $_POST['wp_screen_options'] ) && is_array( $_POST['wp_screen_options'] ) ) { 574 584 check_admin_referer( 'screen-options-nonce', 'screenoptionnonce' ); 575 585 576 if ( ! $user = wp_get_current_user() )586 if ( ! $user = wp_get_current_user() ) { 577 587 return; 588 } 578 589 $option = $_POST['wp_screen_options']['option']; 579 $value = $_POST['wp_screen_options']['value'];580 581 if ( $option != sanitize_key( $option ) ) 590 $value = $_POST['wp_screen_options']['value']; 591 592 if ( $option != sanitize_key( $option ) ) { 582 593 return; 594 } 583 595 584 596 $map_option = $option; 585 $type = str_replace('edit_', '', $map_option);586 $type = str_replace('_per_page', '', $type);587 if ( in_array( $type, get_taxonomies() ) ) 597 $type = str_replace( 'edit_', '', $map_option ); 598 $type = str_replace( '_per_page', '', $type ); 599 if ( in_array( $type, get_taxonomies() ) ) { 588 600 $map_option = 'edit_tags_per_page'; 589 elseif ( in_array( $type, get_post_types() ) )601 } elseif ( in_array( $type, get_post_types() ) ) { 590 602 $map_option = 'edit_per_page'; 591 else 592 $option = str_replace('-', '_', $option); 603 } else { 604 $option = str_replace( '-', '_', $option ); 605 } 593 606 594 607 switch ( $map_option ) { … … 599 612 case 'edit_tags_per_page': 600 613 case 'plugins_per_page': 601 // Network admin614 // Network admin 602 615 case 'sites_network_per_page': 603 616 case 'users_network_per_page': … … 607 620 case 'site_themes_network_per_page': 608 621 $value = (int) $value; 609 if ( $value < 1 || $value > 999 ) 622 if ( $value < 1 || $value > 999 ) { 610 623 return; 624 } 611 625 break; 612 626 default: 613 614 627 /** 615 628 * Filters a screen option value before it is set. … … 630 643 $value = apply_filters( 'set-screen-option', false, $option, $value ); 631 644 632 if ( false === $value ) 645 if ( false === $value ) { 633 646 return; 647 } 634 648 break; 635 649 } 636 650 637 update_user_meta( $user->ID, $option, $value);651 update_user_meta( $user->ID, $option, $value ); 638 652 639 653 $url = remove_query_arg( array( 'pagenum', 'apage', 'paged' ), wp_get_referer() ); … … 655 669 * @param string $filename The file path to the configuration file 656 670 */ 657 function iis7_rewrite_rule_exists( $filename) {658 if ( ! file_exists( $filename) )671 function iis7_rewrite_rule_exists( $filename ) { 672 if ( ! file_exists( $filename ) ) { 659 673 return false; 674 } 660 675 if ( ! class_exists( 'DOMDocument', false ) ) { 661 676 return false; … … 663 678 664 679 $doc = new DOMDocument(); 665 if ( $doc->load( $filename) === false )680 if ( $doc->load( $filename ) === false ) { 666 681 return false; 667 $xpath = new DOMXPath($doc); 668 $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]'); 669 if ( $rules->length == 0 ) 682 } 683 $xpath = new DOMXPath( $doc ); 684 $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' ); 685 if ( $rules->length == 0 ) { 670 686 return false; 671 else687 } else { 672 688 return true; 689 } 673 690 } 674 691 … … 681 698 * @return bool 682 699 */ 683 function iis7_delete_rewrite_rule( $filename) {700 function iis7_delete_rewrite_rule( $filename ) { 684 701 // If configuration file does not exist then rules also do not exist so there is nothing to delete 685 if ( ! file_exists( $filename) )702 if ( ! file_exists( $filename ) ) { 686 703 return true; 704 } 687 705 688 706 if ( ! class_exists( 'DOMDocument', false ) ) { … … 690 708 } 691 709 692 $doc = new DOMDocument();710 $doc = new DOMDocument(); 693 711 $doc->preserveWhiteSpace = false; 694 712 695 if ( $doc -> load($filename) === false )713 if ( $doc->load( $filename ) === false ) { 696 714 return false; 697 $xpath = new DOMXPath($doc); 698 $rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]'); 715 } 716 $xpath = new DOMXPath( $doc ); 717 $rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' ); 699 718 if ( $rules->length > 0 ) { 700 $child = $rules->item(0);719 $child = $rules->item( 0 ); 701 720 $parent = $child->parentNode; 702 $parent->removeChild( $child);721 $parent->removeChild( $child ); 703 722 $doc->formatOutput = true; 704 saveDomDocument( $doc, $filename);723 saveDomDocument( $doc, $filename ); 705 724 } 706 725 return true; … … 716 735 * @return bool 717 736 */ 718 function iis7_add_rewrite_rule( $filename, $rewrite_rule) {737 function iis7_add_rewrite_rule( $filename, $rewrite_rule ) { 719 738 if ( ! class_exists( 'DOMDocument', false ) ) { 720 739 return false; … … 722 741 723 742 // If configuration file does not exist then we create one. 724 if ( ! file_exists( $filename) ) {725 $fp = fopen( $filename, 'w' );726 fwrite( $fp, '<configuration/>');727 fclose( $fp);728 } 729 730 $doc = new DOMDocument();743 if ( ! file_exists( $filename ) ) { 744 $fp = fopen( $filename, 'w' ); 745 fwrite( $fp, '<configuration/>' ); 746 fclose( $fp ); 747 } 748 749 $doc = new DOMDocument(); 731 750 $doc->preserveWhiteSpace = false; 732 751 733 if ( $doc->load( $filename) === false )752 if ( $doc->load( $filename ) === false ) { 734 753 return false; 735 736 $xpath = new DOMXPath($doc); 754 } 755 756 $xpath = new DOMXPath( $doc ); 737 757 738 758 // First check if the rule already exists as in that case there is no need to re-add it 739 $wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');740 if ( $wordpress_rules->length > 0 ) 759 $wordpress_rules = $xpath->query( '/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]' ); 760 if ( $wordpress_rules->length > 0 ) { 741 761 return true; 762 } 742 763 743 764 // Check the XPath to the rewrite rule and create XML nodes if they do not exist 744 $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules');765 $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite/rules' ); 745 766 if ( $xmlnodes->length > 0 ) { 746 $rules_node = $xmlnodes->item( 0);767 $rules_node = $xmlnodes->item( 0 ); 747 768 } else { 748 $rules_node = $doc->createElement( 'rules');749 750 $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite');769 $rules_node = $doc->createElement( 'rules' ); 770 771 $xmlnodes = $xpath->query( '/configuration/system.webServer/rewrite' ); 751 772 if ( $xmlnodes->length > 0 ) { 752 $rewrite_node = $xmlnodes->item( 0);753 $rewrite_node->appendChild( $rules_node);773 $rewrite_node = $xmlnodes->item( 0 ); 774 $rewrite_node->appendChild( $rules_node ); 754 775 } else { 755 $rewrite_node = $doc->createElement( 'rewrite');756 $rewrite_node->appendChild( $rules_node);757 758 $xmlnodes = $xpath->query( '/configuration/system.webServer');776 $rewrite_node = $doc->createElement( 'rewrite' ); 777 $rewrite_node->appendChild( $rules_node ); 778 779 $xmlnodes = $xpath->query( '/configuration/system.webServer' ); 759 780 if ( $xmlnodes->length > 0 ) { 760 $system_webServer_node = $xmlnodes->item( 0);761 $system_webServer_node->appendChild( $rewrite_node);781 $system_webServer_node = $xmlnodes->item( 0 ); 782 $system_webServer_node->appendChild( $rewrite_node ); 762 783 } else { 763 $system_webServer_node = $doc->createElement( 'system.webServer');764 $system_webServer_node->appendChild( $rewrite_node);765 766 $xmlnodes = $xpath->query( '/configuration');784 $system_webServer_node = $doc->createElement( 'system.webServer' ); 785 $system_webServer_node->appendChild( $rewrite_node ); 786 787 $xmlnodes = $xpath->query( '/configuration' ); 767 788 if ( $xmlnodes->length > 0 ) { 768 $config_node = $xmlnodes->item( 0);769 $config_node->appendChild( $system_webServer_node);789 $config_node = $xmlnodes->item( 0 ); 790 $config_node->appendChild( $system_webServer_node ); 770 791 } else { 771 $config_node = $doc->createElement( 'configuration');772 $doc->appendChild( $config_node);773 $config_node->appendChild( $system_webServer_node);792 $config_node = $doc->createElement( 'configuration' ); 793 $doc->appendChild( $config_node ); 794 $config_node->appendChild( $system_webServer_node ); 774 795 } 775 796 } … … 778 799 779 800 $rule_fragment = $doc->createDocumentFragment(); 780 $rule_fragment->appendXML( $rewrite_rule);781 $rules_node->appendChild( $rule_fragment);782 783 $doc->encoding = "UTF-8";801 $rule_fragment->appendXML( $rewrite_rule ); 802 $rules_node->appendChild( $rule_fragment ); 803 804 $doc->encoding = 'UTF-8'; 784 805 $doc->formatOutput = true; 785 saveDomDocument( $doc, $filename);806 saveDomDocument( $doc, $filename ); 786 807 787 808 return true; … … 796 817 * @param string $filename 797 818 */ 798 function saveDomDocument( $doc, $filename) {819 function saveDomDocument( $doc, $filename ) { 799 820 $config = $doc->saveXML(); 800 $config = preg_replace( "/([^\r])\n/", "$1\r\n", $config);801 $fp = fopen($filename, 'w');802 fwrite( $fp, $config);803 fclose( $fp);821 $config = preg_replace( "/([^\r])\n/", "$1\r\n", $config ); 822 $fp = fopen( $filename, 'w' ); 823 fwrite( $fp, $config ); 824 fclose( $fp ); 804 825 } 805 826 … … 820 841 if ( isset( $_wp_admin_css_colors['fresh'] ) ) { 821 842 // Set Default ('fresh') and Light should go first. 822 $_wp_admin_css_colors = array_filter( array_merge( array( 'fresh' => '', 'light' => '' ), $_wp_admin_css_colors ) ); 843 $_wp_admin_css_colors = array_filter( 844 array_merge( 845 array( 846 'fresh' => '', 847 'light' => '', 848 ), $_wp_admin_css_colors 849 ) 850 ); 823 851 } 824 852 … … 866 894 867 895 /** 868 *869 896 * @global array $_wp_admin_css_colors 870 897 */ … … 885 912 } else { 886 913 // Fall back to the default set of icon colors if the default scheme is missing. 887 $icon_colors = array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' ); 914 $icon_colors = array( 915 'base' => '#82878c', 916 'focus' => '#00a0d2', 917 'current' => '#fff', 918 ); 888 919 } 889 920 … … 917 948 if ( array_key_exists( 'wp-check-locked-posts', $data ) && is_array( $data['wp-check-locked-posts'] ) ) { 918 949 foreach ( $data['wp-check-locked-posts'] as $key ) { 919 if ( ! $post_id = absint( substr( $key, 5 ) ) ) 950 if ( ! $post_id = absint( substr( $key, 5 ) ) ) { 920 951 continue; 952 } 921 953 922 954 if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) && current_user_can( 'edit_post', $post_id ) ) { 923 955 $send = array( 'text' => sprintf( __( '%s is currently editing' ), $user->display_name ) ); 924 956 925 if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) 957 if ( ( $avatar = get_avatar( $user->ID, 18 ) ) && preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { 926 958 $send['avatar_src'] = $matches[1]; 927 928 $checked[$key] = $send; 959 } 960 961 $checked[ $key ] = $send; 929 962 } 930 963 } 931 964 } 932 965 933 if ( ! empty( $checked ) ) 966 if ( ! empty( $checked ) ) { 934 967 $response['wp-check-locked-posts'] = $checked; 968 } 935 969 936 970 return $response; … … 950 984 if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) { 951 985 $received = $data['wp-refresh-post-lock']; 952 $send = array();953 954 if ( ! $post_id = absint( $received['post_id'] ) ) 986 $send = array(); 987 988 if ( ! $post_id = absint( $received['post_id'] ) ) { 955 989 return $response; 956 957 if ( ! current_user_can('edit_post', $post_id) ) 990 } 991 992 if ( ! current_user_can( 'edit_post', $post_id ) ) { 958 993 return $response; 994 } 959 995 960 996 if ( ( $user_id = wp_check_post_lock( $post_id ) ) && ( $user = get_userdata( $user_id ) ) ) { 961 997 $error = array( 962 'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ) 998 'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ), 963 999 ); 964 1000 965 1001 if ( $avatar = get_avatar( $user->ID, 64 ) ) { 966 if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) 1002 if ( preg_match( "|src='([^']+)'|", $avatar, $matches ) ) { 967 1003 $error['avatar_src'] = $matches[1]; 1004 } 968 1005 } 969 1006 970 1007 $send['lock_error'] = $error; 971 1008 } else { 972 if ( $new_lock = wp_set_post_lock( $post_id ) ) 1009 if ( $new_lock = wp_set_post_lock( $post_id ) ) { 973 1010 $send['new_lock'] = implode( ':', $new_lock ); 1011 } 974 1012 } 975 1013 … … 992 1030 function wp_refresh_post_nonces( $response, $data, $screen_id ) { 993 1031 if ( array_key_exists( 'wp-refresh-post-nonces', $data ) ) { 994 $received = $data['wp-refresh-post-nonces'];1032 $received = $data['wp-refresh-post-nonces']; 995 1033 $response['wp-refresh-post-nonces'] = array( 'check' => 1 ); 996 1034 … … 1004 1042 1005 1043 $response['wp-refresh-post-nonces'] = array( 1006 'replace' => array(1007 'getpermalinknonce' => wp_create_nonce('getpermalink'),1008 'samplepermalinknonce' => wp_create_nonce( 'samplepermalink'),1009 'closedpostboxesnonce' => wp_create_nonce( 'closedpostboxes'),1010 '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ),1011 '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ),1044 'replace' => array( 1045 'getpermalinknonce' => wp_create_nonce( 'getpermalink' ), 1046 'samplepermalinknonce' => wp_create_nonce( 'samplepermalink' ), 1047 'closedpostboxesnonce' => wp_create_nonce( 'closedpostboxes' ), 1048 '_ajax_linking_nonce' => wp_create_nonce( 'internal-linking' ), 1049 '_wpnonce' => wp_create_nonce( 'update-post_' . $post_id ), 1012 1050 ), 1013 1051 'heartbeatNonce' => wp_create_nonce( 'heartbeat-nonce' ), … … 1052 1090 1053 1091 if ( is_wp_error( $saved ) ) { 1054 $response['wp_autosave'] = array( 'success' => false, 'message' => $saved->get_error_message() ); 1092 $response['wp_autosave'] = array( 1093 'success' => false, 1094 'message' => $saved->get_error_message(), 1095 ); 1055 1096 } elseif ( empty( $saved ) ) { 1056 $response['wp_autosave'] = array( 'success' => false, 'message' => __( 'Error while saving.' ) ); 1097 $response['wp_autosave'] = array( 1098 'success' => false, 1099 'message' => __( 'Error while saving.' ), 1100 ); 1057 1101 } else { 1058 1102 /* translators: draft saved date format, see https://secure.php.net/date */ 1059 1103 $draft_saved_date_format = __( 'g:i:s a' ); 1060 1104 /* translators: %s: date and time */ 1061 $response['wp_autosave'] = array( 'success' => true, 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ) ); 1105 $response['wp_autosave'] = array( 1106 'success' => true, 1107 'message' => sprintf( __( 'Draft saved at %s.' ), date_i18n( $draft_saved_date_format ) ), 1108 ); 1062 1109 } 1063 1110 } … … 1149 1196 } 1150 1197 1151 $hash = md5( $value . time() . mt_rand() );1198 $hash = md5( $value . time() . mt_rand() ); 1152 1199 $new_admin_email = array( 1153 1200 'hash' => $hash, … … 1159 1206 1160 1207 /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ 1161 $email_text = __( 'Howdy ###USERNAME###, 1208 $email_text = __( 1209 'Howdy ###USERNAME###, 1162 1210 1163 1211 You recently requested to have the administration email address on … … 1174 1222 Regards, 1175 1223 All at ###SITENAME### 1176 ###SITEURL###' ); 1224 ###SITEURL###' 1225 ); 1177 1226 1178 1227 /** … … 1200 1249 1201 1250 $current_user = wp_get_current_user(); 1202 $content = str_replace( '###USERNAME###', $current_user->user_login, $content );1203 $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );1204 $content = str_replace( '###EMAIL###', $value, $content );1205 $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );1206 $content = str_replace( '###SITEURL###', home_url(), $content );1251 $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); 1252 $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content ); 1253 $content = str_replace( '###EMAIL###', $value, $content ); 1254 $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content ); 1255 $content = str_replace( '###SITEURL###', home_url(), $content ); 1207 1256 1208 1257 wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ), $content );
Note: See TracChangeset
for help on using the changeset viewer.