Controlling behavior by setting constants

Controlling behavior by setting constants

Contact Form 7 allows you to control its behavior by setting some constant values.

The typical place to define constants is in the wp-config.php file. You will find that many lines defining constants such as, define('XXX', 'xxx'); exist in the file. You can append new lines after them. Note that your lines must be placed before the last line.

Example (wp-config.php):

8081828384858687888990919293define( 'WP_DEBUG', false ); define ( 'WPCF7_LOAD_JS', false ); // Added to disable JS loadingdefine ( 'WPCF7_LOAD_CSS', false ); // Added to disable CSS loading /* That's all, stop editing! Happy publishing. */ /** Absolute path to the WordPress directory. */if ( ! defined( 'ABSPATH' ) ) {    define( 'ABSPATH', __DIR__ . '/' );} /** Sets up WordPress vars and included files. */require_once ABSPATH . 'wp-settings.php';

The rest of this post describes a variety of constants.

WPCF7_LOAD_JS

When the value of this constant is false (default: true), Contact Form 7 does not load the JavaScript on the front end. When the value of this constant is set as header, Contact Form 7 loads the JavaScript in the header instead of in the footer (default).

See also: Loading JavaScript and stylesheet only when it is necessary

WPCF7_LOAD_CSS

When the value of this constant is false (default: true), Contact Form 7 does not load the CSS stylesheet on the front end.

See also: Loading JavaScript and stylesheet only when it is necessary

WPCF7_AUTOP

When the value of this constant is false (default: true), Contact Form 7 does not apply the 「autop」 filter to the form content. The 「autop」 filter replaces double line-breaks with paragraph elements.

WPCF7_USE_PIPE

When the value of this constant is false (default: true), Contact Form 7 disables its 「pipe」 feature, so that pipe character has no special meaning.

See also: Selectable recipient with pipes

WPCF7_ADMIN_READ_CAPABILITY

The value of this constant holds the minimum capability required for access to the administration panel. The default value is edit_posts.

See also: Restricting access to the administration panel

WPCF7_ADMIN_READ_WRITE_CAPABILITY

The value of this constant holds the minimum capability required for editing contact forms. The default value is publish_pages. Obviously WPCF7_ADMIN_READ_WRITE_CAPABILITY should be stricter than WPCF7_ADMIN_READ_CAPABILITY, as you cannot edit contact forms without accessing the administration panel.

See also: Restricting access to the administration panel

WPCF7_UPLOADS_TMP_DIR

When this constant is defined, the value of the constant overrides the setting of directory path of the temporary folder for uploaded files.

See also: File uploading and attachment
Share this:FacebookTwitterLike this:Like Loading...

發表回覆

您的電子郵箱地址不會被公開。 必填項已用 * 標註