Using WP CLI to set options in WP Multisite

You could probably manipulate the option with wp option update but you shouldn’t. It has plenty of dedicated commands for plugins, in your case it would probably be something like wp plugin activate active-directory-integration,disable-comments,http-authentication –url=blogs.my.domain/test1.

WordPress customizer: load controls in a custom div

Put below codes in your functions.php function sorcey_customize_register($wp_customize){ $wp_customize->add_section(‘sorcey_footer’, array( ‘title’ => __(‘New Section’, ‘text_domain’), ‘description’ => ”, ‘priority’ => 120, )); /* ============================= Text input ===============================*/ $wp_customize->add_setting(“sr_copyright”, array( “default” => “”, ‘capability’ => ‘edit_theme_options’, “transport” => “postMessage”, )); $wp_customize->add_control(new WP_Customize_Control($wp_customize, “sr_copyright_ctrl”, array( “label” => __(“Title”, “text_domain”), “section” => “sorcey_footer”, “settings” => “sr_copyright”, “type” => … Read more

Setting ‘autoload’ to ‘no’ with Settings API

The only way to accomplish this is to add the option to the database yourself before the Settings API does so. To do this, add a ‘sanitize_callback’ to the register_settings function: register_setting (‘my_options’, ‘my_option_name’, array (‘type’ => ‘string’, ‘sanitize_callback’ => ‘my_function_name’)); Then, in your function, update the option yourself: function my_function_name ($value) { update_option (‘my_option_name’, … Read more

How do you permanently remove default rewrite rules from the wp_options table?

Rather than modifying stored rules it would be more reliable to modify rules before they are stored. flush_rewrite_rules() calls WP_Rewrite->flush_rules() WP_Rewrite->wp_rewrite_rules() WP_Rewrite->rewrite_rules() Inside last there are fitting hooks to modify rules (after which result they will be saved as usual on each flush): do_action_ref_array(‘generate_rewrite_rules’, array(&$this)); $this->rules = apply_filters(‘rewrite_rules_array’, $this->rules);

How to update widget from widget() function?

Huh. It had never actually occurred to me to use widget instance as cache. I hadn’t ever seen such implementation either. This is quite an original idea, and as such it is hard to accurately point out benefits and issues with implementation. For starters update() doesn’t actually save anything, it just used as check for … 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

what is the meaning of settings_fields()

Via the Developer Reference (not the Codex) Output nonce, action, and option_page fields for a settings page. Here’s the source code for it function settings_fields($option_group) { echo “<input type=”hidden” name=”option_page” value=”” . esc_attr($option_group) . “” />”; echo ‘<input type=”hidden” name=”action” value=”update” />’; wp_nonce_field(“$option_group-options”); } so, it gives the form processor some info to work with … Read more

Why might $input (Settings API) be coming through empty?

The $input variable is not passed to the validate function by default. You need to declare it, e.g. not this: function mytheme_validate_settings() {} But rather, this: function mytheme_validate_settings( $input ) {} (Or maybe I’m the only one who’s made that bone-headed mistake before?) 🙂 EDIT: The other thing to check: does the $optiongroup in register_setting() … Read more

Theme Options page with tabs

The do_settings_section() function call needs to correspond to the $optiongroup argument you pass to register_setting(). To see how all of the myriad functions fit together, see page 10 of my tutorial. It does get fairly confusing trying to follow how the various functions string together. EDIT: You do appear to be using the option group … Read more

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