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

Filters not working, unable to change site ID #76

Open
matt-oakley-99 opened this issue Jun 17, 2020 · 1 comment
Open

Filters not working, unable to change site ID #76

matt-oakley-99 opened this issue Jun 17, 2020 · 1 comment

Comments

@matt-oakley-99
Copy link

Hi

I have been experimenting with the plugin but only been able to get it to work if hard code the site ID constant.

Could you maybe provide some support / direction on where i may be going wrong.

I have tried both the following:

add_filter( 'network-media-library/site_id', function( $site_id ) {
    return 18;
} );
add_filter( 'network-media-library/site_id', array( $this, 'multi_media_network_side_id' ), 999, 1 );

public function multi_media_network_side_id( $site_id ) {
	$site_id = (int) get_theme_mod( 'network_media_id' );

	if ( false !== $site_id ) {
		return $site_id;
	}

	return 0;
}

After some debugging the site id filter is being run but does not seem to be applying it the variable.

@artifex404
Copy link

artifex404 commented Sep 11, 2020

Do you have the Class setup properly? Maybe you should try a plain function:

add_filter( 'network-media-library/site_id', function( $site_id ) {
	$site_id = (int) get_theme_mod( 'network_media_id' );

	if ( false !== $site_id ) {
		return $site_id;
	}

	return 0;
} );

Make sure the function get_theme_mod() actually returns the correct int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants