Skip to content

Commit

Permalink
Add 'theme' badge to themes on the Integrations page.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Nov 25, 2024
1 parent ce869a8 commit b0d5483
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions assets/css/integrations.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@
width: unset;
}

.hcaptcha-integrations table tr .hcaptcha-integrations-entity {
color: #ffffff;
background: #4de1d2;
border: 1px #00a3bf solid;
font-size: 14px;
line-height: 18px;
padding: 4px 6px;
}

.hcaptcha-integrations-logo {
position: relative;
}
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ Instructions for popular native integrations are below:
* Added Maintenance Login Form integration.
* Added Extra theme integration.
* Added theme argument to the [hcaptcha] shortcode.
* Added 'theme' badge to themes on the Integrations page.
* Fixed deactivating of all themes by Ctrl+Click on the Integrations page.
* Fixed theme name display upon activation.
* Fixed display of the hCaptcha shortcode with individual parameters.
Expand Down
17 changes: 16 additions & 1 deletion src/php/Settings/Integrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ private function logo( array $form_field ): string {
$logo_file = sanitize_file_name( strtolower( $label ) . '.' . $logo_type );
$entity = $form_field['entity'] ?? 'plugin';

return sprintf(
$logo = sprintf(
'<div class="hcaptcha-integrations-logo" data-installed="%1$s">' .
'<img src="%2$s" alt="%3$s Logo" data-label="%3$s" data-entity="%4$s">' .
'</div>',
Expand All @@ -679,6 +679,15 @@ private function logo( array $form_field ): string {
$label,
$entity
);

if ( 'theme' === $entity ) {
$logo .= sprintf(
'<div class="hcaptcha-integrations-entity">%1$s</div>',
$entity
);
}

return $logo;
}

/**
Expand All @@ -701,6 +710,8 @@ public function setup_fields(): void {

$this->form_fields = $this->sort_fields( $this->form_fields );

$prefix = self::PREFIX . '-' . $this->section_title() . '-';

foreach ( $this->form_fields as $status => &$form_field ) {
$form_field['installed'] = in_array( $status, $installed, true );
$form_field['section'] = ( ! $form_field['installed'] ) || $form_field['disabled']
Expand All @@ -710,6 +721,10 @@ public function setup_fields(): void {
if ( isset( $form_field['label'] ) ) {
$form_field['label'] = $this->logo( $form_field );
}

$entity = $form_field['entity'] ?? '';
$theme = 'theme' === $entity ? ' ' . $prefix . 'theme' : '';
$form_field['class'] = str_replace( '_', '-', $prefix . $status . $theme );
}

unset( $form_field );
Expand Down

0 comments on commit b0d5483

Please sign in to comment.