PluginProbe
BeyondWords – AI audio for publishers / 6.0.3
BeyondWords – AI audio for publishers v6.0.3
7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.7.0 All 43 releases
speechkit / src / Component / Post / BlockAttributes / BlockAttributes.php

BlockAttributes.php in BeyondWords – AI audio for publishers 6.0.3, at src/Component/Post/BlockAttributes/BlockAttributes.php

83 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 /**
6 * BeyondWords support for Gutenberg blocks.
7 *
8 * @package Beyondwords\Wordpress
9 * @author Stuart McAlpine <stu@beyondwords.io>
10 * @since 3.7.0
11 * @since 4.0.0 Renamed from BlockAudioAttribute.php to BlockAttributes.php to support multiple attributes
12 */
13
14 namespace Beyondwords\Wordpress\Component\Post\BlockAttributes;
15
16 /**
17 * BlockAttributes
18 *
19 * @since 3.7.0
20 * @since 4.0.0 Renamed from BlockAudioAttribute to BlockAttributes to support multiple attributes.
21 * @since 6.0.0 Stop adding beyondwordsMarker attribute to blocks.
22 */
23 class BlockAttributes
24 {
25 /**
26 * Init.
27 *
28 * @since 4.0.0
29 * @since 6.0.0 Make static and remove renderBlock registration.
30 */
31 public static function init()
32 {
33 add_filter('register_block_type_args', [self::class, 'registerAudioAttribute']);
34 add_filter('register_block_type_args', [self::class, 'registerMarkerAttribute']);
35 }
36
37 /**
38 * Register "Audio" attribute for Gutenberg blocks.
39 *
40 * @since 6.0.0 Make static.
41 */
42 public static function registerAudioAttribute($args)
43 {
44 // Setup attributes if needed.
45 if (! isset($args['attributes'])) {
46 $args['attributes'] = [];
47 }
48
49 if (! array_key_exists('beyondwordsAudio', $args['attributes'])) {
50 $args['attributes']['beyondwordsAudio'] = [
51 'type' => 'boolean',
52 'default' => true,
53 ];
54 }
55
56 return $args;
57 }
58
59 /**
60 * Register "Segment marker" attribute for Gutenberg blocks.
61 *
62 * @deprecated This attribute is no longer used as of 6.0.0, but kept for backward compatibility.
63 *
64 * @since 6.0.0 Make static.
65 */
66 public static function registerMarkerAttribute($args)
67 {
68 // Setup attributes if needed.
69 if (! isset($args['attributes'])) {
70 $args['attributes'] = [];
71 }
72
73 if (! array_key_exists('beyondwordsMarker', $args['attributes'])) {
74 $args['attributes']['beyondwordsMarker'] = [
75 'type' => 'string',
76 'default' => '',
77 ];
78 }
79
80 return $args;
81 }
82 }
83