Skip to content

Instantly share code, notes, and snippets.

@jonschr
Last active April 14, 2021 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonschr/7c2eae0708eea6ed01fc0a7e65af459f to your computer and use it in GitHub Desktop.
Save jonschr/7c2eae0708eea6ed01fc0a7e65af459f to your computer and use it in GitHub Desktop.
// This constant should be defined in the main file for the plugin, even if the rest of this code is loaded elsewhere
define( 'ELODIN_STAFF_DIR', plugin_dir_path( __FILE__ ) );
use AC\ListScreenRepository\Storage\ListScreenRepositoryFactory;
use AC\ListScreenRepository\Rules;
use AC\ListScreenRepository\Rule;
add_filter( 'acp/storage/repositories', function( array $repositories, ListScreenRepositoryFactory $factory ) {
//! Change $writable to true to allow changes to columns for the content types below
$writable = false;
// Add rules to target individual list tables.
// Defaults to Rules::MATCH_ANY added here for clarity, other option is Rules::MATCH_ALL
$rules = new Rules( Rules::MATCH_ANY );
$rules->add_rule( new Rule\EqualType( 'staff' ) );
// Register your repository to the stack
$repositories['elodin-staff'] = $factory->create(
ELODIN_STAFF_DIR . '/acp-settings',
$writable,
$rules
);
return $repositories;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment