Wednesday, August 28, 2013

how to create dynamic cache file using php[Solved]

Hey guys you can do your own cache file using php simple function you can learn :)
getUrl() function  identify the specific  url to make the cache file
function getUrl() {
    if (!isset($_SERVER['REQUEST_URI'])) {
    $url = $_SERVER['REQUEST_URI'];
    } else {
    $url = $_SERVER['SCRIPT_NAME'];
    $url .= (!empty($_SERVER['QUERY_STRING']))? '?' . $_SERVER[ 'QUERY_STRING' ] : '';

    }
    return $url;
}                     
Cache($content) function write your page content to destination cache folder 
function cache($buffer) { //page's content is $buffer
    $url = getUrl();

    $filename = md5($url) . '.cache';
    $data = time() . '¦' . $buffer;
    $filew = fopen("cache/" . $filename, 'w');
    fwrite($filew, $data);
    fclose($filew);
    return $buffer;
}
display() function is get the contents from cache location and execute the cache() your cache time
function display() {

    $url = getUrl();
    $filename = md5($url) . '.cache';

    if (!file_exists("cache/" . $filename)) {
    return false;
    }
    $filer = fopen("cache/" . $filename, 'r');
    $data = fread($filer, filesize("cache/" . $filename));
    fclose($filer);
    $content = explode('¦', $data, 2);
    if (count($content)!= 2 OR !is_numeric($content['0'])) {
        return false;
    }
 echo time()-(100).'===='.$content['0'];
    if (time()-(100) > $content['0']) { // 100 is the cache time here!!!
        cache('<strong>bikash ranjan nayak entry into cache html contents file</strong>');
        return false;
    }
        echo $content['1'];
        die();
}

// Display cache (if any)
display();  // if it is displayed, die function will end the program here.

