wpseek.com
A WordPress-centric search engine for devs and theme authors
get_theme_mod › WordPress Function
Since2.1.0
Deprecatedn/a
› get_theme_mod ( $name, $default = false )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
Retrieves theme modification value for the current theme.
If the modification name does not exist, then the $default will be passed through {@link sprintf()} PHP function with the template directory URI as the first string and the stylesheet directory URI as the second string.Source
function get_theme_mod( $name, $default = false ) { $mods = get_theme_mods(); if ( isset( $mods[ $name ] ) ) { /** * Filters the theme modification, or 'theme_mod', value. * * The dynamic portion of the hook name, `$name`, refers to the key name * of the modification array. For example, 'header_textcolor', 'header_image', * and so on depending on the theme options. * * @since 2.2.0 * * @param string $current_mod The value of the current theme modification. */ return apply_filters( "theme_mod_{$name}", $mods[ $name ] ); } if ( is_string( $default ) ) { // Only run the replacement if an sprintf() string format pattern was found. if ( preg_match( '#(?<!%)%(?:\d+\$?)?s#', $default ) ) { // Remove a single trailing percent sign. $default = preg_replace( '#(?<!%)%$#', '', $default ); $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); } } /** This filter is documented in wp-includes/theme.php */ return apply_filters( "theme_mod_{$name}", $default ); }