Skip to content

Commit 949ca7d

Browse files
committed
Initial.
0 parents  commit 949ca7d

15 files changed

+568
-0
lines changed

Diff for: .editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# From http://stackoverflow.com/a/33831598/664741
2+
3+
root = true
4+
5+
# Unix-style newlines with a newline ending every file
6+
[*]
7+
end_of_line = lf
8+
insert_final_newline = true
9+
10+
# Matches multiple files with brace expansion notation
11+
# Set default charset
12+
[*.{js,php}]
13+
charset = utf-8
14+
indent_style = tab
15+
indent_size = 4
16+
trim_trailing_whitespace = true

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.*.swp
2+
node_modules
3+
*.mo
4+
log

Diff for: Gruntfile.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module.exports = function( grunt ) { //The wrapper function
2+
3+
require( 'load-grunt-tasks' )( grunt );
4+
5+
// Project configuration & task configuration
6+
grunt.initConfig( {
7+
pkg: grunt.file.readJSON( 'package.json' ),
8+
9+
wp_readme_to_markdown: {
10+
convert:{
11+
files: {
12+
'README.md': 'readme.txt'
13+
},
14+
options: {
15+
'screenshot_url': 'https://github.com/gitlost/{plugin}/raw/master/assets/{screenshot}.png', //'https://ps.w.org/{plugin}/assets/{screenshot}.png'
16+
}
17+
}
18+
},
19+
20+
compress: {
21+
main: {
22+
options: {
23+
archive: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip',
24+
mode: 'zip'
25+
},
26+
files: [
27+
{
28+
src: [
29+
'../ye-olde-text-widget/readme.txt',
30+
'../ye-olde-text-widget/ye-olde-text-widget.php',
31+
'../ye-olde-text-widget/includes/class-yotw-widget-text.php'
32+
]
33+
}
34+
]
35+
}
36+
},
37+
38+
} );
39+
40+
// Default task(s), executed when you run 'grunt'
41+
grunt.registerTask( 'default', [ 'wp_readme_to_markdown', 'compress' ] );
42+
};

Diff for: LICENSE

+339
Large diffs are not rendered by default.

Diff for: README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Ye Olde Text Widget #
2+
**Contributors:** [gitlost](https://profiles.wordpress.org/gitlost)
3+
**Tags:** Text Widget, Widget
4+
**Requires at least:** 4.8.0
5+
**Tested up to:** 4.8.0
6+
**Stable tag:** 1.0.0
7+
**License:** GPLv2 or later
8+
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
9+
10+
Restores the Text Widget to as it was prior to WordPress 4.8.0.
11+
12+
## Description ##
13+
14+
It fairly minimal way to restore old behaviour.
15+
16+
## Installation ##
17+
18+
Install the plugin in the standard way via the 'Plugins' menu in WordPress and then activate.
19+
20+
## Changelog ##
21+
22+
### 1.0.0 ###
23+
* Initial github release.
24+
25+
## Upgrade Notice ##

Diff for: assets/banner-772x250.png

149 KB
Loading

Diff for: assets/banner-772x250.xcf

609 KB
Binary file not shown.

Diff for: assets/icon-128x128.png

14 KB
Loading

Diff for: assets/icon-256x256.png

43 KB
Loading

Diff for: assets/icon-256x256.xcf

90.9 KB
Binary file not shown.

Diff for: dist/ye-olde-text-widget-1.0.0.zip

2.54 KB
Binary file not shown.

Diff for: includes/class-yotw-widget-text.php

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
class YOTW_Widget_Text extends WP_Widget_Text {
4+
// Copy and paste from 4.7.5 WP_Widget_text::form().
5+
public function form( $instance ) {
6+
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
7+
$filter = isset( $instance['filter'] ) ? $instance['filter'] : 0;
8+
$title = sanitize_text_field( $instance['title'] );
9+
?>
10+
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
11+
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
12+
13+
<p><label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
14+
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo esc_textarea( $instance['text'] ); ?></textarea></p>
15+
16+
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox"<?php checked( $filter ); ?> />&nbsp;<label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p>
17+
<?php
18+
}
19+
}

Diff for: package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "ye-olde-text-widget",
3+
"version": "1.0.0",
4+
"description": "Uses Ghostscript directly to generate PDF previews.",
5+
"repository": {
6+
"type": "git",
7+
"url": "git://github.com/gitlost/ye-olde-text-widget"
8+
},
9+
"author": "gitlost",
10+
"license": "GPL-2.0",
11+
"devDependencies": {
12+
"grunt": "^0.4.5",
13+
"grunt-contrib-compress": "^1.3.0",
14+
"grunt-wp-readme-to-markdown": "~2.0.0",
15+
"gulp": "^3.9.1",
16+
"load-grunt-tasks": "^3.5.0"
17+
}
18+
}

