Warning: Use of undefined constant NONCE_SALTエラーの解決方法

SmartSlider3」プラグインを使用中に、以下のエラー文が出たときの対処法を紹介します。

Warning: Use of undefined constant NONCE_SALT - assumed 'NONCE_SALT' (this will throw an Error in a future version of PHP) in /xxx/wordpress/wp-content/plugins/smart-slider-3/Nextend/SmartSlider3/Platform/WordPress/Shortcode/Shortcode.php on line 248

NONCE_SALT定数が定義されていないのが原因のエラーです。通常、/wp-config.phpファイルの中で以下のようにインストール時にデフォルトで定義されるものです。

/**#@+
 * Authentication unique keys and salts.
 *
 * Change these to different unique phrases! You can generate these using
 * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
 *
 * You can change these at any point in time to invalidate all existing cookies.
 * This will force all users to have to log in again.
 *
 * @since 2.6.0
 */

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');


/**#@-*/

エラーが出てきたということは、この定義がされていない(書かれていない)状態だと思います。そのため、今回はwp-config.phpを開いて、手作業でNONCE_SALTを定義します。

‘put your unique phrase here’には、一意の文字列が入ります。文字列は以下のリンクからWordPress APIで取得して、コピー&ペーストで問題ありません。

https://api.wordpress.org/secret-key/1.1/salt/

石井秀幸@WEBデザイナー
横浜WordPress Meetup 主宰/株式会社ノクチ基地 取締役/モンゼンクリエイティブ合同会社 代表
WEB制作に関する技術や役立つ情報を発信していきます。10年にわたるWordPress歴を背景に、幅広いアイデアを形にするお手伝いをしています。