How to send get request to file.php right and where to store that file.php?

This is not recommended, but if you want to do it, do it this way: Save your file in your WordPress’s root folder, right next to index.php. Then, require WordPress’s core files in it, by this code: define(‘WP_USE_THEMES’, false); global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header; require(‘wp-load.php’); Now, even though the file is not actually a … Read more

Child page menu in sidebar

When trying to output a function’s content, you have to notice whether you want to pass the data to another function (or something else which you want to feed), or you want to directly print it to the browser. If you use return, your function will return the data, so you can use them in … Read more

Replacing mysql_escape_string in a custom plugin when moving to PHP7

You don’t need to sanitize the variables that are passed to wp_update_post() because wp_update_post() after some checks pass the data to wp_insert_post() and wp_insert_post() calls sanitize_post(), which does the sanitization of all arguments. Also add_post_meta and update_post_meta also do all the sanitization for you. To answer your question I would replace mysql_escape_string with $wpdb->esc_sql($_POST[$value]). It … Read more

PHP, Creating a dynamic variable

Your own solution works I guess (double $$) but usually you do it this way: $quantity[‘type’] = 1; ${‘message’ . $quantity[‘type’]} = ‘hello’; echo $message1; // hello