Пример #1
0
 public static function get_login_markup($properties = array())
 {
     $properties = self::_normalize_properties($properties);
     $logged_in_preview = is_array($properties['logged_in_preview']) ? !empty($properties['logged_in_preview'][0]) : !empty($properties['logged_in_preview']);
     if ($logged_in_preview) {
         return self::get_logout_markup($properties);
     }
     $block = !empty($properties['style']) && 'form' == $properties['style'];
     $icon = !empty($properties['appearance']) && "icon" == $properties['appearance'];
     $label = !empty($properties['label_text']) ? $properties['label_text'] : self::_get_l10n('log_in');
     if ('icon' === $label) {
         $label = '';
     }
     $trigger_label = !empty($properties['trigger_text']) ? $properties['trigger_text'] : $label;
     $trigger = empty($block) ? self::_get_trigger_markup($icon, $trigger_label) : '';
     $allow_registration = !is_user_logged_in() && get_option('users_can_register');
     // Allow override for in-editor form previews
     if (defined('DOING_AJAX') && DOING_AJAX && Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         $allow_registration = get_option('users_can_register');
     }
     $data = array('trigger' => $trigger, 'label' => $label, 'allow_registration' => $allow_registration, 'lost_password' => self::_get_l10n('lost_password'), 'click_here' => self::_get_l10n('click_here'), 'register' => self::_get_l10n('register'));
     $tpl = 'block';
     // default
     if (!$block && !empty($properties['behavior'])) {
         $tpl = preg_replace('/[^a-z0-9]/', '', $properties['behavior']);
     }
     return upfront_get_template("login-form-{$tpl}", $data, dirname(dirname(__FILE__)) . "/tpl/form-{$tpl}.php");
 }
