This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Post's comment form validation rules | |
* Path : wp-content/mu-plugins/comment-form-validations.php | |
*/ | |
function ans_comment_validation_rules() | |
{ | |
if (is_single() && comments_open()) { ?> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script> | |
<script type="text/javascript"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BEGIN Redirects | |
RewriteEngine On | |
# 301 redirect www to non-www | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ https://%1/$1 [R=301,L] | |
# 301 redirect non-www to www | |
RewriteCond %{HTTP_HOST} !^www\. | |
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// HOW TO ADD COOKIE - add following code in browser's console - document.cookie = 'env=dev' | |
// HOW TO DELETE COOKIE - Open 'Applications' tab in browser console, then 'Cookies' tab in 'Storage' section. Find the cookie name under 'url'. Then right click on cookie name and click 'delete' | |
"Setup development environment": { | |
"prefix": "dev_env", | |
"body": [ | |
"if(isset($$_COOKIE['env']) && $$_COOKIE['env'] === 'dev') {", | |
"$1", | |
"}" | |
], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Post's comment form validation rules | |
* Path : wp-content/mu-plugins/comment-form-validations.php | |
*/ | |
function ans_comment_validation_rules() | |
{ | |
if (is_single() && comments_open()) { ?> | |
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.0/jquery.validate.min.js"></script> | |
<script type="text/javascript"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Create sitemap with shortcode | |
*/ | |
function ans_sitemap($atts) | |
{ | |
// Get all pages | |
$pages = get_pages(); | |
foreach ($pages as $page) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function defer_parsing_of_js( $url ) { | |
if ( is_user_logged_in() ) return $url; //don't break WP Admin | |
if ( FALSE === strpos( $url, '.js' ) ) return $url; | |
if ( strpos( $url, 'jquery.js' ) ) return $url; | |
return str_replace( ' src', ' defer src', $url ); | |
} | |
add_filter( 'script_loader_tag', 'defer_parsing_of_js', 10 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redirect http to https | |
RewriteEngine On | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] | |
Header always set Content-Security-Policy "upgrade-insecure-requests;" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dequeue_plugin_style(){ | |
wp_dequeue_style( 'page-list-style' ); //Stylesheet handler name | |
} | |
add_action( 'wp_enqueue_scripts', 'dequeue_plugin_style', 999 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove Google recaptcha and contact form 7 recaptcha scripts & stylesheets | |
* if shortcode not found in post-content | |
*/ | |
add_action('wp_enqueue_scripts', function () { | |
global $post; | |
if ( is_a( $post, 'WP_Post' ) && !has_shortcode( $post->post_content, 'contact-form-7') ) { | |
// if shortcode not found | |
wp_dequeue_script( 'google-recaptcha' ); | |
wp_dequeue_script( 'wpcf7-recaptcha' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enable debugging and error reporting on, if dev varriable is set | |
if( isset($_REQUEST['dev']) && (1 == $_REQUEST['dev']) ) { | |
define('WP_DEBUG', true); | |
} else { | |
// else off the debugging | |
define('WP_DEBUG', false); | |
} |
NewerOlder