Skip to content

Instantly share code, notes, and snippets.

Crash dotZak

  • Rush Hour Media
  • Hong Kong
Block or report user

Report or block dotZak

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dotZak
dotZak / script_loader_tag_add_attributes.php
Last active Aug 27, 2019
WordPress `async` and `defer` tags for registered or enqueued scripts.
View script_loader_tag_add_attributes.php
<?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
View accessible-hidden-text.css
.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
Accessible Search Form
View accessible-search-form.html
<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 Oct 4, 2016
wp_enqueue_script() filters
View theme-functions.php
<?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 Jan 23, 2016
Create a dynamic icon font and associated stylesheet.
View gulp-iconfont Configuration
/**
* 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 Oct 14, 2015
PHP: Return string of origin year to the current year
View origin-year-to-current-year.php
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 Aug 29, 2015
scroll events based on an interval
View onScrollOnInterval.js
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 Oct 24, 2018
rewrite urls in mysql for wordpress
View gist:d6f67c04fe261975cb9b
UPDATE wp_options SET option_value = replace(option_value, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_comments SET comment_content = replace(comment_content, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM');
UPDATE wp_posts SET post_content = replace(post_content, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM');
UPDATE wp_posts SET guid = replace(guid, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM');
UPDATE wp_usermeta SET meta_value = replace(meta_value, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM');
UPDATE wp_links SET link_url = replace(link_url, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM');
UPDATE wp_links SET link_image = replace(link_image, 'http://ORIGINAL.COM', 'https://REPLACEMENT.COM');
You can’t perform that action at this time.