/** * Wraps content in a tabbed layout. * * @since 1.1-beta-2 * @access private * * @param array $atts The attributes sent to the shortcode. * @param string $content The content inside the shortcode. * @return string The tabs wrapper HTML. */ function _render_sc_tabs_wrapper($atts = array(), $content = '') { $atts = shortcode_atts(array('nested_children' => false, 'navigation_tab_color' => RENDER_PRIMARY_COLOR, 'navigation_tab_hover_color' => RENDER_PRIMARY_COLOR_LIGHT, 'navigation_tab_font_color' => RENDER_PRIMARY_FONT_COLOR, 'border_color' => RENDER_PRIMARY_COLOR_DARK, 'content_border' => 'show'), $atts); // Escape atts render_esc_atts($atts); // This shouldn't be possible, but just in case it somehow happens if ($atts['nested_children'] === false) { return 'Error in shortcode'; } $tabs = render_associative_atts($atts, 'nested_children'); // Open wrapper $output = '<div class="render-tabs-wrapper">'; // Navigation tabs $output .= '<ul class="render-tabs-navigation">'; $i = 0; foreach ($tabs as $tab) { $i++; // Classes $classes = array(); $classes[] = 'render-tabs-navigation-tab'; $classes[] = $i === 1 ? 'render-tabs-navigation-tab-active' : ''; // Styles $styles = array("background: {$atts['navigation_tab_color']};", "color: {$atts['navigation_tab_font_color']};", "border-color: {$atts['border_color']};"); $output .= "<li class='" . implode(' ', array_filter($classes)) . "'"; $output .= " style='" . implode(' ', $styles) . "'>"; $output .= "<span class='render-tabs-navigation-tab-hover' style='background: {$atts['navigation_tab_hover_color']};'></span>"; $output .= "<span class='render-tabs-navigation-tab-content'>{$tab['navigation_label']}</span>"; $output .= '</li>'; } $output .= '</ul>'; // Content $styles = array('border-width: ' . ($atts['content_border'] !== 'hide' ? '1px' : '0') . ';', "border-color: {$atts['border_color']};"); $output .= '<div class="render-tabs-section-wrapper" style="' . implode(' ', $styles) . '"">'; $output .= do_shortcode($content); $output .= '</div>'; // .render-tabs-section-wrapper // Close wrapper $output .= '</div>'; // .render-tabs-wrapper return $output; }
/** * Returns the content if the specified time properties are not met. * * @since 1.0.0 * @access private * @param array $atts The attributes sent to the shortcode. * @param string $content The content inside the shortcode. * @return string The content, if it's returned */ function _render_sc_hide_for_times($atts = array(), $content = '') { $atts = wp_parse_args($atts, array('visibility' => 'hide', 'timezone' => get_option('timezone_string', 'UTC'))); $atts = render_esc_atts($atts); $time_blocks = render_associative_atts($atts, 'times'); $orig_timezone = date_default_timezone_get(); date_default_timezone_set($atts['timezone']); // See if the time is in the currently hidden blocks $hidden = $atts['visibility'] === 'hide' ? false : true; foreach ($time_blocks as $times) { $times = explode('-', $times['time']); $current = round((time() - strtotime('today')) / 60); if ($current > intval($times[0]) && $current < intval($times[1])) { $hidden = $atts['visibility'] === 'hide' ? true : false; } } date_default_timezone_set($orig_timezone); $content = $hidden ? '' : $content; return $content; }