Skip to content

Instantly share code, notes, and snippets.

View mahdiyazdani's full-sized avatar
:bowtie:
Still Rocking!

Mahdi Yazdani mahdiyazdani

:bowtie:
Still Rocking!
View GitHub Profile
@mahdiyazdani
mahdiyazdani / turn-off-cache-for-all-browsers-with-meta.html
Created September 24, 2016 23:50
Using <meta> tags to turn off caching in all browsers
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
@mahdiyazdani
mahdiyazdani / hide-php-warning-and-errors-in-wordpress.php
Last active September 24, 2016 23:57
Hide PHP Warnings and Errors in WordPress
<?php
/**
* Replace this line from your wp-config.php file
* "define('WP_DEBUG', false);"
* with these commands below.
*/
ini_set('log_errors', 'On');
ini_set('display_errors', 'Off');
ini_set('error_reporting', E_ALL);
define('WP_DEBUG', false);
@mahdiyazdani
mahdiyazdani / change-wp-admin-footer-text.php
Created September 24, 2016 23:56
Change WordPress admin area footer text
@mahdiyazdani
mahdiyazdani / auto-clear-browser-cookies.php
Created September 28, 2016 15:09
Auto-Clear Browser Cookies
<?php
/**
* Add the following code to your wp-config.php file above the “happy blogging” line:
*/
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
@mahdiyazdani
mahdiyazdani / add-expire-headers-to-wordpress.txt
Last active September 30, 2016 09:42
Add Expire Headers to WordPress
# Browser Caching – Add Expire Headers to WordPress
# BEGIN Expire headers
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 5 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
@mahdiyazdani
mahdiyazdani / gzip-compression-for-wordPress.txt
Created September 29, 2016 23:35
Gzip Compression for WordPress
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
@mahdiyazdani
mahdiyazdani / disable-emoji.php
Last active September 29, 2016 23:46
Disable the emoji's
<?php
/**
* Disable the emoji's
*/
function disable_emojis()
{
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_styles', 'print_emoji_styles');
@mahdiyazdani
mahdiyazdani / disable-hotlinking.txt
Created September 29, 2016 23:48
Disable Hotlinking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
@mahdiyazdani
mahdiyazdani / add-custom-fields-in-user-registration-woocommerce.php
Last active February 22, 2024 13:55
Add custom fields in user registration WooCommerce
<?php
/**
* Displaying first name and last name fields on
* WooCommerce's registration page.
*/
function woocommerce_register_form() {
$fields = array(
'first_name' => __('First name', 'woocommerce'),
@mahdiyazdani
mahdiyazdani / add-confirm-password-field-into-woocommerce-registration-form.php
Created October 8, 2016 19:26
Add confirm password field into WooCommerce registration form
<?php
/**
* Add the code below to your theme's functions.php file
* to add a confirm password field on the register form under My Accounts.
*/
function woocommerce_registration_errors_validation($reg_errors, $sanitized_user_login, $user_email) {
global $woocommerce;
extract( $_POST );
if ( strcmp( $password, $password2 ) !== 0 ) {