6 articles PHP

Set WordPress to Enable Error Logging but Move Error Log Outside of /public_html/

The snippet below is for pasting into wp-config.php: to enable error logging into file debug.log, but move it outside of public_html to disable showing errors (you can switch comment below to allow display of errors)   // Enable WP_DEBUG mode define( ‘WP_DEBUG’, true ); // Enable Debug logging to the debug.log file //define( ‘WP_DEBUG_LOG’, true…

Automatically Log a User into a Specific Account in WordPress without Username / Password

This script will automatically (forcefully) log any user that loads this page into a specific wordpress account. This example logs user into an account with username “demo”.

Word of caution: Any user who finds and loads this page will be logged in. Use very carefully. Do NOT use this script to allow logging into any user account with any meaningful privileges. Do NOT use this in a production environment. This basically creates a backdoor to your wordpress site.

PHP Script – Cross Origin Resource Sharing (CORS) – Pre-flight response for the browser

This PHP snippet is to fulfill the pre-flight requirement for Cross Origin Resource Sharing (CORS) so browsers will access a resource from another domain to your server. This is useful for any APIs (restful or not), or any resource that will be called remotely. You can basically copy and paste this code. Brief explanation: Before…