public function init_support_post_type() { $component = new Class_Rucy_Component(); $this->support_post_type = $component->get_support_post_type(); $component->update_support_post_type($this->support_post_type); }
public function add_setting_menu() { $component = new Class_Rucy_Component(); $post_types = $component->get_post_types(); if (isset($_POST['page_options']) && $_POST['page_options'] === RC_SETTING_OPTION_KEY && (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'update-options'))) { // update post $post_support_posts = isset($_POST['rc_support_post_types']) ? $_POST['rc_support_post_types'] : array(); $is_update = $component->update_support_post_type($post_support_posts); if ($is_update) { add_settings_error('rucy', 'update', __('Success to setting update.', RC_TXT_DOMAIN), 'updated'); } $this->options = $component->get_support_post_type(); wp_safe_redirect(menu_page_url('rucy', false)); } $support_post_type = $component->get_support_post_type(); ?> <div class="wrap"> <h2><?php _e('Rucy Settings', RC_TXT_DOMAIN); ?> </h2> <?php if (get_settings_errors('rucy')) { settings_errors('rucy'); } ?> <p><?php _e('Configure content types reservation update.', RC_TXT_DOMAIN); ?> </p> <div class="rc-donation"> <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> </div> <form method="post" action="options-general.php?page=rucy"> <?php wp_nonce_field('update-options'); ?> <table class="form-table"> <tr class=""> <th><?php _e('post type', RC_TXT_DOMAIN); ?> </th> <td> <ul> <?php foreach ($post_types as $key => $post_type) { $checked = in_array($key, $support_post_type) ? 'checked' : ''; ?> <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> <?php } ?> </ul> </td> </tr> </table> <input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="<?php echo RC_SETTING_OPTION_KEY; ?> "/> <p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes'); ?> " /></p> </form> </div> <?php }
public function add_reservation_message($messages) { global $post, $post_ID; $component = new Class_Rucy_Component(); $accept_post_types = $component->get_support_post_type(); $post_type = get_post_type($post); if (!in_array($post_type, $accept_post_types)) { return $messages; } $post_metas = $component->get_post_rc_meta($post_ID); if ($post_metas->accept != "1") { return $messages; } $add_message_date = date_i18n('Y/m/d @ H:i', strtotime($post_metas->date)); $base_str = __('registered reservation update content _RC_DATETIME_', RC_TXT_DOMAIN); $add_message = '<br>' . strtr($base_str, array('_RC_DATETIME_' => $add_message_date)); if ($post_metas->accept_rollback == "1") { $rollback_date = date_i18n('Y/m/d @ H:i', strtotime($post_metas->rollback_date)); $rollback_base_str = __('registered rollback content _RC_ROLLBACK_DATETIME_ ', RC_TXT_DOMAIN); $add_message .= '<br>' . strtr($rollback_base_str, array('_RC_ROLLBACK_DATETIME_' => $rollback_date)); } // published $messages[$post_type][1] .= $add_message; $messages[$post_type][4] .= $add_message; $messages[$post_type][6] .= $add_message; // saved $messages[$post_type][7] .= $add_message; // submited $messages[$post_type][8] .= $add_message; // scheduled $messages[$post_type][9] .= $add_message; return $messages; }