Пример #2
0
 public function get_widget_markup($instance = array())
 {
     global $wp_registered_widgets;
     $widget = $this->get_widget();
     $result = Upfront_Permissions::current(Upfront_Permissions::BOOT) ? Upfront_UwidgetView::get_l10n('render_error') : '';
     $args = !empty($wp_registered_widgets[$widget]['params']) ? $wp_registered_widgets[$widget]['params'] : array();
     $callback = false;
     if (empty($wp_registered_widgets[$widget])) {
         if (class_exists($widget)) {
             $callback = array(new $widget(), 'widget');
         }
     } else {
         $callback = $wp_registered_widgets[$widget]['callback'];
     }
     if (empty($callback) || !is_callable($callback)) {
         return $result;
     }
     if (is_array($callback) && !empty($callback[0]) && is_object($callback[0]) && $callback[0] instanceof WP_Widget) {
         $callback[1] = 'widget';
     }
     $classname = !empty($wp_registered_widgets[$widget]['classname']) ? $wp_registered_widgets[$widget]['classname'] : '';
     $args = wp_parse_args($args, array('before_widget' => sprintf('<div class="widget %s">', $classname), 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', 'after_widget' => '</div>'));
     $args = apply_filters('upfront_widget_widget_args', $args);
     $instance = wp_parse_args($instance, array('title' => ''));
     ob_start();
     call_user_func_array($callback, array($args, $instance));
     $out = ob_get_clean();
     return !empty($out) ? $out : $result;
 }
 private static function boot()
 {
     if (!empty(self::$_me)) {
         return self::$_me;
     }
     self::$_me = new self();
 }
Пример #4
0
 public function initialize()
 {
     require_once dirname(__FILE__) . '/lib/class_upfront_posts_model.php';
     require_once dirname(__FILE__) . '/lib/class_upfront_posts_data.php';
     require_once dirname(__FILE__) . '/lib/class_upfront_posts_posts_view.php';
     require_once dirname(__FILE__) . '/lib/class_upfront_posts_post_view.php';
     require_once dirname(__FILE__) . '/lib/class_upfront_posts_frontend_view.php';
     upfront_add_layout_editor_entity('uposts', upfront_relative_element_url('js/posts-list', __FILE__));
     upfront_add_element_style('upfront-posts', array('css/public.css', __FILE__));
     if (Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         upfront_add_element_style('upfront-posts-editor', array('css/editor.css', __FILE__));
     }
     add_filter('upfront_data', array('Upfront_Posts_PostsData', 'add_js_defaults'));
     add_filter('upfront_l10n', array('Upfront_Posts_PostsData', 'add_l10n_strings'));
     upfront_add_ajax('upfront_posts-load', array($this, "load_posts"));
     upfront_add_ajax('upfront_posts-data', array($this, "load_data"));
     upfront_add_ajax('upfront_posts-terms', array($this, "load_terms"));
     upfront_add_ajax('upfront_posts-list_meta', array($this, "load_meta"));
     if (Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         add_action('wp_footer', array($this, 'pickle_query'), 99);
     }
     // Handle legacy element parsing
     add_filter('upfront-virtual_region-object_defaults-fallback', array($this, 'handle_legacy_data'), 10, 2);
     add_filter('upfront-output-get_markup-fallback', array($this, 'handle_legacy_output'), 10, 2);
     // Force out the 404 handling for archives
     add_action('parse_request', array($this, 'force_wp_archive_limit'));
 }
 public function update_breakpoints()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $breakpoints = isset($_POST['breakpoints']) ? $_POST['breakpoints'] : array();
     // Parse data types
     foreach ($breakpoints as $index => $breakpoint) {
         $breakpoints[$index]['enabled'] = filter_var($breakpoint['enabled'], FILTER_VALIDATE_BOOLEAN);
         $breakpoints[$index]['default'] = filter_var($breakpoint['default'], FILTER_VALIDATE_BOOLEAN);
         $breakpoints[$index]['width'] = filter_var($breakpoint['width'], FILTER_VALIDATE_INT);
         $breakpoints[$index]['columns'] = filter_var($breakpoint['columns'], FILTER_VALIDATE_INT);
         if (isset($breakpoint['fixed'])) {
             $breakpoints[$index]['fixed'] = filter_var($breakpoint['fixed'], FILTER_VALIDATE_BOOLEAN);
         }
     }
     $responsive_settings = get_option('upfront_' . get_stylesheet() . '_responsive_settings');
     $responsive_settings = apply_filters('upfront_get_responsive_settings', $responsive_settings);
     if (empty($responsive_settings)) {
         $responsive_settings = array('breakpoints' => $breakpoints);
     } else {
         if (is_string($responsive_settings)) {
             $responsive_settings = json_decode($responsive_settings);
         }
         $responsive_settings = (array) $responsive_settings;
         $responsive_settings['breakpoints'] = $breakpoints;
     }
     do_action('upfront_update_responsive_settings', $responsive_settings);
     if (!has_action('upfront_update_responsive_settings')) {
         update_option('upfront_' . get_stylesheet() . '_responsive_settings', json_encode($responsive_settings));
     }
     $this->_out(new Upfront_JsonResponse_Success(get_stylesheet() . ' responsive settings updated'));
 }
 private function _add_hooks()
 {
     if (Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         upfront_add_ajax('upfront_load_editor_grid', array($this, "load_styles"));
     }
     upfront_add_ajax('upfront_load_grid', array($this, "load_front_styles"));
     upfront_add_ajax_nopriv('upfront_load_grid', array($this, "load_front_styles"));
 }
 protected function _add_hooks()
 {
     if (Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         upfront_add_ajax('upfront_get_' . $this->elementName . '_presets', array($this, 'get'));
     }
     if (Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         upfront_add_ajax('upfront_save_' . $this->elementName . '_preset', array($this, 'save'));
         upfront_add_ajax('upfront_delete_' . $this->elementName . '_preset', array($this, 'delete'));
     }
 }
 public function update()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $button_presets = isset($_POST['button_presets']) ? $_POST['button_presets'] : array();
     //do_action('upfront_save_button_presets', $button_presets);
     if (!has_action('upfront_update_button_presets')) {
         update_option('upfront_' . get_stylesheet() . '_button_presets', json_encode($button_presets));
     }
     $this->_out(new Upfront_JsonResponse_Success(get_stylesheet() . ' button presets updated'));
 }
 public function update_theme_fonts()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $theme_fonts = isset($_POST['theme_fonts']) ? $_POST['theme_fonts'] : array();
     do_action('upfront_update_theme_fonts', $theme_fonts);
     if (!has_action('upfront_update_theme_fonts')) {
         update_option('upfront_' . get_stylesheet() . '_theme_fonts', json_encode($theme_fonts));
     }
     $this->_out(new Upfront_JsonResponse_Success(get_stylesheet() . ' theme fonts updated'));
 }
 public function update()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $variants = isset($_POST['image_variants']) ? $_POST['image_variants'] : array();
     $data = array("post_image_variants" => $variants);
     do_action('upfront_save_post_image_variants', $data);
     if (!has_action('upfront_update_post_image_variants')) {
         update_option('upfront_' . get_stylesheet() . '_post_image_variants', json_encode($data));
     }
     $this->_out(new Upfront_JsonResponse_Success(get_stylesheet() . ' post image variants updated'));
 }
 public function update()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $theme_colors = isset($_POST['theme_colors']) ? $_POST['theme_colors'] : array();
     $range = isset($_POST['range']) ? $_POST['range'] : 0;
     $data = array("colors" => $theme_colors, "range" => $range);
     do_action('upfront_save_theme_colors', $data);
     if (!has_action('upfront_update_theme_colors')) {
         update_option('upfront_' . get_stylesheet() . '_theme_colors', json_encode($data));
     }
     $this->_out(new Upfront_JsonResponse_Success(get_stylesheet() . ' theme colors updated'));
 }
 public static function add_dependencies()
 {
     if (Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         upfront_add_element_style('upfront_widget', array('css/widget.css', dirname(__FILE__)));
     }
 }
