| ... | ... |
@@ -3,7 +3,7 @@ |
| 3 | 3 |
* Plugin Name: Rucy |
| 4 | 4 |
* Plugin URI: https://github.com/gips/rucy |
| 5 | 5 |
* Description: update published content. |
| 6 |
- * Version: 0.0.1 |
|
| 6 |
+ * Version: 0.1.0 |
|
| 7 | 7 |
* Author: Nita |
| 8 | 8 |
* License: GPLv2 or later |
| 9 | 9 |
* Text Domain: rucy |
| ... | ... |
@@ -13,8 +13,8 @@ define('RC_PLUGIN_URL', plugin_dir_url(__FILE__));
|
| 13 | 13 |
define('RC_SETTING_OPTION_KEY', 'rucy_post_type');
|
| 14 | 14 |
define('RC_TXT_DOMAIN', 'rucy');
|
| 15 | 15 |
define('RC_POSTTYPE_DEFAULT','post,page');
|
| 16 |
+load_plugin_textdomain( RC_TXT_DOMAIN, false, 'rucy/lang'); |
|
| 16 | 17 |
|
| 17 |
-// load_plugin_textdomain( RP_TXT_DOMAIN, false, 'rucy/lang'); |
|
| 18 | 18 |
add_action('admin_enqueue_scripts','rc_load_jscss');
|
| 19 | 19 |
function rc_load_jscss() |
| 20 | 20 |
{
|
| ... | ... |
@@ -28,24 +28,28 @@ function rc_load_jscss() |
| 28 | 28 |
} |
| 29 | 29 |
} |
| 30 | 30 |
|
| 31 |
-// |
|
| 31 |
+/** |
|
| 32 |
+ * get rucy post_metas or post_meta keys. |
|
| 33 |
+ * @param int $post_id |
|
| 34 |
+ * @return array |
|
| 35 |
+ */ |
|
| 32 | 36 |
function getRcMetas($post_id = "") |
| 33 | 37 |
{
|
| 34 |
- $res = array(); |
|
| 35 |
- if($post_id) |
|
| 36 |
- {
|
|
| 37 |
- $res = array( |
|
| 38 |
- 'content' => get_post_meta($post_id,'rc_reserv_content',true), |
|
| 39 |
- 'accept' => get_post_meta($post_id,'rc_reserv_accept', true), |
|
| 40 |
- 'date' => get_post_meta($post_id, 'rc_reserv_accept', true), |
|
| 41 |
- ); |
|
| 42 |
- } else {
|
|
| 43 |
- $res = array( |
|
| 38 |
+ $base = array( |
|
| 44 | 39 |
'content' => 'rc_reserv_content', |
| 45 | 40 |
'accept' => 'rc_reserv_accept', |
| 46 | 41 |
'date' => 'rc_reserv_date' |
| 47 |
- ); |
|
| 42 |
+ ); |
|
| 43 |
+ if($post_id > 0) |
|
| 44 |
+ {
|
|
| 45 |
+ foreach ($base as $key => $value) |
|
| 46 |
+ {
|
|
| 47 |
+ $res[$key] = get_post_meta($post_id, $value, true); |
|
| 48 |
+ } |
|
| 49 |
+ } else {
|
|
| 50 |
+ $res = $base; |
|
| 48 | 51 |
} |
| 52 |
+ return $res; |
|
| 49 | 53 |
} |
| 50 | 54 |
|
| 51 | 55 |
// add reserv_metabox |
| ... | ... |
@@ -55,7 +59,7 @@ function add_rucy_metabox_out() |
| 55 | 55 |
$acceptPostType = getRcSetting(); |
| 56 | 56 |
foreach ($acceptPostType as $postType) |
| 57 | 57 |
{
|
| 58 |
- add_meta_box('rucy_metabox','Reserve Update Content Y.','add_rucy_metabox_inside',$postType,'normal','high');
|
|
| 58 |
+ add_meta_box('rucy_metabox','Rucy - Reservation Update Content -','add_rucy_metabox_inside',$postType,'normal','high');
|
|
| 59 | 59 |
} |
| 60 | 60 |
function add_rucy_metabox_inside() |
| 61 | 61 |
{
|
| ... | ... |
@@ -128,7 +132,7 @@ function savePostmeta($post_id) |
| 128 | 128 |
if(isset($_POST) && isset($_POST['post_type'])) |
| 129 | 129 |
{
|
| 130 | 130 |
$rcKeys = getRcMetas(); |
| 131 |
- $acceptPostType = getReservPostSetting(); |
|
| 131 |
+ $acceptPostType = getRcSetting(); |
|
| 132 | 132 |
foreach ($acceptPostType as $postType) |
| 133 | 133 |
{
|
| 134 | 134 |
if($_POST['post_type'] == $postType) |
| ... | ... |
@@ -158,6 +162,12 @@ function savePostmeta($post_id) |
| 158 | 158 |
} |
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 |
+/** |
|
| 162 |
+ * save, update, delete post_meta |
|
| 163 |
+ * |
|
| 164 |
+ * @param int $post_id |
|
| 165 |
+ * @param string $post_metakey |
|
| 166 |
+ */ |
|
| 161 | 167 |
function savePostMetaBase($post_id, $post_metakey) |
| 162 | 168 |
{
|
| 163 | 169 |
if(isset($_POST)) |
| ... | ... |
@@ -205,7 +215,7 @@ function updateReservedContent($post_id) |
| 205 | 205 |
|
| 206 | 206 |
// add reservation info at postlist |
| 207 | 207 |
function manageRucyCols($columns) {
|
| 208 |
- $columns['subtitle'] = "reservation update content"; |
|
| 208 |
+ $columns['subtitle'] = "Reservation Update Content"; |
|
| 209 | 209 |
return $columns; |
| 210 | 210 |
} |
| 211 | 211 |
function addRucyCol($column_name, $post_id) {
|
| ... | ... |
@@ -223,6 +233,8 @@ function addRucyCol($column_name, $post_id) {
|
| 223 | 223 |
} |
| 224 | 224 |
add_filter('manage_posts_columns', 'manageRucyCols');
|
| 225 | 225 |
add_action('manage_posts_custom_column', 'addRucyCol', 10, 2);
|
| 226 |
+add_filter('manage_pages_columns', 'manageRucyCols');
|
|
| 227 |
+add_action('manage_pages_custom_column', 'addRucyCol', 10, 2);
|
|
| 226 | 228 |
|
| 227 | 229 |
|
| 228 | 230 |
// setting page |
| ... | ... |
@@ -244,7 +256,6 @@ function addRcSetting() |
| 244 | 244 |
if(isset($post['page_options'])) |
| 245 | 245 |
{
|
| 246 | 246 |
$res = ""; |
| 247 |
- //TODO: validate |
|
| 248 | 247 |
if(isset($post['rc_post']) && $post['rc_post'] == 'post') |
| 249 | 248 |
{
|
| 250 | 249 |
$res .= $post['rc_post']; |
| ... | ... |
@@ -337,7 +348,12 @@ function addRcSetting() |
| 337 | 337 |
</div> |
| 338 | 338 |
<?php |
| 339 | 339 |
} |
| 340 |
- |
|
| 340 |
+/** |
|
| 341 |
+ * get post type allowed rucy |
|
| 342 |
+ * |
|
| 343 |
+ * @param boolean $isArray |
|
| 344 |
+ * @return string |
|
| 345 |
+ */ |
|
| 341 | 346 |
function getRcSetting($isArray = true) |
| 342 | 347 |
{
|
| 343 | 348 |
$rc_setting = get_option(RC_SETTING_OPTION_KEY); |
| ... | ... |
@@ -358,10 +374,10 @@ function getRcSetting($isArray = true) |
| 358 | 358 |
// uninstall |
| 359 | 359 |
if(function_exists('register_uninstall_hook'))
|
| 360 | 360 |
{
|
| 361 |
- register_uninstall_hook(__FILE__, 'seeyaRucy'); |
|
| 361 |
+ register_uninstall_hook(__FILE__, 'goodbyeRucy'); |
|
| 362 | 362 |
} |
| 363 | 363 |
|
| 364 |
-function seeyaRucy() |
|
| 364 |
+function goodbyeRucy() |
|
| 365 | 365 |
{
|
| 366 | 366 |
wp_clear_scheduled_hook('rucy_update_reserved_content');
|
| 367 | 367 |
delete_option(RC_SETTING_OPTION_KEY); |