Making WordPress.org

Changeset 7853


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

WordCamp Post Type: Create DRY list of venue address post meta fields.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php

    r7728 r7853  
    263263
    264264        /**
    265          * meta_keys ()
    266          *
    267          * Returns post meta key
     265         * Returns the names and types of post meta fields that have corresponding UI fields.
     266         *
     267         * For keys that don't have UI, see `get_venue_address_meta_keys()` and any similar functions.
    268268         *
    269269         * @param string $meta_group
     
    450450
    451451        /**
     452         * Returns the slugs of the post meta fields for the venue's address.
     453         *
     454         * These aren't included in `meta_keys()` because they have no corresponding UI.
     455         *
     456         * @return array
     457         */
     458        static function get_venue_address_meta_keys() {
     459            return array(
     460                '_venue_coordinates',
     461                '_venue_city',
     462                '_venue_state',
     463                '_venue_country_code',
     464                '_venue_country_name',
     465                '_venue_zip',
     466            );
     467        }
     468
     469        /**
    452470         * Fired during admin_print_styles
    453471         * Adds jQuery UI
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-loader.php

    r7693 r7853  
    333333
    334334    /**
    335      * Meta field keys to publicly expose in the v2 REST API
    336      *
    337      * @see wcorg_json_expose_whitelisted_meta_data() in mu-plugins/wcorg-json-api.php
     335     * Meta field keys that are safe to publicly expose in the v2 REST API.
     336     *
     337     * @see wcorg_json_expose_whitelisted_meta_data() in mu-plugins/wcorg-json-api.php.
    338338     *
    339339     * @return array
    340340     */
    341341    public static function get_public_meta_keys() {
    342         return array(
     342        require_once( __DIR__ . '/wordcamp-admin.php' );
     343
     344        $safe_fields = array(
    343345            // Sourced from wcorg_json_expose_whitelisted_meta_data()
    344346            'Start Date (YYYY-mm-dd)',
     
    357359            'Website URL',
    358360            'Exhibition Space Available',
    359             // Additional venue data
    360             '_venue_coordinates',
    361             '_venue_city',
    362             '_venue_state',
    363             '_venue_country_code',
    364             '_venue_country_name',
    365             '_venue_zip',
     361        );
     362
     363        return array_merge(
     364            $safe_fields,
     365            WordCamp_Admin::get_venue_address_meta_keys()
    366366        );
    367367    }
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-details.php

    r7851 r7853  
    184184            array_keys( WordCamp_Admin::meta_keys( 'organizer' ) ),
    185185            array_keys( WordCamp_Admin::meta_keys( 'venue' ) ),
    186             [
    187                 '_venue_coordinates',
    188                 '_venue_city',
    189                 '_venue_state',
    190                 '_venue_country_code',
    191                 '_venue_country_name',
    192                 '_venue_zip',
    193             ]
     186            WordCamp_Admin::get_venue_address_meta_keys()
    194187        );
    195188    }
     
    294287        }
    295288
    296         $meta_keys = array_merge( array_keys( WordCamp_Admin::meta_keys( 'all' ) ), [
    297             '_venue_coordinates',
    298             '_venue_city',
    299             '_venue_state',
    300             '_venue_country_code',
    301             '_venue_country_name',
    302             '_venue_zip',
    303         ] );
     289        $meta_keys = array_merge(
     290            array_keys( WordCamp_Admin::meta_keys( 'all' ) ),
     291            WordCamp_Admin::get_venue_address_meta_keys()
     292        );
    304293
    305294        return $meta_keys;
Note: See TracChangeset for help on using the changeset viewer.