From 8458d4fff7c0e4827efe946afaec793209ad2b17 Mon Sep 17 00:00:00 2001 From: zach-adams Date: Mon, 11 Sep 2023 10:06:56 -0600 Subject: [PATCH] Move icon data string to utility functions --- includes/external-connection-cpt.php | 2 +- includes/settings.php | 2 +- includes/utils.php | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/includes/external-connection-cpt.php b/includes/external-connection-cpt.php index 48023e812..1e2fb01f8 100644 --- a/includes/external-connection-cpt.php +++ b/includes/external-connection-cpt.php @@ -662,7 +662,7 @@ function add_menu_item() { apply_filters( 'dt_capabilities', 'manage_options' ), 'distributor', __NAMESPACE__ . '\dashboard', - 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6MiIgdmlld0JveD0iMTMuNCA4LjggNTczLjIgNTczLjIiPgogIDxwYXRoIGZpbGw9IiNhN2FhYWQiIGQ9Ik0xOTUuMTEzIDQxMS4wMzNjNDUuODM1IDQ2LjY5MiAxMTkuMTI0IDU4LjQ4OCAxNzguMzg3IDI0LjI3MyA3MC4yNjItNDAuNTY2IDk0LjM3MS0xMzAuNTQ0IDUzLjgwNi0yMDAuODA2LTQwLjU2Ni03MC4yNjItMTMwLjU0NC05NC4zNzEtMjAwLjgwNi01My44MDYtMTkuODczIDExLjQ3NC0zNi4wNTUgMjYuODk5LTQ4LjEyNCA0NC43MTVsNjQuNzIyIDMzLjE4NmMyMi4yMDEtMjUuNTkzIDU5Ljc5Ni0zMy43ODIgOTEuMjc5LTE3LjYzOSAzNy4wMDIgMTguOTczIDUxLjY0IDY0LjQxOCAzMi42NjcgMTAxLjQyMS0xOC45NzMgMzcuMDAyLTY0LjQxOCA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I2Ny43MjEgNTc0IDMwOGMwIDE1MS4yMjUtMTIyLjc3NSAyNzQtMjc0IDI3NFMyNiA0NTkuMjI1IDI2IDMwOEMyNiAxNzAuNTM5IDEyNy40NDMgNTYuNTg0IDI1OS40ODcgMzYuOTggMjY1LjU5NCAyMC41MzMgMjgxLjQzOCA4LjggMzAwIDguOGMyMy44NDMgMCA0My4yIDE5LjM1NyA0My4yIDQzLjIgMCAyMy44NDMtMTkuMzU3IDQzLjItNDMuMiA0My4yLTE2LjIyOSAwLTMwLjM4LTguOTY4LTM3Ljc2My0yMi4yMTVaIi8+Cjwvc3ZnPgo=' + Utils\get_admin_icon(), ); add_action( "load-$hook", __NAMESPACE__ . '\screen_option' ); diff --git a/includes/settings.php b/includes/settings.php index 224c81561..b25603dc6 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -306,7 +306,7 @@ function admin_menu() { * @since 1.2 */ function network_admin_menu() { - add_menu_page( 'Distributor', 'Distributor', 'manage_options', 'distributor-settings', __NAMESPACE__ . '\network_settings_screen', 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6MiIgdmlld0JveD0iMTMuNCA4LjggNTczLjIgNTczLjIiPgogIDxwYXRoIGZpbGw9IiNhN2FhYWQiIGQ9Ik0xOTUuMTEzIDQxMS4wMzNjNDUuODM1IDQ2LjY5MiAxMTkuMTI0IDU4LjQ4OCAxNzguMzg3IDI0LjI3MyA3MC4yNjItNDAuNTY2IDk0LjM3MS0xMzAuNTQ0IDUzLjgwNi0yMDAuODA2LTQwLjU2Ni03MC4yNjItMTMwLjU0NC05NC4zNzEtMjAwLjgwNi01My44MDYtMTkuODczIDExLjQ3NC0zNi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jYtMTIuOTU5LTIwLjAxNC03LjIzMS00Ni43ODMgMTIuNzgzLTU5Ljc0MiAyMC4wMTQtMTIuOTU4IDQ2Ljc4My03LjIzMSA1OS43NDIgMTIuNzgzIDEwLjA5NSAxNS41OTIgOC44NDkgMzUuMjg0LTEuNjU3IDQ5LjM1MkM1NjUuMjg4IDIyOS40NjEgNTc0IDI2Ny43MjEgNTc0IDMwOGMwIDE1MS4yMjUtMTIyLjc3NSAyNzQtMjc0IDI3NFMyNiA0NTkuMjI1IDI2IDMwOEMyNiAxNzAuNTM5IDEyNy40NDMgNTYuNTg0IDI1OS40ODcgMzYuOTggMjY1LjU5NCAyMC41MzMgMjgxLjQzOCA4LjggMzAwIDguOGMyMy44NDMgMCA0My4yIDE5LjM1NyA0My4yIDQzLjIgMCAyMy44NDMtMTkuMzU3IDQzLjItNDMuMiA0My4yLTE2LjIyOSAwLTMwLjM4LTguOTY4LTM3Ljc2My0yMi4yMTVaIi8+Cjwvc3ZnPgo=' ); + add_menu_page( 'Distributor', 'Distributor', 'manage_options', 'distributor-settings', __NAMESPACE__ . '\network_settings_screen', Utils\get_admin_icon() ); } /** diff --git a/includes/utils.php b/includes/utils.php index 2c751ac63..41aa5b8df 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -1271,3 +1271,17 @@ function is_distributed_post( $post ) { $original_post_id = get_post_meta( $post_id, 'dt_original_post_id', true ); return ! empty( $original_post_id ); } + +/** + * Returns the admin icon in data URL base64 format. + * + * @since 2.0.1 + * + * @param string $color The hex color if changing the color of the icon. Default `#a0a5aa`. + * @return string Data URL base64 encoded SVG icon string. + */ +function get_admin_icon( $color = '#a0a5aa' ) { + $svg_icon = sprintf( '', $color ); + + return sprintf( 'data:image/svg+xml;base64,%s', base64_encode( $svg_icon ) ); +}