Inventory_Presser_WP_All_Import::detect_piped_options( int $post_id, string $meta_key, mixed $meta_value )

detect_piped_options


Description

If the value being saved to the meta key inventory_presser_options_array contains a pipe, split the string on pipe and add each option individually.


Parameters

$post_id

(int) (Required)

$meta_key

(string) (Required)

$meta_value

(mixed) (Required)


Return

(void)


Source

File: includes/integrations/class-wp-all-import.php

	public function detect_piped_options( $post_id, $meta_key, $meta_value ) {
		if ( ! class_exists( 'INVP' ) || INVP::POST_TYPE != get_post_type( $post_id ) ) {
			return;
		}

		if ( apply_filters( 'invp_prefix_meta_key', 'options_array' ) != $meta_key ) {
			return;
		}

		// Are there even pipes in the value?
		if ( false === strpos( $meta_value ?? '', '|' ) ) {
			return;
		}

		// Erase the current value
		delete_post_meta( $post_id, $meta_key );

		// Add each option individually, options_array is a multi-meta value
		foreach ( explode( '|', $meta_value ) as $option ) {
			add_post_meta( $post_id, $meta_key, $option );
		}
	}