register_owned_keys(); } /** * Returns keys for owned settings. * * @since 1.30.0 * * @return array An array of keys for owned settings. */ public function get_owned_keys() { return array( // TODO: These can be uncommented when Analytics and Analytics 4 modules are officially separated. /* 'accountID', */ // phpcs:ignore Squiz.PHP.CommentedOutCode.Found /* 'adsConversionID', */ // phpcs:ignore Squiz.PHP.CommentedOutCode.Found 'propertyID', 'webDataStreamID', 'measurementID', 'googleTagID', 'googleTagAccountID', 'googleTagContainerID', ); } /** * Gets the default value. * * @since 1.30.0 * * @return array */ protected function get_default() { return array( 'ownerID' => 0, // TODO: These can be uncommented when Analytics and Analytics 4 modules are officially separated. /* 'accountID' => '', */ // phpcs:ignore Squiz.PHP.CommentedOutCode.Found /* 'adsConversionID' => '', */ // phpcs:ignore Squiz.PHP.CommentedOutCode.Found 'propertyID' => '', 'webDataStreamID' => '', 'measurementID' => '', 'useSnippet' => true, 'googleTagID' => '', 'googleTagAccountID' => '', 'googleTagContainerID' => '', ); } /** * Gets the callback for sanitizing the setting's value before saving. * * @since 1.30.0 * * @return callable|null */ protected function get_sanitize_callback() { return function( $option ) { if ( is_array( $option ) ) { if ( isset( $option['useSnippet'] ) ) { $option['useSnippet'] = (bool) $option['useSnippet']; } if ( isset( $option['googleTagID'] ) ) { if ( ! preg_match( '/^(G|GT|AW)-[a-zA-Z0-9]+$/', $option['googleTagID'] ) ) { $option['googleTagID'] = ''; } } } return $option; }; } }