id ) ) { $setting = $setting->id; } $options = themeoo_get_choices( $setting ); if ( ! in_array( $value, array_keys( $options ) ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict $value = themeoo_get_default( $setting ); } return $value; } endif; if ( ! function_exists( 'themeoo_sanitize_font_family' ) ) : /** * Sanitize function for WP_Customize setting to sanitize Font Family. * * @param string $value font_family. * @param string|object $setting font_family mod name. * * @return string */ function themeoo_sanitize_font_family( $value, $setting ) { if ( is_object( $setting ) && isset( $setting->id ) ) { $setting = $setting->id; } if ( ! is_string( $value ) || '' === $value ) { return ''; } elseif ( ! in_array( $value, array_keys( themeoo_get_all_fonts( false ) ) ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict $value = themeoo_get_default( $setting ); } return $value; } endif; if ( ! function_exists( 'themeoo_sanitize_font_variant' ) ) : /** * Sanitize function for WP_Customize setting to sanitize Font Family Variant. * * @param string $value Font Variant. * * @return string */ function themeoo_sanitize_font_variant( $value ) { $options = [ '100', '100italic', '200', '200italic', '300', '300italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic', 'italic', 'regular', 'thin', 'thin-italic', 'bold', 'bold-italic', 'medium', 'medium-italic', 'extra-light', 'extra-light-italic', 'light', 'light-italic', 'serif', 'serif-italic', ]; if ( ! is_string( $value ) || '' === $value ) { return 'regular'; } elseif ( in_array( $value, $options, true ) ) { return $value; } return 'regular'; } endif; if ( ! function_exists( 'themeoo_sanitize_font_variant_array' ) ) { function themeoo_sanitize_font_variant_array( $variants = [] ) { if ( ! is_array( $variants ) ) { return themeoo_sanitize_font_variant( $variants ); } foreach ( $variants as &$variant ) { $variant = themeoo_sanitize_font_variant( $variant ); } return $variants; } } if ( ! function_exists( 'themeoo_sanitize_font_text_transform' ) ) : /** * Sanitize function for WP_Customize setting to sanitize Font Text Transform. * * @param string $value Text transform. * * @return string */ function themeoo_sanitize_font_text_transform( $value ) { $options = [ 'none', 'uppercase', 'lowercase' ]; if ( ! is_string( $value ) || '' === $value ) { return 'none'; } elseif ( in_array( $value, $options, true ) ) { return $value; } return 'none'; } endif; if ( ! function_exists( 'themeoo_sanitize_font_subsets' ) ) : /** * Sanitize function for WP_Customize setting to sanitize Font Subsets. * * @param string|string[] $values Font subsets. * * @return string[] */ function themeoo_sanitize_font_subsets( $values ) { $multi_values = ! is_array( $values ) ? explode( ',', $values ) : $values; return ! empty( $multi_values ) ? array_map( 'sanitize_text_field', $multi_values ) : []; } endif; if ( ! function_exists( 'themeoo_get_color_mods' ) ) : /** * Determine if a mod is a color mod * * @param string $mod mod name. * * @return bool */ function themeoo_get_color_mods( $mod ) { return 0 === strpos( $mod, 'colors_' ); } endif; if ( ! function_exists( 'themeoo_get_font_mods' ) ) : /** * Determine if a mod is a typography mod * * @param string $mod mod name. * * @return bool */ function themeoo_get_font_mods( $mod ) { return 0 === strpos( $mod, 'typography_' ); } endif; if ( ! function_exists( 'themeoo_is_font_family' ) ) : /** * Checks if a given mod is Font Family * * @param string $mod mod name. * * @return bool */ function themeoo_is_font_family( $mod ) { return themeoo_string_ends_with( $mod, 'font_family' ) || themeoo_string_ends_with( $mod, 'font_variant' ); } endif; if ( ! function_exists( 'themeoo_string_ends_with' ) ) : /** * Determine if a string ends with a particulr value * * @param string $whole the full string. * @param string $end part to check. * * @return bool */ function themeoo_string_ends_with( $whole, $end ) { return strpos( $whole, $end ) !== false && strpos( $whole, $end, strlen( $whole ) - strlen( $end ) ) !== false; } endif; if ( ! function_exists( 'themeoo_font_settings' ) ) : /** * Prints the Font styles for a given section * * @param string $section mod section id. * * @return void CSS Font styles. */ function themeoo_font_settings( $section ) { $global_line_height = themeoo_get_mod( 'typography_global_line_height' ); if ( ! $global_line_height ) { $global_line_height = 1.5; } $line_height = ! themeoo_get_mod( $section . '_line_height' ) ? $global_line_height : themeoo_get_mod( $section . '_line_height' ); $font_variant = themeoo_get_mod( $section . '_font_variant' ); $font_weight = 'regular' === $font_variant ? 'normal' : preg_replace( '/[^0-9]/', '', $font_variant ); ?> font: ; font-weight: ; font-style: ; text-transform: ; letter-spacing: px; word-spacing: px; '', 'url' => '', 'icon' => '', ] ); $profile = [ 'label' => sanitize_text_field( $args['label'] ), 'url' => esc_url_raw( $args['url'] ), 'icon' => sanitize_text_field( $args['icon'] ), ]; if ( $profile['label'] && $profile['url'] && $profile['icon'] ) { return $profile; } return false; } } /** * Determines whether a plugin is active. * * @param string $plugin Path to the plugin file relative to the plugins directory. * @return bool True, if in the active plugins list. False, not in the list. */ function themeoo_is_plugin_active( $plugin ) { if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) ) { return true; } if ( ! is_multisite() ) { return false; } $plugins = get_site_option( 'active_sitewide_plugins' ); if ( isset( $plugins[ $plugin ] ) ) { return true; } return false; }