'; \woocommerce_wp_text_input( [ 'id' => '_google_title', 'label' => __( 'Google title (Shopping)', '3dl-product-feed-for-google' ), 'desc_tip' => true, 'description' => __( 'Optional title used only in the Google feed. Leave blank to use the regular product title.', '3dl-product-feed-for-google' ), ] ); echo ''; } public static function save_product_field( int $post_id ): void { if ( ! isset( $_POST['_google_title'] ) ) { return; } $value = self::sanitize_text( $_POST['_google_title'] ); if ( $value === '' ) { \delete_post_meta( $post_id, '_google_title' ); return; } \update_post_meta( $post_id, '_google_title', $value ); } public static function render_variation_field( int $loop, array $variation_data, \WP_Post $variation ): void { \woocommerce_wp_text_input( [ 'id' => '_google_title_variation[' . $loop . ']', 'name' => '_google_title_variation[' . $loop . ']', 'value' => (string) \get_post_meta( $variation->ID, '_google_title_variation', true ), 'label' => __( 'Google title (Shopping)', '3dl-product-feed-for-google' ), 'desc_tip' => true, 'description' => __( 'Optional title used only in the Google feed for this variation. Leave blank to use the product Google title or the regular title.', '3dl-product-feed-for-google' ), 'wrapper_class' => 'form-row form-row-full', ] ); } public static function save_variation_field( int $variation_id, int $i ): void { if ( ! isset( $_POST['_google_title_variation'][ $i ] ) ) { return; } $value = self::sanitize_text( $_POST['_google_title_variation'][ $i ] ); if ( $value === '' ) { \delete_post_meta( $variation_id, '_google_title_variation' ); return; } \update_post_meta( $variation_id, '_google_title_variation', $value ); } private static function sanitize_text( $value ): string { return \sanitize_text_field( \wp_unslash( (string) $value ) ); } }