Articles of wp load.php

wp_enqueue_style with style.php and WordPress functions

I use wp_enqueue_style to add my stylesheet, like this: <?php wp_enqueue_style( ‘theme-style’, get_template_directory_uri() . ‘/style.php’, false, ‘1.0’, ‘all’ ); ?> It works fine BUT I need to run a WordPress function in the style.php file. The stylesheet file does not know that the core exists. This is what I’ve heard It’s bad to include wp-load.php. […]

Include user defined styles without including wp-load

I’ve looked through the answers on here and none quite match my situation. I have custom CSS that a user can edit and it is saved in the options. I use wp_enqueue_style to include a PHP file with a CSS content header and then load the CSS from the options. However, in order to load […]

How to efficiently load and use the wordpress API from outside the original structure

I want to call WordPress functions (the same ones we use to build a theme) from outside the original structure / folder / files of WordPress. For example, in my theme folder I created a folder called custom, in which I create files such as header-small.php, header-medium.php, etc. So every one of these custom php […]

external wordpress pages using wp-blog-header

I am setting up a few sections of a website external to the core wordpress installation, but I still want to use the built in wpdb functions, and/or header files from wordpress. I follow the instructions outlined in wordpress, setting up my headers: <? require(‘../cms/wp-blog-header.php’); define(‘WP_USE_THEMES’, false); . . ?> Everything works great. I can […]

How do you load WordPress from an external script when using MultiSite?

Possible Duplicate: Using WordPress functions on other sites I have an external script that needs to load up WordPress in order to have access to WordPress functionality. In the past I have successfully done this by including wp-load.php. However, when using MultiSite, this does not work. It appears to be logged as a bug here. […]

WP-Admin not working properly at WordPress multisite with subdirectories

I have recently installed a WordPress Multisite Blog on my domain. Everything is working fine, except for wp-admin of the subsites: I can access wp-admin of a subsite, but css is not loaded and when I try to click on a navigation link I get the wordpress “File not found” error. That is because it […]

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

This is tricky, as people usually mix wp-load with AJAX and I can’t really find a proper answer. Case 1 I have a dynamic style.php file that looks like this: <?php header(“Content-type: text/css”); require_once(‘../../../../wp-load.php’); ?> body { background: <?php echo get_option(‘background_color’); ?>; } Case 2 I’m using AJAX call: jQuery.post(‘<?php bloginfo(‘template_directory’); ?>/framework/foo.php’,{ foo: smth, bar: […]

WordPress function gives different results outside vs inside PHPUnit test

I’ve been working very hard to get PHPUnit to play nice with WordPress (with the help of this, this, this, this, and this), and I think I’ve gotten pretty close. The code I run directly before my tests looks like this (basically lifted verbatim from this article): ( PHP_SAPI === ‘cli’ ) || die( ‘Access […]

Initialize WordPress environment to use in a real cron script

I have to run a PHP script through real cron (WP cron being too unreliable). Within that script, I need $wpdb to insert data into WordPress table. But of course $wpdb will not be available as WordPress would not be initialized. Right? So, my question is how to ‘include’ WordPress/initialize WordPress environment to do such […]

When is wp_loaded initiated only with admin or only when user enters the site or both?

When is wp_loaded initiated? Im trying to add function that downloads a big file for the plugin DB, and I need it to be executed whenever user/admin/unknown user get in the frontend, after the site is fully loaded, so that it would not be any delay with the site speed, and user experience. I use […]