PageSourceSearch

https://www.vinylchapters.com/wp-content/themes/magazine-pro/js/move-entry-dates.js?ver=1.1.0

js vinylchapters.com collected 2026-10-02 08:39:55 UTC 1,811 bytes, 81 lines download raw bytes

1/**
2 * Moves Atomic Blocks Post Grid dates inside featured images.
3 *
4 * @package StudioPress\JS
5 * @author StudioPress
6 * @license GPL-2.0-or-later
7 */
8
9( function() {
10	'use strict';
11
12	/**
13	 * Moves the Atomic Blocks Post Grid date element into the featured image.
14	 *
15	 * The desired styling can not be achieved without moving the element.
16	 *
17	 * @since 3.4.0
18	 */
19	function moveDates() {
20		var i, $date, $imageLink;
21		var $articles = document.querySelectorAll( '.ab-block-post-grid .is-grid article' );
22
23		for ( i = 0; i < $articles.length; ++i ) {
24			$date = $articles[i].querySelector( '.ab-block-post-grid-date' );
25			$imageLink = $articles[i].querySelector( '.ab-block-post-grid-image a' );
26
27			if ( $date && $imageLink ) {
28				$imageLink.appendChild( $date );
29			}
30		}
31	}
32
33	/**
34	 * Tests if the given block list contains an Atomic Blocks Post Grid block.
35	 *
36	 * @param {array} blockList
37	 *
38	 * @since 3.4.0
39	 */
40	function blocksIncludeAtomicBlocksPostGrid( blockList ) {
41		return blockList.some(
42			function( block ) {
43				return 'atomic-blocks/ab-post-grid' === block.name;
44			}
45		);
46	}
47
48	/**
49	 * Tests all required JavaScript libraries have loaded in the block editor.
50	 *
51	 * Also helps to exit early on the front end.
52	 *
53	 * @since 3.4.0
54	 */
55	function blockEditorReady() {
56		return 'undefined' !== typeof wp &&
57				'undefined' !== typeof wp.blocks &&
58				'undefined' !== typeof wp.data;
59	}
60
61	/**
62	 * Triggers date move in admin if Atomic Blocks Post Grid block 
62is in use.
63	 *
64	 * @since 3.4.0
65	 */
66	function initAdmin() {
67		if ( ! blockEditorReady() ) {
68			return;
69		}
70
71		wp.data.subscribe( function() {
72			var blockList = wp.data.select( 'core/editor' ).getBlocks();
73			if ( blocksIncludeAtomicBlocksPostGrid( blockList ) ) {
74				moveDates();
75			}
76		});
77	}
78
79	moveDates();
80	initAdmin();
81}() );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.