WordPress.org

Make WordPress Core

Ticket #9751: php4.nag.patch

File php4.nag.patch, 3.8 KB (added by jorbin, 9 years ago)
  • htdocs/wordpresstrunk/wp-admin/includes/upgrade.php

     
    7576        $wp_rewrite->flush_rules();
    7677
    7778        wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
    78 
     79        wp_check_php_version();
    7980        wp_cache_flush();
    8081
    8182        return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password, 'password_message' => $message);
     
    268269                return;
    269270
    270271        wp_check_mysql_version();
     272        wp_check_php_version();
    271273        wp_cache_flush();
    272274        make_db_current_silent();
    273275        upgrade_all();
     
    16561658        }
    16571659}
    16581660
     1661         /**
     1662 * Checks if the current version of PHP is below the nag level and adds usermeta to use to display a notice if it is
     1663 *
     1664 * @since ???
     1665 * @see php_below_min_nag() for the nag message displayed and php_below_min_nag_handler() for the function that stops display of the nag message
     1666 *
     1667 */
     1668function wp_check_php_version(){
     1669        global $wp_php_min_version;
     1670        global $wpdb;
     1671        if (version_compare(PHP_VERSION, $wp_php_min_version, '<')) {
     1672                $users = $wpdb->get_results("SELECT ID from $wpdb->users");
     1673                foreach ( (array) $users as $a_user ) {
     1674                        $user = new WP_User($a_user->ID);
     1675                        if ( $user->has_cap('install_plugins') )
     1676                                update_usermeta($a_user->ID,'php_below_min_nag','true');
     1677                }
     1678        }
     1679}
    16591680?>
  • htdocs/wordpresstrunk/wp-includes/version.php

    
            
     
    3030 * @global string $manifest_version
    3131 */
    3232$manifest_version = '20090616';
     33
     34/**
     35 * Holds PHP min version to not nagged
     36 *
     37 * @global string $manifest_version
     38 */
     39$wp_php_min_version = '5.0.0';
     40
  • htdocs/wordpresstrunk/wp-admin/includes/user.php

     
    838838}
    839839
    840840/**
     841 * If the phpversion is below the min, display a nag until it goes away
     842 *
     843 * @since 2.9.0
     844 * @see wp_check_php_version() for the function that adds the nag on install and php_below_min_nag_handler() for the function that stops display of the nag message
     845 *
     846 */
     847
     848add_action('admin_notices', 'php_below_min_nag');
     849function php_below_min_nag() {
     850        global $user_ID;
     851        if ( ! get_usermeta($user_ID, 'php_below_min_nag') )
     852                return;
     853
     854        echo '<div class="error php_below_min_nag"><p>';
     855        printf(__("Notice: Your Webserver is currently using PHP version 4, which is no longer recieving security updates and will no longer be supported by WordPress in an upcoming version<br />
     856                          <a href='%1$s'>Learn more about this issue</a> | <a href='%2$s' id='php_below_min_nag-no'>I understand the issue and want you to stop informing me</a>"), 'http://codex.wordpress.org/Switching_to_PHP5', '?php_below_min_nag=0');
     857        echo '</p></div>';
     858}
     859
     860/**
     861 * Checks if the current version of PHP is below the nag level and adds usermeta to use to display a notice if it is
     862 *
     863 * @since 2.9.0
     864 * @see php_below_min_nag() for the nag message displayed and wp_check_php_version() for the function that adds the nag on install/upgrade
     865 *
     866 */
     867add_action('admin_init', 'php_below_min_nag_handler');
     868function php_below_min_nag_handler() {
     869        global $user_ID;
     870        if ( ! get_usermeta($user_ID, 'php_below_min_nag') ) //Short circuit it.
     871                return;
     872
     873        if  (isset($_GET['php_below_min_nag']) && '0' == $_GET['php_below_min_nag'])
     874                delete_usermeta($user_ID, 'php_below_min_nag', 'true');
     875
     876}
     877
     878/**
    841879 * Setup the default contact methods
    842880 *
    843881 * @access private