protected function _out(Upfront_HttpResponse $out)
 {
     if (!$this->_debugger->is_active(Upfront_Debug::RESPONSE) && extension_loaded('zlib') && Upfront_OutputBehavior::has_compression()) {
         ob_start('ob_gzhandler');
     }
     status_header($out->get_status());
     header("Content-type: " . $out->get_content_type() . "; charset=utf-8");
     die($out->get_output());
 }
 private function _add_hooks()
 {
     $this->_cache = Upfront_Cache::get_instance(Upfront_Cache::TYPE_LONG_TERM);
     if (Upfront_OutputBehavior::has_experiments()) {
         add_filter('upfront-experiments-styles-debounce_dependency_load', array($this, 'add_style_load_url'));
         add_filter('upfront-experiments-scripts-debounce_dependency_load', array($this, 'add_script_load_url'));
     } else {
         add_action('upfront-layout-applied', array($this, 'load_styles'));
         add_action('upfront-layout-applied', array($this, 'load_scripts'));
     }
     upfront_add_ajax('upfront-element-styles', array($this, 'serve_styles'));
     upfront_add_ajax_nopriv('upfront-element-styles', array($this, 'serve_styles'));
     upfront_add_ajax('upfront-element-scripts', array($this, 'serve_scripts'));
     upfront_add_ajax_nopriv('upfront-element-scripts', array($this, 'serve_scripts'));
 }
 private static function _parse_experiments()
 {
     if (empty(self::$_experiments) && defined('UPFRONT_EXPERIMENTS_ON') && UPFRONT_EXPERIMENTS_ON) {
         $level = UPFRONT_EXPERIMENTS_ON;
         if (in_array($level, array(1, '1', true), true)) {
             self::$_experiments = self::LEVEL_DEFAULT;
         } else {
             self::$_experiments = $level;
         }
     }
 }
Example #4
0
 public function inject_core_wp_dependencies()
 {
     $deps = Upfront_CoreDependencies_Registry::get_instance();
     if (Upfront_OutputBehavior::has_experiments()) {
         if (defined('DOING_AJAX') && DOING_AJAX) {
             $deps->add_wp_script('jquery-ui-core');
             $deps->add_wp_script('jquery-ui-widget');
             $deps->add_wp_script('jquery-ui-mouse');
             $deps->add_wp_script('jquery-effects-core');
             $deps->add_wp_script('jquery-effects-slide');
             $deps->add_wp_script('jquery-ui-draggable');
             $deps->add_wp_script('jquery-ui-droppable');
             $deps->add_wp_script('jquery-ui-resizable');
             $deps->add_wp_script('jquery-ui-selectable');
             $deps->add_wp_script('jquery-ui-sortable');
             $deps->add_wp_script('jquery-ui-slider');
             $deps->add_wp_script('jquery-ui-datepicker');
         } else {
             $deps->add_script(admin_url('admin-ajax.php?action=wp_scripts'));
         }
     } else {
         // Non-experiments load
         wp_enqueue_script('jquery-ui-core');
         wp_enqueue_script('jquery-effects-core');
         wp_enqueue_script('jquery-effects-slide');
         wp_enqueue_script('jquery-ui-draggable');
         wp_enqueue_script('jquery-ui-droppable');
         wp_enqueue_script('jquery-ui-resizable');
         wp_enqueue_script('jquery-ui-selectable');
         wp_enqueue_script('jquery-ui-sortable');
         wp_enqueue_script('jquery-ui-slider');
         wp_enqueue_script('jquery-ui-datepicker');
     }
 }