Tag Info

Hot answers tagged

10

There's little difference between the files. When you view a WordPress page, the first file called is index.php. And it is, essentially, your "Method 1:" define('WP_USE_THEMES', true); /** Loads the WordPress Environment and Template */ require ('./wp-blog-header.php'); The blog header file (that queues up the rest of WordPress) loads wp-load.php ...


4

muplugins_loaded is the very earliest: http://codex.wordpress.org/Plugin_API/Action_Reference (via: http://stackoverflow.com/questions/2535994/sequential-order-of-wordpress-hooks)


4

I came up with following solution. The script have to start with the following code. <?php if( php_sapi_name() !== 'cli' ) { die("Meant to be run from command line"); } function find_wordpress_base_path() { $dir = dirname(__FILE__); do { //it is possible to check for other files here if( ...


3

Yeah $wpdb2 = new wpdb('dbuser', 'dbpassword', 'dbname', 'dbhost'); // get 10 posts, assuming the other WordPress db table prefix is "wp_" $query = "SELECT post_title, guid FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC LIMIT 10"; $someposts = $wpdb2->get_results($query, ...


3

Use the defines to make it pick the site you want it to pick. You can define these four to setup the $current_site values properly: DOMAIN_CURRENT_SITE, PATH_CURRENT_SITE, SITE_ID_CURRENT_SITE, BLOG_ID_CURRENT_SITE. If you check the wpmu_current_site() function in ms-load.php, you'll see that it uses those to create the $current_site global. You may or ...


3

Instead of cooking up your own PHP file and trying to bring in WordPress functionality, put the functionality inside of WordPress using the AJAX hooks that are designed to do that sort of thing. More info here: http://codex.wordpress.org/AJAX_in_Plugins


3

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 ...


3

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 in your case ...


2

What your asking is if Wordpress is modular. Almost like many plugins making up the core and you could use one of those plugins. There are some files with classes you can call on their own but even then some of the methods use even the smallest of core WP functions. I wouldn't worry about load time. Maybe 5 years ago but if your site needs a CMS driving it ...


2

In the generic case, there is no performant solution other than to check every file and folder that is publicly accessible, and then all the parent folders. Since this is not a feasible or excusable operation to perform on every page load or request, you're left with two other options: Define the location manually, which is not an unreasonable request ...


2

First of all, search this site. This questions has been answered many times in the past: http://wordpress.stackexchange.com/search?q=clean+wp_head and http://wordpress.stackexchange.com/search?q=security+obscurity Secondly, there is a difference in what WP loads and what a theme and a plugin will load. Look in the theme functions file to see what the theme ...


2

Hi @RodeoRamsey: I think your question is very similar to this question: Getting post-thumbnails from another WP site Basically you just need to created the $wpdb using the security credentials for your other site. Take a look at my answer on that question and let me know if it does or does not answer your question, and if not why so I might be able to ...


2

You could give a try to Wordpress Mu Domain Mapping plugin. Update Actually, it better fits on your request to include wp-blog-header.php in the top of your php file of your subdomain, so you can load also the template functions. include(dirname(__FILE__) . "/../path_to_my_blog/wp-blog-header.php"); Or you can do a wp_redirect after the include of ...


2

EDIT Forget my answer below. You could simply use wp_register_style and wp_enqueue_style described in this answer. You could do it with an additional query variable. Add a new variable to the $query_vars array with the query_vars filter On the template_redirect action, make sure your custom.php-css file is included, if the query variable is set. // ...


2

Look at the answers of these questions: How do I add CSS options to my plugin without using inline styles? Best way of adding CSS which can be manipulated by the user via theme option panels? Best practices for a Style/CSS based theme options page?


1

In principal, you could use this with any archive page. All it's doing is fetching the next page of results and displaying the data. The reason it won't work with CPTs is because of the way the PHP script is queued - with an !is_singular() filter. The core of the plugin is in the JavaScript. Namely, this section: $('.pbd-alp-placeholder-' + ...


1

We also needed to do this in WP-CLI. In order to properly handle all the edge cases, such as incorrect database credentials, we ended up rolling our own version of the wp-settings.php file: https://github.com/wp-cli/wp-cli/blob/master/php/wp-settings-cli.php The good news is that you don't have to deal with the messy process of loading WordPress, if you ...


1

This error has nothing to do with wp-load.php. You are declaring the 'some_plugin_function' function twice within your plugin file. The error message tells you exactly where to look. You don't need to call class-frontend.php from your stand-alone PHP file to get the error. It's in a plugin, so as long as that plugin is active, it will be parsed.


1

You must put your gallery.php in the same theme folder, where the theme's functions.php resides. Then add a single line in functions.php: get_template_part('gallery',''); It'll include the gallery.php file into functions.php and gallery.php will behave like functions.php. So, you have to keep in mind that, functions.php file is a file for WordPress and ...


1

Disable the plugin at all and in your function.php add add_action('init', 'my_mobile_redirect'); function get_first_url_subdir() { return str_replace( str_replace( array('http://', 'https://'), '', get_site_url() ), '', $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']); } function redirect_mobile_with_cookie() { $cookiename = ...


1

First of all, is better use get_template_directory_uri() instead of bloginfo(... <input type="hidden" name="notify_url" value="<?php echo get_template_directory_uri(); ?>/ipn.php"> but you are right if you think the problem is not this one. I cannot be sure, but I bet your problem is here: include_once( $_SERVER['DOCUMENT_ROOT'] . ...


1

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( ...


1

It sounds you need some kinda of bootstrap for your code. WordPress has already bootstrap such as index.php or wp-load.php or even wp-blog-header.php. This : require_once('/path/to/site/wp-load.php'); is not recommanded because path can be modified. What you can do to have some bootstrap is : // Load WP $load = 'wp-load.php'; while( !is_file( $load ) ...


1

If you place the file in the WP root directory, e.g. http://mysite.com/myscript.php require( dirname(__FILE__) . '../blog/wp-load.php' ); if (function_exists('wp_create_user')) { echo "wp_create_user() found"; } If you are in a different directory, just make sure you are loading wp-load.php from the proper location.


1

url_to_postid(wp_get_referer()) will give you the ID of the referring page/post if you were referred from a page or a post. It won't work if referred from some other types of pages, like archives. You will then need to retrieve the categories for the ID to see if they match. I would strongly consider passing a parameter with the request though. You should ...


1

You mean: <?php include "http://www.sample.com/wp-load.php"; This setting is disabled/not allowed by default in most web servers (php.ini) so you can not use the include to include the files from a remote address for security reasons. If you still want to allow inclusion of remote files, the directive allow_url_include must be set toOn(or 1) inphp.ini`. ...


1

The shortest way is to load wp-load.php and abort the loading of the template engine (Note: You couldn't do that, if you'd be loading the header file, like you see it on many sites in the interweb). # No need for the template engine define( 'WP_USE_THEMES', false ); # Load WordPress Core // Assuming we're in a subdir: "~/wp-content/plugins/current_dir" ...


1

Solution Found! Thanks to these guys require('../cms/wp-config.php'); $wp->init(); $wp->parse_request(); $wp->query_posts(); $wp->register_globals(); The key is, don't use wp-blog-header, but this code instead.


1

As per the Codex, http://codex.wordpress.org/Integrating_WordPress_with_Your_Website <?php require('/the/path/to/your/wp-blog-header.php'); ?> Whether or not your means and method is foolproof is entirely dependent upon your setup and the locations in which you are placing your scripts, relative to your WordPress installation. Assuming you follow ...



Only top voted, non community-wiki answers of a minimum length are eligible