Tuesday, May 27, 2014

Jquery Show Hide Event

<script>
$(document).ready(function(){



   $(".link").click(function(){
       var id = $(this).attr('id');
       id = id.substring(5);
       $('.map').hide();
       $('#firstbox'+id).show();
   });
  

    

});
</script>

<div id="first1" class="link" >First1</div>
<div id="first2" class="link" >First2</div>


<div id="firstbox1" class="map" style="display:none">  first box here  </div>
<br/>
<div id="firstbox2" class="map" style="display:none">  Second  box here  </div>

Thursday, February 7, 2013

How to make the text box side bar rounded




If you required that to make the text box side bar rounded  then you can easily  make it by using the css property.
First of all you have to make a simple text box  .
<input type="text" name="site" value="Site Name" style="font-size:24px;"/>
Now you have to make the css property for the text box to make the corner rounded
Thease are as below
.login_fields input[type=text] {width:197px; height:20px;text-shadow: 0px 0px 1px #e4e4e4; border:0px; border-radius: 4px;-moz-border-radius: 6px;-webkit-border-radius: 6px;}

By using this class  when you include the class  in your text field it show the  rounded images .
<div class="login_fields"><input type="text" name="site" value="Site Name" style="font-size:24px;"/>
</div>
 Try it


How to add the  loader  on submit button when submit:

If you want  that when you click on login button then it show the other image of other color and then
 Loader on its side
By using java script property  onclick or by css property you can easily do this. You first have to download the images and name the same name  for images  as given or  can chage accordingly .
<script>
function  visibility()
{
        if(document.images)
    {
         
       
        document.images.loading3.style.visibility = 'visible';
        document.images.loading4.style.visibility='visible';}
       
       }
     </script>

<td><input type="image" src="images/btn_login.png" name="submit"  onclick = "javascript:return validateForm();"/>
            <img src="images/btn_logingrey.png"  border="0" name = "loading1" style = "visibility:hidden;margin-left: 10px;margin-top: -5px;"/></td>
            <td><img src="images/loading3.gif"  border="0" name = "loading2" style = "visibility:hidden;"/></td>

You can also  use this property also  for this 
<input type="image" src="images/btn_go.png" name="submit"style = "visibility:visible; float: left;" onclick="this.style.visibility = 'hidden'; if(document.images){document.images.loading.style.visibility = 'visible';}"/>
<img src="images/loading4.gif" alt="" class="left_flo" name = "loading" style = "visibility:hidden; margin-left:-64px;"/>


How To make a Widget in word press


-->


Hello friend  you can  easily make a simple widget   by the given format
 You  have only to give  you condition  query for the particular data to display from  your data base  or  you can easily set it in your wp side bar by dra and drop .

Code given below is

<?php
/*
Plugin Name: Per Page Post

Description: per page Post widget
Author: Vikas Gautam
Version: 2
Author URI: http://vikasbruce.blogspot.com/
*/

function sampleeventcategory()
{
   $page_name="index.php"; //  If you use this code with a different page ( or file ) name then change this
                                                                $start=$_GET['start'];
                                                                if(strlen($start) > 0 and !is_numeric($start)){
                                                                echo "Data Error";
                                                                exit;
                                                                }
                                                                $eu = ($start - 0);
                                                                $limit = 2;                                 // No of records to be shown per page.
                                                                $this1 = $eu + $limit;
                                                                $back = $eu - $limit;
                                                                $next = $eu + $limit;
                               
         $pname = $_REQUEST['event'];
   

/// here  you have to give your query and   show your date   or call data from data base



And after that you have to put the  code  

function widget_myeventcategory($args) {
  extract($args);

  $options = get_option("widget_myeventcategory");
  if (!is_array( $options ))
{
$options = array(
      'title' => 'My Widget Title'
      );
  }

  echo $before_widget;
    echo $before_title;
      echo $options['title'];
    echo $after_title;

    //Our Widget Content
    sampleeventcategory();
  echo $after_widget;
}

function myeventcategory_control()
{
  $options = get_option("widget_myeventcategory");
  if (!is_array( $options ))
{
$options = array(
      'title' => 'My Widget Title'
      );
  }

  if ($_POST['myeventcategory-Submit'])
  {
    $options['title'] = htmlspecialchars($_POST['myeventcategory-WidgetTitle']);
    update_option("widget_myeventcategory", $options);
  }

?>

  <p>
    <label for="myeventcategory-WidgetTitle">Widget Title: </label>
    <input type="text" id="myeventcategory-WidgetTitle" name="myeventcategory-WidgetTitle" value="<?php echo $options['title'];?>" />
    <input type="hidden" id="myeventcategory-Submit" name="myeventcategory-Submit" value="1" />
  </p>
<?php
}

function myeventcategory_init()
{
  register_sidebar_widget(__(' per page Post '), 'widget_myeventcategory');
  register_widget_control(   ' per page Post ', 'myeventcategory_control', 300, 200 );
}
add_action("plugins_loaded", "myeventcategory_init");
?>

How to use fck editor in php

First download the fck editor and ck finder and place them in your directory and  replace the path with your own path

basePath = 'http://localhost/test_new2/wp-content/themes/twentyeleven/ckeditor/';
CKFinder::SetupCKEditor($ckeditor, '/ckfinder/');
$ckeditor->editor('CKEditor1');
$FCKeditor->Width = '220px';
$FCKeditor->Height = '100px';
$ckeditor->ckeditor->config['toolbar'] = 'Full';
$ckeditor->ckeditor->config['language'] = 'en';
*/
?>

Cannot modify header information - pluggable.php


Warning: Cannot modify header information - headers already sent by (output started at /homepages/9/d260170483/htdocs/pettraining/wordpress-2.8/wordpress/wp-content/themes/dog-lover/functions.php:6) in /homepages/9/d260170483/htdocs/pettraining/wordpress-2.8/wordpress/wp-includes/pluggable.php on line 865

If you find this problem in your site  look the page you lastly updated or  the page  on which you are using header location  function   .
After  finding the  page or template  you need to put the   code on top of page
<?php   Ob_start();  ?>

After placing the code at top  save the file  and your problem will be resolved . if have any other issue let me know  or check file  again .

To create custom post from the front end with Feature image



  I f you want to create the custom post from the front with   feature  image end need simple wordpress function  wp_insert_posts();

$new_post = array('post_title'=>$title ,'post_content'  =>   $description,'post_category' =>   array($_POST['cat']),'post_status'=>'publish','post_type'=>  'post');
echo  $pid = wp_insert_post($new_post);
here  in the  variable  $title you have to pass the  title of you post and in
$description  the content you  want to upload   for the post
Array($_POST[‘cat’]) you can pass the category name of post in which you want to post

First you need to create simple html form  like this

<table class="accountForm">
<form method="post" name="insert_post_form" action="" enctype="multipart/form-data" onsubmit="return validateForm()">
<tr>
<td> Post Title: </td> <td> <input type="text" class="inputContact_acc" name="title" ></td>
</tr>
<tr>
<td> Post content: </td> <td><input type="text" class="inputContact_acc" name="content"></td>
</tr>
<tr>
<td> Post category:</td> <td><div class="input_bg1" style="margin-top:5px;"><?php wp_dropdown_categories( 'tab_index=10&taxonomy=category&hide_empty=0&include=4' ); ?></div></td>
</tr>

<tr>
<td> Feature Image : </td> <td> <input name="Feture_image" class="inputContact_acc"  type="file"></td>
</tr>
<tr>
<td></td>
<td>        <input type="submit" name="posted" value="Insert Post" style="background:black;color:#AAAAAA;border:0;width:110px;height:30px;font-weight:bold;border-radius:10px;"></td>
</tr>
</form>

</table>



Now for the  php code you need  to get these values


<?php
if(isset($_POST['posted'])) {



$allowedExts = array("JPG","jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["Feture_image"]["name"]));
if ((($_FILES["Feture_image"]["type"] == "image/gif")
||   ($_FILES["Feture_image"]["type"] == "image/jpeg")
||   ($_FILES["Feture_image"]["type"] == "image/png")
||   ($_FILES["Feture_image"]["type"] == "image/jpg"))
&& in_array($extension, $allowedExts) ) {





$get_parent=$_REQUEST['post_name'];
$title=$_REQUEST['title'];
$description=$_REQUEST['content'];


$new_post = array('post_title'=>$title ,'post_content'  =>   $description,'post_category' =>   array($_POST['cat']),'post_status'=>'publish','post_type'=>  'post');
echo  $pid = wp_insert_post($new_post);


add_theme_support( 'post-thumbnails', array( 'post' ) );


$upload_dir = wp_upload_dir();
$dir = trailingslashit($upload_dir['basedir']) . 'lostpets';
$tmppath = $_FILES['Feture_image']['tmp_name'];

if(!file_exists($dir) && @!mkdir($dir, 0777))
$error = sprintf(__("The userphoto upload content directory does not exist and could not be created. Please ensure that you have write permissions for the '%s' directory. Did you put slash at the beginning of the upload path in Misc. settings? It should be a path relative to the WordPress root directory. <code>wp_upload_dir()</code> returned:<br /> <code style='white-space:pre'>%s</code>", 'user-photo'), $dir, print_r($upload_dir, true));
if(!$error){
$imagefile = "$pid." .$_FILES['Feture_image']['name'];
$imagepath = $dir . '/' . $imagefile;
if(!move_uploaded_file($tmppath, $imagepath)){
$error = sprintf(__("Unable to place the user photo at: %s", 'Feture_image'), $imagepath);
}else{
$wp_filetype = wp_check_filetype(basename($imagepath));

$attachment = array(
'guid' => $imagepath,
'post_type'=>       'attachment',
'post_mime_type' => $wp_filetype['type'],
'post_title' => preg_replace('/\.[^.]+$/', '', basename($imagepath)),
'post_content' => '',
'post_status' => 'inherit'
);
$attach_id = wp_insert_attachment( $attachment, $imagepath, $pid );

require_once(ABSPATH . 'wp-admin/includes/image.php');
$attach_data = wp_generate_attachment_metadata( $attach_id, $imagepath );
wp_update_attachment_metadata( $attach_id, $attach_data );
set_post_thumbnail( $pid, $attach_id );
}
}
echo $error;

if($pid)
{
echo "<script>alert('you successfully posted your deal')</script>";
header('location:http://192.168.0.1/wordpress/carsen');
}

?>

<?php
}
else
{
echo "Try valid image type";
}
}


?>

Thursday, October 18, 2012

To create profile page in wordpress site

<code><?php
/*Template Name:User profile
*/
get_header(); ?>
<?php get_sidebar(); ?>
        <div class="c_right">
<?php

 global $current_user , $woocommerce;
      get_currentuserinfo();
     // echo "<pre>";
       //print_r($current_user);
      //echo "</pre>";
     
     
        $userid=$current_user->data->ID;
         $arydata=array('first_name','last_name','billing_company','billing_address_1','billing_address_2'
         ,'billing_city','billing_postcode','billing_state','billing_phone','shipping_first_name','shipping_last_name','shipping_company','shipping_address_1','shipping_address_2','shipping_city'
         ,'shipping_postcode','shipping_state');
       
         $field=array('First Name','Last Name','Company','Address 1','Address 2','City', 'Postcode','State','Phone','First Name','Last Name','Company','Address 1','Address 2','City','Postcode','State');
          $cunt=count($arydata);
          $cunt=count($field);
          $cunt=0;
         
         
       
         
      if(isset($_POST['update']))
         {
           $useremail=$_REQUEST['useremail'];
               $password1=$_REQUEST['Password'];
          $password=md5($password1);
               $taxid=$_REQUEST['taxid'];
               $user_id=$_REQUEST['ide'];
              
              
       
               $username=$_REQUEST['username'];
              
               $first_name=$_REQUEST['first_name'];
               $last_name=$_REQUEST['last_name'];
               $nickname=$_REQUEST['nickname'];
               $billing_company=$_REQUEST['billing_company'];
               $billing_address_1=$_REQUEST['billing_address_1'];
               $billing_address_2=$_REQUEST['billing_address_2'];
               $billing_city=$_REQUEST['billing_city'];
               $billing_postcode=$_REQUEST['billing_postcode'];
               $billing_country=$_REQUEST['billing_country'];
               $billing_state=$_REQUEST['billing_state'];
               $billing_email=$useremail;
               $billing_phone=$_REQUEST['billing_phone'];
               $billing_taxid=$taxid;
              
              
               $shipping_first_name=$_REQUEST['shipping_first_name'];
                $shipping_last_name=$_REQUEST['shipping_last_name'];
                $shipping_company=$_REQUEST['shipping_company'];
                $shipping_address_1=$_REQUEST['shipping_address_1'];
                $shipping_address_2=$_REQUEST['shipping_address_2'];
                $shipping_city=$_REQUEST['shipping_city'];
                $shipping_postcode=$_REQUEST['shipping_postcode'];
                $shipping_taxid=$taxid;
                $shipping_country=$_REQUEST['shipping_country'];
                $shipping_state=$_REQUEST['shipping_state'];
              
             
              
              
              
              
              
              
             
               if($password1=="")
                {
                  $update1="update wp_users set user_email='$useremail' where ID='$user_id'";
                 $update=mysql_query($update1);
               
                update_user_meta($user_id,'billing_first_name',$first_name);
                update_user_meta($user_id,'billing_last_name',$last_name);
                update_user_meta($user_id,'nickname',$nickname);
                update_user_meta($user_id,'billing_company',$billing_company);
                update_user_meta($user_id,'billing_address_1',$billing_address_1);
                update_user_meta($user_id,'billing_address_2',$billing_address_2);
                update_user_meta($user_id,'billing_city',$billing_city);
                update_user_meta($user_id,'billing_postcode',$billing_postcode);
                update_user_meta($user_id,'billing_country',$billing_country);
                update_user_meta($user_id,'billing_state',$billing_state);
                update_user_meta($user_id,'billing_email',$billing_email);
                update_user_meta($user_id,'billing_phone',$billing_phone);
                update_user_meta($user_id,'billing_taxid',$billing_taxid);
               
               
               
               
                update_user_meta($user_id,'shipping_first_name',$shipping_first_name);
                update_user_meta($user_id,'shipping_last_name',$shipping_last_name);
                update_user_meta($user_id,'shipping_company',$shipping_company);
                update_user_meta($user_id,'shipping_address_1',$shipping_address_1);
                update_user_meta($user_id,'shipping_address_2',$shipping_address_2);
                update_user_meta($user_id,'shipping_city',$shipping_city);
                update_user_meta($user_id,'shipping_postcode',$shipping_postcode);
                update_user_meta($user_id,'shipping_taxid',$shipping_taxid);
                update_user_meta($user_id,'shipping_country',$shipping_country);
                update_user_meta($user_id,'shipping_state',$shipping_state);
               
                update_user_meta($user_id,'taxid',$taxid);
                }
                else
                {
                
                 $update1="update wp_users set user_email='$useremail' , user_pass='$password' where ID='$user_id'";
                $update=mysql_query($update1);
                   
                    update_user_meta($user_id,'billing_first_name',$first_name);
                    update_user_meta($user_id,'billing_last_name',$last_name);
                    update_user_meta($user_id,'nickname',$nickname);
                    update_user_meta($user_id,'billing_company',$billing_company);
                    update_user_meta($user_id,'billing_address_1',$billing_address_1);
                    update_user_meta($user_id,'billing_address_2',$billing_address_2);
                    update_user_meta($user_id,'billing_city',$billing_city);
                    update_user_meta($user_id,'billing_postcode',$billing_postcode);
                    update_user_meta($user_id,'billing_country',$billing_country);
                    update_user_meta($user_id,'billing_state',$billing_state);
                    update_user_meta($user_id,'billing_email',$billing_email);
                    update_user_meta($user_id,'billing_phone',$billing_phone);
                   
                    update_user_meta($user_id,'taxid',$taxid);
                   
                   
                   
                    update_user_meta($user_id,'shipping_first_name',$shipping_first_name);
                update_user_meta($user_id,'shipping_last_name',$shipping_last_name);
                update_user_meta($user_id,'shipping_company',$shipping_company);
                update_user_meta($user_id,'shipping_address_1',$shipping_address_1);
                update_user_meta($user_id,'shipping_address_2',$shipping_address_2);
                update_user_meta($user_id,'shipping_city',$shipping_city);
                update_user_meta($user_id,'shipping_postcode',$shipping_postcode);
                update_user_meta($user_id,'shipping_taxid',$shipping_taxid);
                update_user_meta($user_id,'shipping_country',$shipping_country);
                update_user_meta($user_id,'shipping_state',$shipping_state);
   
               
                  
         }if($update)
             {
              echo "<p style='margin-left:200px;color:green;'>Info Updated</p>";
             }   
         }
       
         //echo $dtl2="select * from wp_usermeta where user_id=$userid";
       
        // print_r($arydata);
          /*while($cunt<14)
              {
                $key=$arydata[$cunt];
           
         $dtl=mysql_query("select * from wp_usermeta where user_id=$userid and  meta_key='$key'");
         $dtl1=mysql_fetch_assoc($dtl);
         echo $dtl1['meta_value']."<br/>";
         $cunt++;
              }*/
               
       
        //echo "<pre>";
        //print_r($dtl1);
        //echo "</pre>";
       
       global $current_user;
      get_currentuserinfo();
      ?>
    <script>
        function validateForm()
            {
           
            var x=document.forms["frm1"]["useremail"].value;
            var atpos=x.indexOf("@");
            var dotpos=x.lastIndexOf(".");
            if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
              {
              alert("Not a valid e-mail address");
              return false;
              }
           
           
           
           
            var x=document.forms["frm1"]["taxid"].value;
            if (x==null || x=="")
              {
              alert("TaxId must be filled out");
              return false;
              }
            }
    </script>
    <!--background:#E9E9E9; -->
<!--div style="float: right;
width: 730px;padding: 4px 0 5px 10px;font-family: Verdana;color: black;font-size: 12px;margin-top: 15px;height:auto;"-->   
<div class="register1">
<form name="frm1" method="post" action="" onsubmit="return validateForm()">
        <input type="hidden" id="hdnSubmit_frm" name="hdnSubmit_frm" value="insert" />
       
            <table style="width:100% !important">
            <tr style="background:#E9E9E9;">
            <td colspan="2"><h2 style="padding-left: 10px;">User Profile<h2></td></tr>
            <tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Name</td>
              <td>
                <input name="username" id="username" type="text" value="<?php echo $current_user->user_login ;?>" class="billing_fild"     readonly="readonly"><i style="color:red">unable to change username</i></td>
              </tr>
             
            <tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Email Address</td>
              <td><input name="useremail" id="useremail" type="text" value="<?php echo $current_user->user_email; ?>" class="billing_fild"></td>
              </tr>
             
           
              <tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Tax Id</td>
              <td>
                  <input name="taxid" id="taxid" type="text" value="<?php echo $current_user->taxid; ?>" class="billing_fild"></td>
              </tr>
              <tr>
              <td style="background:#F5F5F5;padding-left: 10px;">New Password</td>
              <td>
                  <input name="newpassword" id="pass" type="password" value="" class="billing_fild"></td>
              </tr>
             
              <tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Confirm Password</td>
              <td>
                  <input name="Password" id="pass1" type="password" value="" class="billing_fild"></td>
              </tr>
             
            <tr style="background:#E9E9E9;">
            <td colspan="2"><h2 style="padding-left: 10px;">Billing Address</h2></td>
            </tr>
            <?php 
             //echo "<pre>";
            //print_r($field);
            //echo "</pre>";
                     while($cunt<17)
                    {
                       $key=$arydata[$cunt];
                      
                       $dtl=mysql_query("select * from wp_usermeta where user_id=$userid and  meta_key='$key'");
                       $dtl1=mysql_fetch_assoc($dtl);
                       if($cunt==7)
                       { ?>
                         <tr>
                         <td style="background:#F5F5F5;padding-left: 10px;">Country</td>
                         <td><select name="billing_country" id="calc_shipping_country" class="billing_fild" rel="calc_shipping_state">
                <option value=""><?php _e('Select a country&hellip;', 'woocommerce'); ?></option>
                <?php
                    foreach($woocommerce->countries->get_allowed_countries() as $key=>$value) :
                        echo '<option value="'.$key.'"';
                        if ($woocommerce->customer->get_shipping_country()==$key) echo 'selected="selected"';
                        echo '>'.$value.'</option>';
                    endforeach;
                ?>
            </select> <i style="color:red">Insert the state below in short code like AL for Albama</i></td>
                         <td colspan="2"></td>
                         </tr>
                       <?php }
                      
                      
                     
                      if($cunt==9)
                       { ?>
                         <tr style="background:#E9E9E9;">
                         <td colspan="2"><h2 style="padding-left: 10px;">Shipping Address</h2></td>
                         </tr>
                      <?php  }
                     
                       if($cunt==16)
                       { ?>
                         <tr>
                         <td style="background:#F5F5F5;padding-left: 10px;">Country</td>
                         <td><select name="shipping_country" id="calc_shipping_country" class="billing_fild" rel="calc_shipping_state">
                <option value=""><?php _e('Select a country&hellip;', 'woocommerce'); ?></option>
                <?php
                    foreach($woocommerce->countries->get_allowed_countries() as $key=>$value) :
                        echo '<option value="'.$key.'"';
                        if ($woocommerce->customer->get_shipping_country()==$key) echo 'selected="selected"';
                        echo '>'.$value.'</option>';
                    endforeach;
                ?>
            </select> <i style="color:red">Insert the state below in short code like AL for Albama</i> </td>
                         <td colspan="2"></td>
                         </tr>
                       <?php }
                      ?>
                         <tr>
                              <td style="background:#F5F5F5;padding-left: 10px;"><?php echo $field[$cunt];?></td>
                              <td><input type="text" name="<?php echo $dtl1['meta_key'];?>" value="<?php echo $dtl1['meta_value'];?>" class="billing_fild"></td>
                        </tr>
                        <?php 
                       $cunt++;
                    }?>
                <?php /* while($dtl1=mysql_fetch_assoc($dtl))
                         { ?>
                         <tr>
                              <td><input type="text" name="" value="<?php echo $dtl1['meta_value'];?>"></td>
                        </tr>
                        <?php 
                         }*/   
                ?>           
           
              
             
             
               <tr style="display:none;">
                 <td>&nbsp;</td>
                 <td><input type="text" name="ide" value="<?php echo $current_user->ID; ?>"></td>
               </tr>
              
            <tr>
              <td>&nbsp; </td>
              <td><input type="submit" name="update" value="" class="update_user"></td>
              </tr>
            </table>
             </form>
 
</div>

<?php get_footer(); ?></code>