Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c5067f3
Add On This Day Widget
alshakero Apr 22, 2026
e1b0ba0
Lint
alshakero Apr 22, 2026
5b7cbcf
Refactor CSS
alshakero Apr 22, 2026
45571e4
Cleaner CSS
alshakero Apr 22, 2026
6bd17f6
Remove unneeded file
alshakero Apr 22, 2026
c1fcec2
Remove extra space
alshakero Apr 22, 2026
bdf30db
Merge branch 'trunk' into add/on-this-day-widget
alshakero Apr 23, 2026
b53e3b5
Add caching for fetching and rendering
alshakero Apr 23, 2026
63c8422
Merge branch 'add/on-this-day-widget' of https://github.com/alshakero…
alshakero Apr 23, 2026
4865fc0
Redesign
alshakero Apr 23, 2026
a32a13f
Fix on mobile
alshakero Apr 23, 2026
a79feb4
Render date pill only on the header of the postbox (not the title)
alshakero Apr 24, 2026
3ea2323
Design fine tuning
alshakero Apr 24, 2026
eceeec1
Merge branch 'trunk' into add/on-this-day-widget
alshakero Apr 24, 2026
aa09b83
Switch to WP_Query
alshakero Apr 24, 2026
05c5a23
Remove #[AllowDynamicProperties] attribute from WP_On_This_Day class
alshakero Apr 25, 2026
488310b
Add an adjustable window size
alshakero Apr 25, 2026
9747fb5
Merge branch 'trunk' into add/on-this-day-widget
alshakero Apr 26, 2026
dfc24f2
Merge branch 'trunk' into add/on-this-day-widget
alshakero Apr 27, 2026
bcf3daa
Address feedback
alshakero Apr 27, 2026
f62cfb3
Merge branch 'add/on-this-day-widget' of https://github.com/alshakero…
alshakero Apr 27, 2026
e446635
Don't concat two strings to make a sentence
alshakero Apr 27, 2026
4f6b9bc
Switch to `wp_scrub_utf8`
alshakero Apr 27, 2026
7dea82e
Bring back success message config
alshakero Apr 27, 2026
5b46861
Fix toggle indicator collapse on On This Day widget
escapemanuele Apr 28, 2026
6e960aa
Merge branch 'trunk' into add/on-this-day-widget
alshakero Apr 28, 2026
afc4ac2
Move away from CSS prop to `attr` for simpler escaping
alshakero Apr 28, 2026
efd8b31
Use `sprintf` instead
alshakero Apr 28, 2026
3d7ea6f
Refine On This Day widget escaping and rendered markup
escapemanuele Apr 29, 2026
ded7416
Run PHPCBF
alshakero Apr 29, 2026
2aa110e
Merge branch 'trunk' into add/on-this-day-widget
alshakero Apr 29, 2026
993c4fb
Switch to `WP_HTML_Tag_Processor` and use CSS for adding ellipsis ins…
alshakero Apr 30, 2026
d20b27d
Merge branch 'add/on-this-day-widget' of https://github.com/alshakero…
alshakero Apr 30, 2026
5a3fb28
Merge branch 'trunk' into add/on-this-day-widget
alshakero May 5, 2026
2c80205
Don't add whitespace for non-block tags and add tests
alshakero May 11, 2026
903f2c3
Merge branch 'add/on-this-day-widget' of https://github.com/alshakero…
alshakero May 11, 2026
d458d25
Merge branch 'trunk' into add/on-this-day-widget
alshakero May 11, 2026
39ed253
Remove excess whitespace
alshakero May 11, 2026
01e5164
Merge branch 'add/on-this-day-widget' of https://github.com/alshakero…
alshakero May 11, 2026
3be969a
Address feedback
alshakero May 12, 2026
165261c
Merge branch 'trunk' into add/on-this-day-widget
alshakero May 12, 2026
67ff936
Redesign:
alshakero May 13, 2026
e165fc7
Merge branch 'trunk' into add/on-this-day-widget
alshakero May 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ module.exports = function(grunt) {
[ WORKING_DIR + 'wp-admin/js/media-upload.js' ]: [ './src/js/_enqueues/admin/media-upload.js' ],
[ WORKING_DIR + 'wp-admin/js/media.js' ]: [ './src/js/_enqueues/admin/media.js' ],
[ WORKING_DIR + 'wp-admin/js/nav-menu.js' ]: [ './src/js/_enqueues/lib/nav-menu.js' ],
[ WORKING_DIR + 'wp-admin/js/on-this-day.js' ]: [ './src/js/_enqueues/admin/on-this-day.js' ],
[ WORKING_DIR + 'wp-admin/js/password-strength-meter.js' ]: [ './src/js/_enqueues/wp/password-strength-meter.js' ],
[ WORKING_DIR + 'wp-admin/js/password-toggle.js' ]: [ './src/js/_enqueues/admin/password-toggle.js' ],
[ WORKING_DIR + 'wp-admin/js/plugin-install.js' ]: [ './src/js/_enqueues/admin/plugin-install.js' ],
Expand Down Expand Up @@ -1236,6 +1237,7 @@ module.exports = function(grunt) {
'src/wp-admin/js/media-upload.js': 'src/js/_enqueues/admin/media-upload.js',
'src/wp-admin/js/media.js': 'src/js/_enqueues/admin/media.js',
'src/wp-admin/js/nav-menu.js': 'src/js/_enqueues/lib/nav-menu.js',
'src/wp-admin/js/on-this-day.js': 'src/js/_enqueues/admin/on-this-day.js',
'src/wp-admin/js/password-strength-meter.js': 'src/js/_enqueues/wp/password-strength-meter.js',
'src/wp-admin/js/plugin-install.js': 'src/js/_enqueues/admin/plugin-install.js',
'src/wp-admin/js/post.js': 'src/js/_enqueues/admin/post.js',
Expand Down
133 changes: 133 additions & 0 deletions src/js/_enqueues/admin/on-this-day.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/**
* @output wp-admin/js/on-this-day.js
*/

( function( $ ) {
function flashState( $button, message ) {
var original = $button.data( 'otdShareLabel' ) || $button.text();

$button.text( message ).addClass( 'is-copied' );

window.setTimeout( function() {
$button.text( original ).removeClass( 'is-copied' );
}, 2000 );
}

function legacyCopy( text ) {
var $textarea = $( '<textarea readonly></textarea>' )
.val( text )
.css( {
position: 'absolute',
left: '-9999px'
} )
.appendTo( 'body' );

$textarea[0].select();

try {
document.execCommand( 'copy' );
} catch ( error ) {}

$textarea.remove();
}

function copyShareUrl( $button, url ) {
var success = $button.data( 'otdShareCopied' ) || 'Link copied!';

function done() {
flashState( $button, success );
}

if ( navigator.clipboard && navigator.clipboard.writeText ) {
navigator.clipboard.writeText( url ).then(
done,
function() {
legacyCopy( url );
done();
}
);
return;
}

legacyCopy( url );
done();
}

$( '.on-this-day-post-share' ).on( 'click', function( event ) {
var $button = $( this ),
url = $button.data( 'otdShareUrl' ),
shareData = {
title: $button.data( 'otdShareTitle' ) || document.title,
url: url
};

event.preventDefault();

if ( ! url ) {
return;
}

if (
navigator.share &&
( ! navigator.canShare || navigator.canShare( shareData ) )
) {
navigator.share( shareData ).then(
function() {
flashState( $button, $button.data( 'otdShareShared' ) || 'Shared!' );
},
function( error ) {
if ( ! error || 'AbortError' !== error.name ) {
copyShareUrl( $button, url );
}
}
);
return;
}

copyShareUrl( $button, url );
} );

function setupCarousel() {
var $root = $( this ),
$slides = $root.find( '.on-this-day-post' ),
$counter = $root.find( '.on-this-day-carousel-current' ),
current = Math.max( 0, $slides.index( $slides.filter( '.is-active' ) ) );

if ( $slides.length < 2 ) {
return;
}

function show( target ) {
current = ( ( target % $slides.length ) + $slides.length ) % $slides.length;

$slides
.removeClass( 'is-active' )
.attr( 'aria-hidden', 'true' )
.eq( current )
.addClass( 'is-active' )
.attr( 'aria-hidden', 'false' );
$counter.text( current + 1 );
}

$root.find( '.on-this-day-carousel-prev' ).on( 'click', function() {
show( current - 1 );
} );
$root.find( '.on-this-day-carousel-next' ).on( 'click', function() {
show( current + 1 );
} );

$root.on( 'keydown', function( event ) {
if ( 'ArrowLeft' === event.key ) {
show( current - 1 );
}

if ( 'ArrowRight' === event.key ) {
show( current + 1 );
}
} );

show( current );
}

$( '.on-this-day-carousel' ).each( setupCarousel );
}( jQuery ) );
Loading
Loading