PluginProbe
Gutenberg / 7.7.2
Gutenberg v7.7.2
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | lib/blocks.php +105 -42 7.4.0 → 7.7.2 View file →
@@ -5,30 +5,8 @@
5 5 * @package gutenberg
6 6 */
7 7
8 8 /**
9 - * Retrieves registered social link blocks
10 - *
11 - * @return array Array of strings containing the registered social link block names.
12 - */
13 -function gutenberg_get_registered_social_link_blocks() {
14 - $social_link_prefix = 'core/social-link';
15 - $social_link_prefix_length = strlen( $social_link_prefix );
16 -
17 - $registry = WP_Block_Type_Registry::get_instance();
18 - $block_types = $registry->get_all_registered();
19 -
20 - $registered_social_link_blocks = array();
21 - foreach ( $block_types as $block_type ) {
22 - // Block type name starts with $social_link_prefix.
23 - if ( strncmp( $block_type->name, $social_link_prefix, $social_link_prefix_length ) === 0 ) {
24 - $registered_social_link_blocks[] = $block_type->name;
25 - }
26 - }
27 - return $registered_social_link_blocks;
28 -}
29 -
30 -/**
31 9 * Substitutes the implementation of a core-registered block type, if exists,
32 10 * with the built result from the plugin.
33 11 */
34 12 function gutenberg_reregister_core_block_types() {
@@ -38,28 +16,32 @@
38 16 return;
39 17 }
40 18
41 19 $block_names = array(
42 - 'archives.php' => 'core/archives',
43 - 'block.php' => 'core/block',
44 - 'calendar.php' => 'core/calendar',
45 - 'categories.php' => 'core/categories',
46 - 'latest-comments.php' => 'core/latest-comments',
47 - 'latest-posts.php' => 'core/latest-posts',
48 - 'legacy-widget.php' => 'core/legacy-widget',
49 - 'navigation.php' => 'core/navigation',
50 - 'rss.php' => 'core/rss',
51 - 'shortcode.php' => 'core/shortcode',
52 - 'search.php' => 'core/search',
53 - 'social-link.php' => gutenberg_get_registered_social_link_blocks(),
54 - 'tag-cloud.php' => 'core/tag-cloud',
55 - 'site-title.php' => 'core/site-title',
56 - 'template-part.php' => 'core/template-part',
57 - 'post-title.php' => 'core/post-title',
58 - 'post-content.php' => 'core/post-content',
59 - 'post-author.php' => 'core/post-author',
60 - 'post-date.php' => 'core/post-date',
61 - 'post-excerpt.php' => 'core/post-excerpt',
20 + 'archives.php' => 'core/archives',
21 + 'block.php' => 'core/block',
22 + 'calendar.php' => 'core/calendar',
23 + 'categories.php' => 'core/categories',
24 + 'latest-comments.php' => 'core/latest-comments',
25 + 'latest-posts.php' => 'core/latest-posts',
26 + 'legacy-widget.php' => 'core/legacy-widget',
27 + 'navigation.php' => 'core/navigation',
28 + 'rss.php' => 'core/rss',
29 + 'shortcode.php' => 'core/shortcode',
30 + 'search.php' => 'core/search',
31 + 'social-link.php' => 'core/social-link',
32 + 'tag-cloud.php' => 'core/tag-cloud',
33 + 'site-title.php' => 'core/site-title',
34 + 'template-part.php' => 'core/template-part',
35 + 'post-title.php' => 'core/post-title',
36 + 'post-content.php' => 'core/post-content',
37 + 'post-author.php' => 'core/post-author',
38 + 'post-comments-count.php' => 'core/post-comments-count',
39 + 'post-comments-form.php' => 'core/post-comments-form',
40 + 'post-date.php' => 'core/post-date',
41 + 'post-excerpt.php' => 'core/post-excerpt',
42 + 'post-featured-image.php' => 'core/post-featured-image',
43 + 'post-tags.php' => 'core/post-tags',
62 44 );
63 45
64 46 $registry = WP_Block_Type_Registry::get_instance();
65 47
@@ -83,8 +65,89 @@
83 65 require $blocks_dir . $file;
84 66 }
85 67 }
86 68 add_action( 'init', 'gutenberg_reregister_core_block_types' );
69 +
70 +/**
71 + * Complements the implementation of block type `core/social-icon`, whether it
72 + * be provided by core or the plugin, with derived block types for each
73 + * "service" (WordPress, Twitter, etc.) supported by Social Links.
74 + *
75 + * This ensures backwards compatibility for any users running the Gutenberg
76 + * plugin who have used Social Links prior to their conversion to block
77 + * variations.
78 + *
79 + * This shim is INTENTIONALLY left out of core, as Social Links haven't yet
80 + * landed there.
81 + *
82 + * @see https://github.com/WordPress/gutenberg/pull/19887
83 + */
84 +function gutenberg_register_legacy_social_link_blocks() {
85 + $services = array(
86 + 'amazon',
87 + 'bandcamp',
88 + 'behance',
89 + 'chain',
90 + 'codepen',
91 + 'deviantart',
92 + 'dribbble',
93 + 'dropbox',
94 + 'etsy',
95 + 'facebook',
96 + 'feed',
97 + 'fivehundredpx',
98 + 'flickr',
99 + 'foursquare',
100 + 'goodreads',
101 + 'google',
102 + 'github',
103 + 'instagram',
104 + 'lastfm',
105 + 'linkedin',
106 + 'mail',
107 + 'mastodon',
108 + 'meetup',
109 + 'medium',
110 + 'pinterest',
111 + 'pocket',
112 + 'reddit',
113 + 'skype',
114 + 'snapchat',
115 + 'soundcloud',
116 + 'spotify',
117 + 'tumblr',
118 + 'twitch',
119 + 'twitter',
120 + 'vimeo',
121 + 'vk',
122 + 'wordpress',
123 + 'yelp',
124 + 'youtube',
125 + );
126 +
127 + foreach ( $services as $service ) {
128 + register_block_type(
129 + 'core/social-link-' . $service,
130 + array(
131 + 'category' => 'widgets',
132 + 'attributes' => array(
133 + 'url' => array(
134 + 'type' => 'string',
135 + ),
136 + 'service' => array(
137 + 'type' => 'string',
138 + 'default' => $service,
139 + ),
140 + 'label' => array(
141 + 'type' => 'string',
142 + ),
143 + ),
144 + 'render_callback' => 'gutenberg_render_block_core_social_link',
145 + )
146 + );
147 + }
148 +}
149 +add_action( 'init', 'gutenberg_register_legacy_social_link_blocks' );
87 150
88 151 if ( ! function_exists( 'register_block_style' ) ) {
89 152 /**
90 153 * Registers a new block style.