8889841cWeb_Tag.php000064400000003256150515453320006576 0ustar00get_method_proxy_once( 'render' ), 1 ); $this->do_init_tag_action(); } /** * Outputs the Optimize anti-flicker script tag. * * @since 1.39.0 */ protected function render() { $anti_flicker_script = sprintf( "(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date; h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')}; (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c; })(window,document.documentElement,'async-hide','dataLayer',4000, {'%s':true});", esc_js( $this->tag_id ) ); printf( "\n\n", esc_html__( 'Anti-flicker snippet added by Site Kit', 'google-site-kit' ) ); echo ''; BC_Functions::wp_print_inline_script_tag( $anti_flicker_script ); printf( "\n\n", esc_html__( 'End Anti-flicker snippet added by Site Kit', 'google-site-kit' ) ); } } Settings.php000064400000005200150515453320007055 0ustar00register_legacy_keys_migration( array( 'AMPExperimentJson' => 'ampExperimentJSON', 'ampExperimentJson' => 'ampExperimentJSON', 'optimize_id' => 'optimizeID', 'optimizeId' => 'optimizeID', ) ); $this->register_owned_keys(); add_filter( 'option_' . self::OPTION, function ( $option ) { // Migrate legacy values where this was saved as decoded JSON object. if ( is_array( $option ) && array_key_exists( 'ampExperimentJSON', $option ) && ! is_string( $option['ampExperimentJSON'] ) ) { if ( empty( $option['ampExperimentJSON'] ) ) { $option['ampExperimentJSON'] = ''; } else { $option['ampExperimentJSON'] = wp_json_encode( $option['ampExperimentJSON'] ); } } return $option; } ); } /** * Returns keys for owned settings. * * @since 1.16.0 * * @return array An array of keys for owned settings. */ public function get_owned_keys() { return array( 'optimizeID', ); } /** * Gets the default value. * * @since 1.2.0 * * @return array */ protected function get_default() { return array( 'ownerID' => 0, 'ampExperimentJSON' => '', 'optimizeID' => '', 'placeAntiFlickerSnippet' => false, ); } /** * Gets the callback for sanitizing the setting's value before saving. * * @since 1.39.0 * * @return callable|null */ protected function get_sanitize_callback() { return function( $option ) { if ( is_array( $option ) ) { if ( isset( $option['placeAntiFlickerSnippet'] ) ) { $option['placeAntiFlickerSnippet'] = (bool) $option['placeAntiFlickerSnippet']; } } return $option; }; } } Tag_Guard.php000064400000001660150515453320007120 0ustar00settings->get(); if ( ! isset( $settings['placeAntiFlickerSnippet'] ) ) { return false; } return $settings['placeAntiFlickerSnippet']; } }