示例#1
0
 /**
  * Save Rank Details
  * @since 1.1
  * @version 1.3
  */
 public function save_rank_settings($post_id)
 {
     // Make sure fields exists
     if (!isset($_POST['mycred_rank']) || !is_array($_POST['mycred_rank']) || !wp_verify_nonce($_POST['mycred_rank']['token'], 'mycred-edit-rank' . $post_id)) {
         return;
     }
     // Minimum can not be empty
     if (empty($_POST['mycred_rank']['min'])) {
         $min = 0;
     } else {
         $min = sanitize_key($_POST['mycred_rank']['min']);
     }
     update_post_meta($post_id, 'mycred_rank_min', $min);
     // Maximum can not be empty
     if (empty($_POST['mycred_rank']['max'])) {
         $max = 999;
     } else {
         $max = sanitize_key($_POST['mycred_rank']['max']);
     }
     update_post_meta($post_id, 'mycred_rank_max', $max);
     // Save type
     if (empty($_POST['mycred_rank']['ctype'])) {
         $type = 'mycred_default';
     } else {
         $type = sanitize_text_field($_POST['mycred_rank']['ctype']);
     }
     update_post_meta($post_id, 'ctype', $type);
     if (get_post_status($post_id) == 'publish') {
         mycred_assign_ranks($type);
     }
 }
示例#2
0
 /**
  * Save Rank Details
  * @since 1.1
  * @version 1.1
  */
 public function save_rank_settings($post_id)
 {
     // Make sure this is the correct post type
     if (get_post_type($post_id) != 'mycred_rank') {
         return;
     } elseif (!mycred_is_admin(get_current_user_id())) {
         return;
     } elseif (!isset($_POST['mycred_rank']) || !is_array($_POST['mycred_rank'])) {
         return;
     } elseif (!wp_verify_nonce($_POST['mycred_rank']['token'], 'mycred-edit-rank')) {
         return;
     }
     // Minimum can not be empty
     if (empty($_POST['mycred_rank']['min'])) {
         $min = 0;
     } else {
         $min = trim($_POST['mycred_rank']['min']);
     }
     // Maximum can not be empty
     if (empty($_POST['mycred_rank']['max'])) {
         $max = 999;
     } else {
         $max = trim($_POST['mycred_rank']['max']);
     }
     update_post_meta($post_id, 'mycred_rank_min', $min);
     update_post_meta($post_id, 'mycred_rank_max', $max);
     if (get_post_status($post_id) == 'publish') {
         mycred_assign_ranks();
     }
 }