Showing error “Function create_function() is deprecated”

Problem lies in your theme. It’s not compatible with PHP 7.2. In this version the create_function is deprecated and you should use Anonymous Functions instead. So for example instead of something like this: $callback = create_function(”, ‘echo “‘.str_replace(‘”‘, ‘\”‘, $section[‘desc’]).'”;’); You should use this: $callback = function() { echo str_replace(‘”‘, ‘\”‘, $section[‘desc’]); };

Changing the Database Connection Error Message

Basically, if you create a PHP file named db-error.php and put under /wp-content/, you’ll get what db-error.php will have. Here is my template on CodePen. This is example : <?php header(‘HTTP/1.1 503 Service Temporarily Unavailable’); header(‘Status: 503 Service Temporarily Unavailable’); header(‘Retry-After: 3600’); // 1 hour = 3600 seconds mail(“[email protected]”, “Database Error”, “There is a problem … Read more

How to throw error to user when saving post

You can use admin_notices hook http://codex.wordpress.org/Plugin_API/Action_Reference/admin_notices For example: function ravs_admin_notice() { ?> <div class=”error”> <p><?php _e( ‘Article with this title is not found!’, ‘my-text-domain’ ); ?></p> </div> <?php } on publish_{your_custom_post_type} hook http://codex.wordpress.org/Post_Status_Transitions function on_post_publish( $ID, $post ) { // A function to perform actions when a {your_custom_post_type} is published. $post_exists = $wpdb->get_row(“SELECT post_name FROM … Read more

Should messages in WP_Error already be html escaped?

No, escaping should happen at the moment of output ( late escaping ) so that we know that it only occurs once. Double escaping can allow specially crafted output to break out. By escaping, we’re talking about functions such as esc_html, wp_kses_post, esc_url, etc. Sanitizing functions and validating functions are not the same, e.g. sanitize_textfield. … Read more

Why on Earth am I getting “undefined_index” errors?

It’s a common PHP error, usually when you try to access an array member with a non-existent key; $array = array( ‘hello’ => ‘world’ ); echo $array[‘foobar’]; // undefined index You should check for the key first with isset( $array[‘foobar’] ); UPDATE: In this case, I would chuck in a loop that sets-up the variables … Read more

Fatal error: Call to undefined function post_exists()

The files in wp-admin are only loaded when you’re in the admin area… when you’re looking at pages or posts those functions aren’t loaded. In that case you’d need to require the file first, so you’d want to do something like this in your function: if ( ! is_admin() ) { require_once( ABSPATH . ‘wp-admin/includes/post.php’ … Read more

WSOD but WP_DEBUG not giving any errors

Make things simpler by using this in wp-config.php: define( ‘WP_DEBUG’, true ); /** debug on */ define( ‘WP_DEBUG_LOG’, true ); /** log enabled */ define( ‘WP_DEBUG_DISPLAY’, true); /** display enabled */ The @ini_set(‘display_errors’, 0); may be breaking the WP_DEBUG error display and logging by calling the native PHP error reporting at the same time.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)