Changeset 7607 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-loader.php
- Timestamp:
- 08/13/2018 11:52:14 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-loader.php
r6186 r7607 6 6 define( 'WCPT_DEFAULT_STATUS', 'wcpt-needs-vetting' ); 7 7 define( 'WCPT_FINAL_STATUS', 'wcpt-closed' ); 8 9 require_once WCPT_DIR . 'wcpt-event/class-event-loader.php'; 8 10 9 11 if ( ! class_exists( 'WordCamp_Loader' ) ) : … … 16 18 * 17 19 */ 18 class WordCamp_Loader {20 class WordCamp_Loader extends Event_Loader { 19 21 20 22 /** … … 22 24 */ 23 25 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_capabilities' ) ); 27 add_action( 'init', array( $this, 'register_post_statuses' ) ); 28 add_filter( 'pre_get_posts', array( $this, 'query_public_statuses_on_archives' ) ); 26 parent::__construct(); 29 27 add_action( 'wp_insert_post_data', array( $this, 'set_scheduled_date' ) ); 30 28 add_filter( 'wordcamp_rewrite_rules', array( $this, 'wordcamp_rewrite_rules' ) ); … … 132 130 } 133 131 134 public function register_post_statuses() { 135 foreach ( self::get_post_statuses() as $key => $label ) { 136 register_post_status( $key, array( 137 'label' => $label, 138 'public' => true, 139 'label_count' => _nx_noop( 140 sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 141 sprintf( '%s <span class="count">(%s)</span>', $label, '%s' ), 142 'wordcamporg' 143 ), 144 ) ); 145 } 146 } 147 148 /** 149 * Only query the public post statuses on WordCamp archives and feeds 150 * 151 * By default, any public post statuses are queried when the `post_status` parameter is not explicitly passed 152 * to WP_Query. This causes central.wordcamp.org/wordcamps/ and central.wordcamp.org/wordcamps/feed/ to display 153 * camps that are `needs-vetting`, etc, which is not desired. 154 * 155 * Another way to fix this would have been to register some of the posts statuses as `private`, but they're not 156 * consistently used in a public or private way, so that would have had more side effects. 157 * 158 * @param WP_Query $query 159 */ 160 public function query_public_statuses_on_archives( $query ) { 161 if ( ! $query->is_post_type_archive( WCPT_POST_TYPE_ID ) ) { 162 return; 163 } 164 165 if ( is_admin() ) { 166 return; 167 } 168 169 // Sort by the date it was added to the schedule. See WordCamp_Loader::set_scheduled_date() for details. 170 if ( '' === $query->get( 'orderby' ) ) { 171 $query->set( 'orderby', 'menu_order date' ); 172 } 173 174 if ( ! empty( $query->query_vars['post_status'] ) ) { 175 return; 176 } 177 178 $query->query_vars['post_status'] = self::get_public_post_statuses(); 179 } 132 180 133 181 134 /**
Note: See TracChangeset
for help on using the changeset viewer.