Include user defined styles without including wp-load

If you are going to enqueue a stylesheet you should be using wp_enqueue_scripts not wp_print_styles, but you are in a bit of a gray zone between doing things “WordPress-ie” and doing things correctly for performance. The “WordPress-ie” way is to enqueue a stylesheet, but from a performance standpoint you are loading an additional resource and … Read more

Call to undefined function issue

Christ, once again I was fighting with something for a few days straight and found a solution 20 minutes after asking on StackExchange. WHY? require_once(‘../../../wp-load.php’);

How to avoid wp-load.php within a PHP/CSS file?

Here is a basic setup that I use for AJAX with WordPress. instead of loading wp-load.php; just use WordPress default method for AJAX calls. This allows you to also filter function calls from Javascript through a switch. I also added a quick example for wp_localize_script. <?php add_action(‘wp_enqueue_scripts’, ‘YOUR_NAME_scripts’); //back end function YOUR_NAME_scripts( $hook_suffix ) { … Read more

Get current user data from external PHP page

You can… Load the file into the file where you want to display the ‘hey username’ message: <?php include(TEMPLATEPATH .’/check-user-hello.php’); ?> . Then in that file “check-user-hello.php” You need to put this code <?php if ( is_user_logged_in() ) { global $current_user; get_currentuserinfo(); echo ‘Hey ‘ . $current_user->display_name; } else { echo ‘<a href=”‘. get_bloginfo(‘url’) .’/wp-admin” … Read more

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