PS Disable Auto Formatting - Version 1.0.6

Version Description

Download this release

Release Info

Developer jim912
Plugin Icon wp plugin PS Disable Auto Formatting
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

Files changed (2) hide show
  1. ps_disable_auto_formatting.php +307 -311
  2. readme.txt +3 -1
ps_disable_auto_formatting.php CHANGED
@@ -1,311 +1,307 @@
1
- <?php
2
- /*
3
- Plugin Name: PS Disable Auto Formatting
4
- Plugin URI: http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/
5
- Description: PS Disable Auto Formatting is able to disable function auto formatting (wpautop) and save &lt;p&gt; and &lt;br /&gt; formatted content.
6
- Version: 1.0.5
7
- Author: Hitoshi Omagari
8
- Author URI: http://www.web-strategy.jp/
9
- */
10
-
11
- class ps_disable_auto_formatting {
12
-
13
- var $setting_items = array(
14
- 'content formatting' => 'the_content',
15
- 'comment formatting' => 'comment_text',
16
- 'excerpt formatting' => 'the_excerpt',
17
- 'term description formatting' => 'term_description',
18
- );
19
-
20
- var $mce_version = '20080121';
21
-
22
- function __construct() {
23
- global $wp_version;
24
-
25
- if ( version_compare( $wp_version, '2.5', '>=' ) ) {
26
- add_action( 'init', array( &$this, 'disable_auto_formatting_init' ) );
27
- add_action( 'admin_menu', array( &$this, 'add_disable_formatting_setting_page') );
28
- add_filter( 'print_scripts_array', array( &$this, 'rewrite_default_script' ) );
29
- add_filter( 'wp_insert_post_data', array( &$this, 'formatting_quickpress_post' ) );
30
- add_action( 'media_buttons', array( &$this, 'check_edit_mode_and_add_richedit_pre' ), 9 );
31
- add_action( 'media_buttons', array( &$this, 'delete_filtering_wp_richedit_pre' ) );
32
- } else {
33
- add_action('admin_notices', array( &$this, 'version_too_old' ) );
34
- }
35
- }
36
-
37
-
38
- function ps_disable_auto_formatting() {
39
- $this->__construct();
40
- }
41
-
42
-
43
- function disable_auto_formatting_init() {
44
- $locale = get_locale();
45
- $lang_file = dirname( __file__ ) . '/language/ps_disable_auto_formatting-' . $locale . '.mo';
46
-
47
- if ( file_exists( $lang_file ) ) {
48
- load_textdomain( 'ps_disable_auto_formatting', $lang_file );
49
- }
50
-
51
- $this->option_settings = get_option( 'ps_disable_auto_formatting' );
52
-
53
- if ( $this->option_settings === false ) {
54
- $this->set_default_settings();
55
- $this->option_settings = get_option( 'ps_disable_auto_formatting' );
56
- } elseif ( ! $this->option_settings ) {
57
- $this->option_settings = array();
58
- }
59
- $this->delete_default_filters();
60
- }
61
-
62
-
63
- function delete_default_filters() {
64
- global $wp_filter;
65
-
66
- foreach ( $this->option_settings as $hook ) {
67
- if ( $hook == 'comment_text' ) {
68
- $priority = 30;
69
- } else {
70
- $priority = 10;
71
- }
72
- remove_filter( $hook, 'wpautop', $priority );
73
- if ( $hook == 'the_content' ) {
74
- foreach ( array_keys( $wp_filter['the_content'][10] ) as $hook_name ) {
75
- if ( strpos( $hook_name, 'tam_contact_form_sevenwpautop_substitute' ) !== false ) {
76
- remove_filter( 'the_content', $hook_name );
77
- }
78
- }
79
- }
80
- }
81
- }
82
-
83
-
84
- function set_default_settings() {
85
- $default = array( 'the_content' );
86
- update_option( 'ps_disable_auto_formatting', $default );
87
- }
88
-
89
-
90
- function rewrite_default_script( $todo ) {
91
- global $wp_version, $wp_scripts;
92
-
93
- if ( version_compare( $wp_version, '2.8', '>=' ) ) {
94
- $scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/280/ps_editor.js';
95
- } elseif ( version_compare( $wp_version, '2.7', '>=' ) ) {
96
- $scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/270/ps_editor.js';
97
- } else {
98
- $scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/250/ps_editor.js';
99
- if ( version_compare( $wp_version, '2.6', '>=' ) ) {
100
- $wp_scripts->registered['editor_functions']->src = $scripyt_src;
101
- } else {
102
- $wp_scripts->scripts['editor_functions']->src = $scripyt_src;
103
- }
104
- }
105
- wp_enqueue_script( 'ps_editor', $scripyt_src );
106
- if ( version_compare( $wp_version, '3.1', '>=' ) ) {
107
- wp_dequeue_script( 'editor' );
108
- } else {
109
- $key = array_search( 'editor', $todo );
110
- if ( $key !== false ) {
111
- if ( version_compare( $wp_version, '2.7', '>=' ) ) {
112
- $todo[$key] = 'ps_editor';
113
- } else {
114
- unset( $todo[$key] );
115
- }
116
- }
117
- }
118
- return $todo;
119
- }
120
-
121
-
122
- function formatting_quickpress_post( $data ) {
123
- global $action;
124
-
125
- if ( in_array( $action, array( 'post-quickpress-publish', 'post-quickpress-save' ) ) ) {
126
- if ( empty( $_POST['quickpress_post_ID'] ) ) {
127
- $data['post_content'] = wpautop( $data['post_content'] );
128
- }
129
- }
130
- return $data;
131
- }
132
-
133
-
134
- function delete_filtering_wp_richedit_pre() {
135
- remove_filter( 'the_editor_content', 'wp_richedit_pre' );
136
- }
137
-
138
-
139
- function check_edit_mode_and_add_richedit_pre() {
140
- global $wp_filter;
141
- if ( isset( $wp_filter['the_editor_content'][10]['wp_richedit_pre'] ) ) {
142
- add_filter( 'the_editor_content', array( &$this, 'ps_richedit_pre' ) );
143
- }
144
- }
145
-
146
-
147
- function ps_richedit_pre( $text ) {
148
- if ( empty($text) ) return apply_filters('richedit_pre', '');
149
-
150
- $output = convert_chars($text);
151
- $output = htmlspecialchars($output, ENT_NOQUOTES);
152
-
153
- return apply_filters('richedit_pre', $output);
154
- }
155
-
156
-
157
- function add_disable_formatting_setting_page() {
158
- add_options_page( 'PS Disable Auto Formatting', __( 'Auto Formatting', 'ps_disable_auto_formatting' ), 'activate_plugins', basename( __FILE__ ), array( &$this, 'output_disable_formatting_setting_page') );
159
- }
160
-
161
-
162
- function output_disable_formatting_setting_page() {
163
- global $wpdb, $wp_error;
164
- if( isset( $_POST['_wpnonce'] ) && $_POST['_wpnonce'] ) {
165
- check_admin_referer();
166
-
167
- if ( isset( $_POST['batch_formatting'] ) && $_POST['batch_formatting'] ) {
168
- if ( $_POST['allow_batch_formatting'] ) {
169
- $time_limit = sprintf( '%04d-%02d-%02d %02d:%02d:00', $_POST['aa'], $_POST['mm'], $_POST['jj'], $_POST['hh'], $_POST['mn'] );
170
- $sql = "
171
- SELECT `ID`
172
- FROM $wpdb->posts
173
- WHERE `post_status` IN ( 'publish', 'draft', 'pending' )
174
- AND `post_type` IN ( 'post', 'page' )
175
- AND `post_modified` < '$time_limit'
176
- ";
177
- $formatting_posts = $wpdb->get_results( $sql, ARRAY_A );
178
- $formatted_posts = array();
179
-
180
- if ( $formatting_posts ) {
181
- foreach ( $formatting_posts as $row ) {
182
- $data = array();
183
- $post = get_post( $row['ID'] );
184
- $data['post_content'] = wpautop( $post->post_content );
185
- if ( $post->post_content_filtered ) {
186
- $data['post_content_filtered'] = wpautop( $post->post_content_filtered );
187
- }
188
- $data['post_modified_gmt'] = current_time( 'mysql', 1 );
189
- $data['post_modified'] = current_time( 'mysql' );
190
-
191
- do_action( 'pre_post_update', $post->ID );
192
- if ( false === $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post->ID ) ) ) {
193
- if ( $wp_error ) {
194
- $error_mes = new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
195
- break;
196
- } else {
197
- $error_mes = __( 'Database is not found.', 'ps_disable_auto_formatting' );
198
- break;
199
- }
200
- }
201
- $formatted_posts[] = $row['ID'];
202
- }
203
- if ( ! $error_mes ) {
204
- $batch_ret = true;
205
- }
206
- } else {
207
- $error_mes = __( 'No formatting post or page exists.', 'ps_disable_auto_formatting' );
208
- }
209
- } else {
210
- $error_mes = __( 'Require checked allow batch formatting.', 'ps_disable_auto_formatting' );
211
- }
212
- } else {
213
- if ( isset( $_POST['ps_disable_auto_formatting'] ) ) {
214
- $post_data = stripslashes_deep( $_POST['ps_disable_auto_formatting'] );
215
- } else {
216
- $post_data = array();
217
- }
218
- foreach ( $post_data as $key => $func ) {
219
- if ( ! in_array( $func, $this->setting_items) ) {
220
- unset( $_POST['ps_disable_auto_formatting'][$key] );
221
- }
222
- }
223
- $ret = update_option( 'ps_disable_auto_formatting', $post_data );
224
- if ( $ret ) {
225
- $this->option_settings = get_option( 'ps_disable_auto_formatting' );
226
- }
227
- }
228
- }
229
-
230
- ?>
231
- <div class=wrap>
232
- <?php if ( function_exists( 'screen_icon' ) ) { screen_icon(); } ?>
233
- <h2><?php _e( 'Auto Formatting', 'ps_disable_auto_formatting' ); ?></h2>
234
- <?php if ( isset( $ret ) && $ret ) { ?>
235
- <div id="message" class="updated">
236
- <p><?php _e('The settings has changed successfully.', 'ps_disable_auto_formatting' );?></p>
237
- </div>
238
- <?php } elseif ( isset( $batch_ret ) && $batch_ret ) { ?>
239
- <div id="message" class="updated">
240
- <p><?php printf( __( 'Batch fomatting process has completed. total %d posts formatted.', 'ps_disable_auto_formatting' ), count( $formatting_posts ) );?></p>
241
- </div>
242
- <?php } elseif ( isset( $error_mes ) && $error_mes ) { ?>
243
- <div id="notice" class="error">
244
- <p><?php echo wp_specialchars( $error_mes ); ?></p>
245
- </div>
246
- <?php } elseif ( isset( $_POST['ps_disable_auto_formatting'] ) && $_POST['ps_disable_auto_formatting'] && isset( $ret ) && ! $ret ) { ?>
247
- <div id="notice" class="error">
248
- <p><?php _e('The settings has not been changed. There were no changes or failed to update the data base.', 'ps_disable_auto_formatting' );?></p>
249
- </div>
250
- <?php } ?>
251
- <form method="post" action="">
252
- <?php wp_nonce_field(); ?>
253
- <table class="form-table">
254
- <?php foreach( $this->setting_items as $id => $func ) { ?>
255
- <tr>
256
- <th><?php _e( $id, 'ps_disable_auto_formatting' ); ?></th>
257
- <td>
258
- <input type="checkbox" id="ps_disable_auto_formatting_<?php echo $func ?>" name="ps_disable_auto_formatting[]" value="<?php echo $func ?>"<?php if ( in_array( $func, $this->option_settings ) ) { echo ' checked="checked"'; } ?> />
259
- <label for="ps_disable_auto_formatting_<?php echo $func ?>"><?php _e( 'disable', 'ps_disable_auto_formatting' ); ?></label>
260
- </td>
261
- </tr>
262
- <?php } ?>
263
- </table>
264
- <p class="submit">
265
- <input type="submit" name="ps_disable_auto_formatting_submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" />
266
- </p>
267
- <?php if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { ?>
268
- <h3><?php _e( 'Batch formatting for past posts' ,'ps_disable_auto_formatting' ); ?></h3>
269
- <?php _e( '<p>To make it display the same as the format before run this plug-in,
270
- automatic operation process to the specified period of the posts.<br />
271
- Even if some unexpected errors occur, the data is restorable because
272
- rivision on the processed post is made.<br />
273
- This process is safe even if you do two or more times, perhaps. We cannot assure though.<br />
274
- * It is strongly recommended to take the <a href="http://codex.wordpress.org/Backing_Up_Your_Database" title="Backing Up Your Database">backup your database</a> before processing.</p>' ,'ps_disable_auto_formatting' ); ?>
275
- <table class="form-table">
276
- <tr>
277
- <th><?php _e( 'Formatting before' ,'ps_disable_auto_formatting' ); ?></th>
278
- <td>
279
- <?php global $comment; $comment->comment_date = current_time( 'mysql' ); touch_time( 0, 0, 0, 1 ); ?><br />
280
- <?php _e( '* Formatting posts and pages are modified before this time.' ,'ps_disable_auto_formatting' ); ?>
281
- </td>
282
- </tr>
283
- </table>
284
- <div>
285
- <span class="submit"><input type="submit" name="batch_formatting" value="<?php _e( 'Batch formatting', 'ps_disable_auto_formatting' ); ?>" /></span>
286
- &nbsp;&nbsp;&nbsp;<input type="checkbox" id="allow_batch_formatting" name="allow_batch_formatting" value="1" />
287
- <label for="allow_batch_formatting"><?php _e( 'Allow batch formatting', 'ps_disable_auto_formatting' ); ?></label>
288
- </div>
289
- <?php } ?>
290
- </form>
291
- <p><?php _e( 'If you have any problems or find a bug in this plugin, please <a href="http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/#postcomment">report to us</a>.' , 'ps_disable_auto_formatting' ); ?></p>
292
- </div>
293
- <?php
294
- }
295
-
296
-
297
- function version_too_old() {
298
- global $wp_version;
299
- echo '<div class="updated fade"><p>' . sprintf( __( 'Sorry, Your WordPress (version %s) is old to use PS Disable Auto Formatting plugin. Please upgrade to version 2.5 or higher.', 'ps_disable_auto_formatting' ), $wp_version ) . '</p></div>';
300
- $active_plugins = get_option('active_plugins');
301
- $search_plugin = str_replace( str_replace( '\\', '/', ABSPATH . PLUGINDIR . '/' ), '', str_replace( '\\', '/', __file__ ) );
302
- $key = array_search( $search_plugin, $active_plugins );
303
- if ( $key !== false ) {
304
- unset( $active_plugins[$key] );
305
- }
306
- update_option( 'active_plugins', $active_plugins );
307
- }
308
-
309
- } // class end
310
-
311
- $ps_disable_auto_formatting =& new ps_disable_auto_formatting();
1
+ <?php
2
+ /*
3
+ Plugin Name: PS Disable Auto Formatting
4
+ Plugin URI: http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/
5
+ Description: PS Disable Auto Formatting is able to disable function auto formatting (wpautop) and save &lt;p&gt; and &lt;br /&gt; formatted content.
6
+ Version: 1.0.6
7
+ Author: Hitoshi Omagari
8
+ Author URI: http://www.web-strategy.jp/
9
+ */
10
+
11
+ class ps_disable_auto_formatting {
12
+
13
+ var $setting_items = array(
14
+ 'content formatting' => 'the_content',
15
+ 'comment formatting' => 'comment_text',
16
+ 'excerpt formatting' => 'the_excerpt',
17
+ 'term description formatting' => 'term_description',
18
+ );
19
+
20
+ var $mce_version = '20080121';
21
+
22
+ function __construct() {
23
+ global $wp_version;
24
+
25
+ if ( version_compare( $wp_version, '2.5', '>=' ) ) {
26
+ add_action( 'init', array( &$this, 'disable_auto_formatting_init' ) );
27
+ add_action( 'admin_menu', array( &$this, 'add_disable_formatting_setting_page') );
28
+ add_filter( 'print_scripts_array', array( &$this, 'rewrite_default_script' ) );
29
+ add_filter( 'wp_insert_post_data', array( &$this, 'formatting_quickpress_post' ) );
30
+ add_action( 'media_buttons', array( &$this, 'check_edit_mode_and_add_richedit_pre' ), 9 );
31
+ add_action( 'media_buttons', array( &$this, 'delete_filtering_wp_richedit_pre' ) );
32
+ } else {
33
+ add_action('admin_notices', array( &$this, 'version_too_old' ) );
34
+ }
35
+ }
36
+
37
+
38
+ function ps_disable_auto_formatting() {
39
+ $this->__construct();
40
+ }
41
+
42
+
43
+ function disable_auto_formatting_init() {
44
+ $locale = get_locale();
45
+ $lang_file = dirname( __file__ ) . '/language/ps_disable_auto_formatting-' . $locale . '.mo';
46
+
47
+ if ( file_exists( $lang_file ) ) {
48
+ load_textdomain( 'ps_disable_auto_formatting', $lang_file );
49
+ }
50
+
51
+ $this->option_settings = get_option( 'ps_disable_auto_formatting' );
52
+
53
+ if ( $this->option_settings === false ) {
54
+ $this->set_default_settings();
55
+ $this->option_settings = get_option( 'ps_disable_auto_formatting' );
56
+ } elseif ( ! $this->option_settings ) {
57
+ $this->option_settings = array();
58
+ }
59
+ $this->delete_default_filters();
60
+ }
61
+
62
+
63
+ function delete_default_filters() {
64
+ global $wp_filter;
65
+
66
+ foreach ( $this->option_settings as $hook ) {
67
+ if ( $hook == 'comment_text' ) {
68
+ $priority = 30;
69
+ } else {
70
+ $priority = 10;
71
+ }
72
+ remove_filter( $hook, 'wpautop', $priority );
73
+ if ( $hook == 'the_content' ) {
74
+ foreach ( array_keys( $wp_filter['the_content'][10] ) as $hook_name ) {
75
+ if ( strpos( $hook_name, 'tam_contact_form_sevenwpautop_substitute' ) !== false ) {
76
+ remove_filter( 'the_content', $hook_name );
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+
83
+
84
+ function set_default_settings() {
85
+ $default = array( 'the_content' );
86
+ update_option( 'ps_disable_auto_formatting', $default );
87
+ }
88
+
89
+
90
+ function rewrite_default_script( $todo ) {
91
+ global $wp_version, $wp_scripts;
92
+
93
+ if ( version_compare( $wp_version, '2.8', '>=' ) ) {
94
+ $scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/280/ps_editor.js';
95
+ } elseif ( version_compare( $wp_version, '2.7', '>=' ) ) {
96
+ $scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/270/ps_editor.js';
97
+ } else {
98
+ $scripyt_src = get_option( 'siteurl' ) . '/' . str_replace( str_replace( '\\', '/', ABSPATH ), '', str_replace( '\\', '/', dirname( __file__ ) ) ) . '/js/250/ps_editor.js';
99
+ if ( version_compare( $wp_version, '2.6', '>=' ) ) {
100
+ $wp_scripts->registered['editor_functions']->src = $scripyt_src;
101
+ } else {
102
+ $wp_scripts->scripts['editor_functions']->src = $scripyt_src;
103
+ }
104
+ }
105
+ $wp_scripts->add( 'ps_editor', $scripyt_src, false, $this->mce_version );
106
+ $key = array_search( 'editor', $todo );
107
+ if ( $key !== false ) {
108
+ if ( version_compare( $wp_version, '2.7', '>=' ) ) {
109
+ $todo[$key] = 'ps_editor';
110
+ } else {
111
+ unset( $todo[$key] );
112
+ }
113
+ }
114
+ return $todo;
115
+ }
116
+
117
+
118
+ function formatting_quickpress_post( $data ) {
119
+ global $action;
120
+
121
+ if ( in_array( $action, array( 'post-quickpress-publish', 'post-quickpress-save' ) ) ) {
122
+ if ( empty( $_POST['quickpress_post_ID'] ) ) {
123
+ $data['post_content'] = wpautop( $data['post_content'] );
124
+ }
125
+ }
126
+ return $data;
127
+ }
128
+
129
+
130
+ function delete_filtering_wp_richedit_pre() {
131
+ remove_filter( 'the_editor_content', 'wp_richedit_pre' );
132
+ }
133
+
134
+
135
+ function check_edit_mode_and_add_richedit_pre() {
136
+ global $wp_filter;
137
+ if ( isset( $wp_filter['the_editor_content'][10]['wp_richedit_pre'] ) ) {
138
+ add_filter( 'the_editor_content', array( &$this, 'ps_richedit_pre' ) );
139
+ }
140
+ }
141
+
142
+
143
+ function ps_richedit_pre( $text ) {
144
+ if ( empty($text) ) return apply_filters('richedit_pre', '');
145
+
146
+ $output = convert_chars($text);
147
+ $output = htmlspecialchars($output, ENT_NOQUOTES);
148
+
149
+ return apply_filters('richedit_pre', $output);
150
+ }
151
+
152
+
153
+ function add_disable_formatting_setting_page() {
154
+ add_options_page( 'PS Disable Auto Formatting', __( 'Auto Formatting', 'ps_disable_auto_formatting' ), 'activate_plugins', basename( __FILE__ ), array( &$this, 'output_disable_formatting_setting_page') );
155
+ }
156
+
157
+
158
+ function output_disable_formatting_setting_page() {
159
+ global $wpdb, $wp_error;
160
+ if( isset( $_POST['_wpnonce'] ) && $_POST['_wpnonce'] ) {
161
+ check_admin_referer();
162
+
163
+ if ( isset( $_POST['batch_formatting'] ) && $_POST['batch_formatting'] ) {
164
+ if ( $_POST['allow_batch_formatting'] ) {
165
+ $time_limit = sprintf( '%04d-%02d-%02d %02d:%02d:00', $_POST['aa'], $_POST['mm'], $_POST['jj'], $_POST['hh'], $_POST['mn'] );
166
+ $sql = "
167
+ SELECT `ID`
168
+ FROM $wpdb->posts
169
+ WHERE `post_status` IN ( 'publish', 'draft', 'pending' )
170
+ AND `post_type` IN ( 'post', 'page' )
171
+ AND `post_modified` < '$time_limit'
172
+ ";
173
+ $formatting_posts = $wpdb->get_results( $sql, ARRAY_A );
174
+ $formatted_posts = array();
175
+
176
+ if ( $formatting_posts ) {
177
+ foreach ( $formatting_posts as $row ) {
178
+ $data = array();
179
+ $post = get_post( $row['ID'] );
180
+ $data['post_content'] = wpautop( $post->post_content );
181
+ if ( $post->post_content_filtered ) {
182
+ $data['post_content_filtered'] = wpautop( $post->post_content_filtered );
183
+ }
184
+ $data['post_modified_gmt'] = current_time( 'mysql', 1 );
185
+ $data['post_modified'] = current_time( 'mysql' );
186
+
187
+ do_action( 'pre_post_update', $post->ID );
188
+ if ( false === $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post->ID ) ) ) {
189
+ if ( $wp_error ) {
190
+ $error_mes = new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
191
+ break;
192
+ } else {
193
+ $error_mes = __( 'Database is not found.', 'ps_disable_auto_formatting' );
194
+ break;
195
+ }
196
+ }
197
+ $formatted_posts[] = $row['ID'];
198
+ }
199
+ if ( ! $error_mes ) {
200
+ $batch_ret = true;
201
+ }
202
+ } else {
203
+ $error_mes = __( 'No formatting post or page exists.', 'ps_disable_auto_formatting' );
204
+ }
205
+ } else {
206
+ $error_mes = __( 'Require checked allow batch formatting.', 'ps_disable_auto_formatting' );
207
+ }
208
+ } else {
209
+ if ( isset( $_POST['ps_disable_auto_formatting'] ) ) {
210
+ $post_data = stripslashes_deep( $_POST['ps_disable_auto_formatting'] );
211
+ } else {
212
+ $post_data = array();
213
+ }
214
+ foreach ( $post_data as $key => $func ) {
215
+ if ( ! in_array( $func, $this->setting_items) ) {
216
+ unset( $_POST['ps_disable_auto_formatting'][$key] );
217
+ }
218
+ }
219
+ $ret = update_option( 'ps_disable_auto_formatting', $post_data );
220
+ if ( $ret ) {
221
+ $this->option_settings = get_option( 'ps_disable_auto_formatting' );
222
+ }
223
+ }
224
+ }
225
+
226
+ ?>
227
+ <div class=wrap>
228
+ <?php if ( function_exists( 'screen_icon' ) ) { screen_icon(); } ?>
229
+ <h2><?php _e( 'Auto Formatting', 'ps_disable_auto_formatting' ); ?></h2>
230
+ <?php if ( isset( $ret ) && $ret ) { ?>
231
+ <div id="message" class="updated">
232
+ <p><?php _e('The settings has changed successfully.', 'ps_disable_auto_formatting' );?></p>
233
+ </div>
234
+ <?php } elseif ( isset( $batch_ret ) && $batch_ret ) { ?>
235
+ <div id="message" class="updated">
236
+ <p><?php printf( __( 'Batch fomatting process has completed. total %d posts formatted.', 'ps_disable_auto_formatting' ), count( $formatting_posts ) );?></p>
237
+ </div>
238
+ <?php } elseif ( isset( $error_mes ) && $error_mes ) { ?>
239
+ <div id="notice" class="error">
240
+ <p><?php echo wp_specialchars( $error_mes ); ?></p>
241
+ </div>
242
+ <?php } elseif ( isset( $_POST['ps_disable_auto_formatting'] ) && $_POST['ps_disable_auto_formatting'] && isset( $ret ) && ! $ret ) { ?>
243
+ <div id="notice" class="error">
244
+ <p><?php _e('The settings has not been changed. There were no changes or failed to update the data base.', 'ps_disable_auto_formatting' );?></p>
245
+ </div>
246
+ <?php } ?>
247
+ <form method="post" action="">
248
+ <?php wp_nonce_field(); ?>
249
+ <table class="form-table">
250
+ <?php foreach( $this->setting_items as $id => $func ) { ?>
251
+ <tr>
252
+ <th><?php _e( $id, 'ps_disable_auto_formatting' ); ?></th>
253
+ <td>
254
+ <input type="checkbox" id="ps_disable_auto_formatting_<?php echo $func ?>" name="ps_disable_auto_formatting[]" value="<?php echo $func ?>"<?php if ( in_array( $func, $this->option_settings ) ) { echo ' checked="checked"'; } ?> />
255
+ <label for="ps_disable_auto_formatting_<?php echo $func ?>"><?php _e( 'disable', 'ps_disable_auto_formatting' ); ?></label>
256
+ </td>
257
+ </tr>
258
+ <?php } ?>
259
+ </table>
260
+ <p class="submit">
261
+ <input type="submit" name="ps_disable_auto_formatting_submit" class="button-primary" value="<?php _e( 'Save Changes' ); ?>" />
262
+ </p>
263
+ <?php if ( current_user_can( 'edit_posts' ) && current_user_can( 'edit_pages' ) ) { ?>
264
+ <h3><?php _e( 'Batch formatting for past posts' ,'ps_disable_auto_formatting' ); ?></h3>
265
+ <?php _e( '<p>To make it display the same as the format before run this plug-in,
266
+ automatic operation process to the specified period of the posts.<br />
267
+ Even if some unexpected errors occur, the data is restorable because
268
+ rivision on the processed post is made.<br />
269
+ This process is safe even if you do two or more times, perhaps. We cannot assure though.<br />
270
+ * It is strongly recommended to take the <a href="http://codex.wordpress.org/Backing_Up_Your_Database" title="Backing Up Your Database">backup your database</a> before processing.</p>' ,'ps_disable_auto_formatting' ); ?>
271
+ <table class="form-table">
272
+ <tr>
273
+ <th><?php _e( 'Formatting before' ,'ps_disable_auto_formatting' ); ?></th>
274
+ <td>
275
+ <?php global $comment; $comment->comment_date = current_time( 'mysql' ); touch_time( 0, 0, 0, 1 ); ?><br />
276
+ <?php _e( '* Formatting posts and pages are modified before this time.' ,'ps_disable_auto_formatting' ); ?>
277
+ </td>
278
+ </tr>
279
+ </table>
280
+ <div>
281
+ <span class="submit"><input type="submit" name="batch_formatting" value="<?php _e( 'Batch formatting', 'ps_disable_auto_formatting' ); ?>" /></span>
282
+ &nbsp;&nbsp;&nbsp;<input type="checkbox" id="allow_batch_formatting" name="allow_batch_formatting" value="1" />
283
+ <label for="allow_batch_formatting"><?php _e( 'Allow batch formatting', 'ps_disable_auto_formatting' ); ?></label>
284
+ </div>
285
+ <?php } ?>
286
+ </form>
287
+ <p><?php _e( 'If you have any problems or find a bug in this plugin, please <a href="http://www.web-strategy.jp/wp_plugin/ps_disable_auto_formatting/#postcomment">report to us</a>.' , 'ps_disable_auto_formatting' ); ?></p>
288
+ </div>
289
+ <?php
290
+ }
291
+
292
+
293
+ function version_too_old() {
294
+ global $wp_version;
295
+ echo '<div class="updated fade"><p>' . sprintf( __( 'Sorry, Your WordPress (version %s) is old to use PS Disable Auto Formatting plugin. Please upgrade to version 2.5 or higher.', 'ps_disable_auto_formatting' ), $wp_version ) . '</p></div>';
296
+ $active_plugins = get_option('active_plugins');
297
+ $search_plugin = str_replace( str_replace( '\\', '/', ABSPATH . PLUGINDIR . '/' ), '', str_replace( '\\', '/', __file__ ) );
298
+ $key = array_search( $search_plugin, $active_plugins );
299
+ if ( $key !== false ) {
300
+ unset( $active_plugins[$key] );
301
+ }
302
+ update_option( 'active_plugins', $active_plugins );
303
+ }
304
+
305
+ } // class end
306
+
307
+ $ps_disable_auto_formatting =& new ps_disable_auto_formatting();
 
 
 
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: jim912
3
  Tags: auto formatting, formatting, format, paragraph, linebreak, wpautop
4
  Requires at least: 2.5
5
  Tested up to: 3.1
6
- Stable tag: 1.0.5
7
 
8
  Stops the automatic forming and the HTML tag removal in the html mode of WordPress, and generates a natural paragraph and changing line.
9
 
@@ -65,6 +65,8 @@ To prevent the operational error, the batch processing is not done if there is n
65
  Please check "Permit batch formatting" check box.
66
 
67
  == Changelog ==
 
 
68
  * **1.0.5**
69
  * fix : bug fix
70
  * **1.0.4**
3
  Tags: auto formatting, formatting, format, paragraph, linebreak, wpautop
4
  Requires at least: 2.5
5
  Tested up to: 3.1
6
+ Stable tag: 1.0.6
7
 
8
  Stops the automatic forming and the HTML tag removal in the html mode of WordPress, and generates a natural paragraph and changing line.
9
 
65
  Please check "Permit batch formatting" check box.
66
 
67
  == Changelog ==
68
+ * **1.0.6**
69
+ * fix : bug fix
70
  * **1.0.5**
71
  * fix : bug fix
72
  * **1.0.4**