Checking if Database Table exists

If you use “IF NOT EXISTS” then the dbdelta script will not upgrade your database with delta’s appeared after the initial creation of the database. (assuming you want to re-use the same sql script) at least… that is what i think

What are the common security flaws I need to look for? [closed]

Here is a modified checklist, based on my current (work-in-progress) settings/data security checklist used for reviewing Themes (the principles should be no different for Plugins than they are for Themes): Plugins should prefix all options, custom functions, custom variables, and custom constants with plugin-slug. Plugins should implement Plugin Options and Plugin Settings pages deliberately, rather … Read more

How do you get the post thumbnail size?

When an image size is added either by WordPress(add_image_size), or by a plugin or your own custom code it gets added into the $_wp_additional_image_sizes global, i can’t find a similar function for pulling data from that global, but you could certainly just look inside the global to determine what width and height a registered image … Read more

Check if function called by cron job

WordPress has a constant DOING_CRON that helps us know we’re doing the cron jobs or not. It’s defined in wp-cron.php file. So, you can check this constant in your code: if ( defined( ‘DOING_CRON’ ) ) { // Do something }

Where can I sell WordPress themes and plugins? [closed]

here is a nice brake down for you: MarketPlaces Themes: Theme Forest – Probably the biggest theme marketplace by Evanto. Rates: New authors begin at the 50%. Templamatic – Rates: between 50% and 70%. BuyStockDesign – Rates: Start from 50% to 75%. BuySellWordpress – Rates: Starts from 50% and may go up to 70%. WPmart … Read more

How to Display Product specific to a category with WooCommerce Plugin? [closed]

You need to create a new loop for that. Here’s the code I use for displaying products from a specific category on the home page: <ul class=”products”> <?php $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 1, ‘product_cat’ => ‘shoes’, ‘orderby’ => ‘rand’ ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : … Read more

What is the design pattern for WordPress Core?

Spaghetti with meatballs The term “spaghetti with meatballs” is a pejorative term used in computer science to describe loosely constructed object-oriented programming (OOP) that remains dependent on procedural code. It may be the result of a system whose development has included a long life cycle, language constraints, micro-optimization theatre, or a lack of coherent coding … Read more

How do I save metadata for a specific custom post type only?

function save_my_metadata($ID = false, $post = false) { if($post->post_type != ‘your_post_type’) return; update_post_meta($ID, ‘my_metadata’, $_POST[‘my_metadata’]); } That should work. Just replace ‘your_post_type’ with the name of the post type. Also, little known fact: the ‘save_post’ hook passes the post’s ID as an argument. EDIT I updated the function to reflect Jan’s comment. Thanks Jan!