update_option not working in stand-alone PHP script

I’m not sure why it does’t work for you, but the following works in the file wp-content/test.php: <?php // doesn’t make difference to have this or not, for the rest to work define( ‘WP_USE_THEMES’, false ); require( $_SERVER[‘DOCUMENT_ROOT’] .’/wp-load.php’ ); function my_function() { return ‘hello world’; } $value = my_function(); update_option( ‘my_option’, $value ); var_dump( … Read more

do_action and hook methods

Your analogy here is partially correct, but incomplete: I understand that when do_action is called wp looks for all registered listeners and invokes them according set priority. You need to consider what happens when you call add_action. WordPress never searches for the add_action statements, it has those in a list. When you call add_action, it … Read more

Create a post variable processing page

You see a lot of code out there which includes wp-load.php or wp-blog-header.php to use the WordPress API within a php page loaded outside the context of WordPress. There’s often a better way to accomplish this. It’s also worth noting that any plugin which does that will get rejected from the WordPress.org plugin repository, with … Read more

Trying to avoid including wp-load.php

Add a rewrite endpoint to give your plugin a public URL- function wpa_my_endpoint(){ add_rewrite_endpoint( ‘my_api’, EP_ROOT ); } add_action( ‘init’, ‘wpa_my_endpoint’ ); After you flush rewrite rules, you’ll have the URL available for the scheduler to ping. http://example.com/my_api/do/something/ Then catch those requests on the parse_query action to invoke your plugin action: function wpa_parse_query( $query ){ … Read more

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