Skip to content

Commit 5579ccb

Browse files
authored
Merge pull request #7 from rtCamp/feature/admin-logo
Feature: Add admin logo & fix PHPCS issues
2 parents 716a45c + 9da8c63 commit 5579ccb

File tree

6 files changed

+42
-13
lines changed

6 files changed

+42
-13
lines changed

assets/images/logo.svg

Lines changed: 9 additions & 0 deletions
Loading

assets/src/css/admin.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,12 @@
5454
.hidden-logo-url {
5555
display: none;
5656
}
57+
58+
59+
// add icon to the OneDesign admin menu
60+
[id="toplevel_page_onedesign"] {
61+
62+
.dashicons-admin-generic::before{
63+
content: url("../../images/logo.svg") !important;
64+
}
65+
}

inc/classes/class-assets.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ protected function __construct() {
3232
*/
3333
public function setup_hooks(): void {
3434
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts' ), 20, 1 );
35+
add_action( 'admin_enqueue_scripts', array( $this, 'add_admin_scripts' ), 20, 1 );
36+
}
37+
38+
/**
39+
* Add admin scripts.
40+
*
41+
* @return void
42+
*/
43+
public function add_admin_scripts(): void {
44+
$this->register_style( 'onedesign-admin-style', 'css/admin.css' );
45+
wp_enqueue_style( 'onedesign-admin-style' );
3546
}
3647

3748
/**

inc/classes/class-rest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function remove_consumer_site_patterns( WP_REST_Request $request ): WP_Er
370370
return new WP_Error( 'invalid_params', __( 'Pattern names must be provided as an array.', 'onedesign' ), array( 'status' => 400 ) );
371371
}
372372

373-
// Remove the patterns from the consumer site patterns option
373+
// Remove the patterns from the consumer site patterns option.
374374
$consumer_patterns = get_option( 'consumer_site_patterns', array() );
375375
if ( empty( $consumer_patterns ) ) {
376376
return new WP_Error( 'no_patterns_found', __( 'No patterns found for this consumer site.', 'onedesign' ), array( 'status' => 404 ) );
@@ -675,7 +675,7 @@ function ( $site ) use ( $site_id ) {
675675
}
676676
);
677677

678-
$target_site = reset( $target_site ); // Get the first match, should be unique by ID
678+
$target_site = reset( $target_site ); // Get the first match, should be unique by ID.
679679

680680
if ( empty( $target_site ) ) {
681681
$results[ $site_id ] = array(
@@ -782,15 +782,15 @@ private function get_all_local_patterns_map(): array {
782782
}
783783
}
784784

785-
// Get all registered patterns
785+
// Get all registered patterns.
786786
$registered_patterns = \WP_Block_Patterns_Registry::get_instance()->get_all_registered();
787787

788788
foreach ( $registered_patterns as $pattern ) {
789789
if ( false === $pattern['inserter'] ) {
790790
continue; // Skip patterns not intended for inserter.
791791
}
792792

793-
// Map pattern category name to labels
793+
// Map pattern category name to labels.
794794
$pattern['category_labels'] = array();
795795
if ( ! empty( $pattern['categories'] ) && is_array( $pattern['categories'] ) ) {
796796
foreach ( $pattern['categories'] as $category_name ) {

inc/classes/class-settings.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function add_settings_page(): void {
8282
'manage_options',
8383
self::PAGE_SLUG,
8484
'__return_null',
85-
'dashicons-admin-generic',
85+
'',
8686
100
8787
);
8888

@@ -127,12 +127,12 @@ public function handle_design_library_redirect(): void {
127127
return;
128128
}
129129

130-
// Only run for users with proper permissions
130+
// Only run for users with proper permissions.
131131
if ( ! current_user_can( 'manage_options' ) ) {
132132
return;
133133
}
134134

135-
// Your existing create/redirect logic here
135+
// Your existing create/redirect logic here.
136136
$this->create_and_open_design_library_post();
137137
}
138138

@@ -324,16 +324,16 @@ public function handle_form_actions(): void {
324324

325325
// Handle child sites update for dashboard sites.
326326
if ( isset( $_POST['child_sites'] ) && get_option( self::OPTION_SITE_TYPE ) === 'dashboard' ) {
327-
$child_sites = array();
328-
329-
foreach ( $_POST['child_sites'] as $site_data ) {
327+
$child_sites = array();
328+
$post_child_sites = $_POST['child_sites'] ?? array(); // phpcs:ignore -- sites info is sanitized below.
329+
foreach ( $post_child_sites as $site_data ) {
330330
$site_id = isset( $site_data['id'] ) ? sanitize_text_field( $site_data['id'] ) : '';
331331
$site_name = isset( $site_data['name'] ) ? sanitize_text_field( $site_data['name'] ) : '';
332332
$site_url = isset( $site_data['url'] ) ? esc_url_raw( $site_data['url'] ) : '';
333333
$site_logo = isset( $site_data['logo'] ) ? esc_url_raw( $site_data['logo'] ) : '';
334334
$site_api_key = isset( $site_data['api_key'] ) ? sanitize_text_field( $site_data['api_key'] ) : '';
335335

336-
// Only save if all fields are filled
336+
// Only save if all fields are filled.
337337
if ( ! empty( $site_name ) && ! empty( $site_url ) && ! empty( $site_api_key ) ) {
338338
$child_sites[] = array(
339339
'id' => $site_id,

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)