Skip to content

Instantly share code, notes, and snippets.

View dipakcg's full-sized avatar
🎯
Focusing

Dipak C. Gajjar dipakcg

🎯
Focusing
View GitHub Profile
@dipakcg
dipakcg / parallelize.php
Created September 14, 2016 09:22 — forked from leowebguy/parallelize.php
Parallelize downloads across hostnames for WordPress. Useful to boost static resources load speed on websites. Recommended by GTmetrix, Pingdom, Google Speed Insights, and others.
<?php
/******
Parallelize downloads across hostnames for WordPress.
Useful to boost static resources load speed on websites.
Recommended by GTmetrix, Pingdom, Google Speed Insights, and others.
See full post > https://medium.com/p/32e9dc2fec0c
In order to work properly, all subdomains/hostnames MUST have the same structure/path. Ex:
http://mydomain.com/wp-content/uploads/2015/11/myimage.jpg
@dipakcg
dipakcg / functions.php
Created August 29, 2014 17:26
WordPress - Disable Plugin Update Notification For A Specific WordPress Plugin
/* Put this code in current theme’s functions.php */
/* Replace plugin-directory/plugin-file.php with plugin’s directory and file name */
function filter_plugin_updates( $value ) {
unset( $value->response['plugin-directory/plugin-file.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
@dipakcg
dipakcg / search.php
Last active August 22, 2016 14:00
WordPress - Display Google Custom Search results if no posts/results found.
<?php
/* Below code will display Google Custom Search results if no posts/results found */
/* Add the below code in theme's search.php file where you want to display results from Google */
$query = get_search_query();
$query_new =str_replace(' ','%20',$query);
$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=0&rsz=8&q=".$query_new;
$body = file_get_contents($url);
$json = json_decode($body);
@dipakcg
dipakcg / functions.php
Last active June 15, 2016 15:15
WordPress - Remove menu or sub-menu page
/* ==========================================
Put the following code at the end of wp-config.php file to remove menu or sub-menu page.
========================================== */
/* *********
Line 10 will remove menu page of plugin: BackWPup
Line 11 will remove Settings menu
********* */
function dcg_custom_menu_page_removing() {
remove_menu_page( 'backwpup' );
@dipakcg
dipakcg / functions.php
Last active June 15, 2016 15:09
WordPress - Hide plugin from plugins (list) page
/* ==========================================
Put the following code at the end of wp-config.php file to hide plugin from plugins (list) page.
change line 8 with your plugin name.
========================================== */
function dcg_hide_plugin_from_dashboard() {
global $wp_list_table;
$hidearr = array('backwpup/backwpup.php');
$myplugins = $wp_list_table->items;
foreach ($myplugins as $key => $val) {
@dipakcg
dipakcg / style.less
Created May 22, 2016 07:59
Atom.io: Style Atom.io like Sublime Text on Mac
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed and saved.
*
* Add your own CSS or Less to fully customize Atom.
* If you are unfamiliar with Less, you can read more about it here:
* http://lesscss.org
*/
@dipakcg
dipakcg / display-xml-using-php.php
Created May 11, 2013 12:58
Display XML file contents in webpage using PHP
<?php
$strContent = file_get_contents('YOUR-XML-FILE-PATH.xml'); // eg. http://www.SomeDomain.com/FileName.xml
$arrContent = new SimpleXmlElement($strContent, LIBXML_NOCDATA);
?>
<p> &nbsp; </p>
<div style="margin-left:25px; margin-right: 7px;">
<h2>TITLE GOES HERE</h2>
<div>
<?php
$intI = 0;
@dipakcg
dipakcg / functions.php
Created March 28, 2013 21:22
WordPress - Modify main theme shortcode through child theme. (eg. To modify "intro_btn_name" shortcode of main theme, use following code under child theme's functions.php)
add_action( 'after_setup_theme', 'themewerx_child_theme_setup' );
function themewerx_child_theme_setup() {
remove_shortcode( 'intro_btn_name' );
add_shortcode( 'intro_btn_name', 'themewerx_intro_btn_name' );
}
function themewerx_intro_btn_name( $atts, $content = null ) {
global $intro_btn;
extract( shortcode_atts( array(
@dipakcg
dipakcg / functions.php
Last active August 29, 2015 14:20
WordPress - Redirect failed login attempts to any location
/* Adding this snippet to the functions.php or your wordpress theme will allow you to redirect failed login attempts to any location. */
add_action( 'wp_login_failed', 'dcg_redirect_failed_login' );
function dcg_redirect_failed_login( $username ) {
$referrer = $_SERVER['HTTP_REFERER'];
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
wp_redirect( $referrer . '?login=failed' );
exit;
}
@dipakcg
dipakcg / functions.php
Last active August 29, 2015 14:16
WordPress - Add custom RSS feeds to dashboard
/* ========================================== */
// Add this code to theme's functions.php
// It removes the default WordPress feeds and adds your custom feeds to the admin dashboard.
/* ========================================== */
function dcg_dashboard_widgets() {
global $wp_meta_boxes;
// remove unnecessary widgets
// var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs
unset(
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'],