Making WordPress.org


Ignore:
Timestamp:
04/05/2016 04:05:02 PM (10 years ago)
Author:
kovshenin
Message:

WordCamp.org: Reintegrate application-tracking branch into trunk.

Location:
sites/trunk/wordcamp.org
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org

    • Property svn:mergeinfo set to
      /sites/branches/application-tracking/wordcamp.org2783-2897
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-loader.php

    r1230 r2898  
    11<?php
    22
    3 if ( !class_exists( 'WordCamp_Loader' ) ) :
     3define( 'WCPT_POST_TYPE_ID',   'wordcamp'           );
     4define( 'WCPT_YEAR_ID',        'wordcamp_year'      );
     5define( 'WCPT_SLUG',           'wordcamps'          );
     6define( 'WCPT_DEFAULT_STATUS', 'wcpt-needs-vetting' );
     7define( 'WCPT_FINAL_STATUS',   'wcpt-closed'        );
     8
     9if ( ! class_exists( 'WordCamp_Loader' ) ) :
    410/**
    511 * WordCamp_Loader
     
    1521         * The main WordCamp Post Type loader
    1622         */
    17         function wordcamp_loader () {
    18 
    19                 // Attach constants to wcpt_loaded.
    20                 add_action( 'wcpt_constants',           array ( $this, 'constants' ) );
    21 
    22                 // Attach includes to wcpt_includes.
    23                 add_action( 'wcpt_includes',            array ( $this, 'includes' ) );
    24 
    25                 // Attach post type registration to wcpt_register_post_types.
    26                 add_action( 'wcpt_register_post_types', array ( $this, 'register_post_types' ) );
    27 
    28                 // Attach tag registration wcpt_register_taxonomies.
    29                 //add_action( 'wcpt_register_taxonomies', array ( $this, 'register_taxonomies' ) );
    30         }
    31 
    32         /**
    33          * constants ()
    34          *
    35          * Default component constants that can be overridden or filtered
    36          */
    37         function constants () {
    38 
    39                 // The default post type ID
    40                 if ( !defined( 'WCPT_POST_TYPE_ID' ) )
    41                         define( 'WCPT_POST_TYPE_ID', apply_filters( 'wcpt_post_type_id', 'wordcamp' ) );
    42 
    43                 // The default year ID
    44                 if ( !defined( 'WCPT_YEAR_ID' ) )
    45                         define( 'WCPT_YEAR_ID', apply_filters( 'wcpt_tag_id', 'wordcamp_year' ) );
    46 
    47                 // Default slug for post type
    48                 if ( !defined( 'WCPT_SLUG' ) )
    49                         define( 'WCPT_SLUG', apply_filters( 'wcpt_slug', 'wordcamps' ) );
     23        function __construct() {
     24                add_action( 'plugins_loaded', array( $this, 'includes'               ) );
     25                add_action( 'init',           array( $this, 'register_post_types'    ) );
     26                add_action( 'init',           array( $this, 'register_post_statuses' ) );
    5027        }
    5128
     
    5835         */
    5936        function includes () {
    60 
    6137                // Load the files
    62                 require_once ( WCPT_DIR . '/wcpt-wordcamp/wordcamp-template.php' );
     38                require_once ( WCPT_DIR . 'wcpt-wordcamp/wordcamp-template.php' );
    6339
    6440                // Quick admin check and load if needed
    6541                if ( is_admin() )
    66                         require_once ( WCPT_DIR . '/wcpt-wordcamp/wordcamp-admin.php' );
    67 
    68                 require_once( WCPT_DIR . '/wcpt-wordcamp/wordcamp-new-site.php' );
    69                 $GLOBALS['wordcamp_new_site'] = new WordCamp_New_Site();
     42                        require_once ( WCPT_DIR . 'wcpt-wordcamp/wordcamp-admin.php' );
     43
     44                require_once( WCPT_DIR . 'wcpt-wordcamp/wordcamp-new-site.php' );
     45
     46                $GLOBALS['wordcamp_new_site'] = new WordCamp_New_Site;
    7047        }
    7148
     
    7754         * @todo Finish up the post type admin area with messages, columns, etc...*
    7855         */
    79         function register_post_types () {
    80 
     56        function register_post_types() {
    8157                // WordCamp post type labels
    8258                $wcpt_labels = array (
    83                         'name'                  => __( 'WordCamps', 'wcpt' ),
    84                         'singular_name'         => __( 'WordCamp', 'wcpt' ),
    85                         'add_new'               => __( 'Add New', 'wcpt' ),
    86                         'add_new_item'          => __( 'Create New WordCamp', 'wcpt' ),
    87                         'edit'                  => __( 'Edit', 'wcpt' ),
    88                         'edit_item'             => __( 'Edit WordCamp', 'wcpt' ),
    89                         'new_item'              => __( 'New WordCamp', 'wcpt' ),
    90                         'view'                  => __( 'View WordCamp', 'wcpt' ),
    91                         'view_item'             => __( 'View WordCamp', 'wcpt' ),
    92                         'search_items'          => __( 'Search WordCamps', 'wcpt' ),
    93                         'not_found'             => __( 'No WordCamps found', 'wcpt' ),
     59                        'name'                  => __( 'WordCamps',                   'wcpt' ),
     60                        'singular_name'         => __( 'WordCamp',                    'wcpt' ),
     61                        'add_new'               => __( 'Add New',                     'wcpt' ),
     62                        'add_new_item'          => __( 'Create New WordCamp',         'wcpt' ),
     63                        'edit'                  => __( 'Edit',                        'wcpt' ),
     64                        'edit_item'             => __( 'Edit WordCamp',               'wcpt' ),
     65                        'new_item'              => __( 'New WordCamp',                'wcpt' ),
     66                        'view'                  => __( 'View WordCamp',               'wcpt' ),
     67                        'view_item'             => __( 'View WordCamp',               'wcpt' ),
     68                        'search_items'          => __( 'Search WordCamps',            'wcpt' ),
     69                        'not_found'             => __( 'No WordCamps found',          'wcpt' ),
    9470                        'not_found_in_trash'    => __( 'No WordCamps found in Trash', 'wcpt' ),
    95                         'parent_item_colon'     => __( 'Parent WordCamp:', 'wcpt' )
     71                        'parent_item_colon'     => __( 'Parent WordCamp:',            'wcpt' )
    9672                );
    9773
     
    11288
    11389                // Register WordCamp post type
    114                 register_post_type (
    115                         WCPT_POST_TYPE_ID,
    116                         apply_filters( 'wcpt_register_post_type',
    117                                 array (
    118                                         'labels'            => $wcpt_labels,
    119                                         'rewrite'           => $wcpt_rewrite,
    120                                         'supports'          => $wcpt_supports,
    121                                         'menu_position'     => '100',
    122                                         'public'            => true,
    123                                         'show_ui'           => true,
    124                                         'can_export'        => true,
    125                                         'capability_type'   => 'post',
    126                                         'hierarchical'      => false,
    127                                         'has_archive'       => true,
    128                                         'query_var'         => true,
    129                                         'menu_icon'         => 'dashicons-wordpress',
    130                                 )
    131                         )
    132                 );
    133         }
    134 
    135         /**
    136          * register_taxonomies ()
    137          *
    138          * Register the built in WordCamp Post Type taxonomies
    139          *
    140          * @since WordCamp Post Type (0.1)
    141          *
    142          * @uses register_taxonomy()
    143          * @uses apply_filters()
    144          */
    145         function register_taxonomies () {
    146 
    147                 // Tag labels
    148                 $tag_labels = array (
    149                         'name'              => __( 'Years', 'wcpt' ),
    150                         'singular_name'     => __( 'Year', 'wcpt' ),
    151                         'search_items'      => __( 'Search Years', 'wcpt' ),
    152                         'popular_items'     => __( 'Popular Years', 'wcpt' ),
    153                         'all_items'         => __( 'All Years', 'wcpt' ),
    154                         'edit_item'         => __( 'Edit Year', 'wcpt' ),
    155                         'update_item'       => __( 'Update Year', 'wcpt' ),
    156                         'add_new_item'      => __( 'Add Year', 'wcpt' ),
    157                         'new_item_name'     => __( 'New Year', 'wcpt' ),
    158                 );
    159 
    160                 // Tag rewrite
    161                 $tag_rewrite = array (
    162                         'slug' => 'year'
    163                 );
    164 
    165                 // Register the  tag taxonomy
    166                 register_taxonomy (
    167                         WCPT_TAG_ID,               // The  tag ID
    168                         WCPT_POST_TYPE_ID,         // The  post type ID
    169                         apply_filters( 'wcpt_register_year',
    170                                 array (
    171                                         'labels'                => $tag_labels,
    172                                         'rewrite'               => $tag_rewrite,
    173                                         //'update_count_callback' => '_update_post_term_count',
    174                                         'query_var'             => 'wc-year',
    175                                         'hierarchical'          => false,
    176                                         'public'                => true,
    177                                         'show_ui'               => true,
    178                                 )
    179                         )
    180                 );
     90                register_post_type( WCPT_POST_TYPE_ID, array(
     91                        'labels'            => $wcpt_labels,
     92                        'rewrite'           => $wcpt_rewrite,
     93                        'supports'          => $wcpt_supports,
     94                        'menu_position'     => '100',
     95                        'public'            => true,
     96                        'show_ui'           => true,
     97                        'can_export'        => true,
     98                        'capability_type'   => 'post',
     99                        'hierarchical'      => false,
     100                        'has_archive'       => true,
     101                        'query_var'         => true,
     102                        'menu_icon'         => 'dashicons-wordpress',
     103                ) );
     104        }
     105
     106        public function register_post_statuses() {
     107                foreach ( self::get_post_statuses() as $key => $label ) {
     108                        register_post_status( $key, array(
     109                                'label' => $label,
     110                                'public' => true,
     111                                'label_count' => _nx_noop(
     112                                        sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     113                                        sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ),
     114                                        'wordcamporg'
     115                                ),
     116                        ) );
     117                }
     118        }
     119
     120        /**
     121         * Get WordCamp post statuses.
     122         *
     123         * @return array
     124         */
     125        public static function get_post_statuses() {
     126                return array(
     127                        'wcpt-needs-vetting'   => _x( 'Needs Vetting',                               'wordcamp status', 'wordcamporg' ),
     128                        'wcpt-needs-orientati' => _x( 'Needs Orientation/Interview',                 'wordcamp status', 'wordcamporg' ),
     129                        'wcpt-more-info-reque' => _x( 'More Info Requested',                         'wordcamp status', 'wordcamporg' ),
     130                        'wcpt-needs-rejection' => _x( 'Needs Rejection E-mail',                      'wordcamp status', 'wordcamporg' ),
     131                        'wcpt-interview-sched' => _x( 'Interview/Orientation Scheduled',             'wordcamp status', 'wordcamporg' ),
     132                        'wcpt-rejected'        => _x( 'Rejected',                                    'wordcamp status', 'wordcamporg' ),
     133                        'wcpt-cancelled'       => _x( 'Cancelled',                                   'wordcamp status', 'wordcamporg' ),
     134                        'wcpt-approved-pre-pl' => _x( 'Approved for Pre-Planning Pending Agreement', 'wordcamp status', 'wordcamporg' ),
     135                        'wcpt-needs-email'     => _x( 'Needs E-mail Address',                        'wordcamp status', 'wordcamporg' ),
     136                        'wcpt-needs-site'      => _x( 'Needs Site',                                  'wordcamp status', 'wordcamporg' ),
     137                        'wcpt-needs-polldaddy' => _x( 'Needs Polldaddy Account',                     'wordcamp status', 'wordcamporg' ),
     138                        'wcpt-needs-mentor'    => _x( 'Needs Mentor',                                'wordcamp status', 'wordcamporg' ),
     139                        'wcpt-needs-pre-plann' => _x( 'Needs to be Added to Pre-Planning Schedule',  'wordcamp status', 'wordcamporg' ),
     140                        'wcpt-pre-planning'    => _x( 'In Pre-Planning',                             'wordcamp status', 'wordcamporg' ),
     141                        'wcpt-needs-budget-re' => _x( 'Needs Budget Review',                         'wordcamp status', 'wordcamporg' ),
     142                        'wcpt-budget-rev-sche' => _x( 'Budget Review Scheduled',                     'wordcamp status', 'wordcamporg' ),
     143                        'wcpt-needs-contract'  => _x( 'Needs Contract to be Signed',                 'wordcamp status', 'wordcamporg' ),
     144                        'wcpt-needs-fill-list' => _x( 'Needs to Fill Out WordCamp Listing',          'wordcamp status', 'wordcamporg' ),
     145                        'wcpt-needs-schedule'  => _x( 'Needs to be Added to Official Schedule',      'wordcamp status', 'wordcamporg' ),
     146                        'wcpt-scheduled'       => _x( 'WordCamp Scheduled',                          'wordcamp status', 'wordcamporg' ),
     147                        'wcpt-needs-debrief'   => _x( 'Needs Debrief',                               'wordcamp status', 'wordcamporg' ),
     148                        'wcpt-debrief-schedul' => _x( 'Debrief Scheduled',                           'wordcamp status', 'wordcamporg' ),
     149                        'wcpt-closed'          => _x( 'WordCamp Closed',                             'wordcamp status', 'wordcamporg' ),
     150                );
     151        }
     152
     153        /**
     154         * Get post statuses for WordCamps on schedule.
     155         *
     156         * @return array Post status names.
     157         */
     158        public static function get_public_post_statuses() {
     159                return array(
     160                        'wcpt-scheduled',
     161                        'wcpt-needs-debrief',
     162                        'wcpt-debrief-schedul',
     163                        'wcpt-closed',
     164
     165                        // back-compat
     166                        'public',
     167                );
     168        }
     169
     170        /**
     171         * Get post statuses for WordCamps on pre-planning schedule.
     172         *
     173         * @return array Post status names.
     174         */
     175        public static function get_pre_planning_post_statuses() {
     176                return array(
     177                        'wcpt-pre-planning',
     178                        'wcpt-needs-budget-re',
     179                        'wcpt-budget-rev-sche',
     180                        'wcpt-needs-contract',
     181                        'wcpt-needs-fill-list',
     182                        'wcpt-needs-schedule',
     183
     184                        // back-compat
     185                        'pending',
     186                );
     187        }
     188
     189        /**
     190         * Get the milestones that correspond to each status
     191         *
     192         * @return array
     193         */
     194        public static function map_statuses_to_milestones() {
     195                $milestones = array(
     196                        'wcpt-needs-vetting'   => 'Application received',
     197                        'wcpt-needs-orientati' => 'Application vetted',
     198                        'wcpt-more-info-reque' => 'Application vetted',
     199                        'wcpt-needs-rejection' => 'Application vetted',
     200                        'wcpt-interview-sched' => 'Interview scheduled',
     201                        'wcpt-rejected'        => 'Sent rejection email',
     202                        'wcpt-cancelled'       => 'WordCamp cancelled',
     203                        'wcpt-approved-pre-pl' => 'Orientation/interview held',
     204                        'wcpt-needs-email'     => 'Organizer agreement signed',
     205                        'wcpt-needs-site'      => 'Email address/fwd set up',
     206                        'wcpt-needs-polldaddy' => 'Site created',
     207                        'wcpt-needs-mentor'    => 'Polldaddy account created',
     208                        'wcpt-needs-pre-plann' => 'Mentor assigned',
     209                        'wcpt-pre-planning'    => 'Added to pre-planning schedule',
     210                        'wcpt-needs-budget-re' => 'Budget review requested',
     211                        'wcpt-budget-rev-sche' => 'Budget review scheduled',
     212                        'wcpt-needs-contract'  => 'Budget approved',
     213                        'wcpt-needs-fill-list' => 'Contract signed',
     214                        'wcpt-needs-schedule'  => 'WordCamp listing filled out',
     215                        'wcpt-scheduled'       => 'WordCamp added to official schedule',
     216                        'wcpt-needs-debrief'   => 'WordCamp held',
     217                        'wcpt-debrief-schedul' => 'Debrief scheduled',
     218                        'wcpt-closed'          => 'Debrief held',
     219                );
     220
     221                return $milestones;
     222        }
     223
     224        /**
     225         * Return valid transitions given a post status.
     226         *
     227         * @param string $status Current status.
     228         *
     229         * @return array Valid transitions.
     230         */
     231        public static function get_valid_status_transitions( $status ) {
     232                $transitions = array(
     233                        'wcpt-needs-vetting'   => array( 'wcpt-needs-orientati', 'wcpt-more-info-reque', 'wcpt-needs-rejection' ),
     234                        'wcpt-needs-orientati' => array( 'wcpt-needs-vetting', 'wcpt-interview-sched' ),
     235                        'wcpt-more-info-reque' => array(),  // Allowed from any status, see below
     236                        'wcpt-needs-rejection' => array( 'wcpt-needs-vetting', 'wcpt-rejected' ),
     237                        'wcpt-interview-sched' => array( 'wcpt-needs-orientati', 'wcpt-approved-pre-pl' ),
     238                        'wcpt-rejected'        => array( 'wcpt-needs-rejection' ),
     239                        'wcpt-cancelled'       => array(),  // Allowed from any status, see below
     240                        'wcpt-approved-pre-pl' => array( 'wcpt-interview-sched', 'wcpt-needs-email' ),
     241                        'wcpt-needs-email'     => array( 'wcpt-approved-pre-pl', 'wcpt-needs-site' ),
     242                        'wcpt-needs-site'      => array( 'wcpt-needs-email', 'wcpt-needs-polldaddy' ),
     243                        'wcpt-needs-polldaddy' => array( 'wcpt-needs-site', 'wcpt-needs-mentor' ),
     244                        'wcpt-needs-mentor'    => array( 'wcpt-needs-polldaddy', 'wcpt-needs-pre-plann' ),
     245                        'wcpt-needs-pre-plann' => array( 'wcpt-needs-mentor', 'wcpt-pre-planning' ),
     246                        'wcpt-pre-planning'    => array( 'wcpt-needs-pre-plann', 'wcpt-needs-budget-re' ),
     247                        'wcpt-needs-budget-re' => array( 'wcpt-pre-planning', 'wcpt-budget-rev-sche' ),
     248                        'wcpt-budget-rev-sche' => array( 'wcpt-needs-budget-re', 'wcpt-needs-contract' ),
     249                        'wcpt-needs-contract'  => array( 'wcpt-budget-rev-sche', 'wcpt-needs-fill-list' ),
     250                        'wcpt-needs-fill-list' => array( 'wcpt-needs-contract', 'wcpt-needs-schedule' ),
     251                        'wcpt-needs-schedule'  => array( 'wcpt-needs-fill-list', 'wcpt-scheduled' ),
     252                        'wcpt-scheduled'       => array( 'wcpt-needs-schedule', 'wcpt-needs-debrief' ),
     253                        'wcpt-needs-debrief'   => array( 'wcpt-scheduled', 'wcpt-debrief-schedul' ),
     254                        'wcpt-debrief-schedul' => array( 'wcpt-needs-debrief', 'wcpt-closed' ),
     255                        'wcpt-closed'          => array( 'wcpt-debrief-schedul' ),
     256                );
     257
     258                // Cancelled and More Info Requested can be switched to from any status.
     259                foreach ( array_keys( $transitions ) as $key ) {
     260                        $transitions[ $key ][] = 'wcpt-more-info-reque';
     261                        $transitions[ $key ][] = 'wcpt-cancelled';
     262                }
     263
     264                // Any status can be switched to from More Info Requested and Cancelled.
     265                foreach ( array( 'wcpt-more-info-reque', 'wcpt-cancelled' ) as $key ) {
     266                        $transitions[ $key ] = array_keys( $transitions );
     267                }
     268
     269                if ( empty( $transitions[ $status ] ) )
     270                        return array( 'wcpt-needs-vetting' );
     271
     272                return $transitions[ $status ];
    181273        }
    182274}
Note: See TracChangeset for help on using the changeset viewer.