| @@ -11,10 +11,11 @@ | ||
| 11 | 11 | |
| 12 | 12 | use Automattic\Jetpack\Blocks; |
| 13 | 13 | use Jetpack_Gutenberg; |
| 14 | 14 | |
| 15 | -const FEATURE_NAME = 'rating-star'; | |
| 16 | -const BLOCK_NAME = 'jetpack/' . FEATURE_NAME; | |
| 15 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 16 | + exit( 0 ); | |
| 17 | +} | |
| 17 | 18 | |
| 18 | 19 | // Load generic function definitions. |
| 19 | 20 | require_once __DIR__ . '/rating-meta.php'; |
| 20 | 21 | |
| @@ -24,35 +25,11 @@ | ||
| 24 | 25 | * registration if we need to. |
| 25 | 26 | */ |
| 26 | 27 | function register_block() { |
| 27 | 28 | Blocks::jetpack_register_block( |
| 28 | - BLOCK_NAME, | |
| 29 | + __DIR__, | |
| 29 | 30 | array( |
| 30 | 31 | 'render_callback' => __NAMESPACE__ . '\render_block', |
| 31 | - 'attributes' => array( | |
| 32 | - 'rating' => array( | |
| 33 | - 'type' => 'number', | |
| 34 | - 'default' => 1, | |
| 35 | - ), | |
| 36 | - 'maxRating' => array( | |
| 37 | - 'type' => 'number', | |
| 38 | - 'default' => 5, | |
| 39 | - ), | |
| 40 | - 'color' => array( | |
| 41 | - 'type' => 'string', | |
| 42 | - ), | |
| 43 | - 'ratingStyle' => array( | |
| 44 | - 'type' => 'string', | |
| 45 | - 'default' => 'star', | |
| 46 | - ), | |
| 47 | - 'className' => array( | |
| 48 | - 'type' => 'string', | |
| 49 | - ), | |
| 50 | - 'align' => array( | |
| 51 | - 'type' => 'string', | |
| 52 | - 'default' => 'left', | |
| 53 | - ), | |
| 54 | - ), | |
| 55 | 32 | ) |
| 56 | 33 | ); |
| 57 | 34 | } |
| 58 | 35 | add_action( 'init', __NAMESPACE__ . '\register_block' ); |
| @@ -65,9 +42,9 @@ | ||
| 65 | 42 | * @return string |
| 66 | 43 | */ |
| 67 | 44 | function render_block( $attributes ) { |
| 68 | 45 | // Tell Jetpack to load the assets registered via jetpack_register_block. |
| 69 | - Jetpack_Gutenberg::load_assets_as_required( FEATURE_NAME ); | |
| 46 | + Jetpack_Gutenberg::load_assets_as_required( __DIR__ ); | |
| 70 | 47 | |
| 71 | 48 | return jetpack_rating_meta_render_block( $attributes ); |
| 72 | 49 | } |
| 73 | 50 | |
| @@ -76,9 +53,9 @@ | ||
| 76 | 53 | * Newer versions of AMP (1.4.1+) seem OK, but need the screen-reader text hidden |
| 77 | 54 | */ |
| 78 | 55 | function amp_add_inline_css() { |
| 79 | 56 | if ( defined( 'AMP__VERSION' ) && version_compare( AMP__VERSION, '1.4.1', '>=' ) ) { |
| 80 | - echo '.wp-block-jetpack-rating-star span.screen-reader-text { border: 0; clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; word-wrap: normal; }'; | |
| 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; }'; | |
| 81 | 58 | } else { |
| 82 | 59 | echo '.wp-block-jetpack-rating-star span:not([aria-hidden="true"]) { display: none; }'; |
| 83 | 60 | } |
| 84 | 61 | } |