Skip to content

Commit

Permalink
Adds formay_date, get_the_logo_url , Updates get_the_logo
Browse files Browse the repository at this point in the history
  • Loading branch information
adampatterson committed Jan 9, 2022
1 parent e4f9e72 commit 5331e36
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Theme Helpers
*****************************************/

use Carbon\Carbon;
use Illuminate\Support\Arr;

if ( ! function_exists('__t')) {
Expand Down Expand Up @@ -413,16 +414,18 @@ function show_woo_single_product()
* @param bool $include_link
* @param string $custom_logo_css
* @param string $custom_link_css
* @param string $size
*
* @return bool|string
*
* Returns an HTML link including the logo, Or just the path the the logo image.
*/
function get_the_logo($include_link = false,
$custom_logo_css = 'site-logo custom-logo img-fluid',
$custom_link_css = 'logo custom-logo-link'
$custom_link_css = 'logo custom-logo-link',
$size = 'full'
) {
$logo = wp_get_attachment_image(get_theme_mod('custom_logo'), 'full', false, ['class' => $custom_logo_css]);
$logo = wp_get_attachment_image(get_theme_mod('custom_logo'), $size, false, ['class' => $custom_logo_css]);

if ( ! $logo) {
return false;
Expand All @@ -438,6 +441,27 @@ function get_the_logo($include_link = false,
}
}


if ( ! function_exists('get_the_logo_url')) {
/**
* @param string $size
*
* @return bool|string
*
* Returns the site lgoo image path.
*/
function get_the_logo_url($size)
{
$logo = wp_get_attachment_image_url(get_theme_mod('custom_logo'), $size, false);

if ( ! $logo) {
return false;
}

return $logo;
}
}

if ( ! function_exists('if_custom_logo')) {
/**
* @return bool
Expand Down Expand Up @@ -521,6 +545,24 @@ function make_slug($string)
}
}

if ( ! function_exists('format_date')) {
/**
* @param $date
* @param bool $format
*
* @return string
*/
function format_date($date, $format = false)
{
$timezone = get_option('timezone_string');
if ( ! $format) {
return Carbon::parse($format, $timezone)->toFormattedDateString();
}

return Carbon::parse($date, $timezone)->format($format);
}
}

/*
* Helpers for working with ACF data objects
*/
Expand Down

0 comments on commit 5331e36

Please sign in to comment.