'', 'token' => '', 'consent_gate' => false, 'skip_logged_in' => true, 'feed_url' => '' ); } /** * The bcn_ token inside a pasted ``, in either * attribute order; '' when no tag of ours is there. Input is already lower-cased. */ function promvia_token_from_meta_tag( $html ) { if ( ! preg_match_all( '/]*>/', (string) $html, $tags ) ) { return ''; } foreach ( $tags[0] as $tag ) { if ( ! preg_match( '/\bname\s*=\s*["\']?' . preg_quote( PROMVIA_META_NAME, '/' ) . '["\'\s>]/', $tag ) ) { continue; } if ( preg_match( '/\bcontent\s*=\s*["\']?(bcn_[0-9a-f]{32})\b/', $tag, $m ) ) { return $m[1]; } } return ''; } /** * Settings API sanitiser. Invalid id/token keep the previous value and raise a settings error; empty * strings clear. Checkboxes absent from the POST are false. */ function promvia_sanitize_settings( $input, $previous = null ) { $prev = is_array( $previous ) ? array_merge( promvia_default_settings(), $previous ) : promvia_default_settings(); if ( ! is_array( $input ) ) { return promvia_default_settings(); } $out = promvia_default_settings(); foreach ( array( 'site_id' => PROMVIA_SITE_ID_PATTERN, 'token' => PROMVIA_TOKEN_PATTERN ) as $key => $pattern ) { $raw = isset( $input[ $key ] ) ? strtolower( trim( (string) $input[ $key ] ) ) : ''; if ( '' === $raw ) { $out[ $key ] = ''; continue; } // Promvia's Sites card shows the whole tag; take the token out of our own tag only. if ( 'token' === $key && false !== strpos( $raw, ' $origin . '/snippet.js', 'attrs' => $attrs, 'gated' => $gated ); } /** * script_loader_tag for the pixel handle: adds the data attributes snippet.js reads, and when gated * makes the tag inert. Only the tag with a src is touched; the inline loader WordPress prints after it * (in the same $tag) is left alone. */ function promvia_pixel_loader_tag( $tag, array $pixel ) { return (string) preg_replace_callback( '/]*\bsrc=[^>]*)>/', function ( $m ) use ( $pixel ) { $rest = preg_replace( '/\s+type=(["\'])[^"\']*\1/', '', $m[1] ); return ''; }, (string) $tag, 1 ); } /** Byte-for-byte what Promvia's verifier scans for (ownership.ts verificationMetaTag). */ function promvia_meta_tag( $token ) { if ( '' === (string) $token ) { return ''; } return ''; } /** Why the "create an application password" button is hidden: WordPress refuses them over HTTP first. */ function promvia_app_passwords_blocked_reason( $is_ssl, $available_for_user ) { if ( ! $is_ssl ) { return 'http'; } if ( ! $available_for_user ) { return 'unavailable'; } return null; }