Skip to content

Commit

Permalink
Fix an issue with the host url
Browse files Browse the repository at this point in the history
  • Loading branch information
dseydel committed May 23, 2023
1 parent b22ec2e commit 8091223
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 19 deletions.
5 changes: 3 additions & 2 deletions inc/class-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static function deactivate() {
* @since 0.1.0
* @change 0.2.0 - Added option for ignoring admins.
* @change 0.3.0 - Fixed bug with ignore admins option.
* @change 0.4.1 - Fix bug with host url option.
*/
public function render_script() {
$options = Options::get_options();
Expand All @@ -61,8 +62,8 @@ public function render_script() {
if ( isset( $options['cache'] ) && $options['cache'] === 1 ) {
$umami_options .= 'data-cache="true" ';
}
if ( ! empty( $options['host_url'] ) ) {
$umami_options .= 'data-host="' . esc_url( $options['host_url'] ) . '" ';
if ( ! empty( $options['host_url'] ) && isset( $options['use_host_url'] ) && $options['use_host_url'] === 1 ) {
$umami_options .= 'data-host-url="' . esc_url( $options['host_url'] ) . '" ';
}

?>
Expand Down
1 change: 1 addition & 0 deletions inc/class-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static function get_options(): array {
'script_url' => '',
'host_url' => '',
'website_id' => '',
'use_host_url' => 0,
'ignore_admins' => 1,
'auto_track' => 1,
'do_not_track' => 1,
Expand Down
4 changes: 3 additions & 1 deletion inc/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function add_page() {
*
* @since 0.1.0
* @change 0.2.1
* @change 0.4.1 - Fix bug with host url option.
*
* @return array The validated data.
*/
Expand All @@ -108,8 +109,9 @@ public function validate_options( array $data ): array {
return array(
'enabled' => (int) ( $data['enabled'] ?? false ),
'script_url' => esc_url_raw( $data['script_url'] ),
'host_url' => esc_url_raw( $data['script_url'] ),
'website_id' => sanitize_text_field( $data['website_id'] ),
'host_url' => esc_url_raw( $data['host_url'] ),
'use_host_url' => (int) ( $data['use_host_url'] ?? false ),
'ignore_admins' => (int) ( $data['ignore_admins'] ?? false ),
'auto_track' => (int) ( $data['auto_track'] ?? false ),
'do_not_track' => (int) ( $data['do_not_track'] ?? false ),
Expand Down
42 changes: 31 additions & 11 deletions inc/templates/settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@
</td>
</tr>

<tr>
<th scope="row">
<?php esc_html_e( 'Host Url', 'integrate-umami' ); ?>
</th>
<td>
<input class="integrate-umami-url" type="url" name="umami_options[host_url]" id="integration_umami_host_url"
value="<?php echo esc_attr( $options['host_url'] ); ?>"/>
<p class="description"><?php esc_html_e( 'The url to your umami instanace', 'integrate-umami' ); ?></p>
</td>
</tr>

<tr>
<th scope="row">
<?php esc_html_e( 'Website ID', 'integrate-umami' ); ?>
Expand All @@ -64,6 +53,37 @@
<label class="toggle-label" for="advanced-options"><?php esc_html_e( 'Advanced Options', 'integrate-umami' ); ?></label>
<div class="content">
<table class="form-table">
<tr>
<th scope="row">
<?php esc_html_e( 'Host Url', 'integrate-umami' ); ?>
</th>
<td>
<input class="integrate-umami-url" type="url" name="umami_options[host_url]" id="integration_umami_host_url"
value="<?php echo esc_attr( $options['host_url'] ); ?>"/>
<?php
echo wp_kses(
__( 'The URL of the Umami instance <b>if it is different from the URL to the script.</b>', 'integrate-umami' ),
[
'b' => [],
]
);
?>
</td>
</tr>

<tr>
<th class="row">
<?php esc_html_e( 'Use Host Url', 'integrate-umami' ); ?>
</th>
<td>
<label for="integration_umami_use_host_url">
<input type="checkbox" name="umami_options[use_host_url]" id="integration_umami_use_host_url"
value="1" <?php checked( $options['use_host_url'] ); ?> />
<?php esc_html_e( 'Use Host Url as data target', 'integrate-umami' ); ?>
</label>
</td>
</tr>

<tr>
<th class="row">
<?php esc_html_e( 'Ignore Admins', 'integrate-umami' ); ?>
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**Tags:** analytics,umami <br>
**Requires at least:** 5.0 <br>
**Tested up to:** 6.2 <br>
**Stable tag:** 0.4.0 <br>
**Stable tag:** 0.4.1 <br>
**Requires PHP:** 7.0 <br>
**License:** GPLv2 or later <br>

Expand All @@ -16,6 +16,12 @@ Umami is a simple, fast, website analytics tool for those who care about privacy

## Changelog ##

- **0.4.1** - Host URL Issue <br>
<br>Fixed an issue with the host URL which could cause issues with the tracking.
<br>Moved the host URL option to the advanced section
<br>Thanks to @gioxx for reporting the issue
<br><br>

- **0.4.0** - Improve Settings Page <br> The settings page has been improved to be more user friendly.
<br>Fixed an issue with the options validation
<br><br>
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
=== Integrate Umami ===
Contributors: ancocodet
Tags: analytics,umami
Stable tag: 0.4.0
Stable tag: 0.4.1
Requires at least: 5.0
Tested up to: 6.2
Requires PHP: 7.0
Expand All @@ -18,6 +18,11 @@ Umami is a simple, fast, website analytics tool for those who care about privacy

Project and support maintained on github at [ancocodet/wp-umami](https://github.com/Ancocodet/wp-umami).

= 0.4.1 =
* Fixed an issue with the host URL which could cause issues with the tracking.
* Moved the host URL option to the advanced section
* Thanks to [@gioxx](https://github.com/gioxx) for reporting the issue

= 0.4.0 =

* Improved options page to be more user friendly
Expand Down
7 changes: 4 additions & 3 deletions wp-umami.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
/**
* Plugin Name: Integrate Umami
* Description: Integration for Umami Analytics
* Version: 0.4.0
* Version: 0.4.1
* Author: Ancocodet
* Author URI: https://ancozockt.de
* License: GPL
* Plugin URI: https://github.com/Ancocodet/wp-umami
* License: GPLv3 or later
* Text Domain: integrate-umami
*
* @package Integrate Umami
Expand All @@ -15,7 +16,7 @@

require plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';

define( 'INTEGRATE_UMAMI_VERSION', '0.4.0' );
define( 'INTEGRATE_UMAMI_VERSION', '0.4.1' );
define( 'INTEGRATE_UMAMI_BASE_FILE', __FILE__ );

/**
Expand Down

0 comments on commit 8091223

Please sign in to comment.