Changeset 2893
- Timestamp:
- 04/04/2016 08:50:21 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/branches/application-tracking/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
r2892 r2893 46 46 add_action( 'wcpt_added_to_planning_schedule', array( $this, 'mark_date_added_to_planning_schedule' ), 10 ); 47 47 add_filter( 'wp_insert_post_data', array( $this, 'enforce_post_status' ), 10, 2 ); 48 add_filter( 'wp_insert_post_data', array( $this, 'require_complete_meta_to_publish_wordcamp' ), 1 0, 2 );48 add_filter( 'wp_insert_post_data', array( $this, 'require_complete_meta_to_publish_wordcamp' ), 11, 2 ); // after enforce_post_status 49 49 50 50 // Admin notices … … 617 617 * Trigger actions related to WordCamps being scheduled. 618 618 * 619 * When an application is submitted, a `wordcamp` post is created with a `draft` status. When it's accepted620 * to the planning schedule the status changes to `pending`, and when it's accepted for the final schedule621 * the status changes to 'publish'.622 *623 619 * @param string $new_status 624 620 * @param string $old_status … … 751 747 } 752 748 753 // todo update for new statuses754 755 749 // The ID of the last site that was created before this rule went into effect, so that we don't apply the rule retroactively. 756 750 $min_site_id = apply_filters( 'wcpt_require_complete_meta_min_site_id', '2416297' ); 757 751 758 $required_p ending_fields = $this->get_required_fields( 'pending' );759 $required_ publish_fields = $this->get_required_fields( 'publish' );752 $required_pre_planning_fields = $this->get_required_fields( 'pre-planning' ); 753 $required_scheduled_fields = $this->get_required_fields( 'scheduled' ); 760 754 761 755 // Check pending posts 762 if ( ' pending' == $post_data['post_status'] && absint( $_POST['post_ID'] ) > $min_site_id ) {763 foreach( $required_p ending_fields as $field ) {756 if ( 'wcpt-approved-pre-pl' == $post_data['post_status'] && absint( $_POST['post_ID'] ) > $min_site_id ) { 757 foreach( $required_pre_planning_fields as $field ) { 764 758 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 765 759 766 760 if ( empty( $value ) || 'null' == $value ) { 767 $post_data['post_status'] = 'draft'; 761 $post_data['post_status'] = 'wcpt-interview-sched'; 762 $this->active_admin_notices[] = 1; 763 break; 764 } 765 } 766 } 767 768 // Check published posts 769 if ( 'wcpt-scheduled' == $post_data['post_status'] && isset( $_POST['post_ID'] ) && absint( $_POST['post_ID'] ) > $min_site_id ) { 770 foreach( $required_scheduled_fields as $field ) { 771 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ]; 772 773 if ( empty( $value ) || 'null' == $value ) { 774 $post_data['post_status'] = 'wcpt-needs-schedule'; 768 775 $this->active_admin_notices[] = 3; 769 776 break; … … 772 779 } 773 780 774 // Check published posts775 if ( 'publish' == $post_data['post_status'] && isset( $_POST['post_ID'] ) && absint( $_POST['post_ID'] ) > $min_site_id ) {776 foreach( $required_publish_fields as $field ) {777 $value = $_POST[ wcpt_key_to_str( $field, 'wcpt_' ) ];778 779 if ( empty( $value ) || 'null' == $value ) {780 $post_data['post_status'] = 'pending';781 $this->active_admin_notices[] = 1;782 break;783 }784 }785 }786 787 781 return $post_data; 788 782 } … … 791 785 * Get a list of fields required to move to a certain post status 792 786 * 793 * @param string $status 'p ending' | 'publish' | 'any'787 * @param string $status 'pre-planning' | 'scheduled' | 'any' 794 788 * 795 789 * @return array 796 790 */ 797 791 public static function get_required_fields( $status ) { 798 $p ending = array( 'E-mail Address' );799 800 $ publish= array(792 $pre_planning = array( 'E-mail Address' ); 793 794 $scheduled = array( 801 795 // WordCamp 802 796 'Start Date (YYYY-mm-dd)', … … 820 814 821 815 switch ( $status ) { 822 case 'p ending':823 $required_fields = $p ending;816 case 'pre-planning': 817 $required_fields = $pre_planning; 824 818 break; 825 819 826 case ' publish':827 $required_fields = $ publish;820 case 'scheduled': 821 $required_fields = $scheduled; 828 822 break; 829 823 830 824 case 'any': 831 825 default: 832 $required_fields = array_merge( $p ending, $publish);826 $required_fields = array_merge( $pre_planning, $scheduled ); 833 827 break; 834 828 } … … 877 871 } 878 872 879 // todo update for new statuses880 881 873 $notices = array( 882 874 1 => array( 883 875 'type' => 'error', 884 'notice' => __( 'This WordCamp cannot be publisheduntil all of its required metadata is filled in.', 'wordcamporg' ),876 'notice' => __( 'This WordCamp cannot be approved for pre-planning until all of its required metadata is filled in.', 'wordcamporg' ), 885 877 ), 886 878 887 879 3 => array( 888 880 'type' => 'error', 889 'notice' => __( 'This WordCamp cannot be set to pendinguntil all of its required metadata is filled in.', 'wordcamporg' ),881 'notice' => __( 'This WordCamp cannot be added to the schedule until all of its required metadata is filled in.', 'wordcamporg' ), 890 882 ), 891 883 );
Note: See TracChangeset
for help on using the changeset viewer.