Skip to content

Commit

Permalink
Merge pull request #76 from pressidium/next
Browse files Browse the repository at this point in the history
1.5.0
  • Loading branch information
over-engineer authored Jul 30, 2024
2 parents 10bbe02 + ba2e85f commit 9921872
Show file tree
Hide file tree
Showing 48 changed files with 3,794 additions and 987 deletions.
Binary file modified .wordpress-org/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/gtm-gallery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/promo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 40 additions & 1 deletion includes/Admin/Settings/Settings_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ private function get_settings_schema(): array {
'primary_btn_role',
'secondary_btn_role',
'cookie_table',
'font',
'floating_button',
'colors',
'gcm',
),
Expand Down Expand Up @@ -531,6 +533,24 @@ private function get_settings_schema(): array {
),
),
),
'font' => array(
'type' => 'object',
'required' => array(
'name',
'slug',
'family',
),
),
'floating_button' => array(
'type' => 'object',
'required' => array(
'enabled',
'size',
'position',
'icon',
'transition',
),
),
'colors' => array(
'type' => 'object',
'required' => array(
Expand All @@ -557,6 +577,10 @@ private function get_settings_schema(): array {
'overlay-bg',
'webkit-scrollbar-bg',
'webkit-scrollbar-bg-hover',
'btn-floating-bg',
'btn-floating-icon',
'btn-floating-hover-bg',
'btn-floating-hover-icon',
),
'properties' => array(
'bg' => array(
Expand Down Expand Up @@ -628,11 +652,26 @@ private function get_settings_schema(): array {
'webkit-scrollbar-bg-hover' => array(
'type' => 'string',
),
'btn-floating-bg' => array(
'type' => 'string',
),
'btn-floating-icon' => array(
'type' => 'string',
),
'btn-floating-hover-bg' => array(
'type' => 'string',
),
'btn-floating-hover-icon' => array(
'type' => 'string',
),
),
),
'record_consents' => array(
'type' => 'boolean',
),
'hide_empty_categories' => array(
'type' => 'boolean',
),
'gcm' => array(
'type' => 'object',
'required' => array(
Expand Down Expand Up @@ -1246,7 +1285,7 @@ public function register_rest_routes(): void {
);

$did_register_routes = $did_register_routes && register_rest_route(
self::REST_NAMESPACE,
self::REST_NAMESPACE,
'/consents',
array(
'methods' => 'GET',
Expand Down
11 changes: 7 additions & 4 deletions includes/Admin/Settings/Settings_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ public function enqueue_scripts() {
'assets' => array(
'gtm_template_url' => esc_url( PLUGIN_URL . 'assets/templates/template.tpl' ),
'screenshots' => array(
'import' => esc_url( PLUGIN_URL . 'assets/images/gtm-import.png' ),
'tag' => esc_url( PLUGIN_URL . 'assets/images/gtm-tag.png' ),
'config' => esc_url( PLUGIN_URL . 'assets/images/gtm-config.png' ),
'gallery' => esc_url( PLUGIN_URL . 'assets/images/gtm-gallery.png' ),
'import' => esc_url( PLUGIN_URL . 'assets/images/gtm-import.png' ),
'tag' => esc_url( PLUGIN_URL . 'assets/images/gtm-tag.png' ),
'config' => esc_url( PLUGIN_URL . 'assets/images/gtm-config.png' ),
),
'promo' => esc_url( PLUGIN_URL . 'assets/images/promo.png' ),
),
'api' => array(
'route' => 'pressidium-cookie-consent/v1/settings',
Expand Down Expand Up @@ -205,7 +207,8 @@ public function admin_footer_info( ?string $content ): ?string {
__( 'Developed by %1$s | For more information, read the %2$s.', 'pressidium-cookie-consent' ),
sprintf(
'<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>',
esc_url( 'https://pressidium.com/' ),
// phpcs:ignore Generic.Files.LineLength
esc_url( 'https://pressidium.com/?utm_source=cookieconsent&utm_medium=txtlink&utm_campaign=plugins&utm_content=footer' ),
esc_html( 'Pressidium®' )
),
sprintf(
Expand Down
28 changes: 19 additions & 9 deletions includes/Client/Cookie_Consent.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,17 @@ public function enqueue_scripts(): void {
'cookie-consent-client-script',
'pressidiumCCClientDetails',
array(
'settings' => $this->get_settings(),
'api' => array(
'settings' => $this->get_settings(),
'api' => array(
'rest_url' => rest_url(),
'route' => 'pressidium-cookie-consent/v1/settings',
'consent_route' => 'pressidium-cookie-consent/v1/consent',
'consents_route' => 'pressidium-cookie-consent/v1/consents',
),
'record_consents' => $this->settings['pressidium_options']['record_consents'] ?? true,
'gcm' => $this->settings['pressidium_options']['gcm'] ?? array(),
'record_consents' => $this->settings['pressidium_options']['record_consents'] ?? true,
'hide_empty_categories' => $this->settings['pressidium_options']['hide_empty_categories'] ?? true,
'floating_button' => $this->settings['pressidium_options']['floating_button'] ?? array(),
'gcm' => $this->settings['pressidium_options']['gcm'] ?? array(),
)
);
}
Expand Down Expand Up @@ -195,11 +197,19 @@ private function print_inline_style(): void {

<style id="pressidium-cc-styles">
.pressidium-cc-theme {
<?php
foreach ( $this->settings['pressidium_options']['colors'] as $key => $value ) {
echo "--cc-{$key}: {$value};\n";
}
?>
<?php
$font_slug = $this->settings['pressidium_options']['font']['slug'];
$font_family = $this->settings['pressidium_options']['font']['family'];

if ( $font_slug !== 'default' ) {
echo "--cc-font-family: {$font_family};\n";
}

foreach ( $this->settings['pressidium_options']['colors'] as $key => $value ) {
$value = esc_attr( $value );
echo "--cc-{$key}: {$value};\n";
}
?>
}
</style>

Expand Down
48 changes: 48 additions & 0 deletions includes/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,49 @@ private function migrate_1_4_0(): void {
$this->settings['pressidium_options']['gcm'] = $gcm;
}

/**
* Migrate settings coming from versions prior to 1.5.0.
*
* @return void
*/
private function migrate_1_5_0(): void {
// Hide empty categories
$hide_empty_categories = $this->settings['pressidium_options']['hide_empty_categories'] ?? true;

$this->settings['pressidium_options']['hide_empty_categories'] = $hide_empty_categories;

// Font
$font = $this->settings['pressidium_options']['font'] ?? 'default';

$this->settings['pressidium_options']['font'] = $font;

// Floating button
$default_floating_button = array(
'enabled' => true,
'size' => 'sm',
'position' => 'left',
'icon' => 'pressidium',
'transition' => 'fade-in-up',
);

$floating_button = $this->settings['pressidium_options']['floating_button'] ?? $default_floating_button;

$this->settings['pressidium_options']['floating_button'] = $floating_button;

// Floating button colors
$colors = $this->settings['pressidium_options']['colors'] ?? array();

$btn_bg = $colors['btn-floating-bg'] ?? $colors['btn-primary-bg'];
$btn_icon = $colors['btn-floating-icon'] ?? $colors['btn-primary-text'];
$btn_hover_bg = $colors['btn-floating-hover-bg'] ?? $colors['btn-primary-hover-bg'];
$btn_hover_icon = $colors['btn-floating-hover-icon'] ?? $colors['btn-primary-hover-text'];

$this->settings['pressidium_options']['colors']['btn-floating-bg'] = $btn_bg;
$this->settings['pressidium_options']['colors']['btn-floating-icon'] = $btn_icon;
$this->settings['pressidium_options']['colors']['btn-floating-hover-bg'] = $btn_hover_bg;
$this->settings['pressidium_options']['colors']['btn-floating-hover-icon'] = $btn_hover_icon;
}

/**
* Migrate settings if necessary.
*
Expand Down Expand Up @@ -164,6 +207,11 @@ public function maybe_migrate(): array {
$this->migrate_1_4_0();
}

if ( version_compare( $this->settings['version'], '1.5.0', '<' ) ) {
// We are upgrading from a version prior to 1.5.0, so we need to migrate the settings
$this->migrate_1_5_0();
}

return $this->settings;
}

Expand Down
17 changes: 17 additions & 0 deletions includes/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ private function get_default_values(): array {
'preferences' => array(),
),
'blocked_scripts' => array(),
'font' => array(
'name' => 'Default',
'slug' => 'default',
'family' => '',
),
'floating_button' => array(
'enabled' => false,
'size' => 'sm',
'position' => 'left',
'icon' => 'pressidium',
'transition' => 'fade-in-up',
),
'colors' => array(
'bg' => '#f9faff',
'text' => '#112954',
Expand All @@ -186,8 +198,13 @@ private function get_default_values(): array {
'overlay-bg' => 'rgba(230, 235, 255, .85)',
'webkit-scrollbar-bg' => '#ebeff9',
'webkit-scrollbar-bg-hover' => '#3859d0',
'btn-floating-bg' => '#3859d0',
'btn-floating-icon' => '#f9faff',
'btn-floating-hover-bg' => '#1d2e38',
'btn-floating-hover-icon' => '#f9faff',
),
'record_consents' => true,
'hide_empty_categories' => true,
'gcm' => array(
'enabled' => false,
'implementation' => 'gtag',
Expand Down
Loading

0 comments on commit 9921872

Please sign in to comment.