Theme settings default, strange behavior before first save

Don’t rely on the options ever getting saved. Better is for the Theme to function normally, whether or not the user ever visits the Theme Settings page. First step is to define a function to return your option defaults, either: Define them in the function, and then reference that function in your option parameters array … 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

Ajax – Call to undefined function get_option()

You’re firing a request to a PHP file that won’t have the WordPress library loaded – hence the undefined function error. You could manually load in WordPress with something like require ‘../../../wp-load.php’. Or, better yet, use the awesome AJAX API. Just fire your request to wp-admin/admin-ajax.php and then register a callback in your plugin or … Read more

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