Customize Plugin

Your update_option should be inside a hook callback and should check to see if $_POST[‘custom_welcome_panel’] is set before trying to update the option. Otherwise that could be overwriting your option every time the page loads. And, honestly, as written I could shove anything I wanted into that option value. I’d just have to send a … Read more

Add a custom stylesheet for BlackBerry

Well… You’ve already used wp_enqueue_style. Use it again. That is the canonical mechanism for loading stylesheets either by itself or in combination with wp_register_style wp_enqueue_style(‘blackberry’,get_stylesheet_directory_uri().’/path/to/blackberry.css’); I feel compelled to note that user agent sniffing is not especially reliable. Is it not possible to do this with media queries? Reference http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

Where do posts get the sidebar from?

get_sidebar() accepts a parameter $name. Then will look for a file sidebar-{$name}.php. So what you can do is: get_sidebar( get_post_type() ); // search for sidebar-post.php or sidebar-page.php or: if ( in_category( array( ‘featured-listing’, ‘listing-post’ ) ) ) get_sidebar( ‘listing’ ); // sidebar-listing.php else get_sidebar();

Sum custom field values of particular taxonomy

You would have to JOIN a couple of tables. SELECT meta_value FROM wp_postmeta as pm INNER JOIN wp_term_relationships as tr ON (pm.post_id = tr.object_id) INNER JOIN wp_term_taxonomy as tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE 1 AND tt.taxonomy = ‘laptop’ AND pm.meta_key = ‘quantity’ I am fairly sure that is right. These things are complicated. If … Read more

wp_kses and magic quotes

WordPress is still adding slashes to data sent per POST, so yes, in some cases you might have to remove the slashes. There are two options: Use stripslashes_deep( $value ). This function accepts an array, an object or a string and removes the slashes. Get POST data per: $data = file_get_contents( ‘php://input’ ); This takes … Read more

Common abstract class for plugins

Unfortunately there is no system in WordPress to handle dependencies and sharing components between extensions is a challenge. The possible solutions roughly are: make shared part a plugin and require each plugin to require it (and possibly auto install/activate) implement loader that will take care of processing versioning for shared part and take care of … Read more

Integrate WordPress in Yii

I don’t have any experience with Yii, but looking at their Wiki there are already some solutions: Integrating WordPress and Yii,Working Out The Details. Integrating WordPress and Yii: still another approach, using Yii as the router/controller Integrating WordPress and Yii: yet another approach Integrating Yii with WordPress Run an Yii Application inside an WordPress page … Read more

Category Thumbnail Display – How to display ONLY the main Category

Ideally, place this in a plugin (so it’s not overwritten when you update the theme): function wpse_106185_elist_categories( $args ) { return $args + array( ‘depth’ => 1, ); } add_filter( ‘listing_categories_args’, ‘wpse_106185_elist_categories’ ); Alternatively, a quick fix is to edit this line… $elist_categories_args = array( ‘hide_empty’ => 0 ); To… $elist_categories_args = array( ‘hide_empty’ => … Read more

Removing unneccessary p-tags (Not every p)

If what you want is really only to prevent WordPress from adding empty <p></p> and you’d be happy with removing those after post retrieval from the database, then function wpse108194_remove_empty_paragraphs( $content ) { $content = preg_replace( ‘#<p>\s*</p>#’, ”, $content ); return $content; } add_filter( ‘the_content’, ‘wpse108194_remove_empty_paragraphs’, 11 ); will do.