Plugin Directory

Changeset 1688620


Ignore:
Timestamp:
07/01/2017 06:44:58 AM (9 years ago)
Author:
optimality
Message:

Minor bug fixes.

Location:
optimality/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • optimality/trunk/index.php

    r1688504 r1688620  
    147147        register_deactivation_hook(__FILE__, function()
    148148        {
    149             wp_clear_scheduled_hook( __NAMESPACE__ );
    150             Style::cleanCache(); Script::cleanCache(); Html::cleanCache();
     149            wp_clear_scheduled_hook( __NAMESPACE__ ); $this->onReboot();
    151150        });
    152151
     
    164163        });
    165164
     165        add_action('switch_theme', [$this, 'onReboot']);
     166
    166167        if (isset($this->option[Image::MINIFY]))
    167168        {
     
    169170        }
    170171
    171         call_user_func([ $this, '__construct' .
    172             (is_admin() ? 'Admin' : 'Front') ]);
     172        call_user_func([ $this, '__construct' . (is_admin() ? 'Admin' : 'Front') ]);
    173173    }
    174174
     
    263263            }
    264264
     265            $markup = new $markup(get_queried_object());
     266
     267            if ($target = $markup(__TARGET__, $this->option))
     268            {
     269                wp_redirect($target, 301); exit();
     270            }
     271
    265272            $ishtml = preg_grep(Html::HEADER, headers_list());
    266273            $method = strtoupper(@$_SERVER['REQUEST_METHOD']);
     
    270277                !is_user_logged_in() && !defined('DOING_CRON'))
    271278            {
    272                 Html::serve(@$_SERVER['HTTP_ACCEPT_ENCODING']);
    273             }
    274 
    275             $markup = new $markup(get_queried_object());
    276 
    277             if ($target = $markup(__TARGET__, $this->option))
    278             {
    279                 wp_redirect($target, 301); exit();
     279                $markup->serve(@$_SERVER['HTTP_ACCEPT_ENCODING']);
    280280            }
    281281
     
    675675        return $option;
    676676    }
     677
     678
     679    function onReboot()
     680    {
     681        Style::cleanCache();
     682        Script::cleanCache();
     683        Html::cleanCache();
     684    }
    677685}
    678686
  • optimality/trunk/markup/html.php

    r1688504 r1688620  
    219219    {
    220220        $this->preserveWhiteSpace = !isset($option[static::MINIFY]);
    221         @$this->loadHTML($string, LIBXML_COMPACT | LIBXML_NOBLANKS);
     221
     222        if (!@$this->loadHTML($string, LIBXML_COMPACT|LIBXML_NOBLANKS))
     223        {
     224            return $string;
     225        }
    222226
    223227        $schema = new \DOMXPath($this); $linked = [ ];
     
    469473        if ($string = $this->build($string, $option))
    470474        {
    471             $handle = sprintf('~%s.html', md5(__TARGET__));
     475            $handle = sprintf('~%s.html', md5($this->route));
    472476
    473477            file_put_contents($target = __CDNDIR__ . $handle, $string);
     
    479483
    480484
    481     static function serve($accept)
    482     {
    483         $source = sprintf(__CDNDIR__ . '~%s.html', md5( __TARGET__ ));
     485    function serve($accept)
     486    {
     487        $source = sprintf(__CDNDIR__ . '~%s.html', md5($this->route));
    484488
    485489        if ($encode = $accept && (strpos($accept, 'gzip') !== false))
  • optimality/trunk/markup/sitemap.php

    r1688504 r1688620  
    112112
    113113
     114    function cache($string, $option)
     115    {
     116        return $this->build($string, $option);
     117    }
     118
     119
     120    function serve($accept)
     121    {
     122        return false;
     123    }
     124
     125
    114126    static function ping()
    115127    {
Note: See TracChangeset for help on using the changeset viewer.