List all sidebar names?

Loop through the global: <select> <?php foreach ( $GLOBALS[‘wp_registered_sidebars’] as $sidebar ) { ?> <option value=”<?php echo ucwords( $sidebar[‘id’] ); ?>”> <?php echo ucwords( $sidebar[‘name’] ); ?> </option> <?php } ?> </select> Note: The ucwords() function is only there to display it exactly as you asked. Not sure if you really want that. How to … Read more

Unit testing for plugin development

As an ex-software engineer building large business types who landed in an interactive agency let me give you a few thoughts on testing when developing for WordPress: Your Unit Testing should test the smallest amount of behavior that a class can perform. Each class should be able to be tested independently of WordPress. If you … Read more

Is get_option function cached?

When in doubt, look at the source code. Digging in to get_option(), you’ll see (abbreviated): $value = wp_cache_get( $option, ‘options’ ); if ( false === $value ) { $row = $wpdb->get_row( $wpdb->prepare( “SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1”, $option ) ); // Has to be get_row instead of get_var because of … Read more

How to redirect to settings page once the plugin is activated?

Maybe using the wp_redirect() function in the activation hook. In the following example myplugin_settings is a placeholder. Normally this simply is the $hook_suffix you get back from $hook_suffix = add_menu_page( /* etc. */ ); and similar functions. THIS CODE DOESN’T WORK, READ BELOW register_activation_hook(__FILE__, ‘cyb_activation’); function cyb_activation() {     // Don’t forget to exit() … Read more

error code: 521