Skip to content

Instantly share code, notes, and snippets.

@soderlind
Last active May 25, 2023 09:53
Show Gist options
  • Save soderlind/6d6735baeab379b4d7e1e5497cd8581b to your computer and use it in GitHub Desktop.
Save soderlind/6d6735baeab379b4d7e1e5497cd8581b to your computer and use it in GitHub Desktop.
Fix for Plausible Analytics %2f removal from shard link
<?php
/**
* Plugin Name: Plausible 2f Fix
* Description: Fix for Plausible Analytics %2f removal from shard link.
* Plugin URI: https://gist.github.com/soderlind/6d6735baeab379b4d7e1e5497cd8581b
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
declare( strict_types = 1 );
if ( ! defined( 'ABSPATH' ) ) {
wp_die();
}
add_action(
'plausible_analytics_settings_saved',
function() {
$plausible_analytics_settings = \filter_input( \INPUT_POST, 'plausible_analytics_settings', \FILTER_DEFAULT, \FILTER_REQUIRE_ARRAY );
if ( ! empty( $plausible_analytics_settings['shared_link'] ) ) {
$shared_link = \wp_unslash( $plausible_analytics_settings['shared_link'] );
$settings = \get_option( 'plausible_analytics_settings' );
$settings['shared_link'] = $shared_link;
\update_option( 'plausible_analytics_settings', $settings );
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment