Skip to content

Commit

Permalink
Move icon data string to utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
zach-adams committed Sep 11, 2023
1 parent d320ad8 commit 8458d4f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/external-connection-cpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ function add_menu_item() {
apply_filters( 'dt_capabilities', 'manage_options' ),
'distributor',
__NAMESPACE__ . '\dashboard',
'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6MiIgdmlld0JveD0iMTMuNCA4LjggNTczLjIgNTczLjIiPgogIDxwYXRoIGZpbGw9IiNhN2FhYWQiIGQ9Ik0xOTUuMTEzIDQxMS4wMzNjNDUuODM1IDQ2LjY5MiAxMTkuMTI0IDU4LjQ4OCAxNzguMzg3IDI0LjI3MyA3MC4yNjItNDAuNTY2IDk0LjM3MS0xMzAuNTQ0IDUzLjgwNi0yMDAuODA2LTQwLjU2Ni03MC4yNjItMTMwLjU0NC05NC4zNzEtMjAwLjgwNi01My44MDYtMTkuODczIDExLjQ3NC0zNi4wNTUgMjYuODk5LTQ4LjEyNCA0NC43MTVsNjQuNzIyIDMzLjE4NmMyMi4yMDEtMjUuNTkzIDU5Ljc5Ni0zMy43ODIgOTEuMjc5LTE3LjYzOSAzNy4wMDIgMTguOTczIDUxLjY0IDY0LjQxOCAzMi42NjcgMTAxLjQyMS0xOC45NzMgMzcuMDAyLTY0LjQxOCA1MS42NC0xMDEuNDIxIDMyLjY2Ny0zMS40ODMtMTYuMTQzLTQ2Ljc3Ni01MS40NS0zOC45NTEtODQuNDE1bC04MS43MDItN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xNzAuNTM5IDEyNy40NDMgNTYuNTg0IDI1OS40ODcgMzYuOTggMjY1LjU5NCAyMC41MzMgMjgxLjQzOCA4LjggMzAwIDguOGMyMy44NDMgMCA0My4yIDE5LjM1NyA0My4yIDQzLjIgMCAyMy44NDMtMTkuMzU3IDQzLjItNDMuMiA0My4yLTE2LjIyOSAwLTMwLjM4LTguOTY4LTM3Ljc2My0yMi4yMTVaIi8+Cjwvc3ZnPgo='
Utils\get_admin_icon(),
);

add_action( "load-$hook", __NAMESPACE__ . '\screen_option' );
Expand Down
2 changes: 1 addition & 1 deletion includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZDtjbGlwLXJ1bGU6ZXZlbm9kZDtzdHJva2UtbGluZWpvaW46cm91bmQ7c3Ryb2tlLW1pdGVybGltaXQ6MiIgdmlld0JveD0iMTMuNCA4LjggNTczLjIgNTczLjIiPgogIDxwYXRoIGZpbGw9IiNhN2FhYWQiIGQ9Ik0xOTUuMTEzIDQxMS4wMzNjNDUuODM1IDQ2LjY5MiAxMTkuMTI0IDU4LjQ4OCAxNzguMzg3IDI0LjI3MyA3MC4yNjItNDAuNTY2IDk0LjM3MS0xMzAuNTQ0IDUzLjgwNi0yMDAuODA2LTQwLjU2Ni03MC4yNjItMTMwLjU0NC05NC4zNzEtMjAwLjgwNi01My44MDYtMTkuODczIDExLjQ3NC0zNi4wNTUgMjYuODk5LTQ4LjEyNCA0NC43MTVsNjQuNzIyIDMzLjE4NmMyMi4yMDEtMjUuNTkzIDU5Ljc5Ni0zMy43ODIgOTEuMjc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NDIgMTIuNzgzIDEwLjA5NSAxNS41OTIgOC44NDkgMzUuMjg0LTEuNjU3IDQ5LjM1MkM1NjUuMjg4IDIyOS40NjEgNTc0IDI2Ny43MjEgNTc0IDMwOGMwIDE1MS4yMjUtMTIyLjc3NSAyNzQtMjc0IDI3NFMyNiA0NTkuMjI1IDI2IDMwOEMyNiAxNzAuNTM5IDEyNy40NDMgNTYuNTg0IDI1OS40ODcgMzYuOTggMjY1LjU5NCAyMC41MzMgMjgxLjQzOCA4LjggMzAwIDguOGMyMy44NDMgMCA0My4yIDE5LjM1NyA0My4yIDQzLjIgMCAyMy44NDMtMTkuMzU3IDQzLjItNDMuMiA0My4yLTE2LjIyOSAwLTMwLjM4LTguOTY4LTM3Ljc2My0yMi4yMTVaIi8+Cjwvc3ZnPgo=' );
add_menu_page( 'Distributor', 'Distributor', 'manage_options', 'distributor-settings', __NAMESPACE__ . '\network_settings_screen', Utils\get_admin_icon() );
}

/**
Expand Down
14 changes: 14 additions & 0 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" viewBox="13.4 8.8 573.2 573.2"><path fill="%1$s" d="M195.113 411.033c45.835 46.692 119.124 58.488 178.387 24.273 70.262-40.566 94.371-130.544 53.806-200.806-40.566-70.262-130.544-94.371-200.806-53.806-19.873 11.474-36.055 26.899-48.124 44.715l64.722 33.186c22.201-25.593 59.796-33.782 91.279-17.639 37.002 18.973 51.64 64.418 32.667 101.421-18.973 37.002-64.418 51.64-101.421 32.667-31.483-16.143-46.776-51.45-38.951-84.415l-81.702-41.892c-8.838-4.532-12.335-15.367-7.814-24.211 15.514-30.346 39.658-56.715 71.344-75.009 87.469-50.5 199.482-20.486 249.983 66.983 50.5 87.469 20.486 199.482-66.983 249.983-75.235 43.437-168.63 27.307-225.419-33.717-17.809 3.778-36.797-4.055-46.387-20.666-11.922-20.648-4.837-47.091 15.812-59.012 20.648-11.922 47.091-4.836 59.012 15.812 7.77 13.458 7.466 29.377.595 42.133Z"/><path fill="%1$s" d="M262.237 72.985C148.8 91.101 62 189.494 62 308c0 131.356 106.644 238 238 238s238-106.644 238-238c0-34.059-7.168-66.458-20.08-95.766-15.121.99-30.323-6.014-39.137-19.626-12.959-20.014-7.231-46.783 12.783-59.742 20.014-12.958 46.783-7.231 59.742 12.783 10.095 15.592 8.849 35.284-1.657 49.352C565.288 229.461 574 267.721 574 308c0 151.225-122.775 274-274 274S26 459.225 26 308C26 170.539 127.443 56.584 259.487 36.98 265.594 20.533 281.438 8.8 300 8.8c23.843 0 43.2 19.357 43.2 43.2 0 23.843-19.357 43.2-43.2 43.2-16.229 0-30.38-8.968-37.763-22.215Z"/></svg>', $color );

return sprintf( 'data:image/svg+xml;base64,%s', base64_encode( $svg_icon ) );
}

0 comments on commit 8458d4f

Please sign in to comment.