Making WordPress.org


Ignore:
Timestamp:
11/15/2018 01:35:20 AM (6 years ago)
Author:
iandunn
Message:

WordCamp Reports: Call WordCamp_Admin::meta_keys statically for front end use.

The $wordcamp_admin global is only available in wp-admin, but a future commit will introduce a public version of this report, so we need to be able to call meta_keys() on the front end as well. Initializing WordCamp_Admin on the front end would have undesirable side-effects, but meta_keys() is already static, so we can just switch to calling it that way.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-details.php

    r7734 r7851  
    163163     */
    164164    public static function get_field_order() {
    165         /* @var WordCamp_Admin $wordcamp_admin */
    166         global $wordcamp_admin;
     165        if ( ! is_callable( array( 'WordCamp_Admin', 'meta_keys' ) ) ) {
     166            require_once( WP_PLUGIN_DIR . '/wcpt/wcpt-wordcamp/wordcamp-admin.php' );
     167        }
    167168
    168169        return array_merge(
     
    171172                'Name',
    172173            ],
    173             array_keys( $wordcamp_admin->meta_keys( 'wordcamp' ) ),
     174            array_keys( WordCamp_Admin::meta_keys( 'wordcamp' ) ),
    174175            [
    175176                'Created',
     
    180181                'Organizers',
    181182            ],
    182             array_keys( $wordcamp_admin->meta_keys( 'contributor' ) ),
    183             array_keys( $wordcamp_admin->meta_keys( 'organizer' ) ),
    184             array_keys( $wordcamp_admin->meta_keys( 'venue' ) ),
     183            array_keys( WordCamp_Admin::meta_keys( 'contributor' ) ),
     184            array_keys( WordCamp_Admin::meta_keys( 'organizer' ) ),
     185            array_keys( WordCamp_Admin::meta_keys( 'venue' ) ),
    185186            [
    186187                '_venue_coordinates',
     
    289290     */
    290291    public function get_meta_keys() {
    291         /* @var WordCamp_Admin $wordcamp_admin */
    292         global $wordcamp_admin;
    293         $meta_keys = array_merge( array_keys( $wordcamp_admin->meta_keys( 'all' ) ), [
     292        if ( ! is_callable( array( 'WordCamp_Admin', 'meta_keys' ) ) ) {
     293            require_once( WP_PLUGIN_DIR . '/wcpt/wcpt-wordcamp/wordcamp-admin.php' );
     294        }
     295
     296        $meta_keys = array_merge( array_keys( WordCamp_Admin::meta_keys( 'all' ) ), [
    294297            '_venue_coordinates',
    295298            '_venue_city',
Note: See TracChangeset for help on using the changeset viewer.