Orphans - Version 2.6

Version Description

  • 2016-01-09 =

  • Change language domain from iworks_orphan to plugin name `sierotki' to be compatible with i18n WordPress rules.

  • Added activate plugin hook to change options autoload status.

  • Added deactivate plugin hook to change options autoload status.

  • Added filter iworks_orphans_capability, thx to Cezary Buliszak.

  • Added non-breakable space after numbers.

  • Added uninstall plugin hook.

  • Update screenshots.

Download this release

Release Info

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

Version 2.6

Files changed (5) hide show
  1. index.php +2 -0
  2. readme.txt +198 -0
  3. sierotki.php +78 -0
  4. uninstall.php +21 -0
  5. vendor/iworks/orphan.php +340 -0
index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ exit;
readme.txt ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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 - 2016-01-09 =
100
+
101
+ * Change language domain from `iworks_orphan` to plugin name `sierotki' to be compatible with i18n WordPress rules.
102
+ * Added activate plugin hook to change options autoload status.
103
+ * Added deactivate plugin hook to change options autoload status.
104
+ * Added filter `iworks_orphans_capability`, thx to Cezary Buliszak.
105
+ * Added non-breakable space after numbers.
106
+ * Added uninstall plugin hook.
107
+ * Update screenshots.
108
+
109
+ = 2.5 - 2015-11-06 =
110
+
111
+ * IMPROVEMENT: added filter `iworks_orphan_replace`
112
+
113
+ = 2.4 - 2015-02-12 =
114
+
115
+ * IMPROVEMENT: added hard space between number (year) and polish year shortcut "r."
116
+ * IMPROVEMENT: added WooCommerce product title and short description to available options. thx to [Dominik Kawula](https://www.facebook.com/dominik.kawula)
117
+
118
+ = 2.3.2 - 2014-09-12 =
119
+
120
+ * BUGFIX: fixed error in options array
121
+
122
+ = 2.3.1 - 2014-09-12 =
123
+
124
+ * BUGFIX: checked option array for non existing hash.
125
+ * IMPROVEMENT: update screenshot.
126
+
127
+ = 2.3 - 2014-07-10 =
128
+
129
+ * IMPROVEMENT: added all forms of word number
130
+
131
+ = 2.2 - 2014-01-24 =
132
+
133
+ * IMPROVEMENT:added links to forum
134
+ * IMPROVEMENT:checked capability with WP 3.8
135
+
136
+ = 2.1 - 2013-11-09 =
137
+
138
+ * IMPROVEMENT:checked capability with WP 3.6
139
+ * REFACTORING: implement PSR-0 rules to orphan class
140
+
141
+ = 2.0.2 - 2013-08-20 =
142
+
143
+ * BUGFIX: fixed replacement for single letter orphan after orphan thx to [Szymon Skulimowski](http://wpninja.pl/autorzy/szymon-skulimowski/)
144
+ * IMPROVEMENT:checked capability with WP 3.6
145
+ * IMPROVEMENT:added help and related section
146
+
147
+ = 2.0.1 - 2013-07-10 =
148
+
149
+ * IMPROVEMENT:added numbers
150
+
151
+ = 2.0 - 2012-08-12 =
152
+
153
+ * BUGFIX: fixed permissions to configuration page
154
+ * BUGFIX: fixed replacement for strings starting with a orphan
155
+ * REFACTORING: rewrite code to the class
156
+ * IMPROVEMENT:added some shorts of academic degree
157
+ * IMPROVEMENT:massive increase orphans dictionary thx to [adpawl](http://podbabiogorze.info.pl)
158
+
159
+ = 1.4.2 - 2012-03-02 =
160
+
161
+ * NEW: added the_title filter.
162
+
163
+ = 1.4.1 - 2011-02-24 =
164
+
165
+ * NEW: Trim chars.
166
+ * BUGFIX: Fixed multi coma use.
167
+
168
+ = 1.4 - 2011-02-24 =
169
+
170
+ * NEW: Added user defined orphans.
171
+ * BUGFIX: Corrected capability name.
172
+
173
+ = 1.3 - 2011-02-19 =
174
+
175
+ * NEW: Added option page to turn on/off filtering in content, excerpt or comments.
176
+ * NEW: Added "(" as char before a orphan.
177
+
178
+ = 1.2 - 2011-02-18 =
179
+
180
+ * NEW: Added filter comment_text.
181
+ * BUGFIX: Capital letters was missing by plugin.
182
+
183
+ = 1.1 - 2011-02-17 =
184
+
185
+ * Abandoning elegant anonymous function, which requires PHP 5.3.0 :(
186
+ * NEW: Added filter to the_excerpt.
187
+
188
+ = 1.0.2 - 2011-02-17 =
189
+
190
+ * NEW: Added ">" as char before a orphan.
191
+
192
+ = 1.0.1 - 2011-02-16 =
193
+
194
+ * NEW: Added word "to".
195
+
196
+ = 1.0 - 2011-02-16 =
197
+
198
+ * 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
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,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 2.6
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' => __('Allowto keep together phone number or number with unit e.g. 10 kg.', '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
+ $content = preg_replace( "/([0-9]{1,10})\s/", "$1&nbsp;", $content);
151
+ }
152
+
153
+ return $content;
154
+ }
155
+
156
+ public function option_page()
157
+ {
158
+ ?>
159
+ <div class="wrap">
160
+ <h2><?php _e('Orphans', 'sierotki') ?></h2>
161
+ <div class="postbox-container" style="width:75%">
162
+ <form method="post" action="options.php">
163
+ <?php settings_fields('sierotki'); ?>
164
+ <table class="form-table">
165
+ <tbody>
166
+ <?php
167
+ foreach ( $this->options as $filter => $option ) {
168
+ /**
169
+ * check option type
170
+ */
171
+ if (
172
+ 0
173
+ || !is_array($option)
174
+ || empty($option)
175
+ || !array_key_exists('type', $option )
176
+ ) {
177
+ continue;
178
+ }
179
+ $field = 'iworks_orphan_'.$filter;
180
+ printf (
181
+ '<tr valign="top"><th scope="row">%s</th><td>',
182
+ array_key_exists('description', $option)? $option['description']:'&nbsp;'
183
+ );
184
+ switch( $option['type'] ) {
185
+ case 'checkbox':
186
+ printf (
187
+ '<label for="%s"><input type="checkbox" name="%s" value="1"%s id="%s"/> %s</label>',
188
+ $field,
189
+ $field,
190
+ checked(1, get_option($field, 1), false),
191
+ $field,
192
+ isset($option['label'])? $option['label']:'&nbsp;'
193
+ );
194
+ break;
195
+ case 'text':
196
+ default:
197
+ printf (
198
+ '<input type="text" name="%s" value="%s" id="%s" class="regular-text code" />%s',
199
+ $field,
200
+ get_option($field, ''),
201
+ $field,
202
+ isset($option['label'])? '<p class="description">'.$option['label'].'</p>':''
203
+ );
204
+ break;
205
+ }
206
+ print '</td></tr>';
207
+ }
208
+ ?>
209
+ </tbody>
210
+ </table>
211
+ <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
212
+ </form>
213
+ </div>
214
+ <div class="postbox-container" style="width:23%;margin-left:2%">
215
+ <div class="metabox-holder">
216
+ <div id="links" class="postbox">
217
+ <h3 class="hndle"><?php _e('Loved this Plugin?', 'sierotki' ); ?></h3>
218
+ <div class="inside">
219
+ <p><?php _e('Below are some links to help spread this plugin to other users', 'sierotki' ); ?></p>
220
+ <ul>
221
+ <li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e('Give it a 5 star on Wordpress.org', 'sierotki' ); ?></a></li>
222
+ <li><a href="http://wordpress.org/extend/plugins/sierotki/"><?php _e('Link to it so others can easily find it', 'sierotki' ); ?></a></li>
223
+ </ul>
224
+ </div>
225
+ </div>
226
+ <div id="help" class="postbox">
227
+ <h3 class="hndle"><?php _e('Need Assistance?', 'sierotki' ); ?></h3>
228
+ <div class="inside">
229
+ <p><?php _e('Problems? The links bellow can be very helpful to you', 'sierotki' ); ?></p>
230
+ <ul>
231
+ <li><a href="<?php _e('http://wordpress.org/support/plugin/sierotki', 'sierotki' ); ?>"><?php _e('Wordpress Help Forum', 'sierotki' ); ?></a></li>
232
+ <li><a href="mailto:<?php echo antispambot('marcin@iworks.pl'); ?>"><?php echo antispambot('marcin@iworks.pl' ); ?></a></li>
233
+ </ul>
234
+ <hr />
235
+ <p class="description"><?php _e('Created by: ', 'sierotki' ); ?> <a href="http://iworks.pl/"><span>iWorks.pl</span></a></p>
236
+ </div>
237
+ </div>
238
+ </div>
239
+ </div>
240
+ </div><?php
241
+ }
242
+
243
+ public function admin_menu()
244
+ {
245
+ if ( function_exists('add_theme_page' ) ) {
246
+ $this->admin_page = add_theme_page(
247
+ __('Orphans', 'sierotki'),
248
+ __('Orphans', 'sierotki'),
249
+ /**
250
+ * Allow to change capability.
251
+ *
252
+ * This filter allow to change capability which is needed to
253
+ * access to Orphans configuration page.
254
+ *
255
+ * @since 2.6.0
256
+ *
257
+ * @param string $capability current capability
258
+ *
259
+ */
260
+ apply_filters('iworks_orphans_capability', 'manage_options'),
261
+ basename(__FILE__),
262
+ array( $this, 'option_page' )
263
+ );
264
+ add_action('load-'.$this->admin_page, array( $this, 'add_help_tab' ) );
265
+ }
266
+ }
267
+
268
+ public function add_help_tab()
269
+ {
270
+ $screen = get_current_screen();
271
+ if ( $screen->id != $this->admin_page ) {
272
+ return;
273
+ }
274
+ // Add my_help_tab if current screen is My Admin Page
275
+ $screen->add_help_tab( array(
276
+ 'id' => 'overview',
277
+ 'title' => __('Orphans', 'sierotki' ),
278
+ 'content' => '<p>' . __('Plugin fix some Polish gramary rules with orphans.', 'sierotki' ) . '</p>',
279
+ ) );
280
+ /**
281
+ * make sidebar help
282
+ */
283
+ $screen->set_help_sidebar(
284
+ '<p><strong>' . __('For more information:' ) . '</strong></p>' .
285
+ '<p>' . __('<a href="http://wordpress.org/extend/plugins/sierotki/" target="_blank">Plugin Homepage</a>', 'sierotki' ) . '</p>' .
286
+ '<p>' . __('<a href="http://wordpress.org/support/plugin/sierotki/" target="_blank">Support Forums</a>', 'sierotki' ) . '</p>' .
287
+ '<p>' . __('<a href="http://iworks.pl/en/" target="_blank">break the web</a>', 'sierotki' ) . '</p>'
288
+ );
289
+
290
+ }
291
+
292
+ public function admin_init()
293
+ {
294
+ foreach ( $this->options as $filter => $option) {
295
+ $sanitize_callback = isset($option['sanitize_callback'])? $option['sanitize_callback']:null;
296
+ register_setting('sierotki', 'iworks_orphan_'.$filter, $sanitize_callback);
297
+ }
298
+ add_filter('plugin_row_meta', array( $this, 'links' ), 10, 2 );
299
+ }
300
+
301
+ public function init()
302
+ {
303
+ if ( 0 == get_option('iworks_orphan_initialized', 0 ) ) {
304
+ foreach ( $this->options as $filter => $option ) {
305
+ if ( !isset( $option['type'] ) ) {
306
+ $option['type'] = 'undefinied';
307
+ }
308
+ switch( $option['type'] ) {
309
+ case 'checkbox':
310
+ update_option('iworks_orphan_'.$filter, 1);
311
+ break;
312
+ case 'text':
313
+ default:
314
+ update_option('iworks_orphan_'.$filter, '');
315
+ break;
316
+ }
317
+ }
318
+ update_option('iworks_orphan_initialized', 1);
319
+ }
320
+ foreach ( array_keys( $this->options ) as $filter ) {
321
+ if ( 1 == get_option('iworks_orphan_'.$filter, 1 ) ) {
322
+ add_filter($filter, array($this, 'replace'));
323
+ }
324
+ }
325
+ add_filter('iworks_orphan_replace', array($this, 'replace'));
326
+ }
327
+
328
+ public function links($links, $file)
329
+ {
330
+ if ( $file == plugin_basename(__FILE__) ) {
331
+ if ( !is_multisite() ) {
332
+ $dir = explode('/', dirname(__FILE__));
333
+ $dir = $dir[ count( $dir ) - 1 ];
334
+ $links[] = '<a href="themes.php?page='.$dir.'.php">' . __('Settings') . '</a>';
335
+ }
336
+ $links[] = '<a href="http://iworks.pl/donate/sierotki.php">' . __('Donate') . '</a>';
337
+ }
338
+ return $links;
339
+ }
340
+ }