“Notice: Undefined variable: content” is showing [closed]

Although the actual question is off topic, I would make a few alterations to the code to make it more reliable and a bit faster and less resource intensive: Add $content=””; right at the top of the function, this will take care off the Notice: Undefined variable notice Only get the term id’s from wp_get_post_terms(). … Read more

How to make a variable available for the duration of the page request

A class provides structure, and if it’s what you need to do it then do it. The alternative would be a global variable, which is bad practice and should be avoided ( and makes reliable unit testing near impossible ) However, your entire premise is unnecessary. WordPress already stores the option in its caches, so … Read more

Custom WordPress+PHP+MYSQL+AJAX form, submit event not captured by Javascript, but does POST data to the DB

If you’re releasing this as a plugin, you absolutely must use the AJAX API. It’s super easy: /** * Handle the request and return the result. */ function alumni_process_request() { global $wpdb; // All your processing code from your original question, except for loading WordPress! return $data; } /** * AJAX handler for the “alumni” … Read more

Callback URL in WordPress

That’s pretty simple, just use your website home url 🙂 After that, just fire an action when the page is loaded via POST HTTP method and hook with a callback. add_action( ‘wp_loaded’, function() { if ( $_SERVER[‘REQUEST_METHOD’] === ‘POST’ ) { // fire the custom action do_action(‘onchangeapi’, new PostListener($_POST)); } } ); And now the … Read more

Sanitize get_query_var() url parameters

There’s a slight disconnect between your question title and the actual question. It sounds like you’re using a plugin (or developing a plugin?) that allows for some front-end sorting. If it’s a plugin you’re using and the query string parameter is not sanitized, you need to notify that plugin’s developer, because that’s a security issue. … Read more

automatic PDF invoice with FPDF in PHP (creating Plugin)

You need to load WordPress before using wp functions, use this just after the <?php tag: require( ‘<<DIR>>/wp-load.php’ ); where <<DIR>> is the path to the main wordpress folder (in your case something like ../../../, add double dots as needed to navigate up the plugins and wp-content hierarchy NOTE: direct linking outside you control zone … Read more