desrosj/respect-art-direction

View on GitHub
functions-media-sets.php

Summary

Maintainability
A
0 mins
Test Coverage
<?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(
Spaces must be used for mid-line alignment; tabs are not allowed
* 'breakpoint-name-1' => array(
Spaces must be used for mid-line alignment; tabs are not allowed
* 'source_list_1',
Spaces must be used for mid-line alignment; tabs are not allowed
* ),
Spaces must be used for mid-line alignment; tabs are not allowed
* 'breakpoint-name-2' => array(
Spaces must be used for mid-line alignment; tabs are not allowed
* 'source_list_1',
Spaces must be used for mid-line alignment; tabs are not allowed
* 'source_list_2',
Spaces must be used for mid-line alignment; tabs are not allowed
* )
* )
*
* @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.
*
Expected 7 spaces after parameter type; 1 found
* @param string $name Media set name.
Expected 7 spaces after parameter type; 1 found
* @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 ] );
}