How to make a plugin require another plugin?

Thanks for the answers guys. Though both answers set me on the right path, none worked out of the box. So I’m sharing my solutions below. Method 1 – Using register_activation_hook: Create the Parent Plugin in plugins/parent-plugin/parent-plugin.php: <?php /* Plugin Name: Parent Plugin Description: Demo plugin with a dependent child plugin. Version: 1.0.0 */ Create … Read more

Settings API with arrays example

Short answer: your name attribute values must use the schema option_name[array_key]. So, when you use … <input name=”option_name[key1]”> <input name=”option_name[key2]”> … you get an array as option value in your validation function: array ( ‘key1’ => ‘some value’, ‘key2’ => ‘some other value’ ) PHP does that for you, this is not a WordPress feature. … Read more

How can you check if you are in a particular page in the WP Admin section? For example how can I check if I am in the Users > Your Profile page?

The way to do this is to use the ‘admin_enqueue_scripts’ hook to en-queue the files you need. This hook will get passed a $hook_suffix that relates to the current page that is loaded: function my_admin_enqueue($hook_suffix) { if($hook_suffix == ‘appearance_page_theme-options’) { wp_enqueue_script(‘my-theme-settings’, get_template_directory_uri() . ‘/js/theme-settings.js’, array(‘jquery’)); wp_enqueue_style(‘my-theme-settings’, get_template_directory_uri() . ‘/styles/theme-settings.css’); ?> <script type=”text/javascript”> //<![CDATA[ var template_directory … Read more

Creating a table in the admin-style?

This is what I generally use: <table class=”widefat fixed” cellspacing=”0″> <thead> <tr> <th id=”cb” class=”manage-column column-cb check-column” scope=”col”></th> // this column contains checkboxes <th id=”columnname” class=”manage-column column-columnname” scope=”col”></th> <th id=”columnname” class=”manage-column column-columnname num” scope=”col”></th> // “num” added because the column contains numbers </tr> </thead> <tfoot> <tr> <th class=”manage-column column-cb check-column” scope=”col”></th> <th class=”manage-column column-columnname” scope=”col”></th> … Read more