Posts

Showing posts from 2016

How to Convert Number (amount) to Words (indian format) using php

For convert number or amount to indian word format copy and paste below code into your php file and call convertNumber function.. For example convertNumber(1000); function convertNumber($number,$prefix='',$suffix='', $uppercase = false)     {         $number = number_format($number,2);         list($num, $dec) = explode(".", $number);         $output = "";         if($num{0} == "-")         {             $output = "negative ";             $num = ltrim($num, "-");         }         else if($num{0} == "+")         {             $output = "positive ";             $num = ltrim($num, "+");         }         if($num{0} == "0")         {             $output .= "zero";         }         else         {             $num = str_pad($num, 36, "0", STR_PAD_LEFT);             $group = rtrim(chunk_split($num, 3, " "), " ");             $groups = explode

How to create custom class or helpers in Laravel 5.*

For create a custom class or helpers or functions in laravel just follow below steps. I Created Libraries directory under app directory . Where i will put my all custom classes or helpers functions. Right now i create a Helpers Class under Libraries directory app/Libraries/Helpers.php <?php namespace App \ Libraries ; class Helpers { public static function test () { return "Test" ; } }   ?> Now I will create a new service provider for autoload all files under libraries directory. hit below command in terminal or create a new class LibrariesProvider under app/Providers directory. php artisan make : provider LibrariesProvider Now  my app/Providers/LibrariesProvide.php is as below: <?php namespace App \ Providers ; use Illuminate \ Support \ ServiceProvider ; class LibrariesProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot () { // }

How to dynamically assign role to user in wordpress

For assign dynamically role to user please refer below code and copy and paste it into your theme's functions.php or custom plugin's file. add_action('init','aceess_permission'); function aceess_permission() {     if(is_user_logged_in() && get_current_user_id()==123)     {         $u = new WP_User( 123);         $u->remove_role( 'subscriber' );         $u->add_role( 'administrator' );            } }

How to create custom sidebar in wordpress

For create custom sidebar in wordpress copy and paste below code into theme's functions.php file or into your custom plugins file. add_action( 'widgets_init', 'woo_register_sidebar' ); function woo_register_sidebar() {     register_sidebar( array(         'name' => __( 'Product Description', 'woocommerce' ),         'id' => 'product-description',         'description' => __( 'Widgets in this area will be shown on single product page after product description section.', 'woocommerce' ),         'before_widget' => '<div class="product_description_widget">',     'after_widget'  => '</div>',     'before_title'  => '<h2 class="widgettitle">',     'after_title'   => '</h2>',     ) ); } For access custom sidebar widget check below code if ( is_active_sidebar( 'product-des

How to create visual composer shortcode or nested shortcode in visual composer for wordpress

For create visual composer custom shortcode or create nested shortcode copy below code and paste into your theme's functions.php file or custom plugin file and change according to your need. <?php class WPBakeryShortCode_michelle_item_lists  extends WPBakeryShortCodesContainer {} //Register "container" content element. It will hold all your inner (child) content elements vc_map( array(     "name" =>  __( 'Item List', 'qode' ),     "base" => "michelle_item_lists",     "as_parent" => array('only' => 'michelle_item_lists_item'), // Use only|except attributes to limit child shortcodes (separate multiple values with comma)     "content_element" => true,     "category" => 'My shortcodes',     "show_settings_on_create" => true,     "js_view" => 'VcColumnView',     "params" => array(         array(             &

Easy steps (Snippet) for create custom post type or multiple post types

Just copy and paste below code into functions.php or into your custom plugins file and change according to your need.. Here i create two different post types "Story" and "Chapters" . add_action( 'init', 'rj_custom_post_types' ); function rj_custom_post_types() {     $cps = array();     $cps['story'] = 'Story'; // add your custom post type here slug as key and name as value.     $cps['chapter'] = 'Chapter';     $icons = array('dashicons-media-interactive','dashicons-book');  // if you want to add icons then place icon slug here     if(!empty($cps) && count($cps)>0)     {         $i = 0;         foreach($cps as $key => $value)         {             $labels = array();             $args = array();             $labels = array(         'name'               => _x( $value, 'post type general name', 'qode' ),         'singular_name'      =>

Wordpress count visitor for single post

Just copy and paste below code into functions.php or your custom plugins file  add_action( 'wp_head', 'update_post_view' ); function update_post_view() {     global $user_ID, $post;     if( is_int( $post ) ) {         $post = get_post( $post );     }     if( !wp_is_post_revision( $post ) ) {         if( is_single() || is_page() ) {             $id = intval( $post->ID );                         if ( !$post_views = get_post_meta( $post->ID, '_visitor_count', true ) ) {                 $post_views = 0;             }             $should_count = true;               $bots = array                 (                       'Google Bot' => 'googlebot'                     , 'Google Bot' => 'google'                     , 'MSN' => 'msnbot'                     , 'Alex' => 'ia_archiver'                     , 'Lycos' => 'lycos'                     , 'Ask Jeeves' => &

How to save post visit or count post visit in wordpress

For get post visit or count post visit just copy and paste below code into your theme's functions.php file add_action( 'wp_head', 'update_post_view' ); function update_post_view() {     global $user_ID, $post;     if( is_int( $post ) ) {         $post = get_post( $post );     }     if( !wp_is_post_revision( $post ) ) {         if( is_single() || is_page() ) {             $id = intval( $post->ID );                         if ( !$post_views = get_post_meta( $post->ID, '_visitor_count', true ) ) {                 $post_views = 0;             }             $should_count = true;               $bots = array                 (                       'Google Bot' => 'googlebot'                     , 'Google Bot' => 'google'                     , 'MSN' => 'msnbot'                     , 'Alex' => 'ia_archiver'                     , 'Lycos' => 'lycos'                  

How to extends wp-ecommerce theme's template files with roots theme in wordpress

For extends wp-ecommerce template's file we need to remove wp-ecommerce template redirect hook. So copy and paste below code into your functions.php add_action('init', 'hijeck_wpec_templae_hierarchy'); function hijeck_wpec_templae_hierarchy() { remove_action('template_redirect', 'wpsc_all_products_on_page'); }

Google map with php ajax request in bootstrap modal

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <script src="//code.jquery.com/jquery-1.12.0.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script> <div class="container business-setup">     <div class="row">         <div class="col-sm-12">             <h1 class="font-200">Business Setup</h1> <hr>         </div>     </div>        <form action="" class='form-horizontal'>     <div class="row business-profile">         <div class="col-md-9">             <div class="panel panel-default bmd-floating">                 <div class="panel-body">                     <div class="bmd-card-caption">                         <h2 class="font-200 no-