wordpress4.0.1源碼學習和摘錄--項目設定

來源:互聯網
上載者:User

標籤:style   blog   http   ar   io   color   sp   for   on   

1.靜態變數日期
define( ‘MINUTE_IN_SECONDS‘, 60 );define( ‘HOUR_IN_SECONDS‘,   60 * MINUTE_IN_SECONDS );define( ‘DAY_IN_SECONDS‘,    24 * HOUR_IN_SECONDS   );define( ‘WEEK_IN_SECONDS‘,    7 * DAY_IN_SECONDS    );define( ‘YEAR_IN_SECONDS‘,  365 * DAY_IN_SECONDS    );

2.禁止開啟magic quotes

@ini_set( ‘magic_quotes_runtime‘, 0 );@ini_set( ‘magic_quotes_sybase‘,  0 );

3.設定時區

date_default_timezone_set(‘Asia/Hong_Kong‘);

4.檢查是否在維護

function wp_maintenance() {    if ( !file_exists( ABSPATH . ‘.maintenance‘ ) || defined( ‘WP_INSTALLING‘ ) )        return;    global $upgrading;    include( ABSPATH . ‘.maintenance‘ );    // If the $upgrading timestamp is older than 10 minutes, don‘t die.    if ( ( time() - $upgrading ) >= 600 )        return;    if ( file_exists( WP_CONTENT_DIR . ‘/maintenance.php‘ ) ) {        require_once( WP_CONTENT_DIR . ‘/maintenance.php‘ );        die();    }    wp_load_translations_early();    $protocol = $_SERVER["SERVER_PROTOCOL"];    if ( ‘HTTP/1.1‘ != $protocol && ‘HTTP/1.0‘ != $protocol )        $protocol = ‘HTTP/1.0‘;    header( "$protocol 503 Service Unavailable", true, 503 );    header( ‘Content-Type: text/html; charset=utf-8‘ );    header( ‘Retry-After: 600‘ );?>    <!DOCTYPE html>    <html xmlns="http://www.w3.org/1999/xhtml"<?php if ( is_rtl() ) echo ‘ dir="rtl"‘; ?>>    <head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <title><?php _e( ‘Maintenance‘ ); ?></title>    </head>    <body>        <h1><?php _e( ‘Briefly unavailable for scheduled maintenance. Check back in a minute.‘ ); ?></h1>    </body>    </html><?php    die();}

5.檢查是否開啟偵錯模式

function wp_debug_mode() {    if ( WP_DEBUG ) {        error_reporting( E_ALL );        if ( WP_DEBUG_DISPLAY )            ini_set( ‘display_errors‘, 1 );        elseif ( null !== WP_DEBUG_DISPLAY )            ini_set( ‘display_errors‘, 0 );        if ( WP_DEBUG_LOG ) {            ini_set( ‘log_errors‘, 1 );            ini_set( ‘error_log‘, WP_CONTENT_DIR . ‘/debug.log‘ );        }    } else {        error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR );    }    if ( defined( ‘XMLRPC_REQUEST‘ ) )        ini_set( ‘display_errors‘, 0 );}

wordpress4.0.1源碼學習和摘錄--項目設定

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.