zoukankan      html  css  js  c++  java
  • wordpress4.0.1源码学习和摘录--项目设置

    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 );
    }
  • 相关阅读:
    万能五笔的广告怎么去掉
    JS版日期格式化和解析工具类,毫秒级
    Toast信息提示:下拉收起(基于jQuery)(app信息提示更新)
    MUI右滑关闭窗口用Webview的drag实现
    mui 列表项左右滑删除功能升级(仿微信左滑 点击删除后出现确认删除)
    修正 Mui 下拉上拉刷新功能
    javascript中new Date()的浏览器兼容性问题
    Mui 下拉刷新,刷新完成功能实现
    mysql 时间类型精确到毫秒、微秒及其处理
    Windows 上如何安装Sqlite
  • 原文地址:https://www.cnblogs.com/jdhu/p/4172337.html
Copyright © 2011-2022 走看看