Changeset 1684796
- Timestamp:
- 06/24/2017 04:46:22 PM (9 years ago)
- Location:
- optimality/trunk
- Files:
-
- 7 edited
-
index.php (modified) (8 diffs)
-
markup/comment.php (modified) (1 diff)
-
markup/page.php (modified) (3 diffs)
-
markup/post.php (modified) (5 diffs)
-
markup/script.php (modified) (3 diffs)
-
markup/style.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
optimality/trunk/index.php
r1683276 r1684796 5 5 * Plugin URI: https://wordpress.org/plugins/optimality 6 6 * Description: Optimizes website's content delivery, images, database, permalink structure, search engines and social media markup. 7 * Version: 0. 2.07 * Version: 0.3.0 8 8 * License: GPLv2 or later 9 9 * Author: Optimality … … 33 33 class Plugin 34 34 { 35 const WIDGET = 'widget'; 36 35 37 protected $preset; 36 38 protected $option; … … 48 50 $this->option = array_merge($this->preset = 49 51 [ 52 Html::CUSTOM => NULL, 53 Plugin::WIDGET => 'on', 54 50 55 Html::UNMETA => NULL, 51 56 Html::UNEMOJ => NULL, 52 57 Html::PREDNS => NULL, 53 58 Html::MINIFY => NULL, 54 Html::CUSTOM => NULL,55 59 Style::MINIFY => NULL, 56 60 Style::CDNLIB => NULL, … … 72 76 Section::UNBASE => NULL, 73 77 Comment::UNLINK => NULL, 78 Comment::UNPAGE => NULL, 74 79 User::UNLINK => NULL, 75 80 Media::UNLINK => NULL, … … 272 277 273 278 274 add_action('admin_bar_menu', function($widget)279 @$this->option[Plugin::WIDGET] && add_action('admin_bar_menu', function($widget) 275 280 { 276 281 $this->addWidget($widget, NULL, ucwords(__NAMESPACE__ ), $this->urlPlugin()); … … 310 315 register_setting(__NAMESPACE__, __NAMESPACE__, array( $this, 'onSubmit' )); 311 316 317 $this->addModule($module = 'gen', __('General Settings' )); 318 $this->addOption(Html::CUSTOM , __('Custom HTML' ), $module, 'editor', __('This code will be injected into the head section of every HTML page.')); 319 $this->addOption(Plugin::WIDGET , __('Admin Bar Menu' ), $module, 'binary', __('Display a menu on the Admin Bar when browsing as admin.')); 320 312 321 $this->addModule($module = 'cdo', __('Content Delivery' )); 313 322 $this->addOption(Html::UNMETA , __('Clean Meta Tags' ), $module, 'binary', __('Remove unnecessary meta tags from the head section of HTML.')); … … 315 324 $this->addOption(Html::PREDNS , __('Prefetch DNS' ), $module, 'binary', __('Reduce DNS lookup time by pre-resolving all external domains.')); 316 325 $this->addOption(Html::MINIFY , __('Optimize HTML' ), $module, 'binary', __('Remove comments, unnecessary whitespace and empty nodes.')); 317 $this->addOption(Html::CUSTOM , __('Custom HTML' ), $module, 'editor', __('This code will be injected into the head section of every HTML page.'));318 326 $this->addOption(Style::MINIFY , __('Optimize Styles' ), $module, 'binary', __('Combine files, flatten imports, remove comments and cache.')); 319 327 $this->addAction(Style::MINIFY , __('Clean Style Cache' ), 'trash', [Style::class, 'cleanCache'], [Style::class, 'countCache']); … … 350 358 $this->addOption(Media::UNLINK , __('Disable Attachments' ), $module, 'binary', __('Redirect image attachment pages to the URL of the parent page.')); 351 359 $this->addOption(Comment::UNLINK, __('Disable Reply Queries'), $module, 'binary', __('Redirect ?replytocom=id to #comment-id in comment replies.')); 360 $this->addOption(Comment::UNPAGE, __('Depaginate Comments' ), $module, 'binary', __('Redirect paginated comments to the URL of the parent page.')); 352 361 353 362 $this->addModule($module = 'seo', __('Search Engines' )); -
optimality/trunk/markup/comment.php
r1683276 r1684796 9 9 const DBMETA = 'comment_dbmeta'; 10 10 const UNLINK = 'comment_unlink'; 11 const UNPAGE = 'comment_unpage'; 11 12 const SEMETA = 'comment_semeta'; 12 13 const SENAME = 'comment_sename'; -
optimality/trunk/markup/page.php
r1683276 r1684796 11 11 const SMNAME = 'page_smname'; 12 12 const SMDESC = 'page_smdesc'; 13 14 public $notes; 13 15 14 16 … … 27 29 $this->edit = date(DATE_W3C, strtotime($object->post_modified)); 28 30 $this->user = $object->post_author; 31 $this->notes = intval($object->comment_count); 29 32 } 30 33 … … 43 46 44 47 48 function apply($target, $option) 49 { 50 if (@$option[Comment::UNLINK]) 51 { 52 if ($source = @$_GET['replytocom']) 53 { 54 return Comment::route(NULL, $source); 55 } 56 } 57 58 if (@$option[Comment::UNPAGE]) 59 { 60 if (get_query_var('cpage')) 61 { 62 return $this->route; 63 } 64 } 65 66 return parent::apply($target, $option); 67 } 68 69 45 70 static function fetch() 46 71 { -
optimality/trunk/markup/post.php
r1683276 r1684796 3 3 namespace optimality; 4 4 5 class Post extends Html5 class Post extends Page 6 6 { 7 7 const DBAUTO = 'post_dbauto'; … … 17 17 public $section; 18 18 public $terms = []; 19 public $notes;20 19 21 20 … … 25 24 26 25 $this->type = 'Article'; 27 $this->ruid = $object->ID;28 $this->slug = $object->post_name;29 $this->name = $object->post_title;30 $this->lead = $object->post_excerpt;31 $this->image = get_the_post_thumbnail_url($object, 'full');32 $this->route = get_page_link($object);33 $this->date = date(DATE_W3C, strtotime($object->post_date));34 $this->edit = date(DATE_W3C, strtotime($object->post_modified));35 $this->user = $object->post_author;36 $this->notes = intval($object->comment_count);37 26 } 38 27 … … 54 43 return array_merge(parent::getMeta($option), 55 44 [ 56 'og:type' => 'article',57 'article:published_time' => $this->date,58 'article:modified_time' => $this->edit,59 'article:author' => $this->user->face,60 'article:publisher' => $this->site->face,61 45 'article:section' => $this->section, 62 46 'article:tag' => $this->terms, … … 67 51 function apply($target, $option) 68 52 { 69 if (@$option[Comment::UNLINK])70 {71 if ($source = @$_GET['replytocom'])72 {73 return Comment::route(NULL, $source);74 }75 }76 77 53 if (is_array($result = get_the_terms($this->ruid, 'category'))) 78 54 { -
optimality/trunk/markup/script.php
r1683276 r1684796 30 30 ]; 31 31 32 static $ export=32 static $hoster = 33 33 [ 34 'backbone' => 'https://cdnjs.cloudflare.com/ajax/libs/backbone.js/%s/backbone-min.js', 35 'bootstrap' => 'https://maxcdn.bootstrapcdn.com/bootstrap/%s/js/bootstrap.min.js', 36 'device' => 'https://cdnjs.cloudflare.com/ajax/libs/device.js/0.2.7/device.min.js', 37 'hoverIntent' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery.hoverintent/%s/jquery.hoverIntent.min.js', 38 'jquery-color' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery-color/%s/jquery.color.min.js', 34 39 'jquery-core' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery/%s/jquery.min.js', 40 'jquery-form' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery.form/%s/jquery.form.min.js', 35 41 'jquery-migrate' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/%s/jquery-migrate.min.js', 42 'masonry' => 'https://cdnjs.cloudflare.com/ajax/libs/masonry/%s/masonry.pkgd.min.js', 36 43 'mediaelement' => 'https://cdnjs.cloudflare.com/ajax/libs/mediaelement/%s/mediaelement-and-player.min.js', 37 'device' => 'https://cdnjs.cloudflare.com/ajax/libs/device.js/0.2.7/device.min.js', 38 'bootstrap' => 'https://maxcdn.bootstrapcdn.com/bootstrap/%s/js/bootstrap.min.js', 44 'schedule' => 'https://cdnjs.cloudflare.com/ajax/libs/schedulejs/%s/schedule.min.js', 45 'swfobject' => 'https://cdnjs.cloudflare.com/ajax/libs/swfobject/%s/swfobject.min.js', 46 'tiny_mce' => 'https://cdnjs.cloudflare.com/ajax/libs/tinymce/%s/tinymce.min.js', 47 'underscore' => 'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/%s/underscore-min.js', 39 48 ]; 40 49 … … 95 104 private function bundle($target) 96 105 { 106 $stream = stream_context_create( 107 [ 108 'ssl' => array('verify_peer' => false, 'verify_peer_name' => false), 109 ]); 110 97 111 $import = 'import \s* " ([^"]+) " \s* ;'; 98 112 99 return preg_replace_callback("/$import/ix", function($result) 113 return preg_replace_callback("/$import/ix", function($result) use($stream) 100 114 { 101 if ($string = @file_get_contents($source = $result[1] ))115 if ($string = @file_get_contents($source = $result[1], false, $stream)) 102 116 { 103 117 return (new static([$string]))->bundle($source); … … 110 124 static function serve($source, $handle) 111 125 { 112 if (($target = @static::$ export[$handle]) && ($offset = strpos($source, '?ver=')))126 if (($target = @static::$hoster[$handle]) && ($offset = strpos($source, '?ver='))) 113 127 { 114 128 return sprintf($target, substr($source, $offset + 5)); -
optimality/trunk/markup/style.php
r1683276 r1684796 22 22 ]; 23 23 24 static $ export=24 static $hoster = 25 25 [ 26 ' mediaelement' => 'https://cdnjs.cloudflare.com/ajax/libs/mediaelement/%s/mediaelementplayer.min.css',26 'animate' => 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/%s/animate.min.css', 27 27 'bootstrap' => 'https://maxcdn.bootstrapcdn.com/bootstrap/%s/css/bootstrap.min.css', 28 28 'font-awesome' => 'https://maxcdn.bootstrapcdn.com/font-awesome/%s/css/font-awesome.min.css', 29 'materialize' => 'https://cdnjs.cloudflare.com/ajax/libs/materialize/%s/css/materialize.min.css', 30 'mediaelement' => 'https://cdnjs.cloudflare.com/ajax/libs/mediaelement/%s/mediaelementplayer.min.css', 31 'normalize' => 'https://cdnjs.cloudflare.com/ajax/libs/normalize/%s/normalize.min.css', 32 'skeleton' => 'https://cdnjs.cloudflare.com/ajax/libs/skeleton/%s/skeleton.min.css', 29 33 ]; 30 34 … … 97 101 private function bundle($target) 98 102 { 103 $stream = stream_context_create( 104 [ 105 'ssl' => array('verify_peer' => false, 'verify_peer_name' => false), 106 ]); 107 99 108 $import = '@import \s* url \( [\'"]? ([^\'"\)]+) [\'"]? \) \s* ([^;]*) \s* ;'; 100 109 101 return preg_replace_callback("/$import/ix", function($result) 110 return preg_replace_callback("/$import/ix", function($result) use($stream) 102 111 { 103 if ($string = @file_get_contents($source = $result[1] ))112 if ($string = @file_get_contents($source = $result[1], false, $stream)) 104 113 { 105 114 $string = (new static([$string]))->bundle($source); … … 134 143 static function serve($source, $handle) 135 144 { 136 if (($target = @static::$ export[$handle]) && ($offset = strpos($source, '?ver=')))145 if (($target = @static::$hoster[$handle]) && ($offset = strpos($source, '?ver='))) 137 146 { 138 147 return sprintf($target, substr($source, $offset + 5)); -
optimality/trunk/readme.txt
r1683808 r1684796 76 76 == Changelog == 77 77 78 = 0.3.0 = 79 * Feature: Added option to disable Admin Bar menu 80 * Feature: Moved custom HTML to general settings 81 * Feature: Redirect paginated comment pages to their parent 82 * Feature: More CDN providers for popular JS/CSS libraries 83 * Feature: Ignore SSL errors on self signed SSL certificates 84 78 85 = 0.2.0 = 79 * Feature: Extended the mapping ofpopular JS/CSS libraries86 * Feature: More CDN providers for popular JS/CSS libraries 80 87 * Feature: +10% reduction in filesize of PNG thumbnails 81 88
Note: See TracChangeset
for help on using the changeset viewer.