Orphans - Version 2.4

Version Description

  • 2015-02-12 =

  • IMPROVEMENT: add hard space between number (year) and polish year shortcut "r."

  • IMPROVEMENT: add WooCommerce product title and short description to available options. thx to Dominik Kawula

Download this release

Release Info

Developer iworks
Plugin Icon 128x128 Orphans
Version 2.4
Comparing to
See all releases

Version 2.4

Files changed (4) hide show
  1. index.php +2 -0
  2. readme.txt +146 -0
  3. sierotki.php +12 -0
  4. vendor/iworks/orphan.php +310 -0
index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ exit;
readme.txt ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Sierotki ===
2
+ Contributors: iworks
3
+ Donate link: http://iworks.pl/donate/sierotki.php
4
+ Tags: sierotki, spójniki, twarda spacja, spójniki
5
+ Requires at least: 3.3
6
+ Tested up to: 4.3
7
+ Stable tag: 2.4
8
+
9
+ Wtyczka poprawia sierotki, tak żeby nie mogły zostać na końcu linii.
10
+
11
+ == Description ==
12
+
13
+ Wtyczka poprawia sierotki, tak żeby nie mogły zostać na końcu linii, zastępując spacje znajdujące się za sierotkami na jedną twardą spację.
14
+
15
+ = EN =
16
+
17
+ Plugin supports some of the grammatical rules of the Polish language.
18
+
19
+ = Asset image =
20
+
21
+ [Manuscript by Muffet, on Flickr](http://www.flickr.com/photos/calliope/306564541/)
22
+
23
+ == Installation ==
24
+
25
+ 1. Upload plugin to the `/wp-content/plugins/` directory.
26
+ 1. Activate the plugin through the 'Plugins' menu in WordPress.
27
+ 1. Configure options 'Apperance' => 'Orphan' (default all options are turn on).
28
+
29
+ == Frequently Asked Questions ==
30
+
31
+ = When this plugin replace spaces? =
32
+
33
+ Plugin works when viewing the content and does not modify your content.
34
+
35
+ = How to use this plugin on custom field? =
36
+
37
+ Use this code:
38
+
39
+ `
40
+ $orphan = new iworks_orphan();
41
+ echo $orphan->replace( get_post_meta($post_id, 'meta_key', true ) );
42
+ `
43
+
44
+ = How to use this plugin on any string? =
45
+
46
+ Use this code:
47
+
48
+ `
49
+ $orphan = new iworks_orphan();
50
+ echo $orphan->replace( 'any_string' );
51
+ `
52
+
53
+
54
+ == Screenshots ==
55
+
56
+ 1. Opcje Sierotek
57
+ 1. Orphan Options
58
+
59
+ == Changelog ==
60
+
61
+ = 2.4 - 2015-02-12 =
62
+
63
+ * IMPROVEMENT: add hard space between number (year) and polish year shortcut "r."
64
+ * IMPROVEMENT: add WooCommerce product title and short description to available options. thx to [Dominik Kawula](https://www.facebook.com/dominik.kawula)
65
+
66
+ = 2.3.2 - 2014-09-12 =
67
+
68
+ * BUGFIX: fixed error in options array
69
+
70
+ = 2.3.1 - 2014-09-12 =
71
+
72
+ * BUGFIX: check option array for non existing hash.
73
+ * IMPROVEMENT: update screenshot.
74
+
75
+ = 2.3 - 2014-07-10 =
76
+
77
+ * IMPROVEMENT: add all forms of word number
78
+
79
+ = 2.2 - 2014-01-24 =
80
+
81
+ * IMPROVEMENT:add links to forum
82
+ * IMPROVEMENT:checked capability with WP 3.8
83
+
84
+ = 2.1 - 2013-11-09 =
85
+
86
+ * IMPROVEMENT:checked capability with WP 3.6
87
+ * REFACTORING: implement PSR-0 rules to orphan class
88
+
89
+ = 2.0.2 - 2013-08-20 =
90
+
91
+ * BUGFIX: fixed replacement for single letter orphan after orphan thx to [Szymon Skulimowski](http://wpninja.pl/autorzy/szymon-skulimowski/)
92
+ * IMPROVEMENT:checked capability with WP 3.6
93
+ * IMPROVEMENT:added help and related section
94
+
95
+ = 2.0.1 - 2013-07-10 =
96
+
97
+ * IMPROVEMENT:add numbers
98
+
99
+ = 2.0 - 2012-08-12 =
100
+
101
+ * BUGFIX: fixed permissions to configuration page
102
+ * BUGFIX: fixed replacement for strings starting with a orphan
103
+ * REFACTORING: rewrite code to the class
104
+ * IMPROVEMENT:add some shorts of academic degree
105
+ * IMPROVEMENT:massive increase orphans dictionary thx to [adpawl](http://podbabiogorze.info.pl)
106
+
107
+ = 1.4.2 - 2012-03-02 =
108
+
109
+ * NEW: Add the_title filter.
110
+
111
+ = 1.4.1 - 2011-02-24 =
112
+
113
+ * NEW: Trim chars.
114
+ * BUGFIX: Fixed multi coma use.
115
+
116
+ = 1.4 - 2011-02-24 =
117
+
118
+ * NEW: Added user defined orphans.
119
+ * BUGFIX: Corrected capability name.
120
+
121
+ = 1.3 - 2011-02-19 =
122
+
123
+ * NEW: Added option page to turn on/off filtering in content, excerpt or comments.
124
+ * NEW: Added "(" as char before a orphan.
125
+
126
+ = 1.2 - 2011-02-18 =
127
+
128
+ * NEW: Added filter comment_text.
129
+ * BUGFIX: Capital letters was missing by plugin.
130
+
131
+ = 1.1 - 2011-02-17 =
132
+
133
+ * Abandoning elegant anonymous function, which requires PHP 5.3.0 :(
134
+ * NEW: Added filter to the_excerpt.
135
+
136
+ = 1.0.2 - 2011-02-17 =
137
+
138
+ * NEW: Added ">" as char before a orphan.
139
+
140
+ = 1.0.1 - 2011-02-16 =
141
+
142
+ * NEW: Added word "to".
143
+
144
+ = 1.0 - 2011-02-16 =
145
+
146
+ * INIT
sierotki.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Sierotki
4
+ Plugin URI: http://iworks.pl/2011/02/16/sierotki/
5
+ Description: Wtyczka zamienia leżące za sierotkami spacje w jedną twardą.
6
+ Author: Marcin Pietrzak
7
+ Version: 2.4
8
+ Author URI: http://iworks.pl/
9
+ */
10
+
11
+ require_once( dirname(__FILE__)).'/vendor/iworks/orphan.php';
12
+ new iworks_orphan();
vendor/iworks/orphan.php ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Sierotki
4
+ Plugin URI: http://iworks.pl/2011/02/16/sierotki/
5
+ Description: Wtyczka zamienia leżące za sierotkami spacje w jedną twardą.
6
+ Author: Marcin Pietrzak
7
+ Version: trunk
8
+ Author URI: http://iworks.pl/
9
+ */
10
+
11
+ class iworks_orphan
12
+ {
13
+ private $options;
14
+ private $admin_page;
15
+
16
+ public function __construct()
17
+ {
18
+ /**
19
+ * l10n
20
+ */
21
+ load_plugin_textdomain( 'iworks_orphan', false, dirname( plugin_basename( dirname(dirname(__FILE__))) ).'/languages' );
22
+
23
+ /**
24
+ * actions
25
+ */
26
+ add_action( 'init', array( &$this, 'init' ) );
27
+ add_action( 'admin_init', array( &$this, 'admin_init' ) );
28
+ add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
29
+
30
+ /**
31
+ * options
32
+ */
33
+ $this->options = array (
34
+ 'comment_text' => array(
35
+ 'description' => __( 'Use for comments:',
36
+ 'iworks_orphan' ),
37
+ 'type' => 'checkbox',
38
+ 'label' => __('Enabled the substitution of orphans in the comments.', 'iworks_orphan'),
39
+ 'sanitize_callback' => 'absint',
40
+ ),
41
+ 'the_title' => array(
42
+ 'description' => __( 'Use for post title:',
43
+ 'iworks_orphan' ),
44
+ 'type' => 'checkbox',
45
+ 'label' => __('Enabled the substitution of orphans in the post_title.', 'iworks_orphan'),
46
+ 'sanitize_callback' => 'absint',
47
+ ),
48
+ 'the_excerpt' => array(
49
+ 'description' => __( 'Use for excerpt:',
50
+ 'iworks_orphan' ),
51
+ 'type' => 'checkbox',
52
+ 'label' => __('Enabled the substitution of orphans in the excerpt.', 'iworks_orphan'),
53
+ 'sanitize_callback' => 'absint',
54
+ ),
55
+ 'the_content' => array(
56
+ 'description' => __( 'Use for content:',
57
+ 'iworks_orphan' ),
58
+ 'type' => 'checkbox',
59
+ 'label' => __('Enabled the substitution of orphans in the content.', 'iworks_orphan'),
60
+ 'sanitize_callback' => 'absint',
61
+ ),
62
+ 'woocommerce_product_title' => array(
63
+ 'description' => __( 'Use for WooCommerce product title:',
64
+ 'iworks_orphan' ),
65
+ 'type' => 'checkbox',
66
+ 'label' => __('Enabled the substitution of orphans in the WooCommerce product title.', 'iworks_orphan'),
67
+ 'sanitize_callback' => 'absint',
68
+ ),
69
+ 'woocommerce_short_description' => array(
70
+ 'description' => __( 'Use for WooCommerce short description:',
71
+ 'iworks_orphan' ),
72
+ 'type' => 'checkbox',
73
+ 'label' => __('Enabled the substitution of orphans in the WooCommerce short description.', 'iworks_orphan'),
74
+ 'sanitize_callback' => 'absint',
75
+ ),
76
+ 'own_orphans' => array(
77
+ 'description' => __( 'User definied orphans:',
78
+ 'iworks_orphan' ),
79
+ 'type' => 'text',
80
+ 'label' => __('Use a comma to separate orphans.', 'iworks_orphan'),
81
+ 'sanitize_callback' => 'esc_html',
82
+ ),
83
+ );
84
+ }
85
+
86
+ public function replace($content)
87
+ {
88
+ if ( empty( $content ) ) {
89
+ return;
90
+ }
91
+ $therms = array (
92
+ 'al.', 'ale', 'ależ',
93
+ 'b.', 'bł.', 'bm.', 'bp', 'br.', 'by', 'bym', 'byś',
94
+ 'cyt.', 'cz.', 'czyt.',
95
+ 'dn.', 'do', 'doc.', 'dr', 'ds.', 'dyr.', 'dz.',
96
+ 'fot.',
97
+ 'gdy', 'gdyby', 'gdybym', 'gdybyś', 'gdyż', 'godz.',
98
+ 'im.', 'inż.',
99
+ 'jw.',
100
+ 'kol.', 'komu', 'ks.', 'która', 'którego', 'której', 'któremu', 'który', 'których', 'którym', 'którzy',
101
+ 'lic.',
102
+ 'max', 'mgr', 'm.in.', 'min', 'moich', 'moje', 'mojego', 'mojej', 'mojemu', 'mój', 'mych', 'na', 'nad', 'np.','nt.', 'nw.',
103
+ 'nr', 'nr.', 'nru', 'nrowi', 'nrem', 'nrze', 'nrze', 'nry', 'nrów', 'nrom', 'nrami', 'nrach',
104
+ 'od', 'oraz', 'os.',
105
+ 'p.', 'pl.', 'pn.', 'po', 'pod', 'pot.', 'prof.', 'przed', 'pt.', 'pw.', 'pw.',
106
+ 'śp.', 'św.',
107
+ 'tamtej', 'tamto', 'tej', 'tel.', 'tj.', 'to', 'twoich', 'twoje', 'twojego', 'twojej', 'twój', 'twych',
108
+ 'ul.',
109
+ 'we', 'wg', 'woj.',
110
+ 'za', 'ze',
111
+ 'że', 'żeby', 'żebyś',
112
+ );
113
+ $own_orphans = trim( get_option( 'iworks_orphan_own_orphans', '' ), ' \t,');
114
+ if ( $own_orphans ) {
115
+ $own_orphans = preg_replace('/\,\+/', ',', $own_orphans);
116
+ $therms = array_merge( $therms, preg_split('/,[ \t]*/', strtolower( $own_orphans ) ) );
117
+ }
118
+ $re = '/^([aiouwz]|'.preg_replace('/\./', '\.', implode('|', $therms)).') +/i';
119
+ $content = preg_replace( $re, "$1$2&nbsp;", $content );
120
+ /**
121
+ * replace space in numbers
122
+ */
123
+ $content = preg_replace( '/(\d) (\d)/', "$1&nbsp;$2", $content );
124
+ /**
125
+ * single letters
126
+ */
127
+ $re = '/([ >\(]+)([aiouwz]|'.preg_replace('/\./', '\.', implode('|', $therms)).') +/i';
128
+ $content = preg_replace( $re, "$1$2&nbsp;", $content );
129
+ /**
130
+ * single letter after previous orphan
131
+ */
132
+ $re = '/(&nbsp;)([aiouwz]) +/i';
133
+ $content = preg_replace( $re, "$1$2&nbsp;", $content );
134
+ /**
135
+ * polish year after number
136
+ */
137
+ $content = preg_replace('/(\d+) (r\.)/', "$1&nbsp;$2", $content);
138
+ /**
139
+ * return
140
+ */
141
+ return $content;
142
+ }
143
+
144
+ public function option_page()
145
+ {
146
+ ?>
147
+ <div class="wrap">
148
+ <h2><?php _e('Orphans', 'iworks_orphan') ?></h2>
149
+ <div class="postbox-container" style="width:75%">
150
+ <form method="post" action="options.php">
151
+ <?php settings_fields('iworks_orphan'); ?>
152
+ <table class="form-table">
153
+ <tbody>
154
+ <?php
155
+ foreach ( $this->options as $filter => $option ) {
156
+ /**
157
+ * check option type
158
+ */
159
+ if (
160
+ 0
161
+ || !is_array($option)
162
+ || empty($option)
163
+ || !array_key_exists('type', $option )
164
+ ) {
165
+ continue;
166
+ }
167
+ $field = 'iworks_orphan_'.$filter;
168
+ printf (
169
+ '<tr valign="top"><th scope="row">%s</th><td>',
170
+ array_key_exists('description', $option)? $option['description']:'&nbsp;'
171
+ );
172
+ switch( $option['type'] ) {
173
+ case 'checkbox':
174
+ printf (
175
+ '<label for="%s"><input type="checkbox" name="%s" value="1"%s id="%s"/> %s</label>',
176
+ $field,
177
+ $field,
178
+ (get_option($field, 1) == 1)?' checked="checked"':'',
179
+ $field,
180
+ isset($option['label'])? $option['label']:'&nbsp;'
181
+ );
182
+ break;
183
+ case 'text':
184
+ default:
185
+ printf (
186
+ '<input type="text" name="%s" value="%s" id="%s" class="regular-text code" />%s',
187
+ $field,
188
+ get_option($field, ''),
189
+ $field,
190
+ isset($option['label'])? '<p class="description">'.$option['label'].'</p>':''
191
+ );
192
+ break;
193
+ }
194
+ print '</td></tr>';
195
+ }
196
+ ?>
197
+ </tbody>
198
+ </table>
199
+ <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
200
+ </form>
201
+ </div>
202
+ <div class="postbox-container" style="width:23%;margin-left:2%">
203
+ <div class="metabox-holder">
204
+ <div id="links" class="postbox">
205
+ <h3 class="hndle"><?php _e( 'Loved this Plugin?', 'iworks_orphan' ); ?></h3>
206
+ <div class="inside">
207
+ <p><?php _e( 'Below are some links to help spread this plugin to other users', 'iworks_orphan' ); ?></p>
208
+ <ul>
209
+ <li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e( 'Give it a 5 star on Wordpress.org', 'iworks_orphan' ); ?></a></li>
210
+ <li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e( 'Link to it so others can easily find it', 'iworks_orphan' ); ?></a></li>
211
+ </ul>
212
+ </div>
213
+ </div>
214
+ <div id="help" class="postbox">
215
+ <h3 class="hndle"><?php _e( 'Need Assistance?', 'iworks_orphan' ); ?></h3>
216
+ <div class="inside">
217
+ <p><?php _e( 'Problems? The links bellow can be very helpful to you', 'iworks_orphan' ); ?></p>
218
+ <ul>
219
+ <li><a href="<?php _e( 'http://wordpress.org/support/plugin/sierotki', 'iworks_orphan' ); ?>"><?php _e( 'Wordpress Help Forum', 'iworks_orphan' ); ?></a></li>
220
+ <li><a href="mailto:<?php echo antispambot('marcin@iworks.pl'); ?>"><?php echo antispambot( 'marcin@iworks.pl' ); ?></a></li>
221
+ </ul>
222
+ <hr />
223
+ <p class="description"><?php _e('Created by: ', 'iworks_orphan' ); ?> <a href="http://iworks.pl/"><span>iWorks.pl</span></a></p>
224
+ </div>
225
+ </div>
226
+ </div>
227
+ </div>
228
+ </div><?php
229
+ }
230
+
231
+ public function admin_menu()
232
+ {
233
+ if ( function_exists( 'add_theme_page' ) ) {
234
+ $this->admin_page = add_theme_page( __( 'Orphan', 'iworks_orphan'), __('Orphan', 'iworks_orphan'), 'manage_options', basename(__FILE__), array( &$this, 'option_page' ) );
235
+ add_action( 'load-'.$this->admin_page, array( &$this, 'add_help_tab' ) );
236
+ }
237
+ }
238
+
239
+ public function add_help_tab()
240
+ {
241
+ $screen = get_current_screen();
242
+ if ( $screen->id != $this->admin_page ) {
243
+ return;
244
+ }
245
+ // Add my_help_tab if current screen is My Admin Page
246
+ $screen->add_help_tab( array(
247
+ 'id' => 'overview',
248
+ 'title' => __( 'Orphans', 'iworks_orphan' ),
249
+ 'content' => '<p>' . __( 'Plugin fix some Polish gramary rules with orphans.', 'iworks_orphan' ) . '</p>',
250
+ ) );
251
+ /**
252
+ * make sidebar help
253
+ */
254
+ $screen->set_help_sidebar(
255
+ '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
256
+ '<p>' . __( '<a href="http://wordpress.org/extend/plugins/sierotki/" target="_blank">Plugin Homepage</a>', 'iworks_orphan' ) . '</p>' .
257
+ '<p>' . __( '<a href="http://wordpress.org/support/plugin/sierotki/" target="_blank">Support Forums</a>', 'iworks_orphan' ) . '</p>' .
258
+ '<p>' . __( '<a href="http://iworks.pl/en/" target="_blank">break the web</a>', 'iworks_orphan' ) . '</p>'
259
+ );
260
+
261
+ }
262
+
263
+ public function admin_init()
264
+ {
265
+ foreach ( $this->options as $filter => $option) {
266
+ $sanitize_callback = isset($option['sanitize_callback'])? $option['sanitize_callback']:null;
267
+ register_setting('iworks_orphan', 'iworks_orphan_'.$filter, $sanitize_callback);
268
+ }
269
+ add_filter( 'plugin_row_meta', array( &$this, 'links' ), 10, 2 );
270
+ }
271
+
272
+ public function init()
273
+ {
274
+ if ( 0 == get_option('iworks_orphan_initialized', 0 ) ) {
275
+ foreach ( $this->options as $filter => $option ) {
276
+ if ( !isset( $option['type'] ) ) {
277
+ $option['type'] = 'undefinied';
278
+ }
279
+ switch( $option['type'] ) {
280
+ case 'checkbox':
281
+ update_option('iworks_orphan_'.$filter, 1);
282
+ break;
283
+ case 'text':
284
+ default:
285
+ update_option('iworks_orphan_'.$filter, '');
286
+ break;
287
+ }
288
+ }
289
+ update_option('iworks_orphan_initialized', 1);
290
+ }
291
+ foreach ( array_keys( $this->options ) as $filter ) {
292
+ if ( 1 == get_option( 'iworks_orphan_'.$filter, 1 ) ) {
293
+ add_filter( $filter, array( &$this, 'replace' ) );
294
+ }
295
+ }
296
+ }
297
+
298
+ public function links($links, $file)
299
+ {
300
+ if ( $file == plugin_basename(__FILE__) ) {
301
+ if ( !is_multisite() ) {
302
+ $dir = explode('/', dirname(__FILE__));
303
+ $dir = $dir[ count( $dir ) - 1 ];
304
+ $links[] = '<a href="themes.php?page='.$dir.'.php">' . __('Settings') . '</a>';
305
+ }
306
+ $links[] = '<a href="http://iworks.pl/donate/sierotki.php">' . __('Donate') . '</a>';
307
+ }
308
+ return $links;
309
+ }
310
+ }