Possible to add another setting to ‘Front page displays’ setting for Custom Post Type

It appears that the options-reading.php file is hard-coding its options, rather than using the Settings API. And that option is using wp_dropdown_pages() specifically. The Codex lists the following arguments for wp_dropdown_pages(): <?php $args = array( ‘depth’ => 0, ‘child_of’ => 0, ‘selected’ => 0, ‘echo’ => 1, ‘name’ => ‘page_id’); ?> The Codex page also … Read more

Disable $title in Plugin Options Screen?

As background, and to answer my own question (after some research), the <form> tag in an Options screen is usually generated with code similar to this: <form action=’options.php’ method=’post’> <?php settings_fields( ‘pluginPage’ ); // initializes all of the settings fields do_settings_sections( ‘pluginPage’ ); // does the settings section; into a table submit_button(); // creats the … Read more

Settings API – how to update multiple options manually?

Fetch current options, and be sure to return an array if empty: $current_options = get_option( ‘option_name’, array() ); Ensure desired options are in an array: $desired_options = array( /* whatever you need goes here */ ); Merge them, using [wp_parse_args()]1: $merged_options = wp_parse_args( $current_options, $desired_options ); Update update_option( ‘option_name’, $merged_options ); Of course, the trick … Read more

Settings API – Undefined Index when unchecking checkbox

Managed to fix this by doing the following: function dat_checkbox_field_0_render( ) { $options = get_option( ‘dat_settings’ ); $a = $options; if (array_key_exists(“dat_checkbox_field_0″,$a)) { } else { $options[‘data_checkbox_field_0’] = false; } ?> <input type=”checkbox” name=”dat_settings[dat_checkbox_field_0]” <?php checked( $options[‘dat_checkbox_field_0’], 1 ); ?> value=”1″> <?php }

Saving multiple checkboxes with WordPress settings api

The field name should be uwcc_settings[uwcc_checkbox_field_1][], i.e. turn the field into an array. Secondly, when saved as an array, you should use in_array() along with the checked() function. But first, let’s put the uwcc_checkbox_field_1 option’s values into a variable: $uwcc_checkbox_field_1 = isset( $options[‘uwcc_checkbox_field_1’] ) ? (array) $options[‘uwcc_checkbox_field_1’] : []; Now you call checked() like so … Read more

Settings API erases itself?

The reason is that if you are on page 1, the data that is posted to be saved is an array of the form: XX_theme_settings=array(‘XX_Option1′ =>’input1′,’XX_Option2’=>’input2′,…) and contains no data from page 2. This is because the input from page 2 is not posted with it (since it wasn’t in the same <form> – it’s … Read more

Why won’t register_setting() create a setting?

I am not exactly sure what you mean by saying that you can see your settings section and fields displayed correctly, but your my_plugin_settings has not been created. I know sometimes I forget to add the actual admin part in which generally looks something like this: settings_fields( ‘my_plugin_settings’ ); do_settings_sections( ‘my_plugin_settings’ ); submit_button(); Or is … Read more

Import / Export Settings API fields values?

I just came across this wp.tuts tutorial a few days ago: Creating a Simple Backup/Restore Settings Feature Lee Pham on Jun 22nd 2012 In this tutorial, I’m going to show you how to create a simple backup/restore feature for your WordPress blog. With this feature, you can backup all options to another place, that you … Read more

Add Admin Menu Inside Construct or Init

The callback you have given in add_menu_page() is a static function, not a class method. It should be: add_menu_page( ‘School Manager Settings’, ‘School Manager’, ‘administrator’, ‘school-manager-settings’, array ( $this, ‘show_admin_settings_page’ ) ); And please don’t use &$this anymore, that’s PHP 4. 🙂 My demo plugin T5 Admin Menu Demo might help understanding how that works.

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