‘Global’ settings page for multisite plugin

As a reference To create network or global settings, you need to do the following Add a settings page add_submenu_page( ‘settings.php’… # cf options.php for blog level` Add a global option add_site_option($key,$value) Update a global option update_site_option($key,$value) Get a site option get_site_option($key) Global settings are saved to the sitemeta table (individual blog settings are saved … Read more

Disable plugin / plugin action via theme

When WordPress activates a plugin, it calls the activate_plugin() function. This function activates the plugin in a sandbox and redirects somewhere else on success. It’s been used by a few authors to programmatically activate plugin dependencies. There’s another function, deactivate_plugins(), that does a similar thing in reverse … it’s actually how WordPress deactivates plug-ins when … Read more

How To Activate Plugins via Code?

This is how I did it in some web apps: function run_activate_plugin( $plugin ) { $current = get_option( ‘active_plugins’ ); $plugin = plugin_basename( trim( $plugin ) ); if ( !in_array( $plugin, $current ) ) { $current[] = $plugin; sort( $current ); do_action( ‘activate_plugin’, trim( $plugin ) ); update_option( ‘active_plugins’, $current ); do_action( ‘activate_’ . trim( … Read more

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)