IIS Library
Documentation
Packages
Application
Namespaces
Internetstiftelsen
Table of Contents
iis_config()
: mixed
IIS Start config helper
iis_remember()
: mixed|null
Cache return value of callback if not already cached and return the contents
iis_safe_get_input()
: array<string|int, mixed>|string
Escape input recursively
iis_safe_get()
: null|string
Return a safe GET value with an optional default value.
iis_active_class()
: void
Echo an "active"-class if the comparison is true, otherwise
an empty string.
iis_active()
: bool|string|void
Echo a string if the comparison is true, otherwise empty string
iis_vite_dev_server_url()
: string
Get the URL to the Vite dev server
iis_vite_is_dev()
: bool
Check if the Vite dev server is running
iis_vite_manifest()
: array<string|int, mixed>|null
Get the Vite manifest
iis_vite_dev_script()
: void
Enqueue the Vite dev script
iis_enqueue_vite_asset()
: void
Enqueue a Vite asset
iis_enqueue_vite_script()
: void
Enqueue a Vite script
iis_enqueue_vite_style()
: void
Enqueue a Vite style
iis_vite()
: void
Enqueue the Vite assets
iis_mix_manifest()
: array<string|int, mixed>|null
Get the laravel mix manifest
iis_mix()
: string|null
Get the path to a versioned Mix file
iis_get_hero()
: array<string|int, mixed>|null
Get the content hero
iis_has_hero()
: bool
Checks if content starts with a hero
iis_has_full_hero()
: bool
Checks if content starts with a full-width hero
imns()
: void|string
Get and echo the styleguide namespace, set in .env-file of the theme
iis_uses_styleguide()
: bool
Check if theme is using the styleguide
iis_styleguide_sprite()
: void
Print IIS styleguide icon sprite
iis_word_count()
: false|int|null
Count number of words in string.
iis_get_reading_time()
: float
Get reading time for a string, in minutes.
iis_get_post_reading_time()
: float
Get reading time for a post, in minutes.
iis_get_images_reading_time()
: int
Calculate reading time for images in minutes.
iis_config()
IIS Start config helper
iis_config ( string $keys [ , mixed|null $fallback = null ] [ , string|null $directory = null ] ) : mixed
Parameters
$keys
: string
the key to get the value for. Use dot notation for going deeper.
$fallback
: mixed|null
= null
fallback if value is missing
$directory
: string|null
= null
The directory where the config file is located.
Return values
mixed
—
The value (if found) for the given key.
iis_remember()
Cache return value of callback if not already cached and return the contents
iis_remember ( string $cache_key , int $cache_time , callable $callback ) : mixed|null
Parameters
$cache_key
: string
The name of the cached content.
$cache_time
: int
How long the content should be cached.
$callback
: callable
The callback that returns the content that should be cached.
Return values
mixed|null
—
Escape input recursively
iis_safe_get_input ( mixed $input ) : array<string|int, mixed>|string
Parameters
$input
: mixed
Return values
array<string|int, mixed>|string
—
iis_safe_get()
Return a safe GET value with an optional default value.
iis_safe_get ( string $key [ , null|string $default = null ] ) : null|string
Parameters
$key
: string
The key for the $_GET array.
$default
: null|string
= null
Default value if GET variable doesn't exist.
Return values
null|string
—
iis_active_class()
Echo an "active"-class if the comparison is true, otherwise
an empty string.
iis_active_class ( string $value [ , string $compare_with = null ] [ , string $class = 'is-active' ] [ , bool $include_attr = true ] ) : void
Parameters
$value
: string
The value to compare against.
$compare_with
: string
= null
The value to compare with.
$class
: string
= 'is-active'
The class that should be echoed if true.
$include_attr
: bool
= true
True if class attribute should be included.
Return values
void
—
iis_active()
Echo a string if the comparison is true, otherwise empty string
iis_active ( string $value [ , string|array<string|int, mixed> $compare_with = null ] [ , string $attr = 'checked' ] [ , bool $echo = true ] ) : bool|string|void
Parameters
$value
: string
The value to compare against.
$compare_with
: string|array<string|int, mixed>
= null
The value to compare with.
$attr
: string
= 'checked'
The attribute that should be echoed if $echo is true.
$echo
: bool
= true
True if class attribute should be included.
Return values
bool|string|void
—
iis_vite_dev_server_url()
Get the URL to the Vite dev server
iis_vite_dev_server_url ( string $path ) : string
Parameters
$path
: string
Return values
string
—
iis_vite_is_dev()
Check if the Vite dev server is running
iis_vite_is_dev ( ) : bool
Return values
bool
—
iis_vite_manifest()
Get the Vite manifest
iis_vite_manifest ( ) : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null
—
iis_vite_dev_script()
Enqueue the Vite dev script
iis_vite_dev_script ( ) : void
Return values
void
—
iis_enqueue_vite_asset()
Enqueue a Vite asset
iis_enqueue_vite_asset ( string $handle , string $path [ , string $type = 'script' ] [ , array<string|int, mixed> $deps = [] ] [ , bool $in_footer = true ] ) : void
Parameters
$handle
: string
The handle for the script.
$path
: string
$type
: string
= 'script'
$deps
: array<string|int, mixed>
= []
$in_footer
: bool
= true
Whether to enqueue the script before
. Ignored for styles.
Return values
void
—
iis_enqueue_vite_script()
Enqueue a Vite script
iis_enqueue_vite_script ( string $handle , string $path [ , array<string|int, mixed> $deps = [] ] [ , bool $in_footer = true ] ) : void
Parameters
$handle
: string
The handle for the script.
$path
: string
$deps
: array<string|int, mixed>
= []
An array of registered script handles this script depends on.
$in_footer
: bool
= true
Whether to enqueue the script before .
Return values
void
—
iis_enqueue_vite_style()
Enqueue a Vite style
iis_enqueue_vite_style ( string $handle , string $path [ , array<string|int, mixed> $deps = [] ] ) : void
Parameters
$handle
: string
The handle for the style.
$path
: string
$deps
: array<string|int, mixed>
= []
An array of registered style handles this style depends on.
Return values
void
—
iis_vite()
Enqueue the Vite assets
iis_vite ( ) : void
Return values
void
—
iis_mix_manifest()
Get the laravel mix manifest
iis_mix_manifest ( [ string|null $directory = null ] ) : array<string|int, mixed>|null
Parameters
$directory
: string|null
= null
The directory where the mix manifest is located.
deprecated
Return values
array<string|int, mixed>|null
—
iis_mix()
Get the path to a versioned Mix file
iis_mix ( string $path [ , string $base = '/assets/' ] [ , string|null $manifest_directory = null ] ) : string|null
Parameters
$path
: string
$base
: string
= '/assets/'
$manifest_directory
: string|null
= null
The directory where the manifest is located.
deprecated
Return values
string|null
—
iis_get_hero()
Get the content hero
iis_get_hero ( [ int|null $post_id = null ] ) : array<string|int, mixed>|null
Parameters
$post_id
: int|null
= null
Return values
array<string|int, mixed>|null
—
iis_has_hero()
Checks if content starts with a hero
iis_has_hero ( [ int|null $post_id = null ] ) : bool
Parameters
$post_id
: int|null
= null
Return values
bool
—
iis_has_full_hero()
Checks if content starts with a full-width hero
iis_has_full_hero ( [ int|null $post_id = null ] ) : bool
Parameters
$post_id
: int|null
= null
Return values
bool
—
imns()
Get and echo the styleguide namespace, set in .env-file of the theme
imns ( string $class [ , bool $echo = true ] ) : void|string
Parameters
$class
: string
Class names, separated by space
$echo
: bool
= true
true for echo and false to return the string
Return values
void|string
—
iis_uses_styleguide()
Check if theme is using the styleguide
iis_uses_styleguide ( ) : bool
deprecated
Return values
bool
—
iis_styleguide_sprite()
Print IIS styleguide icon sprite
iis_styleguide_sprite ( ) : void
Return values
void
—
iis_word_count()
Count number of words in string.
iis_word_count ( $str ) : false|int|null
Multibyte version because str_word_count does not work with Swedish chars.
https://stackoverflow.com/questions/8290537/is-php-str-word-count-multibyte-safe
Parameters
$str
:
Return values
false|int|null
—
iis_get_reading_time()
Get reading time for a string, in minutes.
iis_get_reading_time ( string $html ) : float
Uses the calculation from https://blog.medium.com/read-time-and-you-bc2048ab620c.
Parameters
$html
: string
Return values
float
—
iis_get_post_reading_time()
Get reading time for a post, in minutes.
iis_get_post_reading_time ( WP_Post |object|int $post_id ) : float
Uses the calculation from https://blog.medium.com/read-time-and-you-bc2048ab620c.
Parameters
$post_id
: WP_Post |object|int
Return values
float
—
iis_get_images_reading_time()
Calculate reading time for images in minutes.
iis_get_images_reading_time ( int $total_images , int $wpm ) : int
Based on function from
https://github.com/yingles/reading-time-wp/blob/master/rt-reading-time.php
Parameters
$total_images
: int
number of images in post.
$wpm
: int
Return values
int
—
Additional time in minutes added to the reading time by images.