How to save the option’s new values plus old value without overwrite old one

You are misspelling the variables names. You define them as $new_value and $old_value with underscore that you forgot about. Except this your code working fine. function myplugin_update_field_foo( $new_value, $old_value ) { if ($new_value !== $old_value && is_array($old_value) && is_array($new_value)) { $new_value = array_unique( array_merge( $new_value, $old_value ) ); } return $new_value; } To get the … Read more

How to implement theme option to change bootstrap 4 container from .container to .container-fluid

Here is possible solution that works (theme name is “zoran”): //1. Step (Create Customizer section, setting, control) //In functions.php include or directly put code that goes something like this: function zoran_customize_register( $wp_customize ) { $wp_customize->add_section( ‘zoran_sekcija’, array( ‘title’ => __( ‘Zoran’, ‘zoran’ ), ‘priority’ => 35, ) ); $wp_customize->add_setting( ‘zoran_postavka’, array( ‘default’ => ‘container’, ‘type’ … Read more

Plugin Options Page and Subpage

If you want to use multiple options pages for plugin, ensure that your sanitize function gets the additional missing options from the database example public function sanitize($input): array { /** My Plugin Setting Options */ $option = get_option(‘my_plugin_settings’); /** Do this for all the settings keys in your options array */ if ($input[‘setting_key’]) { $output[‘setting_key’] … Read more

Problem with checkbox in Settings API

I managed to figure this out. It was because on the template page where I output the form I had forgotten to include the settings_fields function, so it was not saving the setting. I added the following code below to that page and then it worked: <?php settings_fields(‘prev-next-setting’); ?>

Button to clear transients

I have managed to do the following. I made a clear cache button: function advanza_direct_plugin_delete_transients() { delete_transient( ‘advanza_direct_terms_of_service’ ); delete_transient( ‘advanza_direct_privacy_policy’ ); // at the end redirect to target page exit( wp_redirect( admin_url( ‘admin.php?page=advanza-direct-plugin-settings’ ) ) ); } add_action( ‘admin_post_advanza_direct_plugin_delete_transients’, ‘advanza_direct_plugin_delete_transients’ ); I put this where I have my admin logic: <form action=”<?php echo admin_url(‘admin-post.php’); … Read more

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