Last active
August 4, 2019 09:33
-
-
Save goiblas/78d8272e2cb93dc2d9d843a2f4007731 to your computer and use it in GitHub Desktop.
Add Attributes to block (WordPress)
This file contains 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 | |
global $wp_roles; | |
$all_roles = array_values($wp_roles->get_names()); | |
register_block_type( 'block-restrict-content/block-restrict-content', array( | |
'editor_script' => 'block_restrict_content', | |
'attributes' => [ | |
'rolesSelected' => [ | |
'type' => 'array', | |
'default' => [ $all_roles[0] ] | |
], | |
'roles' => [ | |
'type' => 'array', | |
'default' => $all_roles | |
] | |
] | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment