Last active
November 8, 2019 19:40
-
-
Save kshaner/7fcbc7e3e967c5694fd38638bff1cc17 to your computer and use it in GitHub Desktop.
Patch popup builder's class path loading on multi head environments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) { | |
/** | |
* filter popup-builders path for multi head environments | |
* | |
* @param mixed $value | |
* @param string $option | |
* @param int $network_id | |
* @return mixed | |
* | |
* @filter option_SG_POPUP_BUILDER_REGISTERED_PLUGINS | |
* @filter site_option_SG_POPUP_BUILDER_REGISTERED_PLUGINS | |
*/ | |
function patch_popup_builder_paths( $value, $option, $network_id = 1 ) { | |
try { | |
$value = json_decode( $value ); | |
foreach( $value as &$plugin ) { | |
$plugin->classPath = preg_replace( '/^\/srv\/bindings\/[a-zA-Z0-9]+\/code\//', ABSPATH, $plugin->classPath ); | |
} | |
$value = json_encode( $value ); | |
} catch( \Exception $e ) {} | |
return $value; | |
} | |
add_filter( 'option_SG_POPUP_BUILDER_REGISTERED_PLUGINS', 'patch_popup_builder_paths', 10, 2 ); | |
add_filter( 'site_option_SG_POPUP_BUILDER_REGISTERED_PLUGINS', 'patch_popup_builder_paths', 10, 3 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment