Using Checkboxes on Plugin Options Page for Custom Plugin

This should do it: // Going to add a conditional statement here to run this vc_remove_element function if the checkbox for Row is selected vc_remove_element( “vc_row” ); // Row add_action(‘admin_menu’, ‘plugin_admin_settings_tab’); function plugin_admin_settings_tab() { add_options_page(‘Remove Visual Composer Elements’, ‘Remove Visual Composer Elements’, ‘manage_options’, ‘remove_visual_composer_elements’, ‘plugin_rvce_options_page’); add_action(‘admin_init’, ‘plugin_rvce_admin_init’); } ?> <?php function plugin_rvce_options_page() { ?> <div> … Read more

Performance of several get_option() calls

If you check the implementation of get_option() you’ll see that in line 168 it calls wp_cache_get() like so: $value = wp_cache_get( $option, ‘options’ ); This means multiple calls to get_option(“style_settings”) within the same PHP execution will be served from cache. There is no need to re-invent this, as you might break other functionality with it. … Read more

How to update selective options on plugin settings page

First kick in your validation callback by changing the register_setting() to register_setting( ‘pluginname_options’, ‘pluginname-settings’, ‘pluginname_validate’ ); And then update your validation function to actually do something. Below it gets the current state of the options, and then only updates the pieces of the array that are submitted. When you are on a tab and click … Read more

Is it possible to set a option, and then redirect to another page directly from a admin notice link?

You could use /wp-admin/admin-post.php. Link: $url = admin_url( ‘admin-post.php?action=somethingunique’ ); print “<a href=”https://wordpress.stackexchange.com/questions/85825/$url”>Update and redirect</a>”; Then you should register a callback for that action: add_action( ‘admin_post_somethingunique’, ‘wpse_85825_callback’ ); And in that callback you can do what you want: function wpse_85825_callback() { if ( current_user_can( ‘manage_options’ ) ) update_option( ‘my_option’, ‘some_value’ ); wp_redirect( admin_url( ‘users.php’ ) … Read more

What is the correct form action URL for network options pages?

When referring to urls within the network-admin, you should consider the network_admin_url(). core function, that falls back to admin_url() for non-multisite setups. So try this, using add_query_arg just as @toscho uses in the answer OP links to: echo esc_url( add_query_arg( ‘action’, ‘your_option_name’, network_admin_url( ‘edit.php’ ) ) ); instead of hard-coding it with possible wrong assumptions … Read more