File "functions.php"

Full Path: /home/ubunrgit/public_html/wp-content/themes/unicoach/functions.php
File size: 2.8 KB
MIME-type: text/x-php
Charset: utf-8

<?php

/**
 * Load Theme Dependencies
 */
require_once get_theme_file_path('/core/class/theme-dependencies.php');

/**
 * Sequence of theme specific actions
 */

add_action('after_setup_theme', function() {
    $content_width = $content_width ?? 940;
}, 0);

add_action('after_setup_theme', function() {
    add_theme_support('title-tag');
});

add_action('init', function() {
    add_post_type_support('page', 'excerpt');
});

/** Add a pingback url auto-discovery for single posts, pages or attachments. */
add_action('wp_head', function() {
    if (is_singular() && pings_open()) {
        echo '<link rel="pingback" href="', esc_url(get_bloginfo('pingback_url')), '">';
    }
});


/**
 * Sequence of theme specific filters
 */

add_filter('unicoach/header/enable', 'unicoach_header_enable');

add_filter('unicoach/page_title/enable', 'unicoach_page_title_enable');

add_filter('unicoach/footer/enable', 'unicoach_footer_enable');

add_action('unicoach/preloader', 'Unicoach_Theme_Helper::preloader');

add_action('unicoach/after_main_content', 'unicoach_after_main_content');

add_filter('comment_form_fields', 'unicoach_comment_form_fields');

add_filter('mce_buttons_2', function($buttons) {
	array_unshift($buttons, 'styleselect');
    return $buttons;
});

add_filter('tiny_mce_before_init', 'unicoach_tiny_mce_before_init');

add_action('current_screen', function() {
    add_editor_style('css/font-awesome-5.min.css');
});

add_filter('wp_list_categories', 'unicoach_categories_postcount_filter');
add_filter('woocommerce_layered_nav_term_html', 'unicoach_categories_postcount_filter');

add_filter('get_archives_link', 'unicoach_render_archive_widgets', 10, 6);

add_filter('unicoach/enqueue_shortcode_css', function($styles) {
    global $unicoach_dynamic_css;
    if (!isset($unicoach_dynamic_css['style'])) {
        $unicoach_dynamic_css = [];
        $unicoach_dynamic_css['style'] = $styles;
    } else {
        $unicoach_dynamic_css['style'] .= $styles;
    }
});

/* Add Custom Image Link field to media uploader for WGL Gallery module */
add_filter('attachment_fields_to_edit', function($form_fields, $post) {
    $form_fields['custom_image_link'] = array(
        'label' => esc_html__('Custom Image Link','unicoach'),
        'input' => 'text',
        'value' => get_post_meta($post->ID, 'custom_image_link', true),
        'helps' => esc_html__('This option works only for the WGL Gallery module.','unicoach'),
    );

    return $form_fields;
}, 10, 2);

/* Save values of Custom Image Link in media uploader */
add_filter('attachment_fields_to_save', function ($post, $attachment) {
    if (isset($attachment['custom_image_link']))
    update_post_meta($post['ID'], 'custom_image_link', $attachment['custom_image_link']);

    return $post;
}, 10, 2);