Пример #13
0
<?php

if (!Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
    header('Status: 403');
    die;
}
header('Content-Type: application/javascript');
$upfront_data = apply_filters('upfront_data', array('loading' => array(), 'posts' => array()));
$insert_count = intval(get_option('ueditor_insert_count'));
if (!$insert_count) {
    $insert_count = 0;
}
$upfront_data['ueditor'] = array('selectors' => apply_filters('upfront_post_selectors', array()), 'filters' => array('date' => apply_filters('upfront_post_date', '%date%'), 'author' => apply_filters('upfront_post_author', '%display_name%')), 'months' => array(__('January'), __('February'), __('March'), __('April'), __('May'), __('June'), __('July'), __('August'), __('September'), __('October'), __('November'), __('December')), 'days' => array(__('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday'), __('Sunday')), 'insertCount' => $insert_count, 'authors' => $this->get_authors());
$upfront_data['region_default_args'] = upfront_get_region_default_args();
//Upfront styles
$dev = isset($_GET['dev']) && $_GET['dev'] ? 'dev_' : '';
$styles = get_option('upfront_' . $dev . get_stylesheet() . '_styles');
$elementTypes = array();
if ($styles) {
    foreach ($styles as $type => $rules) {
        if (!is_array($rules)) {
            continue;
        }
        $elementTypes[$type] = array_keys($rules);
    }
}
$element_styles = apply_filters('upfront_get_theme_styles', $elementTypes);
$upfront_data['styles'] = $elementTypes;
$upfront_data['date'] = array('format' => get_option('date_format'));
?>
Пример #14
0
 /**
  * Updates the template file for a page.
  * @param  Object $data The data sent to update the template, at least a postId and a template name are needed.
  * @return null       Json response {postId, template}
  */
 function update_page_template($data)
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::EDIT)) {
         $this->_reject();
     }
     if (!current_user_can('edit_pages')) {
         $this->_out(new Upfront_JsonResponse_Error("You can't do this."));
     }
     if (!$data['postId']) {
         $this->_out(new Upfront_JsonResponse_Error("No page id."));
     }
     if (!$data['template']) {
         $this->_out(new Upfront_JsonResponse_Error("No template given."));
     }
     $key = '_wp_page_template';
     $post_id = $data['postId'];
     $template = $data['template'];
     $success_response = new Upfront_JsonResponse_Success(array('template' => $data['template'], 'postId' => $data['postId']));
     $tpl = get_post_meta($post_id, $key, true);
     if ($template) {
         if (update_post_meta($post_id, $key, $template)) {
             $this->_out($success_response);
         }
     } else {
         if (add_post_meta($post_id, $key, $template, true)) {
             $this->_out($success_response);
         }
     }
     $this->_out(new Upfront_JsonResponse_Error("There was an error saving the template." . $post_id . $key . $template));
 }