// if no cache, callback cache
ob_start ('cache');
Hope it`s may help you :)



how to speed up WordPress load times

how to speed up WordPress load times


The reason why you choose WordPress to build your website is because it is easy to use and you do not need any HTML background knowledge to create your website. So, when your website is done and completed, you work very hard to create more posts and content everyday. Your website traffic picks up and it starts to grow. To enhance your readers browsing experiences, you start using more WordPress plugins so that your website can have a few extra features (i.e. Social Media Share button, different language translators, etc). However, you start to realize that the more plugins and posts you make, the longer load time your website experiences. What should you do now?
Nobody likes slow websites. Nobody likes to wait around for websites to load every minute. Your (potential) readers will leave your website when it does not load for 10 seconds which means it is very important to optimize the load time of your WordPress website. Therefore, we have prepared a list with 10 easy tips to speed up your website.
1. Caching Plugin
Caching plugin helps your website improve its load speed because the plugin caches every aspect of your website. As a result, this will significantly reduce the download time. Among the different caching plugins available online, we recommend W3 Total Cache because it is very simple to use (and it’s FREE)!
2. Optimizing Image
Image file sizes are much larger than text files. If your website is image-oriented, it will take a much longer time to load your website. There is a free plugin called WP-Smushlt which can automatically help you reduce the file sizes of your website but does not reduce the quality of the image. Definitely check this out!
3. Another Image-related plugin: LazyLoad
This plugin will not only speed up your website load time but will also help your website lower the bandwidth by loading less data for your viewers who do not scroll down your website. For example, if your website is vertically long and requires readers to scroll down in order to view your entire page, with LazyLoad, the images on the lower side on your website will NOT load until your readers scroll down.
4. Optimizing databases
There are three plugins that we would like to recommend for optimizing your WordPress databases. The first one is WP-Optimize. This plugin, as the name suggests, optimizes your database by reducing the overhead of spams, drafts, tables, etc. Second, you can also consider installing WP-DBManger to help you schedule dates for database optimization.
Last, Revision Control is another great tool that can help you optimize your database. This plugin enables you to set the numbers of revisions you make for each post. WordPress, by default, stores all of your drafts indefinitely. By installing this powerful plugin, your database will be very lightweight compared to other websites without this plugin.
5. Removing unused plugins
The title says it all. If there are plugins that you do not use, simply delete them. Give it a try! Your site will load faster for sure!
6. Optimizing your home page
Your home page is the most important part that requires a quick load speed among all of your other pages because this is where your readers normally enter first. Here are a few tips to optimize your home page
  • - Show excerpts of your posts.
  • - Set fewer number of posts displayed on your home page (we recommend 5 posts)
  • - Set the Social Media Share plugins to only display on the actual post page instead of the home page.
Remember the key: less is MORE!!
7. Enabling hotlink protection
Hotlinking happens when external websites direct a link to the images on your websites making your server load increase. In cPanel, there is a function called “HotLink Protection”. Once you enable the protection, you can eliminate this form of “bandwidth theft”.
8. cPanel “Optimize Website” Feature
Another great feature of cPanel! There is a feature under “Software/Services” in cPanel which is called “Optimize Website”. By enabling this feature, cPanel tweaks the way Apache will handle requests and will compress content before sending it to the visitor’s browsers.
9. Making use of Google PageSpeed Insights
PageSpeed Insights, developed by Google, is a tool that analyzes the content of a web page and provides suggestions to make that page load faster. Check out their official page for full details.
10. Good web hosting service company
A good web host can provide not only stable uptime and connection but also professional solutions and support when needed. At Doteasy, our in-house Customer Support agents are resourceful web technicians and experts. We can provide speedy solutions for WordPress and other website builder programs. It’s our goal to keep our customers up-to-date with the latest web hosting trends through our blog, our Scripts Library, and our how-to video tutorials on the YouTube channel.
Lack of time to complete all these tips?
It takes a great amount of time to secure a website and maintain a quick load time. Therefore, we strongly recommend our customers to perform all of the above tips on your own. But, we understand that many of you do not have the time to do these tasks on your website. In this case, we can suggest to you our Managed Hosting plan which is an ideal solution for customers who need some extra help in maintaining their websites. Our Managed Hosting plan includes automated website backup as well as import, export, and optimization of your MySQL databases. To learn more, check out our Managed Hosting service feature page.

how add reomve active class using jquery go to other page

<script type="text/javascript">
$(document).ready(function(){
var str=location.href.toLowerCase();

$(".main_nav li a").each(function() {
alert('lopp');
     if (str.indexOf(this.href.toLowerCase()) > -1) {
         $("li.active").removeClass("active");
        $(this).parent().addClass("active");
     }
 });
 });
</script>

Monday, August 26, 2013

Saturday, August 24, 2013

how to swap two column value in mysql query

see the example how to swap  column rows value

UPDATE emprs SET EName=(@temp:=EName), EName= Salary, Salary = @temp;
or
UPDATE emprs s1, emprs s2 SET s1.EName=s1.Salary, s1.Salary=s2.EName WHERE s1.id=s2.id;

Friday, August 16, 2013

How does we check the product page in wordpress

 if (is_single() && get_post_type()== 'wpsc-product' ) {
echo "its a product pag";
}else{
echo "it is not product page";
}?>

Tuesday, August 13, 2013

How to fix Mootools and jQuery conflict on Joomla

here is the solutation :
$document = &JFactory::getDocument();
$document->addScript(JPATH_SITE.'/media/system/js/thickbox.js' );
$noconflict = 'jQuery.noConflict();';
$document->addScriptDeclaration( $noconflict );

Monday, August 12, 2013

Monday, August 5, 2013

how to getting all the zip codes withing a range miles using php

<?php
// constants for setting the $units data member
define('_UNIT_MILES', 'm');
define('_UNIT_KILOMETERS', 'k');

// constants for passing $sort to get_zips_in_range()
define('_ZIPS_SORT_BY_DISTANCE_ASC', 1);
define('_ZIPS_SORT_BY_DISTANCE_DESC', 2);
define('_ZIPS_SORT_BY_ZIP_ASC', 3);
define('_ZIPS_SORT_BY_ZIP_DESC', 4);

// constant for miles to kilometers conversion
define('_M2KM_FACTOR', 1.609344);

class zipcode_class {

   var $last_error = "";            // last error message set by this class
   var $last_time = 0;              // last function execution time (debug info)
   var $units = _UNIT_MILES;        // miles or kilometers
   var $decimals = 2;               // decimal places for returned distance

   function get_distance($zip1, $zip2) {

      // returns the distance between to zip codes.  If there is an error, the
      // function will return false and set the $last_error variable.
     
      $this->chronometer();         // start the clock
     
      if ($zip1 == $zip2) return 0; // same zip code means 0 miles between. :)
  
  
      // get details from database about each zip and exit if there is an error
     
      $details1 = $this->get_zip_point($zip1);
      $details2 = $this->get_zip_point($zip2);
      if ($details1 == false) {
         $this->last_error = "No details found for zip code: $zip1";
         return false;
      }
      if ($details2 == false) {
         $this->last_error = "No details found for zip code: $zip2";
         return false;
      }    


      // calculate the distance between the two points based on the lattitude
      // and longitude pulled out of the database.
     
      $miles = $this->calculate_mileage($details1[0], $details2[0], $details1[1], $details2[1]);
     
      $this->last_time = $this->chronometer();

      if ($this->units == _UNIT_KILOMETERS) return round($miles * _M2KM_FACTOR, $this->decimals);
      else return round($miles, $this->decimals);       // must be miles
     
   }  

   function get_zip_details($zip) {
     
      // This function pulls the details from the database for a
      // given zip code.

      $sql = "SELECT lat AS lattitude, lon AS longitude, city, county, state_prefix,
              state_name, area_code, time_zone
              FROM zip_code
              WHERE zip_code='$zip'";
             
      $r = mysql_query($sql);
      if (!$r) {
         $this->last_error = mysql_error();
         return false;
      } else {
         $row = mysql_fetch_array($r, MYSQL_ASSOC);
         mysql_free_result($r);
         return $row;      
      }
   }

   function get_zip_point($zip) {
  
      // This function pulls just the lattitude and longitude from the
      // database for a given zip code.
     
      $sql = "SELECT lat, lon from zip_code WHERE zip_code='$zip'";
      $r = mysql_query($sql);
      if (!$r) {
         $this->last_error = mysql_error();
         return false;
      } else {
         $row = mysql_fetch_array($r);
         mysql_free_result($r);
         return $row;      
      }     
   }

   function calculate_mileage($lat1, $lat2, $lon1, $lon2) {

      // used internally, this function actually performs that calculation to
      // determine the mileage between 2 points defined by lattitude and
      // longitude coordinates.  This calculation is based on the code found
      // at http://www.cryptnet.net/fsp/zipdy/
      
      // Convert lattitude/longitude (degrees) to radians for calculations
      $lat1 = deg2rad($lat1);
      $lon1 = deg2rad($lon1);
      $lat2 = deg2rad($lat2);
      $lon2 = deg2rad($lon2);
     
      // Find the deltas
      $delta_lat = $lat2 - $lat1;
      $delta_lon = $lon2 - $lon1;
   
      // Find the Great Circle distance
      $temp = pow(sin($delta_lat/2.0),2) + cos($lat1) * cos($lat2) * pow(sin($delta_lon/2.0),2);
      $distance = 3956 * 2 * atan2(sqrt($temp),sqrt(1-$temp));

      return $distance;
   }
  
   function get_zips_in_range($zip, $range, $sort=1, $include_base) {
      
      // returns an array of the zip codes within $range of $zip. Returns
      // an array with keys as zip codes and values as the distance from
      // the zipcode defined in $zip.
     
      $this->chronometer();                     // start the clock
     
      $details = $this->get_zip_point($zip);  // base zip details
      if ($details == false) return false;
     
      // This portion of the routine  calculates the minimum and maximum lat and
      // long within a given range.  This portion of the code was written
      // by Jeff Bearer (http://www.jeffbearer.com). This significanly decreases
      // the time it takes to execute a query.  My demo took 3.2 seconds in
      // v1.0.0 and now executes in 0.4 seconds!  Greate job Jeff!
     
      // Find Max - Min Lat / Long for Radius and zero point and query
      // only zips in that range.
      $lat_range = $range/69.172;
      $lon_range = abs($range/(cos($details[0]) * 69.172));
      $min_lat = number_format($details[0] - $lat_range, "4", ".", "");
      $max_lat = number_format($details[0] + $lat_range, "4", ".", "");
      $min_lon = number_format($details[1] - $lon_range, "4", ".", "");
      $max_lon = number_format($details[1] + $lon_range, "4", ".", "");

      $return = array();    // declared here for scope

      $sql = "SELECT zip_code, lat, lon FROM zip_code ";
      if (!$include_base) $sql .= "WHERE zip_code <> '$zip' AND ";
      else $sql .= "WHERE ";
      $sql .= "lat BETWEEN '$min_lat' AND '$max_lat'
               AND lon BETWEEN '$min_lon' AND '$max_lon'";
            
      $r = mysql_query($sql);
     
      if (!$r) {    // sql error

         $this->last_error = mysql_error();
         return false;
        
      } else {
         
         while ($row = mysql_fetch_row($r)) {
  
            // loop through all 40 some thousand zip codes and determine whether
            // or not it's within the specified range.
           
            $dist = $this->calculate_mileage($details[0],$row[1],$details[1],$row[2]);
            if ($this->units == _UNIT_KILOMETERS) $dist = $dist * _M2KM_FACTOR;
            if ($dist <= $range) {
               $return[str_pad($row[0], 5, "0", STR_PAD_LEFT)] = round($dist, $this->decimals);
            }
         }
         mysql_free_result($r);
      }
     
      // sort array
      switch($sort)
      {
         case _ZIPS_SORT_BY_DISTANCE_ASC:
            asort($return);
            break;
           
         case _ZIPS_SORT_BY_DISTANCE_DESC:
            arsort($return);
            break;
           
         case _ZIPS_SORT_BY_ZIP_ASC:
            ksort($return);
            break;
           
         case _ZIPS_SORT_BY_ZIP_DESC:
            krsort($return);
            break;
      }
     
      $this->last_time = $this->chronometer();
     
      if (empty($return)) return false;
      return $return;
   }

   function chronometer()  {

   // chronometer function taken from the php manual.  This is used primarily
   // for debugging and anlyzing the functions while developing this class. 
 
   $now = microtime(TRUE);  // float, in _seconds_
   $now = $now + time();
   $malt = 1;
   $round = 7;
 
   if ($this->last_time > 0) {
       /* Stop the chronometer : return the amount of time since it was started,
       in ms with a precision of 3 decimal places, and reset the start time.
       We could factor the multiplication by 1000 (which converts seconds
       into milliseconds) to save memory, but considering that floats can
       reach e+308 but only carry 14 decimals, this is certainly more precise */
     
       $retElapsed = round($now * $malt - $this->last_time * $malt, $round);
     
       $this->last_time = $now;
     
       return $retElapsed;
   } else {
       // Start the chronometer : save the starting time
   
       $this->last_time = $now;
     
       return 0;
   }
}

}?>
-----------------------------------end class here the example---------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <title>Zip Code Range and Distance Calculation Demo</title>
   <style type="text/css" lang="en">
   BODY, P { font-family: sans-serif; font-size: 9pt; }
   H3 { font-family: sans-serif; font-size: 14pt; }
   </style>
</head>
<body>

<?php

/* 
   DEMO for using the zipcode PHP class. By: Micah Carrick
   Questions?  Comments?  Suggestions?  email@micahcarrick.com
*/

require_once('zipcode.class.php');      // zip code class


// Open up a connection to the database.  The sql required to create the MySQL
// tables and populate them with the data is in the /sql subfolder.  You can
// upload those sql files using phpMyAdmin or a MySQL prompt.  You will have to
// modify the below information to your database information. 
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('test') or die(mysql_error());



// Below is an example of how to calculate the distance between two zip codes.

echo '<h3>A sample calculating the distance between 2 zip codes: 93001 and 60618</h3>';

$z = new zipcode_class;
$miles = $z->get_distance(97214, 98501);

if ($miles === false) echo 'Error: '.$z->last_error;
else echo "Zip code <b>97214</b> is <b>$miles</b> miles away from <b>98501</b>.<br />";



// Below is an example of how to return an array with all the zip codes withing
// a range of a given zip code along with how far away they are.  The array's
// keys are assigned to the zip code and their value is the distance from the
// given zip code. 

echo '<h3>A sample getting all the zip codes withing a range: 2 miles from 97214</h3>';

$zips = $z->get_zips_in_range('97214', 2, _ZIPS_SORT_BY_DISTANCE_ASC, true);


if ($zips === false) echo 'Error: '.$z->last_error;
else {
  
   foreach ($zips as $key => $value) {
      echo "Zip code <b>$key</b> is <b>$value</b> miles away from <b>97214</b>.<br />";
   }
  
   // One thing you may want to do with this is create SQL from it. For example,
   // iterate through the array to create SQL that is something like:
   // WHERE zip_code IN ('93001 93002 93004')
   // and then use that condition in your query to find all pizza joints or
   // whatever you're using it for. Make sense? Hope so.
  
   echo "<br /><i>get_zips_in_range() executed in <b>".$z->last_time."</b> seconds.</i><br />";
}

// And one more example of using the class to simply get the information about
// a zip code.  You can then do whatever you want with it.  The array returned
// from the function has the database field names as the keys.  I just do a
// couple string converstions to make them more readable.

echo '<h3>A sample getting details about a zip code: 97214</h3>';

$details = $z->get_zip_details('97214');

if ($details === false) echo 'Error: '.$z->last_error;
else {
   foreach ($details as $key => $value) {
      $key = str_replace('_',' ',$key);
      $key = ucwords($key);
      echo "$key:&nbsp;$value<br />";
   }
}
?>

</body>
</html>

how to check it`s a product of wp ecommerce page in wordpress

