Ejemplo n.º 1
0
 function generate_smart_content_width()
 {
     global $content_width, $post;
     // Get Customizer options
     $generate_settings = wp_parse_args(get_option('generate_settings', array()), generate_get_defaults());
     // Get sidebar widths
     $right_sidebar_width = apply_filters('generate_right_sidebar_width', '25');
     $left_sidebar_width = apply_filters('generate_left_sidebar_width', '25');
     // Get the layout
     $layout = generate_get_layout();
     // Find the real content width
     if ('left-sidebar' == $layout) {
         // If left sidebar is present
         $content_width = $generate_settings['container_width'] * ((100 - $left_sidebar_width) / 100);
     } elseif ('right-sidebar' == $layout) {
         // If right sidebar is present
         $content_width = $generate_settings['container_width'] * ((100 - $right_sidebar_width) / 100);
     } elseif ('no-sidebar' == $layout) {
         // If no sidebars are present
         $content_width = $generate_settings['container_width'];
     } else {
         // If both sidebars are present
         $content_width = $generate_settings['container_width'] * ((100 - ($left_sidebar_width + $right_sidebar_width)) / 100);
     }
 }
Ejemplo n.º 2
0
function generate_content_classes($classes)
{
    $right_sidebar_width = apply_filters('generate_right_sidebar_width', '25');
    $left_sidebar_width = apply_filters('generate_left_sidebar_width', '25');
    $total_sidebar_width = $left_sidebar_width + $right_sidebar_width;
    $right_sidebar_tablet_width = apply_filters('generate_right_sidebar_tablet_width', '30');
    $left_sidebar_tablet_width = apply_filters('generate_left_sidebar_tablet_width', '30');
    $total_sidebar_tablet_width = $left_sidebar_tablet_width + $right_sidebar_tablet_width;
    $classes[] = 'content-area';
    $classes[] = 'grid-parent';
    // Get the layout
    $layout = generate_get_layout();
    if ('' !== $layout) {
        switch ($layout) {
            case 'right-sidebar':
                $classes[] = 'grid-' . (100 - $right_sidebar_width);
                $classes[] = 'tablet-grid-' . (100 - $right_sidebar_tablet_width);
                break;
            case 'left-sidebar':
                $classes[] = 'push-' . $left_sidebar_width;
                $classes[] = 'grid-' . (100 - $left_sidebar_width);
                $classes[] = 'tablet-push-' . $left_sidebar_tablet_width;
                $classes[] = 'tablet-grid-' . (100 - $left_sidebar_tablet_width);
                break;
            case 'no-sidebar':
                $classes[] = 'grid-100';
                $classes[] = 'tablet-grid-100';
                break;
            case 'both-sidebars':
                $classes[] = 'push-' . $left_sidebar_width;
                $classes[] = 'grid-' . (100 - $total_sidebar_width);
                $classes[] = 'tablet-push-' . $left_sidebar_tablet_width;
                $classes[] = 'tablet-grid-' . (100 - $total_sidebar_tablet_width);
                break;
            case 'both-right':
                $classes[] = 'grid-' . (100 - $total_sidebar_width);
                $classes[] = 'tablet-grid-' . (100 - $total_sidebar_tablet_width);
                break;
            case 'both-left':
                $classes[] = 'push-' . $total_sidebar_width;
                $classes[] = 'grid-' . (100 - $total_sidebar_width);
                $classes[] = 'tablet-push-' . $total_sidebar_tablet_width;
                $classes[] = 'tablet-grid-' . (100 - $total_sidebar_tablet_width);
                break;
        }
    }
    return $classes;
}