widgets['Simple_Social_Icons_Widget'], 'css' ) );
}
}
add_action( 'wp_head', 'corporate_simple_social_icons_css' );
/**
* Simple Social Icons multiple instances workaround.
*
* By default, Simple Social Icons only allows you to create one style for your
* icons, even if you have multiple on the same page. This function allows us
* to have different styles for each widget that is output on the frontend.
*
* @since 1.0.0
*
* @return void
*/
function corporate_simple_social_icons_css() {
if ( ! class_exists( 'Simple_Social_Icons_Widget' ) ) {
return;
}
$obj = new Simple_Social_Icons_Widget();
// Get widget settings.
$all_instances = $obj->get_settings();
// Loop through instances.
foreach ( $all_instances as $key => $options ) :
$instance = wp_parse_args( $all_instances[ $key ] );
$font_size = round( (int) $instance['size'] / 2 );
$icon_padding = round( (int) $font_size / 2 );
// CSS to output.
$css = '#' . $obj->id_base . '-' . $key . ' ul li a,
#' . $obj->id_base . '-' . $key . ' ul li a:hover {
background-color: ' . $instance['background_color'] . ';
border-radius: ' . $instance['border_radius'] . 'px;
color: ' . $instance['icon_color'] . ';
border: ' . $instance['border_width'] . 'px ' . $instance['border_color'] . ' solid;
font-size: ' . $font_size . 'px;
padding: ' . $icon_padding . 'px;
}
#' . $obj->id_base . '-' . $key . ' ul li a:hover,
#' . $obj->id_base . '-' . $key . ' ul li a:focus {
background-color: ' . $instance['background_color_hover'] . ';
border-color: ' . $instance['border_color_hover'] . ';
color: ' . $instance['icon_color_hover'] . ';
}';
// Minify.
$css = corporate_minify_css( $css );
// Output.
printf( '', $css );
endforeach;
}
add_action( 'init', 'corporate_structural_wrap_hooks' );
/**
* Add hooks before and after Genesis structural wraps.
*
* This is a clever workaround that allows us to insert HTML between a container
* and its immediate descendant .wrap element. These hooks are used to display
* the Before Header widget area, the Secondary Nav and the Footer Widgets.
*
* @since 1.0.0
*
* @author Tim Jensen
* @link https://timjensen.us/add-hooks-before-genesis-structural-wraps
*
* @return void
*/
function corporate_structural_wrap_hooks() {
$wraps = get_theme_support( 'genesis-structural-wraps' );
foreach ( $wraps[0] as $context ) {
/**
* Inserts an action hook before the opening div and after the closing div
* for each of the structural wraps.
*
* @param string $output HTML for opening or closing the structural wrap.
* @param string $original Either 'open' or 'close'.
*
* @return string
*/
add_filter( "genesis_structural_wrap-{$context}", function ( $output, $original ) use ( $context ) {
$position = ( 'open' === $original ) ? 'before' : 'after';
ob_start();
do_action( "genesis_{$position}_{$context}_wrap" );
if ( 'open' === $original ) {
return ob_get_clean() . $output;
} else {
return $output . ob_get_clean();
}
}, 10, 2 );
}
}
add_filter( 'http_request_args', 'corporate_dont_update_theme', 5, 2 );
/**
* Prevent automatic theme updates.
*
* Because WordPress (the software) doesn’t know whether a theme or plugin is
* listed in the WordPress.org repositories, it has to check them all, and
* let the repository sort it out. If there is a theme in the repo with
* the same name this prevents WP from prompting an automatic update.
*
* @since 1.0.0
*
* @link https://markjaquith.wordpress.com/2009/12/14/excluding-your-plugin-or-theme-from-update-checks/
* @param array $request Request arguments.
* @param string $url Request url.
*
* @return array request arguments
*/
function corporate_dont_update_theme( $request, $url ) {
// Not a theme update request. Bail immediately.
if ( 0 !== strpos( $url, 'http://api.wordpress.org/themes/update-check' ) ) {
return $request;
}
$themes = unserialize( $request['body']['themes'] );
unset( $themes[ get_option( 'template' ) ] );
unset( $themes[ get_option( 'stylesheet' ) ] );
$request['body']['themes'] = serialize( $themes );
return $request;
}
add_filter( 'agm_custom_styles', 'corporate_map_styles' );
/**
* Custom Google map style (Ultra Light).
*
* Adds a custom Google map style to the Google Map plugin used in the theme demo.
* The JSON file used in this function can be found in the top level directory
* of the theme. More information can be found by following the links below.
*
* @since 1.0.0
*
* @link https://github.com/ankurk91/wp-google-map/wiki/How-to-add-your-own-styles
* @link https://snazzymaps.com/style/85413/cartagena
* @param array $json Array of JSON data.
*
* @return array
*/
function corporate_map_styles( $json ) {
array_push( $json, array(
'id' => '123456789',
'name' => 'Ultra Light',
'style' => json_decode( file_get_contents( CHILD_THEME_DIR . '/map.json' ), true ),
) );
return $json;
}
add_filter( 'genesis_markup_title-area_close', 'corporate_after_title_area', 10, 2 );
/**
* Appends HTML to the closing markup for .title-area.
*
* Adding something between the title + description and widget area used to require
* re-building genesis_do_header(). However, since the title-area closing markup
* now goes through genesis_markup(), it means we now have some extra filters
* to play with. This function makes use of this and adds in an extra hook
* after the title-area used for displaying the primary navigation menu.
*
* @since 1.0.0
*
* @param string $close_html HTML tag being processed by the API.
* @param array $args Array with markup arguments.
*
* @return string
*/
function corporate_after_title_area( $close_html, $args ) {
if ( $close_html ) {
ob_start();
do_action( 'genesis_after_title_area' );
$close_html = $close_html . ob_get_clean();
}
return $close_html;
}
//add_filter( 'display_posts_shortcode_output', 'corporate_remove_listing_link', 20 );
/**
* Remove redundant link from listing item.
*
* By default, the Display Posts Shortcode outputs Adjacent links go to the same URL.
* When adjacent links go to the same location (such as a linked product image and
* an adjacent linked product name that go to the same product page) this results
* in additional navigation and repetition for keyboard and screen reader users.
* To meet 508 compliance and WCAG, we need to remove these redundant links.
*
* @since 1.0.0
*
* @link https://webaim.org/standards/wcag/checklist#sc2.4.4
* @param string $output Display posts output.
*
* @return string
*/
function corporate_remove_listing_link( $output ) {
$output = str_replace( '', '', $output );
return $output;
}
add_action( 'genesis_entry_header', 'corporate_reposition_post_meta', 0 );
/**
* Reposition post info and remove excerpts on archives.
*
* Small customization to reposition the post info and remove the excerpt links
* on all archive pages including search results, blog page, categories etc.
*
* @since 1.0.0
*
* @return void
*/
function corporate_reposition_post_meta() {
if ( is_archive() || is_home() || is_search() || is_post_type_archive() ) {
// Reposition post meta.
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
add_action( 'genesis_entry_header', 'genesis_post_info', 1 );
// Remove read more link on archives.
add_filter( 'get_the_content_more_link', '__return_empty_string' );
}
}
add_filter( 'genesis_post_info', 'corporate_post_info_date' );
/**
* Change the default post info on archives.
*
* Replaces the default post info (author, comments, edit link) with just the
* date of the post, which is then repositioned above the entry title with
* the corporate_reposition_post_meta() function above on archive pages.
*
* @since 1.0.0
*
* @param string $post_info The default post information.
*
* @return string
*/
function corporate_post_info_date( $post_info ) {
if ( is_archive() || is_home() || is_search() || is_post_type_archive() ) {
$post_info = '[post_date]';
}
global $post;
$EM_Event = em_get_event($post->ID, 'post_id');
$location = $EM_Event->output('#_LOCATIONTOWN');
if (is_post_type_archive('event')) {
$post_info = '[field _event_start_date date_format="d/m/Y"]';
$post_info .= ' - '.$location;
}
return $post_info;
}
add_filter( 'genesis_post_meta', 'corporate_post_meta_filter' );
/**
* Customize the entry meta in the entry footer.
*
* This function filters the genesis post meta to display SVG icons before the
* post categories and post tags on archive pages including the search page,
* blog, category and tag pages. SVG images are included with the theme.
*
* @since 1.0.0
*
* @param string $post_meta Default post meta.
*
* @return string
*/
function corporate_post_meta_filter( $post_meta ) {
if ( is_archive() || is_home() || is_search() || ! is_post_type_archive() ) {
$cat_alt = apply_filters( 'corporate_cat_alt', __( 'Category icon', 'yeuchaybo' ) );
$tag_alt = apply_filters( 'corporate_tag_alt', __( 'Tag icon', 'yeuchaybo' ) );
$cat_img = '';
$tag_img = '
';
$post_meta = '[post_categories before="' . $cat_img . '" sep=", "] [post_tags before="' . $tag_img . '" sep=", "]';
}
return $post_meta;
}
add_filter( 'genesis_attr_site-container', 'corporate_primary_nav_id' );
/**
* Add ID attribute to site-container.
*
* This adds an ID attribute to the site-container by filtering the element
* attributes so that the "Return to Top" link has something to link to.
*
* @since 1.0.0
*
* @param array $atts Navigation attributes.
*
* @return array
*/
function corporate_primary_nav_id( $atts ) {
$atts['id'] = 'top';
return $atts;
}
add_shortcode( 'footer_backtotop', 'corporate_footer_backtotop_shortcode' );
/**
* Produces the "Return to Top" link.
*
* Supported shortcode attributes are:
* - after (output after link, default is empty string),
* - before (output before link, default is empty string),
* - href (link url, default is fragment identifier '#wrap'),
* - nofollow (boolean for whether to include rel="nofollow", default is true),
* - text (Link text, default is 'Return to top of page').
*
* Output passes through `corporate_footer_backtotop_shortcode` filter before returning.
*
* @since 1.0.0
*
* @param array|string $atts Shortcode attributes. Empty string if no attributes.
*
* @return string Output for `footer_backtotop` shortcode.
*/
function corporate_footer_backtotop_shortcode( $atts ) {
$defaults = array(
'after' => '',
'before' => '',
'href' => '#top',
'nofollow' => true,
'text' => __( 'Return to top', 'genesis' ),
);
$atts = shortcode_atts( $defaults, $atts, 'footer_backtotop' );
$nofollow = $atts['nofollow'] ? 'rel="nofollow"' : '';
$output = sprintf( '%s%s%s', $atts['before'], esc_url( $atts['href'] ), $nofollow, $atts['text'], $atts['after'] );
return apply_filters( 'corporate_footer_backtotop_shortcode', $output, $atts );
}
add_filter( 'genesis_site_layout', 'corporate_search_and_404_page_layouts' );
/**
* Gets a custom page layout for the search results page.
*
* @since 1.0.0
*
* @return string
*/
function corporate_search_and_404_page_layouts() {
if ( is_search() ) {
$page = get_page_by_path( 'search' );
$field = genesis_get_custom_field( '_genesis_layout', $page->ID );
$layout = $field ? $field : genesis_get_option( 'site_layout' );
return $layout;
}
if ( is_404() ) {
$page = get_page_by_path( 'error-404' );
$field = genesis_get_custom_field( '_genesis_layout', $page->ID );
$layout = $field ? $field : genesis_get_option( 'site_layout' );
return $layout;
}
}