wp_usermeta wp_usersettings

When a user changes their admin settings; like the screen options, posts per page or moves metaboxes around or ‘hides’ them, it is saved in their user settings. So if user settings are blank – the user has never tailored their admin environment. Aside: (I use this to great advantage in one of my plugins … Read more

How to create a drop down list with pages to a themes options page?

I have found the solution. I used the wordpress function wp_dropdown_pages <?php function combo_select_page_callback() { $options = get_option(‘function plugin’); wp_dropdown_pages( array( ‘name’ => ‘function plugin[ID used to identify the field throughout the theme]’, ‘echo’ => 1, ‘show_option_none’ => __( ‘&mdash; Select &mdash;’ ), ‘option_none_value’ => ‘0’, ‘selected’ => $options[‘ID used to identify the field throughout … Read more

Implementing action correctly

do_action() does not use a returned value. It works more like the onload event in JavaScript: You cannot undo the load. To change a value you need filters. If you want to change the option content, hook into pre_update_option_{$option_name} very late (with a high priority parameter): add_filter( ‘pre_update_option_myp_settings’, ‘myp_settings_et_validate’, 100, 3 ); function myp_settings_et_validate( $option, … Read more

Run function on settings save

I’m not familiar with wordpress settings api but I know those options generated by settings api are handled/saved in wp-admin/options.php Unfortunately, if ( isset( $_POST[ $option ] ) ) { $value = $_POST[ $option ]; if ( ! is_array( $value ) ) $value = trim( $value ); $value = stripslashes_deep( $value ); } update_option( $option, … Read more

Custom blog settings

Here is part of a class I wrote for client recently: if ( is_admin() ) RevenueCalculatorAdminSettings::init(); /** * Call this class with: * * RevenueCalculatorAdminSettings->init(); * * or * * RevenueCalculatorAdminSettings->init( ‘text_domain’ ); * */ class RevenueCalculatorAdminSettings { public static $text_domain = ”; /** * Add actions to produce new settings. * * @param string … Read more

Two settings_fields in one form

take a look at https://tommcfarlin.com/multiple-sections-on-wordpress-options-pages/ You can… add_settings_section(“owlish_license”, “SECTION NAME”, null, “theme-options”); add_settings_section(“owlish_settings_group”, “SECTION NAME 2”, null, “theme-options”); add_settings_field(“owlish_display_notes”, “Display Notes”, “callback1”, “theme-options”, “owlish_license”); register_setting(‘owlish_settings_all’,’owlish_display_notes’); add_settings_field(“owlish_display_notes2”, “Display Notes 2”, “callback2”, “theme-options”, “owlish_settings_group”); register_setting(‘owlish_settings_all’,’owlish_display_notes2′); after you can use this wrapper on page settings_fields(“owlish_settings_all”); do_settings_sections(“theme-options”); Have a nice day.

Settings API – Separating PHP and HTML

Settings API is (also) about the modularity of the settings, settings can be removed (never heard of anyone do it but it is possible) or amended (my favorite technique right now). When you separate the HTML and PHP you are breaking the modularity so maybe the setting API should just not be used by you. … Read more

How to store a value on WP_option table

replace your code with as. <?php function myplugin_register_settings() { add_option(‘marker_pin’,”); register_setting( ‘marker_group’, ‘marker_pin’, ‘myplugin_callback’ ); } add_action( ‘admin_init’, ‘myplugin_register_settings’ ); function myplugin_register_options_page() { add_options_page(‘Google Map’, ‘Map’, ‘manage_options’, ‘Google_map’, ‘myplugin_options_page’); } add_action(‘admin_menu’, ‘myplugin_register_options_page’); function plugin_admin_enqueue_styles() { wp_enqueue_script( ‘google-maps’, ‘https://maps.googleapis.com/maps/api/js?key=AIzaSyBPUcMLet39Rn_MXvOJErCbT7VnsOAVPWc&libraries=places&callback=initMap’, array(‘jquery’),’1.0′, true ); wp_enqueue_script( ‘ajax-js’, ‘https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js’, array(‘jquery’),’1.0′, true ); wp_enqueue_script( ‘code-js’, ‘https://code.jquery.com/jquery-1.11.3.min.js’, array(‘jquery’),’1.0′, true ); } add_action( … Read more

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