Wednesday, 26 July 2017

jquery validation message overide

Add this code in a separate file/script included after the validation plugin to override the messages, edit at will :)
jQuery.extend(jQuery.validator.messages, {
    required: "This field is required.",
    remote: "Please fix this field.",
    email: "Please enter a valid email address.",
    url: "Please enter a valid URL.",
    date: "Please enter a valid date.",
    dateISO: "Please enter a valid date (ISO).",
    number: "Please enter a valid number.",
    digits: "Please enter only digits.",
    creditcard: "Please enter a valid credit card number.",
    equalTo: "Please enter the same value again.",
    accept: "Please enter a value with a valid extension.",
    maxlength: jQuery.validator.format("Please enter no more than {0} characters."),
    minlength: jQuery.validator.format("Please enter at least {0} characters."),
    rangelength: jQuery.validator.format("Please enter a value between {0} and {1} characters long."),
    range: jQuery.validator.format("Please enter a value between {0} and {1}."),
    max: jQuery.validator.format("Please enter a value less than or equal to {0}."),
    min: jQuery.validator.format("Please enter a value greater than or equal to {0}.")
});

Tuesday, 25 July 2017

remove update from wordpress

/*&
     *@Disable auto update plugn and themes and wordpress version
     */
   
    add_action('after_setup_theme','remove_core_updates');
    function remove_core_updates()
    {
    if(! current_user_can('update_core')){return;}
    add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
    add_filter('pre_option_update_core','__return_null');
    add_filter('pre_site_transient_update_core','__return_null');
    }

    remove_action('load-update-core.php','wp_update_plugins');
    add_filter('pre_site_transient_update_plugins','__return_null');

change column position in wordpress








 add code on function.php

 //change manage_finance_posts_columns finance to your custom posttype

function array_insert( $array, $index, $insert ) {
    return array_slice( $array, 0, $index, true ) + $insert +
    array_slice( $array, $index, count( $array ) - $index, true);
}
add_filter('manage_finance_posts_columns', 'hs_finance_table_head');
function hs_finance_table_head( $columns ) {   

    return array_insert( $columns, 2,['country'=>'Country']);  

}

add_action( 'manage_finance_posts_custom_column', 'hs_finance_table_content');

function hs_finance_table_content( $column_name, $post_id ) {
   
    if( $column_name == 'country' ) {
       
                echo get_post_field('country', $post_id);       
    }

Monday, 3 July 2017

get all querystring from javascript

/*
    * get all querystring
    */
   function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, " "));
}

    var getCountryData = getParameterByName('country'); // "lorem"