Hot answers tagged

4

All those options are actually pointing to the active theme, but the difference is the value stored in each option: The options template and stylesheet both store the name of the active theme folder, e.g. twentytwentyone for the Twenty Twenty-One theme. But if you're using a child theme, then stylesheet would be the name of the child theme folder, e.g. ...


3

This is escaped JSON. Formatted nicely, it looks like this: [ { "title": "Brand Primary", "value": "#2185D0", "_id": "627a0637cf178d93e50be224cc07cd6e" }, { "title": "Brand Secondary", "value": "transparent", "_id": &...


2

Check out this thread wp_options is GB in size My wp_options table dropped from 670GB to 13.5MB after running the optimization commands they outlined


2

That's not JSON, it's serialised PHP data. If you try to store a value that isn't a primitive string/number, such as an object or array, WordPress serializes it using PHP. How do we decode this structure deserialize( ... ); However, I do not recommend relying on this for practical and security reasons. Don't store structured data as strings in the ...


2

The file wp-admin/options.php handles updates to options submitted via the admin area and filters the submitted option values against a list of allowed options for the option page that submitted the request. The allowed list (called a "whitelist" before WordPress 5.5) uses the value of the variable $option_page to determine the settings that are ...


2

The "Deleted", "Spam" and "Archived" attributes If you checked "Deleted", "Spam" or "Archived", the site would no longer be accessible to the public and all users except super admins, and the only thing non super admins would see is a notice saying: "This site is no longer available." if ...


1

I've not seen this type of title settings layout in the admin pages, so it seems you're parting away from it. Otherwise note that the title field of add_settings_field() is unescaped, so in theory one could add some HTML code for new title layout. Usually the description is added to the input field.


1

The save_post hook has a third parameter named $update, so you can use it to check if the post is being created and not updated. function define_asset( $post_id, $post, $update ) { if ( $update ) { return; } // else, run your code... } add_action( 'save_post', 'define_asset', 20, 3 );


1

Your method is correct, but the problem is that the value inside the option in your example, i.e.: get_option( 'second_option' ); is not serialized correctly ( it was either edited directly--and incorrectly--through the database or inserted with something other than update_option() ). If you var_dump( get_option( 'second_option' ) );, you'll see that it's ...


1

Nevermind, the last option was actually working, but in my own CSS code I found that I was overriding it. I cleaned up my CSS and it's working with the function I posted above. I also found an alternative method using wp_add_inline_style() which got me to look at my CSS code in more depth. Example code below: function wpdocs_styles_method() { ...


1

Fixed! function Setting_() { register_setting( 'Set_my_options', 'My_plugin_header_logo' ); register_setting( 'Set_my_options', 'My_plugin_links_facebook' ); register_setting( 'Set_my_options', 'My_plugin_links_youtube' ); register_setting( 'Set_my_options', 'My_plugin_links_email' ); register_setting( 'Set_my_options', '...


1

The wpmu_new_blog hook is indeed deprecated and shouldn't be used; however, it works because it runs after the new site has been initialized (see wp_initialize_site()) which means the database tables for that site has been created and filled with the default options. So because you are updating the site's options like default_comment_status, then you should ...


1

If you have a term, you can retrieve its meta via get_term_meta, this function works the same way as get_post_meta only it takes a term ID not a post ID E.g. if ( get_term_meta( $term_id, 'key', true ) === 'value' ) { // it has the value } Once you know this, it's just basic logic of looping over each term and checking them, which you already do in the ...


1

I guess the problem is when you do have a value for test_hs_options but that value does not have a 'duration_months' ? The default array you're supplying will only be used when there is no test_hs_options in the database: this code won't add a duration_months to a non-empty array that does not have one. Instead you can check is_array and isset to check if $...


1

Please check ID no. 13496, 13497 in page 22 of the table list


1

To complement @Radek's answer, here is another way to use his solution. public function sanitize_callback ( $options ) { $saved_options = $this->get_option( 'your_option_name' ); $options = $this->sanitize_options( $options ); if ( is_array( $saved_options ) && is_array( $options ) ) { $options = array_merge( $...


Only top voted, non community-wiki answers of a minimum length are eligible