-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Add some whimsical fun with an easter egg #13152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamsilverstein
wants to merge
11
commits into
WordPress:trunk
Choose a base branch
from
adamsilverstein:65907-restore-easter-egg
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+539
−0
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
45886c7
Script Loader: Restore the admin easter egg behind the command palette.
adamsilverstein a27c5b5
Script Loader: Fix overlay coverage, accessibility, and ending of the…
adamsilverstein a686785
Script Loader: Use single quotes for the easter egg closing line.
adamsilverstein 9597553
Script Loader: Trigger the easter egg without listing a command.
adamsilverstein b2150a3
Script Loader: Rename the easter egg files to teletype.
adamsilverstein 182a994
Script Loader: Correct the easter egg's provenance and cipher its dia…
adamsilverstein bbd8f3a
Script Loader: Trim the easter egg's inline commentary.
adamsilverstein 5230403
Script Loader: Soften the easter egg's dialogue and let it exit on it…
adamsilverstein 3517a62
Script Loader: Only claim Enter when the command palette found nothing.
adamsilverstein f7bcded
Script Loader: Add the falling glyph rain to the easter egg's Matrix …
adamsilverstein 57e9174
Script Loader: Give the easter egg to screen reader users too.
adamsilverstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| /** | ||
| * Hides the admin easter egg behind the command palette. | ||
| * | ||
| * No command is registered: a registered command would be listed as soon as its phrase | ||
| * matched. This listens for Enter while the palette is open instead, so the palette shows | ||
| * its ordinary "No results found." state throughout. | ||
| * | ||
| * The phrase is compared in its Dvorak/QWERTY-substituted form so that it is not a | ||
| * readable string in the admin bundle. | ||
| * | ||
| * @output wp-admin/js/teletype-loader.js | ||
| */ | ||
|
|
||
| ( function ( wp, settings ) { | ||
| 'use strict'; | ||
|
|
||
| if ( ! wp || ! wp.data || ! settings ) { | ||
| return; | ||
| } | ||
|
|
||
| var KEY = 'ishdg;rsdkot', | ||
| FROM = '\',.pyfgcrl/=\\aoeuidhtns-;qjkxbmwvz"<>PYFGCRL?+|AOEUIDHTNS_:QJKXBMWVZ[]', | ||
| TO = 'qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?-='; | ||
|
|
||
| /** | ||
| * Applies the Dvorak/QWERTY substitution cipher. | ||
| * | ||
| * @param {string} value Text to substitute. | ||
| * @return {string} Substituted text. | ||
| */ | ||
| function dvortr( value ) { | ||
| var map = {}, | ||
| i; | ||
|
|
||
| for ( i = 0; i < FROM.length; i++ ) { | ||
| map[ FROM.charAt( i ) ] = TO.charAt( i ); | ||
| } | ||
|
|
||
| return value.replace( /[\s\S]/g, function ( character ) { | ||
| return map[ character ] || character; | ||
| } ); | ||
| } | ||
|
|
||
| /** | ||
| * Fetches the payload if it is not already loaded, then plays it. | ||
| */ | ||
| function play() { | ||
| var script; | ||
|
|
||
| if ( wp.teletype ) { | ||
| wp.teletype.run( settings.name ); | ||
| return; | ||
| } | ||
|
|
||
| script = document.createElement( 'script' ); | ||
| script.src = settings.src; | ||
|
|
||
| script.onload = function () { | ||
| if ( wp.teletype ) { | ||
| wp.teletype.run( settings.name ); | ||
| } | ||
| }; | ||
|
|
||
| document.head.appendChild( script ); | ||
| } | ||
|
|
||
| /** | ||
| * Acts on the phrase when it is submitted from an open command palette. | ||
| * | ||
| * @param {KeyboardEvent} event The keydown event. | ||
| */ | ||
| function onKeydown( event ) { | ||
| var store, | ||
| input = event.target, | ||
| value; | ||
|
|
||
| if ( 'Enter' !== event.key || ! input || ! input.value ) { | ||
| return; | ||
| } | ||
|
|
||
| store = wp.data.select( 'core/commands' ); | ||
|
|
||
| if ( ! store || ! store.isOpen() ) { | ||
| return; | ||
| } | ||
|
|
||
| /* | ||
| * The palette's search field is a combobox: while any command matches, one of | ||
| * them is the active option and Enter belongs to it. Only an empty result list | ||
| * is ours to take, otherwise a post that happens to be named for the phrase | ||
| * would never open. | ||
| */ | ||
| if ( | ||
| 'combobox' !== input.getAttribute( 'role' ) || | ||
| input.getAttribute( 'aria-activedescendant' ) | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| value = input.value.toLowerCase().replace( /[^a-z0-9]/g, '' ); | ||
|
|
||
| if ( ! value || dvortr( value ) !== KEY ) { | ||
| return; | ||
| } | ||
|
|
||
| event.preventDefault(); | ||
| event.stopPropagation(); | ||
|
|
||
| wp.data.dispatch( 'core/commands' ).close(); | ||
| play(); | ||
| } | ||
|
|
||
| document.addEventListener( 'keydown', onKeydown, true ); | ||
| }( window.wp, window.wpTeletype ) ); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one 👍