is_active( 'stats' ) ) { return; } // Do not render in contexts outside the front-end (eg. emails, API). if ( ! Request::is_frontend() ) { return; } Jetpack_Gutenberg::load_assets_as_required( __DIR__ ); /* * We cannot rely on obtaining posts from the block because * top posts might have changed since then. As such, we must * check for updated stats. */ $period = $attributes['period']; $number = $attributes['postsToShow']; $types = implode( ',', array_keys( array_filter( $attributes['postTypes'] ) ) ); $data = Jetpack_Top_Posts_Helper::get_top_posts( $period, $number, $types ); if ( ! is_array( $data ) ) { return; } $wrapper_attributes = \WP_Block_Supports::get_instance()->apply_block_supports(); $output = sprintf( '