Last active
May 25, 2023 09:53
-
-
Save soderlind/6d6735baeab379b4d7e1e5497cd8581b to your computer and use it in GitHub Desktop.
Fix for Plausible Analytics %2f removal from shard link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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