append stylesheet via shortcode

here is a handy function i use a lot which is based on the_posts hook function check_for_shortcode($posts) { if ( empty($posts) ) return $posts; $flag = false; foreach ($posts as $post) { if ( stripos($post->post_content, ‘[YOUR_SHORTCODE_HERE’) ) $flag = true; break; } if ($flag){ //add scripts and styles here eg: //wp_enqueue_script //wp_enqueue_style } return $posts; … Read more

Automatic updates not working/plugins not installing

Jeff, unfortunately this looks like a problem with your hosting setup, so your host will be the only one who can help. If they can’t, and the problem doesn’t correct itself, I’d recommend exporting your site and moving to a more supportive host. In the meantime, though, who is your current host? If you have … Read more

Good tools for locating hooks in a wordpress page/admin interface/blog post?

It is usually easy to find most hooks in documentation or source. It can be much more tricky for hooks that are dynamically generated, like post transitions. Essentially it doesn’t exist in source as specific hook – it is hook that is getting generated dynamically at runtime, depending on variables. do_action(“${old_status}_to_$new_status”, $post); do_action(“${new_status}_$post->post_type”, $post->ID, $post); … Read more

Plugin to set all Posts in a certain Category to a certain Post Format

Try putting this plugin in your wp-content/plugins folder and then activate it: <?php /* Plugin Name: WPSE53245 – Set Tweet category posts as Aside Plugin URI: http://http://wordpress.stackexchange.com/questions/53235 Description: Set Tweet category posts as Aside Version: 0.1 Author: Ashfame Author URI: http://wordpress.stackexchange.com/users/1521/ashfame */ add_action( ‘save_post’, ‘wpse53235_set_post_format_aside’ ); function wpse53235_set_post_format_aside( $postID ) { if ( has_post_format( ‘aside’, … Read more

How to make my plugin theme-independent?

Shortcode is definitely a good start. It is very flexible in terms of where you output the content (widget, post, page, inside php function, etc). You can also override the template output easily by using action hooks and custom post type that you create: add_action(‘the_content’, ‘add_project_content’); function add_project_content($content) { // Only override the content of … Read more

Help With A Reverse Pagination Plugin

This function will give you a url for a page number without stripping the url for page 1: function get_pagenum_link_full($pagenum = 1, $escape = true ) { global $wp_rewrite; $pagenum = (int) $pagenum; $request = remove_query_arg( ‘paged’ ); $home_root = parse_url(home_url()); $home_root = ( isset($home_root[‘path’]) ) ? $home_root[‘path’] : ”; $home_root = preg_quote( $home_root, ‘|’ … Read more