function load_front_styles()
 {
     $grid = Upfront_Grid::get_grid();
     $preprocessor = new Upfront_StylePreprocessor($grid);
     $style = $preprocessor->get_grid();
     $this->_out(new Upfront_CssResponse_Success($style));
 }
 public function __construct($args, $properties = array())
 {
     $this->data = array_merge(array('properties' => array(), 'modules' => array(), 'wrappers' => array(), 'name' => '', 'title' => '', 'scope' => 'local', 'container' => '', 'default' => false, 'position' => 11, 'allow_sidebar' => true, 'type' => 'wide'), $args);
     foreach ($properties as $prop => $value) {
         $this->set_property($prop, $value);
     }
     $this->grid = Upfront_Grid::get_grid();
 }
 public function get_breakpoints()
 {
     $responsive_settings = get_option('upfront_' . get_stylesheet() . '_responsive_settings');
     if (empty($responsive_settings)) {
         // Add defaults
         $defaults = Upfront_Grid::get_grid()->get_default_breakpoints();
         $responsive_settings = json_encode($defaults);
     }
     $this->_out(new Upfront_JsonResponse_Success($responsive_settings));
 }
Пример #4
0
 public function get_markup()
 {
     $menu_id = $this->_get_property('menu_id');
     $menu_slug = $this->_get_property('menu_slug');
     $layout_settings = json_decode($this->_get_property('layout_setting'));
     $menu_style = $this->_get_property('menu_style');
     $breakpoint_data = $this->_get_property('breakpoint');
     $breakpoints = Upfront_Grid::get_grid()->get_breakpoints();
     foreach ($breakpoints as $name => $point) {
         $data = $point->get_data();
         if (!empty($data['enabled'])) {
             $breakpoint_data[$data['id']]['width'] = $data['width'];
         }
     }
     $burgermenu_desktop = $this->_get_property('burger_menu');
     $breakpoint_data['desktop']['burger_menu'] = is_array($burgermenu_desktop) && isset($burgermenu_desktop[0]) ? $burgermenu_desktop[0] : $burgermenu_desktop;
     $breakpoint_data['desktop']['burger_alignment'] = $this->_get_property('burger_alignment');
     $breakpoint_data['desktop']['burger_over'] = $this->_get_property('burger_over');
     //$breakpoint_data['desktop']['menu_style'] = 'horizontal';
     $breakpoint_data = json_encode($breakpoint_data);
     $menu_aliment = $this->_get_property('menu_alignment');
     $sub_navigation = $this->_get_property('allow_sub_nav');
     $is_floating = $this->_get_property('is_floating');
     $menu_style = $menu_style ? "data-style='{$menu_style}' data-stylebk='{$menu_style}'" : "";
     $breakpoint_data = $breakpoint_data ? "data-breakpoints='{$breakpoint_data}'" : "";
     $menu_aliment = $menu_aliment ? "data-aliment='{$menu_aliment}' data-alimentbk='{$menu_aliment}'" : "";
     $sub_navigation = $sub_navigation ? "data-allow-sub-nav='yes'" : "data-allow-sub-nav='no'";
     $float_class = $is_floating ? 'upfront-navigation-float' : '';
     //  upfront_add_element_style('unewnavigation', array('css/unewnavigation-style.css', dirname(__FILE__)));
     //    if (is_user_logged_in()) {
     //      upfront_add_element_style('unewnavigation_editor', array('css/unewnavigation-editor.css', dirname(__FILE__)));
     //  }
     if ($is_floating) {
         //wp_enqueue_script('unewnavigation', upfront_element_url('js/public.js', dirname(__FILE__)));
         upfront_add_element_script('unewnavigation', array('js/public.js', dirname(__FILE__)));
     }
     //wp_enqueue_script('unewnavigation_responsive', upfront_element_url('js/responsive.js', dirname(__FILE__)));
     upfront_add_element_script('unewnavigation_responsive', array('js/responsive.js', dirname(__FILE__)));
     if ($menu_slug) {
         $menu = wp_get_nav_menu_object($menu_slug);
         if ($menu) {
             $menu_id = $menu->term_id;
         }
     }
     if ($menu_id) {
         $menu = wp_nav_menu(array('menu' => $menu_id, 'fallback_cb' => false, 'echo' => false, 'walker' => new upfront_nav_walker()));
     } else {
         return "<div class=' {$float_class} upfront-navigation' {$menu_style} {$menu_aliment} {$breakpoint_data} {$sub_navigation}>" . self::_get_l10n('select_menu') . "</div>";
     }
     return "<div class=' {$float_class} upfront-navigation' {$menu_style} {$menu_aliment} {$breakpoint_data} {$sub_navigation}>" . $menu . "</div>";
 }
 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));
 }
