Exemplo n.º 1
0
function upfront_is_page_template($page_template, $layout_ids = null)
{
    if (defined("DOING_AJAX") && DOING_AJAX) {
        if (is_array($layout_ids)) {
            $layout = $layout_ids;
        } else {
            if (isset($_POST['layout'])) {
                $layout = $_POST['layout'];
            } else {
                if (isset($_GET['layout'])) {
                    $layout = $_GET['layout'];
                } else {
                    if (Upfront_Layout::get_instance()) {
                        $layout = Upfront_Layout::get_instance()->get('layout');
                    }
                }
            }
        }
        if (!$layout) {
            return false;
        }
        return $page_template == upfront_get_page_template_slug($layout);
    } else {
        return is_page_template($page_template);
    }
}
 function load_styles()
 {
     $grid = Upfront_Grid::get_grid();
     $layout = apply_filters('upfront-style-base_layout', Upfront_Layout::get_instance());
     $preprocessor = new Upfront_StylePreprocessor($grid, $layout);
     $base_only = isset($_POST['base_only']) ? filter_var($_POST['base_only'], FILTER_VALIDATE_BOOLEAN) : false;
     // Alright, so initialize the var first
     $style = '';
     // Add typography styles - rearranging so the imports from Google fonts come first, if needed.
     // When loading styles in editor mode don't include typography styles since they are generated
     // by javascript
     if (false === $base_only) {
         $style = $this->prepare_typography_styles($layout, $grid);
         $style .= $preprocessor->process();
     }
     // Always load original theme styles into theme unless we're in builder, yay
     // Reasoning behind it: we want theme users to always have original theme styles loaded
     // because if they want to override some style they can add their own additional properties
     // or nullify explicitly existing rules. So, to avoid complex initialization logic depending
     // on wheather there is something in database just load theme styles always. In builder though
     // we don't want this because user is editing actual theme styles.
     $style .= $this->load_theme_styles_unless_in_builder();
     // When loading styles in editor mode don't include element styles and colors since they
     // will be loaded separately to the body. If they are included in main style than after
     // style is edited in editor (e.g. some property is removed) inconsistencies may occur
     // especially with rules removal since those would still be defined in main style.
     if ($base_only) {
         $this->_out(new Upfront_JsonResponse_Success(array('styles' => $style)));
         return;
     }
     //Add theme styles
     $style .= $this->prepare_theme_styles();
     // Add theme colors styles
     $style .= $this->_get_theme_colors_styles();
     // Add elements presets styles
     $style = apply_filters('get_element_preset_styles', $style);
     $style = Upfront_UFC::init()->process_colors($style);
     $this->_out(new Upfront_CssResponse_Success($style));
 }