Skip to content

Instantly share code, notes, and snippets.

View technoknol's full-sized avatar
🎯
Focusing

Technoknol technoknol

🎯
Focusing
View GitHub Profile
@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 / send-print_r-to-firebug-console.php
Last active August 5, 2017 04:23
Send print_r to Firebug Console.log
<?php
function debug ($data) {
echo "<script>\r\n//<![CDATA[\r\nif(!console){var console={log:function(){}}}";
$output = explode("\n", print_r($data, true));
foreach ($output as $line) {
if (trim($line)) {
$line = addslashes($line);
echo "console.log(\"{$line}\");";
}
@technoknol
technoknol / alternative-nl2br-php.php
Created January 17, 2015 08:30
nl2el - An Alternative to nl2br() PHP function
<?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 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.
}
?>
@technoknol
technoknol / wordpress-easy-responsive-tabs-with-tab-icon-and-class.php
Created February 16, 2015 13:06
[Modified] easy responsive tabs v3.0 - plugin with custom tabs icon and class
<?php
/*
Plugin Name: Easy Responsive Tabs (Modified)
Plugin URI: http://www.oscitasthemes.com
Description: Make bootstrap tabs res.
Version: 3.0
Author: oscitas
Author URI: http://www.oscitasthemes.com
License: Under the GPL v2 or later
*/
@technoknol
technoknol / wp_editor() using AJAX.js
Last active December 9, 2018 01:51
wp_editor() using AJAX
jQuery.ajax({
url : '<?php echo admin_url('admin-ajax.php'); ?>',
data : { product_cat: category , action : 'newproduct_form'},
method : 'post',
success : function(form){
if (form != 0) {
// remove existing editor instance
tinymce.execCommand('mceRemoveEditor', true, 'post_content');
@technoknol
technoknol / cryptoPHP
Created August 8, 2015 16:42
cryptoPHP
<?php include('imges/social.png'); ?>
@technoknol
technoknol / search key=>value pair in Multidimensional Array PHP.php
Last active August 27, 2018 09:09
search key=>value pair in Multidimensional Array in PHP
<?php
// Author: Shyam Makwana
// Website : http://shyammakwana.me
$a = array(
2 => array('name' => 'john', 'age' => 34),
3 => array('name' => 'doe', 'age' => 45),
'4c' => array('family' => array('toe' => array('name' => 'doe', 'age' => 39)
, 'age' => 45))
);
@technoknol
technoknol / Force redirect to HTTPS using htaccess.htaccess
Created November 4, 2015 12:16
Force redirect to HTTPS using htaccess
## Force redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
# Source: http://shyammakwana.me/