Thursday, 23 June 2016

MySQL/SQL Queries Fetching Current and Previous Month Data


These queries are for fetching data for the last Months only not the days.

Wednesday, 22 June 2016

Get target check box checked in post editor

When adding a link in the WP visual post editor you have to click the settings after adding the link and then click the Open link in a new tab to have it add a link with a target in a new window/tab. Here is the way to have this automatically checked by default.


Saturday, 4 June 2016

Get Related Posts (Posts Under Same Category/Tags)

Tuesday, 31 May 2016

jQuery simple slider

Wednesday, 18 May 2016

Function for Showing Page Navigation on WordPress

Saturday, 7 May 2016

Code for Blocking Plugin Updates

/** Here, I blocked s2Member updates **/
/** You have to pass main file path. **/
function filter_plugin_updates($value) {
    unset($value->response['s2member/s2member.php']);
    return $value;
}
add_filter('site_transient_update_plugins', 'filter_plugin_updates');

Wednesday, 27 April 2016

Handling Post Request in PHP

Instead of $_POST you can handle the post data using function. By using this you need not to worry about the undefined index notice.
function postData($key) {
    $res = '';
    if (isset($_POST[$key])) {
        if (!is_array($_POST[$key])) {
            $res = htmlentities($_POST[$key]);
        } else if (is_array($_POST[$key]) && !empty($_POST[$key])) {
            $res = array();
            foreach ($_POST[$key] as $k => $v) {
                $res[$k] = htmlentities($v);
            }
        }
        return $res;
    }
    return '';
}

Thursday, 14 April 2016

Function for Currency Conversion PHP

function currencyConvert($from, $to, $amount) {
    $url = "http://www.google.com/finance/converter?a=$amount&from=$from&to=$to";
    $request = curl_init();
    $timeOut = 0;
    curl_setopt($request, CURLOPT_URL, $url);
    curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($request, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($request, CURLOPT_CONNECTTIMEOUT, $timeOut);
    $response = curl_exec($request);
    curl_close($request);
    return $response;
}

Sunday, 6 March 2016

Get Key From Array JavaScript

var _dat = array('name':'Rahul Dravid');
for (var prop in _dat) 
{
   //Adding extra parameters to form_data
   console.log(_dat[prop]['name'])
}