MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: machen (1008)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /disk001/machen/www/support/wp-content/themes/wp-moose/inc/universal/helpers.php
<?php

if ( ! function_exists( 'wp_moose_hex_to_rgb' ) ) {
	/**
	 * Convert hex color to rgb color
	 *
	 * @param $hex
	 *
	 * @return array|null
	 */
	function wp_moose_hex_to_rgb( $hex ) {
		return sscanf( $hex, "#%02x%02x%02x" );
	}
}

if ( ! function_exists( 'wp_moose_rgb_to_hex' ) ) {
	/**
	 * Convert rgb value to hex color
	 *
	 * @param $r
	 * @param $g
	 * @param $b
	 *
	 * @return string
	 */
	function wp_moose_rgb_to_hex( $r, $g, $b ) {
		return sprintf( "#%02x%02x%02x", $r, $g, $b );
	}
}

if ( ! function_exists( 'wp_moose_array_replace' ) ) {
	/**
	 * Find and replace an item in array
	 *
	 * @param $arr
	 * @param $find
	 * @param $replacement
	 *
	 * @return array
	 */
	function wp_moose_array_replace( $arr, $find, $replacement ) {
		return array_map( function ( $item ) use ( $find, $replacement ) {
			if ( $item === $find ) {
				return $replacement;
			}

			return $item;
		}, $arr );
	}
}

if ( ! function_exists( 'wp_moose_get_prop' ) ) {

	/**
	 * Get a specific property of an array without needing to check if that property exists.
	 */
	function wp_moose_get_prop( $array, $prop, $default = null ) {

		if ( ! is_array( $array ) && ! ( is_object( $array ) && $array instanceof ArrayAccess ) ) {
			return $default;
		}

		if ( isset( $array[ $prop ] ) ) {
			$value = $array[ $prop ];
		} else {
			$value = '';
		}

		return empty( $value ) && null !== $default ? $default : $value;
	}
}

if ( ! function_exists( 'wp_moose_customizer_url' ) ) {
	/**
	 * Get customizer url with autofocus
	 *
	 * @param $type
	 * @param $id
	 *
	 * @return string
	 */
	function wp_moose_customizer_url( $type, $id ) {
		$query                               = array();
		$query[ 'autofocus[' . $type . ']' ] = $id;

		return add_query_arg( $query, admin_url( 'customize.php' ) );
	}
}

if ( ! function_exists( 'wp_moose_array_pluck' ) ) {
	/**
	 * Just like array_pluck function in laravel
	 *
	 * @param $key
	 * @param $arr
	 *
	 * @return array
	 */
	function wp_moose_array_pluck( $key, $arr ) {
		return array_map( function ( $item ) use ( $key ) {
			return $item[ $key ];
		}, $arr );
	}
}

if ( ! function_exists( 'wp_moose_parse_css' ) ) {
	/**
	 * Parse CSS
	 *
	 * @param array $css_output Array of CSS.
	 * @param string $min_media Min Media breakpoint.
	 * @param string $max_media Max Media breakpoint.
	 *
	 * @return string             Generated CSS.
	 */
	function wp_moose_parse_css( $css_output = array(), $min_media = '', $max_media = '' ) {

		$parse_css = '';
		if ( is_array( $css_output ) && count( $css_output ) > 0 ) {

			foreach ( $css_output as $selector => $properties ) {

				if ( null === $properties ) {
					break;
				}

				if ( ! count( $properties ) ) {
					continue;
				}

				$temp_parse_css   = $selector . '{';
				$properties_added = 0;

				foreach ( $properties as $property => $value ) {

					if ( '' === $value ) {
						continue;
					}

					$properties_added ++;
					$temp_parse_css .= $property . ':' . $value . ';';
				}

				$temp_parse_css .= '}';

				if ( $properties_added > 0 ) {
					$parse_css .= $temp_parse_css;
				}
			}

			if ( '' != $parse_css && ( '' !== $min_media || '' !== $max_media ) ) {

				$media_css       = '@media ';
				$min_media_css   = '';
				$max_media_css   = '';
				$media_separator = '';

				if ( '' !== $min_media ) {
					$min_media_css = '(min-width:' . $min_media . 'px)';
				}
				if ( '' !== $max_media ) {
					$max_media_css = '(max-width:' . $max_media . 'px)';
				}
				if ( '' !== $min_media && '' !== $max_media ) {
					$media_separator = ' and ';
				}

				$media_css .= $min_media_css . $media_separator . $max_media_css . '{' . $parse_css . '}';

				return $media_css;
			}
		}

		return $parse_css;
	}
}