Skip to content

Instantly share code, notes, and snippets.

<?php
// Asset version number - change when CSS needs updating
$version = '20150829';
// If cookie has been set and matches the version above, load CSS normally
if (!empty( $_COOKIE[ 'csscached' ]) && $_COOKIE[ 'csscached' ] === $version) :
?>
<link rel="stylesheet" href="/assets/styles/main.min.css?v=<?php echo $version;?>">
<?php
else :
@dotZak
dotZak / script_loader_tag_add_attributes.php
Last active August 27, 2019 11:16
WordPress `async` and `defer` tags for registered or enqueued scripts.
<?php
/**
* Use in WordPress themes or plugins in order to add
* `async` and `defer` attributes to script tags when
* using `wp_enqueue_script` or `wp_register_script`.
*/
if ( ! function_exists( 'tag_add_attribute_async' ) ) :
/**
* Add Async Attribute
@dotZak
dotZak / accessible-hidden-text.css
Created July 6, 2017 11:31
Accessible hidden text
.visible-on-focus:not(:focus), /* Keyboard accessible */
.screen-reader-only /* Not keyboard accessible */ {
clip: rect(1px, 1px, 1px, 1px);
clip-path: polygon(0px 0px, 0px 0px,0px 0px, 0px 0px);
position: absolute !important;
white-space: nowrap;
height: 1px;
width: 1px;
overflow: hidden;
}
@dotZak
dotZak / accessible-search-form.html
Last active May 12, 2017 09:54
Accessible Search Form
<form role="search">
<label for="directorysearchfield">Search <abbr title="Required">*</abbr></label><!-- '*' is an abbreviation of "required". -->
<input id="directorysearchfield" name="search" type="search" placeholder="Enter a search term…" required aria-required="true">
<input type="submit" name="submit">
</form>
@dotZak
dotZak / theme-functions.php
Last active October 4, 2016 07:58
wp_enqueue_script() filters
<?php
/**
* Functions used be the WordPress theme.
*/
if ( ! function_exists( 'get_google_maps_src' ) ) :
/**
* Take a Google Maps API v3 key (and optional callback) and return value for the 'src' attribute to load the api script.
* To be used for getting the wp_enqueue_script() URI parameter.
*
@dotZak
dotZak / gulp-iconfont Configuration
Last active January 23, 2016 04:39
Create a dynamic icon font and associated stylesheet.
/**
* Custom icon font generation
*
* require gulp
* require gulp-consolidate
* require gulp-iconfont
* require gulp-newer
* require gulp-rename
* require browser-sync (optional)
*
@dotZak
dotZak / origin-year-to-current-year.php
Created October 14, 2015 10:43
PHP: Return string of origin year to the current year
function origin_year_to_current_year( $origin_year, $sep = '-', $after = '' )
{
$date_range = $origin_year;
if( date('Y') != $origin_year )
{
$current_year = date('Y');
$date_range = $current_year . $sep . date('Y');
}
@dotZak
dotZak / onScrollOnInterval.js
Last active August 29, 2015 14:28
scroll events based on an interval
if (document.getElementById('widget-slide-dock'))
{
var didScroll = false
, randomPost = document.getElementById('widget-slide-dock')
, triggerElement = document.getElementById('site-sidebar')
, targetPosition = (triggerElement.offsetHeight + jQuery(triggerElement).offset().top);
setInterval( function()
{
if(didScroll)
@dotZak
dotZak / gist:d6f67c04fe261975cb9b
Last active December 1, 2021 14:25
rewrite urls in mysql for wordpress
UPDATE wp_options SET option_value = replace(option_value, 's://ORIGINAL.COM', '://REPLACEMENT.COM') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_comments SET comment_content = replace(comment_content, 's://ORIGINAL.COM', '://REPLACEMENT.COM');
UPDATE wp_posts SET post_content = replace(post_content, 's://ORIGINAL.COM', '://REPLACEMENT.COM');
UPDATE wp_posts SET guid = replace(guid, 's://ORIGINAL.COM', '://REPLACEMENT.COM');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 's://ORIGINAL.COM', '://REPLACEMENT.COM');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 's://ORIGINAL.COM', '://REPLACEMENT.COM');
UPDATE wp_links SET link_url = replace(link_url, 's://ORIGINAL.COM', '://REPLACEMENT.COM');
UPDATE wp_links SET link_image = replace(link_image, 's://ORIGINAL.COM', '://REPLACEMENT.COM');
UPDATE wp_blogs SET domain = replace(domain, 'ORIGINAL.COM', 'REPLACEM