oreach ($wp_registered_sidebars as $sidebar_id => $sidebar) :
$out[$sidebar_id] = $sidebar['name'];
endforeach;
return $out;
}
}
if (!function_exists('reuss_get_custom_menu')) {
function reuss_get_custom_menu()
{
$taxonomies = [];
$menus = get_terms('nav_menu');
foreach ($menus as $value) {
$taxonomies[$value->name] = $value->name;
}
return $taxonomies;
}
}
function reuss_get_attachment($attachment_id)
{
$attachment = get_post($attachment_id);
return [
'alt' => get_post_meta($attachment->ID, '_wp_attachment_image_alt', true),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink($attachment->ID),
'src' => $attachment->guid,
'title' => $attachment->post_title
];
}
if (!function_exists('reuss_reorder_comment_fields')) {
function reuss_reorder_comment_fields($fields)
{
$new_fields = [];
$myorder = ['author', 'email', 'url', 'comment'];
foreach ($myorder as $key) {
$new_fields[$key] = isset($fields[$key]) ? $fields[$key] : '';
unset($fields[$key]);
}
if ($fields) {
foreach ($fields as $key => $val) {
$new_fields[$key] = $val;
}
}
return $new_fields;
}
}
add_filter('comment_form_fields', 'reuss_reorder_comment_fields');
function reuss_mce_buttons_2($buttons)
{
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'reuss_mce_buttons_2');
if (!function_exists('reuss_header_enable')) {
function reuss_header_enable() {
$header_switch = Reuss_Theme_Helper::get_option('header_switch');
if(empty($header_switch)) return false;
$id = !is_archive() && !is_search() && !is_404() ? get_queried_object_id() : 0;
// Don't render header if in metabox set to hide it.
if (
class_exists('RWMB_Loader')
&& $id !== 0
&& rwmb_meta('mb_customize_header_layout') == 'hide'
) {
return false;
}
//hide if 404 page
$page_not_found = Reuss_Theme_Helper::get_option('404_show_header');
$layout_template = Reuss_Theme_Helper::get_option('404_page_type');
if (is_404() && (!(bool) $page_not_found || $layout_template === 'custom')) return;
return true;
}
}
add_filter('reuss_header_enable', 'reuss_header_enable');
if (!function_exists('reuss_page_title_enable')) {
function reuss_page_title_enable()
{
$id = !is_archive() && !is_search() && !is_404() ? get_queried_object_id() : 0;
$output['mb_page_title_switch'] = '';
if (is_404()) {
$layout_template = Reuss_Theme_Helper::get_option('404_page_type');
if($layout_template === 'default'){
$output['page_title_switch'] = Reuss_Theme_Helper::get_option('404_page_title_switcher') ? 'on' : 'off';
}else{
$output['page_title_switch'] = 'off';
}
} else {
$output['page_title_switch'] = Reuss_Theme_Helper::get_option('page_title_switch') ? 'on' : 'off';
if (class_exists('RWMB_Loader') && $id !== 0) {
$output['mb_page_title_switch'] = rwmb_meta('mb_page_title_switch');
}
}
$output['single'] = ['type' => '', 'layout' => ''];
/**
* Check the Post Type
*
* Aimed to prevent Page Title rendering for the following pages:
* - blog single type 3;
*
* @since 1.0.0
*/
if (
get_post_type($id) == 'post'
&& is_single()
) {
$output['single']['type'] = 'post';
$output['single']['layout'] = Reuss_Theme_Helper::options_compare('single_type_layout', 'mb_post_layout_conditional', 'custom');
if ($output['single']['layout'] === '3') {
$output['page_title_switch'] = 'off';
}
}
if (isset($output['mb_page_title_switch']) && $output['mb_page_title_switch'] == 'on') {
$output['page_title_switch'] = 'on';
}
if (
is_home()
|| is_front_page()
|| isset($output['mb_page_title_switch']) && $output['mb_page_title_switch'] == 'off'
) {
$output['page_title_switch'] = 'off';
}
return $output;
}
}
add_filter('reuss_page_title_enable', 'reuss_page_title_enable');
if (!function_exists('reuss_footer_enable')) {
function reuss_footer_enable()
{
$output = [];
$output['footer_switch'] = Reuss_Theme_Helper::get_option('footer_switch');
$output['copyright_switch'] = Reuss_Theme_Helper::get_option('copyright_switch');
if (class_exists('RWMB_Loader') && get_queried_object_id() !== 0) {
$output['mb_footer_switch'] = rwmb_meta('mb_footer_switch');
$output['mb_copyright_switch'] = rwmb_meta('mb_copyright_switch');
if ($output['mb_footer_switch'] == 'on') {
$output['footer_switch'] = true;
} elseif ($output['mb_footer_switch'] == 'off') {
$output['footer_switch'] = false;
}
if ($output['mb_copyright_switch'] == 'on') {
$output['copyright_switch'] = true;
} elseif ($output['mb_copyright_switch'] == 'off') {
$output['copyright_switch'] = false;
}
}
// Hide on 404 page
$page_not_found = Reuss_Theme_Helper::get_option('404_show_footer');
$layout_template = Reuss_Theme_Helper::get_option('404_page_type');
if (is_404() && (!$page_not_found || $layout_template === 'custom')) $output['footer_switch'] = $output['copyright_switch'] = false;
return $output;
}
}
add_filter('reuss_footer_enable', 'reuss_footer_enable');
add_action('reuss_preloader', 'Reuss_Theme_Helper::preloader');
if (!function_exists('reuss_after_main_content')) {
function reuss_after_main_content()
{
global $reuss_dynamic_css;
$scroll_up = Reuss_Theme_Helper::get_option('scroll_up');
// Scroll Up Button
if ($scroll_up) {
echo '';
}
// Dynamic Styles
if (!empty($reuss_dynamic_css['style'])) {
echo '';
}
}
}
add_action('reuss_after_main_content', 'reuss_after_main_content');
function reuss_tiny_mce_before_init($settings)
{
$settings['theme_advanced_blockformats'] = 'p,h1,h2,h3,h4';
$h_font_color = Reuss_Theme_Helper::get_option('header-font')['color'];
$primary_color = Reuss_Theme_Helper::get_option('theme-primary-color');
$style_formats = [
[
'title' => esc_html__('Dropcap', 'reuss'),
'items' => [
[
'title' => esc_html__('Primary Text Color', 'reuss'),
'inline' => 'span',
'classes' => 'dropcap primary',
], [
'title' => esc_html__('Secondary Text Color', 'reuss'),
'inline' => 'span',
'classes' => 'dropcap secondary',
], [
'title' => esc_html__('Primary Background Color', 'reuss'),
'inline' => 'span',
'classes' => 'dropcap-bg primary',
], [
'title' => esc_html__('Secondary Background Color', 'reuss'),
'inline' => 'span',
'classes' => 'dropcap-bg secondary',
],
],
],
[
'title' => esc_html__('Highlighter', 'reuss'),
'items' => [
[
'title' => esc_html__('Primary Color', 'reuss'),
'inline' => 'span',
'classes' => 'highlighter primary',
], [
'title' => esc_html__('Secondary Color', 'reuss'),
'inline' => 'span',
'classes' => 'highlighter secondary',
],
],
],
[
'title' => esc_html__('Font Weight', 'reuss'),
'items' => [
[
'title' => esc_html__('Default', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => 'inherit'],
], [
'title' => esc_html__('Lightest (100)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '100'],
], [
'title' => esc_html__('Lighter (200)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '200'],
], [
'title' => esc_html__('Light (300)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '300'],
], [
'title' => esc_html__('Normal (400)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '400'],
], [
'title' => esc_html__('Medium (500)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '500'],
], [
'title' => esc_html__('Semi-Bold (600)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '600'],
], [
'title' => esc_html__('Bold (700)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '700'],
], [
'title' => esc_html__('Bolder (800)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '800'],
], [
'title' => esc_html__('Extra Bold (900)', 'reuss'),
'inline' => 'span',
'styles' => ['font-weight' => '900'],
],
]
],
[
'title' => esc_html__('List Style', 'reuss'),
'items' => [
[
'title' => esc_html__('Dot Primary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_dot primary',
], [
'title' => esc_html__('Dot Secondary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_dot secondary',
], [
'title' => esc_html__('Check Primary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_check primary',
], [
'title' => esc_html__('Check Secondary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_check secondary',
], [
'title' => esc_html__('Plus Primary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_plus primary',
], [
'title' => esc_html__('Plus Secondary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_plus secondary',
], [
'title' => esc_html__('Hyphen Primary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_hyphen primary',
], [
'title' => esc_html__('Hyphen Secondary Color', 'reuss'),
'selector' => 'ul',
'classes' => 'reuss_list reuss_hyphen secondary',
], [
'title' => esc_html__('Right Style', 'reuss'),
'selector' => 'ul.reuss_list',
'classes' => 'icon_right',
], [
'title' => esc_html__('Disable Line - Lighter', 'reuss'),
'selector' => 'ul.reuss_list li',
'classes' => 'reuss_disable',
], [
'title' => esc_html__('Disable Line - Darker', 'reuss'),
'selector' => 'ul.reuss_list li',
'classes' => 'reuss_disable_dark',
], [
'title' => esc_html__('No List Style', 'reuss'),
'selector' => 'ul',
'classes' => 'no-list-style',
],
]
],
];
$settings['style_formats'] = str_replace('"', "'", json_encode($style_formats));
$settings['extended_valid_elements'] = 'span[*],a[*],i[*]';
return $settings;
}
add_filter('tiny_mce_before_init', 'reuss_tiny_mce_before_init');
function reuss_theme_add_editor_styles()
{
add_editor_style('css/font-awesome.min.css');
}
add_action('current_screen', 'reuss_theme_add_editor_styles');
function reuss_categories_postcount_filter($variable)
{
if (strpos($variable, ' (')) {
$variable = str_replace(' (', '', $variable);
$variable = str_replace(' (', '', $variable);
$variable = str_replace(')', '', $variable);
} else {
$variable = str_replace(' (', '', $variable);
$variable = str_replace(')', '', $variable);
}
$pattern1 = '/cat-item-\d+/';
preg_match_all($pattern1, $variable, $matches);
if (isset($matches[0])) {
foreach ($matches[0] as $value) {
$int = (int) str_replace('cat-item-', '', $value);
$icon_image_id = get_term_meta($int, 'category-icon-image-id', true);
if (!empty($icon_image_id)) {
$icon_image = wp_get_attachment_image_src($icon_image_id, 'full');
$icon_image_alt = get_post_meta($icon_image_id, '_wp_attachment_image_alt', true);
$replacement = '$1';
$pattern = '/(cat-item-' . $int . '+.*?>)/';
$variable = preg_replace($pattern, $replacement, $variable);
}
}
}
return $variable;
}
add_filter('wp_list_categories', 'reuss_categories_postcount_filter');
add_filter('woocommerce_layered_nav_term_html', 'reuss_categories_postcount_filter');
function reuss_render_archive_widgets(
$link_html,
$url,
$text,
$format,
$before,
$after
) {
$text = wptexturize($text);
$url = esc_url($url);
if ('link' == $format) {
$link_html = "\t\n";
} elseif ('option' == $format) {
$link_html = "\t\n";
} elseif ('html' == $format) {
$after = str_replace('(', '', $after);
$after = str_replace(' ', '', $after);
$after = str_replace(' ', '', $after);
$after = str_replace(')', '', $after);
$after = !empty($after) ? " (" . esc_html($after) . ") " : "";
$link_html = "" . esc_html($before) . "" . esc_html($text) . $after . "";
} else { // custom
$link_html = "\t$before$text$after\n";
}
return $link_html;
}
add_filter('get_archives_link', 'reuss_render_archive_widgets', 10, 6);
// Woocommerce Init
if (class_exists('WooCommerce')) {
require_once(get_theme_file_path('/woocommerce/woocommerce-init.php'));
}
add_filter('reuss_enqueue_shortcode_css', 'reuss_render_css');
function reuss_render_css($styles)
{
global $reuss_dynamic_css;
if (!isset($reuss_dynamic_css['style'])) {
$reuss_dynamic_css = [];
$reuss_dynamic_css['style'] = $styles;
} else {
$reuss_dynamic_css['style'] .= $styles;
}
}
/**
* Add a pingback url auto-discovery for single posts, pages or attachments.
*/
function reuss_pingback_header()
{
if (is_singular() && pings_open()) {
echo '';
}
}
add_action('wp_head', 'reuss_pingback_header');
/* Add Custom Image Link field to media uploader for WGL Gallery module */
function attachment_custom_link_field($form_fields, $post)
{
$form_fields['custom_image_link'] = array(
'label' => esc_html__('Custom Image Link','reuss'),
'input' => 'text',
'value' => get_post_meta($post->ID, 'custom_image_link', true),
'helps' => esc_html__('This option works only for the WGL Gallery module.','reuss'),
);
return $form_fields;
}
add_filter('attachment_fields_to_edit', 'attachment_custom_link_field', 10, 2);
/* Save values of Custom Image Link in media uploader */
function attachment_custom_link_field_save($post, $attachment)
{
if (isset($attachment['custom_image_link']))
update_post_meta($post['ID'], 'custom_image_link', $attachment['custom_image_link']);
return $post;
}
add_filter('attachment_fields_to_save', 'attachment_custom_link_field_save', 10, 2);