how to check it`s a product of wp ecommerce page in wordpress
f ('wpsc-product' == get_post_type()&& is_single()){
echo "it product page of wp ecommerce";
}

Friday, August 2, 2013

how to find my previous content in joomla article

Hi guys download the component and plugin according to your joomla version.

when you have done your change content how to recover article content in future .
best way to recover your content for joomla .



Joomla 1.5

  • com_versions: This is the component that shows the list of content versions available for a particular document.
  • plg_content_versioning: This is the plugin that actually saves the version when you hit “Save” in the back end.
  • plg_editors_xtd_versioning: This is the button that appears at the bottom of the editor which you click to access prior versions of the document you’re currently editing.

Joomla 1.6 1.7 and 2.5

  • com_versions_16: This is the component that shows the list of content versions available for a particular document.
  • plg_content_versioning_16: This is the plugin that actually saves the version when you hit “Save” in the back end.
  • plg_editors_xtd_versioning_16: This is the button that appears at the bottom of the editor which you click to access prior versions of the document you’re currently editing.

How to convert Joomla 1.5 template to Joomla 2.5 template

In this tutorial, we will show how to convert a Joomla 1.5 template to Joomla 2.5 template. We will take default Joomla 1.5 template "rhuk_milkyway" as an example and convert it to Joomla 2.5 native compatible template.
Note:
This tutorial covers only the template conversion process, so it's assumed that you already have a Joomla 2.5 website installed, or converted from version 1.5.
There are 5 steps involved.
  1. Make a copy of all Joomla 1.5 template files
  2. Edit files structure
  3. Edit file "templateDetails.xml"
  4. Edit file "index.php"
  5. Install and test the converted Joomla 2.5 template

Step 1. Make a copy all Joomla 1.5 template files

The first thing to do is to copy the whole theme folder from version 1.5 to version 2.5
Copy whole Joomla template folder
Copy the whole template folder
  1. Go to the theme folder in Joomla 2.5 website
  2. Create a folder named "rhuk_milkyway25"
  3. Copy all files from folder "rhuk_milkyway" in Joomla 1.5 template folder to folder created in point 2.

Step 2. Edit files structure

Now, you need to edit the folder structure to make it compatible with Joomla 2.5
Edit folder structure to make it compatible
Edit folder structure to make it compatible
  1. Delete file "params.ini"
  2. In version 1.5 this file used to store values of template parameters. But in version 2.5, all template parameters are stored in the database. So there is no need for file "params.ini".
  3. Copy file "error.php" from default Joomla 2.5 template "atomic"
  4. Joomla 2.5 introduces new file "error.php" to contain layout of error pages. This file is simple and we can reuse the file from default theme "atomic".
  5. Create new file "template_preview.png"
  6. Joomla 2.5 introduces new file "template_preview.png" to present a big preview image of the theme. You need to make a 640x480 screenshot of your theme and name it "template_preview.png".

Step 3. Edit file "templateDetails.xml"

Now, you need to edit file "templateDetails.xml" to make it compatible with version 2.5.
  1. Rename tag <install> to <extension>
Edit file "templateDetails.xml"
Old value
New value
<install version="1.5"...
<extension version="2.5"...
</install>
</extension>
  1. Change template name in tag <name>
Change template name in tag <name>
  1. Replace multiple tags <filename> with single tag <folder>
  2. This is very cool feature of Joomla 2.5. Now you don't need to declare all the files in some folder, you just need to declare that folder.
Declare file folder
  1. Delete declaration for file "params.ini"
 Delete declaration for file "params.ini"
  1. Add declaration for new files created in step 2
  2. Add 2 following tags:
    1. <filename>error.php</filename>
    2. <filename>template_preview.png</filename>
     Add declaration for new files
  1. Rename tags in section <params>
Rename tags in section <params>
Old value
New value
<params>
<config>
<fields name="params">
<fieldset name="advanced">
<param...
< field...
</param>
</ field>
</params>
</fieldset>
</fields>
</config>

Step 4. Edit file "index.php"

After editing file "templateDetails.xml", you need to continue to edit file "index.php".
  1. Add PHP code to load Mootool library
  2. Add code string "JHtml::_('behavior.framework', true);" to the location as seen on the screenshot bellow.
Add PHP code to load Mootool library
  1. Replace template name text "rhuk_milkyway" with php code
  2. Joomla 2.5 allows you to get the theme name directly from file "templateDetails.xml" file, so there is no need to declare the theme name as plain text.
Replace template name
Old Value
New value
rhuk_milkyway
<?php echo $this->template ?>

Step 5. Install and test converted Joomla 2.5 template

Now, the converted Joomla 2.5 template is presented in templates folder, but you won't see new theme in Template Manager, because it's not installed yet. Make following steps:
  1. Go to Administrator > Extensions > Extension Manager > Discover.
Choose Discover tab in Extension Manager
  1. Click button "Discover" on toolbar
Click button "Discover" on toolbar
Select the item "rhuk_milkyway25" in the list and click button "Install"
Choose the Joomla 2.5 template to install
  1. Now, the Joomla 2.5 template is installed and you can go to "Template Manager" to set it as default.
Set the new Joomla 2.5 template as default
We finished the Joomla template migration with template "rhuk_milkyway" for today. Do you have any other ways to convert your template from version 1.5 to version 2.5 ? Please share using comment form belows. Feel free to leave questions if you get trouble with this migration process.

php - Unexpected $end in eval()'d code [Solve]

why we geting this error :  "Unexpected $end in eval()'d code" or "Parse error: syntax error, unexpected $end" or any syntax related error
because we just execute the statement not print the statement. ok lets check the statement
$ss="myclass::".$method_name.'()';
eval($ss);
if we execute the program it ll give the error because the statement ll come like this

myclass::function1() but you eval() method doing execute the php code not print the statement.

so we need to correct into eval() the PHP statement like myclass::function1(); in here ";" semicolon is missed that why the error. i think you got my point

Tuesday, July 30, 2013

difference between Action and Filter functions in wordpress

Actions are triggered by specific events that take place in WordPress, such as publishing a post, changing themes, or displaying a page of the admin panel. Your plugin can respond to the event by executing a PHP function, which might do one or more of the following:
* Modify database data
* Send an email message
* Modify what is displayed in the browser screen (admin or end-user)
Filters are functions that WordPress passes data through, at certain points in execution, just before taking some action with the data (such as adding it to the database or sending it to the browser screen). Filters sit between the database and the browser (when WordPress is generating pages), and between the browser and the database (when WordPress is adding new posts and comments to the database);

Action Hooks

Actions Hooks are intended for use when WordPress core or some plugin or theme is giving you the opportunity to insert your code at a certain point and do one or more of the following:
  1. Use echo to inject some HTML or other content into the response buffer,
  2. Modify global variable state for one or more variables, and/or
  3. Modify the parameters passed to your hook function (assuming the hook was called bydo_action_ref_array() instead of do_action() since the latter does not support passing variables by-reference.)

Filter Hooks

Filter Hooks behave very similar to Action Hooks but their intended use is to receive a value and potentially return a modified version of the value. A filter hook could also be used just like an Action Hook i.e. to modify a global variable or generate some HTML, assuming that's what you need to do when the hook is called. One thing that is very important about Filter Hooks that you don't need to worry about with Action Hooks is that the person using a Filter Hook must return (a modified version of) the first parameter it was passed. A common newbie mistake is to forget to return that value!

Using Additional Parameters to Provide Context in Filter Hooks

As an aside I felt that Filter Hooks were hobbled in earlier versions of WordPress because they would receive only one parameter; i.e they would get a value to modify but no 2nd or 3rd parameters to provide any context. Lately, and positively however, it seems the WordPress core team has joyously (for me) been adding extra parameters to Filter Hooks so that you can discover more context. A good example is the posts_where hook; I believe a few versions back it only accepted one parameter being the current query's "where" class SQL but now it accepts both the where clause and a reference to current instance of the WP_Query class that is invoking the hook.

So what's the Real Difference?

In reality Filter Hooks are pretty much a superset of Action Hooks. The former can do anything the latter can do and a bit more albeit the developer doesn't have the responsibility to return a value with the Action Hook that he or she does with the Filter Hook.

Giving Guidance and Telegraphing Intent

But that's probably not what is important. I think what is important is that by a developer choosing to use an Action Hook vs. a Filter Hook or vice versa they are telegraphing their intent and thus giving guidance to the themer or plugin developer who might be using the hook. In essence they are saying either "I'm going to call you, do whatever you need to do" OR"I've going to pass you this value to modify but be sure that you pass it back." 

Monday, July 29, 2013

how to run mail function in localhost php

do set in your php.ini file if you have any smtp configuration the do set nothing is requied to run email


SMTP = smtp.yoursmtp.com

smtp_port = 25
sendmail_from = bikash@htssgroups.com

Thursday, July 25, 2013

Change default from email -->wordpress@mydomain.com in wordpress

Change default email -->wordpress@mydomain.com to

 

 

step in 


If you wish to hard code this.. it's in wp-includes/pluggable.php
lines 320 and 336

Wednesday, July 24, 2013

joomla you have no access to this page The requested resource was not found. An error has occurred while processing your request.Eroor: 500 [Solve]

Hi new developers, i was spent lot of time lastly my own mind has resolved this issue.
that why  i do want to spend time any other resource in joomla.
for joomla administrator error
do change the configuration log and tmp path in configuration.php
--------------------------------------------------------------------------------------
set your server log path  like "d:\xampp\htdocs\projects/log"
same as tmp path                 "d:\xampp\htdocs\projects/tmp"
-------------------------------------------------------------------------------------


"an out-of-date bookmark/favourite     a search engine that has an out-of-date listing for this site     a mistyped address     you have no access to this page     The requested resource was not found.     An error has occurred while processing your request ERROR : 500 [solved] joomla.

thanks
Bikash ranjan

Friday, July 19, 2013

how to add custom menu in worpress menu van items


if($current_user->user_login == 'cloudburst') :
function add_login_out_item_to_menu( $items, $args ){
$link = '<li id="log-in-out-link" class="menu-item menu-type-link"><a href="'.get_bloginfo('url').'/allproducts">Shop</a></li>';
return $items.= $link;
}add_filter( 'wp_nav_menu_items', 'add_login_out_item_to_menu', 50, 2 );

endif;

Friday, July 12, 2013

how to check is availability domain using php curl

<?php
if (domainAvailibility('http://www.bikashsadf.com'))
       {
               echo "Up and running!";
       }
       else
       {
               echo "Woops, nothing found there.";
       }

       //returns boolean value
       function domainAvailibility($domain)
       {
               //check, if a valid url is provided
               if(!filter_var($domain, FILTER_VALIDATE_URL))
               {
                       return false;
               }

               //initialize curl
               $curlInit = curl_init($domain);
               curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
               curl_setopt($curlInit,CURLOPT_HEADER,true);
               curl_setopt($curlInit,CURLOPT_NOBODY,true);
               curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);

               //get answer
               $response = curl_exec($curlInit);

               curl_close($curlInit);

               if ($response) return true;

               return false;
       }
?>