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
| export class ImmutableRecord< T > { | |
| readonly #map: Readonly< Record< string, T > >; | |
| public constructor( map: Readonly< Record< string, T > > = {} ) { | |
| this.#map = map; | |
| } | |
| public get< F >( key: string, fallback?: F ): T | F | undefined { | |
| return this.#map[ key ] ?? fallback; | |
| } |
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
| @use "sass:math"; | |
| $browser-context: 16; | |
| /* | |
| * Convert pixels to ems. | |
| */ | |
| @function em($pixels, $context: $browser-context) { | |
| @if (math.is-unitless($pixels)) { |
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 an action that will be executed when a specific module is imported via importmap. | |
| * | |
| * WordPress does not allow modules to depend on scripts. As such, we investigate the `importmap` | |
| * for the presence of a module and execute an action when it is found. | |
| * The action shall take care of registering / enqueueing the appropriate scripts. | |
| */ | |
| function add_action_on_module_import(string $moduleName, callable $action): void | |
| { |
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
| /* | |
| * Usage | |
| * | |
| * ``` | |
| * a { | |
| * @include mixins.animate-border-bottom-on-hover-loop(); | |
| * } | |
| * ``` | |
| */ | |
| @mixin animate-border-bottom-on-hover-loop() { |
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_filter('block_editor_settings_all', static function (array $settings): array { | |
| $currentUserRoles = \wp_get_current_user()->roles; | |
| $allowedUserRoles = ['editor', 'administrator']; | |
| $isUserAllowed = (bool)\array_intersect($currentUserRoles, $allowedUserRoles); | |
| if (!$isUserAllowed) { | |
| $settings['canLockBlocks'] = false; | |
| } |
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 | |
| function notify(string $message, string $noticeType, array $allowedMarkup = []): void | |
| { | |
| $callback = function () use ($message, $noticeType, $allowedMarkup) { | |
| ?> | |
| <div class="notice notice-<?= \sanitize_html_class($noticeType) ?>"> | |
| <p><?= \wp_kses($message, $allowedMarkup) ?></p> | |
| </div> | |
| <?php | |
| }; |
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 | |
| function array_insert_into_position( | |
| $needle, | |
| array &$haystack, | |
| $pos, | |
| $preserve = false, | |
| $recursive = false | |
| ): array { | |
| $keys = array_filter( |
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 | |
| /** | |
| * Re Order Files | |
| * | |
| * @access private | |
| * | |
| * @param array $list An array $_FILES like to re-order | |
| * | |
| * @return array The re-order array list | |
| */ |
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 | |
| /** | |
| * Get post by name | |
| * | |
| * @since 2.0.0 | |
| * | |
| * @param string $name The name ( slug ) of the post to retrieve. | |
| * @param string $post_type The post type. Optional. Default to 'post'. | |
| * | |
| * @return WP_Post The post object |
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
| @mixin screen-reader-text { | |
| & { | |
| clip : rect(1px, 1px, 1px, 1px); | |
| position : absolute !important; | |
| height : 1px; | |
| width : 1px; | |
| overflow : hidden; | |
| &:focus { | |
| background-color : #F1F1F1; |
NewerOlder