Skip to content

Commit fbf7f2d

Browse files
committed
Release v0.2.0
2 parents bebbe21 + dd727bc commit fbf7f2d

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

include/functions/utilities.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,27 @@ function get_version_hash( $filepath, $length = 7, $alg = 'sha1' )
4949

5050
return $hash;
5151
}
52+
53+
54+
/**
55+
* string minify( string $html )
56+
* Strips extraneous whitespace from a chunk of HTML.
57+
*
58+
* @param string $html The HTML to minify.
59+
*
60+
* @return string The minified HTML.
61+
* ------------------------------------------------------------------------------------------ */
62+
function minify( $html )
63+
{
64+
// Remove whitespace between tags
65+
$html = preg_replace( '/(?<=\>)[\r\n\t]+(?=\<)/', '', $html );
66+
67+
// Restrict whitespace between the beginning/end of a tag and text
68+
$html = preg_replace( '/(?<=\>)[\r\n\t\s]+(?=[^\<])/', ' ', $html );
69+
$html = preg_replace( '/(?<=[^\>])[\r\n\t\s]+(?=\<)/', ' ', $html );
70+
71+
// Remove linebreaks in blocks of text
72+
$html = preg_replace( '/(?<=[^\-\<\>])[\r\n\t\s]+(?=[^\-\<\>])/', ' ', $html );
73+
74+
return $html;
75+
}

include/functions/widgets.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
// -- include/functions/widgets.php
3+
// ---------------------------------------------------------------------------------------------
4+
5+
6+
/**
7+
* void unregister_bloggy_widgets()
8+
* Hooks into widgets_init to get rid of all those bloggy widgets that people only use when
9+
* they're actually using WordPress as a blog platform.
10+
* ------------------------------------------------------------------------------------------ */
11+
function unregister_bloggy_widgets()
12+
{
13+
unregister_widget( 'WP_Widget_Archives' );
14+
unregister_widget( 'WP_Widget_Calendar' );
15+
unregister_widget( 'WP_Widget_Categories' );
16+
unregister_widget( 'WP_Widget_Meta' );
17+
unregister_widget( 'WP_Widget_Pages' );
18+
unregister_widget( 'WP_Widget_Recent_Comments' );
19+
unregister_widget( 'WP_Widget_Recent_Posts' );
20+
unregister_widget( 'WP_Widget_RSS' );
21+
unregister_widget( 'WP_Widget_Search' );
22+
unregister_widget( 'WP_Widget_Tag_Cloud' );
23+
24+
unregister_widget( 'WP_Nav_Menu_Widget' );
25+
}
26+
add_action( 'widgets_init', 'unregister_bloggy_widgets' );

sugar.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Author URI: https://github.com/asmbs
77
* License: MIT License
88
* License URI: http://opensource.org/licenses/MIT
9-
* Version: 0.1.0
9+
* Version: 0.2.0
1010
*/
1111

1212
// Don't forget, plugin_dir_path adds a trailing slash.
@@ -15,5 +15,6 @@
1515
// Include stuff
1616
include_once SUGAR_PATH .'include/functions/template.php';
1717
include_once SUGAR_PATH .'include/functions/utilities.php';
18+
include_once SUGAR_PATH .'include/functions/widgets.php';
1819

1920
// Wait...that's it?!

0 commit comments

Comments
 (0)