Need help understanding/coding with Settings API

You have some of the callback functions and the ID’s mixed up, try this: add_action(‘admin_init’, function() { register_setting(‘elem_opts’, ‘elem_opts’, ‘elem_validate_opts’); add_settings_section(‘elem_opts_form1’, ‘Elements Theme Options’, ‘elem_opts_form’, ‘elem_opts’); add_settings_field(‘elem_opts_form’, ‘Facebook’, ‘elem_opts_social_fb_cb’, ‘elem_opts’, ‘elem_opts_form1’); }); function elem_opts_social_fb_cb() { $opts = get_option(‘elem_opts’); if (empty($opts) || !is_array($opts)) { $opts = array(); } ?> <input type=”text” name=”elem_opts[fb]” value=”<?php echo $opts[‘fb’] ? … Read more

Display user HTML on website

You may need to un-escape the output. Take a look at html_entity_decode or similar functions before outputting to the screen. $orig = “I’ll \”walk\” the <b>dog</b> now”; $a = htmlentities($orig); $b = html_entity_decode($a); echo $a; // I’ll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now echo $b; // I’ll “walk” the <b>dog</b> now html_entity_decode function MKWD_Display_Westmor_Bottom_Left() { $westmor_customers_options = … Read more

Single callback with multiple setting fields

add_settings_field() accepts six arguments, the last one is an array of arguments: add_settings_field($id, $title, $callback, $page, $section, $args); You can add custom values here, so you can reuse one callback. A simple example: add_settings_field( ‘foo’, ‘Foo’, ‘wpse_settingsfield_callback’, ‘my_page’, ‘my_section’, array ( ‘context’ => ‘foo’ ) // custom arguments ); add_settings_field( ‘bar’, ‘Bar’, ‘wpse_settingsfield_callback’, ‘my_page’, ‘my_section’, … Read more

Same option_id=0 for 2 options in wp_options?

If we check how the wp_options table is created (in 4.4) from the schema.php file, we will find the following: CREATE TABLE $wpdb->options ( option_id bigint(20) unsigned NOT NULL auto_increment, option_name varchar(191) NOT NULL default ”, option_value longtext NOT NULL, autoload varchar(20) NOT NULL default ‘yes’, PRIMARY KEY (option_id), UNIQUE KEY option_name (option_name) ) $charset_collate; … Read more

Setting the uploads directory

You can use the ‘upload_dir’ filter add_filter(‘upload_dir’, ‘set_upload_folder’, 999); function set_upload_folder( $upload_data ) { // absolute dir path, must be writable by wordpress $upload_data[‘basedir’] = trailingslashit(ABSPATH). ‘/files’; $upload_data[‘baseurl’] = ‘http://subdomain.wptest.com/files’; $subdir = $upload_data[‘subdir’]; $upload_data[‘path’] = $upload_data[‘basedir’] . $subdir; $upload_data[‘url’] = $upload_data[‘baseurl’] . $subdir; return wp_parse_args($upload_data, $upload_data); } This code will works no matter if year/month … Read more

Huge wp_options table

I’d be interested to validate what you’re looking at there to make sure it really is that table. MySQL shouldn’t behave like this unless you actually have 12Gb in a row somewhere. But if you can run SQL on this database, maybe you want to try MySQL OPTIMIZE TABLE command which asks MySQL to see … Read more

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