Adding onload to body

And here’s a jQuery solution (as Mike suggested in his first comment). function add_my_scripts() { wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘my_init_script’, SCRIPTSRC, ‘jquery’, ‘1.0’ ); } add_action( ‘init’, ‘add_my_scripts’ ); Then add a script to your plug-in that does this: jQuery.noConflict(); jQuery(document).ready(function($) { init(); }); This will start jQuery in no conflict mode (if it isn’t … Read more

How to tell if Jetpack’s Photon is active?

We just committed a new function to Jetpack Trunk, and it should be enabled in the next release, Jetpack::is_module_active() — http://plugins.trac.wordpress.org/changeset/716884 Then you can just call: if( class_exists( ‘Jetpack’ ) && Jetpack::is_module_active( ‘contact-form’ ) ) {} Or at least, you will once the next version releases, and the user has their Jetpack updated. 🙂 If … Read more

Add a subitem to Woocommerce section

Short answer, use: $args = array(‘show_in_menu’ => ‘woocommerce’); register_post_type(‘my_posttype’, $args); But this won’t give you the custom post type submenus. You can also use add_submenu_page, the code below is just an example: function register_my_custom_submenu_page() { add_submenu_page( ‘woocommerce’, ‘My Custom Submenu Page’, ‘My Custom Submenu Page’, ‘manage_options’, ‘my-custom-submenu-page’, ‘my_custom_submenu_page_callback’ ); } function my_custom_submenu_page_callback() { echo ‘<h3>My … Read more

Sending all emails using SMTP

You are trying with your Gmail mail server and it’s blocked from Gmail not form your host. Enable Gmail less secure apps into your Gmail account. If you want to allow access anyway, follow these steps: 1) Go to the Less secure apps section of your Google Account. 2) Turn on Allow less secure apps. … Read more

How can I import a class privately into a plugin?

Use namespaces, but check the PHP version on the server side and deactivate the plugin with a useful error message if the requirements aren’t met. If you look at the official statistics, you can see how many installations are still running on outdated WordPress versions. But almost all new plugins require the latest WordPress version, … Read more