Hook from plugin doesn’t fire up from external PHP script
Hook from plugin doesn’t fire up from external PHP script
Hook from plugin doesn’t fire up from external PHP script
How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
I am not sure if that is cause of your issue, but you do not load WordPress in correct way. Please see Integrating WordPress with Your Website in Codex for details.
Ok, I’ve fixed it. Turns out that there was a php class name that was getting redeclared. Declared once in the theme, and once in the plugin.
A different way of fixing it: function load_wp(){ global $wpdb; include_once(‘wp-load.php’); }
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=”redirect_mobile_is_a_mobile_device”; if ( isset($_COOKIE[$cookiename]) && ($_COOKIE[$cookiename] == ‘yes’) && strpos(get_first_url_subdir(), ‘/mobile’) !== 0) return true; return false; } function my_mobile_redirect(){ if ( redirect_mobile_with_cookie() ) … Read more
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’] . ‘/wp-load.php’ ); This is a problematic way to include wp-load.php, but … Read more
I can’t say I’ve ever tried including wp-load.php directly, but I’ve had success using: define(“WP_USE_THEMES”, false); include(“wp-blog-header.php”); … when trying to invoke WordPress stack in a non-templated workflow. wp_blog_header.php does make the call out to wp-load.php but also wires up some other stuff (such as calling wp()).
You could do that, including wp-load.php would bootstrap WordPress and allow you to query the database. I prefer to keep things encapsulated in plugins though, much more portable. You just need to hook early enough to send your own headers, and you can short-circuit the rest of the load process. For example- function wpd_my_export_script() { … Read more
Yes, using admin-ajax.php is the way to go here. To use it, you would do something like the following: in vote_database_update.php // hook into admin-ajax // the text after ‘wp_ajax_’ and ‘wp_ajax_no_priv_’ in the add_action() calls // that follow is what you will use as the value of data.action in the ajax // call in … Read more