@@ -23,8 +23,15 @@ public function register( Service_Container $container ): void {}
2323 * @param Service_Container $container Service container.
2424 */
2525 public function boot ( Service_Container $ container ): void {
26+ if ( ! function_exists ( 'wp_register_icon_collection ' ) || ! function_exists ( 'wp_register_icon ' ) ) {
27+ return ;
28+ }
29+
2630 add_action ( 'init ' , [ $ this , 'register_icon_collections ' ] );
27- add_action ( 'init ' , [ $ this , 'unregister_core_icon_collection ' ], 20 );
31+
32+ if ( function_exists ( 'wp_unregister_icon_collection ' ) ) {
33+ add_action ( 'init ' , [ $ this , 'unregister_core_icon_collection ' ], 20 );
34+ }
2835 }
2936
3037 /**
@@ -40,10 +47,6 @@ public function get_service_name(): string {
4047 * @return void
4148 */
4249 public function register_icon_collections (): void {
43- if ( ! function_exists ( 'wp_register_icon_collection ' ) || ! function_exists ( 'wp_register_icon ' ) ) {
44- return ;
45- }
46-
4750 $ collections = apply_filters (
4851 'bff_icon_collections ' ,
4952 [
@@ -73,10 +76,6 @@ public function register_icon_collections(): void {
7376 * @return void
7477 */
7578 public function unregister_core_icon_collection (): void {
76- if ( ! function_exists ( 'wp_unregister_icon_collection ' ) ) {
77- return ;
78- }
79-
8079 if ( ! apply_filters ( 'bff_unregister_core_icon_collection ' , true ) ) {
8180 return ;
8281 }
@@ -91,10 +90,6 @@ public function unregister_core_icon_collection(): void {
9190 * @return void
9291 */
9392 private function register_collection ( string $ collection_slug , array $ collection_args ): void {
94- if ( ! function_exists ( 'wp_register_icon_collection ' ) ) {
95- return ;
96- }
97-
9893 $ source_subdir = isset ( $ collection_args ['source_subdir ' ] ) ? (string ) $ collection_args ['source_subdir ' ] : '' ;
9994
10095 if ( '' === $ source_subdir ) {
@@ -163,10 +158,6 @@ private function resolve_icons_directory( string $source_subdir ): ?string {
163158 * @return void
164159 */
165160 private function register_icon_file ( string $ collection_slug , string $ svg_file ): void {
166- if ( ! function_exists ( 'wp_register_icon ' ) ) {
167- return ;
168- }
169-
170161 $ real_file = realpath ( $ svg_file );
171162
172163 if ( false === $ real_file || ! is_readable ( $ real_file ) ) {
0 commit comments