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 | |
/** | |
* Some Jetpack modules can be manually loaded. | |
* | |
* Here's an example of how to enable Lazy Images via code instead of database. | |
* | |
* @see https://github.com/Automattic/jetpack/blob/593ee4cccd6aead047c72aa78378f368f084035e/modules/lazy-images.php#L27 | |
*/ | |
if ( defined( 'JETPACK__PLUGIN_DIR' ) ) { |
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
// If the sub-navigation is off-screen we want to bump it left. | |
const parentsli = document.querySelectorAll( 'ul > li.page_item_has_children' ); | |
for ( let parent of parentsli ) { | |
const children = parent.querySelector( 'ul.children' ); | |
parent.addEventListener( 'mouseenter', evt => { | |
// Compare with width, to dropdown offset, to width of drop down. | |
const windowWidth = document.documentElement.clientWidth; | |
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 | |
/** | |
* Retreive a list events from a Google Calender in PHP. | |
* | |
* Useful when using Google Calendar as a project/time log. | |
* This script can be adapted to peal out events from a specific calendar. | |
* I use this for my personal timelog'ing. My events follow a naming | |
* pattern of `{category} - {project}: {details}`. | |
* |
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 | |
wp_scripts()->add_data( | |
'my_js_theme', | |
'my_theme_data', | |
sprintf( | |
'var my_theme_data = %s;', | |
wp_json_encode( [ | |
'nonce' => wp_create_nonce( 'wp_rest' ), | |
'path' => $path, |
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 | |
add_action( 'wp_enqueue_scripts', function() { | |
$version = SCRIPT_DEBUG ? time() : null; | |
wp_enqueue_script( | |
'_my_js_app', | |
get_template_directory_uri() . '/_my_js_app.js', | |
[], | |
$version, | |
true // in footer. |
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 | |
// Images in post galleries | |
add_filter( 'get_post_galleries', '_img_url_filter', PHP_INT_MAX ); | |
add_filter( 'widget_media_image_instance', '_img_url_filter', PHP_INT_MAX ); | |
// Core image retrieval | |
add_filter( 'image_downsize', '_img_url_filter', 10, 3 ); | |
// Responsive image srcset substitution |
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 | |
global $wp_taxonomies; | |
switch_to_blog($new); | |
if(!taxonomy_exists('my_missing_tax')) | |
$wp_taxonomies['my_missing_tax'] = 'delete'; | |
// do `tax_query`'s in $new with `my_missing_tax` |
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 // don't actually use the php in workflow | |
// get the result of Apple Script action | |
$url = '{query}'; | |
$a = ['http:','.loc']; // dev | |
$b = ['https:','.com']; // production | |
// identify if production and invert if so | |
if (strstr($url,$b[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
tell application "System Events" | |
set myApp to name of first application process whose frontmost is true | |
if myApp is "Google Chrome" then | |
tell application "Google Chrome" to return URL of active tab of front window | |
else if myApp is "Opera" then | |
tell application "Opera" to return URL of front document | |
else if myApp is "Safari" then | |
tell application "Safari" to return URL of front document | |
else if myApp is "Firefox" then | |
tell application "System Events" |