illegal offset in option add

The array is ‘hidden’ inside the form elements. Their respective name/ID is like MY_option_name[some_other_name]. That is the array structure. // Edit (to elaborate a little on that) Suppose you have the following form: <form action=”options.php” method=”post”> Font:<br /> <input type=”text” name=”MY_options[font]” id=”MY_options[font]” /> Color:<br /> <input type=”text” name=”MY_options[color]” id=”MY_options[color]” /> <?php submit_button(); ?> </form> If … Read more

Where to adjust presets for slider options “auto rotate” (3, 5, 10, 15 seconds)? [closed]

In anybody needs this in the future I found a quick and easy workaround: you could just adjust the slider interval in the shortcode. First you have to switch to the “classic mode” (turn the Visual Composer off) and then find the shortcode that defines the interval: [vc_gallery interval=”10″ images=”22390,23006″ img_size=”full”] You can then set … Read more

WordPress Plugin default option

$default_data = Array( “plugin551-setting-group” => Array( ‘checkboxoption1’ => ‘true’, ‘checkboxoption2’ => ‘true’ ) ); if ( is_admin() && isset($_GET[‘activate’] ) && $pagenow == ‘plugins.php’ ){ global $default_data; plugin551_save_settings($default_data); } function plugin551_save_settings ( $data ) { if( isset( $data[‘plugin551-setting-group’] )){ array_walk_recursive( $data[‘plugin551-setting-group’] , ‘plugin551_clean_options’); update_option( ‘plugin551-setting-group’ , $data[‘plugin551-setting-group’] ); } } function plugin551_clean_options(&$value) { $value = … Read more

How to delete all the options in an option group

Usually, the Codex is a good resource for doing research on things like this … and there are functions related to register_setting() listed directly on it’s page in the Codex. The function you’re looking for is unregister_setting(). From it’s Codex page: Description Allows clean de-registration of registered settings. Should be used mostly in deactivation hooks. … Read more

Creating your own options-general.php page

You don’t. You would have to keep your new page in sync with the core file each time WordPress is updated … that would not be very pragmatic. Hook into the do_settings_sections(‘general’); with register_setting() and add your code here. There is a third parameter for register_setting(): you can register a callback function here which used … Read more

How can I save a setting field with multiple checkbox options generated by a foreach loop on a custom wordpress admin page?

You can use the function xprofile_get_field_data( $field, $user_id, $multi_format) * @param mixed $field The ID of the field, or the $name of the field. * @param int $user_id The ID of the user. * @param string $multi_format How should array data be returned? ‘comma’ if you want a * comma-separated string; ‘array’ if you want … Read more