Пример #6
0
 public function __construct($layout, $post)
 {
     $this->_layout = $layout;
     $this->_debugger = Upfront_Debug::get_debugger();
     self::$grid = Upfront_Grid::get_grid();
 }
Пример #7
0
 function inject_grid_scope_class($cls)
 {
     $grid = Upfront_Grid::get_grid();
     $cls[] = $grid->get_grid_scope();
     return $cls;
 }
    function load_main()
    {
        $is_ssl = !empty($_GET['ssl']);
        $root = Upfront::get_root_url();
        $ajax = admin_url('admin-ajax.php');
        $site = home_url();
        $includes_url = includes_url();
        $current_theme_url = get_stylesheet_directory_uri();
        if (empty($is_ssl) && is_ssl()) {
            $root = preg_replace('/^https:/', 'http:', $root);
            $includes_url = preg_replace('/^https:/', 'http:', $includes_url);
            $ajax = preg_replace('/^https:/', 'http:', $ajax);
            $site = preg_replace('/^https:/', 'http:', $site);
            $current_theme_url = preg_replace('/^https:/', 'http:', $current_theme_url);
        }
        $admin = admin_url();
        $upfront_data_url = $ajax . '?action=upfront_data';
        $entities = Upfront_Entity_Registry::get_instance();
        $registered = $entities->get_all();
        $child_instance = Upfront_ChildTheme::get_instance();
        $paths = array("backbone" => $includes_url . "js/backbone.min", "underscore" => $includes_url . "js/underscore.min", "upfront-data" => $upfront_data_url, "text" => 'scripts/text', "async" => "scripts/async", "upfront" => "scripts/upfront", "models" => "scripts/upfront/upfront-models", "views" => "scripts/upfront/upfront-views", "editor_views" => "scripts/upfront/upfront-views-editor", "util" => "scripts/upfront/upfront-util", "behaviors" => "scripts/upfront/upfront-behaviors", "application" => "scripts/upfront/upfront-application", "objects" => "scripts/upfront/upfront-objects", "media" => "scripts/upfront/upfront-media", "content" => "scripts/upfront/upfront-content", "bg-settings" => "scripts/upfront/bg-settings/bg-settings", "spectrum" => "scripts/spectrum/spectrum", "responsive" => "scripts/responsive", "redactor_plugins" => 'scripts/redactor/plugins', "redactor" => 'scripts/redactor/redactor', "jquery-df" => 'scripts/jquery/jquery-dateFormat.min', "jquery-simulate" => 'scripts/jquery/jquery.simulate', "ueditor" => 'scripts/redactor/ueditor', "chosen" => "scripts/chosen/chosen.jquery.min", "findandreplace" => "scripts/findandreplace/findAndReplaceDOMText");
        $paths = apply_filters('upfront-settings-requirement_paths', $paths + $registered);
        $shim = array('underscore' => array('exports' => '_'), 'redactor' => array('redactor_plugins'), 'jquery-df' => array('jquery'), 'chosen' => array('deps' => array('jquery'), 'exports' => 'jQuery.fn.chosen'));
        $require_config = array('baseUrl' => "{$root}", 'paths' => $paths, 'shim' => $shim, 'waitSeconds' => 60);
        if ($this->_debugger->is_active(Upfront_Debug::CACHED_RESPONSE)) {
            $require_config['urlArgs'] = "nocache=" + microtime(true);
        }
        $require_config = json_encode(apply_filters('upfront-settings-require_js_config', $require_config));
        $layout_editor_requirements = array("core" => array('models', 'views', 'editor_views', 'behaviors', $upfront_data_url, 'media', 'content', 'spectrum', 'responsive', 'redactor', 'ueditor'), "entities" => array_merge(array('objects'), array_keys($registered)));
        $layout_editor_requirements = json_encode(apply_filters('upfront-settings-layout_editor_requirements', $layout_editor_requirements));
        $grid = Upfront_Grid::get_grid();
        $breakpoints = $grid->get_breakpoints();
        $grid_info = array('breakpoint_columns' => array(), 'size_classes' => array(), 'margin_left_classes' => array(), 'margin_right_classes' => array(), 'margin_top_classes' => array(), 'margin_bottom_classes' => array(), 'scope' => $grid->get_grid_scope(), 'baseline' => '', 'size' => '', 'class' => '', 'left_margin_class' => '', 'right_margin_class' => '', 'baseline' => '', 'column_width' => '', 'column_padding' => '', 'type_padding' => '', 'top_margin_class' => '', 'bottom_margin_class' => '', 'size_name' => '');
        foreach ($breakpoints as $context => $breakpoint) {
            $grid_info['breakpoint_columns'][$context] = $breakpoint->get_columns();
            $grid_info['column_widths'][$context] = $breakpoint->get_column_width();
            $grid_info['column_paddings'][$context] = $breakpoint->get_column_padding();
            $grid_info['type_paddings'][$context] = $breakpoint->get_type_padding();
            $grid_info['baselines'][$context] = $breakpoint->get_baseline();
            $grid_info['size_classes'][$context] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_WIDTH);
            $grid_info['margin_left_classes'][$context] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_LEFT);
            $grid_info['margin_right_classes'][$context] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_RIGHT);
            $grid_info['margin_top_classes'][$context] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_TOP);
            $grid_info['margin_bottom_classes'][$context] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_BOTTOM);
            // @TODO temporary fix to keep old breakpoint work, before we move on to the new breakpoint system
            if ($breakpoint->is_default()) {
                $grid_info['size_name'] = $context;
                $grid_info['size'] = $breakpoint->get_columns();
                $grid_info['column_width'] = $breakpoint->get_column_width();
                $grid_info['column_padding'] = $breakpoint->get_column_padding();
                $grid_info['type_padding'] = $breakpoint->get_type_padding();
                $grid_info['baseline'] = $breakpoint->get_baseline();
                $grid_info['class'] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_WIDTH);
                $grid_info['left_margin_class'] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_LEFT);
                $grid_info['right_margin_class'] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_RIGHT);
                $grid_info['top_margin_class'] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_TOP);
                $grid_info['bottom_margin_class'] = $breakpoint->get_prefix(Upfront_GridBreakpoint::PREFIX_MARGIN_BOTTOM);
            }
        }
        $grid_info = json_encode(apply_filters('upfront-settings-grid_info', $grid_info));
        $theme_info = get_option('upfront_' . get_stylesheet() . '_responsive_settings');
        $theme_info = apply_filters('upfront_get_responsive_settings', $theme_info);
        if (is_array($theme_info)) {
            $theme_info = json_encode($theme_info);
        }
        if (empty($theme_info) || $theme_info === '[]') {
            // Add defaults
            $defaults = Upfront_Grid::get_grid()->get_breakpoints_data();
            $theme_info = json_encode(array('breakpoints' => $defaults));
        }
        $theme_fonts = get_option('upfront_' . get_stylesheet() . '_theme_fonts');
        $theme_fonts = apply_filters('upfront_get_theme_fonts', $theme_fonts, array('json' => true));
        if (empty($theme_fonts)) {
            $theme_fonts = json_encode(array());
        }
        $icon_fonts = get_option('upfront_' . get_stylesheet() . '_icon_fonts');
        $icon_fonts = apply_filters('upfront_get_icon_fonts', $icon_fonts, array('json' => true));
        if (empty($icon_fonts)) {
            $icon_fonts = json_encode(array());
        }
        $additional_fonts = $child_instance ? $child_instance->getAdditionalFonts() : json_encode(array());
        $current_user = wp_get_current_user();
        $user_done_font_intro = in_array($current_user->user_login, get_option('upfront_users_done_font_intro', array())) ? 'true' : 'false';
        $theme_colors = get_option('upfront_' . get_stylesheet() . '_theme_colors');
        $theme_colors = apply_filters('upfront_get_theme_colors', $theme_colors, array('json' => true));
        if (empty($theme_colors)) {
            $theme_colors = json_encode(array());
        }
        $post_image_variants = get_option('upfront_' . get_stylesheet() . '_post_image_variants');
        $post_image_variants = apply_filters('upfront_get_post_image_variants', $post_image_variants, array('json' => true));
        if (empty($post_image_variants)) {
            $post_image_variants = json_encode(array());
        }
        $button_presets = get_option('upfront_' . get_stylesheet() . '_button_presets');
        $button_presets = apply_filters('upfront_get_button_presets', $button_presets, array('json' => true));
        if (empty($button_presets)) {
            $button_presets = json_encode(array());
        }
        $tab_presets = get_option('upfront_' . get_stylesheet() . '_tab_presets');
        $tab_presets = apply_filters('upfront_get_tab_presets', $tab_presets, array('json' => true));
        if (empty($tab_presets)) {
            $tab_presets = json_encode(array());
        }
        $accordion_presets = get_option('upfront_' . get_stylesheet() . '_accordion_presets');
        $accordion_presets = apply_filters('upfront_get_accordion_presets', $accordion_presets, array('json' => true));
        if (empty($accordion_presets)) {
            $accordion_presets = json_encode(array());
        }
        $debug = array("transients" => $this->_debugger->is_active(Upfront_Debug::JS_TRANSIENTS), "dev" => $this->_debugger->is_active(Upfront_Debug::DEV));
        $debug = json_encode(apply_filters('upfront-settings-debug', $debug));
        $specificity = json_encode(array('specificity' => __('This post only'), 'item' => __('All posts of this type'), 'type' => __('All posts')));
        $content = json_encode(array('create' => array('page' => Upfront_VirtualPage::get_url('create/page'), 'post' => Upfront_VirtualPage::get_url('create/post')), 'edit' => array('page' => Upfront_VirtualPage::get_url('edit/page/'), 'post' => Upfront_VirtualPage::get_url('edit/post/'))));
        $allowed_modes = array();
        if (Upfront_Permissions::current(Upfront_Permissions::LAYOUT_MODE)) {
            $allowed_modes[] = 'layout';
        }
        if (Upfront_Permissions::current(Upfront_Permissions::CONTENT_MODE)) {
            $allowed_modes[] = 'content';
        }
        if (Upfront_Permissions::current(Upfront_Permissions::THEME_MODE)) {
            $allowed_modes[] = 'theme';
        }
        if (Upfront_Permissions::current(Upfront_Permissions::POSTLAYOUT_MODE)) {
            $allowed_modes[] = 'postlayout';
        }
        if (Upfront_Permissions::current(Upfront_Permissions::RESPONSIVE_MODE)) {
            $allowed_modes[] = 'responsive';
        }
        $application_modes = json_encode(array("LAYOUT" => "layout", "CONTENT" => "content", "THEME" => "theme", "POST" => "post layout", "CONTENT_STYLE" => "post content style", "POSTCONTENT" => "post content", "RESPONSIVE" => "responsive", "POSTCONTENT_STYLE" => false, "DEFAULT" => Upfront_Permissions::current(Upfront_Permissions::LAYOUT_MODE) ? "layout" : "content", "ALLOW" => Upfront_Permissions::current(Upfront_Permissions::LAYOUT_MODE) ? join(',', $allowed_modes) : "content"));
        $read_only = json_encode(defined('UPFRONT_READ_ONLY') && UPFRONT_READ_ONLY);
        $allow_revisions = json_encode(Upfront_Permissions::current(Upfront_Permissions::SAVE_REVISION));
        $l10n = json_encode($this->_get_l10n_strings());
        $content_settings = array();
        if (Upfront_Permissions::current(Upfront_Permissions::CONTENT_MODE)) {
            $raw_post_types = get_post_types(array('public' => true), 'objects');
            $content_settings["post_types"] = array();
            foreach ($raw_post_types as $type => $obj) {
                if (empty($obj->labels->name)) {
                    continue;
                }
                $content_settings["post_types"][] = array("name" => $type, "label" => $obj->labels->name);
            }
        }
        $content_settings = json_encode($content_settings);
        $main = <<<EOMainJs
