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"

Tuesday, 23 May 2017

Create multi language file in wordpress

#######define Constant in wp-config.php file ######
define ('WPLANG', 'en_US');

#####add code in function.php######
function my_child_theme_locale() {
   load_child_theme_textdomain( 'framework', get_stylesheet_directory() . '/languages' );
}

add_action( 'after_setup_theme', 'my_child_theme_locale' );

####create mo file in wordpress commond###########
msgcat default.po | msgfmt -o languages/en_US.mo -

Monday, 17 April 2017

add ip for phpmyadmin


/etc/phpmyadmin$ sudo vim config.inc.php
/* Advance to next server for rest of config */
    $i++;
    $cfg['Servers'][$i]['verbose'] = 'Anil DB Magic2';
    $cfg['Servers'][$i]['host'] = 'XXX.XXX.X.XXX';
    $cfg['Servers'][$i]['port'] = '';
    $cfg['Servers'][$i]['socket'] = '';
    $cfg['Servers'][$i]['connect_type'] = 'tcp';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    $cfg['Servers'][$i]['AllowNoPassword'] = false;

Monday, 27 March 2017

ckeditor for multiple id

var editor_config = {
    toolbar: [
        {name: 'basicstyles', items: ['Bold', 'Italic']},
        {name: 'paragraph', items: ['BulletedList']}
    ],
    width: "210px",
    height: "140px"
};

CKEDITOR.replace('dsi3', editor_config );
CKEDITOR.replace('dsi4', editor_config );
CKEDITOR.replace('dsi5', editor_config );
CKEDITOR.replace('dsi6', editor_config );