function check_widget_visibility($vis_settings = array()) { global $paged; if (empty($vis_settings)) { return true; } $do_show = true; $do_show_by_select = false; $do_show_by_url = false; $do_show_by_word_count = false; $do_show_by_antenna = false; $do_show_on_front = false; // Check by current URL if (!empty($vis_settings['url']['urls'])) { // Split on line breaks $split_urls = split("[\n ]+", (string) $vis_settings['url']['urls']); $current_url = $this->get_current_url(); foreach ($split_urls as $id => $check_url) { $check_url = trim($check_url); if ($check_url !== '') { if ($this->match_path($current_url, $check_url)) { $do_show_by_url = true; } } else { $ignore_url = true; } } if (!$ignore_url && $do_show_by_url) { $do_show_by_url = true; } else { $do_show_by_url = false; } } // Check by tag settings if (!empty($vis_settings['location'])) { $currently = array(); if (is_front_page() && $paged < 2) { $currently['is_front_page'] = true; } if (is_home() && $paged < 2) { $currently['is_home'] = true; } if (is_page() && !is_attachment()) { $currently['is_page'] = true; } if (is_single() && !is_attachment()) { $currently['is_single'] = true; } if (is_archive()) { $currently['is_archive'] = true; } if (is_category()) { $currently['is_category'] = true; } if (is_tag()) { $currently['is_tag'] = true; } if (is_author()) { $currently['is_author'] = true; } if (is_search()) { $currently['is_search'] = true; } if (is_404()) { $currently['is_404'] = true; } if (is_attachment()) { $currently['is_attachment'] = true; } // Check for selected pages/sections $current_location = array_keys($currently); $visibility_options = array_keys($vis_settings['location']); foreach ($current_location as $location_id) { if (in_array($location_id, $visibility_options)) { $do_show_by_select = true; } } // Check for word count $word_count_to_check = (int) $vis_settings['location']['word_count']; if ($vis_settings['location']['check_wordcount'] == 'on' && $word_count_to_check > 1) { $check_type = $vis_settings['location']['check_wordcount_type']; if ($check_type == 'more' && $this->words_on_page > $word_count_to_check) { print '<!-- showing because ' . $this->words_on_page . ' > ' . $word_count_to_check . ' -->'; $do_show_by_word_count = true; } elseif ($check_type == 'less' && $this->words_on_page < $word_count_to_check) { print '<!-- showing because ' . $this->words_on_page . ' < ' . $word_count_to_check . ' -->'; $do_show_by_word_count = true; } } else { $ignore_word_count = true; } if (!$ignore_word_count && $do_show_by_word_count) { $do_show_by_word_count = true; } else { $do_show_by_word_count = false; } } global $multi; // Check Antennas settings if (!empty($vis_settings['antenna'])) { if (function_exists('get_current_antenna')) { $current_antenna = $multi && is_front_page() ? '' : get_current_antenna(); } $visibility_options_antennas = array_keys($vis_settings['antenna']); if (function_exists('icl_object_id')) { foreach ($visibility_options_antennas as $k => $antID) { $tabID[] = icl_object_id($antID, 'category', true, ICL_LANGUAGE_CODE); } } if (in_array($current_antenna, $visibility_options_antennas) || in_array($current_antenna, $tabID)) { $do_show_by_antenna = true; } } if (function_exists('multi_antennas')) { if (!empty($vis_settings['country']) && $multi) { if (is_front_page() && $paged < 2) { $do_show_on_front = true; } if (is_home() && $paged < 2) { $do_show_on_front = true; } } } // Combine all context checks if ($do_show_by_word_count || $do_show_by_url || $do_show_by_select || $do_show_on_front || $do_show_by_antenna) { $one_is_true = true; } elseif (!$do_show_by_word_count || !$do_show_by_url || !$do_show_by_select || !$do_show_on_front || !$do_show_by_antenna) { $one_is_true = false; } if ($vis_settings['incexc'] == 'selected' && $one_is_true) { // Show on selected $do_show = true; } elseif ($vis_settings['incexc'] == 'notselected' && !$one_is_true) { // Hide on selected $do_show = true; } elseif (!empty($vis_settings['incexc'])) { $do_show = false; } else { $do_show = true; } // Hide if selected if ($vis_settings['incexc'] == 'hide') { $do_show = false; } return $do_show; }
<?php //declare a global var to know if we have a simple or multi-antennas website global $multi; $multi = multi_antennas(); //$multi = false; //Get theme options for antennas global $options; $options = get_antennas_details(); //Make antenna id accessible everywhere global $antenna; $antenna = get_current_antenna(); if ($multi && is_front_page() && is_home()) { $antenna = 'front'; } global $sitepress; $default_lg = isset($sitepress) ? $sitepress->get_default_language() : 'fr'; //assuming that 'fr' should be default language global $antenna_op; $antenna_op = function_exists('icl_object_id') ? icl_object_id($antenna, 'category', true, $default_lg) : $antenna; global $c; $c = get_query_var('cat'); global $current_user; get_currentuserinfo(); global $if_front; $if_front = is_front_page(); ?> <!DOCTYPE html> <html <?php language_attributes(); ?>