// Set up the global namespace
var Upfront = window.Upfront || {};
Upfront.mainData = {
\trequireConfig: {$require_config},
\troot: '{$root}',
\tcurrentThemeUrl: '{$current_theme_url}',
\tajax: '{$ajax}',
\tadmin: '{$admin}',
\tsite: '{$site}',
\tdebug: {$debug},
\tlayoutEditorRequirements: {$layout_editor_requirements},
\tapplicationModes: {$application_modes},
\tALLOW_REVISIONS: {$allow_revisions},
\treadOnly: {$read_only},
\tspecificity: {$specificity},
\tgridInfo: {$grid_info},
\tthemeInfo: {$theme_info},
\tthemeFonts: {$theme_fonts},
\ticonFonts: {$icon_fonts},
\tadditionalFonts: {$additional_fonts},
\tuserDoneFontsIntro: {$user_done_font_intro},
\tbuttonPresets: {$button_presets},
\ttabPresets: {$tab_presets},
\taccordionPresets: {$accordion_presets},
\tthemeColors: {$theme_colors},
\tpostImageVariants: {$post_image_variants},
\tcontent: {$content},
\tcontent_settings: {$content_settings},
\tl10n: {$l10n}
};
EOMainJs;
        $this->_out(new Upfront_JavascriptResponse_Success($main));
    }