From 80bfbfbc431889bddec3fb2c808f5d5ec4e72659 Mon Sep 17 00:00:00 2001 From: Brian DiChiara Date: Thu, 13 Jun 2024 15:39:50 -0500 Subject: [PATCH] [#105] Convert button icons file into class --- bin/composer-scripts/ProjectEventHandler.php | 11 + .../acf-blocks-toolkit/acf-blocks-toolkit.php | 24 +- .../includes/button-icons.php | 390 ---------------- .../src/classes/BlockIcons.php | 433 ++++++++++++++++++ .../classes/BlockRegistration.php} | 2 +- .../settings.php => src/classes/Settings.php} | 4 +- 6 files changed, 460 insertions(+), 404 deletions(-) delete mode 100644 wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php create mode 100644 wp-content/plugins/acf-blocks-toolkit/src/classes/BlockIcons.php rename wp-content/plugins/acf-blocks-toolkit/{includes/register.php => src/classes/BlockRegistration.php} (99%) rename wp-content/plugins/acf-blocks-toolkit/{includes/settings.php => src/classes/Settings.php} (95%) diff --git a/bin/composer-scripts/ProjectEventHandler.php b/bin/composer-scripts/ProjectEventHandler.php index 17979d2b..af9fc6ab 100644 --- a/bin/composer-scripts/ProjectEventHandler.php +++ b/bin/composer-scripts/ProjectEventHandler.php @@ -23,4 +23,15 @@ class ProjectEventHandler { public static function postCreateProject( Event $event ): void { PostCreateProjectScript::execute( $event ); } + + /** + * Post install event. + * + * @param Event $event + * + * @return void + */ + public static function postInstall( Event $event ): void { + // Do nothing. + } } diff --git a/wp-content/plugins/acf-blocks-toolkit/acf-blocks-toolkit.php b/wp-content/plugins/acf-blocks-toolkit/acf-blocks-toolkit.php index 74500a38..d3c73b52 100644 --- a/wp-content/plugins/acf-blocks-toolkit/acf-blocks-toolkit.php +++ b/wp-content/plugins/acf-blocks-toolkit/acf-blocks-toolkit.php @@ -17,7 +17,8 @@ * @package ACFBlocksToolkit */ -use Viget\ACFBlocksToolkit\Block_Registration; +use Viget\ACFBlocksToolkit\BlockIcons; +use Viget\ACFBlocksToolkit\BlockRegistration; use Viget\ACFBlocksToolkit\Settings; // Plugin version. @@ -32,20 +33,21 @@ // Helper functions. require_once 'includes/helpers.php'; +// Timber functions. +require_once 'includes/timber.php'; + // Assets. require_once 'includes/assets.php'; -// Registration functions. -require_once 'includes/register.php'; +// Block Registration class. +require_once 'src/classes/BlockRegistration.php'; -// Settings functions. -require_once 'includes/settings.php'; +// Block Settings class. +require_once 'src/classes/Settings.php'; -// Timber functions. -require_once 'includes/timber.php'; - -// Timber functions. -require_once 'includes/button-icons.php'; +// Block Icons support. +require_once 'src/classes/BlockIcons.php'; -Block_Registration::init(); +BlockRegistration::init(); Settings::init(); +new BlockIcons(); diff --git a/wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php b/wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php deleted file mode 100644 index f8029e27..00000000 --- a/wp-content/plugins/acf-blocks-toolkit/includes/button-icons.php +++ /dev/null @@ -1,390 +0,0 @@ - acfbt_get_icons(), - 'supportedBlocks' => acfbt_get_supported_icon_blocks(), - ] - ); - - wp_enqueue_script( 'acfbt-editor-scripts' ); - - wp_set_script_translations( - 'acfbt-editor-scripts', - 'acf-blocks-toolkit', - ACFBT_PLUGIN_URL . 'languages' - ); - - wp_enqueue_style( - 'acfbt-editor-styles', - ACFBT_PLUGIN_URL . 'build/editor.css' - ); - - wp_add_inline_style( - 'acfbt-editor-styles', - acfbt_button_icons_editor_css() - ); - } -); - -/** - * Enqueue block styles - * (Applies to both frontend and Editor) - */ -add_action( - 'init', - function () { - foreach ( acfbt_get_supported_icon_blocks() as $block_name ) { - wp_enqueue_block_style( - $block_name, - array( - 'handle' => 'acfbt-block-styles', - 'src' => ACFBT_PLUGIN_URL . '/build/style.css', - 'ver' => ACFBT_VERSION, - 'path' => ACFBT_PLUGIN_PATH . '/build/style.css', - ) - ); - } - } -); - -/** - * Add the icons to the block styles. - * - * @return string - */ -function acfbt_button_icons_editor_css(): string { - $icons = acfbt_get_icons(); - $css = ''; - - foreach ( $icons as $icon ) { - $slug = $icon['value']; - $content = 'data:image/svg+xml;utf8,' . rawurlencode( $icon['icon'] ); - - $css .= ".wp-block-button.has-icon__{$slug} .wp-block-button__link::after,"; - $css .= ".wp-block-button.has-icon__{$slug} .wp-block-button__link::before,"; - $css .= ".wp-block-navigation-item.has-icon__{$slug} .wp-block-navigation-item__content::after,"; - $css .= ".wp-block-navigation-item.has-icon__{$slug} .wp-block-navigation-item__content::before {"; - $css .= 'height: 0.7em;'; - $css .= 'width: 1em;'; - $css .= "mask-image: url( $content );"; - $css .= "-webkit-mask-image: url( $content );"; - $css .= '}' . PHP_EOL; - } - - // Manually adjust a few of the icons - $css .= '.button-icon-picker__button.button-icon-picker__icon-chevron-left-small span svg,.button-icon-picker__button.button-icon-picker__icon-chevron-right-small span svg, - .button-icon-picker__button.button-icon-picker__icon-external-arrow span svg {max-height: 60%}'; - $css .= '.button-icon-picker__button.button-icon-picker__icon-previous span svg,.button-icon-picker__button.button-icon-picker__icon-next span svg {max-height: 80%}'; - - return apply_filters( 'acfbt_button_icons_editor_css', $css ); -} - -/** - * Render icons on the frontend. - */ -foreach ( acfbt_get_supported_icon_blocks() as $block_name ) { - add_filter( "render_block_{$block_name}", 'acfbt_render_frontend_icons', 10, 2 ); -} - -/** - * Render icons on frontend. - * - * @param string $block_content - * @param array $block - * - * @return string - */ -function acfbt_render_frontend_icons( string $block_content, array $block ): string { - if ( ! isset( $block['attrs']['icon'] ) ) { - return $block_content; - } - - list( $namespace, $block_name ) = explode( '/', $block['blockName'] ); - - $icon = acfbt_get_icon( $block['attrs']['icon'] ); - - // Make sure the selected icon exists, otherwise bail. - if ( empty( $icon ) ) { - return $block_content; - } - - $position_left = $block['attrs']['iconPositionLeft'] ?? false; - - // Append the icon class to the block. - $p = new WP_HTML_Tag_Processor( $block_content ); - if ( $p->next_tag() ) { - $p->add_class( 'has-icon__' . $icon['value'] ); - } - $block_content = $p->get_updated_html(); - $block_content = str_replace( '$', '\$', $block_content ); - - $pattern = '/(]*>)(.*?)(<\/a>)/i'; - $markup = sprintf( - '', - esc_attr( $block_name ), - esc_attr( $icon['value'] ), - $icon['icon'] - ); - - // Add the SVG icon either to the left of right of the button text. - return $position_left - ? preg_replace( $pattern, '$1' . $markup . '$2$3', $block_content ) - : preg_replace( $pattern, '$1$2' . $markup . '$3', $block_content ); -} - -/** - * Get all available icons. - * - * @param bool $from_file - * - * @return array - */ -function acfbt_get_icons( bool $from_file = true ): array { - global $acfbt_disable_filters; - - if ( $from_file ) { - $path = acfbt_get_icons_file_path(); - return file_exists( $path ) ? json_decode( file_get_contents( $path ), true ) : []; - } - - $icons = [ - 'arrow-left' => [ - 'label' => __( 'Arrow Left', 'acf-blocks-toolkit' ), - 'icon' => "", - 'defaultLeft' => true, - ], - 'arrow-right' => [ - 'label' => __( 'Arrow Right', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'chevron-left' => [ - 'label' => __( 'Chevron Left', 'acf-blocks-toolkit' ), - 'icon' => "", - 'defaultLeft' => true, - ], - 'chevron-left-small' => [ - 'label' => __( 'Chevron Left Small', 'acf-blocks-toolkit' ), - 'icon' => "", - 'defaultLeft' => true, - ], - 'chevron-right' => [ - 'label' => __( 'Chevron Right', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'chevron-right-small' => [ - 'label' => __( 'Chevron Right Small', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'cloud' => [ - 'label' => __( 'Cloud', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'cloud-upload' => [ - 'label' => __( 'Cloud Upload', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'comment-author-avatar' => [ - 'label' => __( 'Comment Author Avatar', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'download' => [ - 'label' => __( 'Download', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'external' => [ - 'label' => __( 'External', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'external-arrow' => [ - 'label' => __( 'External Arrow', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'help' => [ - 'label' => __( 'Help', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'info' => [ - 'label' => __( 'Info', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'lock-outline' => [ - 'label' => __( 'Lock Outline', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'login' => [ - 'label' => __( 'Login', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'next' => [ - 'label' => __( 'Next', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'previous' => [ - 'label' => __( 'Previous', 'acf-blocks-toolkit' ), - 'icon' => "", - 'defaultLeft' => true, - ], - 'shuffle' => [ - 'label' => __( 'Shuffle', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - 'wordpress' => [ - 'label' => __( 'WordPress', 'acf-blocks-toolkit' ), - 'icon' => "", - ], - ]; - - if ( $acfbt_disable_filters ) { - return $icons; - } - - /** - * Filter the available button icons. - * - * @param array $icons The available button icons. - */ - return apply_filters( 'acfbt_button_icons', $icons ); -} - -/** - * Get an icon - * - * @param string $slug - * - * @return array - */ -function acfbt_get_icon( string $slug ): array { - $icons = acfbt_get_icons(); - - foreach ( $icons as $icon ) { - if ( $slug === $icon['value'] ) { - return $icon; - } - } - - return []; -} - -/** - * Generate the Icons JSON file. - * - * @return void - */ -function acfbt_generate_json(): void { - $icons = acfbt_get_icons( false ); - $checksum = md5( json_encode( $icons ) ); - $path = acfbt_get_icons_file_path( true ); - - if ( file_exists( $path ) && $checksum === get_transient( ACFBT_ICONS_CHECKSUM ) ) { - return; - } - - $json = []; - - foreach ( $icons as $slug => $icon ) { - if ( ! is_array( $icon ) ) { - $icon = [ 'icon' => $icon ]; - } - - $default_label = is_numeric( $slug ) ? __( 'Icon', 'acf-blocks-toolkit' ) . ' ' . $slug : ucwords( str_replace( '-', ' ', $slug ) ); - - $json[] = [ - 'label' => $icon['label'] ?? $default_label, - 'value' => $slug, - 'icon' => $icon['icon'], - 'defaultLeft' => $icon['defaultLeft'] ?? false, - ]; - } - - if ( ! is_dir( dirname( $path ) ) ) { - wp_mkdir_p( dirname( $path ) ); - } - - if ( file_put_contents( $path, json_encode( $json, JSON_PRETTY_PRINT ) ) ) { - set_transient( ACFBT_ICONS_CHECKSUM, $checksum ); - } -} - -add_action( 'init', 'acfbt_generate_json' ); - -/** - * Get path to the icons JSON file. - * - * @param bool $write_file - * - * @return string - */ -function acfbt_get_icons_file_path( bool $write_file = false ): string { - global $acfbt_disable_filters; - $uploads_dir = wp_get_upload_dir(); - $custom_icons = $uploads_dir['basedir'] . '/acf-blocks-toolkit/icons.json'; - $plugin_icons = ACFBT_PLUGIN_PATH . 'assets/icons.json'; - - if ( $write_file ) { - if ( ! file_exists( $plugin_icons ) ) { - $acfbt_disable_filters = true; - return $plugin_icons; - } - - return $custom_icons; - } - - $theme_icons = get_stylesheet_directory() . '/acf-blocks-toolkit/icons.json'; - - if ( file_exists( $theme_icons ) ) { - return $theme_icons; - } - - if ( file_exists( $custom_icons ) ) { - return $custom_icons; - } - - return $plugin_icons; -} diff --git a/wp-content/plugins/acf-blocks-toolkit/src/classes/BlockIcons.php b/wp-content/plugins/acf-blocks-toolkit/src/classes/BlockIcons.php new file mode 100644 index 00000000..ca74060f --- /dev/null +++ b/wp-content/plugins/acf-blocks-toolkit/src/classes/BlockIcons.php @@ -0,0 +1,433 @@ +generate_json(); + + // Enqueue editor assets. + $this->enqueue_editor_assets(); + + // Enqueue block assets. + $this->enqueue_block_assets(); + + // Add hooks to render icons on frontend. + $this->add_render_hooks(); + } + + /** + * Get supported blocks for icons. + * + * @return string[] + */ + public function get_supported_blocks(): array { + return apply_filters( + 'acfbt_supported_icon_blocks', + [ + 'core/button', + 'core/navigation-link', + 'core/home-link', + ] + ); + } + + /** + * Render icons on the frontend. + */ + private function add_render_hooks(): void { + foreach ( $this->get_supported_blocks() as $block_name ) { + add_filter( + "render_block_{$block_name}", + [ $this, 'render_frontend_icons' ], + 10, + 2 + ); + } + } + + /** + * Get all available icons. + * + * @param bool $from_file + * + * @return array + */ + private function get_icons( bool $from_file = true ): array { + if ( $from_file ) { + $path = $this->get_icons_file_path(); + return file_exists( $path ) ? json_decode( file_get_contents( $path ), true ) : []; + } + + $icons = [ + 'arrow-left' => [ + 'label' => __( 'Arrow Left', 'acf-blocks-toolkit' ), + 'icon' => "", + 'defaultLeft' => true, + ], + 'arrow-right' => [ + 'label' => __( 'Arrow Right', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'chevron-left' => [ + 'label' => __( 'Chevron Left', 'acf-blocks-toolkit' ), + 'icon' => "", + 'defaultLeft' => true, + ], + 'chevron-left-small' => [ + 'label' => __( 'Chevron Left Small', 'acf-blocks-toolkit' ), + 'icon' => "", + 'defaultLeft' => true, + ], + 'chevron-right' => [ + 'label' => __( 'Chevron Right', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'chevron-right-small' => [ + 'label' => __( 'Chevron Right Small', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'cloud' => [ + 'label' => __( 'Cloud', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'cloud-upload' => [ + 'label' => __( 'Cloud Upload', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'comment-author-avatar' => [ + 'label' => __( 'Comment Author Avatar', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'download' => [ + 'label' => __( 'Download', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'external' => [ + 'label' => __( 'External', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'external-arrow' => [ + 'label' => __( 'External Arrow', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'help' => [ + 'label' => __( 'Help', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'info' => [ + 'label' => __( 'Info', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'lock-outline' => [ + 'label' => __( 'Lock Outline', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'login' => [ + 'label' => __( 'Login', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'next' => [ + 'label' => __( 'Next', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'previous' => [ + 'label' => __( 'Previous', 'acf-blocks-toolkit' ), + 'icon' => "", + 'defaultLeft' => true, + ], + 'shuffle' => [ + 'label' => __( 'Shuffle', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + 'wordpress' => [ + 'label' => __( 'WordPress', 'acf-blocks-toolkit' ), + 'icon' => "", + ], + ]; + + if ( $this->disable_icon_filter ) { + return $icons; + } + + /** + * Filter the available button icons. + * + * @param array $icons The available button icons. + */ + return apply_filters( 'acfbt_button_icons', $icons ); + } + + /** + * Get an icon + * + * @param string $slug + * + * @return array + */ + private function get_icon( string $slug ): array { + $icons = $this->get_icons(); + + foreach ( $icons as $icon ) { + if ( $slug === $icon['value'] ) { + return $icon; + } + } + + return []; + } + + /** + * Render icons on frontend. + * + * @param string $block_content + * @param array $block + * + * @return string + */ + public function render_frontend_icons( string $block_content, array $block ): string { + if ( ! isset( $block['attrs']['icon'] ) ) { + return $block_content; + } + + list( $namespace, $block_name ) = explode( '/', $block['blockName'] ); + + $icon = $this->get_icon( $block['attrs']['icon'] ); + + // Make sure the selected icon exists, otherwise bail. + if ( empty( $icon ) ) { + return $block_content; + } + + $position_left = $block['attrs']['iconPositionLeft'] ?? false; + + // Append the icon class to the block. + $p = new WP_HTML_Tag_Processor( $block_content ); + if ( $p->next_tag() ) { + $p->add_class( 'has-icon__' . $icon['value'] ); + } + $block_content = $p->get_updated_html(); + $block_content = str_replace( '$', '\$', $block_content ); + + $pattern = '/(]*>)(.*?)(<\/a>)/i'; + $markup = sprintf( + '', + esc_attr( $block_name ), + esc_attr( $icon['value'] ), + $icon['icon'] + ); + + // Add the SVG icon either to the left of right of the button text. + return $position_left + ? preg_replace( $pattern, '$1' . $markup . '$2$3', $block_content ) + : preg_replace( $pattern, '$1$2' . $markup . '$3', $block_content ); + } + + /** + * Enqueue Editor scripts and styles. + * + * @return void + */ + private function enqueue_editor_assets(): void { + add_action( + 'enqueue_block_editor_assets', + function () { + $asset_file = include ACFBT_PLUGIN_PATH . 'build/index.asset.php'; + + wp_register_script( + 'acfbt-editor-scripts', + ACFBT_PLUGIN_URL . 'build/index.js', + $asset_file['dependencies'], + $asset_file['version'] + ); + + wp_localize_script( + 'acfbt-editor-scripts', + 'acfbtVars', + [ + 'iconsJson' => $this->get_icons(), + 'supportedBlocks' => $this->get_supported_blocks(), + ] + ); + + wp_enqueue_script( 'acfbt-editor-scripts' ); + + wp_set_script_translations( + 'acfbt-editor-scripts', + 'acf-blocks-toolkit', + ACFBT_PLUGIN_URL . 'languages' + ); + + wp_enqueue_style( + 'acfbt-editor-styles', + ACFBT_PLUGIN_URL . 'build/editor.css' + ); + + wp_add_inline_style( + 'acfbt-editor-styles', + $this->editor_css() + ); + } + ); + + } + + /** + * Enqueue block styles + * (Applies to both frontend and Editor) + */ + private function enqueue_block_assets(): void { + add_action( + 'init', + function (): void { + foreach ( $this->get_supported_blocks() as $block_name ) { + wp_enqueue_block_style( + $block_name, + [ + 'handle' => 'acfbt-block-styles', + 'src' => ACFBT_PLUGIN_URL . 'build/style.css', + 'ver' => ACFBT_VERSION, + 'path' => ACFBT_PLUGIN_PATH . 'build/style.css', + ] + ); + } + } + ); + } + + /** + * Get the CSS for the editor. + * + * @return string + */ + private function editor_css(): string { + $icons = $this->get_icons(); + $css = ''; + + foreach ( $icons as $icon ) { + $slug = $icon['value']; + $content = 'data:image/svg+xml;utf8,' . rawurlencode( $icon['icon'] ); + + $css .= ".wp-block-button.has-icon__{$slug} .wp-block-button__link::after,"; + $css .= ".wp-block-button.has-icon__{$slug} .wp-block-button__link::before,"; + $css .= ".wp-block-navigation-item.has-icon__{$slug} .wp-block-navigation-item__content::after,"; + $css .= ".wp-block-navigation-item.has-icon__{$slug} .wp-block-navigation-item__content::before {"; + $css .= 'height: 0.7em;'; + $css .= 'width: 1em;'; + $css .= "mask-image: url( $content );"; + $css .= "-webkit-mask-image: url( $content );"; + $css .= '}' . PHP_EOL; + } + + // Manually adjust a few of the icons + $css .= '.button-icon-picker__button.button-icon-picker__icon-chevron-left-small span svg,.button-icon-picker__button.button-icon-picker__icon-chevron-right-small span svg, + .button-icon-picker__button.button-icon-picker__icon-external-arrow span svg {max-height: 60%}'; + $css .= '.button-icon-picker__button.button-icon-picker__icon-previous span svg,.button-icon-picker__button.button-icon-picker__icon-next span svg {max-height: 80%}'; + + return apply_filters( 'acfbt_button_icons_editor_css', $css ); + } + + /** + * Generate the Icons JSON file. + * + * @return void + */ + private function generate_json(): void { + add_action( + 'init', + function () { + $icons = $this->get_icons( false ); + $checksum = md5( json_encode( $icons ) ); + $path = $this->get_icons_file_path( true ); + + if ( file_exists( $path ) && $checksum === get_transient( self::ICONS_CHECKSUM ) ) { + return; + } + + $json = []; + + foreach ( $icons as $slug => $icon ) { + if ( ! is_array( $icon ) ) { + $icon = [ 'icon' => $icon ]; + } + + $default_label = is_numeric( $slug ) ? __( 'Icon', 'acf-blocks-toolkit' ) . ' ' . $slug : ucwords( str_replace( '-', ' ', $slug ) ); + + $json[] = [ + 'label' => $icon['label'] ?? $default_label, + 'value' => $slug, + 'icon' => $icon['icon'], + 'defaultLeft' => $icon['defaultLeft'] ?? false, + ]; + } + + if ( ! is_dir( dirname( $path ) ) ) { + wp_mkdir_p( dirname( $path ) ); + } + + if ( file_put_contents( $path, json_encode( $json, JSON_PRETTY_PRINT ) ) ) { + set_transient( self::ICONS_CHECKSUM, $checksum ); + } + } + ); + } + + /** + * Get path to the icons JSON file. + * + * @param bool $write_file + * + * @return string + */ + private function get_icons_file_path( bool $write_file = false ): string { + $uploads_dir = wp_get_upload_dir(); + $custom_icons = $uploads_dir['basedir'] . '/acf-blocks-toolkit/icons.json'; + $plugin_icons = ACFBT_PLUGIN_PATH . 'assets/icons.json'; + + if ( $write_file ) { + if ( ! file_exists( $plugin_icons ) ) { + $this->disable_icon_filter = true; + return $plugin_icons; + } + + return $custom_icons; + } + + $theme_icons = get_stylesheet_directory() . '/acf-blocks-toolkit/icons.json'; + + if ( file_exists( $theme_icons ) ) { + return $theme_icons; + } + + if ( file_exists( $custom_icons ) ) { + return $custom_icons; + } + + return $plugin_icons; + } +} diff --git a/wp-content/plugins/acf-blocks-toolkit/includes/register.php b/wp-content/plugins/acf-blocks-toolkit/src/classes/BlockRegistration.php similarity index 99% rename from wp-content/plugins/acf-blocks-toolkit/includes/register.php rename to wp-content/plugins/acf-blocks-toolkit/src/classes/BlockRegistration.php index aebf0f4c..2f325a42 100644 --- a/wp-content/plugins/acf-blocks-toolkit/includes/register.php +++ b/wp-content/plugins/acf-blocks-toolkit/src/classes/BlockRegistration.php @@ -12,7 +12,7 @@ /** * Block Registration Class */ -class Block_Registration { +class BlockRegistration { /** * @var array diff --git a/wp-content/plugins/acf-blocks-toolkit/includes/settings.php b/wp-content/plugins/acf-blocks-toolkit/src/classes/Settings.php similarity index 95% rename from wp-content/plugins/acf-blocks-toolkit/includes/settings.php rename to wp-content/plugins/acf-blocks-toolkit/src/classes/Settings.php index c6a02172..234df23a 100644 --- a/wp-content/plugins/acf-blocks-toolkit/includes/settings.php +++ b/wp-content/plugins/acf-blocks-toolkit/src/classes/Settings.php @@ -39,7 +39,7 @@ function ( array $paths ): array { return array_merge( $paths, self::$paths ); } - foreach ( Block_Registration::get_all_blocks() as $block ) { + foreach ( BlockRegistration::get_all_blocks() as $block ) { if ( empty( $block['path'] ) ) { continue; } @@ -74,7 +74,7 @@ function ( $path ) { return $path; } - $block_path = Block_Registration::get_block_location( $block ); + $block_path = BlockRegistration::get_block_location( $block ); if ( $block_path ) { return $block_path;