This file contains 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
/** | |
* Randomize widgets in a given sidebar (index) and only display a single widget | |
* | |
* @See http://wordpress.stackexchange.com/a/152408/26350 | |
* | |
* Good for Ad banners (simple) | |
* | |
*/ | |
! is_admin() && add_filter( 'sidebars_widgets', function( $sidebars_widgets ) { | |
// ------------------------ |
This file contains 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 | |
/** | |
* Add security and performance enhancements | |
* | |
*/ | |
// Exit if accessed directly. | |
defined( 'ABSPATH' ) || exit; | |
// remove version from head |
This file contains 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
// Archive.php only shows content of type 'post' | |
// This filter include custom post type | |
function archive_add_custom_post_types( $query ) { | |
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { | |
$query->set( 'post_type', array( | |
'post', 'fornecedores', 'produtos' //fornecedores ad produtos are custom post types | |
)); | |
return $query; | |
} | |
} |
This file contains 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
// Display Fornecedores & Produtos in ASC order by title | |
function my_change_sort_order($query){ | |
if(is_archive()): //If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type ) | |
//if (is_post_type_archive( 'fornecedores' ) | is_post_type_archive( 'produtos' ) ): | |
//Set the order ASC or DESC | |
$query->set( 'order', 'ASC' ); | |
//Set the orderby | |
$query->set( 'orderby', 'title' ); | |
endif; | |
}; |
This file contains 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 Dashicons for not logged in users | |
add_action( 'wp_print_styles', 'dashicons_dequeue_styles' ); | |
function dashicons_dequeue_styles() { | |
if ( ! is_user_logged_in() ) { | |
wp_dequeue_style( 'dashicons' ); | |
wp_deregister_style( 'dashicons' ); | |
} | |
} |
This file contains 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
<IfModule mod_expires.c> | |
ExpiresActive on | |
# Perhaps better to whitelist expires rules? Perhaps. | |
ExpiresDefault "access plus 1 month" | |
# Data | |
ExpiresByType text/xml "access plus 0 seconds" | |
ExpiresByType application/xml "access plus 0 seconds" | |
ExpiresByType application/json "access plus 0 seconds" | |
# Favicon (cannot be renamed) | |
ExpiresByType image/x-icon "access plus 1 week" |
This file contains 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 | |
/** | |
* Add useful shortcodes | |
* | |
*/ | |
// Exit if accessed directly. | |
defined( 'ABSPATH' ) || exit; | |
This file contains 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
//Change AO folder and file prefix | |
//It's mandatory to have an underline | |
//serve files from e.g. /wp-content/resources/aggregated_12345.css | |
//wp_config.php | |
define('AUTOPTIMIZE_CACHE_CHILD_DIR','/resources/'); | |
define('AUTOPTIMIZE_CACHEFILE_PREFIX','aggregated_'); | |
//Enable non-ASCII characters | |
add_filter('autoptimize_filter_main_use_mbstring', '__return_true'); |
This file contains 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
//GET UTM VALUES | |
//get url | |
var urlQueryString = window.location.search; | |
//set params | |
var urlParams = new URLSearchParams(urlQueryString); | |
//set vars to empty to avoid receiving 'NULL' on forms | |
var utm_source = ' '; |