Version Description
2016-10-25 =
Implement WP syntax rules for PHP files.
Added "Call for ratings" on settings page.
Download this release
Release Info
Developer | iworks |
Plugin | Orphans |
Version | 2.6.3 |
Comparing to | |
See all releases |
Version 2.6.3
- index.php +2 -0
- readme.txt +213 -0
- sierotki.php +78 -0
- uninstall.php +21 -0
- vendor/iworks/orphan.php +449 -0
index.php
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<?php
|
2 |
+
exit;
|
readme.txt
ADDED
@@ -0,0 +1,213 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.3
|
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.3 - 2016-10-25 =
|
101 |
+
|
102 |
+
* Implement WP syntax rules for PHP files.
|
103 |
+
* Added "Call for ratings" on settings page.
|
104 |
+
|
105 |
+
= 2.6.2 - 2016-02-27 =
|
106 |
+
|
107 |
+
* Fixed a problem with ignored option for numbers. Props for [Kacper](https://profiles.wordpress.org/alento/)
|
108 |
+
* Added check site or entry language to avoid replacing if language is other then Polish. It is one exception: numbers.
|
109 |
+
|
110 |
+
= 2.6.1 - 2016-01-11 =
|
111 |
+
|
112 |
+
* Fixed a problem with non-breakable space. Replace space after number to space between numbers.
|
113 |
+
|
114 |
+
= 2.6 - 2016-01-09 =
|
115 |
+
|
116 |
+
* Change language domain from `iworks_orphan` to plugin name `sierotki' to be compatible with i18n WordPress rules.
|
117 |
+
* Added activate plugin hook to change options autoload status.
|
118 |
+
* Added deactivate plugin hook to change options autoload status.
|
119 |
+
* Added filter `iworks_orphans_capability`, thx to Cezary Buliszak.
|
120 |
+
* Added non-breakable space after numbers.
|
121 |
+
* Added uninstall plugin hook.
|
122 |
+
* Update screenshots.
|
123 |
+
|
124 |
+
= 2.5 - 2015-11-06 =
|
125 |
+
|
126 |
+
* IMPROVEMENT: added filter `iworks_orphan_replace`
|
127 |
+
|
128 |
+
= 2.4 - 2015-02-12 =
|
129 |
+
|
130 |
+
* Added hard space between number (year) and polish year shortcut "r."
|
131 |
+
* Added WooCommerce product title and short description to available options. thx to [Dominik Kawula](https://www.facebook.com/dominik.kawula)
|
132 |
+
|
133 |
+
= 2.3.2 - 2014-09-12 =
|
134 |
+
|
135 |
+
* Fixed error in options array
|
136 |
+
|
137 |
+
= 2.3.1 - 2014-09-12 =
|
138 |
+
|
139 |
+
* Checked option array for non existing hash.
|
140 |
+
* Updated screenshots.
|
141 |
+
|
142 |
+
= 2.3 - 2014-07-10 =
|
143 |
+
|
144 |
+
* IMPROVEMENT: added all forms of word number
|
145 |
+
|
146 |
+
= 2.2 - 2014-01-24 =
|
147 |
+
|
148 |
+
* IMPROVEMENT:added links to forum
|
149 |
+
* IMPROVEMENT:checked capability with WP 3.8
|
150 |
+
|
151 |
+
= 2.1 - 2013-11-09 =
|
152 |
+
|
153 |
+
* IMPROVEMENT:checked capability with WP 3.6
|
154 |
+
* REFACTORING: implement PSR-0 rules to orphan class
|
155 |
+
|
156 |
+
= 2.0.2 - 2013-08-20 =
|
157 |
+
|
158 |
+
* BUGFIX: fixed replacement for single letter orphan after orphan thx to [Szymon Skulimowski](http://wpninja.pl/autorzy/szymon-skulimowski/)
|
159 |
+
* IMPROVEMENT:checked capability with WP 3.6
|
160 |
+
* IMPROVEMENT:added help and related section
|
161 |
+
|
162 |
+
= 2.0.1 - 2013-07-10 =
|
163 |
+
|
164 |
+
* IMPROVEMENT:added numbers
|
165 |
+
|
166 |
+
= 2.0 - 2012-08-12 =
|
167 |
+
|
168 |
+
* BUGFIX: fixed permissions to configuration page
|
169 |
+
* BUGFIX: fixed replacement for strings starting with a orphan
|
170 |
+
* REFACTORING: rewrite code to the class
|
171 |
+
* IMPROVEMENT:added some shorts of academic degree
|
172 |
+
* IMPROVEMENT:massive increase orphans dictionary thx to [adpawl](http://podbabiogorze.info.pl)
|
173 |
+
|
174 |
+
= 1.4.2 - 2012-03-02 =
|
175 |
+
|
176 |
+
* NEW: added the_title filter.
|
177 |
+
|
178 |
+
= 1.4.1 - 2011-02-24 =
|
179 |
+
|
180 |
+
* NEW: Trim chars.
|
181 |
+
* BUGFIX: Fixed multi coma use.
|
182 |
+
|
183 |
+
= 1.4 - 2011-02-24 =
|
184 |
+
|
185 |
+
* NEW: Added user defined orphans.
|
186 |
+
* BUGFIX: Corrected capability name.
|
187 |
+
|
188 |
+
= 1.3 - 2011-02-19 =
|
189 |
+
|
190 |
+
* NEW: Added option page to turn on/off filtering in content, excerpt or comments.
|
191 |
+
* NEW: Added "(" as char before a orphan.
|
192 |
+
|
193 |
+
= 1.2 - 2011-02-18 =
|
194 |
+
|
195 |
+
* NEW: Added filter comment_text.
|
196 |
+
* BUGFIX: Capital letters was missing by plugin.
|
197 |
+
|
198 |
+
= 1.1 - 2011-02-17 =
|
199 |
+
|
200 |
+
* Abandoning elegant anonymous function, which requires PHP 5.3.0 :(
|
201 |
+
* NEW: Added filter to the_excerpt.
|
202 |
+
|
203 |
+
= 1.0.2 - 2011-02-17 =
|
204 |
+
|
205 |
+
* NEW: Added ">" as char before a orphan.
|
206 |
+
|
207 |
+
= 1.0.1 - 2011-02-16 =
|
208 |
+
|
209 |
+
* NEW: Added word "to".
|
210 |
+
|
211 |
+
= 1.0 - 2011-02-16 =
|
212 |
+
|
213 |
+
* 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.3
|
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,449 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 );
|
21 |
+
|
22 |
+
/**
|
23 |
+
* options
|
24 |
+
*/
|
25 |
+
$this->options = array(
|
26 |
+
'comment_text' => array(
|
27 |
+
'description' => __( 'Use for comments:', 'sierotki' ),
|
28 |
+
'type' => 'checkbox',
|
29 |
+
'label' => __( 'Enabled the substitution of orphans in the comments.', 'sierotki' ),
|
30 |
+
'sanitize_callback' => 'absint',
|
31 |
+
),
|
32 |
+
'the_title' => array(
|
33 |
+
'description' => __( 'Use for post title:', 'sierotki' ),
|
34 |
+
'type' => 'checkbox',
|
35 |
+
'label' => __( 'Enabled the substitution of orphans in the post_title.', 'sierotki' ),
|
36 |
+
'sanitize_callback' => 'absint',
|
37 |
+
),
|
38 |
+
'the_excerpt' => array(
|
39 |
+
'description' => __( 'Use for excerpt:', 'sierotki' ),
|
40 |
+
'type' => 'checkbox',
|
41 |
+
'label' => __( 'Enabled the substitution of orphans in the excerpt.', 'sierotki' ),
|
42 |
+
'sanitize_callback' => 'absint',
|
43 |
+
),
|
44 |
+
'the_content' => array(
|
45 |
+
'description' => __( 'Use for content:', 'sierotki' ),
|
46 |
+
'type' => 'checkbox',
|
47 |
+
'label' => __( 'Enabled the substitution of orphans in the content.', 'sierotki' ),
|
48 |
+
'sanitize_callback' => 'absint',
|
49 |
+
),
|
50 |
+
'woocommerce_product_title' => array(
|
51 |
+
'description' => __( 'Use for WooCommerce product title:', 'sierotki' ),
|
52 |
+
'type' => 'checkbox',
|
53 |
+
'label' => __( 'Enabled the substitution of orphans in the WooCommerce product title.', 'sierotki' ),
|
54 |
+
'sanitize_callback' => 'absint',
|
55 |
+
),
|
56 |
+
'woocommerce_short_description' => array(
|
57 |
+
'description' => __( 'Use for WooCommerce short description:', 'sierotki' ),
|
58 |
+
'type' => 'checkbox',
|
59 |
+
'label' => __( 'Enabled the substitution of orphans in the WooCommerce short description.', 'sierotki' ),
|
60 |
+
'sanitize_callback' => 'absint',
|
61 |
+
),
|
62 |
+
'numbers' => array(
|
63 |
+
'description' => __( 'Keep numbers together:', 'sierotki' ),
|
64 |
+
'type' => 'checkbox',
|
65 |
+
'label' => __( 'Allow to keep together phone number or strings with space between numbers.', 'sierotki' ),
|
66 |
+
'sanitize_callback' => 'absint',
|
67 |
+
),
|
68 |
+
'own_orphans' => array(
|
69 |
+
'description' => __( 'User definied orphans:', 'sierotki' ),
|
70 |
+
'type' => 'text',
|
71 |
+
'label' => __( 'Use a comma to separate orphans.', 'sierotki' ),
|
72 |
+
'sanitize_callback' => 'esc_html',
|
73 |
+
),
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
public function replace( $content ) {
|
78 |
+
|
79 |
+
if ( empty( $content ) ) {
|
80 |
+
return;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Keep numbers together - this is independed of current language
|
85 |
+
*/
|
86 |
+
$numbers = get_option( 'iworks_orphan_numbers' );
|
87 |
+
if ( ! empty( $numbers ) ) {
|
88 |
+
while ( preg_match( '/(\d) (\d)/', $content ) ) {
|
89 |
+
$content = preg_replace( '/(\d) (\d)/', '$1 $2', $content );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* apply other rules only for Polish language
|
95 |
+
*/
|
96 |
+
$locale = apply_filters( 'wpml_current_language', get_locale() );
|
97 |
+
if ( ! preg_match( '/^pl/', $locale ) ) {
|
98 |
+
return $content;
|
99 |
+
}
|
100 |
+
|
101 |
+
$terms = array(
|
102 |
+
'al.',
|
103 |
+
'ale',
|
104 |
+
'ależ',
|
105 |
+
'b.',
|
106 |
+
'bł.',
|
107 |
+
'bm.',
|
108 |
+
'bp',
|
109 |
+
'br.',
|
110 |
+
'by',
|
111 |
+
'bym',
|
112 |
+
'byś',
|
113 |
+
'cyt.',
|
114 |
+
'cz.',
|
115 |
+
'czyt.',
|
116 |
+
'dn.',
|
117 |
+
'do',
|
118 |
+
'doc.',
|
119 |
+
'dr',
|
120 |
+
'ds.',
|
121 |
+
'dyr.',
|
122 |
+
'dz.',
|
123 |
+
'fot.',
|
124 |
+
'gdy',
|
125 |
+
'gdyby',
|
126 |
+
'gdybym',
|
127 |
+
'gdybyś',
|
128 |
+
'gdyż',
|
129 |
+
'godz.',
|
130 |
+
'im.',
|
131 |
+
'inż.',
|
132 |
+
'jw.',
|
133 |
+
'kol.',
|
134 |
+
'komu',
|
135 |
+
'ks.',
|
136 |
+
'która',
|
137 |
+
'którego',
|
138 |
+
'której',
|
139 |
+
'któremu',
|
140 |
+
'który',
|
141 |
+
'których',
|
142 |
+
'którym',
|
143 |
+
'którzy',
|
144 |
+
'lic.',
|
145 |
+
'max',
|
146 |
+
'mgr',
|
147 |
+
'm.in.',
|
148 |
+
'min',
|
149 |
+
'moich',
|
150 |
+
'moje',
|
151 |
+
'mojego',
|
152 |
+
'mojej',
|
153 |
+
'mojemu',
|
154 |
+
'mój',
|
155 |
+
'mych',
|
156 |
+
'na',
|
157 |
+
'nad',
|
158 |
+
'np.',
|
159 |
+
'nt.',
|
160 |
+
'nw.',
|
161 |
+
'nr',
|
162 |
+
'nr.',
|
163 |
+
'nru',
|
164 |
+
'nrowi',
|
165 |
+
'nrem',
|
166 |
+
'nrze',
|
167 |
+
'nrze',
|
168 |
+
'nry',
|
169 |
+
'nrów',
|
170 |
+
'nrom',
|
171 |
+
'nrami',
|
172 |
+
'nrach',
|
173 |
+
'od',
|
174 |
+
'oraz',
|
175 |
+
'os.',
|
176 |
+
'p.',
|
177 |
+
'pl.',
|
178 |
+
'pn.',
|
179 |
+
'po',
|
180 |
+
'pod',
|
181 |
+
'pot.',
|
182 |
+
'prof.',
|
183 |
+
'przed',
|
184 |
+
'pt.',
|
185 |
+
'pw.',
|
186 |
+
'pw.',
|
187 |
+
'śp.',
|
188 |
+
'św.',
|
189 |
+
'tamtej',
|
190 |
+
'tamto',
|
191 |
+
'tej',
|
192 |
+
'tel.',
|
193 |
+
'tj.',
|
194 |
+
'to',
|
195 |
+
'twoich',
|
196 |
+
'twoje',
|
197 |
+
'twojego',
|
198 |
+
'twojej',
|
199 |
+
'twój',
|
200 |
+
'twych',
|
201 |
+
'ul.',
|
202 |
+
'we',
|
203 |
+
'wg',
|
204 |
+
'woj.',
|
205 |
+
'za',
|
206 |
+
'ze',
|
207 |
+
'że',
|
208 |
+
'żeby',
|
209 |
+
'żebyś',
|
210 |
+
);
|
211 |
+
$own_orphans = trim( get_option( 'iworks_orphan_own_orphans', '' ), ' \t,' );
|
212 |
+
if ( $own_orphans ) {
|
213 |
+
$own_orphans = preg_replace( '/\,\+/', ',', $own_orphans );
|
214 |
+
$terms = array_merge( $terms, preg_split( '/,[ \t]*/', strtolower( $own_orphans ) ) );
|
215 |
+
}
|
216 |
+
$terms = apply_filters( 'iworks_orphan_therms', $terms );
|
217 |
+
/**
|
218 |
+
* base therms replace
|
219 |
+
*/
|
220 |
+
$re = '/^([aiouwz]|'.preg_replace( '/\./', '\.', implode( '|', $terms ) ).') +/i';
|
221 |
+
$content = preg_replace( $re, '$1$2 ', $content );
|
222 |
+
/**
|
223 |
+
* single letters
|
224 |
+
*/
|
225 |
+
$re = '/([ >\(]+)([aiouwz]|'.preg_replace( '/\./', '\.', implode( '|', $terms ) ).') +/i';
|
226 |
+
$content = preg_replace( $re, '$1$2 ', $content );
|
227 |
+
/**
|
228 |
+
* single letter after previous orphan
|
229 |
+
*/
|
230 |
+
$re = '/( )([aiouwz]) +/i';
|
231 |
+
$content = preg_replace( $re, '$1$2 ', $content );
|
232 |
+
/**
|
233 |
+
* polish year after number
|
234 |
+
*/
|
235 |
+
$content = preg_replace( '/(\d+) (r\.)/', '$1 $2', $content );
|
236 |
+
|
237 |
+
/**
|
238 |
+
* return
|
239 |
+
*/
|
240 |
+
return $content;
|
241 |
+
}
|
242 |
+
|
243 |
+
public function option_page() {
|
244 |
+
|
245 |
+
?>
|
246 |
+
<div class="wrap">
|
247 |
+
<h2><?php _e( 'Orphans', 'sierotki' ) ?></h2>
|
248 |
+
<div class="postbox-container" style="width:75%">
|
249 |
+
<form method="post" action="options.php">
|
250 |
+
<?php settings_fields( 'sierotki' ); ?>
|
251 |
+
<table class="form-table">
|
252 |
+
<tbody>
|
253 |
+
<?php
|
254 |
+
foreach ( $this->options as $filter => $option ) {
|
255 |
+
/**
|
256 |
+
* check option type
|
257 |
+
*/
|
258 |
+
if (
|
259 |
+
0
|
260 |
+
|| ! is_array( $option )
|
261 |
+
|| empty( $option )
|
262 |
+
|| ! array_key_exists( 'type', $option )
|
263 |
+
) {
|
264 |
+
continue;
|
265 |
+
}
|
266 |
+
$field = 'iworks_orphan_'.$filter;
|
267 |
+
printf(
|
268 |
+
'<tr valign="top"><th scope="row">%s</th><td>',
|
269 |
+
array_key_exists( 'description', $option )? $option['description']:' '
|
270 |
+
);
|
271 |
+
switch ( $option['type'] ) {
|
272 |
+
case 'checkbox':
|
273 |
+
printf(
|
274 |
+
'<label for="%s"><input type="checkbox" name="%s" value="1"%s id="%s"/> %s</label>',
|
275 |
+
$field,
|
276 |
+
$field,
|
277 |
+
checked( 1, get_option( $field, 1 ), false ),
|
278 |
+
$field,
|
279 |
+
isset( $option['label'] )? $option['label']:' '
|
280 |
+
);
|
281 |
+
break;
|
282 |
+
case 'text':
|
283 |
+
default:
|
284 |
+
printf(
|
285 |
+
'<input type="text" name="%s" value="%s" id="%s" class="regular-text code" />%s',
|
286 |
+
$field,
|
287 |
+
get_option( $field, '' ),
|
288 |
+
$field,
|
289 |
+
isset( $option['label'] )? '<p class="description">'.$option['label'].'</p>':''
|
290 |
+
);
|
291 |
+
break;
|
292 |
+
}
|
293 |
+
print '</td></tr>';
|
294 |
+
}
|
295 |
+
?>
|
296 |
+
</tbody>
|
297 |
+
</table>
|
298 |
+
<p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" /></p>
|
299 |
+
</form>
|
300 |
+
</div>
|
301 |
+
<div class="postbox-container" style="width:23%;margin-left:2%">
|
302 |
+
<div class="metabox-holder">
|
303 |
+
<div id="links" class="postbox">
|
304 |
+
<h3 class="hndle"><?php _e( 'Loved this Plugin?', 'sierotki' ); ?></h3>
|
305 |
+
<div class="inside">
|
306 |
+
<p><?php _e( 'Below are some links to help spread this plugin to other users', 'sierotki' ); ?></p>
|
307 |
+
<ul>
|
308 |
+
<li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e( 'Give it a 5 star on Wordpress.org', 'sierotki' ); ?></a></li>
|
309 |
+
<li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e( 'Link to it so others can easily find it', 'sierotki' ); ?></a></li>
|
310 |
+
</ul>
|
311 |
+
</div>
|
312 |
+
</div>
|
313 |
+
<div id="help" class="postbox">
|
314 |
+
<h3 class="hndle"><?php _e( 'Need Assistance?', 'sierotki' ); ?></h3>
|
315 |
+
<div class="inside">
|
316 |
+
<p><?php _e( 'Problems? The links bellow can be very helpful to you', 'sierotki' ); ?></p>
|
317 |
+
<ul>
|
318 |
+
<li><a href="<?php _e( 'http://wordpress.org/support/plugin/sierotki', 'sierotki' ); ?>"><?php _e( 'Wordpress Help Forum', 'sierotki' ); ?></a></li>
|
319 |
+
<li><a href="mailto:<?php echo antispambot( 'marcin@iworks.pl' ); ?>"><?php echo antispambot( 'marcin@iworks.pl' ); ?></a></li>
|
320 |
+
</ul>
|
321 |
+
<hr />
|
322 |
+
<p class="description"><?php _e( 'Created by: ', 'sierotki' ); ?> <a href="http://iworks.pl/"><span>iWorks.pl</span></a></p>
|
323 |
+
</div>
|
324 |
+
</div>
|
325 |
+
</div>
|
326 |
+
</div>
|
327 |
+
</div><?php
|
328 |
+
}
|
329 |
+
|
330 |
+
private function get_capability() {
|
331 |
+
return apply_filters( 'iworks_orphans_capability', 'manage_options' );
|
332 |
+
}
|
333 |
+
|
334 |
+
public function admin_menu() {
|
335 |
+
|
336 |
+
if ( function_exists( 'add_theme_page' ) ) {
|
337 |
+
$this->admin_page = add_theme_page(
|
338 |
+
__( 'Orphans', 'sierotki' ),
|
339 |
+
__( 'Orphans', 'sierotki' ),
|
340 |
+
/**
|
341 |
+
* Allow to change capability.
|
342 |
+
*
|
343 |
+
* This filter allow to change capability which is needed to
|
344 |
+
* access to Orphans configuration page.
|
345 |
+
*
|
346 |
+
* @since 2.6.0
|
347 |
+
*
|
348 |
+
* @param string $capability current capability
|
349 |
+
*
|
350 |
+
*/
|
351 |
+
$this->get_capability(),
|
352 |
+
basename( __FILE__ ),
|
353 |
+
array( $this, 'option_page' )
|
354 |
+
);
|
355 |
+
add_action( 'load-'.$this->admin_page, array( $this, 'add_help_tab' ) );
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
public function add_help_tab() {
|
360 |
+
|
361 |
+
$screen = get_current_screen();
|
362 |
+
if ( $screen->id != $this->admin_page ) {
|
363 |
+
return;
|
364 |
+
}
|
365 |
+
// Add my_help_tab if current screen is My Admin Page
|
366 |
+
$screen->add_help_tab( array(
|
367 |
+
'id' => 'overview',
|
368 |
+
'title' => __( 'Orphans', 'sierotki' ),
|
369 |
+
'content' => '<p>' . __( 'Plugin fix some Polish gramary rules with orphans.', 'sierotki' ) . '</p>',
|
370 |
+
) );
|
371 |
+
/**
|
372 |
+
* make sidebar help
|
373 |
+
*/
|
374 |
+
$screen->set_help_sidebar(
|
375 |
+
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
|
376 |
+
'<p>' . __( '<a href="http://wordpress.org/extend/plugins/sierotki/" target="_blank">Plugin Homepage</a>', 'sierotki' ) . '</p>' .
|
377 |
+
'<p>' . __( '<a href="http://wordpress.org/support/plugin/sierotki/" target="_blank">Support Forums</a>', 'sierotki' ) . '</p>' .
|
378 |
+
'<p>' . __( '<a href="http://iworks.pl/en/" target="_blank">break the web</a>', 'sierotki' ) . '</p>'
|
379 |
+
);
|
380 |
+
|
381 |
+
}
|
382 |
+
|
383 |
+
public function admin_init() {
|
384 |
+
|
385 |
+
foreach ( $this->options as $filter => $option ) {
|
386 |
+
$sanitize_callback = isset( $option['sanitize_callback'] )? $option['sanitize_callback']:null;
|
387 |
+
register_setting( 'sierotki', 'iworks_orphan_'.$filter, $sanitize_callback );
|
388 |
+
}
|
389 |
+
add_filter( 'plugin_row_meta', array( $this, 'links' ), 10, 2 );
|
390 |
+
}
|
391 |
+
|
392 |
+
public function init() {
|
393 |
+
|
394 |
+
if ( 0 == get_option( 'iworks_orphan_initialized', 0 ) ) {
|
395 |
+
foreach ( $this->options as $filter => $option ) {
|
396 |
+
if ( ! isset( $option['type'] ) ) {
|
397 |
+
$option['type'] = 'undefinied';
|
398 |
+
}
|
399 |
+
switch ( $option['type'] ) {
|
400 |
+
case 'checkbox':
|
401 |
+
update_option( 'iworks_orphan_'.$filter, 1 );
|
402 |
+
break;
|
403 |
+
case 'text':
|
404 |
+
default:
|
405 |
+
update_option( 'iworks_orphan_'.$filter, '' );
|
406 |
+
break;
|
407 |
+
}
|
408 |
+
}
|
409 |
+
update_option( 'iworks_orphan_initialized', 1 );
|
410 |
+
}
|
411 |
+
foreach ( array_keys( $this->options ) as $filter ) {
|
412 |
+
if ( 1 == get_option( 'iworks_orphan_'.$filter, 1 ) ) {
|
413 |
+
add_filter( $filter, array( $this, 'replace' ) );
|
414 |
+
}
|
415 |
+
}
|
416 |
+
add_filter( 'iworks_orphan_replace', array( $this, 'replace' ) );
|
417 |
+
}
|
418 |
+
|
419 |
+
public function links( $links, $file ) {
|
420 |
+
|
421 |
+
if ( $file == plugin_basename( __FILE__ ) ) {
|
422 |
+
if ( ! is_multisite() ) {
|
423 |
+
$dir = explode( '/', dirname( __FILE__ ) );
|
424 |
+
$dir = $dir[ count( $dir ) - 1 ];
|
425 |
+
$links[] = '<a href="themes.php?page='.$dir.'.php">' . __( 'Settings' ) . '</a>';
|
426 |
+
}
|
427 |
+
$links[] = '<a href="http://iworks.pl/donate/sierotki.php">' . __( 'Donate' ) . '</a>';
|
428 |
+
}
|
429 |
+
return $links;
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Change the admin footer text on Orphans admin pages.
|
434 |
+
*
|
435 |
+
* @since 2.3
|
436 |
+
* @param string $footer_text
|
437 |
+
* @return string
|
438 |
+
*/
|
439 |
+
public function admin_footer_text( $footer_text ) {
|
440 |
+
if ( ! current_user_can( $this->get_capability() ) ) {
|
441 |
+
return;
|
442 |
+
}
|
443 |
+
$screen = get_current_screen();
|
444 |
+
if ( ! preg_match( '/page_orphan$/', $screen->id ) ) {
|
445 |
+
return;
|
446 |
+
}
|
447 |
+
return sprintf( __( 'If you like <strong>Orphans</strong> please leave us a %s★★★★★%s rating. A huge thanks in advance!', 'sierotki' ), '<a href="https://wordpress.org/support/plugin/sierotki/reviews/?rate=5#new-post" target="_blank">', '</a>' );
|
448 |
+
}
|
449 |
+
}
|