PluginProbe ʕ •ᴥ•ʔ
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets / 4.1.1
WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets v4.1.1
4.1.1 3.9.5 3.9.6 4.0.0 4.0.1 4.1.0 trunk 2.12 2.13 2.14 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9 3.7.0 3.7.1 3.7.2 3.7.3 3.7.3-beta-1.0 3.7.4 3.7.4-beta-1.0 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4
wp-all-import / addon-api / fields / post.php
wp-all-import / addon-api / fields Last commit date
checkbox.php 1 month ago date.php 1 month ago datetime.php 1 month ago field.php 1 month ago gallery.php 1 month ago map.php 1 month ago media-url.php 1 month ago media.php 1 month ago number.php 1 month ago post.php 1 month ago radio.php 1 month ago repeater.php 1 month ago select.php 1 month ago switcher.php 1 month ago text.php 1 month ago time.php 1 month ago toggle.php 1 month ago user.php 1 month ago
post.php
67 lines
1 <?php
2
3 namespace Wpai\AddonAPI;
4
5 if ( ! defined( 'ABSPATH' ) ) exit;
6
7 class PMXI_Addon_Post_Field extends PMXI_Addon_Field {
8
9 static $repeater_path = 'value';
10
11 public function parseDelimitedValues($value) {
12 $delimiter = $value['delim'] ?? ',';
13 $values = explode($delimiter, $value['value'] ?? '');
14 $values = array_filter($values);
15 $values = array_map('trim', $values);
16 return $values;
17 }
18
19 public function beforeImport($postId, $value, $data, $logger, $rawData) {
20 global $wpdb;
21
22 $post_ids = [];
23 $values = $this->parseDelimitedValues($value);
24 $post_types = $this->args['search_post_type'] ?? [$data['articleData']['post_type']];
25
26 if (empty($values)) {
27 return $post_ids;
28 }
29
30 foreach ($values as $ev) {
31 $relation = false;
32
33 if (ctype_digit($ev)) {
34 if (empty($post_types)) {
35 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- {$wpdb->posts} is an internal table name from $wpdb.
36 $relation = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d", $ev));
37 } else {
38 $placeholders = implode(',', array_fill(0, count($post_types), '%s'));
39 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- {$wpdb->posts} is an internal table name from $wpdb; $placeholders contains only %s tokens.
40 $relation = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d AND post_type IN ($placeholders)", array_merge([$ev], $post_types)));
41 }
42 }
43
44 if (empty($relation)) {
45 if (empty($post_types)) {
46 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- {$wpdb->posts} is an internal table name from $wpdb.
47 $relation = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type != %s AND ( post_title = %s OR post_name = %s )", 'revision', $ev, sanitize_title_for_query($ev)));
48 } else {
49 $placeholders = implode(',', array_fill(0, count($post_types), '%s'));
50 // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQLPlaceholders.ReplacementsWrongNumber -- {$wpdb->posts} is an internal table name from $wpdb; $placeholders contains only %s tokens.
51 $relation = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type IN ($placeholders) AND ( post_title = %s OR post_name = %s )", array_merge($post_types, [$ev, sanitize_title_for_query($ev)])));
52 }
53 }
54
55 if ($relation) {
56 $post_ids[] = (string) $relation->ID;
57 }
58 }
59
60 if (empty($this->multiple)) {
61 return array_shift($post_ids);
62 }
63
64 return $post_ids;
65 }
66 }
67