Пример #15
0
 public static function add_styles_scripts()
 {
     //wp_enqueue_style('ubutton', upfront_element_url('css/upfront-button.css', dirname(__FILE__)));
     upfront_add_element_style('ubutton', array('css/upfront-button.css', dirname(__FILE__)));
     if (Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         //wp_enqueue_style('ubutton_editor', upfront_element_url('css/upfront-button-editor.css', dirname(__FILE__)));
         upfront_add_element_style('ubutton_editor', array('css/upfront-button-editor.css', dirname(__FILE__)));
     }
 }
 private function _add_hooks()
 {
     if (Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
         upfront_add_ajax('upfront_list_google_fonts', array($this, 'json_list_google_fonts'));
     }
 }
 /**
  * Saves theme colors styles
  * Hooks to upfront_save_theme_colors_styles ajax call
  * @access public
  */
 function save_theme_colors_styles()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $styles = trim(stripslashes($_POST['styles']));
     $styles = apply_filters('upfront-save_theme_colors_styles', $styles);
     update_option("upfront_" . get_stylesheet() . "_theme_colors_styles", $styles);
     $this->_out(new Upfront_JsonResponse_Success(array('styles' => $styles)));
 }
 private function _check_valid_request_level($level)
 {
     if (!Upfront_Permissions::current($level)) {
         return false;
     }
     $ref = !empty($_REQUEST[Upfront_UploadHandler::REF]) ? $_REQUEST[Upfront_UploadHandler::REF] : false;
     return Upfront_Permissions::is_nonce($level, $ref);
 }
 public static function get_ref($level)
 {
     return array(self::REF => Upfront_Permissions::nonce($level));
 }
Пример #20
0
    function inject_upfront_dependencies()
    {
        if (!Upfront_Permissions::current(Upfront_Permissions::BOOT)) {
            return false;
        }
        // Do not inject for users that can't use this
        $url = self::get_root_url();
        //Boot Edit Mode if the querystring contains the editmode param
        if (isset($_GET['editmode'])) {
            echo upfront_boot_editor_trigger();
        }
        $storage_key = apply_filters('upfront-data-storage-key', Upfront_Layout::STORAGE_KEY);
        $save_storage_key = $storage_key;
        $is_ssl = is_ssl() ? '&ssl=1' : '';
        if (isset($_GET['dev']) && current_user_can('switch_themes') && apply_filters('upfront-enable-dev-saving', true)) {
            $save_storage_key .= '_dev';
        }
        $script_urls = array("{$url}/scripts/require.js", admin_url('admin-ajax.php?action=upfront_load_main' . $is_ssl), "{$url}/scripts/main.js");
        $deps = Upfront_CoreDependencies_Registry::get_instance();
        foreach ($script_urls as $url) {
            $deps->add_script($url);
        }
        echo '<script type="text/javascript">
			var _upfront_post_data=' . json_encode(array('layout' => Upfront_EntityResolver::get_entity_ids(), 'post_id' => is_singular() ? apply_filters('upfront-data-post_id', get_the_ID()) : false)) . ';
			var _upfront_storage_key = "' . $storage_key . '";
			var _upfront_save_storage_key = "' . $save_storage_key . '";
			var _upfront_stylesheet = "' . get_stylesheet() . '";
			var _upfront_debug_mode = ' . (int) isset($_GET['debug']) . ';
			var _upfront_please_hold_on = ' . json_encode(__('Please, hold on for just a little bit more', 'upfront')) . ';
		</script>';
        echo <<<EOAdditivemarkup
\t<div id="sidebar-ui" class="upfront-ui"></div>
\t<div id="settings" style="display:none"></div>
\t<div id="contextmenu" style="display:none"></div>
EOAdditivemarkup;
        do_action('upfront-core-inject_dependencies');
    }
 /**
  * Builds preview layout model and dispatches save.
  */
 public function build_preview()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE) && !Upfront_Permissions::current(Upfront_Permissions::SAVE_REVISION)) {
         $this->_reject();
     }
     global $post;
     $raw_data = stripslashes_deep($_POST);
     $data = !empty($raw_data['data']) ? $raw_data['data'] : '';
     $current_url = !empty($raw_data['current_url']) ? $raw_data['current_url'] : home_url();
     $current_url = wp_validate_redirect(wp_sanitize_redirect($current_url), false);
     $current_url = $current_url ? $current_url : home_url();
     $layout = Upfront_Layout::from_json($data);
     $layout_id_key = $this->_data->save_revision($layout);
     // Check concurrent edits from other users
     $current_user_id = get_current_user_id();
     $current_others_revisions = $this->_data->get_entity_revisions($layout->get_cascade(), array('date_query' => array(array('after' => "-15 minutes")), 'author__not_in' => array($current_user_id)));
     $concurrent_users = array();
     if (!empty($current_others_revisions)) {
         foreach ($current_others_revisions as $rvsn) {
             if (empty($rvsn->post_author)) {
                 continue;
             }
             $user = get_user_by('id', $rvsn->post_author);
             if (empty($user) || empty($user->ID)) {
                 continue;
             }
             $concurrent_users[$user->ID] = $user->display_name;
         }
     }
     $preview_url = remove_query_arg('editmode', add_query_arg(array(self::HOOK => $layout_id_key), $current_url));
     $this->_out(new Upfront_JsonResponse_Success(array('html' => $preview_url, 'concurrent_users' => $concurrent_users)));
 }
