Skip to content

Instantly share code, notes, and snippets.

@ibrokemywp
ibrokemywp / serialize-options.php
Last active October 25, 2020 10:23
Store all of your options in a single serialized array in the database
/**
* Register a single setting to store all of your options in the database
*/
register_setting( 'myslug_option_group', 'myslug', 'myslug_sanitize_options_array' );
/**
* Define each of your settings
*/
add_settings_field(
'name',
@aayushdrolia
aayushdrolia / gist:23b40152f34fa790773ea894fd4d6091
Last active October 14, 2022 06:59
Comment form validation message on the same page in wordpress
***********************************************
PHP CODE (add it in your theme's functions.php)*
***********************************************
function insert_jquery_validate(){
wp_enqueue_script('validate', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js', array( 'jquery' ), false, true );
}
add_filter('wp_enqueue_scripts','insert_jquery_validate');
@joshuafredrickson
joshuafredrickson / no-nags.php
Created January 29, 2019 14:46
WordPress: Move all admin notices and plugin nags to console
add_action('plugins_loaded', function() {
$action = is_user_admin() ? 'user_admin_notices' : 'admin_notices';
add_action($action, function () {
ob_start();
});
add_action('all_admin_notices', function () {
$log = strip_tags(trim(ob_get_clean()));