WP_DEBUG

Notes about WordPress Gutenberg themes development.

  • GitHub

.htaccess (1) ACF (7) admin (1) ajax (2) api (1) API interactivity (1) block (20) block_style (2) colors (2) constante (1) context (1) conventions (2) cron (1) css (5) custom post type (1) data (1) debug (2) define (1) file_API (1) functions.php (6) git (4) hook (7) i18n (2) js (2) layout (1) loop (1) media (1) media library (1) menu (2) navigation (1) patterns (1) performance (2) post (1) query (3) readmore (1) responsive (1) rest api (1) scss (1) security (7) spacing (1) sql (1) svg (1) taxonomy (1) theme (1) theme.json (11) typo (2) URL (1) wp-config.php (6) wp cli (3) wp function (7)

  • Folder patterns

    # patterns, wp-config.php
    Read more

    To load pattern php files, create a patterns folder, add a file.php with at least:

    <?php
    
    /*
     * Title: required
     * Slug: required
     */
    
    Some content

    Having a php file can be handy for translations.

    Integration in a template file example :

    <!-- wp:pattern {"slug":"df/content-404"} /-->

    Note: for WordPress to be able to automatically look into the patterns folder, one need to add in wp-config.php:

    define( 'WP_ENVIRONMENT_TYPE', 'development' ); 
    define( 'WP_DEVELOPMENT_MODE', 'theme' );

    Sources:

    • https://developer.wordpress.org/themes/patterns/using-php-in-patterns/
    • https://make.wordpress.org/core/2023/07/14/configuring-development-mode-in-6-3/
  • File system method

    # file_API, wp-config.php
    Read more

    The hosting server doesn’t necessary allow WordPress to write files.

    define( 'FS_METHOD', 'direct' );

    Sources:

    • https://wordpress.stackexchange.com/questions/189554/what-security-concerns-should-i-have-when-setting-fs-method-to-direct-in-wp-co
    • https://kinsta.com/knowledgebase/constant-fs_method/
    • https://developer.wordpress.org/reference/functions/get_filesystem_method/
  • Debug

    # debug, wp-config.php
    Read more
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true ); // or define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log' )
    define( 'WP_DEBUG_DISPLAY', true );

    Source: https://wordpress.org/documentation/article/debugging-in-wordpress/

  • Force SSL admin connection

    # security, wp-config.php
    July 18, 2023
    Read more
    define( ‘FORCE_SSL_ADMIN’, true );
  • Disallow file editing

    # security, wp-config.php
    Read more
    define( 'DISALLOW_FILE_EDIT', true );
  • Get and set the environment state

    # debug, wp-config.php
    July 21, 2023
    Read more

    With wp_get_environment_type(): string one can get the current state of the project. It returns production by default, otherwise local, development or staging can be used.

    It can be set in the wp-config.php file as :

    define( 'WP_ENVIRONMENT_TYPE', 'development' );

    Sources :

    • https://developer.wordpress.org/reference/functions/wp_get_environment_type/
    • https://make.wordpress.org/core/2020/07/24/new-wp_get_environment_type-function-in-wordpress-5-5/
WP_DEBUG

WP_DEBUG

  • GitHub