Skip to content

Instantly share code, notes, and snippets.

@peterwegren
peterwegren / js_dynamic_function_call_and_dynamic_args.js
Created November 20, 2019 22:04
How to call a JS function dynamically, and also pass in a variable number of dynamic arguments.
// INPUT:
// const largeSphere = {
// type: 'sphere',
// radius: 40
// }
// const smallSphere = {
// type: 'sphere',
// radius: 10
// }
@peterwegren
peterwegren / style_guide.html
Created June 28, 2017 16:26
Basic HTML style guide for developing basic element styles.
<div id="top" class="page">
<ul>
<li><a href="#text__headings">Headings</a></li>
<li><a href="#text__paragraphs">Paragraphs</a></li>
<li><a href="#text__blockquotes">Blockquotes</a></li>
<li><a href="#text__lists">Lists</a></li>
<li><a href="#text__tables">Tabular data</a></li>
<li><a href="#text__inline">Inline elements</a></li>
</ul>
</div>
@peterwegren
peterwegren / featured_image.php
Created March 6, 2017 18:21
Get WP post featured image URL for defined image size.
@peterwegren
peterwegren / WP-hide-plugin-updates.php
Created February 8, 2017 17:14
Hide WP plugin updates.
<?php
function filter_plugin_updates( $value ) {
unset( $value->response['akismet/akismet.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
@peterwegren
peterwegren / sunrise.php
Created February 3, 2017 16:39
WP Sunrise file for nested subdirectory multisite installation.
<?php
if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
$current_site->id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
$current_site->domain = $domain = DOMAIN_CURRENT_SITE;
$current_site->path = $path = PATH_CURRENT_SITE;
if ( defined( 'BLOGID_CURRENT_SITE' ) )
$current_site->blog_id = BLOGID_CURRENT_SITE;
@peterwegren
peterwegren / apache-browser-caching.txt
Last active January 26, 2017 18:55
Apache .htaccess browser caching settings.
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
@peterwegren
peterwegren / gf-prevent-duplicate.php
Last active January 25, 2017 18:54
Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value)
<?php
/**
* Gravity Wiz // Gravity Forms // Limit Submissions Per Time Period (by IP, User, Role, Form URL, or Field Value)
*
* Limit the number of times a form can be submitted per a specific time period. You modify this limit to apply to
* the visitor's IP address, the user's ID, the user's role, a specific form URL, or the value of a specific field.
* These "limiters" can be combined to create more complex limitations.
*
* @version 2.8
* @author David Smith <[email protected]>
@peterwegren
peterwegren / _modal.scss
Created January 12, 2017 17:16
Default style overrides for Bootstrap modals.
.modal {
z-index: 999999;
.modal-header {
position: relative;
}
.close {
font-size: 2.6rem;
width: 2.6rem;
height: 2.6rem;
@peterwegren
peterwegren / waldo_add_image_sizes.php
Created December 6, 2016 20:17
Waldo - add image sizes.
<?php
/* in your functions.php */
add_image_size( 'small', 420, 420, false );
// default WP sizes, update dimensions under Settings > Media
// add_image_size( 'medium', 768, 768, false );
// add_image_size( 'large', 1024, 1024, false );
@peterwegren
peterwegren / waldo_multiple_images.php
Last active December 6, 2016 19:31
Waldo - multiple images, single page/template.
<?php
$image = get_field('section_image_1');
$waldo_class = 'section-image-1';
$waldo_styles = $waldo->waldoStylesArray($image, $waldo_class, $waldo_styles, $waldo_class);
$image = get_field('section_image_2');
$waldo_class = 'section-image-2';
$waldo_styles = $waldo->waldoStylesArray($image, $waldo_class, $waldo_styles, $waldo_class);