Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Dipak C. Gajjar dipakcg

🎯
Focusing
View GitHub Profile
@dipakcg
dipakcg / whitelist.conf or exclude.conf
Created Jun 20, 2019
Specific rules for BBPress exclusion under ModSecurity (mod_security)
View whitelist.conf or exclude.conf
<locationmatch "/bb-post.php">
SecRuleRemoveById 300013
SecRuleRemoveById 300015
SecRuleRemoveById 300016
SecRuleRemoveById 300017
</locationmatch>
@dipakcg
dipakcg / whitelist.conf or exclude.conf
Created Jun 20, 2019
Specific rules for WordPress exclusion under ModSecurity (mod_security)
View whitelist.conf or exclude.conf
<locationmatch "/wp-admin/admin-ajax.php">
SecRuleRemoveById 300013
SecRuleRemoveById 300015
SecRuleRemoveById 300016
SecRuleRemoveById 300017
SecRuleRemoveById 949110
SecRuleRemoveById 980130
</locationmatch>
<locationmatch "/wp-admin/page.php">
@dipakcg
dipakcg / footer.php
Last active Oct 28, 2020
WordPress : Load any third-party script locally
View footer.php
@dipakcg
dipakcg / wp-config.php
Created Sep 23, 2018 — forked from MikeNGarrett/wp-config.php
Disable admin-ajax on the front-end of WordPress sites and cache the resulting 404.
View wp-config.php
<?php
if(
strpos( $_SERVER['HTTP_REFERER'], 'wp-admin' ) === false &&
strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) !== false
) {
header( 'Cache-Control: max-age=30000, must-revalidate' );
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', strtotime( '+5000 minutes' ) ) . ' GMT' );
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', strtotime( '-5000 minutes' ) ) . ' GMT' );
header( $_SERVER["SERVER_PROTOCOL"]." 404 Not Found" );
die;
@dipakcg
dipakcg / functions.php
Last active May 22, 2017
Customise WordPress Dashboard for Clients
View functions.php
function dcg_customise_dashboard() {
// remove_menu_page( 'index.php' ); //Dashboard
// remove_menu_page( 'jetpack' ); //Jetpack*
// remove_menu_page( 'edit.php' ); //Posts
// remove_menu_page( 'upload.php' ); //Media
// remove_menu_page( 'edit.php?post_type=page' ); //Pages
// remove_menu_page( 'edit-comments.php' ); //Comments
// remove_menu_page( 'themes.php' ); //Appearance
// remove_menu_page( 'plugins.php' ); //Plugins
// remove_menu_page( 'users.php' ); //Users
@dipakcg
dipakcg / functions.php
Created Jan 3, 2017 — forked from amdrew/functions.php
Easy Digital Downloads - Start to finish example of 1. Adding a phone number field at checkout 2. Making the phone field required 3. Showing the phone field on the "view order details" screen 4. Adding a new {phone} email tag to show the phone number in either the standard purchase receipt or admin notifications
View functions.php
<?php
/**
* Display phone number field at checkout
* Add more here if you need to
*/
function sumobi_edd_display_checkout_fields() {
// get user's phone number if they already have one stored
if ( is_user_logged_in() ) {
@dipakcg
dipakcg / responsive.html
Created Dec 1, 2016
Get browser window size using jQuery (useful for responsive web design)
View responsive.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Get browser window size using jQuery (useful for responsive testing)</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(window).bind({
load:function(){
@dipakcg
dipakcg / search.php
Created Dec 1, 2016
Display Google Custom Search results in WordPress if no posts/results found.
View search.php
<?php
/* Add this code in theme's search.php file where you want to display search 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 / export.php
Created Dec 1, 2016
Export MySQL to Excel (.xls) using PHP
View export.php
<?php
/***** EDIT BELOW LINES *****/
$DB_Server = "localhost"; // MySQL Server
$DB_Username = "username"; // MySQL Username
$DB_Password = "password"; // MySQL Password
$DB_DBName = "databasename"; // MySQL Database Name
$DB_TBLName = "tablename"; // MySQL Table Name
$xls_filename = 'export_'.date('Y-m-d').'.xls'; // Define Excel (.xls) file name
/***** DO NOT EDIT BELOW LINES *****/
@dipakcg
dipakcg / parallelize.php
Created Sep 14, 2016 — 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.
View parallelize.php
<?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