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