-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions-media-sets.php
62 lines (55 loc) · 1.39 KB
/
functions-media-sets.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Media set functionality.
*
* @package Respect_Art_Direction
*/
/**
* Register a media set.
*
* A media set is a list of breakpoints with source lists for that breakpoint.
*
* Example:
*
* array(
* 'breakpoint-name-1' => array(
* 'source_list_1',
* ),
* 'breakpoint-name-2' => array(
* 'source_list_1',
* 'source_list_2',
* )
* )
*
* @param string $name Name of the media set.
* @param array $breakpoints An array of source lists for registered breakpoints.
*/
function rad_add_media_set( $name, $breakpoints ) {
global $rad_media_sets;
$rad_media_sets[ $name ] = $breakpoints;
}
/**
* Adds a breakpoint to a media set with the specified source list.
*
* @param string $name Media set name.
* @param string $breakpoint Breakpoint name.
* @param string}array $source_list Source list name.
*/
function rad_add_breakpoint_to_media_set( $name, $breakpoint, $source_list ) {
global $rad_media_sets;
if ( ! isset( $rad_media_sets ) ) {
$rad_media_sets = array();
}
$rad_media_sets[ $name ][ $breakpoint ][] = $source_list;
}
/**
* Checks if a media list is registered.
*
* @param string $media_list_name Image size name to check.
*
* @return bool Whether the list name is a registered media list.
*/
function rad_image_size_is_media_set( $media_list_name ) {
global $rad_media_sets;
return isset( $rad_media_sets[ $media_list_name ] );
}