Changeset 2401 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
- Timestamp:
- 01/28/2016 06:53:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
r2152 r2401 627 627 $min_site_id = apply_filters( 'wcpt_require_complete_meta_min_site_id', '2416297' ); 628 628 629 $required_pending_fields = array( 'E-mail Address' ); 630 631 $required_publish_fields = array( 629 $required_pending_fields = $this->get_required_fields( 'pending' ); 630 $required_publish_fields = $this->get_required_fields( 'publish' ); 631 632 // Check pending posts 633 if ( 'pending' == $post_data['post_status'] && absint( $_POST['post_ID'] ) > $min_site_id ) { 634 foreach( $required_pending_fields as $field ) { 635 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 636 637 if ( empty( $value ) || 'null' == $value ) { 638 $post_data['post_status'] = 'draft'; 639 $this->active_admin_notices[] = 3; 640 break; 641 } 642 } 643 } 644 645 // Check published posts 646 if ( 'publish' == $post_data['post_status'] && isset( $_POST['post_ID'] ) && absint( $_POST['post_ID'] ) > $min_site_id ) { 647 foreach( $required_publish_fields as $field ) { 648 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 649 650 if ( empty( $value ) || 'null' == $value ) { 651 $post_data['post_status'] = 'pending'; 652 $this->active_admin_notices[] = 1; 653 break; 654 } 655 } 656 } 657 658 return $post_data; 659 } 660 661 /** 662 * Get a list of fields required to move to a certain post status 663 * 664 * @param string $status 'pending' | 'publish' | 'any' 665 * 666 * @return array 667 */ 668 public static function get_required_fields( $status ) { 669 $pending = array( 'E-mail Address' ); 670 671 $publish = array( 632 672 // WordCamp 633 673 'Start Date (YYYY-mm-dd)', … … 650 690 ); 651 691 652 // Check pending posts 653 if ( 'pending' == $post_data['post_status'] && absint( $_POST['post_ID'] ) > $min_site_id ) { 654 foreach( $required_pending_fields as $field ) { 655 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 656 657 if ( empty( $value ) || 'null' == $value ) { 658 $post_data['post_status'] = 'draft'; 659 $this->active_admin_notices[] = 3; 660 break; 661 } 662 } 663 } 664 665 // Check published posts 666 if ( 'publish' == $post_data['post_status'] && isset( $_POST['post_ID'] ) && absint( $_POST['post_ID'] ) > $min_site_id ) { 667 foreach( $required_publish_fields as $field ) { 668 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 669 670 if ( empty( $value ) || 'null' == $value ) { 671 $post_data['post_status'] = 'pending'; 672 $this->active_admin_notices[] = 1; 673 break; 674 } 675 } 676 } 677 678 return $post_data; 692 switch ( $status ) { 693 case 'pending': 694 $required_fields = $pending; 695 break; 696 697 case 'publish': 698 $required_fields = $publish; 699 break; 700 701 case 'any': 702 default: 703 $required_fields = array_merge( $pending, $publish ); 704 break; 705 } 706 707 return $required_fields; 679 708 } 680 709 … … 791 820 global $post_id; 792 821 822 $required_fields = WordCamp_Admin::get_required_fields( 'any' ); 823 793 824 // @todo When you refactor meta_keys() to support changing labels -- see note in meta_keys() -- also make it support these notes 794 825 $messages = array( … … 799 830 foreach ( $meta_keys as $key => $value ) : 800 831 $object_name = wcpt_key_to_str( $key, 'wcpt_' ); 801 802 832 ?> 803 833 … … 814 844 <p> 815 845 <strong><?php echo $key; ?></strong> 846 <?php if ( in_array( $key, $required_fields, true ) ) : ?> 847 <span class="description"><?php _e( '(required)', 'wordcamporg' ); ?></span> 848 <?php endif; ?> 816 849 </p> 817 850
Note: See TracChangeset
for help on using the changeset viewer.