... | ... |
@@ -16,7 +16,7 @@ class Class_Rucy_Component { |
16 | 16 |
public function get_support_post_type() { |
17 | 17 |
$res = get_option( RC_SETTING_OPTION_KEY ); |
18 | 18 |
if( !$res ) { |
19 |
- $res = array( 'post', 'page' ); |
|
19 |
+ $res = array(); |
|
20 | 20 |
} else if ( !is_array( $res ) ) { |
21 | 21 |
$res = explode( ',' , $res ); |
22 | 22 |
} |
... | ... |
@@ -13,24 +13,22 @@ class Class_Rucy_Setting { |
13 | 13 |
add_options_page( 'Rucy', 'Rucy', 'manage_options', 'rucy', array( $this, 'add_setting_menu') ); |
14 | 14 |
} |
15 | 15 |
|
16 |
- public function setting_init() { |
|
17 |
- register_setting( 'rucy_setting', RC_SETTING_OPTION_KEY ); |
|
18 |
- add_settings_section( 'rucy_setting', '', '', 'rucy'); |
|
19 |
- add_settings_field("rc-post-types", __( 'post type', RC_TXT_DOMAIN ), array($this, 'get_rc_setting_fields'), 'rucy', 'rucy_setting'); |
|
20 |
- } |
|
21 |
- |
|
22 | 16 |
public function add_setting_menu() { |
23 | 17 |
$component = new Class_Rucy_Component(); |
24 |
- // update post |
|
25 |
- $post_support_posts = ( isset($_POST['rc_support_post_types']) ) ? $_POST['rc_support_post_types'] : array(); |
|
26 |
- $is_update = $component->update_support_post_type( $post_support_posts ); |
|
27 |
- if ( $is_update ) { |
|
28 |
- add_settings_error( 'rucy', 'update', __( 'Success to setting update.', RC_TXT_DOMAIN ), 'updated'); |
|
29 |
- } else { |
|
30 |
- // 更新失敗 |
|
18 |
+ $post_types = $component->get_post_types(); |
|
19 |
+ if( ( isset( $_POST['page_options'] ) && $_POST['page_options'] === RC_SETTING_OPTION_KEY ) |
|
20 |
+ && ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'update-options' ) ) |
|
21 |
+ ) { |
|
22 |
+ // update post |
|
23 |
+ $post_support_posts = ( isset($_POST['rc_support_post_types']) ) ? $_POST['rc_support_post_types'] : array(); |
|
24 |
+ $is_update = $component->update_support_post_type( $post_support_posts ); |
|
25 |
+ if ( $is_update ) { |
|
26 |
+ add_settings_error( 'rucy', 'update', __( 'Success to setting update.', RC_TXT_DOMAIN ), 'updated'); |
|
27 |
+ } |
|
28 |
+ $this->options = $component->get_support_post_type(); |
|
29 |
+ wp_safe_redirect( menu_page_url( 'rucy', false ) ); |
|
31 | 30 |
} |
32 |
- $this->options = $component->get_support_post_type(); |
|
33 |
- wp_safe_redirect( menu_page_url( 'rucy', false ) ); |
|
31 |
+ $support_post_type = $component->get_support_post_type(); |
|
34 | 32 |
?> |
35 | 33 |
<div class="wrap"> |
36 | 34 |
<h2><?php _e( 'Rucy Settings', RC_TXT_DOMAIN ); ?></h2> |
... | ... |
@@ -44,28 +42,27 @@ class Class_Rucy_Setting { |
44 | 44 |
<p><?php _e( 'Your contribution will continue to better this plugin.', RC_TXT_DOMAIN ); ?> <a href="http://www.amazon.co.jp/registry/wishlist/27FDI6LJU0X1O" class="button"><?php _e( 'Donate', RC_TXT_DOMAIN ); ?></a></p> |
45 | 45 |
</div> |
46 | 46 |
<form method="post" action="options-general.php?page=rucy"> |
47 |
- <?php |
|
48 |
- settings_fields('rucy'); |
|
49 |
- do_settings_sections('rucy'); |
|
50 |
- submit_button(); |
|
51 |
- ?> |
|
47 |
+ <?php wp_nonce_field('update-options'); ?> |
|
48 |
+ <table class="form-table"> |
|
49 |
+ <tr class=""> |
|
50 |
+ <th><?php _e( 'post type', RC_TXT_DOMAIN ); ?></th> |
|
51 |
+ <td> |
|
52 |
+ <ul> |
|
53 |
+ <?php |
|
54 |
+ foreach ( $post_types as $key => $post_type ) { |
|
55 |
+ $checked = ( in_array( $key, $support_post_type ) ) ? 'checked' : ''; |
|
56 |
+ ?> |
|
57 |
+ <li><label for="rc_<?php echo $key; ?>"><input type="checkbox" id="rc_<?php echo $key; ?>" name="rc_support_post_types[]" value="<?php echo $key; ?>" <?php echo $checked; ?> /><?php echo $post_type->labels->name; ?></label></li> |
|
58 |
+ <?php } ?> |
|
59 |
+ </ul> |
|
60 |
+ </td> |
|
61 |
+ </tr> |
|
62 |
+ </table> |
|
63 |
+ <input type="hidden" name="action" value="update" /> |
|
64 |
+ <input type="hidden" name="page_options" value="<?php echo RC_SETTING_OPTION_KEY ?>"/> |
|
65 |
+ <p class="submit"><input type="submit" class="button-primary" value="<?php _e( 'Save Changes' ) ?>" /></p> |
|
52 | 66 |
</form> |
53 | 67 |
</div> |
54 | 68 |
<?php |
55 | 69 |
} |
56 |
- |
|
57 |
- public function get_rc_setting_fields() { |
|
58 |
- $component = new Class_Rucy_Component(); |
|
59 |
- $post_types = $component->get_post_types(); |
|
60 |
- $support_post_type = $component->get_support_post_type(); |
|
61 |
-?> |
|
62 |
-<ul id="rc-post-types"> |
|
63 |
- <?php foreach ( $post_types as $key => $post_type ) { |
|
64 |
- $checked = ( in_array( $key, $support_post_type ) ) ? 'checked' : ''; |
|
65 |
- ?> |
|
66 |
- <li><label for="rc_<?php echo $key; ?>"><input type="checkbox" id="rc_<?php echo $key; ?>" name="rc_support_post_types[]" value="<?php echo $key; ?>" <?php echo $checked; ?> /><?php echo $post_type->labels->name; ?></label></li> |
|
67 |
- <?php } ?> |
|
68 |
-</ul> |
|
69 |
-<?php |
|
70 |
- } |
|
71 | 70 |
} |
... | ... |
@@ -3,7 +3,7 @@ Contributors: gips-nita |
3 | 3 |
Tags: post, update content, update post, update page, schedule update, reserve update, reservation update, rucy, Rucy |
4 | 4 |
Requires at least: 3.5 |
5 | 5 |
Tested up to: 4.3.1 |
6 |
-Stable tag: 0.4.2 |
|
6 |
+Stable tag: 0.4.3 |
|
7 | 7 |
License: GPLv2 or later |
8 | 8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html |
9 | 9 |
|
... | ... |
@@ -37,6 +37,12 @@ You can install this plugin directly from your WordPress dashboard: |
37 | 37 |
|
38 | 38 |
== Changelog == |
39 | 39 |
|
40 |
+= 0.4.3 = |
|
41 |
+ |
|
42 |
+2015-11-22 |
|
43 |
+ |
|
44 |
+* fixed Bugs in Setting Page. |
|
45 |
+ |
|
40 | 46 |
= 0.4.2 = |
41 | 47 |
|
42 | 48 |
2015-11-15 |
... | ... |
@@ -3,7 +3,7 @@ |
3 | 3 |
* Plugin Name: Rucy |
4 | 4 |
* Plugin URI: https://github.com/gips/rucy |
5 | 5 |
* Description: Reservation Update "Published" Content(Post & Page). |
6 |
- * Version: 0.4.2 |
|
6 |
+ * Version: 0.4.3 |
|
7 | 7 |
* Author: Nita |
8 | 8 |
* License: GPLv2 or later |
9 | 9 |
* Text Domain: rucy |
... | ... |
@@ -35,7 +35,6 @@ class Rucy_Class { |
35 | 35 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_setting_link' ) ); |
36 | 36 |
$setting = new Class_Rucy_Setting(); |
37 | 37 |
add_action( 'admin_menu', array( $setting, 'set_admin_menu' ) ); |
38 |
- add_action( 'admin_init', array( $setting, 'setting_init' ) ); |
|
39 | 38 |
$editor = new Class_Rucy_Editer(); |
40 | 39 |
add_action( 'admin_menu', array( $editor, 'add_rucy_metabox' ) ); |
41 | 40 |
add_action( 'save_post', array( $editor, 'save_rc_post_meta' ) ); |