Version Description
2016-02-27 =
Fixed a problem with ignored option for numbers. Props for Kacper
Added check site or entry language to avoid replacing if language is other then Polish. It is one exception: numbers.
Download this release
Release Info
Developer | iworks |
Plugin | Orphans |
Version | 2.6.2 |
Comparing to | |
See all releases |
Version 2.6.2
- index.php +2 -0
- readme.txt +208 -0
- sierotki.php +78 -0
- uninstall.php +21 -0
- vendor/iworks/orphan.php +338 -0
index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
exit;
|
readme.txt
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Orphans ===
|
2 |
+
Contributors: iworks
|
3 |
+
Donate link: http://iworks.pl/donate/sierotki.php
|
4 |
+
Tags: sierotka, sierotki, spójniki, twarda spacja
|
5 |
+
Requires at least: 3.3
|
6 |
+
Tested up to: 4.6.1
|
7 |
+
Stable tag: 2.6.2
|
8 |
+
|
9 |
+
Plugin supports some of the grammatical rules of the Polish language.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Plugin fix orphans position and replace space after orphan to hard space, to avoid
|
14 |
+
line break incorrect position.
|
15 |
+
|
16 |
+
= Asset image =
|
17 |
+
|
18 |
+
[Manuscript by Muffet, on Flickr](http://www.flickr.com/photos/calliope/306564541/)
|
19 |
+
|
20 |
+
== Installation ==
|
21 |
+
|
22 |
+
There are 3 ways to install this plugin:
|
23 |
+
|
24 |
+
= The super easy way =
|
25 |
+
|
26 |
+
|
27 |
+
1. **Log in** to your WordPress Admin panel.
|
28 |
+
1. **Go to: Plugins > Add New.**
|
29 |
+
1. **Type** ‘orphans’ into the Search Plugins field and hit Enter. Once found, you can view details such as the point release, rating and description.
|
30 |
+
1. **Click** Install Now. After clicking the link, you’ll be asked if you’re sure you want to install the plugin.
|
31 |
+
1. **Click** Yes, and WordPress completes the installation.
|
32 |
+
1. **Activate** the plugin.
|
33 |
+
1. A new menu `Orphans` in `Appearance` will appear in your Admin Menu.
|
34 |
+
|
35 |
+
***
|
36 |
+
|
37 |
+
= The easy way =
|
38 |
+
|
39 |
+
1. Download the plugin (.zip file) on the right column of this page
|
40 |
+
1. In your Admin, go to menu Plugins > Add
|
41 |
+
1. Select button `Upload Plugin`
|
42 |
+
1. Upload the .zip file you just downloaded
|
43 |
+
1. Activate the plugin
|
44 |
+
1. A new menu `Orphans` in `Appearance` will appear in your Admin Menu.
|
45 |
+
|
46 |
+
***
|
47 |
+
|
48 |
+
= The old and reliable way (FTP) =
|
49 |
+
|
50 |
+
1. Upload `sierotki` folder to the `/wp-content/plugins/` directory
|
51 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
52 |
+
1. A new menu `Orphans` in `Appearance` will appear in your Admin Menu.
|
53 |
+
|
54 |
+
== Frequently Asked Questions ==
|
55 |
+
|
56 |
+
= When this plugin replace spaces? =
|
57 |
+
|
58 |
+
Plugin works when viewing the content and does not modify your content.
|
59 |
+
|
60 |
+
= How to use this plugin on custom field? =
|
61 |
+
|
62 |
+
Use this code:
|
63 |
+
|
64 |
+
`
|
65 |
+
$orphan = new iworks_orphan();
|
66 |
+
echo $orphan->replace( get_post_meta($post_id, 'meta_key', true ) );
|
67 |
+
`
|
68 |
+
|
69 |
+
= How to use this plugin on any string? =
|
70 |
+
|
71 |
+
Use this code:
|
72 |
+
|
73 |
+
`
|
74 |
+
$orphan = new iworks_orphan();
|
75 |
+
echo $orphan->replace( 'any_string' );
|
76 |
+
`
|
77 |
+
|
78 |
+
= How to change plugin capability? =
|
79 |
+
|
80 |
+
By default to use this plugin you must have `manage_options` capability,
|
81 |
+
that usually mean site administrator. If you want to allow manage
|
82 |
+
Orphans by "Editors" then you need to use other capability, e.g.
|
83 |
+
`unfiltered_html`. You can use `iworks_orphans_capability` filter:
|
84 |
+
|
85 |
+
`
|
86 |
+
add_filter('iworks_orphans_capability', 'my_orphans_capability');
|
87 |
+
function my_orphans_capability($capability)
|
88 |
+
{
|
89 |
+
return 'unfiltered_html';
|
90 |
+
}
|
91 |
+
`
|
92 |
+
|
93 |
+
== Screenshots ==
|
94 |
+
|
95 |
+
1. Orphan Options (Polish).
|
96 |
+
1. Orphan Options
|
97 |
+
|
98 |
+
== Changelog ==
|
99 |
+
|
100 |
+
= 2.6.2 - 2016-02-27 =
|
101 |
+
|
102 |
+
* Fixed a problem with ignored option for numbers. Props for [Kacper](https://profiles.wordpress.org/alento/)
|
103 |
+
* Added check site or entry language to avoid replacing if language is other then Polish. It is one exception: numbers.
|
104 |
+
|
105 |
+
= 2.6.1 - 2016-01-11 =
|
106 |
+
|
107 |
+
* Fixed a problem with non-breakable space. Replace space after number to space between numbers.
|
108 |
+
|
109 |
+
= 2.6 - 2016-01-09 =
|
110 |
+
|
111 |
+
* Change language domain from `iworks_orphan` to plugin name `sierotki' to be compatible with i18n WordPress rules.
|
112 |
+
* Added activate plugin hook to change options autoload status.
|
113 |
+
* Added deactivate plugin hook to change options autoload status.
|
114 |
+
* Added filter `iworks_orphans_capability`, thx to Cezary Buliszak.
|
115 |
+
* Added non-breakable space after numbers.
|
116 |
+
* Added uninstall plugin hook.
|
117 |
+
* Update screenshots.
|
118 |
+
|
119 |
+
= 2.5 - 2015-11-06 =
|
120 |
+
|
121 |
+
* IMPROVEMENT: added filter `iworks_orphan_replace`
|
122 |
+
|
123 |
+
= 2.4 - 2015-02-12 =
|
124 |
+
|
125 |
+
* Added hard space between number (year) and polish year shortcut "r."
|
126 |
+
* Added WooCommerce product title and short description to available options. thx to [Dominik Kawula](https://www.facebook.com/dominik.kawula)
|
127 |
+
|
128 |
+
= 2.3.2 - 2014-09-12 =
|
129 |
+
|
130 |
+
* Fixed error in options array
|
131 |
+
|
132 |
+
= 2.3.1 - 2014-09-12 =
|
133 |
+
|
134 |
+
* Checked option array for non existing hash.
|
135 |
+
* Updated screenshots.
|
136 |
+
|
137 |
+
= 2.3 - 2014-07-10 =
|
138 |
+
|
139 |
+
* IMPROVEMENT: added all forms of word number
|
140 |
+
|
141 |
+
= 2.2 - 2014-01-24 =
|
142 |
+
|
143 |
+
* IMPROVEMENT:added links to forum
|
144 |
+
* IMPROVEMENT:checked capability with WP 3.8
|
145 |
+
|
146 |
+
= 2.1 - 2013-11-09 =
|
147 |
+
|
148 |
+
* IMPROVEMENT:checked capability with WP 3.6
|
149 |
+
* REFACTORING: implement PSR-0 rules to orphan class
|
150 |
+
|
151 |
+
= 2.0.2 - 2013-08-20 =
|
152 |
+
|
153 |
+
* BUGFIX: fixed replacement for single letter orphan after orphan thx to [Szymon Skulimowski](http://wpninja.pl/autorzy/szymon-skulimowski/)
|
154 |
+
* IMPROVEMENT:checked capability with WP 3.6
|
155 |
+
* IMPROVEMENT:added help and related section
|
156 |
+
|
157 |
+
= 2.0.1 - 2013-07-10 =
|
158 |
+
|
159 |
+
* IMPROVEMENT:added numbers
|
160 |
+
|
161 |
+
= 2.0 - 2012-08-12 =
|
162 |
+
|
163 |
+
* BUGFIX: fixed permissions to configuration page
|
164 |
+
* BUGFIX: fixed replacement for strings starting with a orphan
|
165 |
+
* REFACTORING: rewrite code to the class
|
166 |
+
* IMPROVEMENT:added some shorts of academic degree
|
167 |
+
* IMPROVEMENT:massive increase orphans dictionary thx to [adpawl](http://podbabiogorze.info.pl)
|
168 |
+
|
169 |
+
= 1.4.2 - 2012-03-02 =
|
170 |
+
|
171 |
+
* NEW: added the_title filter.
|
172 |
+
|
173 |
+
= 1.4.1 - 2011-02-24 =
|
174 |
+
|
175 |
+
* NEW: Trim chars.
|
176 |
+
* BUGFIX: Fixed multi coma use.
|
177 |
+
|
178 |
+
= 1.4 - 2011-02-24 =
|
179 |
+
|
180 |
+
* NEW: Added user defined orphans.
|
181 |
+
* BUGFIX: Corrected capability name.
|
182 |
+
|
183 |
+
= 1.3 - 2011-02-19 =
|
184 |
+
|
185 |
+
* NEW: Added option page to turn on/off filtering in content, excerpt or comments.
|
186 |
+
* NEW: Added "(" as char before a orphan.
|
187 |
+
|
188 |
+
= 1.2 - 2011-02-18 =
|
189 |
+
|
190 |
+
* NEW: Added filter comment_text.
|
191 |
+
* BUGFIX: Capital letters was missing by plugin.
|
192 |
+
|
193 |
+
= 1.1 - 2011-02-17 =
|
194 |
+
|
195 |
+
* Abandoning elegant anonymous function, which requires PHP 5.3.0 :(
|
196 |
+
* NEW: Added filter to the_excerpt.
|
197 |
+
|
198 |
+
= 1.0.2 - 2011-02-17 =
|
199 |
+
|
200 |
+
* NEW: Added ">" as char before a orphan.
|
201 |
+
|
202 |
+
= 1.0.1 - 2011-02-16 =
|
203 |
+
|
204 |
+
* NEW: Added word "to".
|
205 |
+
|
206 |
+
= 1.0 - 2011-02-16 =
|
207 |
+
|
208 |
+
* INIT
|
sierotki.php
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Orphans
|
4 |
+
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.6.2
|
9 |
+
Author URI: http://iworks.pl/
|
10 |
+
*/
|
11 |
+
|
12 |
+
require_once(dirname(__FILE__)).'/vendor/iworks/orphan.php';
|
13 |
+
new iworks_orphan();
|
14 |
+
|
15 |
+
register_activation_hook( __FILE__, 'iworks_orphan_activate');
|
16 |
+
register_deactivation_hook( __FILE__, 'iworks_orphan_deactivate');
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Activate plugin function
|
20 |
+
*
|
21 |
+
* @since 2.6.0
|
22 |
+
*
|
23 |
+
*/
|
24 |
+
function iworks_orphan_activate()
|
25 |
+
{
|
26 |
+
iworks_orphan_change_options_autoload_status('yes');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Deactivate plugin function
|
31 |
+
*
|
32 |
+
* @since 2.6.0
|
33 |
+
*
|
34 |
+
*/
|
35 |
+
function iworks_orphan_deactivate()
|
36 |
+
{
|
37 |
+
iworks_orphan_change_options_autoload_status('no');
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* Activate/Deactivate helper function
|
41 |
+
*
|
42 |
+
* @since 2.6.0
|
43 |
+
*
|
44 |
+
* @global wpdb $wpdb WordPress database abstraction object.
|
45 |
+
*
|
46 |
+
* @param string $status status of autoload, possible values: yes or no
|
47 |
+
*
|
48 |
+
*/
|
49 |
+
function iworks_orphan_change_options_autoload_status($status)
|
50 |
+
{
|
51 |
+
if ( !preg_match('/^(yes|no)$/', $status ) ) {
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
$options_keys = array(
|
55 |
+
'comment_text',
|
56 |
+
'initialized',
|
57 |
+
'numbers',
|
58 |
+
'own_orphans',
|
59 |
+
'the_content',
|
60 |
+
'the_excerpt',
|
61 |
+
'the_title',
|
62 |
+
'woocommerce_product_title',
|
63 |
+
'woocommerce_short_description',
|
64 |
+
);
|
65 |
+
global $wpdb;
|
66 |
+
foreach( $options_keys as $key ) {
|
67 |
+
$wpdb->update(
|
68 |
+
$wpdb->options,
|
69 |
+
array(
|
70 |
+
'autoload' => $status,
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'option_name' => sprintf('iworks_orphan_%s', $key),
|
74 |
+
)
|
75 |
+
);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
uninstall.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if (!defined( 'WP_UNINSTALL_PLUGIN') ) {
|
3 |
+
exit();
|
4 |
+
}
|
5 |
+
|
6 |
+
$keys = array(
|
7 |
+
'comment_text',
|
8 |
+
'initialized',
|
9 |
+
'numbers',
|
10 |
+
'own_orphans',
|
11 |
+
'the_content',
|
12 |
+
'the_excerpt',
|
13 |
+
'the_title',
|
14 |
+
'woocommerce_product_title',
|
15 |
+
'woocommerce_short_description',
|
16 |
+
);
|
17 |
+
|
18 |
+
foreach( $keys as $key ) {
|
19 |
+
delete_option('iworks_orphan_'.$key);
|
20 |
+
}
|
21 |
+
|
vendor/iworks/orphan.php
ADDED
@@ -0,0 +1,338 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class iworks_orphan
|
3 |
+
{
|
4 |
+
private $options;
|
5 |
+
private $admin_page;
|
6 |
+
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* l10n
|
11 |
+
*/
|
12 |
+
load_plugin_textdomain('sierotki', false, dirname( plugin_basename( dirname(dirname(__FILE__))) ).'/languages' );
|
13 |
+
|
14 |
+
/**
|
15 |
+
* actions
|
16 |
+
*/
|
17 |
+
add_action('init', array( $this, 'init' ) );
|
18 |
+
add_action('admin_init', array( $this, 'admin_init' ) );
|
19 |
+
add_action('admin_menu', array( $this, 'admin_menu' ) );
|
20 |
+
|
21 |
+
/**
|
22 |
+
* options
|
23 |
+
*/
|
24 |
+
$this->options = array (
|
25 |
+
'comment_text' => array(
|
26 |
+
'description' => __('Use for comments:', 'sierotki' ),
|
27 |
+
'type' => 'checkbox',
|
28 |
+
'label' => __('Enabled the substitution of orphans in the comments.', 'sierotki'),
|
29 |
+
'sanitize_callback' => 'absint',
|
30 |
+
),
|
31 |
+
'the_title' => array(
|
32 |
+
'description' => __('Use for post title:', 'sierotki' ),
|
33 |
+
'type' => 'checkbox',
|
34 |
+
'label' => __('Enabled the substitution of orphans in the post_title.', 'sierotki'),
|
35 |
+
'sanitize_callback' => 'absint',
|
36 |
+
),
|
37 |
+
'the_excerpt' => array(
|
38 |
+
'description' => __('Use for excerpt:', 'sierotki' ),
|
39 |
+
'type' => 'checkbox',
|
40 |
+
'label' => __('Enabled the substitution of orphans in the excerpt.', 'sierotki'),
|
41 |
+
'sanitize_callback' => 'absint',
|
42 |
+
),
|
43 |
+
'the_content' => array(
|
44 |
+
'description' => __('Use for content:', 'sierotki' ),
|
45 |
+
'type' => 'checkbox',
|
46 |
+
'label' => __('Enabled the substitution of orphans in the content.', 'sierotki'),
|
47 |
+
'sanitize_callback' => 'absint',
|
48 |
+
),
|
49 |
+
'woocommerce_product_title' => array(
|
50 |
+
'description' => __('Use for WooCommerce product title:', 'sierotki' ),
|
51 |
+
'type' => 'checkbox',
|
52 |
+
'label' => __('Enabled the substitution of orphans in the WooCommerce product title.', 'sierotki'),
|
53 |
+
'sanitize_callback' => 'absint',
|
54 |
+
),
|
55 |
+
'woocommerce_short_description' => array(
|
56 |
+
'description' => __('Use for WooCommerce short description:', 'sierotki' ),
|
57 |
+
'type' => 'checkbox',
|
58 |
+
'label' => __('Enabled the substitution of orphans in the WooCommerce short description.', 'sierotki'),
|
59 |
+
'sanitize_callback' => 'absint',
|
60 |
+
),
|
61 |
+
'numbers' => array(
|
62 |
+
'description' => __('Keep numbers together:', 'sierotki' ),
|
63 |
+
'type' => 'checkbox',
|
64 |
+
'label' => __('Allow to keep together phone number or strings with space between numbers.', 'sierotki'),
|
65 |
+
'sanitize_callback' => 'absint',
|
66 |
+
),
|
67 |
+
'own_orphans' => array(
|
68 |
+
'description' => __('User definied orphans:', 'sierotki' ),
|
69 |
+
'type' => 'text',
|
70 |
+
'label' => __('Use a comma to separate orphans.', 'sierotki'),
|
71 |
+
'sanitize_callback' => 'esc_html',
|
72 |
+
),
|
73 |
+
);
|
74 |
+
}
|
75 |
+
|
76 |
+
public function replace($content)
|
77 |
+
{
|
78 |
+
if ( empty( $content ) ) {
|
79 |
+
return;
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Keep numbers together - this is independed of current language
|
84 |
+
*/
|
85 |
+
$numbers = get_option('iworks_orphan_numbers');
|
86 |
+
if ( !empty($numbers) ){
|
87 |
+
while( preg_match( '/(\d) (\d)/', $content ) ) {
|
88 |
+
$content = preg_replace('/(\d) (\d)/', "$1 $2", $content );
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* apply other rules only for Polish language
|
94 |
+
*/
|
95 |
+
$locale = apply_filters( 'wpml_current_language', get_locale());
|
96 |
+
if ( !preg_match( '/^pl/', $locale ) ) {
|
97 |
+
return $content;
|
98 |
+
}
|
99 |
+
|
100 |
+
$terms = array (
|
101 |
+
'al.', 'ale', 'ależ',
|
102 |
+
'b.', 'bł.', 'bm.', 'bp', 'br.', 'by', 'bym', 'byś',
|
103 |
+
'cyt.', 'cz.', 'czyt.',
|
104 |
+
'dn.', 'do', 'doc.', 'dr', 'ds.', 'dyr.', 'dz.',
|
105 |
+
'fot.',
|
106 |
+
'gdy', 'gdyby', 'gdybym', 'gdybyś', 'gdyż', 'godz.',
|
107 |
+
'im.', 'inż.',
|
108 |
+
'jw.',
|
109 |
+
'kol.', 'komu', 'ks.', 'która', 'którego', 'której', 'któremu', 'który', 'których', 'którym', 'którzy',
|
110 |
+
'lic.',
|
111 |
+
'max', 'mgr', 'm.in.', 'min', 'moich', 'moje', 'mojego', 'mojej', 'mojemu', 'mój', 'mych', 'na', 'nad', 'np.','nt.', 'nw.',
|
112 |
+
'nr', 'nr.', 'nru', 'nrowi', 'nrem', 'nrze', 'nrze', 'nry', 'nrów', 'nrom', 'nrami', 'nrach',
|
113 |
+
'od', 'oraz', 'os.',
|
114 |
+
'p.', 'pl.', 'pn.', 'po', 'pod', 'pot.', 'prof.', 'przed', 'pt.', 'pw.', 'pw.',
|
115 |
+
'śp.', 'św.',
|
116 |
+
'tamtej', 'tamto', 'tej', 'tel.', 'tj.', 'to', 'twoich', 'twoje', 'twojego', 'twojej', 'twój', 'twych',
|
117 |
+
'ul.',
|
118 |
+
'we', 'wg', 'woj.',
|
119 |
+
'za', 'ze',
|
120 |
+
'że', 'żeby', 'żebyś',
|
121 |
+
);
|
122 |
+
$own_orphans = trim( get_option('iworks_orphan_own_orphans', '' ), ' \t,');
|
123 |
+
if ( $own_orphans ) {
|
124 |
+
$own_orphans = preg_replace('/\,\+/', ',', $own_orphans);
|
125 |
+
$terms = array_merge( $terms, preg_split('/,[ \t]*/', strtolower( $own_orphans ) ) );
|
126 |
+
}
|
127 |
+
$terms = apply_filters('iworks_orphan_therms', $terms);
|
128 |
+
/**
|
129 |
+
* base therms replace
|
130 |
+
*/
|
131 |
+
$re = '/^([aiouwz]|'.preg_replace('/\./', '\.', implode('|', $terms)).') +/i';
|
132 |
+
$content = preg_replace( $re, "$1$2 ", $content );
|
133 |
+
/**
|
134 |
+
* single letters
|
135 |
+
*/
|
136 |
+
$re = '/([ >\(]+)([aiouwz]|'.preg_replace('/\./', '\.', implode('|', $terms)).') +/i';
|
137 |
+
$content = preg_replace( $re, "$1$2 ", $content );
|
138 |
+
/**
|
139 |
+
* single letter after previous orphan
|
140 |
+
*/
|
141 |
+
$re = '/( )([aiouwz]) +/i';
|
142 |
+
$content = preg_replace( $re, "$1$2 ", $content );
|
143 |
+
/**
|
144 |
+
* polish year after number
|
145 |
+
*/
|
146 |
+
$content = preg_replace('/(\d+) (r\.)/', "$1 $2", $content);
|
147 |
+
|
148 |
+
/**
|
149 |
+
* return
|
150 |
+
*/
|
151 |
+
return $content;
|
152 |
+
}
|
153 |
+
|
154 |
+
public function option_page()
|
155 |
+
{
|
156 |
+
?>
|
157 |
+
<div class="wrap">
|
158 |
+
<h2><?php _e('Orphans', 'sierotki') ?></h2>
|
159 |
+
<div class="postbox-container" style="width:75%">
|
160 |
+
<form method="post" action="options.php">
|
161 |
+
<?php settings_fields('sierotki'); ?>
|
162 |
+
<table class="form-table">
|
163 |
+
<tbody>
|
164 |
+
<?php
|
165 |
+
foreach ( $this->options as $filter => $option ) {
|
166 |
+
/**
|
167 |
+
* check option type
|
168 |
+
*/
|
169 |
+
if (
|
170 |
+
0
|
171 |
+
|| !is_array($option)
|
172 |
+
|| empty($option)
|
173 |
+
|| !array_key_exists('type', $option )
|
174 |
+
) {
|
175 |
+
continue;
|
176 |
+
}
|
177 |
+
$field = 'iworks_orphan_'.$filter;
|
178 |
+
printf (
|
179 |
+
'<tr valign="top"><th scope="row">%s</th><td>',
|
180 |
+
array_key_exists('description', $option)? $option['description']:' '
|
181 |
+
);
|
182 |
+
switch( $option['type'] ) {
|
183 |
+
case 'checkbox':
|
184 |
+
printf (
|
185 |
+
'<label for="%s"><input type="checkbox" name="%s" value="1"%s id="%s"/> %s</label>',
|
186 |
+
$field,
|
187 |
+
$field,
|
188 |
+
checked(1, get_option($field, 1), false),
|
189 |
+
$field,
|
190 |
+
isset($option['label'])? $option['label']:' '
|
191 |
+
);
|
192 |
+
break;
|
193 |
+
case 'text':
|
194 |
+
default:
|
195 |
+
printf (
|
196 |
+
'<input type="text" name="%s" value="%s" id="%s" class="regular-text code" />%s',
|
197 |
+
$field,
|
198 |
+
get_option($field, ''),
|
199 |
+
$field,
|
200 |
+
isset($option['label'])? '<p class="description">'.$option['label'].'</p>':''
|
201 |
+
);
|
202 |
+
break;
|
203 |
+
}
|
204 |
+
print '</td></tr>';
|
205 |
+
}
|
206 |
+
?>
|
207 |
+
</tbody>
|
208 |
+
</table>
|
209 |
+
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
|
210 |
+
</form>
|
211 |
+
</div>
|
212 |
+
<div class="postbox-container" style="width:23%;margin-left:2%">
|
213 |
+
<div class="metabox-holder">
|
214 |
+
<div id="links" class="postbox">
|
215 |
+
<h3 class="hndle"><?php _e('Loved this Plugin?', 'sierotki' ); ?></h3>
|
216 |
+
<div class="inside">
|
217 |
+
<p><?php _e('Below are some links to help spread this plugin to other users', 'sierotki' ); ?></p>
|
218 |
+
<ul>
|
219 |
+
<li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e('Give it a 5 star on Wordpress.org', 'sierotki' ); ?></a></li>
|
220 |
+
<li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e('Link to it so others can easily find it', 'sierotki' ); ?></a></li>
|
221 |
+
</ul>
|
222 |
+
</div>
|
223 |
+
</div>
|
224 |
+
<div id="help" class="postbox">
|
225 |
+
<h3 class="hndle"><?php _e('Need Assistance?', 'sierotki' ); ?></h3>
|
226 |
+
<div class="inside">
|
227 |
+
<p><?php _e('Problems? The links bellow can be very helpful to you', 'sierotki' ); ?></p>
|
228 |
+
<ul>
|
229 |
+
<li><a href="<?php _e('http://wordpress.org/support/plugin/sierotki', 'sierotki' ); ?>"><?php _e('Wordpress Help Forum', 'sierotki' ); ?></a></li>
|
230 |
+
<li><a href="mailto:<?php echo antispambot('marcin@iworks.pl'); ?>"><?php echo antispambot('marcin@iworks.pl' ); ?></a></li>
|
231 |
+
</ul>
|
232 |
+
<hr />
|
233 |
+
<p class="description"><?php _e('Created by: ', 'sierotki' ); ?> <a href="http://iworks.pl/"><span>iWorks.pl</span></a></p>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</div>
|
237 |
+
</div>
|
238 |
+
</div><?php
|
239 |
+
}
|
240 |
+
|
241 |
+
public function admin_menu()
|
242 |
+
{
|
243 |
+
if ( function_exists('add_theme_page' ) ) {
|
244 |
+
$this->admin_page = add_theme_page(
|
245 |
+
__('Orphans', 'sierotki'),
|
246 |
+
__('Orphans', 'sierotki'),
|
247 |
+
/**
|
248 |
+
* Allow to change capability.
|
249 |
+
*
|
250 |
+
* This filter allow to change capability which is needed to
|
251 |
+
* access to Orphans configuration page.
|
252 |
+
*
|
253 |
+
* @since 2.6.0
|
254 |
+
*
|
255 |
+
* @param string $capability current capability
|
256 |
+
*
|
257 |
+
*/
|
258 |
+
apply_filters('iworks_orphans_capability', 'manage_options'),
|
259 |
+
basename(__FILE__),
|
260 |
+
array( $this, 'option_page' )
|
261 |
+
);
|
262 |
+
add_action('load-'.$this->admin_page, array( $this, 'add_help_tab' ) );
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
public function add_help_tab()
|
267 |
+
{
|
268 |
+
$screen = get_current_screen();
|
269 |
+
if ( $screen->id != $this->admin_page ) {
|
270 |
+
return;
|
271 |
+
}
|
272 |
+
// Add my_help_tab if current screen is My Admin Page
|
273 |
+
$screen->add_help_tab( array(
|
274 |
+
'id' => 'overview',
|
275 |
+
'title' => __('Orphans', 'sierotki' ),
|
276 |
+
'content' => '<p>' . __('Plugin fix some Polish gramary rules with orphans.', 'sierotki' ) . '</p>',
|
277 |
+
) );
|
278 |
+
/**
|
279 |
+
* make sidebar help
|
280 |
+
*/
|
281 |
+
$screen->set_help_sidebar(
|
282 |
+
'<p><strong>' . __('For more information:' ) . '</strong></p>' .
|
283 |
+
'<p>' . __('<a href="http://wordpress.org/extend/plugins/sierotki/" target="_blank">Plugin Homepage</a>', 'sierotki' ) . '</p>' .
|
284 |
+
'<p>' . __('<a href="http://wordpress.org/support/plugin/sierotki/" target="_blank">Support Forums</a>', 'sierotki' ) . '</p>' .
|
285 |
+
'<p>' . __('<a href="http://iworks.pl/en/" target="_blank">break the web</a>', 'sierotki' ) . '</p>'
|
286 |
+
);
|
287 |
+
|
288 |
+
}
|
289 |
+
|
290 |
+
public function admin_init()
|
291 |
+
{
|
292 |
+
foreach ( $this->options as $filter => $option) {
|
293 |
+
$sanitize_callback = isset($option['sanitize_callback'])? $option['sanitize_callback']:null;
|
294 |
+
register_setting('sierotki', 'iworks_orphan_'.$filter, $sanitize_callback);
|
295 |
+
}
|
296 |
+
add_filter('plugin_row_meta', array( $this, 'links' ), 10, 2 );
|
297 |
+
}
|
298 |
+
|
299 |
+
public function init()
|
300 |
+
{
|
301 |
+
if ( 0 == get_option('iworks_orphan_initialized', 0 ) ) {
|
302 |
+
foreach ( $this->options as $filter => $option ) {
|
303 |
+
if ( !isset( $option['type'] ) ) {
|
304 |
+
$option['type'] = 'undefinied';
|
305 |
+
}
|
306 |
+
switch( $option['type'] ) {
|
307 |
+
case 'checkbox':
|
308 |
+
update_option('iworks_orphan_'.$filter, 1);
|
309 |
+
break;
|
310 |
+
case 'text':
|
311 |
+
default:
|
312 |
+
update_option('iworks_orphan_'.$filter, '');
|
313 |
+
break;
|
314 |
+
}
|
315 |
+
}
|
316 |
+
update_option('iworks_orphan_initialized', 1);
|
317 |
+
}
|
318 |
+
foreach ( array_keys( $this->options ) as $filter ) {
|
319 |
+
if ( 1 == get_option('iworks_orphan_'.$filter, 1 ) ) {
|
320 |
+
add_filter($filter, array($this, 'replace'));
|
321 |
+
}
|
322 |
+
}
|
323 |
+
add_filter('iworks_orphan_replace', array($this, 'replace'));
|
324 |
+
}
|
325 |
+
|
326 |
+
public function links($links, $file)
|
327 |
+
{
|
328 |
+
if ( $file == plugin_basename(__FILE__) ) {
|
329 |
+
if ( !is_multisite() ) {
|
330 |
+
$dir = explode('/', dirname(__FILE__));
|
331 |
+
$dir = $dir[ count( $dir ) - 1 ];
|
332 |
+
$links[] = '<a href="themes.php?page='.$dir.'.php">' . __('Settings') . '</a>';
|
333 |
+
}
|
334 |
+
$links[] = '<a href="http://iworks.pl/donate/sierotki.php">' . __('Donate') . '</a>';
|
335 |
+
}
|
336 |
+
return $links;
|
337 |
+
}
|
338 |
+
}
|