PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | extensions/blocks/rating-star/rating-star.php +62 -0 16.2-beta → 16.3 View file →
@@ -1,0 +1,62 @@
1 +<?php
2 +/**
3 + * Star Rating Block.
4 + *
5 + * @since 8.0.0
6 + *
7 + * @package automattic/jetpack
8 + */
9 +
10 +namespace Automattic\Jetpack\Extensions\Rating_Star;
11 +
12 +use Automattic\Jetpack\Blocks;
13 +use Jetpack_Gutenberg;
14 +
15 +if ( ! defined( 'ABSPATH' ) ) {
16 + exit( 0 );
17 +}
18 +
19 +// Load generic function definitions.
20 +require_once __DIR__ . '/rating-meta.php';
21 +
22 +/**
23 + * Registers the block for use in Gutenberg
24 + * This is done via an action so that we can disable
25 + * registration if we need to.
26 + */
27 +function register_block() {
28 + Blocks::jetpack_register_block(
29 + __DIR__,
30 + array(
31 + 'render_callback' => __NAMESPACE__ . '\render_block',
32 + )
33 + );
34 +}
35 +add_action( 'init', __NAMESPACE__ . '\register_block' );
36 +
37 +/**
38 + * Dynamic rendering of the block.
39 + *
40 + * @param array $attributes Array containing the block attributes.
41 + *
42 + * @return string
43 + */
44 +function render_block( $attributes ) {
45 + // Tell Jetpack to load the assets registered via jetpack_register_block.
46 + Jetpack_Gutenberg::load_assets_as_required( __DIR__ );
47 +
48 + return jetpack_rating_meta_render_block( $attributes );
49 +}
50 +
51 +/**
52 + * Older versions of AMP (0.6.2) are unable to render the markup, so we hide it
53 + * Newer versions of AMP (1.4.1+) seem OK, but need the screen-reader text hidden
54 + */
55 +function amp_add_inline_css() {
56 + if ( defined( 'AMP__VERSION' ) && version_compare( AMP__VERSION, '1.4.1', '>=' ) ) {
57 + echo '.wp-block-jetpack-rating-star span.screen-reader-text { border: 0; clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; word-wrap: normal; }';
58 + } else {
59 + echo '.wp-block-jetpack-rating-star span:not([aria-hidden="true"]) { display: none; }';
60 + }
61 +}
62 +add_action( 'amp_post_template_css', __NAMESPACE__ . '\amp_add_inline_css', 11 );