action_tracker = $action_tracker; $this->capability_helper = $capability_helper; $this->options_helper = $options_helper; } /** * Returns the needed conditionals. * * @return array The conditionals that must be met to load this. */ public static function get_conditionals(): array { return [ Admin_Conditional::class, ]; } /** * Registers action hook. * * @return void */ public function register_hooks(): void { \add_action( 'admin_init', [ $this, 'store_version_on_page_load' ] ); } /** * Stores the current version for the tracking option taken from the URL. * * @return void */ public function store_version_on_page_load() { if ( ! isset( $_GET['wpseo_tracked_action'] ) || ! \is_string( $_GET['wpseo_tracked_action'] ) ) { return; } if ( $this->capability_helper->current_user_can( 'wpseo_manage_options' ) !== true ) { return; } if ( ! isset( $_GET['wpseo_tracking_nonce'] ) || ! \wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_GET['wpseo_tracking_nonce'] ) ), 'wpseo_tracking_nonce' ) ) { return; } $action_to_track = \sanitize_text_field( \wp_unslash( $_GET['wpseo_tracked_action'] ) ); // Verify that the option to store is one of our tracking options. if ( ! \in_array( $action_to_track, $this->options_helper->get_tracking_only_options(), true ) ) { return; } $this->action_tracker->track_version_for_performed_action( $action_to_track ); } }