wp-load.php redeclares classes

The problem happens when you have a function declared in the root file of the plugin or in the functions.php file of a theme. You need to require_once a file for functions and move those functions into that file. For example: Your plugin is called some-plugin and the root file is some-plugin.php. Any function on … Read more

Change the style of h1, h2, only in post entry

You can change the styling of the editor content with your own CSS stylesheet via the add_editor_style function: function wpa_add_editor_styles() { add_editor_style( ‘custom-editor-style.css’ ); } add_action( ‘init’, ‘wpa_add_editor_styles’ ); Then in your stylesheet, add your rules: body#tinymce.wp-editor h1 { font-size: 50%; }

Use different single.php file based on condition

In a previous edit you used: if (in_category(’21’)) { include (TEMPLATEPATH . ‘/single-21.php’); } else { include (TEMPLATEPATH . ‘/single-29.php’); } This is part of your solution, but before I continue, some important notes: Don’t use include like that, instead get_template_part(‘single-21’); works better Indent correctly This clashes with how IDs work in the template heirarchy. … Read more

Use conditional logic for woocommerce variable product

Late to the party but here you go: <?php if( $product->is_type( ‘simple’ ) ){ // a simple product } elseif( $product->is_type( ‘variable’ ) ){ // a variable product } // If you need a Product object for the above: $product = new WC_Product( get_the_ID() ); Found it here: https://gist.github.com/patrickgilmour/9d4a28b4a2f0c1dcecbf and here https://wordpress.org/support/topic/condition-to-check-if-product-is-simple-or-variable. I’m glad this … Read more

How do I avoid having duplicate of plugin in trunk?

I do not know which OS and/or software you use but regarding SVN it’s quite simple : $ svn co http://plugins.svn.wordpress.org/your-plugin-name Then you just have to add your files in trunk and/or maybe in assets (banner,screenshots). Then : $ svn add trunk/* and or : $ svn add assets/* Last step is : $ svn … Read more

Looking for advice for a mail sending plugin

There is no need for a custom table here – you can use the user metadata table and API. Then create a WP-Cron job to run every 24 hours (or more frequently if you’re paranoid). On the callback query users who’ve registered in the last 7 days using something like: /* * Get all users … Read more

How to multiply a post to test internal search results?

Well, there are ways to duplicate posts, but I don’t think that’s what you need. Check out http://wordpress.org/plugins/bulk-content-creator/, which is probably exactly what you’re after, and allows you to create many posts at once for test purposes. Otherwise, check out http://codex.wordpress.org/Theme_Unit_Test where you can get test content.