Diff for: readme.txt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
=== Ye Olde Text Widget ===
2+
Contributors: gitlost
3+
Tags: Text Widget, Widget
4+
Requires at least: 4.8.0
5+
Tested up to: 4.8.0
6+
Stable tag: 1.0.0
7+
License: GPLv2 or later
8+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9+
10+
Restores the Text Widget to as it was prior to WordPress 4.8.0.
11+
12+
== Description ==
13+
14+
It fairly minimal way to restore old behaviour.
15+
16+
== Installation ==
17+
18+
Install the plugin in the standard way via the 'Plugins' menu in WordPress and then activate.
19+
20+
== Changelog ==
21+
22+
= 1.0.0 =
23+
* Initial github release.
24+
25+
== Upgrade Notice ==

Diff for: ye-olde-text-widget.php

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
/**
3+
* Plugin Name: Ye Olde Text Widget
4+
* Plugin URI: https://github.com/gitlost/ye-olde-text-widget
5+
* Description: Restores the Text Widget to as it was prior to WordPress 4.8.0.
6+
* Version: 1.0.0
7+
* Author: gitlost
8+
* Author URI: https://profiles.wordpress.org/gitlost
9+
* License: GPLv2
10+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
11+
* Text Domain: ye-olde-text-widget
12+
*/
13+
14+
// Exit if accessed directly.
15+
if ( ! defined( 'ABSPATH' ) ) exit;
16+
17+
// These need to be synced with "readme.txt".
18+
define( 'YOTW_PLUGIN_WP_AT_LEAST_VERSION', '4.8.0' );
19+
define( 'YOTW_PLUGIN_WP_UP_TO_VERSION', '4.8.0' );
20+
21+
class Ye_Olde_Text_Widget {
22+
static function activation_hook() {
23+
if ( $msg = self::incompatible() ) {
24+
deactivate_plugins( plugin_basename( __FILE__ ) );
25+
wp_die( $msg );
26+
}
27+
}
28+
29+
static function incompatible() {
30+
global $wp_version;
31+
$stripped_wp_version = substr( $wp_version, 0, strspn( $wp_version, '0123456789.' ) ); // Remove any trailing stuff.
32+
if ( preg_match( '/^[0-9]+\.[0-9]+$/', $stripped_wp_version ) ) {
33+
$stripped_wp_version .= '.0'; // Make WP version x.y.z compat.
34+
}
35+
if ( version_compare( $stripped_wp_version, YOTW_PLUGIN_WP_AT_LEAST_VERSION, '<' ) ) {
36+
return sprintf(
37+
/* translators: %1$s: lowest compatible WordPress version; %2$s: user's current WordPress version; %3$s: url to admin plugins page. */
38+
__( 'The plugin "Ye Olde Text Widget" cannot be activated as it requires WordPress %1$s to work and you have WordPress %2$s. <a href="%3$s">Return to Plugins page.</a>', 'ye-olde-text-widget' ),
39+
YOTW_PLUGIN_WP_AT_LEAST_VERSION, $wp_version, esc_url( self_admin_url( 'plugins.php' ) )
40+
);
41+
}
42+
if ( version_compare( $stripped_wp_version, YOTW_PLUGIN_WP_UP_TO_VERSION, '>' ) ) {
43+
return sprintf(
44+
/* translators: %1$s: highest compatible WordPress version; %2$s: user's current WordPress version; %3$s: url to admin plugins page. */
45+
__( 'The plugin "Ye Olde Text Widget" cannot be activated as it only works up to WordPress %1$s and you have WordPress %2$s. <a href="%3$s">Return to Plugins page.</a>', 'ye-olde-text-widget' ),
46+
YOTW_PLUGIN_WP_UP_TO_VERSION, $wp_version, esc_url( self_admin_url( 'plugins.php' ) )
47+
);
48+
}
49+
return null; // Compatible.
50+
}
51+
52+
static function init() {
53+
remove_filter( 'widget_text_content', 'capital_P_dangit', 11 );
54+
remove_filter( 'widget_text_content', 'wptexturize' );
55+
remove_filter( 'widget_text_content', 'convert_smilies', 20 );
56+
remove_filter( 'widget_text_content', 'wpautop' );
57+
58+
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
59+
}
60+
61+
static function admin_init() {
62+
global $wp_scripts;
63+
if ( $wp_scripts ) {
64+
$wp_scripts->remove( 'text-widgets' );
65+
}
66+
}
67+
68+
static function widgets_init() {
69+
require dirname( __FILE__ ) . '/includes/class-yotw-widget-text.php';
70+
unregister_widget( 'WP_Widget_Text' );
71+
register_widget( 'YOTW_Widget_Text' );
72+
}
73+
}
74+
75+
register_activation_hook( __FILE__, array( 'Ye_Olde_Text_Widget', 'activation_hook' ) );
76+
77+
if ( ! Ye_Olde_Text_Widget::incompatible() ) {
78+
add_action( 'widgets_init', array( 'Ye_Olde_Text_Widget', 'widgets_init' ) );
79+
add_action( 'init', array( 'Ye_Olde_Text_Widget', 'init' ) );
80+
}

0 commit comments

Comments
 (0)