first commit
This commit is contained in:
40
wp-content/plugins/wp-all-import/helpers/backward.php
Normal file
40
wp-content/plugins/wp-all-import/helpers/backward.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Contains function which were introduced in late wordpress versions
|
||||
*/
|
||||
|
||||
if ( ! function_exists('is_network_admin')):
|
||||
/**
|
||||
* Whether the current request is for a network admin screen /wp-admin/network/
|
||||
*
|
||||
* Does not inform on whether the user is a network admin! Use capability checks to
|
||||
* tell if the user should be accessing a section or not.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @return bool True if inside WordPress network administration pages.
|
||||
*/
|
||||
function is_network_admin() {
|
||||
if ( defined( 'WP_NETWORK_ADMIN' ) )
|
||||
return WP_NETWORK_ADMIN;
|
||||
return false;
|
||||
}
|
||||
endif;
|
||||
|
||||
if ( ! function_exists('is_user_admin')):
|
||||
/**
|
||||
* Whether the current request is for a user admin screen /wp-admin/user/
|
||||
*
|
||||
* Does not inform on whether the user is an admin! Use capability checks to
|
||||
* tell if the user should be accessing a section or not.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @return bool True if inside WordPress user administration pages.
|
||||
*/
|
||||
function is_user_admin() {
|
||||
if ( defined( 'WP_USER_ADMIN' ) )
|
||||
return WP_USER_ADMIN;
|
||||
return false;
|
||||
}
|
||||
endif;
|
||||
484
wp-content/plugins/wp-all-import/helpers/functions.php
Normal file
484
wp-content/plugins/wp-all-import/helpers/functions.php
Normal file
@@ -0,0 +1,484 @@
|
||||
<?php
|
||||
if( !function_exists('wpai_wp_enqueue_code_editor')){
|
||||
function wpai_wp_enqueue_code_editor( $args ) {
|
||||
|
||||
// We need syntax highlighting to work in the plugin regardless of user setting.
|
||||
// Function matches https://developer.wordpress.org/reference/functions/wp_enqueue_code_editor/ otherwise.
|
||||
/*if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) {
|
||||
return false;
|
||||
}*/
|
||||
|
||||
$settings = wp_get_code_editor_settings( $args );
|
||||
|
||||
if ( empty( $settings ) || empty( $settings['codemirror'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'code-editor' );
|
||||
wp_enqueue_style( 'code-editor' );
|
||||
|
||||
if ( isset( $settings['codemirror']['mode'] ) ) {
|
||||
$mode = $settings['codemirror']['mode'];
|
||||
if ( is_string( $mode ) ) {
|
||||
$mode = array(
|
||||
'name' => $mode,
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $settings['codemirror']['lint'] ) ) {
|
||||
switch ( $mode['name'] ) {
|
||||
case 'css':
|
||||
case 'text/css':
|
||||
case 'text/x-scss':
|
||||
case 'text/x-less':
|
||||
wp_enqueue_script( 'csslint' );
|
||||
break;
|
||||
case 'htmlmixed':
|
||||
case 'text/html':
|
||||
case 'php':
|
||||
case 'application/x-httpd-php':
|
||||
case 'text/x-php':
|
||||
wp_enqueue_script( 'htmlhint' );
|
||||
wp_enqueue_script( 'csslint' );
|
||||
wp_enqueue_script( 'jshint' );
|
||||
if ( ! current_user_can( 'unfiltered_html' ) ) {
|
||||
wp_enqueue_script( 'htmlhint-kses' );
|
||||
}
|
||||
break;
|
||||
case 'javascript':
|
||||
case 'application/ecmascript':
|
||||
case 'application/json':
|
||||
case 'application/javascript':
|
||||
case 'application/ld+json':
|
||||
case 'text/typescript':
|
||||
case 'application/typescript':
|
||||
wp_enqueue_script( 'jshint' );
|
||||
wp_enqueue_script( 'jsonlint' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings ) ) );
|
||||
|
||||
/**
|
||||
* Fires when scripts and styles are enqueued for the code editor.
|
||||
*
|
||||
* @since 4.9.0
|
||||
*
|
||||
* @param array $settings Settings for the enqueued code editor.
|
||||
*/
|
||||
do_action( 'wp_enqueue_code_editor', $settings );
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('pmxi_if') ) {
|
||||
function pmxi_if( $left_condition, $operand, $right_condition, $then, $else = '' ) {
|
||||
$str = trim(implode(' ', array($left_condition, html_entity_decode($operand), $right_condition)));
|
||||
return (eval ("return ($str);")) ? $then : $else;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('is_empty') ) {
|
||||
function is_empty( $var ) {
|
||||
return empty($var);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('pmxi_human_filesize') ) {
|
||||
function pmxi_human_filesize($bytes, $decimals = 2) {
|
||||
$sz = 'BKMGTP';
|
||||
$factor = (int) floor((strlen($bytes) - 1) / 3);
|
||||
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . (isset($sz[$factor]) ? $sz[$factor] : '');
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('pmxi_get_remote_image_ext') ) {
|
||||
function pmxi_get_remote_image_ext( $filePath ) {
|
||||
$response = wp_remote_get($filePath);
|
||||
$headers = wp_remote_retrieve_headers( $response );
|
||||
$content_type = (!empty($headers['content-type'])) ? explode('/', $headers['content-type']) : false;
|
||||
if (!empty($content_type[1])){
|
||||
if (preg_match('%jpeg%i', $content_type[1])) return 'jpeg';
|
||||
if (preg_match('%jpg%i', $content_type[1])) return 'jpg';
|
||||
if (preg_match('%png%i', $content_type[1])) return 'png';
|
||||
if (preg_match('%gif%i', $content_type[1])) return 'gif';
|
||||
if (preg_match('%svg%i', $content_type[1])) return 'svg';
|
||||
if (preg_match('%webp%i', $content_type[1])) return 'webp';
|
||||
if (preg_match('%pdf%i', $content_type[1])) return 'pdf';
|
||||
return ($content_type[1] == "unknown") ? "" : $content_type[1];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('pmxi_getExtension') ) {
|
||||
function pmxi_getExtension( $str ){
|
||||
$i = strrpos($str,".");
|
||||
if (!$i) return "";
|
||||
$l = strlen($str) - $i;
|
||||
$ext = substr($str,$i+1,$l);
|
||||
return (strlen($ext) <= 4) ? $ext : "";
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('pmxi_getExtensionFromStr' ) ) {
|
||||
function pmxi_getExtensionFromStr( $str ) {
|
||||
$filetype = wp_check_filetype($str);
|
||||
if (empty($filetype['ext'])){
|
||||
$filetype = wp_check_filetype(strtok($str, "?"));
|
||||
}
|
||||
return ($filetype['ext'] == "unknown") ? "" : $filetype['ext'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('pmxi_convert_encoding')) {
|
||||
function pmxi_convert_encoding ( $source, $target_encoding = 'ASCII' ) {
|
||||
if ( function_exists('mb_detect_encoding') ) {
|
||||
// detect the character encoding of the incoming file
|
||||
$encoding = mb_detect_encoding( $source, "auto" );
|
||||
// escape all of the question marks so we can remove artifacts from
|
||||
// the unicode conversion process
|
||||
$target = str_replace( "?", "[question_mark]", $source );
|
||||
// convert the string to the target encoding
|
||||
$target = mb_convert_encoding( $target, $target_encoding, $encoding);
|
||||
// remove any question marks that have been introduced because of illegal characters
|
||||
$target = str_replace( "?", "", $target );
|
||||
// replace the token string "[question_mark]" with the symbol "?"
|
||||
$target = str_replace( "[question_mark]", "?", $target );
|
||||
return html_entity_decode($target, ENT_COMPAT, 'UTF-8');
|
||||
}
|
||||
return $source;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_get_remote_file_name') ) {
|
||||
function wp_all_import_get_remote_file_name( $filePath ) {
|
||||
$bn = wp_all_import_basename($filePath);
|
||||
$type = (preg_match('%\W(csv|txt|dat|psv)$%i', $bn)) ? 'csv' : false;
|
||||
if (!$type) $type = (preg_match('%\W(xml)$%i', $bn)) ? 'xml' : false;
|
||||
if (!$type) $type = (preg_match('%\W(zip)$%i', $bn)) || (preg_match('%\W(get_bundle)$%i', $bn) && strpos($bn, 'export_id') !== false && strpos($bn, 'security_token') !== false) ? 'zip' : false;
|
||||
if (!$type) $type = (preg_match('%\W(gz)$%i', $bn)) ? 'gz' : false;
|
||||
|
||||
if(!$type){
|
||||
$filePath = strtok($filePath, "?");
|
||||
$bn = wp_all_import_basename($filePath);
|
||||
$type = (preg_match('%\W(csv|txt|dat|psv)$%i', $bn)) ? 'csv' : false;
|
||||
if (!$type) $type = (preg_match('%\W(xml)$%i', $bn)) ? 'xml' : false;
|
||||
if (!$type) $type = (preg_match('%\W(zip)$%i', $bn)) ? 'zip' : false;
|
||||
if (!$type) $type = (preg_match('%\W(gz)$%i', $bn)) ? 'gz' : false;
|
||||
}
|
||||
return ($type) ? $type : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_translate_uri') ) {
|
||||
function wp_all_import_translate_uri($uri) {
|
||||
$parts = explode('/', $uri);
|
||||
for ($i = 1; $i < count($parts); $i++) {
|
||||
$parts[$i] = rawurlencode($parts[$i]);
|
||||
}
|
||||
return implode('/', $parts);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_cdata_filter') ) {
|
||||
function wp_all_import_cdata_filter($matches) {
|
||||
PMXI_Import_Record::$cdata[] = $matches[0];
|
||||
return '{{CPLACE_'. count(PMXI_Import_Record::$cdata) .'}}';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_amp_filter') ) {
|
||||
function wp_all_import_amp_filter($matches) {
|
||||
if (empty($matches[1]) && !empty($matches[0])) {
|
||||
return "&";
|
||||
}
|
||||
return in_array($matches[1], array("amp;", "lt;", "gt;")) ? "&" . $matches[1] : "&" . $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_isValidMd5') ) {
|
||||
function wp_all_import_isValidMd5($md5 ='') {
|
||||
return preg_match('/^[a-f0-9]{32}$/', $md5);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_get_relative_path') ) {
|
||||
function wp_all_import_get_relative_path($path){
|
||||
$uploads = wp_upload_dir();
|
||||
return str_replace($uploads['basedir'], '', $path);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_get_absolute_path') ) {
|
||||
function wp_all_import_get_absolute_path($path) {
|
||||
$uploads = wp_upload_dir();
|
||||
return ( strpos($path, $uploads['basedir']) === false and ! preg_match('%^https?://%i', $path)) ? $uploads['basedir'] . $path : $path;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_clear_xss') ) {
|
||||
function wp_all_import_clear_xss( $str ) {
|
||||
return stripslashes(esc_sql(htmlspecialchars(strip_tags($str))));
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_get_taxonomies') ) {
|
||||
function wp_all_import_get_taxonomies() {
|
||||
// get all taxonomies
|
||||
$taxonomies = get_taxonomies(FALSE, 'objects');
|
||||
$ignore = array('nav_menu', 'link_category');
|
||||
$r = array();
|
||||
// populate $r
|
||||
foreach ($taxonomies as $taxonomy) {
|
||||
if (in_array($taxonomy->name, $ignore)) {
|
||||
continue;
|
||||
}
|
||||
if ( ! empty($taxonomy->labels->name) && strpos($taxonomy->labels->name, "_") === false){
|
||||
$r[$taxonomy->name] = $taxonomy->labels->name;
|
||||
}
|
||||
else{
|
||||
$r[$taxonomy->name] = empty($taxonomy->labels->singular_name) ? $taxonomy->name : $taxonomy->labels->singular_name;
|
||||
}
|
||||
}
|
||||
asort($r, SORT_FLAG_CASE | SORT_STRING);
|
||||
// return
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_is_password_protected_feed') ) {
|
||||
function wp_all_import_is_password_protected_feed($url){
|
||||
$url_data = parse_url($url);
|
||||
return (!empty($url_data['user']) and !empty($url_data['pass'])) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_cmp_custom_types') ) {
|
||||
function wp_all_import_cmp_custom_types($a, $b) {
|
||||
return strcmp($a->labels->name, $b->labels->name);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_basename') ) {
|
||||
function wp_all_import_basename($file) {
|
||||
$a = explode('/', $file);
|
||||
return end($a);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_update_post_count') ) {
|
||||
function wp_all_import_update_post_count() {
|
||||
global $wpdb;
|
||||
update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ), false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_supported_image_types') ) {
|
||||
function wp_all_import_supported_image_types() {
|
||||
$supported_image_types = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP);
|
||||
if (defined('IMAGETYPE_WEBP')) {
|
||||
$supported_image_types[] = IMAGETYPE_WEBP;
|
||||
}
|
||||
return $supported_image_types;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists('wp_all_import_generate_functions_hash') ) {
|
||||
function wp_all_import_generate_functions_hash() {
|
||||
$uploads = wp_upload_dir();
|
||||
$functions_hash = false;
|
||||
$functions_file = $uploads['basedir'] . DIRECTORY_SEPARATOR . WP_ALL_IMPORT_UPLOADS_BASE_DIRECTORY . DIRECTORY_SEPARATOR . 'functions.php';
|
||||
if (@file_exists($functions_file)) {
|
||||
$functions_hash = hash_file('md5', $functions_file);
|
||||
// Check functions file from current theme.
|
||||
$theme_functions_file = get_template_directory() . '/functions.php';
|
||||
if (@file_exists($theme_functions_file)) {
|
||||
$functions_hash .= hash_file('md5', $theme_functions_file);
|
||||
}
|
||||
}
|
||||
return $functions_hash;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_all_import_is_update_custom_field')) {
|
||||
function wp_all_import_is_update_custom_field($meta_key, $options) {
|
||||
if ($options['update_all_data'] == 'yes') {
|
||||
return TRUE;
|
||||
}
|
||||
if (!$options['is_update_custom_fields']) {
|
||||
return FALSE;
|
||||
}
|
||||
if ($options['update_custom_fields_logic'] == "full_update") {
|
||||
return TRUE;
|
||||
}
|
||||
if ($options['update_custom_fields_logic'] == "only"
|
||||
&& !empty($options['custom_fields_list'])
|
||||
&& is_array($options['custom_fields_list'])
|
||||
&& in_array($meta_key, $options['custom_fields_list'])
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
if ($options['update_custom_fields_logic'] == "all_except"
|
||||
&& (empty($options['custom_fields_list']) || !in_array($meta_key, $options['custom_fields_list']))
|
||||
) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
if (!function_exists('wp_all_import_delete_missing_notice')) {
|
||||
function wp_all_import_delete_missing_notice( $options ) {
|
||||
|
||||
$options += PMXI_Plugin::get_default_import_options();
|
||||
|
||||
$notice = false;
|
||||
if (!empty($options['is_delete_missing'])) {
|
||||
|
||||
switch ($options['custom_type']){
|
||||
case 'taxonomies':
|
||||
$custom_type = get_taxonomy($options['taxonomy_type']);
|
||||
if (empty($custom_type)){
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('Taxonomy Terms', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('Taxonomy Term', 'wp_all_import_plugin');
|
||||
}
|
||||
break;
|
||||
case 'comments':
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('Comments', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('Comment', 'wp_all_import_plugin');
|
||||
break;
|
||||
case 'woo_reviews':
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('Reviews', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('Review', 'wp_all_import_plugin');
|
||||
break;
|
||||
default:
|
||||
$custom_type = get_post_type_object( $options['custom_type'] );
|
||||
break;
|
||||
}
|
||||
|
||||
if ($options['delete_missing_logic'] == 'all' && $options['delete_missing_action'] == 'keep' && !empty($options['is_change_post_status_of_removed'])) {
|
||||
if( !empty($options['is_send_removed_to_trash']) ) {
|
||||
$notice = sprintf( __( '<span class="important-warning">Warning</span>: Any %s not in your import file will be sent to the trash, even those not created by this import.' ), $custom_type->labels->name);
|
||||
}else{
|
||||
$notice = sprintf( __( '<span class="important-warning">Warning</span>: Any %s not in your import file will be marked as %s, even those not created by this import.' ), $custom_type->labels->name, $options['status_of_removed'] );
|
||||
}
|
||||
}
|
||||
if ($options['delete_missing_logic'] == 'import' && $options['delete_missing_action'] == 'keep' && !empty($options['is_send_removed_to_trash'])) {
|
||||
$notice = sprintf(__('<span class="important-warning">Warning</span>: %s created by this import and no longer present in the import file will be sent to the trash.'), $custom_type->labels->name);
|
||||
}
|
||||
if ($options['delete_missing_logic'] == 'import' && $options['delete_missing_action'] == 'keep' && !empty($options['is_change_post_status_of_removed'])) {
|
||||
if( !empty($options['is_send_removed_to_trash']) ) {
|
||||
$notice = sprintf( __( '<span class="important-warning">Warning</span>: %s created by this import and no longer present in the import file will be sent to the trash.' ), $custom_type->labels->name);
|
||||
}else{
|
||||
$notice = sprintf( __( '<span class="important-warning">Warning</span>: %s created by this import and no longer present in the import file will be marked as %s.' ), $custom_type->labels->name, $options['status_of_removed'] );
|
||||
}
|
||||
}
|
||||
if ($options['delete_missing_logic'] == 'import' && $options['delete_missing_action'] == 'remove') {
|
||||
$notice = sprintf(__('<span class="important-warning">Warning</span>: %s created by this import and no longer present in the import file will be <b>permanently deleted</b>.'), $custom_type->labels->name);
|
||||
}
|
||||
if ($options['delete_missing_logic'] == 'all' && $options['delete_missing_action'] == 'keep' && !empty($options['is_send_removed_to_trash'])) {
|
||||
$notice = sprintf(__('<span class="important-warning">Warning</span>: Any %s not in your import file will be sent to the trash when this import runs. This includes %s that weren\'t created by this import.'), $custom_type->labels->name, $custom_type->labels->name);
|
||||
}
|
||||
if ($options['delete_missing_logic'] == 'all' && $options['delete_missing_action'] == 'remove') {
|
||||
$notice = sprintf(__('<span class="important-warning">Warning</span>: Any %s not in your import file will be <b>permanently deleted</b>, even those not created by this import.'), $custom_type->labels->name);
|
||||
}
|
||||
}
|
||||
return $notice;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_all_import_custom_type_labels')) {
|
||||
function wp_all_import_custom_type_labels($post_type, $taxonomy_type = false) {
|
||||
switch ($post_type){
|
||||
case 'taxonomies':
|
||||
if (!empty($taxonomy_type)) {
|
||||
$tx = get_taxonomy($taxonomy_type);
|
||||
}
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->name = $post_type;
|
||||
$custom_type->label = empty($tx->labels->name) ? __('Taxonomy Terms', 'wp_all_import_plugin') : $tx->labels->name;
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = empty($tx->labels->name) ? __('Taxonomy Terms', 'wp_all_import_plugin') : $tx->labels->name;
|
||||
$custom_type->labels->singular_name = empty($tx->labels->singular_name) ? __('Taxonomy Term', 'wp_all_import_plugin') : $tx->labels->singular_name;
|
||||
break;
|
||||
case 'comments':
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->name = $post_type;
|
||||
$custom_type->label = __('Comments', 'wp_all_import_plugin');
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('Comments', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('Comment', 'wp_all_import_plugin');
|
||||
break;
|
||||
case 'woo_reviews':
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->name = $post_type;
|
||||
$custom_type->label = __('WooCommerce Reviews', 'wp_all_import_plugin');
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('WooCommerce Reviews', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('Review', 'wp_all_import_plugin');
|
||||
break;
|
||||
case 'import_users':
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->name = $post_type;
|
||||
$custom_type->label = __('Users', 'wp_all_import_plugin');
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('Users', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('User', 'wp_all_import_plugin');
|
||||
break;
|
||||
case 'gf_entries':
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->name = $post_type;
|
||||
$custom_type->label = __('Gravity Forms Entry', 'wp_all_import_plugin');
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('Gravity Forms Entry', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('Gravity Forms Entry', 'wp_all_import_plugin');
|
||||
break;
|
||||
case 'shop_customer':
|
||||
$custom_type = new stdClass();
|
||||
$custom_type->name = $post_type;
|
||||
$custom_type->label = __('WooCommerce Customers', 'wp_all_import_plugin');
|
||||
$custom_type->labels = new stdClass();
|
||||
$custom_type->labels->name = __('WooCommerce Customers', 'wp_all_import_plugin');
|
||||
$custom_type->labels->singular_name = __('WooCommerce Customer', 'wp_all_import_plugin');
|
||||
break;
|
||||
default:
|
||||
$custom_type = get_post_type_object( $post_type );
|
||||
break;
|
||||
}
|
||||
return $custom_type;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_all_import_get_product_id_by_sku')) {
|
||||
function wp_all_import_get_product_id_by_sku( $sku ) {
|
||||
global $wpdb;
|
||||
|
||||
// phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery
|
||||
$id = $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT posts.ID
|
||||
FROM {$wpdb->posts} as posts
|
||||
INNER JOIN {$wpdb->wc_product_meta_lookup} AS lookup ON posts.ID = lookup.product_id
|
||||
WHERE
|
||||
posts.post_type IN ( 'product', 'product_variation' )
|
||||
AND lookup.sku = %s
|
||||
LIMIT 1
|
||||
",
|
||||
$sku
|
||||
)
|
||||
);
|
||||
|
||||
return (int) apply_filters( 'wp_all_import_get_product_id_by_sku', $id, $sku );
|
||||
}
|
||||
}
|
||||
183
wp-content/plugins/wp-all-import/helpers/get_file_curl.php
Normal file
183
wp-content/plugins/wp-all-import/helpers/get_file_curl.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists('get_file_curl') ):
|
||||
|
||||
function get_file_curl($url, $fullpath, $to_variable = false, $iteration = false) {
|
||||
|
||||
if ( ! preg_match('%^(http|ftp)s?://%i', $url) ) return false;
|
||||
|
||||
$response = wp_remote_get($url);
|
||||
|
||||
if ( ! is_wp_error($response) and ( ! isset($response['response']['code']) or isset($response['response']['code']) and ! in_array($response['response']['code'], array(401, 403, 404))) )
|
||||
{
|
||||
$rawdata = wp_remote_retrieve_body( $response );
|
||||
|
||||
if (empty($rawdata))
|
||||
{
|
||||
$result = pmxi_curl_download($url, $fullpath, $to_variable);
|
||||
if ( ! $result and $iteration === false)
|
||||
{
|
||||
$new_url = wp_all_import_translate_uri($url);
|
||||
return ($new_url !== $url) ? get_file_curl($new_url, $fullpath, $to_variable, true) : $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( ! @file_put_contents($fullpath, $rawdata) )
|
||||
{
|
||||
$fp = fopen($fullpath,'w');
|
||||
fwrite($fp, $rawdata);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ( preg_match('%\W(svg)$%i', basename($fullpath)) or preg_match('%\W(jpg|jpeg|gif|png|webp)$%i', basename($fullpath)) and ( ! ($image_info = apply_filters('pmxi_getimagesize', @getimagesize($fullpath), $fullpath)) or ! in_array($image_info[2], wp_all_import_supported_image_types()) ) )
|
||||
{
|
||||
$result = pmxi_curl_download($url, $fullpath, $to_variable);
|
||||
if ( ! $result and $iteration === false)
|
||||
{
|
||||
$new_url = wp_all_import_translate_uri($url);
|
||||
return ($new_url !== $url) ? get_file_curl($new_url, $fullpath, $to_variable, true) : $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
return ($to_variable) ? $rawdata : true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$use_only_wp_http_api = apply_filters('wp_all_import_use_only_wp_http_api', false);
|
||||
|
||||
if ( false == $use_only_wp_http_api ){
|
||||
$curl = pmxi_curl_download($url, $fullpath, $to_variable);
|
||||
|
||||
if ($curl === false and $iteration === false)
|
||||
{
|
||||
$new_url = wp_all_import_translate_uri($url);
|
||||
return ($new_url !== $url) ? get_file_curl($new_url, $fullpath, $to_variable, true) : ( is_wp_error($response) ? $response : false );
|
||||
}
|
||||
|
||||
return ($curl === false) ? ( is_wp_error($response) ? $response : false ) : $curl;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
if ( ! function_exists('pmxi_curl_download') ) {
|
||||
|
||||
function pmxi_curl_download($url, $fullpath, $to_variable){
|
||||
|
||||
if ( ! function_exists('curl_version') ) return false;
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$rawdata = curl_exec_follow($ch);
|
||||
|
||||
$result = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
curl_close ($ch);
|
||||
|
||||
if ( empty($rawdata) ) return false;
|
||||
|
||||
if (!@file_put_contents($fullpath, $rawdata)){
|
||||
$fp = fopen($fullpath,'w');
|
||||
fwrite($fp, $rawdata);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
if ( preg_match('%\W(jpg|jpeg|gif|png|webp)$%i', basename($fullpath)) and ( ! ($image_info = apply_filters('pmxi_getimagesize', @getimagesize($fullpath), $fullpath)) or ! in_array($image_info[2], wp_all_import_supported_image_types()))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ($result == 200) ? (($to_variable) ? $rawdata : true) : false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( ! function_exists('curl_exec_follow') ):
|
||||
|
||||
function curl_exec_follow($ch, &$maxredirect = null) {
|
||||
|
||||
$mr = $maxredirect === null ? 5 : intval($maxredirect);
|
||||
|
||||
if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
|
||||
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $mr > 0);
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, $mr);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
} else {
|
||||
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||
|
||||
if ($mr > 0)
|
||||
{
|
||||
$original_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
||||
$newurl = $original_url;
|
||||
|
||||
$url_data = parse_url($newurl);
|
||||
|
||||
if (!empty($url_data['user']) and !empty($url_data['pass'])){
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY );
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $url_data['user']. ":" . $url_data['pass']);
|
||||
$newurl = $url_data['scheme'] . '://' . $url_data['host'];
|
||||
if (!empty($url_data['port'])){
|
||||
$newurl .= ':' . $url_data['port'];
|
||||
}
|
||||
$newurl .= $url_data['path'];
|
||||
if (!empty($url_data['query']))
|
||||
{
|
||||
$newurl .= '?' . $url_data['query'];
|
||||
}
|
||||
}
|
||||
|
||||
$rch = curl_copy_handle($ch);
|
||||
|
||||
curl_setopt($rch, CURLOPT_HEADER, true);
|
||||
curl_setopt($rch, CURLOPT_NOBODY, true);
|
||||
curl_setopt($rch, CURLOPT_FORBID_REUSE, false);
|
||||
|
||||
do
|
||||
{
|
||||
curl_setopt($rch, CURLOPT_URL, $newurl);
|
||||
$header = curl_exec($rch);
|
||||
if (curl_errno($rch)) {
|
||||
$code = 0;
|
||||
} else {
|
||||
$code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
|
||||
if ($code == 301 || $code == 302) {
|
||||
preg_match('/Location:(.*?)\n/', $header, $matches);
|
||||
$newurl = trim(array_pop($matches));
|
||||
|
||||
// if no scheme is present then the new url is a
|
||||
// relative path and thus needs some extra care
|
||||
if(!preg_match("/^https?:/i", $newurl)){
|
||||
$newurl = $original_url . $newurl;
|
||||
}
|
||||
} else {
|
||||
$code = 0;
|
||||
}
|
||||
}
|
||||
} while ($code && --$mr);
|
||||
|
||||
curl_close($rch);
|
||||
|
||||
if (!$mr)
|
||||
{
|
||||
if ($maxredirect !== null)
|
||||
$maxredirect = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_URL, $newurl);
|
||||
}
|
||||
}
|
||||
return curl_exec($ch);
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
if ( ! function_exists('get_taxonomies_by_object_type')):
|
||||
/**
|
||||
* get_taxnomies doesn't filter propery by object_type, so these function can be used when filtering by object type requied
|
||||
* @param string|array $object_type
|
||||
* @param string[optional] $output
|
||||
*/
|
||||
function get_taxonomies_by_object_type($object_type, $output = 'names') {
|
||||
global $wp_taxonomies;
|
||||
|
||||
is_array($object_type) or $object_type = array($object_type);
|
||||
$field = ('names' == $output) ? 'name' : false;
|
||||
$filtered = array();
|
||||
foreach ($wp_taxonomies as $key => $obj) {
|
||||
if (array_intersect($object_type, $obj->object_type)) {
|
||||
$filtered[$key] = $obj;
|
||||
}
|
||||
}
|
||||
if ($field) {
|
||||
$filtered = wp_list_pluck($filtered, $field);
|
||||
}
|
||||
return $filtered;
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
if (!function_exists('import_custom_meta_box')){
|
||||
function import_custom_meta_box($edit_post) {
|
||||
?>
|
||||
<div id="postcustomstuff">
|
||||
<table id="list-table">
|
||||
<tbody class="list:meta" id="the-list">
|
||||
<?php if (!empty(PMXI_Plugin::$session->data['pmxi_import']['options']['custom_name'])): foreach (PMXI_Plugin::$session->data['pmxi_import']['options']['custom_name'] as $i => $name): ?>
|
||||
<tr>
|
||||
<td class="left">
|
||||
<label class="screen-reader-text">Key</label>
|
||||
<input type="text" value="<?php echo esc_attr($name) ?>" name="custom_name[]" size="20">
|
||||
<div class="submit"><input type="submit" class="delete deletemeta" value="Delete"></div>
|
||||
</td>
|
||||
<td>
|
||||
<label class="screen-reader-text">Value</label>
|
||||
<textarea name="custom_value[]" rows="2" cols="30" class="widefat"><?php echo esc_html(PMXI_Plugin::$session->data['pmxi_import']['options']['custom_value'][$i]) ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php meta_form(); ?>
|
||||
</div>
|
||||
<p><?php _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.'); ?></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
if (!function_exists('is_exists_term')){
|
||||
|
||||
function is_exists_term( $term, $taxonomy = '', $parent = null ){
|
||||
|
||||
return apply_filters( 'wp_all_import_term_exists', term_exists( $term, $taxonomy, $parent ), $taxonomy, $term, $parent );
|
||||
|
||||
}
|
||||
}
|
||||
191
wp-content/plugins/wp-all-import/helpers/pmxi_findDuplicates.php
Normal file
191
wp-content/plugins/wp-all-import/helpers/pmxi_findDuplicates.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Find duplicates according to settings
|
||||
*/
|
||||
function pmxi_findDuplicates($articleData, $custom_duplicate_name = '', $custom_duplicate_value = '', $duplicate_indicator = 'title', $indicator_value = '') {
|
||||
|
||||
global $wpdb;
|
||||
|
||||
if ('custom field' == $duplicate_indicator) {
|
||||
$duplicate_ids = [];
|
||||
if (!empty($articleData['post_type'])) {
|
||||
switch ($articleData['post_type']) {
|
||||
case 'taxonomies':
|
||||
$args = [
|
||||
'hide_empty' => FALSE,
|
||||
// also retrieve terms which are not used yet
|
||||
'meta_query' => [
|
||||
[
|
||||
'key' => $custom_duplicate_name,
|
||||
'value' => $custom_duplicate_value,
|
||||
'compare' => '='
|
||||
]
|
||||
]
|
||||
];
|
||||
$terms = get_terms($articleData['taxonomy'], $args);
|
||||
if (!empty($terms) && !is_wp_error($terms)) {
|
||||
foreach ($terms as $term) {
|
||||
$duplicate_ids[] = $term->term_id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'woo_reviews':
|
||||
case 'comments':
|
||||
$args = [
|
||||
'hide_empty' => FALSE,
|
||||
// also retrieve terms which are not used yet
|
||||
'meta_query' => [
|
||||
[
|
||||
'key' => $custom_duplicate_name,
|
||||
'value' => $custom_duplicate_value,
|
||||
'compare' => '='
|
||||
]
|
||||
]
|
||||
];
|
||||
$comments = get_comments($args);
|
||||
if (!empty($comments) && !is_wp_error($comments)) {
|
||||
foreach ($comments as $comment) {
|
||||
$duplicate_ids[] = $comment->comment_ID;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$post_types = (class_exists('PMWI_Plugin') and $articleData['post_type'] == 'product') ? [
|
||||
'product',
|
||||
'product_variation'
|
||||
] : [$articleData['post_type']];
|
||||
|
||||
// We should search for the product ID to update using the native WooCommerce function.
|
||||
if (trim($custom_duplicate_name) == '_sku' && function_exists('wp_all_import_get_product_id_by_sku')) {
|
||||
$id = wp_all_import_get_product_id_by_sku(trim($custom_duplicate_value));
|
||||
} else {
|
||||
$id = $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT posts.ID
|
||||
FROM {$wpdb->posts} as posts
|
||||
INNER JOIN {$wpdb->postmeta} AS lookup ON posts.ID = lookup.post_id
|
||||
WHERE
|
||||
posts.post_type IN ( '" . implode("','", $post_types) . "' )
|
||||
AND lookup.meta_key = %s
|
||||
AND lookup.meta_value = %s
|
||||
LIMIT 1
|
||||
",
|
||||
trim($custom_duplicate_name),
|
||||
trim($custom_duplicate_value)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$duplicate_ids[] = $id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$args = [
|
||||
'meta_query' => [
|
||||
0 => [
|
||||
'key' => $custom_duplicate_name,
|
||||
'value' => $custom_duplicate_value,
|
||||
'compare' => '='
|
||||
]
|
||||
]
|
||||
];
|
||||
$user_query = new WP_User_Query($args);
|
||||
|
||||
if (!empty($user_query->results)) {
|
||||
foreach ($user_query->results as $user) {
|
||||
$duplicate_ids[] = $user->ID;
|
||||
}
|
||||
} else {
|
||||
$query = $wpdb->get_results($wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS " . $wpdb->users . ".ID FROM " . $wpdb->users . " INNER JOIN " . $wpdb->usermeta . " ON (" . $wpdb->users . ".ID = " . $wpdb->usermeta . ".user_id) WHERE 1=1 AND ( (" . $wpdb->usermeta . ".meta_key = '%s' AND " . $wpdb->usermeta . ".meta_value = '%s') ) GROUP BY " . $wpdb->users . ".ID ORDER BY " . $wpdb->users . ".ID ASC LIMIT 0, 20", $custom_duplicate_name, $custom_duplicate_value));
|
||||
if (!empty($query)) {
|
||||
foreach ($query as $p) {
|
||||
$duplicate_ids[] = $p->ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $duplicate_ids;
|
||||
} elseif ('parent' == $duplicate_indicator) {
|
||||
$field = 'post_title'; // post_title or post_content
|
||||
return $wpdb->get_col($wpdb->prepare("
|
||||
SELECT ID FROM " . $wpdb->posts . "
|
||||
WHERE
|
||||
post_type = %s
|
||||
AND ID != %s
|
||||
AND post_parent = %s
|
||||
AND REPLACE(REPLACE(REPLACE($field, ' ', ''), '\\t', ''), '\\n', '') = %s
|
||||
",
|
||||
$articleData['post_type'],
|
||||
isset($articleData['ID']) ? $articleData['ID'] : 0,
|
||||
(!empty($articleData['post_parent'])) ? $articleData['post_parent'] : 0,
|
||||
preg_replace('%[ \\t\\n]%', '', $articleData[$field])
|
||||
));
|
||||
} else {
|
||||
if (!empty($articleData['post_type'])) {
|
||||
switch ($articleData['post_type']) {
|
||||
case 'taxonomies':
|
||||
$field = $duplicate_indicator == 'title' ? 'name' : 'slug';
|
||||
if (empty($indicator_value)) {
|
||||
$indicator_value = $duplicate_indicator == 'title' ? $articleData['post_title'] : $articleData['slug'];
|
||||
}
|
||||
return $wpdb->get_col($wpdb->prepare("
|
||||
SELECT t.term_id FROM " . $wpdb->terms . " t
|
||||
INNER JOIN " . $wpdb->term_taxonomy . " tt ON (t.term_id = tt.term_id)
|
||||
WHERE
|
||||
t.term_id != %s
|
||||
AND tt.taxonomy LIKE %s
|
||||
AND (REPLACE(REPLACE(REPLACE(t." . $field . ", ' ', ''), '\\t', ''), '\\n', '') = %s
|
||||
OR REPLACE(REPLACE(REPLACE(t." . $field . ", ' ', ''), '\\t', ''), '\\n', '') = %s
|
||||
OR REPLACE(REPLACE(REPLACE(t." . $field . ", ' ', ''), '\\t', ''), '\\n', '') = %s)
|
||||
",
|
||||
isset($articleData['ID']) ? $articleData['ID'] : 0,
|
||||
isset($articleData['taxonomy']) ? $articleData['taxonomy'] : '%',
|
||||
preg_replace('%[ \\t\\n]%', '', esc_attr($indicator_value)),
|
||||
preg_replace('%[ \\t\\n]%', '', htmlentities($indicator_value)),
|
||||
preg_replace('%[ \\t\\n]%', '', $indicator_value)
|
||||
));
|
||||
break;
|
||||
case 'comments':
|
||||
$field = 'comment_' . $duplicate_indicator; // post_title or post_content
|
||||
return $wpdb->get_col($wpdb->prepare("
|
||||
SELECT comment_ID FROM " . $wpdb->comments . "
|
||||
WHERE
|
||||
AND comment_ID != %s
|
||||
AND REPLACE(REPLACE(REPLACE($field, ' ', ''), '\\t', ''), '\\n', '') = %s
|
||||
",
|
||||
isset($articleData['ID']) ? $articleData['ID'] : 0,
|
||||
preg_replace('%[ \\t\\n]%', '', $articleData[$field])
|
||||
));
|
||||
break;
|
||||
default:
|
||||
$field = 'post_' . $duplicate_indicator; // post_title or post_content
|
||||
return $wpdb->get_col($wpdb->prepare("
|
||||
SELECT ID FROM " . $wpdb->posts . "
|
||||
WHERE
|
||||
post_type = %s
|
||||
AND ID != %s
|
||||
AND REPLACE(REPLACE(REPLACE($field, ' ', ''), '\\t', ''), '\\n', '') = %s
|
||||
",
|
||||
$articleData['post_type'],
|
||||
isset($articleData['ID']) ? $articleData['ID'] : 0,
|
||||
preg_replace('%[ \\t\\n]%', '', $articleData[$field])
|
||||
));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ($duplicate_indicator == 'title') {
|
||||
$field = 'user_login';
|
||||
$u = get_user_by('login', $articleData[$field]);
|
||||
return (!empty($u)) ? array($u->ID) : FALSE;
|
||||
} else {
|
||||
$field = 'user_email';
|
||||
$u = get_user_by('email', $articleData[$field]);
|
||||
return (!empty($u)) ? array($u->ID) : FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* Get parent category term ID
|
||||
*
|
||||
* @param $parent
|
||||
* @param $tx_name
|
||||
* @param $txes
|
||||
* @param $key
|
||||
* @return int
|
||||
*/
|
||||
function pmxi_recursion_taxes($parent, $tx_name, $txes, $key, $do_not_create_terms = 0){
|
||||
|
||||
if ( is_array($parent) ){
|
||||
|
||||
if ( empty($parent['parent']) ){
|
||||
|
||||
$term = is_exists_term($parent['name'], $tx_name, 0);
|
||||
|
||||
if ( empty($term) and !is_wp_error($term) ){
|
||||
|
||||
$term = is_exists_term(htmlspecialchars($parent['name']), $tx_name, 0);
|
||||
if ( empty($do_not_create_terms) && empty($term) && !is_wp_error($term) ){
|
||||
$term = wp_insert_term(
|
||||
$parent['name'], // the term
|
||||
$tx_name // the taxonomy
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return ( ! empty($term) and ! is_wp_error($term)) ? $term['term_id'] : 0;
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$parent_id = pmxi_recursion_taxes($parent['parent'], $tx_name, $txes, $key, $do_not_create_terms);
|
||||
|
||||
if (empty($parent['name'])) return $parent_id;
|
||||
|
||||
$term = is_exists_term($parent['name'], $tx_name, (int)$parent_id);
|
||||
|
||||
if ( empty($term) and !is_wp_error($term) ){
|
||||
|
||||
$term = is_exists_term(htmlspecialchars($parent['name']), $tx_name, (int)$parent_id);
|
||||
if ( empty($do_not_create_terms) && empty($term) && !is_wp_error($term) ){
|
||||
$term = wp_insert_term(
|
||||
$parent['name'], // the term
|
||||
$tx_name, // the taxonomy
|
||||
array('parent'=> (!empty($parent_id)) ? (int)$parent_id : 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
return ( ! empty($term) and ! is_wp_error($term)) ? $term['term_id'] : 0;
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if ( !empty($txes[$key - 1]) and !empty($txes[$key - 1]['parent']) and $parent != $txes[$key - 1]['parent']) {
|
||||
|
||||
$parent_id = pmxi_recursion_taxes($txes[$key - 1]['parent'], $tx_name, $txes, $key - 1, $do_not_create_terms);
|
||||
|
||||
$term = is_exists_term($parent, $tx_name, (int)$parent_id);
|
||||
|
||||
if ( empty($term) and ! is_wp_error($term) ){
|
||||
$term = is_exists_term(htmlspecialchars($parent), $tx_name, (int)$parent_id);
|
||||
if ( empty($do_not_create_terms) && empty($term) && !is_wp_error($term) ){
|
||||
$term = wp_insert_term(
|
||||
$parent, // the term
|
||||
$tx_name, // the taxonomy
|
||||
array('parent'=> (!empty($parent_id)) ? (int)$parent_id : 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return ( ! empty($term) and ! is_wp_error($term) ) ? $term['term_id'] : 0;
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
$term = is_exists_term($parent, $tx_name);
|
||||
if ( empty($term) and !is_wp_error($term) ){
|
||||
$term = is_exists_term(htmlspecialchars($parent), $tx_name);
|
||||
if ( empty($term) and !is_wp_error($term) ){
|
||||
$term = wp_insert_term(
|
||||
$parent, // the term
|
||||
$tx_name // the taxonomy
|
||||
);
|
||||
}
|
||||
}
|
||||
return ( ! empty($term) and ! is_wp_error($term)) ? $term['term_id'] : 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists('reverse_taxonomies_html') ) {
|
||||
|
||||
function reverse_taxonomies_html($post_taxonomies, $item_id, &$i, $ctx_name = '', $entry = ''){
|
||||
$childs = array();
|
||||
foreach ($post_taxonomies as $j => $cat) if ($cat->parent_id == $item_id and $cat->item_id != $item_id) { $childs[] = $cat; }
|
||||
|
||||
if (!empty($childs)){
|
||||
?>
|
||||
<ol>
|
||||
<?php
|
||||
foreach ($childs as $child_cat){
|
||||
$i++;
|
||||
?>
|
||||
<li id="item_<?php echo esc_attr($i); ?>" class="dragging">
|
||||
<div class="drag-element">
|
||||
<input type="hidden" class="assign_term" value="1" />
|
||||
<input class="widefat xpath_field" type="text" value="<?php echo esc_textarea($child_cat->xpath); ?>"/>
|
||||
<?php do_action('pmxi_category_view', $cat, $i, $ctx_name, $entry); ?>
|
||||
</div>
|
||||
<a href="javascript:void(0);" class="icon-item remove-ico"></a>
|
||||
<?php echo reverse_taxonomies_html($post_taxonomies, $child_cat->item_id, $i, $ctx_name, $entry); ?>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</ol>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
18
wp-content/plugins/wp-all-import/helpers/str_getcsv.php
Normal file
18
wp-content/plugins/wp-all-import/helpers/str_getcsv.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
if ( ! function_exists('str_getcsv')):
|
||||
/**
|
||||
* str_getcsv function for PHP less than 5.3
|
||||
* @see http://php.net/manual/en/function.str-getcsv.php
|
||||
* NOTE: function doesn't support escape paramter (in correspondance to fgetcsv not supporting it prior 5.3)
|
||||
*/
|
||||
function str_getcsv($input, $delimiter=',', $enclosure='"') {
|
||||
if ("" == $delimiter) $delimiter = ',';
|
||||
$temp = fopen("php://memory", "rw");
|
||||
fwrite($temp, $input);
|
||||
fseek($temp, 0);
|
||||
$r = fgetcsv($temp, strlen($input), $delimiter, $enclosure);
|
||||
fclose($temp);
|
||||
return $r;
|
||||
}
|
||||
|
||||
endif;
|
||||
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_addon_notifications') ){
|
||||
function wp_all_import_addon_notifications(){
|
||||
if ( ! empty($_GET['page']) and preg_match('%(pmxi-admin)%i', sanitize_key($_GET['page'])))
|
||||
{
|
||||
if ( ! function_exists( 'is_plugin_active' ) ) require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
|
||||
$current_theme = wp_get_theme();
|
||||
$parent_theme = $current_theme->parent();
|
||||
$theme_name = $current_theme->get('Name');
|
||||
$parent_theme_name = ($parent_theme) ? $parent_theme->get('Name') : '';
|
||||
|
||||
$current_themes = array($theme_name, $parent_theme_name);
|
||||
|
||||
$recommended_addons = array();
|
||||
|
||||
// Reales WP Add-On
|
||||
if ( in_array('Reales WP', $current_themes)
|
||||
and is_wp_error(validate_plugin('reales-wp-xml-csv-property-listings-import/reales-add-on.php')))
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'Reales WP',
|
||||
'url' => 'https://wordpress.org/plugins/reales-wp-xml-csv-property-listings-import/',
|
||||
);
|
||||
}
|
||||
// WooCommerce Add-On
|
||||
if ( is_plugin_active('woocommerce/woocommerce.php')
|
||||
and is_wp_error(validate_plugin('woocommerce-xml-csv-product-import/plugin.php'))
|
||||
and is_wp_error(validate_plugin('wpai-woocommerce-add-on/wpai-woocommerce-add-on.php')) )
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'WooCommerce',
|
||||
'url' => 'https://wordpress.org/plugins/woocommerce-xml-csv-product-import/'
|
||||
);
|
||||
}
|
||||
// WP Job Manager Add-On
|
||||
if ( is_plugin_active('wp-job-manager/wp-job-manager.php')
|
||||
and is_wp_error(validate_plugin('wp-job-manager-xml-csv-listings-import/wp-job-manager-add-on.php'))
|
||||
and ! in_array('Listify', $current_themes)
|
||||
and ! in_array('Jobify', $current_themes)
|
||||
and ! in_array('Listable', $current_themes)
|
||||
and ! in_array('My Listing', $current_themes) )
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'WP Job Manager',
|
||||
'url' => 'https://wordpress.org/plugins/wp-job-manager-xml-csv-listings-import/'
|
||||
);
|
||||
}
|
||||
// WP Residence Add-On
|
||||
if ( is_wp_error(validate_plugin('wp-residence-add-on-for-wp-all-import/wp-residence-add-on.php'))
|
||||
and (preg_match('%(WP Residence)%i', $theme_name) or preg_match('%(WP Residence)%i', $parent_theme_name)) )
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'WP Residence',
|
||||
'url' => 'https://wordpress.org/plugins/wp-residence-add-on-for-wp-all-import/'
|
||||
);
|
||||
}
|
||||
// Realia Add-On
|
||||
if ( is_wp_error(validate_plugin('realia-xml-csv-property-listings-import/realia-add-on.php'))
|
||||
and (in_array('Realia', $current_themes) or is_plugin_active('realia/realia.php')) )
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'Realia',
|
||||
'url' => 'https://wordpress.org/plugins/realia-xml-csv-property-listings-import/'
|
||||
);
|
||||
}
|
||||
// Listify Add-On
|
||||
if ( in_array('Listify', $current_themes)
|
||||
and is_wp_error(validate_plugin('listify-xml-csv-listings-import/listify-add-on.php')))
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'Listify',
|
||||
'url' => 'https://wordpress.org/plugins/listify-xml-csv-listings-import/'
|
||||
);
|
||||
}
|
||||
// RealHomes Add-On
|
||||
if ( in_array('RealHomes Theme', $current_themes)
|
||||
and is_wp_error(validate_plugin('realhomes-xml-csv-property-listings-import/realhomes-add-on.php')))
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'RealHomes',
|
||||
'url' => 'https://wordpress.org/plugins/realhomes-xml-csv-property-listings-import/'
|
||||
);
|
||||
}
|
||||
// Jobify Add-On
|
||||
if ( in_array('Jobify', $current_themes)
|
||||
and is_wp_error(validate_plugin('jobify-xml-csv-listings-import/jobify-add-on.php')))
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'Jobify',
|
||||
'url' => 'https://wordpress.org/plugins/jobify-xml-csv-listings-import/'
|
||||
);
|
||||
}
|
||||
// Listable Add-On
|
||||
if ( in_array('Listable', $current_themes)
|
||||
and is_wp_error(validate_plugin('import-xml-csv-listings-to-listable-theme/listable-add-on.php')))
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'Listable',
|
||||
'url' => 'https://wordpress.org/plugins/import-xml-csv-listings-to-listable-theme/'
|
||||
);
|
||||
}
|
||||
// Yoast SEO Add-On
|
||||
if ( is_plugin_active('wordpress-seo/wp-seo.php')
|
||||
and is_wp_error(validate_plugin('yoast-seo-settings-xml-csv-import/yoast-addon.php')))
|
||||
{
|
||||
$recommended_addons[] = array(
|
||||
'title' => 'Yoast SEO',
|
||||
'url' => 'https://wordpress.org/plugins/yoast-seo-settings-xml-csv-import/'
|
||||
);
|
||||
}
|
||||
// ACF Add-On
|
||||
if ( is_plugin_active('advanced-custom-fields-pro/acf.php')
|
||||
and is_wp_error(validate_plugin('wpai-acf-add-on/wpai-acf-add-on.php')))
|
||||
{
|
||||
if ( ! get_option('acf_addon_notice_ignore')) {
|
||||
?>
|
||||
<div class="updated notice is-dismissible wpallimport-dismissible" rel="acf_addon"><p>
|
||||
<?php
|
||||
printf(
|
||||
__('Make imports easier with the <strong>Advanced Custom Fields Add-On</strong> for WP All Import: <a href="%s" target="_blank">Read More</a>', 'wp_all_import_plugin'),
|
||||
'http://www.wpallimport.com/advanced-custom-fields/'
|
||||
);
|
||||
?>
|
||||
</p></div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
// WP All Export
|
||||
if ( is_wp_error(validate_plugin('wp-all-export-pro/wp-all-export-pro.php')) and is_wp_error(validate_plugin('wp-all-export/wp-all-export.php')) )
|
||||
{
|
||||
if ( ! get_option('wp_all_export_notice_ignore')) {
|
||||
?>
|
||||
<!--div class="wpallimport-wrapper updated notice is-dismissible wpallimport-dismissible" rel="wp_all_export" style="margin: 10px 0; padding: 12px 0;">
|
||||
<div class="wpallimport-notify-wrapper">
|
||||
<div class="found_records speedup" style="margin-top: 20px;">
|
||||
<h3 style="font-size:26px;"><?php _e('WP All Export', 'wp_all_import_plugin');?></h3>
|
||||
<h4><?php _e("Export anything in WordPress to CSV, XML, or Excel.", "wp_all_import_plugin"); ?></h4>
|
||||
</div>
|
||||
</div>
|
||||
<a class="button button-primary button-hero wpallimport-large-button wpallimport-wpae-notify-read-more" href="http://www.wpallimport.com/export" target="_blank"><?php _e('Read More', 'wp_all_import_plugin');?></a>
|
||||
</div-->
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty($recommended_addons))
|
||||
{
|
||||
foreach ($recommended_addons as $addon) {
|
||||
if ( ! get_option(sanitize_key($addon['title']) . '_notice_ignore')) {
|
||||
?>
|
||||
<div class="updated notice is-dismissible wpallimport-dismissible" rel="<?php echo sanitize_key(esc_attr($addon['title'])); ?>"><p>
|
||||
<?php printf(
|
||||
__('Make imports easier with the <strong>free %s Add-On</strong> for WP All Import: <a href="%s" target="_blank">Get Add-On</a>', 'wp_all_import_plugin'),
|
||||
wp_kses_post($addon['title']),
|
||||
esc_url($addon['url'])
|
||||
);
|
||||
?>
|
||||
</p></div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
if( !function_exists('wp_all_import_base64_decode_image')){
|
||||
function wp_all_import_base64_decode_image( $image ){
|
||||
// Only check the base64 portion of image references.
|
||||
$matches = [];
|
||||
preg_match('@(data:image/.{1,6};base64,)(.*)@', $image, $matches);
|
||||
|
||||
// Set image to only the base64 encoded portion if detected.
|
||||
$image = isset($matches[2]) ? $matches[2] : $image;
|
||||
|
||||
return base64_decode($image);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_clear_directory') ){
|
||||
function wp_all_import_clear_directory($path){
|
||||
if (($dir = @opendir($path . '/')) !== false or ($dir = @opendir($path)) !== false) {
|
||||
while(($file = @readdir($dir)) !== false) {
|
||||
$filePath = $path . '/' . $file;
|
||||
if ( is_dir($filePath) && ( ! in_array($file, array('.', '..'))) ){
|
||||
wp_all_import_rmdir($filePath);
|
||||
}
|
||||
elseif( is_file($filePath) ){
|
||||
@unlink($filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists('wp_all_import_ctx_mapping')){
|
||||
function wp_all_import_ctx_mapping( $ctx, $mapping_rules, $tx_name ){
|
||||
if ( ! empty( $mapping_rules) and $ctx['is_mapping']){
|
||||
foreach ($mapping_rules as $rule) {
|
||||
foreach ($rule as $key => $value) {
|
||||
// Modify the values used to check if something should be mapped by checking the name and key with both being lowercase
|
||||
$mappingCheckName = $ctx["name"];
|
||||
$mappingCheckKey = $key;
|
||||
$mappingCheckLowercase = apply_filters("wpai_is_case_insensitive_taxonomy_mapping", false, $tx_name);
|
||||
if ($mappingCheckLowercase) {
|
||||
$mappingCheckName = strtolower($mappingCheckName);
|
||||
$mappingCheckKey = strtolower($mappingCheckKey);
|
||||
}
|
||||
if ( trim($mappingCheckName) == trim($mappingCheckKey) || str_replace("&", "&", trim($mappingCheckName)) == str_replace("&", "&", trim($mappingCheckKey)) ){
|
||||
$ctx['name'] = trim($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return apply_filters('pmxi_single_category', $ctx, $tx_name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
if( !function_exists('wp_all_import_filter_html_kses')){
|
||||
function wp_all_import_filter_html_kses($html, $context = 'post'){
|
||||
return wp_kses($html, $context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists('wp_all_import_get_feed_type')){
|
||||
function wp_all_import_get_feed_type($url){
|
||||
|
||||
$type = wp_all_import_get_remote_file_name($url);
|
||||
|
||||
if ($type !== false) {
|
||||
|
||||
return array(
|
||||
'Content-Type' => $type,
|
||||
'Content-Encoding' => false
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$headers = @get_headers($url, 1);
|
||||
|
||||
if (empty($headers)){
|
||||
$response = wp_remote_get($url);
|
||||
$headers = wp_remote_retrieve_headers( $response );
|
||||
}
|
||||
|
||||
$extensions = array('gzip', 'gz', 'xml', 'csv', 'json', 'sql');
|
||||
$type = false;
|
||||
|
||||
$contentType = ( ! empty($headers['Content-Type']) ) ? $headers['Content-Type'] : false;
|
||||
if ($contentType === false)
|
||||
$contentType = ( ! empty($headers['content-type']) ) ? $headers['content-type'] : false;
|
||||
|
||||
if ( ! empty($contentType)){
|
||||
if (is_array($contentType)){
|
||||
foreach ($contentType as $key => $ct) {
|
||||
foreach ($extensions as $ext) {
|
||||
if (strpos($ct, $ext) !== false) {
|
||||
$type = $ext;
|
||||
break(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
foreach ($extensions as $ext) {
|
||||
if (strpos($contentType, $ext) !== false){
|
||||
$type = $ext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! empty($headers['Content-Disposition'])){
|
||||
foreach ($extensions as $ext) {
|
||||
if (strpos($headers['Content-Disposition'], $ext) !== false) {
|
||||
$type = $ext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'Content-Type' => $type,
|
||||
'Content-Encoding' => (!empty($headers['Content-Encoding'])) ? $headers['Content-Encoding'] : false,
|
||||
'Content-Disposition' => (!empty($headers['Content-Disposition'])) ? $headers['Content-Disposition'] : false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_get_gz')){
|
||||
|
||||
function wp_all_import_get_gz($filename, $use_include_path = 0, $targetDir = false, $headers = false) {
|
||||
|
||||
$type = 'csv';
|
||||
if (!empty($headers['Content-Type']) && preg_match('%(csv|xml|json|sql|txt|xls|xlsx)$%i', $headers['Content-Type'])) {
|
||||
$type = $headers['Content-Type'];
|
||||
}
|
||||
|
||||
$uploads = wp_upload_dir();
|
||||
$targetDir = ( ! $targetDir ) ? wp_all_import_secure_file($uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::UPLOADS_DIRECTORY ) : $targetDir;
|
||||
|
||||
$tmpname = wp_unique_filename($targetDir, (strlen(basename($filename)) < 30) ? basename($filename) : time() );
|
||||
$localPath = $targetDir .'/'. urldecode(sanitize_file_name($tmpname));
|
||||
|
||||
$fp = @fopen($localPath, 'w');
|
||||
$file = @gzopen($filename, 'rb', $use_include_path);
|
||||
|
||||
if ($file) {
|
||||
$first_chunk = true;
|
||||
while (!gzeof($file)) {
|
||||
$chunk = gzread($file, 1024);
|
||||
if ($first_chunk and strpos($chunk, "<?") !== false and strpos($chunk, "</") !== false) {
|
||||
$type = 'xml';
|
||||
$first_chunk = false;
|
||||
$chunk = substr($chunk, strpos($chunk, "<?"));
|
||||
} // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
||||
@fwrite($fp, $chunk);
|
||||
}
|
||||
gzclose($file);
|
||||
}
|
||||
else{
|
||||
|
||||
$tmpname = wp_unique_filename($targetDir, (strlen(basename($filename)) < 30) ? basename($filename) : time() );
|
||||
$localGZpath = $targetDir .'/'. urldecode(sanitize_file_name($tmpname));
|
||||
$request = get_file_curl($filename, $localGZpath, false, true);
|
||||
|
||||
if ( ! is_wp_error($request) ){
|
||||
|
||||
$file = @gzopen($localGZpath, 'rb', $use_include_path);
|
||||
|
||||
if ($file) {
|
||||
$first_chunk = true;
|
||||
while (!gzeof($file)) {
|
||||
$chunk = gzread($file, 1024);
|
||||
if ($first_chunk and strpos($chunk, "<?") !== false and strpos($chunk, "</") !== false) {
|
||||
$type = 'xml';
|
||||
$first_chunk = false;
|
||||
$chunk = substr($chunk, strpos($chunk, "<?"));
|
||||
} // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
||||
@fwrite($fp, $chunk);
|
||||
}
|
||||
gzclose($file);
|
||||
}
|
||||
|
||||
@unlink($localGZpath);
|
||||
|
||||
}
|
||||
else return $request;
|
||||
|
||||
}
|
||||
@fclose($fp);
|
||||
|
||||
if (strpos($headers['Content-Disposition'], 'tar.gz') !== false && class_exists('PharData'))
|
||||
{
|
||||
rename($localPath, $localPath . '.tar');
|
||||
$phar = new PharData($localPath . '.tar');
|
||||
$phar->extractTo($targetDir);
|
||||
@unlink($localPath . '.tar');
|
||||
|
||||
$scanned_files = @scandir($targetDir);
|
||||
if (!empty($scanned_files) and is_array($scanned_files)){
|
||||
$files = array_diff($scanned_files, array('.','..'));
|
||||
if (!empty($files)){
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('%\W(csv|xml|json|sql|txt|xls|xlsx)$%i', basename($file)))
|
||||
{
|
||||
$localPath = $targetDir . DIRECTORY_SEPARATOR . $file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('%\W(gz)$%i', basename($localPath))){
|
||||
if (@rename($localPath, str_replace('.gz', '.' . $type, $localPath)))
|
||||
$localPath = str_replace('.gz', '.' . $type, $localPath);
|
||||
}
|
||||
else{
|
||||
if (@rename($localPath, $localPath . '.' . $type))
|
||||
$localPath = $localPath . '.' . $type;
|
||||
}
|
||||
|
||||
return array('type' => $type, 'localPath' => $localPath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
function wp_all_import_get_image_from_gallery($image_name, $targetDir = FALSE, $bundle_type = 'images', $logger = false) {
|
||||
|
||||
$search_image_by_wp_attached_file = apply_filters('wp_all_import_search_image_by_wp_attached_file', true);
|
||||
if (!$search_image_by_wp_attached_file){
|
||||
return false;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$original_image_name = $image_name;
|
||||
|
||||
if (!$targetDir) {
|
||||
$wp_uploads = wp_upload_dir();
|
||||
$targetDir = $wp_uploads['path'];
|
||||
}
|
||||
|
||||
// Prepare scaled image file name.
|
||||
$scaled_name = $image_name;
|
||||
$rotated_name = $image_name;
|
||||
$ext = pmxi_getExtension($image_name);
|
||||
if ($ext) {
|
||||
$scaled_name = str_replace('.' . $ext, '-scaled.' . $ext, $image_name);
|
||||
$rotated_name = str_replace('.' . $ext, '-rotated.' . $ext, $image_name);
|
||||
}
|
||||
|
||||
$attch = '';
|
||||
|
||||
// search attachment by attached file
|
||||
$attachment_metas = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->postmeta . " WHERE meta_key = %s AND (meta_value = %s OR meta_value = %s OR meta_value = %s OR meta_value LIKE %s ESCAPE '$' OR meta_value LIKE %s ESCAPE '$' OR meta_value LIKE %s ESCAPE '$');", '_wp_attached_file', $image_name, $scaled_name, $rotated_name, "%/" . str_replace('_', '$_', $image_name), "%/" . str_replace('_', '$_', $scaled_name), "%/" . str_replace('_', '$_', $rotated_name)));
|
||||
|
||||
if (!empty($attachment_metas)) {
|
||||
foreach ($attachment_metas as $attachment_meta) {
|
||||
$attch = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE ID = %d;", $attachment_meta->post_id));
|
||||
if (!empty($attch)) {
|
||||
$logger and call_user_func($logger, sprintf(__('- Found existing image with ID `%s` by meta key _wp_attached_file equals to `%s`...', 'wp_all_import_plugin'), $attch->ID, trim($image_name)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($attch)) {
|
||||
$attachment_metas = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->postmeta . " WHERE meta_key = %s AND (meta_value = %s OR meta_value = %s OR meta_value = %s OR meta_value LIKE %s ESCAPE '$' OR meta_value LIKE %s ESCAPE '$' OR meta_value LIKE %s ESCAPE '$');", '_wp_attached_file', sanitize_file_name($image_name), sanitize_file_name($scaled_name), sanitize_file_name($rotated_name), "%/" . str_replace('_', '$_', sanitize_file_name($image_name)), "%/" . str_replace('_', '$_', sanitize_file_name($scaled_name)), "%/" . str_replace('_', '$_', sanitize_file_name($rotated_name))));
|
||||
|
||||
if (!empty($attachment_metas)) {
|
||||
foreach ($attachment_metas as $attachment_meta) {
|
||||
$attch = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE ID = %d;", $attachment_meta->post_id));
|
||||
if (!empty($attch)) {
|
||||
$logger and call_user_func($logger, sprintf(__('- Found existing image with ID `%s` by meta key _wp_attached_file equals to `%s`...', 'wp_all_import_plugin'), $attch->ID, sanitize_file_name($image_name)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($attch)) {
|
||||
// Search attachment by file name with extension.
|
||||
$attch = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE (post_title = %s OR post_name = %s) AND post_type = %s", $image_name, sanitize_title($image_name), "attachment") . " AND post_mime_type LIKE 'image%';");
|
||||
if (!empty($attch)) {
|
||||
$logger and call_user_func($logger, sprintf(__('- Found existing image with ID `%s` by post_title or post_name equals to `%s`...', 'wp_all_import_plugin'), $attch->ID, $image_name));
|
||||
}
|
||||
}
|
||||
|
||||
// Search attachment by file headers.
|
||||
if (empty($attch) and @file_exists($targetDir . DIRECTORY_SEPARATOR . $original_image_name)) {
|
||||
if ( ! function_exists('wp_read_image_metadata') ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/image.php' );
|
||||
}
|
||||
if ($bundle_type == 'images' and ($img_meta = wp_read_image_metadata($targetDir . DIRECTORY_SEPARATOR . $original_image_name))) {
|
||||
if (trim($img_meta['title']) && !is_numeric(sanitize_title($img_meta['title']))) {
|
||||
$img_title = $img_meta['title'];
|
||||
$attch = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->posts . " WHERE post_title = %s AND post_type = %s AND post_mime_type LIKE %s;", $img_title, "attachment", "image%"));
|
||||
if (!empty($attch)){
|
||||
$logger and call_user_func($logger, sprintf(__('- Found existing image with ID `%s` by post_title equals to `%s`...', 'wp_all_import_plugin'), $attch->ID, $img_title));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters('wp_all_import_get_image_from_gallery', $attch, $original_image_name, $targetDir);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'wp_all_import_get_import_id' ) ) {
|
||||
function wp_all_import_get_import_id() {
|
||||
global $argv;
|
||||
$import_id = 'new';
|
||||
|
||||
if ( ! empty( $argv ) ) {
|
||||
|
||||
// First check for the ID set by the WP_CLI code.
|
||||
$temp_id = apply_filters('wp_all_import_cli_import_id', false);
|
||||
|
||||
if($temp_id !== false && is_numeric($temp_id)){
|
||||
$import_id = $temp_id;
|
||||
}else {
|
||||
|
||||
// Try to get the ID from the CLI arguments if it's not found otherwise.
|
||||
$import_id_arr = array_filter( $argv, function( $a ) {
|
||||
return ( is_numeric( $a ) ) ? true : false;
|
||||
});
|
||||
|
||||
if ( ! empty( $import_id_arr ) ) {
|
||||
$import_id = reset( $import_id_arr );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $import_id == 'new' ) {
|
||||
if ( isset( $_GET['import_id'] ) ) {
|
||||
$import_id = intval($_GET['import_id']);
|
||||
} elseif ( isset( $_GET['id'] ) ) {
|
||||
$import_id = intval($_GET['id']);
|
||||
}
|
||||
}
|
||||
|
||||
return $import_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
if ( ! function_exists( 'wp_all_import_get_import_post_type' ) ) {
|
||||
function wp_all_import_get_import_post_type( $import_id = 'new' ) {
|
||||
$custom_type = false;
|
||||
// Declaring $wpdb as global to access database
|
||||
global $wpdb;
|
||||
if ( $import_id == 'new' ) {
|
||||
// Attempt to get import ID
|
||||
$import_id = wp_all_import_get_import_id();
|
||||
}
|
||||
|
||||
// Get values from import data table
|
||||
$imports_table = $wpdb->prefix . 'pmxi_imports';
|
||||
|
||||
// Get import session from database based on import ID or 'new'
|
||||
$import_options = $wpdb->get_row( $wpdb->prepare("SELECT options FROM $imports_table WHERE id = %d", $import_id), ARRAY_A );
|
||||
|
||||
// If this is an existing import load the custom post type from the array
|
||||
if ( ! empty($import_options) ) {
|
||||
$import_options_arr = unserialize($import_options['options']);
|
||||
$custom_type = $import_options_arr['custom_type'];
|
||||
} else {
|
||||
// If this is a new import get the custom post type data from the current session
|
||||
$import_options = $wpdb->get_row( $wpdb->prepare("SELECT option_name, option_value FROM $wpdb->options WHERE option_name = %s", '_wpallimport_session_' . $import_id . '_'), ARRAY_A );
|
||||
$import_options_arr = empty($import_options) ? array() : unserialize($import_options['option_value']);
|
||||
$custom_type = empty($import_options_arr['custom_type']) ? '' : $import_options_arr['custom_type'];
|
||||
}
|
||||
return $custom_type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'wp_all_import_get_page_by_title' ) ) {
|
||||
|
||||
function wp_all_import_get_page_by_title( $title, $post_type = 'page' ) {
|
||||
|
||||
$posts = get_posts(
|
||||
array(
|
||||
'post_type' => $post_type,
|
||||
'title' => $title,
|
||||
'post_status' => 'all',
|
||||
'numberposts' => 1,
|
||||
'update_post_term_cache' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
'orderby' => 'post_date ID',
|
||||
'order' => 'ASC',
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $posts ) ) {
|
||||
$page = $posts[0];
|
||||
} else {
|
||||
$page = null;
|
||||
}
|
||||
|
||||
return $page;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
function wp_all_import_get_parent_post($identity, $post_type, $import_type = 'post') {
|
||||
$page = 0;
|
||||
|
||||
if ( empty( $identity ) ) {
|
||||
return $page;
|
||||
}
|
||||
|
||||
switch ($import_type) {
|
||||
case 'post':
|
||||
if ( ! empty($identity) ){
|
||||
if (ctype_digit($identity)){
|
||||
$page = get_post($identity);
|
||||
}
|
||||
else
|
||||
{
|
||||
$page = wp_all_import_get_page_by_title($identity, $post_type) or $page = get_page_by_path($identity, OBJECT, $post_type);
|
||||
|
||||
if ( empty($page) ){
|
||||
$args = array(
|
||||
'name' => $identity,
|
||||
'post_type' => $post_type,
|
||||
'post_status' => 'any',
|
||||
'numberposts' => 1
|
||||
);
|
||||
$my_posts = get_posts($args);
|
||||
if ( $my_posts ) {
|
||||
$page = $my_posts[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'page':
|
||||
$page = wp_all_import_get_page_by_title($identity) or $page = get_page_by_path($identity) or ctype_digit($identity) and $page = get_post($identity);
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
return (!empty($page)) ? (int) $page->ID : 0;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
function wp_all_import_get_parent_terms( $term_id, $taxonomy ){
|
||||
|
||||
$ids = array();
|
||||
|
||||
// start from the current term
|
||||
$parent = get_term_by( 'id', $term_id, $taxonomy );
|
||||
|
||||
// climb up the hierarchy until we reach a term with parent = '0'
|
||||
while ( (int) $parent->parent != 0 ){
|
||||
|
||||
$term_id = $parent->parent;
|
||||
|
||||
$parent = get_term_by( 'id', $term_id, $taxonomy);
|
||||
|
||||
$ids[] = $parent->term_taxonomy_id;
|
||||
|
||||
}
|
||||
|
||||
return $ids;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists('wp_all_import_get_reader_engine')){
|
||||
|
||||
function wp_all_import_get_reader_engine( $local_paths, $post, $import_id = 0 ) {
|
||||
|
||||
$xml_reader_engine = 'xmlreader';
|
||||
|
||||
$is_auto_detect_xml_reader = apply_filters( 'wp_all_import_auto_detect_reader_engine', true );
|
||||
|
||||
// auto detect xml reader engine disabled
|
||||
if ( $is_auto_detect_xml_reader === false )
|
||||
{
|
||||
update_option('wpai_parser_type', 'xmlreader', false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$root_element = '';
|
||||
|
||||
// auto-detect XML reader engine
|
||||
foreach ($local_paths as $key => $path) {
|
||||
|
||||
if ( @file_exists($path) ){
|
||||
|
||||
$file = new PMXI_Chunk( $path, array('element' => $post['root_element']), 'xmlreader' );
|
||||
|
||||
$xmlreader_count = 0;
|
||||
|
||||
if ( ! empty($file->options['element']) ) {
|
||||
|
||||
$root_element = $file->options['element'];
|
||||
|
||||
$xpath = "/" . $file->options['element'];
|
||||
|
||||
$start_time = time();
|
||||
|
||||
// loop through the file until all lines are read
|
||||
while ($xml = $file->read()) {
|
||||
|
||||
if ( ! empty($xml) )
|
||||
{
|
||||
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "\n" . $xml;
|
||||
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$old = libxml_use_internal_errors(true);
|
||||
$dom->loadXML($xml);
|
||||
libxml_use_internal_errors($old);
|
||||
$dxpath = new DOMXPath($dom);
|
||||
|
||||
if (($elements = @$dxpath->query($xpath)) and $elements->length){
|
||||
$xmlreader_count += $elements->length;
|
||||
unset($dom, $dxpath, $elements);
|
||||
}
|
||||
}
|
||||
|
||||
$execution_time = time() - $start_time;
|
||||
|
||||
// if stream reader takes longer than 30 seconds just stop using it
|
||||
// if ( $execution_time > 30 ) {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
unset($file);
|
||||
|
||||
// count element using xml streamer
|
||||
|
||||
if ( ! empty($post['root_element'])) $root_element = $post['root_element'];
|
||||
|
||||
$file = new PMXI_Chunk( $path, array('element' => $root_element), 'xmlstreamer' );
|
||||
|
||||
$xmlstreamer_count = 0;
|
||||
|
||||
if ( ! empty($file->options['element']) ) {
|
||||
|
||||
$xpath = "/" . $file->options['element'];
|
||||
|
||||
$start_time = time();
|
||||
|
||||
// loop through the file until all lines are read
|
||||
while ($xml = $file->read()) {
|
||||
|
||||
if ( ! empty($xml) )
|
||||
{
|
||||
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "\n" . $xml;
|
||||
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$old = libxml_use_internal_errors(true);
|
||||
$dom->loadXML($xml);
|
||||
libxml_use_internal_errors($old);
|
||||
$dxpath = new DOMXPath($dom);
|
||||
|
||||
if (($elements = @$dxpath->query($xpath)) and $elements->length){
|
||||
$xmlstreamer_count += $elements->length;
|
||||
unset($dom, $dxpath, $elements);
|
||||
}
|
||||
}
|
||||
|
||||
$execution_time = time() - $start_time;
|
||||
|
||||
// if stream reader takes longer than 30 seconds just stop using it
|
||||
// if ( $execution_time > 30 ) {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
unset($file);
|
||||
|
||||
$xml_reader_engine = ($xmlreader_count >= $xmlstreamer_count) ? 'xmlreader' : 'xmlstreamer';
|
||||
|
||||
update_option('wpai_parser_type', $xml_reader_engine, false);
|
||||
}
|
||||
}
|
||||
|
||||
return $root_element;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Reading large files from remote server
|
||||
* @ $filePath - file URL
|
||||
* return local path of copied file
|
||||
*/
|
||||
|
||||
if (!function_exists('wp_all_import_get_url')) {
|
||||
|
||||
function wp_all_import_get_url($filePath, $targetDir = FALSE, $contentType = FALSE, $contentEncoding = FALSE, $detect = FALSE) {
|
||||
|
||||
$type = $contentType;
|
||||
|
||||
$uploads = wp_upload_dir();
|
||||
|
||||
$targetDir = (!$targetDir) ? wp_all_import_secure_file($uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::UPLOADS_DIRECTORY) : $targetDir;
|
||||
|
||||
$tmpname = wp_unique_filename($targetDir, ($type and strlen(basename($filePath)) < 30) ? basename($filePath) : (string) time());
|
||||
|
||||
$localPath = $targetDir . '/' . urldecode(sanitize_file_name($tmpname)) . ((!$type) ? '.tmp' : '');
|
||||
|
||||
$is_valid = FALSE;
|
||||
|
||||
$is_curl_download_only = apply_filters('wp_all_import_curl_download_only', false, $filePath);
|
||||
|
||||
if ( ! $is_curl_download_only ){
|
||||
|
||||
$file = ($contentEncoding == 'gzip') ? @fopen($filePath) : @fopen($filePath, "rb");
|
||||
|
||||
if (is_resource($file)) {
|
||||
|
||||
$fp = @fopen($localPath, 'w');
|
||||
$first_chunk = TRUE;
|
||||
while (!@feof($file)) {
|
||||
$chunk = @fread($file, 1024);
|
||||
if (!$type and $first_chunk and (strpos($chunk, "<?") !== FALSE or strpos($chunk, "<rss") !== FALSE) or strpos($chunk, "xmlns") !== FALSE) {
|
||||
$type = 'xml';
|
||||
} elseif (!$type and $first_chunk) {
|
||||
$type = 'csv';
|
||||
} // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
||||
$first_chunk = FALSE;
|
||||
@fwrite($fp, $chunk);
|
||||
}
|
||||
@fclose($file);
|
||||
@fclose($fp);
|
||||
|
||||
$chunk = new PMXI_Chunk($localPath);
|
||||
|
||||
if (!empty($chunk->options['element'])) {
|
||||
$defaultXpath = "/" . $chunk->options['element'];
|
||||
$is_valid = TRUE;
|
||||
}
|
||||
|
||||
if ($is_valid) {
|
||||
|
||||
while ($xml = $chunk->read()) {
|
||||
|
||||
if (!empty($xml)) {
|
||||
|
||||
//PMXI_Import_Record::preprocessXml($xml);
|
||||
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . "\n" . $xml;
|
||||
|
||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$old = libxml_use_internal_errors(TRUE);
|
||||
$dom->loadXML($xml);
|
||||
libxml_use_internal_errors($old);
|
||||
$xpath = new DOMXPath($dom);
|
||||
if (($elements = $xpath->query($defaultXpath)) and $elements->length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($xml)) {
|
||||
$is_valid = FALSE;
|
||||
}
|
||||
}
|
||||
unset($chunk);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$is_valid) {
|
||||
|
||||
$request = get_file_curl($filePath, $localPath);
|
||||
|
||||
if ( ! is_wp_error($request) ) {
|
||||
|
||||
if ( ! $type ) {
|
||||
if ($contentEncoding == 'gzip') {
|
||||
$file = @fopen($localPath);
|
||||
} else {
|
||||
$file = @fopen($localPath, "rb");
|
||||
}
|
||||
while (!@feof($file)) {
|
||||
$chunk = @fread($file, 1024);
|
||||
if (strpos($chunk, "<?") !== FALSE or strpos($chunk, "<rss") !== FALSE or strpos($chunk, "xmlns") !== FALSE) {
|
||||
$type = 'xml';
|
||||
} else {
|
||||
$type = 'csv';
|
||||
} // if it's a 1st chunk, then chunk <? symbols to detect XML file
|
||||
break;
|
||||
}
|
||||
@fclose($file);
|
||||
}
|
||||
} else {
|
||||
return $request;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!preg_match('%\W(' . $type . ')$%i', basename($localPath))) {
|
||||
if (@rename($localPath, $localPath . '.' . $type)) {
|
||||
$localPath = $localPath . '.' . $type;
|
||||
}
|
||||
}
|
||||
|
||||
return ($detect) ? array(
|
||||
'type' => $type,
|
||||
'localPath' => $localPath
|
||||
) : $localPath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
if( !function_exists('wp_all_import_is_base64_encoded')){
|
||||
function wp_all_import_is_base64_encoded($data){
|
||||
|
||||
// Only check the base64 portion of image references.
|
||||
$matches = [];
|
||||
preg_match('@(data:image/.{1,6};base64,)(.*)@', $data, $matches);
|
||||
|
||||
// Set data to only the base64 encoded portion if detected.
|
||||
$data = isset($matches[2]) ? $matches[2] : $data;
|
||||
|
||||
$decoded = base64_decode($data, true);
|
||||
|
||||
// Check if there is no invalid character in string
|
||||
if (!preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $data)) return false;
|
||||
|
||||
// Decode the string in strict mode and send the response
|
||||
if (!$decoded) return false;
|
||||
|
||||
// Encode and compare it to original one
|
||||
if (base64_encode($decoded) != $data) return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists('wp_all_import_is_json')){
|
||||
function wp_all_import_is_json($string) {
|
||||
if (function_exists('json_last_error'))
|
||||
{
|
||||
json_decode($string);
|
||||
switch (json_last_error()) {
|
||||
case JSON_ERROR_NONE:
|
||||
return true;
|
||||
break;
|
||||
case JSON_ERROR_DEPTH:
|
||||
return new WP_Error( 'broke', __( "Maximum stack depth exceeded", "pmxi_plugin" ) );
|
||||
break;
|
||||
case JSON_ERROR_STATE_MISMATCH:
|
||||
return new WP_Error( 'broke', __( "Underflow or the modes mismatch", "pmxi_plugin" ) );
|
||||
break;
|
||||
case JSON_ERROR_CTRL_CHAR:
|
||||
return new WP_Error( 'broke', __( "Unexpected control character found", "pmxi_plugin" ) );
|
||||
break;
|
||||
case JSON_ERROR_SYNTAX:
|
||||
return new WP_Error( 'broke', __( "Syntax error, malformed JSON", "pmxi_plugin" ) );
|
||||
break;
|
||||
case JSON_ERROR_UTF8:
|
||||
return new WP_Error( 'broke', __( "Malformed UTF-8 characters, possibly incorrectly encoded", "pmxi_plugin" ) );
|
||||
break;
|
||||
default:
|
||||
return new WP_Error( 'broke', __( "Unknown json error", "pmxi_plugin" ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
function wp_all_import_is_update_cf( $meta_key, $options ){
|
||||
|
||||
if ( $options['update_all_data'] == 'yes') return true;
|
||||
|
||||
if ( ! $options['is_update_custom_fields'] ) return false;
|
||||
|
||||
if ( $options['update_custom_fields_logic'] == "full_update" ) return true;
|
||||
if ( $options['update_custom_fields_logic'] == "only" and ! empty($options['custom_fields_list']) and is_array($options['custom_fields_list']) and in_array($meta_key, $options['custom_fields_list']) ) return true;
|
||||
if ( $options['update_custom_fields_logic'] == "all_except" and ( empty($options['custom_fields_list']) or ! in_array($meta_key, $options['custom_fields_list']) )) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
function wp_all_import_json_to_xml( $json = array() ){
|
||||
|
||||
return PMXI_ArrayToXML::toXml($json);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_rand_char')){
|
||||
|
||||
function wp_all_import_rand_char($length) {
|
||||
$random = '';
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$random .= chr(mt_rand(33, 126));
|
||||
}
|
||||
return $random;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_remove_source')){
|
||||
function wp_all_import_remove_source($file, $remove_dir = true){
|
||||
|
||||
@unlink($file);
|
||||
|
||||
$path_parts = pathinfo($file);
|
||||
|
||||
if ( ! empty($path_parts['dirname'])){
|
||||
$path_all_parts = explode('/', $path_parts['dirname']);
|
||||
$dirname = array_pop($path_all_parts);
|
||||
|
||||
if ( wp_all_import_isValidMd5($dirname)){
|
||||
if ($remove_dir or count(@scandir($path_parts['dirname'])) == 3){
|
||||
if (file_exists($path_parts['dirname'] . DIRECTORY_SEPARATOR . 'index.php')){
|
||||
@unlink($path_parts['dirname'] . DIRECTORY_SEPARATOR . 'index.php' );
|
||||
}
|
||||
}
|
||||
if ($remove_dir or count(@scandir($path_parts['dirname'])) == 2){
|
||||
wp_all_import_rmdir($path_parts['dirname']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
function wp_all_import_rmdir($dir) {
|
||||
if (@file_exists($dir)) {
|
||||
$scanned_files = @scandir($dir);
|
||||
if (!empty($scanned_files) and is_array($scanned_files)){
|
||||
$files = array_diff($scanned_files, array('.','..'));
|
||||
if (!empty($files)){
|
||||
foreach ($files as $file) {
|
||||
(is_dir("$dir/$file")) ? wp_all_import_rmdir("$dir/$file") : @unlink("$dir/$file");
|
||||
}
|
||||
}
|
||||
return @rmdir($dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
function wp_all_import_sanitize_filename($filename) {
|
||||
$filename = preg_replace('/\?.*/', '', $filename);
|
||||
$filename_parts = explode('.',$filename);
|
||||
if ( ! empty($filename_parts) and count($filename_parts) > 1){
|
||||
$ext = end($filename_parts);
|
||||
// Replace all weird characters
|
||||
$sanitized = substr($filename, 0, -(strlen($ext)+1));
|
||||
$sanitized = str_replace(".", "willbedots", $sanitized);
|
||||
$sanitized = str_replace("_", "willbetrimmed", $sanitized);
|
||||
$sanitized = sanitize_file_name($sanitized);
|
||||
$sanitized = str_replace("willbetrimmed", "_", $sanitized);
|
||||
$sanitized = str_replace("willbedots", ".", $sanitized);
|
||||
// Replace dots inside filename
|
||||
//$sanitized = str_replace('.','-', $sanitized);
|
||||
return $sanitized . '.' . $ext;
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Get correct import URL for Dropbox and Google share URLs
|
||||
*
|
||||
*
|
||||
* @param $link
|
||||
* The share URL for your Dropbox or Google Drive/Spreadsheets file.
|
||||
* @param $format
|
||||
* The type of file, if it's a Spreadsheet file. Acceptable examples: 'csv', 'xls'. Defaults to 'csv'.
|
||||
* @return string
|
||||
* The direct download URL.
|
||||
*/
|
||||
if ( ! function_exists('wp_all_import_sanitize_url')) {
|
||||
|
||||
function wp_all_import_sanitize_url( $link, $format = 'csv' ) {
|
||||
$link = str_replace(" ", "%20", $link);
|
||||
$parse = parse_url( $link );
|
||||
preg_match( '/(?<=.com\/).*?(?=\/d)/', $link, $match );
|
||||
// Check for 'spreadsheets' or 'file' from Google URL.
|
||||
if ( ! empty( $match[0] ) ) {
|
||||
// The type is either 'file' or 'spreadsheets' typically.
|
||||
$type = $match[0];
|
||||
}
|
||||
$domain = isset( $parse['host'] ) ? $parse['host'] : '';
|
||||
if ( preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $match ) ) {
|
||||
// Set the domain - i.e. google.com
|
||||
$domain = $match['domain'];
|
||||
}
|
||||
if ( ! empty( $domain ) ) {
|
||||
switch( $domain ) {
|
||||
case 'dropbox.com':
|
||||
if ( substr( $link, -4 ) == 'dl=0' ) {
|
||||
return str_replace( 'dl=0', 'dl=1', $link );
|
||||
}
|
||||
if ( strpos( $link, '?' ) === false ) {
|
||||
return $link . '?dl=1';
|
||||
}
|
||||
if ( strpos( $link, 'dl=1' ) === false ) {
|
||||
return $link . '&dl=1';
|
||||
}
|
||||
break;
|
||||
case 'google.com':
|
||||
if ( !empty( $type ) ) {
|
||||
switch( $type ) {
|
||||
case 'file':
|
||||
$pattern = '/(?<=\/file\/d\/).*?(?=\/edit)/';
|
||||
preg_match( $pattern, $link, $match );
|
||||
if (!empty($match[0])) {
|
||||
$file_id = $match[0];
|
||||
return 'https://drive.google.com/uc?export=download&id=' . $file_id;
|
||||
}
|
||||
break;
|
||||
case 'spreadsheets':
|
||||
$pattern = '/(?<=\/spreadsheets\/d\/).*?(?=\/edit)/';
|
||||
preg_match( $pattern, $link, $match );
|
||||
if ( !empty( $match[0] ) ) {
|
||||
$file_id = $match[0];
|
||||
return 'https://docs.google.com/spreadsheets/d/' . $file_id . '/export?format=' . $format;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return $link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
return $link;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_secure_file') ) {
|
||||
function wp_all_import_secure_file( $targetDir, $importID = false, $remove_dir = false, $generateDir = true ) {
|
||||
$is_secure_import = PMXI_Plugin::getInstance()->getOption('secure');
|
||||
if ( $is_secure_import ) {
|
||||
$nonce_salt = defined('NONCE_SALT') ? NONCE_SALT : wp_salt('nonce');
|
||||
$dir = $targetDir . DIRECTORY_SEPARATOR . ( ( $importID ) ? md5( $importID . $nonce_salt ) : md5( time() . $nonce_salt ) );
|
||||
if ( @is_dir($dir) and $remove_dir ) wp_all_import_remove_source($dir . DIRECTORY_SEPARATOR . 'index.php' );
|
||||
if ( $generateDir ) @wp_mkdir_p($dir);
|
||||
if (@is_writable($dir) and @is_dir($dir)) {
|
||||
$targetDir = $dir;
|
||||
if (!@file_exists($dir . DIRECTORY_SEPARATOR . 'index.php') && $generateDir) {
|
||||
@touch( $dir . DIRECTORY_SEPARATOR . 'index.php' );
|
||||
}
|
||||
}
|
||||
}
|
||||
return $targetDir;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_strip_tags_content')){
|
||||
|
||||
function wp_all_import_strip_tags_content($text, $tags = '', $invert = FALSE) {
|
||||
|
||||
preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags);
|
||||
$tags = array_unique($tags[1]);
|
||||
|
||||
if(is_array($tags) AND count($tags) > 0) {
|
||||
if($invert == FALSE) {
|
||||
return preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text);
|
||||
}
|
||||
else {
|
||||
return preg_replace('@<('. implode('|', $tags) .')\b.*?>.*?</\1>@si', '', $text);
|
||||
}
|
||||
}
|
||||
elseif($invert == FALSE) {
|
||||
return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text);
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_template_notifications') )
|
||||
{
|
||||
function wp_all_import_template_notifications( $post, $type = 'warning')
|
||||
{
|
||||
$notifications = array();
|
||||
// import template was generated via WP All Export
|
||||
if ( ! empty($post['required_add_ons']) )
|
||||
{
|
||||
foreach ($post['required_add_ons'] as $key => $addon)
|
||||
{
|
||||
if (class_exists($key)) continue;
|
||||
|
||||
$notifications[] = sprintf(__('The import template you are using requires the %s. If you continue without it your data may import incorrectly.<br/><br/><a href="%s" target="_blank">' . ($addon['paid'] ? 'Purchase' : 'Download') . ' the %s</a>.', 'wp_all_import_plugin'), esc_attr($addon['name']), esc_url($addon['url']), esc_attr($addon['name']));
|
||||
}
|
||||
}
|
||||
else // Custom Import Template
|
||||
{
|
||||
if ( ! function_exists( 'is_plugin_active' ) ) require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
|
||||
if ( $post['custom_type'] == 'import_users' && ! class_exists('PMUI_Plugin') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the User Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707221&edd_options%5Bprice_id%5D=1&utm_source=import-plugin-free&utm_medium=upgrade-notice&utm_campaign=import-users-template" target="_blank">Purchase the User Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
|
||||
if ( $post['custom_type'] == 'shop_customer' && ! class_exists('PMUI_Plugin') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the User Add-On. If you continue without having this add-on active, your data may import incorrectly.<br/><br/><a href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707221&edd_options%5Bprice_id%5D=1&utm_source=import-plugin-free&utm_medium=upgrade-notice&utm_campaign=import-users-template" target="_blank">Purchase the User Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
|
||||
|
||||
elseif ( $post['custom_type'] == 'product' && ! class_exists('PMWI_Plugin') && class_exists( 'Woocommerce' ))
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the WooCommerce Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://www.wpallimport.com/checkout/?edd_action=add_to_cart&download_id=2707227&edd_options%5Bprice_id%5D=1&utm_source=import-plugin-free&utm_medium=upgrade-notice&utm_campaign=import-wooco-template" target="_blank">Purchase the WooCommerce Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// Realia Add-On
|
||||
elseif ( ! empty($post['realia_addon']) and ! is_plugin_active('realia-xml-csv-property-listings-import/realia-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the Realia Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/realia-xml-csv-property-listings-import/" target="_blank">Download the Realia Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// WP Residence Add-On
|
||||
elseif ( ! empty($post['realhomes_addon'])
|
||||
and isset($post['realhomes_addon']['property_price'])
|
||||
and ! is_plugin_active('wp-residence-add-on-for-wp-all-import/wp-residence-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the WP Residence Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/wp-residence-add-on-for-wp-all-import/" target="_blank">Download the WP Residence Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// RealHomes Add-On
|
||||
elseif ( ! empty($post['realhomes_addon'])
|
||||
and isset($post['realhomes_addon']['REAL_HOMES_property_price'])
|
||||
and ! is_plugin_active('realhomes-xml-csv-property-listings-import/realhomes-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the RealHomes Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/realhomes-xml-csv-property-listings-import/" target="_blank">Download the RealHomes Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// Jobify Add-On
|
||||
elseif ( ! empty($post['jobify_addon'])
|
||||
and ! is_plugin_active('jobify-xml-csv-listings-import/jobify-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the Jobify Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/jobify-xml-csv-listings-import/" target="_blank">Download the Jobify Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// Listify Add-On
|
||||
elseif ( ! empty($post['listify_addon'])
|
||||
and ! is_plugin_active('listify-xml-csv-listings-import/listify-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the Listify Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/listify-xml-csv-listings-import/" target="_blank">Download the Listify Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// Reales WP Add-On
|
||||
elseif ( ! empty($post['reales_addon'])
|
||||
and ! is_plugin_active('reales-wp-xml-csv-property-listings-import/reales-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the Reales WP Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/reales-wp-xml-csv-property-listings-import/" target="_blank">Download the Reales WP Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// WP Job Manager Add-On
|
||||
elseif ( ! empty($post['wpjm_addon'])
|
||||
and ! is_plugin_active('wp-job-manager-xml-csv-listings-import/wp-job-manager-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the WP Job Manager Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/wp-job-manager-xml-csv-listings-import/" target="_blank">Download the WP Job Manager Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// Yoast SEO Add-On
|
||||
elseif ( ! empty($post['yoast_addon'])
|
||||
and ! is_plugin_active('yoast-seo-settings-xml-csv-import/yoast-addon.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the Yoast SEO Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/yoast-seo-settings-xml-csv-import/" target="_blank">Download the Yoast SEO Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// Listable SEO Add-On
|
||||
elseif ( ! empty($post['listable_addon'])
|
||||
and ! is_plugin_active('import-xml-csv-listings-to-listable-theme/listable-add-on.php') )
|
||||
{
|
||||
$notifications[] = __('The import template you are using requires the Listable Add-On. If you continue without it your data may import incorrectly.<br/><br/><a href="https://wordpress.org/plugins/import-xml-csv-listings-to-listable-theme/" target="_blank">Download the Listable Add-On</a>.', 'wp_all_import_plugin');
|
||||
}
|
||||
// 3rd party Add-On
|
||||
elseif( ! empty($post['rapid_addon']) and ! is_plugin_active($post['rapid_addon']) )
|
||||
{
|
||||
$notification[] = __('The import template you are using requires an Add-On for WP All Import. If you continue without using this Add-On your data may import incorrectly.', 'wp_all_import_plugin');
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty($notifications))
|
||||
{
|
||||
foreach ($notifications as $notification)
|
||||
{
|
||||
if ($type == 'warning')
|
||||
{
|
||||
?>
|
||||
<div class="error inline">
|
||||
<p><?php printf(__('<strong>Warning:</strong>', 'wp_all_import_plugin') . ' %s', wp_kses_post($notification));?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<div class="wpallimport-free-edition-notice" style="text-align:center; margin-top:0; margin-bottom: 20px;">
|
||||
<p class="upgrade_link"><?php echo wp_kses_post($notification);?></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_all_import_url_title')){
|
||||
|
||||
function wp_all_import_url_title($str, $separator = 'dash', $lowercase = FALSE) {
|
||||
if ($separator == 'dash') {
|
||||
$search = '_';
|
||||
$replace = '-';
|
||||
} else {
|
||||
$search = '-';
|
||||
$replace = '_';
|
||||
}
|
||||
|
||||
$trans = array(
|
||||
'&\#\d+?;' => '',
|
||||
'&\S+?;' => '',
|
||||
'\s+' => $replace,
|
||||
'[^a-z0-9\-\._]' => '',
|
||||
$replace.'+' => $replace,
|
||||
$replace.'$' => $replace,
|
||||
'^'.$replace => $replace,
|
||||
'\.+$' => ''
|
||||
);
|
||||
|
||||
$str = strip_tags($str);
|
||||
|
||||
foreach ($trans as $key => $val) {
|
||||
$str = preg_replace("#".$key."#i", $val, $str);
|
||||
}
|
||||
|
||||
if ($lowercase === TRUE) {
|
||||
$str = strtolower($str);
|
||||
}
|
||||
|
||||
return trim(stripslashes($str));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
if ( ! function_exists('wp_all_import_xml2array')){
|
||||
function wp_all_import_xml2array( $xmlObject, $out = array () ) {
|
||||
foreach ( (array) $xmlObject as $index => $node )
|
||||
$out[$index] = ( is_object ( $node ) ) ? wp_all_import_xml2array ( $node ) : $node;
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Delete attachments linked to a specified post
|
||||
* @param int $parent_id Parent id of post to delete attachments for
|
||||
*/
|
||||
function wp_delete_attachments($parent_id, $unlink = true, $type = 'images') {
|
||||
|
||||
$ids = array();
|
||||
|
||||
$attachments = get_posts(array('post_parent' => $parent_id, 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null));
|
||||
|
||||
foreach ($attachments as $attach) {
|
||||
if ( ($type == 'files' && ! wp_attachment_is_image( $attach->ID )) || ($type == 'images' && wp_attachment_is_image( $attach->ID ))) {
|
||||
if ($unlink) {
|
||||
if (!empty($attach->ID)) {
|
||||
$file = get_attached_file($attach->ID);
|
||||
if (@file_exists($file)) {
|
||||
wp_delete_attachment($attach->ID, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ids[] = $attach->ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
if ( ! empty( $ids ) ) {
|
||||
|
||||
$ids_string = implode( ',', $ids );
|
||||
// unattach
|
||||
$result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
|
||||
|
||||
foreach ( $ids as $att_id ) {
|
||||
clean_attachment_cache( $att_id );
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
if ( ! function_exists('wp_redirect_or_javascript')):
|
||||
/**
|
||||
* For AJAX request outputs javascript specified, otherwise acts like wp_redirect
|
||||
* @param string $location
|
||||
* @param string[optional] $javascript
|
||||
* @param int[optional] $status
|
||||
*/
|
||||
function wp_redirect_or_javascript($location, $javascript = NULL, $status = 302) {
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
|
||||
is_null($javascript) and $javascript = 'location.href="' . addslashes($location) . '";';
|
||||
echo '<script type="text/javascript">' . esc_js($javascript) . '</script>';
|
||||
} else {
|
||||
return wp_redirect($location, $status);
|
||||
}
|
||||
}
|
||||
endif;
|
||||
28
wp-content/plugins/wp-all-import/helpers/wpai_util_map.php
Normal file
28
wp-content/plugins/wp-all-import/helpers/wpai_util_map.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
if( !function_exists('wpai_util_map') ){
|
||||
|
||||
function wpai_util_map( $orig, $change, $source ){
|
||||
|
||||
$orig = html_entity_decode($orig);
|
||||
$change = html_entity_decode($change);
|
||||
$source = html_entity_decode($source);
|
||||
$original_array = array_map('trim',explode(',',$orig));
|
||||
|
||||
if ( empty($original_array) ) return "";
|
||||
|
||||
$change_array = array_map('trim',explode(',',$change));
|
||||
|
||||
if ( empty($change_array) or count($original_array) != count($change_array)) return "";
|
||||
|
||||
if( count($change_array) == count($original_array) ){
|
||||
$replacement = array();
|
||||
foreach ($original_array as $key => $el){
|
||||
$replacement[$el] = $change_array[$key];
|
||||
}
|
||||
$result = strtr($source,$replacement);
|
||||
}
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user