add_attachment.php
1 month ago
admin_head.php
1 month ago
admin_init.php
1 month ago
admin_menu.php
1 month ago
admin_notices.php
1 month ago
attachment_updated.php
1 month ago
delete_post.php
1 month ago
pmxi_after_xml_import.php
1 month ago
pmxi_before_xml_import.php
1 month ago
pmxi_extend_options_custom_fields.php
1 month ago
wp_ajax_auto_detect_cf.php
1 month ago
wp_ajax_auto_detect_sf.php
1 month ago
wp_ajax_delete_import.php
1 month ago
wp_ajax_dismiss_notifications.php
1 month ago
wp_ajax_import_failed.php
1 month ago
wp_ajax_test_images.php
1 month ago
wp_ajax_wpai_dismiss_review_modal.php
1 month ago
wp_ajax_wpai_send_feedback.php
1 month ago
wpmu_new_blog.php
1 month ago
wp_ajax_auto_detect_sf.php
62 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | function pmxi_wp_ajax_auto_detect_sf(){ |
| 4 | |
| 5 | if ( ! check_ajax_referer( 'wp_all_import_secure', 'security', false )){ |
| 6 | exit( json_encode(array('result' => array(), 'msg' => __('Security check', 'wp-all-import'))) ); |
| 7 | } |
| 8 | |
| 9 | if ( ! current_user_can( PMXI_Plugin::$capabilities ) ){ |
| 10 | exit( json_encode(array('result' => array(), 'msg' => __('Security check', 'wp-all-import'))) ); |
| 11 | } |
| 12 | |
| 13 | $input = new PMXI_Input(); |
| 14 | $fieldName = $input->post('name', ''); |
| 15 | $post_type = $input->post('post_type', 'post'); |
| 16 | global $wpdb; |
| 17 | |
| 18 | $result = array(); |
| 19 | |
| 20 | if ($fieldName) { |
| 21 | |
| 22 | switch ($post_type){ |
| 23 | case 'import_users': |
| 24 | case 'shop_customer': |
| 25 | // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching |
| 26 | $values = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT usermeta.meta_value FROM {$wpdb->usermeta} as usermeta WHERE usermeta.meta_key = %s", $fieldName), ARRAY_A); |
| 27 | // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching |
| 28 | break; |
| 29 | case 'taxonomies': |
| 30 | // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching |
| 31 | $values = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT termmeta.meta_value FROM {$wpdb->termmeta} as termmeta WHERE termmeta.meta_key = %s", $fieldName), ARRAY_A); |
| 32 | // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching |
| 33 | break; |
| 34 | default: |
| 35 | // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching |
| 36 | $values = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT postmeta.meta_value FROM {$wpdb->postmeta} as postmeta WHERE postmeta.meta_key = %s", $fieldName), ARRAY_A); |
| 37 | // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching |
| 38 | break; |
| 39 | } |
| 40 | |
| 41 | if ( ! empty($values) ){ |
| 42 | foreach ($values as $key => $value) { |
| 43 | if ( ! empty($value['meta_value']) and is_serialized($value['meta_value'])){ |
| 44 | $v = \pmxi_maybe_unserialize($value['meta_value']); |
| 45 | if ( ! empty($v) and is_array($v) ){ |
| 46 | foreach ($v as $skey => $svalue) { |
| 47 | $result[] = array( |
| 48 | 'key' => $skey, |
| 49 | 'val' => maybe_serialize($svalue), |
| 50 | ); |
| 51 | } |
| 52 | break; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | } |
| 59 | |
| 60 | exit( json_encode(array('result' => $result)) ); |
| 61 | |
| 62 | } |