Sunday 13 March 2016

How to chnage character lenght and continue reading text in excerpt in wordpress

How to chnage character lenght and continue reading text in excerpt in wordpress


if you have child theme first remove this filter  i have twenty thierteen theme

function child_theme_setup() {
// override parent theme's 'more' text for excerpts
remove_filter( 'excerpt_more', 'twentythirteen_excerpt_more' );

}
add_action( 'after_setup_theme', 'child_theme_setup' );

after change character lenght in wordpress

function et_excerpt_length($length) {
    return 70;
}
add_filter('excerpt_length', 'et_excerpt_length');

you can change the text of continue reading

function et_excerpt_more($more) {
    global $post;
    return '<a href="'. get_permalink($post->ID) . '" class="view-full-post-btn"> read more....</a>';
}
add_filter('excerpt_more', 'et_excerpt_more');

How to Add Js and css In footer in Wordpress

How to Add Js and css In footer in Wordpress


/** Footer add js and css in wordpress
function prefix_add_footer_styles() {

wp_enqueue_script( 'js-name', get_stylesheet_directory_uri() . 'your js path',array('jquery'),'',true);
wp_enqueue_style( 'css-name', get_stylesheet_directory_uri(). 'yor css path' );
  
};
add_action( 'get_footer', 'prefix_add_footer_styles' );

**/

Thursday 10 March 2016

add smooth scrolling using jquery in menu

Hello Here example Add Smooth scroll menu in menu

simple add this js in your page. check it it. it working file

but you need to add jquery.easing.min.js in your header after jquery

jQuery(function() {
    jQuery('a[href*="#"]:not([href="#"])').click(function() {
      if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
        var target = jQuery(this.hash);
        target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
        if (target.length) {
          jQuery('html, body').animate({
            scrollTop: target.offset().top
          }, 1000);
          return false;
        }
      }
    });
  });

Tuesday 16 February 2016

image upload with compress image and add text into image in using php

Hello Here Example Image compress and add text into image

<?php
function compress_image($source_url, $destination_url, $quality) {
  $info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg') $image = imagecreatefromjpeg($source_url);
elseif ($info['mime'] == 'image/gif') $image = imagecreatefromgif($source_url);
elseif ($info['mime'] == 'image/png') $image = imagecreatefrompng($source_url);
 // Set Path to Font File
$color = imagecolorallocate($image, 255, 255, 255);

//x-coordinate of the upper left corner.
$xPos = 600;
//y-coordinate of the upper left corner.
$yPos = 200;

//Writting the picture
imagestring($image,5,$xPos,$yPos,"Add Your Text Here",$color);
imagejpeg($image, $destination_url, $quality);



return  $destination_url;
}
if(isset($_POST['submit'])){
$tempPath = $_FILES['upload']['tmp_name'];
$mypath = "compress";
if(!is_dir($mypath)){
mkdir($mypath);
}
 $filename = $_FILES['upload']['name'];
 $destination = $mypath."/".$filename;

$destination  =   compress_image($tempPath,$destination,90);
}
?>

<form method="post" enctype="multipart/form-data">

<input type="file" name="upload"/>
<input type="submit" name="submit" value="upload"/>

</form>

Friday 5 February 2016

How to pass variables via PHP CURL

How to pass variables via PHP CURL

$message="Thank you";
$phone = 123456789;
$url = 'http://example.com';


$fields = array('phone'=>$phone,'source'=>'test','message'=>$message);
$fields_string='';


foreach($fields as $key=>$value) {  $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');


$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);

Saturday 30 January 2016

Insert Csv File Data in Mysql using Php with Validation

Insert Csv File Data in Mysql using Php with Validation  Full Example

Sample Csv File Test.csv

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/jquery.validate.min.js"></script>
<script src="http://jqueryvalidation.org/files/dist/additional-methods.min.js"></script>

<script type="application/javascript">
$(document).ready(function(e) {
    $('#pincodeList').validate({
        rules: {
            Csv: {
                required: true,
extension: "xls|csv"
              
            }

        },

    messages: {
        Csv: {
            extension: 'Please upload a csv file!'
        }
}

    });
});
</script>

<?php
include('connect.php');


if($_POST['submit']){
$csv_file = $_FILES['Csv']['name'];
$tmpFilePath =$_FILES['Csv']['tmp_name'];
$newFilePath="pincodeUpload/";
$mypath = "pincodeUpload/".$csv_file;
move_uploaded_file($tmpFilePath, $mypath);
if ( ! is_dir($newFilePath)) {

mkdir($newFilePath);

$csv_file =$mypath;

if (($handle = fopen($csv_file, "r")) !== FALSE) {

   fgetcsv($handle);  
   while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
         $num = count($data);
        for ($c=0; $c < $num; $c++) {
           $col[$c] = $data[$c];
        }

    $col1 = $col[0];

  
// SQL Query to insert data into DataBase
$query = "INSERT INTO pincode(Pincode) VALUES('$col1')";
$s     = mysql_query($query);
 }
    fclose($handle);
}

}

?>

