Skip to content

Instantly share code, notes, and snippets.

View logichub's full-sized avatar

Kashif Rafique logichub

View GitHub Profile
@logichub
logichub / 0_reuse_code.js
Created December 23, 2013 08:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
The HTTP requests made by the premium plugins are really a huge pain. While I understand the purpose, I still don't get why they need to happen so often.
I have been struggling during a long time with this issue. Woo plugins, affiliate, etc. they all send requests even on page, post or custom posts pages. When their server is loaded, sit can easily take between 500ms to 2s.
Puneet, the only way to fix this has been to block all http request on specific pages by adding a filter 'pre_http_request'.
Here is a sample code: http://pastebin.com/5bji3rQG
This is not pretty but this should give you a starting point.
Before experimenting with this, you can always test by adding
define( 'WP_HTTP_BLOCK_EXTERNAL', TRUE );
/* Urdu font is available at https://github.com/logichub/urdu-fonts-support/tree/master/public/css/fonts
* Put following CSS code in your style.css or custom.css
* Copy fonts folder in your css file directory
*/
@font-face {
font-family: 'Urdu';
src: url('fonts/urdufont.eot');
src: url('fonts/urdufont.eot?#iefix') format('embedded-opentype'),
url('fonts/urdufont.woff') format('woff'),
@logichub
logichub / edd_google_tracking_code.php
Created April 28, 2016 11:21 — forked from miguelmich/edd_google_tracking_code.php
Easy Digital Downloads - Google Conversion Tracking Code
<?php
//Google Analytics E-commerce Tracking code
function your_prefix_google_ecommerce_tracking_code() {
$success_page = edd_get_option( 'success_page' ) ? is_page( edd_get_option( 'success_page' ) ) : false;
if ( ! $success_page || !edd_is_success_page() ){
return;
}
@logichub
logichub / .htaccess
Created May 14, 2016 05:17 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
<?php
// Building bootstrap 3 menu with submenu items without use WP_nav_walker (boostrap)!
// (Require bootstrap.css and bootstrap.js)
// Intented to use bootstrap 3.
// Location is like a 'primary'
// After, you print menu just add create_bootstrap_menu("primary") in your preferred position;
// Source: https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/#comment-1609
#add this function in your theme functions.php
@logichub
logichub / botscheduler.js
Created April 17, 2017 23:59 — forked from unnikked/botscheduler.js
Bot scheduler for Telegram - to use with IFTTT - please check https://unnikked.ga/build-telegram-bot-hook-io/ for instructions
module['exports'] = function bot (hook) {
var request = require('request');
var TOKEN = hook.env.bot_scheduler_token;
var ENDPOINT = 'https://api.telegram.org/bot' + TOKEN;
console.log(hook.params);
// generic handler to log api call responses
var handler = function (err, httpResponse, body) {
var response = JSON.stringify({
<?php
/* Add custom tags in the header */
function lh_add_custom_tag_head() {
if( is_page( array( 1, 2, 3, 4, 5, 6, 7 ) ) ) { //replace these numbers with the ids of your pages ?>
<link href="http://hvsimage.com/canonical/morris-water-maze-mwm/solutions/ " rel="canonical" />
<?php }
}
add_action( 'wp_head', 'lh_add_custom_tag_head' );
@logichub
logichub / list-hooked-functions.php
Created September 16, 2017 20:27 — forked from renventura/list-hooked-functions.php
List All Currently Hooked WordPress Functions
<?php //* mind this opening php tag
/**
* This snippet returns a list of all currently hooked functions.
* It is set up to output this data on a specific page. Do not output this data publicly.
* Use this snippet for debugging/testing/development.
* Source: http://www.rarst.net/wordpress/debug-wordpress-hooks/
* Modified by Ren Ventura, EngageWP.com
**/
<?php
/* Custom Post Type Setup */
function post_type_jobs() {
$labels = array(
'name' => _x('Jobs', 'post type general name', 'agrg'),
'singular_name' => _x('Jobs', 'post type singular name', 'agrg'),
'add_new' => _x('Add New Job', 'jobs', 'agrg'),
'add_new_item' => __('Add New Job', 'agrg'),
'edit_item' => __('Edit Job', 'agrg'),
'new_item' => __('New Job', 'agrg'),