Orphans - Version 2.9.4

Version Description

  • 2022-02-02 =
  • Added ability to turn off replacements on menu title elements. New option is in "Miscellaneous" tab.
  • Added orphan_allowed_filters to add ability to change allowed filters.
  • Fixed issue with Font Awesome replacements. Props for lewleo999
  • Improved replacement process to avoid change HTML tags params.
Download this release

Release Info

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

Code changes from version 2.9.3 to 2.9.4

etc/options.php CHANGED
@@ -163,6 +163,15 @@ function orphang_indicator_options() {
163
  'classes' => array( 'switch-button' ),
164
  'default' => 0,
165
  ),
 
 
 
 
 
 
 
 
 
166
  array(
167
  'name' => 'numbers',
168
  'th' => __( 'Keep numbers together', 'sierotki' ),
163
  'classes' => array( 'switch-button' ),
164
  'default' => 0,
165
  ),
166
+ array(
167
+ 'name' => 'menu_title',
168
+ 'th' => __( 'Menu Title', 'sierotki' ),
169
+ 'type' => 'checkbox',
170
+ 'description' => __( 'Enabled the substitution of orphans in the menu title.', 'sierotki' ),
171
+ 'sanitize_callback' => 'absint',
172
+ 'classes' => array( 'switch-button' ),
173
+ 'default' => 1,
174
+ ),
175
  array(
176
  'name' => 'numbers',
177
  'th' => __( 'Keep numbers together', 'sierotki' ),
includes/iworks/class-iworks-orphan.php CHANGED
@@ -172,6 +172,28 @@ class iworks_orphan {
172
  return $this->unconditional_replacement( $content );
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  /**
176
  * Unconditional replacement with super-base check is replacement even
177
  * possible.
@@ -229,21 +251,37 @@ class iworks_orphan {
229
  */
230
  $terms = $this->_terms();
231
  $terms_terms = array_chunk( $terms, 10 );
232
- foreach ( $terms_terms as $terms ) {
233
- /**
234
- * base therms replace
235
- */
236
- $re = '/^([aiouwz]|' . preg_replace( '/\./', '\.', implode( '|', $terms ) ) . ') +/i';
237
- $content = preg_replace( $re, '$1$2 ', $content );
238
- /**
239
- * single letters
240
- */
241
- $re = '/([ >\(]+| |„|")([aiouwz]|' . preg_replace( '/\./', '\.', implode( '|', $terms ) ) . ') +/i';
242
- /**
243
- * double call to handle orphan after orphan after orphan
244
- */
245
- $content = preg_replace( $re, '$1$2 ', $content );
246
- $content = preg_replace( $re, '$1$2 ', $content );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  }
248
  /**
249
  * single letter after previous orphan
@@ -310,24 +348,69 @@ class iworks_orphan {
310
  if ( is_admin() ) {
311
  return;
312
  }
313
- $this->settings = $this->options->get_all_options();
314
- $allowed_filters = array(
315
- 'the_title',
316
- 'the_excerpt',
317
- 'the_content',
318
- 'comment_text',
319
- 'widget_title',
320
- 'widget_text',
321
- 'term_description',
322
- 'get_the_author_description',
323
- 'widget_block_content',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  );
325
  foreach ( $this->settings as $filter => $value ) {
326
- if ( ! in_array( $filter, $allowed_filters ) ) {
327
  continue;
328
  }
329
  if ( is_integer( $value ) && 1 == $value ) {
330
- add_filter( $filter, array( $this, 'replace' ), PHP_INT_MAX );
 
 
 
 
331
  /**
332
  * WooCommerce exception: short descripton
333
  */
172
  return $this->unconditional_replacement( $content );
173
  }
174
 
175
+ /**
176
+ * Replacement wrapper function for two params filters
177
+ *
178
+ * Replacement wrapper function for two params filters allow to check menu
179
+ * the_tilte settings.
180
+ *
181
+ * @since 2.9.4
182
+ */
183
+ public function replace_two( $content, $object_id ) {
184
+ /**
185
+ * Check for menu title
186
+ *
187
+ * @since 2.9.4
188
+ */
189
+ if ( 'nav_menu_item' === get_post_type( $object_id ) ) {
190
+ if ( isset( $this->settings['menu_title'] ) && 0 === $this->settings['menu_title'] ) {
191
+ return $content;
192
+ }
193
+ }
194
+ return $this->replace( $content );
195
+ }
196
+
197
  /**
198
  * Unconditional replacement with super-base check is replacement even
199
  * possible.
251
  */
252
  $terms = $this->_terms();
253
  $terms_terms = array_chunk( $terms, 10 );
254
+
255
+ /**
256
+ * avoid to replace tags contnt
257
+ *
258
+ * @since 2.9.4
259
+ */
260
+ $content_array = array( $content );
261
+ if ( preg_match( '/</', $content ) && preg_match_all( '/>([^<]+)</', $content, $matches ) ) {
262
+ $content_array = $matches[1];
263
+ }
264
+ foreach ( $content_array as $part_source ) {
265
+ $part_to_change = $part_source;
266
+ foreach ( $terms_terms as $terms ) {
267
+ /**
268
+ * base therms replace
269
+ */
270
+ $re = '/^([aiouwz]|' . preg_replace( '/\./', '\.', implode( '|', $terms ) ) . ') +/i';
271
+ $part_to_change = preg_replace( $re, '$1$2&nbsp;', $part_to_change );
272
+ /**
273
+ * single letters
274
+ */
275
+ $re = '/([ >\(]+|&nbsp;|&#8222;|&quot;)([aiouwz]|' . preg_replace( '/\./', '\.', implode( '|', $terms ) ) . ') +/i';
276
+ /**
277
+ * double call to handle orphan after orphan after orphan
278
+ */
279
+ $part_to_change = preg_replace( $re, '$1$2&nbsp;', $part_to_change );
280
+ $part_to_change = preg_replace( $re, '$1$2&nbsp;', $part_to_change );
281
+ }
282
+ if ( $part_source !== $part_to_change ) {
283
+ $content = str_replace( $part_source, $part_to_change, $content );
284
+ }
285
  }
286
  /**
287
  * single letter after previous orphan
348
  if ( is_admin() ) {
349
  return;
350
  }
351
+ $this->settings = $this->options->get_all_options();
352
+ /**
353
+ * Filter allowed filters.
354
+ *
355
+ * @since 2.9.4
356
+ *
357
+ * @param array $args {
358
+ * Array of filters, array key as filter.
359
+ *
360
+ * @type integer priority Filter priority.
361
+ * @type integer accepted_args Filter number of accepted args.
362
+ */
363
+ $allowed_filters = apply_filters(
364
+ 'orphan_allowed_filters',
365
+ array(
366
+ 'the_title' => array(
367
+ 'priority' => PHP_INT_MAX,
368
+ 'accepted_args' => 2,
369
+ ),
370
+ 'the_excerpt' => array(
371
+ 'priority' => PHP_INT_MAX,
372
+ 'accepted_args' => 1,
373
+ ),
374
+ 'the_content' => array(
375
+ 'priority' => PHP_INT_MAX,
376
+ 'accepted_args' => 1,
377
+ ),
378
+ 'comment_text' => array(
379
+ 'priority' => PHP_INT_MAX,
380
+ 'accepted_args' => 1,
381
+ ),
382
+ 'widget_title' => array(
383
+ 'priority' => PHP_INT_MAX,
384
+ 'accepted_args' => 1,
385
+ ),
386
+ 'widget_text' => array(
387
+ 'priority' => PHP_INT_MAX,
388
+ 'accepted_args' => 1,
389
+ ),
390
+ 'term_description' => array(
391
+ 'priority' => PHP_INT_MAX,
392
+ 'accepted_args' => 1,
393
+ ),
394
+ 'get_the_author_description' => array(
395
+ 'priority' => PHP_INT_MAX,
396
+ 'accepted_args' => 1,
397
+ ),
398
+ 'widget_block_content' => array(
399
+ 'priority' => PHP_INT_MAX,
400
+ 'accepted_args' => 1,
401
+ ),
402
+ )
403
  );
404
  foreach ( $this->settings as $filter => $value ) {
405
+ if ( ! array_key_exists( $filter, $allowed_filters ) ) {
406
  continue;
407
  }
408
  if ( is_integer( $value ) && 1 == $value ) {
409
+ if ( 2 === $allowed_filters[ $filter ]['accepted_args'] ) {
410
+ add_filter( $filter, array( $this, 'replace_two' ), PHP_INT_MAX, 2 );
411
+ } else {
412
+ add_filter( $filter, array( $this, 'replace' ), PHP_INT_MAX );
413
+ }
414
  /**
415
  * WooCommerce exception: short descripton
416
  */
languages/sierotki.pot CHANGED
@@ -3,26 +3,26 @@
3
  msgid ""
4
  msgstr ""
5
  "Project-Id-Version: Orphans PLUGIN_VERSION\n"
6
- "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/sierotki\n"
7
- "POT-Creation-Date: 2022-01-20 20:06:35+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
  "PO-Revision-Date: 2022-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
- "X-Generator: grunt-wp-i18n 0.5.3\n"
15
- "X-Poedit-KeywordsList: "
16
- "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
17
- "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
18
  "Language: en\n"
19
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
  "X-Poedit-Country: United States\n"
21
  "X-Poedit-SourceCharset: UTF-8\n"
 
 
 
22
  "X-Poedit-Basepath: ../\n"
23
  "X-Poedit-SearchPath-0: .\n"
24
  "X-Poedit-Bookmarks: \n"
25
  "X-Textdomain-Support: yes\n"
 
26
 
27
  #: etc/options.php:11
28
  msgid "Orphans configuration"
@@ -137,111 +137,119 @@ msgid "Allow to use plugin with another languages then Polish."
137
  msgstr ""
138
 
139
  #: etc/options.php:168
140
- msgid "Keep numbers together"
141
  msgstr ""
142
 
143
  #: etc/options.php:170
 
 
 
 
 
 
 
 
144
  msgid "Allow to keep together phone number or strings with space between numbers."
145
  msgstr ""
146
 
147
- #: etc/options.php:176
148
  msgid "User definied orphans"
149
  msgstr ""
150
 
151
- #: etc/options.php:178
152
  msgid "Use a comma to separate orphans."
153
  msgstr ""
154
 
155
- #: etc/options.php:185
156
  msgid "Entries custom fields"
157
  msgstr ""
158
 
159
- #: etc/options.php:187
160
  msgid "Use a comma to separate custom fields name."
161
  msgstr ""
162
 
163
- #: etc/options.php:195 etc/options.php:254
164
  msgid "We are waiting for your message"
165
  msgstr ""
166
 
167
- #: etc/options.php:201
168
  msgid "I love what I do!"
169
  msgstr ""
170
 
171
- #: etc/options.php:218
172
  msgid "Below are some links to help spread this plugin to other users"
173
  msgstr ""
174
 
175
- #: etc/options.php:220
176
  msgid "Give it a five stars on WordPress.org"
177
  msgstr ""
178
 
179
- #: etc/options.php:221
180
  msgid "Link to it so others can easily find it"
181
  msgstr ""
182
 
183
- #: etc/options.php:256
184
  msgid "WordPress Help Forum"
185
  msgstr ""
186
 
187
- #: includes/iworks/class-iworks-orphan.php:281
188
  msgid "Plugin fix some Polish gramary rules with orphans."
189
  msgstr ""
190
 
191
- #: includes/iworks/class-iworks-orphan.php:288
192
  msgid "For more information:"
193
  msgstr ""
194
 
195
- #: includes/iworks/class-iworks-orphan.php:289
196
  msgid ""
197
  "<a href=\"http://wordpress.org/extend/plugins/sierotki/\" "
198
  "target=\"_blank\">Plugin Homepage</a>"
199
  msgstr ""
200
 
201
- #: includes/iworks/class-iworks-orphan.php:290
202
  msgid ""
203
  "<a href=\"http://wordpress.org/support/plugin/sierotki/\" "
204
  "target=\"_blank\">Support Forums</a>"
205
  msgstr ""
206
 
207
- #: includes/iworks/class-iworks-orphan.php:291
208
  msgid "<a href=\"http://iworks.pl/en/\" target=\"_blank\">break the web</a>"
209
  msgstr ""
210
 
211
- #: includes/iworks/class-iworks-orphan.php:403
212
  #: includes/iworks/rate/rate.php:118
213
  msgid "Settings"
214
  msgstr ""
215
 
216
- #: includes/iworks/class-iworks-orphan.php:553
217
  msgid "Integrations"
218
  msgstr ""
219
 
220
- #: includes/iworks/class-iworks-orphan.php:569
221
  msgid "Advanced Custom Fields"
222
  msgstr ""
223
 
224
- #: includes/iworks/class-iworks-orphan.php:574
225
  msgid "Text"
226
  msgstr ""
227
 
228
- #: includes/iworks/class-iworks-orphan.php:575
229
  msgid "Enabled the substitution of orphans in text fields."
230
  msgstr ""
231
 
232
- #: includes/iworks/class-iworks-orphan.php:583
233
  msgid "Textarea"
234
  msgstr ""
235
 
236
- #: includes/iworks/class-iworks-orphan.php:584
237
  msgid "Enabled the substitution of orphans in textarea fields. (Include WYSIWYG)."
238
  msgstr ""
239
 
240
- #: includes/iworks/class-iworks-orphan.php:592
241
  msgid "WYSIWYG"
242
  msgstr ""
243
 
244
- #: includes/iworks/class-iworks-orphan.php:593
245
  msgid "Enabled the substitution of orphans in WYSIWYG fields."
246
  msgstr ""
247
 
@@ -374,12 +382,12 @@ msgstr ""
374
  msgid "http://iworks.pl/"
375
  msgstr ""
376
 
377
- #: etc/options.php:221
378
  msgctxt "plugin home page on WordPress.org"
379
  msgid "https://wordpress.org/plugins/sierotki/"
380
  msgstr ""
381
 
382
- #: etc/options.php:256
383
  msgctxt "link to support forum on WordPress.org"
384
  msgid "https://wordpress.org/support/plugin/sierotki/"
385
  msgstr ""
3
  msgid ""
4
  msgstr ""
5
  "Project-Id-Version: Orphans PLUGIN_VERSION\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/sierotki-dev\n"
7
+ "POT-Creation-Date: 2022-02-02 10:16:00+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
  "PO-Revision-Date: 2022-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
 
 
 
 
14
  "Language: en\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
  "X-Poedit-Country: United States\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: "
19
+ "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
20
+ "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
21
  "X-Poedit-Basepath: ../\n"
22
  "X-Poedit-SearchPath-0: .\n"
23
  "X-Poedit-Bookmarks: \n"
24
  "X-Textdomain-Support: yes\n"
25
+ "X-Generator: grunt-wp-i18n 1.0.3\n"
26
 
27
  #: etc/options.php:11
28
  msgid "Orphans configuration"
137
  msgstr ""
138
 
139
  #: etc/options.php:168
140
+ msgid "Menu Title"
141
  msgstr ""
142
 
143
  #: etc/options.php:170
144
+ msgid "Enabled the substitution of orphans in the menu title."
145
+ msgstr ""
146
+
147
+ #: etc/options.php:177
148
+ msgid "Keep numbers together"
149
+ msgstr ""
150
+
151
+ #: etc/options.php:179
152
  msgid "Allow to keep together phone number or strings with space between numbers."
153
  msgstr ""
154
 
155
+ #: etc/options.php:185
156
  msgid "User definied orphans"
157
  msgstr ""
158
 
159
+ #: etc/options.php:187
160
  msgid "Use a comma to separate orphans."
161
  msgstr ""
162
 
163
+ #: etc/options.php:194
164
  msgid "Entries custom fields"
165
  msgstr ""
166
 
167
+ #: etc/options.php:196
168
  msgid "Use a comma to separate custom fields name."
169
  msgstr ""
170
 
171
+ #: etc/options.php:204 etc/options.php:263
172
  msgid "We are waiting for your message"
173
  msgstr ""
174
 
175
+ #: etc/options.php:210
176
  msgid "I love what I do!"
177
  msgstr ""
178
 
179
+ #: etc/options.php:227
180
  msgid "Below are some links to help spread this plugin to other users"
181
  msgstr ""
182
 
183
+ #: etc/options.php:229
184
  msgid "Give it a five stars on WordPress.org"
185
  msgstr ""
186
 
187
+ #: etc/options.php:230
188
  msgid "Link to it so others can easily find it"
189
  msgstr ""
190
 
191
+ #: etc/options.php:265
192
  msgid "WordPress Help Forum"
193
  msgstr ""
194
 
195
+ #: includes/iworks/class-iworks-orphan.php:319
196
  msgid "Plugin fix some Polish gramary rules with orphans."
197
  msgstr ""
198
 
199
+ #: includes/iworks/class-iworks-orphan.php:326
200
  msgid "For more information:"
201
  msgstr ""
202
 
203
+ #: includes/iworks/class-iworks-orphan.php:327
204
  msgid ""
205
  "<a href=\"http://wordpress.org/extend/plugins/sierotki/\" "
206
  "target=\"_blank\">Plugin Homepage</a>"
207
  msgstr ""
208
 
209
+ #: includes/iworks/class-iworks-orphan.php:328
210
  msgid ""
211
  "<a href=\"http://wordpress.org/support/plugin/sierotki/\" "
212
  "target=\"_blank\">Support Forums</a>"
213
  msgstr ""
214
 
215
+ #: includes/iworks/class-iworks-orphan.php:329
216
  msgid "<a href=\"http://iworks.pl/en/\" target=\"_blank\">break the web</a>"
217
  msgstr ""
218
 
219
+ #: includes/iworks/class-iworks-orphan.php:486
220
  #: includes/iworks/rate/rate.php:118
221
  msgid "Settings"
222
  msgstr ""
223
 
224
+ #: includes/iworks/class-iworks-orphan.php:636
225
  msgid "Integrations"
226
  msgstr ""
227
 
228
+ #: includes/iworks/class-iworks-orphan.php:652
229
  msgid "Advanced Custom Fields"
230
  msgstr ""
231
 
232
+ #: includes/iworks/class-iworks-orphan.php:657
233
  msgid "Text"
234
  msgstr ""
235
 
236
+ #: includes/iworks/class-iworks-orphan.php:658
237
  msgid "Enabled the substitution of orphans in text fields."
238
  msgstr ""
239
 
240
+ #: includes/iworks/class-iworks-orphan.php:666
241
  msgid "Textarea"
242
  msgstr ""
243
 
244
+ #: includes/iworks/class-iworks-orphan.php:667
245
  msgid "Enabled the substitution of orphans in textarea fields. (Include WYSIWYG)."
246
  msgstr ""
247
 
248
+ #: includes/iworks/class-iworks-orphan.php:675
249
  msgid "WYSIWYG"
250
  msgstr ""
251
 
252
+ #: includes/iworks/class-iworks-orphan.php:676
253
  msgid "Enabled the substitution of orphans in WYSIWYG fields."
254
  msgstr ""
255
 
382
  msgid "http://iworks.pl/"
383
  msgstr ""
384
 
385
+ #: etc/options.php:230
386
  msgctxt "plugin home page on WordPress.org"
387
  msgid "https://wordpress.org/plugins/sierotki/"
388
  msgstr ""
389
 
390
+ #: etc/options.php:265
391
  msgctxt "link to support forum on WordPress.org"
392
  msgid "https://wordpress.org/support/plugin/sierotki/"
393
  msgstr ""
readme.txt CHANGED
@@ -4,9 +4,9 @@ Donate link: https://ko-fi.com/iworks?utm_source=sierotki&utm_medium=readme-dona
4
  Tags: sierotka, sierotki, spójniki, twarda spacja
5
  Requires at least: 4.6
6
  Tested up to: 5.9
7
- Stable tag: 2.9.3
 
8
 
9
- Plugin supports some of the grammatical rules of the Polish language.
10
 
11
  == Description ==
12
 
@@ -126,6 +126,12 @@ function remove_iworks_orphan_terms( $terms ) {
126
 
127
  == Changelog ==
128
 
 
 
 
 
 
 
129
  = 2.9.3 - 2022-01-20 =
130
  * Removed doubled "Donate" link on plugin page.
131
  * Updated iWorks Options to 2.8.0.
4
  Tags: sierotka, sierotki, spójniki, twarda spacja
5
  Requires at least: 4.6
6
  Tested up to: 5.9
7
+ Stable tag: 2.9.4
8
+
9
 
 
10
 
11
  == Description ==
12
 
126
 
127
  == Changelog ==
128
 
129
+ = 2.9.4 - 2022-02-02 =
130
+ * Added ability to turn off replacements on menu title elements. New option is in "Miscellaneous" tab.
131
+ * Added `orphan_allowed_filters` to add ability to change allowed filters.
132
+ * Fixed issue with Font Awesome replacements. Props for [lewleo999](https://wordpress.org/support/users/lewleo999/)
133
+ * Improved replacement process to avoid change HTML tags params.
134
+
135
  = 2.9.3 - 2022-01-20 =
136
  * Removed doubled "Donate" link on plugin page.
137
  * Updated iWorks Options to 2.8.0.
sierotki.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://iworks.pl/2011/02/16/sierotki/
5
  Text Domain: sierotki
6
  Description: Implement Polish grammar rules with orphans.
7
  Author: Marcin Pietrzak
8
- Version: 2.9.3
9
  Author URI: http://iworks.pl/
10
  */
11
 
5
  Text Domain: sierotki
6
  Description: Implement Polish grammar rules with orphans.
7
  Author: Marcin Pietrzak
8
+ Version: 2.9.4
9
  Author URI: http://iworks.pl/
10
  */
11