Пример #22
0
 function create_image_size()
 {
     $data = stripslashes_deep($_POST);
     if (!$data['images']) {
         return $this->_out(new Upfront_JsonResponse_Error(Upfront_UimageView::_get_l10n('no_images')));
     }
     @ini_set('memory_limit', apply_filters('upfront_memory_limit', WP_MAX_MEMORY_LIMIT));
     $images = array();
     foreach ($data['images'] as $imageData) {
         if (!$imageData['id']) {
             continue;
         }
         //return $this->_out(new Upfront_JsonResponse_Error("Invalid image ID"));
         //if(!current_user_can('edit_post', $imageData['id']) ){
         if (!Upfront_Permissions::current(Upfront_Permissions::RESIZE, $imageData['id'])) {
             $images[$imageData['id']] = array('error' => true, 'msg' => Upfront_UimageView::_get_l10n('not_allowed'));
             continue;
             //wp_die( -1 );
         }
         $image = get_post($imageData['id']);
         if ($image instanceof WP_Post && $image->post_mime_type == 'image/gif') {
             //Gif are not really resized/croped to preserve animations
             $imageAttrs = wp_get_attachment_image_src($imageData['id'], 'full');
             $images[$imageData['id']] = $this->get_resized_gif_data($imageData, $imageAttrs);
         } else {
             $rotate = isset($imageData['rotate']) && is_numeric($imageData['rotate']) ? $imageData['rotate'] : false;
             $resize = isset($imageData['resize']) ? $imageData['resize'] : false;
             $crop = isset($imageData['crop']) ? $imageData['crop'] : false;
             $images[$imageData['id']] = $this->resize_image($imageData);
         }
     }
     return $this->_out(new Upfront_JsonResponse_Success(array('images' => $images)));
 }
Пример #23
0
 function update_insertcount()
 {
     if (!Upfront_Permissions::current(Upfront_Permissions::SAVE)) {
         $this->_reject();
     }
     $insertcount = get_option('ueditor_insert_count');
     if (!$insertcount) {
         $insertcount = 0;
     }
     $insertcount++;
     update_option('ueditor_insert_count', $insertcount);
     $this->_out(new Upfront_JsonResponse_Success("Insert count updated"));
 }
    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));
    }