is_plugin_active function doesn’t exist

That’s because the file in which is_plugin_active() is defined – wp-admin/includes/plugin.php – is only loaded in the admin, after your plugin is loaded. Thus, you can only call it after ‘admin_init’ has fired: function check_some_other_plugin() { if ( is_plugin_active(‘some-plugin.php’) ) { … } } add_action( ‘admin_init’, ‘check_some_other_plugin’ );

Adding Additional Attributes in Script Tag for 3rd party JS

you can try to use the script_loader_src filter hook e.g: add_filter(‘script_loader_src’,’add_id_to_script’,10,2); function add_id_to_script($src, $handle){ if ($handle != ‘dropbox.js’) return $src; return $src.”‘ id=’dropboxjs’ data-app-key=’MY_APP_KEY”; } Update i just figured it out myself that the src is escaped by esc_url, so looking a bit more i found the clean_url filter which you can use to return … Read more

Given the ID of a product in woocommerce, how can I get its URL?

Products in WooCommerce are a custom post type, so this should work: $url = get_permalink( $product_id ); You can treat that $product_id as a postID (that’s what it is), so you can use it with other normal WP functions, like: echo ‘<a href=”‘.get_permalink($product_id).'”>’.get_the_title($product_id).'</a>’;

In what order does WordPress load plugin files?

Answer to the First question: In wp-settings.php, WordPress first checks for any must-use plugins (plugins in the optional mu-plugins folder) and loads those. Then, if you’re running a multisite installation, it checks for plugins that are network-activated and loads those. Then it checks for all other active plugins by looking at the active_plugins entry of … Read more

Should all plugins be encapsulated in a Class?

When developing a plugin should the functions be grouped together into a Class to avoid namespace conflicts? Yes, but that’s only one of the minor arguments. In-fact that’s not the “true” nature of a class in OOAD. Does using classes create performance overheads for PHP? No, not notably. Bad design and/or bad written code or … Read more