You know What Would Be Useful…
…. A WordPress plugin that allowed me to search Google Images for a certain keyword, with image dimensions – if I so desired – and bring me back the results i.e Just the images.
I’d then be able to click on the image I wanted, view it, uploaded it if I wanted and auto magically inserted it into the post that I am writing.
Now you are going to say “Insights” does this. But no. It doesn’t.
Anyone know if one already exists with the functionality I am looking for? Its a real pain having to leave the post editing window to trek off to Google, do the search, upload the file, insert it etc.
Hopefully I wont have to write this myself – but I’m thinking about it.
Tags: google images, plugin, Wordpress
Categories: Wordpress
WordPress 2.6: register_activation_hook Cannot See Global Variables
I have recently been trying to update an old plugin I created for WordPress 2.3.2 so that it would be compatible with the latest version : 2.6.
I am currently having an issue where the register_activation_hook function (and this may not be limited to this one function) where it refuses to reference the global variables that I define in the plugin.
Take the below as an example (proper code attached at the bottom):
require 'mcn_constants.php';
$mcn_test_blabla = "Well ??????";
register_activation_hook(__FILE__,'mcn_test_install');
register_deactivation_hook(__FILE__, 'mcn_test_uninstall' ) ;
add_action('parse_query', 'mcn_test_check');
function mcn_test_install() {
global $this_is_broke, $mcn_test_blabla;
add_option("mcn_test_value", "The value is: $this_is_broke And :: $mcn_test_blabla ");
}
function mcn_test_uninstall() {
delete_option("mcn_test_value");
}
function mcn_test_check() {
global $this_is_broke;
echo get_option("mcn_test_value");
echo "Proper value : $this_is_broke";
}
When you load the front page of your blog with the above plugin code activated you should see :
The value is: YES I AM BROKE!!!!!
And ::Well ??????
Proper value : YES I AM BROKE!!!!!
… but instead you see:
The value is:
And ::
Proper value : YES I AM BROKE!!!!!
As you can see – the $this_is_broke and $mcn_test_blabla variables are not being set in the Option “mcn_test_value”.
Yet calling the global variable in the function “mcn_test_check”, which is called as part of the “parse query” action, will show the global variable – as it should.
So – is this a bug or am I missing something fundamentally different in WordPress 2.6? Using global variables in WordPress 2.3.2 worked just fine.
I have attached a sample plugin that will replicate this issue.
Any ideas?
Tags: 2.3.2, 2.6, global variables, register_activation_hook, Wordpress
Categories: ALM, Programming, Wordpress