Skip to content

Commit

Permalink
Update wp_rand() usage to a more unique index approach
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Aug 3, 2017
1 parent f23a5da commit c501a4b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion blocks/library/categories/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* @return string Returns the categories list/dropdown markup.
*/
function gutenberg_render_block_core_categories( $attributes ) {
static $block_id = 0;
$block_id++;

$align = 'center';
if ( isset( $attributes['align'] ) && in_array( $attributes['align'], array( 'left', 'right', 'full' ), true ) ) {
$align = $attributes['align'];
Expand All @@ -27,7 +30,7 @@ function gutenberg_render_block_core_categories( $attributes ) {
);

if ( ! empty( $attributes['displayAsDropdown'] ) ) {
$id = 'wp-block-categories-' . wp_rand();
$id = 'wp-block-categories-' . $block_id;
$args['id'] = $id;
$args['show_option_none'] = __( 'Select Category', 'gutenberg' );
$wrapper_markup = '<div class="%1$s">%2$s</div>';
Expand Down

0 comments on commit c501a4b

Please sign in to comment.