<form id="pincodeList" name="pincodeList" method="post" enctype="multipart/form-data">
               <div class="row">
               <div class="co-md-3 col-sm-6">
<input  type="file" name="Csv" >
                </div>
                <div class="co-md-3 col-sm-6">
<input class="btn btn-success" type="submit" name="submit" value="Upload Csv"/>
                </div>
                </div>
</form>

File or Image Upload Validation using Jquery Validation

File or Image Upload Validation using Jquery Validation Example

$("#form1").validate({

        rules: {
        
categoryBanner:{

filesize:1048576
},
        },
messages: { categoryBanner: "File must be JPG, GIF or PNG, less than 1MB" },


        highlight: function(element) {
            $(element).css({
                "background-color": "rgba(60, 141, 188, 0.52)",
                "border-color": "red"
            });
        },
        unhighlight: function(element) {
            $(element).css({
                "background-color": "",
                "border-color": ""
            });
        }

    });

$.validator.addMethod('filesize', function(value, element, param) {
    // param = size (in bytes)
    // element = element to validate (<input>)
    // value = value of the element (file name)
    return this.optional(element) || (element.files[0].size <= param)
});

<input type="file" name="categoryBanner" />
<input type="submit" name="submit"/>

Wednesday 20 January 2016

Upload Multiple-image Using Webservice in PHP



Hello
Upload Multiple-image Using Webservice in PHP

<?php



 
  if(isset($_POST['submit'])){
 
 
for($i=0; $i<count($_FILES['upload']['name']); $i++) {

/** valiation  only 1 Mb File Upload **/
if($_FILES['upload']['size'][$i] > 1048576){
$notice_image = '<div class="alert alert-info fade in">
    <a title="close" aria-label="close" data-dismiss="alert" class="close" href="#">×</a>
    <strong>Info!</strong> Image Size Must Be Less Than 1 Mb. Your Image is "'.$_FILES['upload']['name'][$i].'"
</div>';

}else{

$tmpFilePath =$_FILES['upload']['tmp_name'][$i];


//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "ProductImg/";

if ( ! is_dir($newFilePath)) {

mkdir($newFilePath);


$picture =uniqid()."_".$_FILES['upload']['name'][$i];
$mypath = "ProductImg/".$picture;
//Upload the file into the temp dir
// if(move_uploaded_file($tmpFilePath, $mypath)) {
if(!file_exists($mypath)){
//move_uploaded_file($tmpFilePath, $mypath);
/** remove Comment when not use webservice*/

 
 
if(!empty($picture))
  {

 
$data = base64_decode($_FILES['upload']['name'][$i]);
$file = fopen($mypath, "w");
fwrite($file,$data);
fclose($file);
  }


}

}


}
}

}
?>

<form method="post" enctype="multipart/form-data">
<?php echo $notice_image; ?>
<input type="file" name="upload[]" multiple="multiple" >
<input type="submit" name="submit" value="save">

</form>

Monday 18 January 2016

Get longitude and latitude using address with php

Get longitude and latitude using address with php 

here The Example For that.

function Get_LatLng_From_Google_Maps($address) {
    $address = urlencode($address);

    $url = "http://maps.googleapis.com/maps/api/geocode/json?address=$address&sensor=false";

    // Make the HTTP request
    $data = @file_get_contents($url);
    // Parse the json response
    $jsondata = json_decode($data,true);

    // If the json data is invalid, return empty array
    if (!check_status($jsondata))   return array();

    $LatLng = array(
        'lat' => $jsondata["results"][0]["geometry"]["location"]["lat"],
        'lng' => $jsondata["results"][0]["geometry"]["location"]["lng"],
    );

    return $LatLng;
}

/*
* Check if the json data from Google Geo is valid
*/

function check_status($jsondata) {
    if ($jsondata["status"] == "OK") return true;
    return false;
}

/*
*  Print an array
*/

function d($a) {
    echo "<pre>";
    print_r($a);
    echo "</pre>";
}
$address="bhavnagar,gujrat,india";
$arry_lat_lag = Get_LatLng_From_Google_Maps($address);

Monday 4 January 2016

Customize single product page in woocommerce


All function call in wc-template-function.php file check it
location is woocommerce/include/
if you change position of product title,single rating,single price,description,add to cart then

follow below code.

go to content-single.php file

<div class="summary entry-summary">

<?php
/**
* woocommerce_single_product_summary hook
*
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
*/
//do_action( 'woocommerce_single_product_summary' );

woocommerce_template_single_title(); 
             woocommerce_template_single_rating();
             woocommerce_template_single_price(); // this will output the price text
             woocommerce_template_single_excerpt(); // this will output the short description of your product.
             woocommerce_template_single_add_to_cart();
             woocommerce_template_single_meta();
             woocommerce_template_single_sharing();
?>

</div><!-- .summary -->

here all get single single you can set in your html

if you want to change breadcub then go to single-product file

follow below

comment

//do_action( 'woocommerce_before_main_content' );

this and

this two funcion

woocommerce_output_content_wrapper();
and
woocommerce_breadcrumb();

set it your ways