Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update class-boldgrid-connect.php #13

Open
wants to merge 1 commit into
base: feature/rest-api
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions includes/class-boldgrid-connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,19 @@ private function overrideConfigs() {
* @return false|mixed (Maybe) filtered option value.
*/
add_filter( 'option_bg_connect_configs', function( $value, $option ) {
/**
* The BoldGrid Library applies this filter before the
* 'configs' service gets registered above. In order for this
* value to not be 'null', we need to run setup_configs() here
* as well. Just checking for a null value doesn't work below,
* because the Boldgrid_Connect_Service::get() method throws an
* error if the requested service hasn't been registered
*/
$config = new Boldgrid_Connect_Config();
$config->setup_configs();

$value = is_array( $value ) ? $value : [];
$conf = \Boldgrid_Connect_Service::get( 'configs' );
$conf = \Boldgrid_Connect_Service::get( 'configs' );

$confs = ! empty( $conf ) ? array_merge( $conf, $value ) : $value;

Expand All @@ -214,8 +225,6 @@ private function overrideConfigs() {
foreach ( $confs['branding'] as $brand => $opts ) {
if ( strpos( strtolower( $brand ), $confs['brand'] ) !== false ) {
update_site_option( 'boldgrid_connect_provider', $brand );
// This option controls hiding various menu items from the plugins/library.
update_site_option( 'boldgrid_connect_hide_menu', $brand === 'InMotion Hosting' );
}
}
}
Expand Down