PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
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/compat/wordpress-7.1/icons.php +4 -74 24.0.0 → trunk View file →
@@ -14,8 +14,12 @@
14 14 * Arguments for registering an icon collection.
15 15 *
16 16 * @type string $label Required. A human-readable label for the icon collection.
17 17 * @type string $description Optional. A human-readable description for the icon collection.
18 + * @type bool $public Optional. Whether the collection and its icons are exposed through
19 + * the REST API and selectable in the editor's Icon block. Icons in
20 + * non-public collections remain available via {@see wp_get_icon()}.
21 + * Default true.
18 22 * }
19 23 * @return bool True if the icon collection was registered successfully, else false.
20 24 */
21 25 function wp_register_icon_collection( $slug, $args ) {
@@ -71,82 +75,8 @@
71 75 function wp_unregister_icon( $icon_name ) {
72 76 return WP_Icons_Registry::get_instance()->unregister( $icon_name );
73 77 }
74 78 }
75 -
76 -/**
77 - * Registers the default icon collections for Gutenberg.
78 - */
79 -function gutenberg_register_default_icon_collections() {
80 - wp_register_icon_collection(
81 - 'core',
82 - array(
83 - 'label' => __( 'WordPress', 'gutenberg' ),
84 - 'description' => __( 'Core icon collection.', 'gutenberg' ),
85 - )
86 - );
87 -}
88 -
89 -$default_icon_collections_priority = has_action( 'init', '_wp_register_default_icon_collections' );
90 -if ( false !== $default_icon_collections_priority ) {
91 - remove_action( 'init', '_wp_register_default_icon_collections', $default_icon_collections_priority );
92 -}
93 -add_action( 'init', 'gutenberg_register_default_icon_collections', 0 );
94 -
95 -/**
96 - * Registers the default core icons from the Gutenberg manifest.
97 - */
98 -function gutenberg_register_default_icons() {
99 - $icons_directory = gutenberg_dir_path() . 'packages/icons/src';
100 - $icons_directory = trailingslashit( $icons_directory );
101 - $manifest_path = $icons_directory . 'manifest.php';
102 -
103 - if ( ! is_readable( $manifest_path ) ) {
104 - wp_trigger_error(
105 - __FUNCTION__,
106 - __( 'Core icon collection manifest is missing or unreadable.', 'gutenberg' )
107 - );
108 - return;
109 - }
110 -
111 - $collection = include $manifest_path;
112 -
113 - if ( empty( $collection ) ) {
114 - wp_trigger_error(
115 - __FUNCTION__,
116 - __( 'Core icon collection manifest is empty or invalid.', 'gutenberg' )
117 - );
118 - return;
119 - }
120 -
121 - foreach ( $collection as $icon_name => $icon_data ) {
122 - if (
123 - empty( $icon_data['filePath'] )
124 - || ! is_string( $icon_data['filePath'] )
125 - ) {
126 - _doing_it_wrong(
127 - __FUNCTION__,
128 - __( 'Core icon collection manifest must provide a valid "filePath" for each icon.', 'gutenberg' ),
129 - '7.1.0'
130 - );
131 - return;
132 - }
133 -
134 - wp_register_icon(
135 - 'core/' . $icon_name,
136 - array(
137 - 'label' => $icon_data['label'],
138 - 'file_path' => $icons_directory . $icon_data['filePath'],
139 - )
140 - );
141 - }
142 -}
143 -
144 -$default_icons_priority = has_action( 'init', '_wp_register_default_icons' );
145 -if ( false !== $default_icons_priority ) {
146 - remove_action( 'init', '_wp_register_default_icons', $default_icons_priority );
147 -}
148 -add_action( 'init', 'gutenberg_register_default_icons' );
149 79
150 80 if ( ! function_exists( 'wp_get_icon' ) ) {
151 81 /**
152 82 * Returns the SVG markup for a registered icon.