add_filter(
'webp_uploads_img_url_mime_type',
function ( $replacement, $attachment_id, $size_name, $mime_type, $image_tag ) {
// Plugin is interested only on WebP.
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
add_action( 'rest_api_init', function () { | |
register_rest_route( | |
'wp/v2', | |
'/media/(?P<id>[\d]+)/custom', | |
array( | |
'methods' => 'GET', | |
'args' => array( | |
'id' => array( | |
'validate_callback' => function ( $id ) { | |
if ( ! is_numeric( $id ) ) { |
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 | |
/* | |
* EXAMPLE OF CHANGING ANY TEXT (STRING) IN THE EVENTS CALENDAR | |
* See the codex to learn more about WP text domains: | |
* http://codex.wordpress.org/Translating_WordPress#Localization_Technology | |
* Example Tribe domains: 'tribe-events-calendar', 'tribe-events-calendar-pro'... | |
*/ | |
function tribe_custom_theme_text( $translation, $text, $domain ) { | |
// If this text domain doesn't start with "tribe-", "the-events-", or "event-" bail. | |
if ( ! ( strpos( $domain, 'tribe-' ) !== false || strpos( $domain, 'the-events-' ) !== false || strpos( $domain, 'event-' ) !== false ) ) { |
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 | |
function upload_asset( $location, $post_id ) { | |
$timeout_seconds = MINUTE_IN_SECONDS * 10; | |
$tmp_file = download_url( $location, $timeout_seconds ); | |
if ( is_wp_error( $tmp_file ) ) { | |
@unlink( $tmp_file ); | |
return false; | |
} | |
$type = wp_check_filetype( $tmp_file ); |
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
AL : Alabama | |
AK : Alaska | |
AZ : Arizona | |
AR : Arkansas | |
CA : California | |
CO : Colorado | |
CT : Connecticut | |
DE : Delaware | |
FL : Florida | |
GA : Georgia |
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
Interesting Javascript puzzle (from a recent programming contest): | |
How do you create a number 100000000000000000000 in Javascript using only these four characters: '+', '!', '[', ']' and you can only use at most 60 such characters? | |
Some hints: | |
+!![] is equal to number 1 | |
+!![]+!![] is equal to number 2 | |
(don't answer if you participated in that contest) | |
FYI, the answer is super tricky and close to "cheating". |
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
#!/bin/bash | |
# Show all the current LOG of your history. | |
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent' | |
# Delete all the entries from the history. | |
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent' | |
# Credits: | |
# http://lifehacker.com/your-mac-logs-everything-you-download-heres-how-to-cle-1658394180 |
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
defaults write com.apple.screencapture location ~/Pictures | |
killall SystemUIServer | |
# Where ~/Pictures is the current location where the screenshots | |
# are going to be saved. |
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
defaults write com.apple.screencapture type png | |
killall SystemUIServer | |
# Different formats | |
# png: Portable Network Graphic | |
# pdf: Portable Document Format | |
# jpg: Joint Photographic Experts Group (JPEG) | |
# tif: Tagged Image File Format (TIFF) | |
# gif: Graphics Interchange Format | |
# pct: Macintosh QuickDraw Picture (PICT) |