__( 'Post', 'airwpsync' ), 'slug' => 'post', ); } protected function get_mapping_fields() { return array( array( 'value' => 'post_title', 'label' => __( 'Title', 'airwpsync' ), 'enabled' => true, ), array( 'value' => 'post_content', 'label' => __( 'Content', 'airwpsync' ), 'enabled' => true, ), array( 'value' => 'post_excerpt', 'label' => __( 'Excerpt', 'airwpsync' ), 'enabled' => true, ), array( 'value' => 'post_name', 'label' => __( 'Slug', 'airwpsync' ), 'enabled' => true, ), array( 'value' => 'post_date', 'label' => __( 'Publication Date', 'airwpsync' ), 'enabled' => true, ), ); } public function add_to_post_data( $post_data, $importer, $fields ) { $mapped_fields = $this->get_my_mapping( $importer, $fields ); foreach ( $mapped_fields as $mapped_field ) { $value = $fields[ $mapped_field['airtable'] ] ?? ''; if ( in_array( $mapped_field['wordpress'], array( 'post_title', 'post_name', ), true ) ) { $value = wp_strip_all_tags( $value ); } if ( 'post_date' === $mapped_field['wordpress'] && ! empty( $value ) && false === strtotime( $value ) ) { throw new Exception( __( 'The Airtable field mapped to the publication date seems invalid.', 'airwpsync' ) ); } $post_data[ $mapped_field['wordpress'] ] = $value; } return $post_data; } } new Air_WP_Sync_Post_Destination();