Roger Theriault
Forum Replies Created
-
Forum: Plugins
In reply to: Pass Variable to function in add_action()(Correction – I meant to say the do_action has already been inserted)
Forum: Plugins
In reply to: top bar plugin@mikegoodstadt – #1 – yes, you only need to register your topbar if there’s just one.
#2 – not sure what the issue really is – I probably need a picture – but the array you see is just a way PHP collects and passes all the parameters. ‘topbar’ is the name of the sidebar you’re setting up. The rest is what XHTML to put around the widgets IF they are output.
On the Widgets page you assign widgets to specific sidebars, then set them up.
Wherever you call
dynamic_sidebar('topbar')
it will insert the widgets for that sidebar – ie ‘topbar’. You should usually only call it once for each sidebar, where you need it.Some older code fails to name the sidebars; in that case you can fix things by inserting a name in both places – ie dynamic_sidebar() and register_sidebar() – for each of the sidebars. Otherwise, yes, calling dynamic_sidebar() without a string parameter might just output the next sidebar in the order they were defined.
Forum: Plugins
In reply to: plugin optionsSettings?
Forum: Plugins
In reply to: [Plugin: AdServe] Creating Zones@thestig2 – Yeah, that’s the whole idea.
<?php $categories = get_the_category(); AdServe($category[0]->category_nicename); ?>
This would work for the first category if there are more than one.
Set up zones that match the slugs of your categories. (You can find that on the Edit Category admin page)
See https://codex.www.ads-software.com/Template_Tags/get_the_category
Forum: Fixing WordPress
In reply to: add_action passing parameters@renato_s that’s right. Although, if you KNOW what globals are available at that time, you can access them…
unfortunately publish_post is hard to research, but your email function should be written with two parameters, like this (the name of the params doesn’t exactly matter of course):
email_friends($post_ID, $post) { ... }
where $post_ID is an integer and $post is your familiar $post object that accesses the fields directly.
See here: https://adambrown.info/p/wp_hooks/hook/$%7Bnew_status%7D_$post-%3Epost_type just follow the code link to see the actual WordPress code. That’s the best way to learn WordPress!
Here’s a full list of hooks and filters:
https://adambrown.info/p/wp_hooks
And to answer the older question “how do I pass a post id?” well if you know a specific one you probably don’t need the hook. ??
The hooks are for people who want their code to be called every time a particular event happens in WordPress. In the case of this function, the code indicates that the event is when a post’s status changes from something else to “publish”. The example is to mail a notification to people every time a post is published.
I hope that sheds some light on the mystery. This codex doc explains it in more detail: https://codex.www.ads-software.com/Plugin_API
Forum: Plugins
In reply to: Pass Variable to function in add_action()Sorry, it doesn’t work that way.
All WP really does is save your function name and then call it when do_action(‘wp_hook_sidebar’) is called. Your displayAd function is going to have to get what it needs on its own – from a global variable, a function call, a SQL query, etc…
Try
global $passedtext; $passedtext = 'foo';
and elsewhere …
add_action('wp_hook_sidebar','displayAd'); function displayAd() { global $passedtext; echo $passedtext; }
However, if $passedtext is available in the code that calls do_action() then you CAN pass it (but your example is odd or misleading, why bother if you can just echo it anyway.) However, if your displayAd function is doing a bit more, you can do this:
do_action('my_hook',$myparameter, $secondparameter);
and then
add_action('my_hook', 'my_function'); function my_function( $param1, $param2 ) { ... }
Of course if you’re dealing with an existing WordPress hook, you can only use parameters if it will be passing them, since the add_action has already been inserted into the code. Check here for details:
https://adambrown.info/p/wp_hooks
or just open up the core php file that you’re hooking into.(And for other options to get stuff to your function, grab a handy PHP book.)
Forum: Plugins
In reply to: [Plugin: Great Real Estate] Problem with image uploadThis should be corrected in release 1.2 just out today…
Forum: Plugins
In reply to: Rating plugin for commentsA bit old but check out Lorelle’s post “WordPress Plugins for Comments“.
Top Comments plugin might be too new I couldn’t get it to work.
IMHO, nobody really likes forms so I doubt you’ll find that, you might have to hack the comments form (you can store the number in $comment->comment_karma).
Please be sure to come back here and let us know what you went with…
Forum: Plugins
In reply to: Need mouseover text preview plugin – ideas?You might get by with just a bit of AJAX jQuery added to your theme. See my example in this thread:
Forum: Plugins
In reply to: [Plugin: Great Real Estate] Problem with image uploadI assume with 2.6… it’s because of a change in WordPress’ inclusion of jQuery ui components. A fix will be available soon, in the mean time, you can try commenting out (near line 143) of great-real-estate.php:
// wp_enqueue_script( 'jquery-ui', GRE_URLPATH . 'js/ui.core.js', array( 'jquery' ) );
Also see: https://rogertheriault.com/forums/topic.php?id=49
Roger
Forum: Plugins
In reply to: How to use jquery in wordpress?@doodlebug – any error messages from Firebug?
Forum: Plugins
In reply to: [Plugin: AdServe] Creating ZonesYou need to put the PHP code in a php file… most widgets will not be able to handle that PHP, and most widgets will not interpret the shortcode.
Forum: Plugins
In reply to: How to use jquery in wordpress?and rather than the shortcut $ you should use jQuery(“#foo”)
Forum: Developing with WordPress
In reply to: WordPress and JQuery – how get a post via ajaxStart by looking at the code of similar plugins, or even the WordPress core code (because it does indeed use Ajax for various things including autosave). You won’t find anything more accurate than the source code for a how-to, and if it’s been done the code is out there… it might even already be on your hard drive.
Forum: Plugins
In reply to: Real Estate plugin released@gillsans, first of all, you can control everything – first with CSS and if you need different fields in different places, you can customize a template with template tags.
The plugin supports localization and there’s already an Italian file that comes with the plugin. Localization includes changing terms like feet and acres to meters and hectares, even English phrases like “for rent” to the local equivalent “to let” if you will…
As for updates and support, I plan to add features and you can find out more on my user forums. Updates depend on my schedule and how important the update is. But the nice thing about WordPress is, it’s all PHP and the plugin is licensed under the GPL so there’s no dead end even if I get hit by a bus one day…