Orphans - Version 2.6.1

Version Description

  • 2016-01-11 =

  • Fixed a problem with non-breakable space. Replace space after number to space between numbers.

Download this release

Release Info

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

Version 2.6.1

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