Making WordPress.org

Changeset 7727


Ignore:
Timestamp:
10/12/2018 02:49:02 PM (6 years ago)
Author:
vedjain
Message:

WordCamp: Enable server side key support.

This will allow to fetch dedicated server side google map api key. Default behavior for 'wordcamp_google_maps_api_key' is not changed to keep supporting all client renders of google maps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/wcorg-misc.php

    r7669 r7727  
    302302
    303303// Google Maps API
    304 add_filter( 'wordcamp_google_maps_api_key', function( $key ) {
     304add_filter( 'wordcamp_google_maps_api_key', function( $key, $scope = 'client' ) {
    305305    $environment = ( defined('WORDCAMP_ENVIRONMENT') ) ? WORDCAMP_ENVIRONMENT : 'development';
    306306
    307307    switch ( $environment ) {
    308308        case 'production' :
    309             if ( defined( 'WORDCAMP_PROD_GOOGLE_MAPS_API_KEY' ) ) {
     309            if ( $scope === 'client' && defined( 'WORDCAMP_PROD_GOOGLE_MAPS_API_KEY' ) ) {
    310310                $key = WORDCAMP_PROD_GOOGLE_MAPS_API_KEY;
     311            } elseif ( $scope === 'server' && defined( 'WORDCAMP_PROD_GOOGLE_MAPS_SERVER_API_KEY') ) {
     312                $key = WORDCAMP_PROD_GOOGLE_MAPS_SERVER_API_KEY;
    311313            }
    312314            break;
     
    321323
    322324    return $key;
    323 } );
     325}, 10, 2 );
    324326
    325327/*
Note: See TracChangeset for help on using the changeset viewer.