Commit inicial - WordPress Análisis de Precios Unitarios

- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-11-03 21:04:30 -06:00
commit a22573bf0b
24068 changed files with 4993111 additions and 0 deletions

View File

@@ -0,0 +1,416 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class DefaultExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (DefaultExtension::$instance == null) {
DefaultExtension::$instance = new DefaultExtension;
}
return DefaultExtension::$instance;
}
/**
* Provides default mapping fields for specific post type or taxonomies
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$mode = isset($_POST['Mode']) ? sanitize_text_field($_POST['Mode']) :'';
$import_types = $data;
$import_type = $this->import_name_as($import_types);
$response = [];
$check_custpost = array('Posts' => 'post', 'Pages' => 'page', 'Users' => 'users', 'Comments' => 'comments', 'CustomerReviews' =>'wpcr3_review', 'Categories' => 'categories', 'Tags' => 'tags', 'WooCommerce' => 'product', 'WPeCommerce' => 'wpsc-product','WPeCommerceCoupons' => 'wpsc-product', 'WooCommerceOrders' => 'product', 'WooCommerceCoupons' => 'product', 'WooCommerceRefunds' => 'product', 'CustomPosts' => 'CustomPosts','WooCommerceReviews' => 'reviews');
if ($import_type != 'Users' && $import_type != 'WooCommerceCustomer' && $import_type != 'Taxonomies' && $import_types != 'JetReviews' && $import_type != 'CustomerReviews' && $import_type != 'Comments' && $import_type != 'WooCommerceOrders' && $import_type != 'WooCommerceCoupons' && $import_type != 'WooCommerceRefunds' && $import_type != 'ngg_pictures' && $import_types != 'JetBooking' && $import_types != 'lp_order' && $import_types != 'nav_menu_item' && $import_types != 'widgets' && $import_type != 'WooCommerceReviews') { $wordpressfields = array(
'Title' => 'post_title',
'ID' => 'ID',
'Content' => 'post_content',
'Short Description' => 'post_excerpt',
'Publish Date' => 'post_date',
'Slug' => 'post_name',
'Author' => 'post_author',
'Status' => 'post_status',
'Featured Image' => 'featured_image'
);
if(is_plugin_active('multilanguage/multilanguage.php')) {
$wordpressfields['Language Code'] = 'lang_code';
}
if(is_plugin_active('post-expirator/post-expirator.php')) {
$wordpressfields['Post Expirator'] = 'post_expirator';
$wordpressfields['Post Expirator Status'] = 'post_expirator_status';
}
if ($import_type === 'Posts') {
$wordpressfields['Format'] = 'post_format';
$wordpressfields['Comment Status'] = 'comment_status';
$wordpressfields['Ping Status'] = 'ping_status';
}
if ($import_type === 'CustomPosts') {
if($import_types == 'elementor_library'){
$wordpressfields = array(
'ID' => 'ID',
'Template title' => 'Template title',
'Template content' => 'Template content',
'Style'=> 'Style',
'Template type' => 'Template type',
'Created time' => 'Created time',
'Created by' => 'Created by',
'Template status' => 'Template status',
'Category'=> 'Category'
);
}
else{
$wordpressfields = array(
'Title' => 'post_title',
'ID' => 'ID',
'Content' => 'post_content',
'Short Description' => 'post_excerpt',
'Publish Date' => 'post_date',
'Slug' => 'post_name',
'Author' => 'post_author',
'Status' => 'post_status',
'Featured Image' => 'featured_image'
);
$wordpressfields['Format'] = 'post_format';
$wordpressfields['Comment Status'] = 'comment_status';
$wordpressfields['Ping Status'] = 'ping_status';
$wordpressfields['Parent'] = 'post_parent';
$wordpressfields['Order'] = 'menu_order';
}
}
if ($import_type === 'Pages') {
$wordpressfields['Parent'] = 'post_parent';
$wordpressfields['Order'] = 'menu_order';
$wordpressfields['Page Template'] = 'wp_page_template';
$wordpressfields['Comment Status'] = 'comment_status';
$wordpressfields['Ping Status'] = 'ping_status';
}
if($mode == 'Insert'){
unset($wordpressfields['ID']);
}
//WooCommerceOrders
if($import_types == 'lp_lesson'){
unset($wordpressfields['Format']);
unset($wordpressfields['Featured Image']);
unset($wordpressfields['Short Description']);
unset($wordpressfields['Author']);
}
if($import_types == 'lp_quiz' || $import_types == 'lp_question' || $import_types == 'wp_font_face' || $import_types == 'wp_font_family' || $import_types == 'wp_global_style' || $import_types == 'wp_template' ){
unset($wordpressfields['Format']);
unset($wordpressfields['Featured Image']);
unset($wordpressfields['Short Description']);
unset($wordpressfields['Author']);
unset($wordpressfields['Comment Status']);
unset($wordpressfields['Ping Status']);
unset($wordpressfields['Track Options']);
unset($wordpressfields['Order']);
}
}
if(is_plugin_active('jet-engine/jet-engine.php')){
global $wpdb;
$get_slug_name = $wpdb->get_results("SELECT slug FROM {$wpdb->prefix}jet_post_types WHERE status = 'content-type'");
foreach($get_slug_name as $key=>$get_slug){
$value=$get_slug->slug;
if($import_type == $value){
$wordpressfields=array(
'_ID'=>'_ID',
'Status'=>'cct_status',
);
if($mode == 'Insert'){
unset($wordpressfields['_ID']);
}
}
}
}
// if($import_type == 'Media') {
// $wordpressfields = array(
// 'File Name' => 'file_name',
// 'Caption' => 'caption',
// 'Alt text' => 'alt_text',
// 'Desctiption' => 'description',
// 'Title' => 'title',
// );
// }
// if( $import_types == "Media"){
// $wordpressfields = array(
// 'File Name' => 'file_name',
// 'Title' => 'title',
// 'Caption' => 'caption',
// 'Alt text' => 'alt_text',
// 'Description' => 'description',
// );
// $wordpress_value = $this->convert_static_fields_to_array($wordpressfields);
// }
if($import_type == 'WooCommerceOrders'){
$wordpressfields = array(
'Customer Note' => 'customer_note',
'Order Status' => 'order_status',
'Order Date' => 'order_date',
'Order Id' => 'ORDERID'
);
if($mode == 'Insert'){
unset($wordpressfields['Order Id']);
}
}
if($import_type === 'WooCommerceCoupons'){
$wordpressfields = array(
'Coupon Code' => 'coupon_code',
'Description' => 'description',
'Date' => 'coupon_date',
'Status' => 'coupon_status',
'Coupon Id' =>'COUPONID'
);
if($mode == 'Insert'){
unset($wordpressfields['Coupon Id']);
}
}
if($import_type === 'WooCommerceRefunds' ){
$wordpressfields = array(
'Post Parent' => 'post_parent',
'Post Excerpt' => 'post_excerpt',
'Refund Id' => 'REFUNDID'
);
if($mode == 'Insert'){
unset($wordpressfields['Refund Id']);
}
}
if($import_types == 'lp_order'){
$wordpressfields = array(
'Order Status' => 'order_status',
'Order Date' => 'order_date',
);
}
if($import_types == 'nav_menu_item'){
$wordpressfields = array(
'Menu Title' => 'menu_title',
'Menu Type' => '_menu_item_type',
'Menu Items' => '_menu_item_object',
'Menu Item Ids' => '_menu_item_object_id',
'Menu Custom Url' => '_menu_item_url',
'Menu Auto Add' => 'menu_auto_add'
);
$get_navigation_locations = get_nav_menu_locations();
foreach($get_navigation_locations as $nav_key => $nav_values){
$wordpressfields[$nav_key] = $nav_key;
}
}
if($import_types === 'JetReviews') {
$wordpressfields = array(
'ID' => 'ID',
'Review Post Id' => 'post_id', // The ID of the post being reviewed
'Review Source' => 'source', // Source of the review (e.g., 'post')
'Review Post Type' => 'post_type', // Type of post (e.g., 'post', 'page', etc.)
'Review Author' => 'author', // ID of the author who wrote the review
'Review Date' => 'date', // Date of the review
'Review Title' => 'title', // Title of the review
'Review Content' => 'content', // Content of the review
'Review Type Slug' => 'type_slug', // Slug of the review type (e.g., 'default', etc.)
'Review Rating Data' => 'rating_data', // Serialized rating data
'Review Rating' => 'rating', // Rating score (e.g., 100)
'Review Likes' => 'likes', // Number of likes
'Review Dislikes' => 'dislikes', // Number of dislikes
'Review Approved' => 'approved', // Whether the review is approved (1 or 0)
'Review Pinned' => 'pinned', // Whether the review is pinned (1 or 0)
);
if($mode == 'Insert'){
unset($wordpressfields['ID']);
}
}
if($import_types == 'widgets') {
$wordpressfields = array(
'Recent Posts' => 'widget_recent-posts',
'Pages' => 'widget_pages',
'Recent Comments'=> 'widget_recent-comments',
'Archieves' => 'widget_archives',
'Categories' => 'widget_categories'
);
}
if($import_type == 'WooCommerce' || $import_type == 'WPeCommerce'){
$wordpressfields['PRODUCT SKU'] = 'PRODUCTSKU';
}
if($import_type === 'Categories') {
$wordpressfields = array(
'Category Name' => 'name',
'Category Slug' => 'slug',
'Category Description' => 'description',
'Parent' => 'parent',
'Term ID' => 'TERMID'
);
if($mode == 'Insert'){
unset($wordpressfields['Term ID']);
}
if($import_types == 'product_cat'){
$wordpressfields['Category Image'] = 'image';
$wordpressfields['Display type'] = 'display_type';
$wordpressfields['Top Content'] = 'top_content';
$wordpressfields['Bottom Content'] = 'bottom_content';
}elseif($import_types == 'wpsc_product_category'){
$wordpressfields['Category Image'] = 'image';
}elseif($import_types == 'event-categories'){
$wordpressfields['Category Image'] = 'image';
$wordpressfields['Category Color'] = 'color';
}
}
if($import_type === 'Tags') {
$wordpressfields = array(
'Tag Name' => 'name',
'Tag Slug' => 'slug',
'Tag Description' => 'description',
'Term ID' => 'TERMID',
);
if($mode == 'Insert'){
unset($wordpressfields['Term ID']);
}if($import_types == 'event-tags'){
$wordpressfields['Tag Image'] = 'image';
$wordpressfields['Tag Color'] = 'color';
}
}
if($import_type == 'Users' || $import_type == 'WooCommerceCustomer'){
$wordpressfields = array(
'User Login' => 'user_login',
'User Pass' => 'user_pass',
'First Name' => 'first_name',
'Last Name' => 'last_name',
'Nick Name' => 'nickname',
'User Email' => 'user_email',
'User URL' => 'user_url',
'User Nicename' => 'user_nicename',
'User Registered' => 'user_registered',
'Display Name' => 'display_name',
'User Role' => 'role',
'Biographical Info' => 'biographical_info',
'Disable Visual Editor' => 'disable_visual_editor',
'Admin Color Scheme' => 'admin_color',
'Enable Keyboard Shortcuts' => 'enable_keyboard_shortcuts',
'Show Toolbar' => 'show_toolbar',
);
}
if($import_type === 'Comments') {
$wordpressfields = array(
'Comment Post Id' => 'comment_post_ID',
'Comment Author' => 'comment_author',
'Comment Author Email' => 'comment_author_email',
'Comment Author URL' => 'comment_author_url',
'Comment Content' => 'comment_content',
'Comment Rating' => 'comment_rating',
'Comment Author IP' => 'comment_author_IP',
'Comment Date' => 'comment_date',
'Comment Approved' => 'comment_approved',
'Comment Parent' => 'comment_parent',
'user_id'=>'user_id',
);
}
if($import_type === 'WooCommerceReviews') {
$wordpressfields = array(
'Review Product Id' => 'comment_post_ID',
'Review Author' => 'comment_author',
'Review Author Email' => 'comment_author_email',
'Review Author URL' => 'comment_author_url',
'Review Content' => 'comment_content',
'Review Rating' => 'comment_rating',
'Review Author IP' => 'comment_author_IP',
'Review Date' => 'comment_date',
'Review Approved' => 'comment_approved',
'Review Parent' => 'comment_parent',
'user_id'=>'user_id',
);
}
if($import_type === 'Taxonomies') {
$wordpressfields = array(
'Taxonomy Name' => 'name',
'Taxonomy Slug' => 'slug',
'Taxonomy Description' => 'description',
'Term ID' => 'TERMID',
);
if($mode == 'Insert'){
unset($wordpressfields['Term ID']);
}
}
if($import_type === 'CustomerReviews') {
if(is_plugin_active('wp-customer-reviews/wp-customer-reviews-3.php') || is_plugin_active('wp-customer-reviews/wp-customer-reviews.php')) {
$wordpressfields = array(
'Review Date Time' => 'date_time',
'Reviewer Name' => 'review_name',
'Reviewer Email' => 'review_email',
'Reviewer IP' => 'review_ip',
'Review Format' => 'review_format',
'Review Title' => 'review_title',
'Review Text' => 'review_text',
'Review Response' => 'review_admin_response',
'Review Status' => 'status',
'Review Rating' => 'review_rating',
'Review URL' => 'review_website',
'Review to Post/Page Id' => 'review_post',
'Review ID' => 'review_id',
);
if($mode == 'Insert'){
unset($wordpressfields['Review ID']);
}
}
}
if ($import_types == 'JetBooking' && is_plugin_active('jet-booking/jet-booking.php')) {
$wordpressfields = array(
'booking_id' => 'booking_id',
'status' => 'status',
'apartment_id' => 'apartment_id',
'apartment_unit' => 'apartment_unit',
'check_in_date' => 'check_in_date',
'check_out_date' => 'check_out_date',
'order_id' => 'order_id',
'user_id' => 'user_id',
'import_id' => 'import_id',
'attributes' => 'attributes',
'guests' => 'guests',
'orderStatus' => 'orderStatus',
);
if($mode == 'Insert'){
unset($wordpressfields['booking_id']);
unset($wordpressfields['order_id']);
}if($mode == 'Update'){
unset($wordpressfields['orderStatus']);
unset($wordpressfields['order_id']);
unset($wordpressfields['user_id']);
unset($wordpressfields['import_id']);
}
}
$wordpress_value = $this->convert_static_fields_to_array($wordpressfields);
$response['core_fields'] = $wordpress_value ;
return $response;
}
/**
* Core Fields extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
return true;
}
}

View File

@@ -0,0 +1,189 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ACFExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ACFExtension::$instance == null) {
ACFExtension::$instance = new ACFExtension;
}
return ACFExtension::$instance;
}
/**
* Provides default mapping fields for ACF Free plugin
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
$import_type = $this->import_type_as($import_type);
$acf_pro_fields = $this->ACFFields($import_type , 'ACF');
$acf_group_fields=$this->ACFFields($import_type , 'GF');
if(!empty($acf_pro_fields)){
$response['acf_fields'] = $acf_pro_fields;
}
if(!empty($acf_group_fields)){
$response['acf_group_fields'] = null;
}
return $response;
}
/**
* Retrieves ACF mapping fields
* @param string $import_type - selected import type
* @param string $group - ACF or GF
* @return array - mapping fields
*/
public function ACFFields($import_type ,$group) {
global $wpdb;
$group_id_arr = $customFields = $rep_customFields = array();
$get_acf_groups = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_content from {$wpdb->prefix}posts where post_status != 'trash' and post_type = %s" , 'acf-field-group'));
// Get available ACF group id
foreach ( $get_acf_groups as $item => $group_rules ) {
$rule = maybe_unserialize($group_rules->post_content);
if(!empty($rule)) {
if ($import_type != 'Users') {
foreach($rule['location'] as $key => $value) {
if($value[0]['operator'] == '==' && $value[0]['value'] == $this->import_post_types($import_type)){
$group_id_arr[] = $group_rules->ID; #. ',';
}
elseif($value[0]['operator'] == '==' && $value[0]['value'] == 'all' && $value[0]['param'] == 'taxonomy' && in_array($this->import_post_types($import_type) , get_taxonomies())){
$group_id_arr[] = $group_rules->ID;
}
}
} else {
foreach($rule['location'] as $key => $value) {
if( $value[0]['operator'] == '==' && $value[0]['param'] == 'user_role' || $value[0]['param'] == 'current_user'){
$group_id_arr[] = $group_rules->ID;
}
}
}
}
}
if ( !empty($group_id_arr) ) {
foreach($group_id_arr as $groupId) {
//$get_acf_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != %s AND post_parent in (%s)",'trash' , array($groupId) ) );
$get_acf_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in (%s)", array($groupId) ) );
if ( ! empty( $get_acf_fields ) ) {
$group_field_arr = array();
foreach ( $get_acf_fields as $acf_pro_fields ) {
$get_field_content = unserialize( $acf_pro_fields->post_content );
if ( $get_field_content['type'] == 'group' ) {
$group_field_arr[] = $acf_pro_fields->ID . ",";
foreach($group_field_arr as $group_field){
//$get_sub_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != %s AND post_parent in (%s)", 'trash',array($group_field) ) );
$get_sub_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in (%s)",array($group_field) ) );
foreach ( $get_sub_fields as $get_sub_key ) {
$get_sub_field_content = unserialize( $get_sub_key->post_content );
if ( $get_sub_field_content['type'] == 'group' ) {
$group_field_arr[] = $get_sub_key->ID . ",";
}
}
}
}
elseif ( $acf_pro_fields->post_excerpt != null || $acf_pro_fields->post_excerpt != '' ) {
if($get_field_content['type'] !== 'group' && $get_field_content['type'] !== 'message' && $get_field_content['type'] !== 'tab' && $get_field_content['type'] !== 'image' && $get_field_content['type'] !== 'file' && $get_field_content['type'] !== 'oembed' && $get_field_content['type'] !== 'link' && $get_field_content['type'] !== 'page_link'){
if($get_field_content['type'] == 'select'){
if($get_field_content['multiple'] == 0){
$customFields["ACF"][ $acf_pro_fields->post_name ]['label'] = $acf_pro_fields->post_title;
$customFields["ACF"][ $acf_pro_fields->post_name ]['name'] = $acf_pro_fields->post_excerpt;
}
}
else{
$customFields["ACF"][ $acf_pro_fields->post_name ]['label'] = $acf_pro_fields->post_title;
$customFields["ACF"][ $acf_pro_fields->post_name ]['name'] = $acf_pro_fields->post_excerpt;
}
}
}
}
}
$group_fields = $group_field_arr ;
$group_field_placeholders = array_fill(0, count($group_fields), '%s');
$placeholdersForGroupFields = implode(', ', $group_field_placeholders);
if ( ! empty( $group_field_arr ) ) {
$query1 = "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in ($placeholdersForGroupFields)";
$get_acf_group_fields = $wpdb->get_results( $wpdb->prepare( $query1, $group_fields ) );
}
if ( ! empty( $get_acf_group_fields ) ) {
foreach ( $get_acf_group_fields as $acf_pro_group_fields ) {
$get_sub_field_content = unserialize( $acf_pro_group_fields->post_content );
$rep_customFields[ $acf_pro_group_fields->post_title ] = $acf_pro_group_fields->post_excerpt;
$check_exist_key = "ACF: " . $acf_pro_group_fields->post_title;
if ( array_key_exists( $check_exist_key, $customFields ) ) {
unset( $customFields[ $check_exist_key ] );
}
if($get_sub_field_content['type'] !== 'group'){
$customFields["GF"][ $acf_pro_group_fields->post_name ]['label'] = $acf_pro_group_fields->post_title;
$customFields["GF"][ $acf_pro_group_fields->post_name ]['name'] = $acf_pro_group_fields->post_excerpt;
}
}
}
}
}
$requested_group_fields = array();
if(!empty($customFields[$group]))
$requested_group_fields[$group] = $customFields[$group];
$acf_pro_value = $this->convert_fields_to_array($requested_group_fields);
return $acf_pro_value;
}
/**
* ACF extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('advanced-custom-fields/acf.php') || is_plugin_active('secure-custom-fields/secure-custom-fields.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='Users' || $import_type =='WooCommerce' || $import_type =='Taxonomies' || $import_type =='Tags' || $import_type =='Categories') {
return true;
}
else{
return false;
}
}
}
function import_post_types($import_type, $importAs = null) {
$import_type = trim($import_type);
$module = array('Posts' => 'post', 'Pages' => 'page', 'Users' => 'user', 'Comments' => 'comments', 'Taxonomies' => $importAs, 'CustomerReviews' =>'wpcr3_review', 'Categories' => 'categories', 'Tags' => 'tags', 'WooCommerce' => 'product', 'WPeCommerce' => 'wpsc-product','WPeCommerceCoupons' => 'wpsc-product', 'WooCommerceOrders' => 'product', 'WooCommerceCoupons' => 'product', 'WooCommerceRefunds' => 'product', 'CustomPosts' => $importAs);
foreach (get_taxonomies() as $key => $taxonomy) {
$module[$taxonomy] = $taxonomy;
}
if(array_key_exists($import_type, $module)) {
return $module[$import_type];
}
else {
return $import_type;
}
}
}

View File

@@ -0,0 +1,365 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ACFProExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ACFProExtension::$instance == null) {
ACFProExtension::$instance = new ACFProExtension;
}
return ACFProExtension::$instance;
}
/**
* Provides default mapping fields for ACF Pro plugin
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$response = [];
$import_type = $data;
$acf_pro_fields = $this->ACFProFields($import_type , 'ACF');
if(!empty($acf_pro_fields)){
$response['acf_pro_fields'] = null;
}
$acf_group_fields = $this->ACFProFields($import_type , 'GF');
if(!empty($acf_group_fields)){
$response['acf_group_fields'] = null;
}
$acf_repeater_fields = $this->ACFProFields($import_type , 'RF');
if(!empty($acf_repeater_fields)){
$response['acf_repeater_fields'] = null;
}
$acf_flexible_fields = $this->ACFProFields($import_type , 'FC');
if(!empty($acf_flexible_fields)){
$response['acf_flexible_fields'] = null;
}
return $response;
}
/**
* Retrieves ACF Pro mapping fields
* @param string $import_type - selected import type
* @param string $group - ACF or GF or RF
* @return array - mapping fields
*/
public function ACFProFields($import_type ,$group) {
global $wpdb;
$repeater_field_arr = $flexible_field_arr = $group_field_arr = "";
$group_id_arr = $customFields = $rep_customFields = array();
$get_acf_groups = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_content FROM {$wpdb->prefix}posts WHERE post_status != 'trash' AND post_type = %s", 'acf-field-group'));
$get_acf_groups = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_content FROM {$wpdb->prefix}posts WHERE post_status != 'trash' AND post_status != 'acf-disabled' AND post_type = %s", 'acf-field-group'));
// Get available ACF group id
foreach ( $get_acf_groups as $item => $group_rules ) {
$rule = maybe_unserialize($group_rules->post_content);
if(!empty($rule)) {
if ($import_type != 'Users') {
foreach($rule['location'] as $key => $value) {
if($value[0]['operator'] == '==' && $value[0]['value'] == $this->import_post_types($import_type) || $value[0]['param'] == 'comment'){
$group_id_arr[] = $group_rules->ID; #. ',';
}
elseif($value[0]['operator'] == '==' && $value[0]['value'] == 'all' && $value[0]['param'] == 'taxonomy' && in_array($this->import_post_types($import_type) , get_taxonomies())){
$group_id_arr[] = $group_rules->ID;
}
elseif($value[0]['param'] == 'post_category'){
$group_id_arr[] = $group_rules->ID;
}
elseif($value[0]['operator'] == '==' && $value[0]['param'] == 'post_taxonomy'){
$group_id_arr[] = $group_rules->ID;
}
}
} else {
foreach($rule['location'] as $key => $value) {
if( $value[0]['operator'] == '==' && $value[0]['param'] == 'current_user_role' || $value[0]['param'] == 'current_user'|| $value[0]['param'] == 'user_form' || $value[0]['param'] == 'user_role'){
$group_id_arr[] = $group_rules->ID;
}
}
}
}
}
if ( !empty($group_id_arr) ) {
foreach($group_id_arr as $groupId) {
$get_acf_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in (%s)", array($groupId) ) );
if ( ! empty( $get_acf_fields ) ) {
$group_field_arr = array();
$repeater_field_arr = array();
foreach ( $get_acf_fields as $acf_pro_fields ) {
$get_field_content = unserialize( $acf_pro_fields->post_content );
if ( $get_field_content['type'] == 'repeater' ) {
$repeater_field_arr[] = $acf_pro_fields->ID . ",";
foreach($repeater_field_arr as $repeater_field ) {
$get_sub_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in (%s)", array($repeater_field) ) );
foreach ( $get_sub_fields as $get_sub_key ) {
$get_sub_field_content = unserialize( $get_sub_key->post_content );
if ( $get_sub_field_content['type'] == 'repeater' || $get_sub_field_content['type'] == 'group') {
$repeater_field_arr[] .= $get_sub_key->ID . ",";
}
}
}
}
if ( $get_field_content['type'] == 'group' ) {
$group_field_arr[] = $acf_pro_fields->ID . ",";
foreach($group_field_arr as $group_field){
$get_sub_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in (%s)", array($group_field) ) );
foreach ( $get_sub_fields as $get_sub_key ) {
$get_sub_field_content = unserialize( $get_sub_key->post_content );
$subfield_id =$get_sub_key->ID;
if ( $get_sub_field_content['type'] == 'group' ) {
$group_field_arr[] .= $get_sub_key->ID . ",";
}
if ( $get_sub_field_content['type'] == 'repeater' ) {
$group_field_arr[] .= $get_sub_key->ID . ",";
}
}
}
}
if ( $get_field_content['type'] == 'flexible_content' ) {
$flexible_field_arr .= $acf_pro_fields->ID . ",";
} else if ( $get_field_content['type'] == 'message' || $get_field_content['type'] == 'tab' ) {
$customFields["ACF"][ $acf_pro_fields->post_name ]['label'] = $acf_pro_fields->post_title;
$customFields["ACF"][ $acf_pro_fields->post_name ]['name'] = $acf_pro_fields->post_name;
}
else if ( $acf_pro_fields->post_excerpt != null || $acf_pro_fields->post_excerpt != '' ) {
if(($get_field_content['type'] !== 'group')&&($get_field_content['type'] !== 'repeater')){
$customFields["ACF"][ $acf_pro_fields->post_name ]['label'] = $acf_pro_fields->post_title;
$customFields["ACF"][ $acf_pro_fields->post_name ]['name'] = $acf_pro_fields->post_excerpt;
}
}
}
}
$flexible_field_arr = substr( $flexible_field_arr, 0, - 1 );
$repeater_fields = $repeater_field_arr;
$group_fields = $group_field_arr;
$flexible_fields = explode(',', $flexible_field_arr);
$repeater_field_placeholders = array_fill(0, count($repeater_fields), '%s');
$group_field_placeholders = array_fill(0, count($group_fields), '%s');
$flexible_field_placeholders = array_fill(0, count($flexible_fields), '%s');
// Put all the placeholders in one string %s, %s, %s, %s, %s,…’
$placeholdersForGroupFields = implode(', ', $group_field_placeholders);
$placeholdersForRepeaterFields = implode(', ', $repeater_field_placeholders);
$placeholdersForFlexibleFields = implode(', ', $flexible_field_placeholders);
if ( ! empty( $repeater_field_arr ) ) {
$query = "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in ($placeholdersForRepeaterFields)";
$get_acf_repeater_fields = $wpdb->get_results( $wpdb->prepare( $query, $repeater_fields ) );
}
if ( ! empty( $group_field_arr ) ) {
$query1 = "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in ($placeholdersForGroupFields)";
$get_acf_group_fields = $wpdb->get_results( $wpdb->prepare( $query1, $group_fields ) );
}
if ( ! empty( $get_acf_repeater_fields ) ) {
foreach ( $get_acf_repeater_fields as $acf_pro_repeater_fields ) {
$get_sub_field_content = unserialize( $acf_pro_repeater_fields->post_content );
if($get_sub_field_content['type'] == 'repeater') {
$repeaterSubFields = $this->fetchACFProRepeaterFields($acf_pro_repeater_fields->ID);
// if (is_array($repeaterSubFields) || is_object($repeaterSubFields)){
// if(is_object($customFields['RF'])){
$customFields['RF'] = is_array($customFields['RF']) ? $customFields['RF'] : [];
$customFields['RF'] = array_merge($repeaterSubFields,$customFields['RF']);
// }
// }
} else {
$rep_customFields[ $acf_pro_repeater_fields->post_title ] = $acf_pro_repeater_fields->post_excerpt;
$check_exist_key = "ACF: " . $acf_pro_repeater_fields->post_title;
if ( array_key_exists( $check_exist_key, $customFields ) ) {
unset( $customFields[ $check_exist_key ] );
}
if(($get_sub_field_content['type'] !== 'repeater')&&($get_sub_field_content['type'] !== 'group')){
$customFields["RF"][ $acf_pro_repeater_fields->post_name ]['label'] = $acf_pro_repeater_fields->post_title;
//changed
$customFields["RF"][ $acf_pro_repeater_fields->post_name ]['id'] = $acf_pro_repeater_fields->post_name;
$customFields["RF"][ $acf_pro_repeater_fields->post_name ]['name'] = $acf_pro_repeater_fields->post_excerpt;
$customFields["RF"][ $acf_pro_repeater_fields->post_name ]['backend_id'] = $acf_pro_repeater_fields->post_name;
}
}
}
}
if ( ! empty( $get_acf_group_fields ) ) {
foreach ( $get_acf_group_fields as $acf_pro_group_fields ) {
$get_sub_field_content = unserialize( $acf_pro_group_fields->post_content );
$rep_customFields[ $acf_pro_group_fields->post_title ] = $acf_pro_group_fields->post_excerpt;
$check_exist_key = "ACF: " . $acf_pro_group_fields->post_title;
if ( array_key_exists( $check_exist_key, $customFields ) ) {
unset( $customFields[ $check_exist_key ] );
}
if(($get_sub_field_content['type'] !== 'group')&&($get_sub_field_content['type'] !== 'repeater')){
$customFields["GF"][ $acf_pro_group_fields->post_name ]['label'] = $acf_pro_group_fields->post_title;
//changed
$customFields["GF"][ $acf_pro_group_fields->post_name ]['id'] = $acf_pro_group_fields->post_name;
$customFields["GF"][ $acf_pro_group_fields->post_name ]['name'] = $acf_pro_group_fields->post_excerpt;
$customFields["GF"][ $acf_pro_group_fields->post_name ]['backend_id'] = $acf_pro_group_fields->post_name;
}
}
}
if ( ! empty( $flexible_field_arr ) ) {
$query = "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in ($placeholdersForFlexibleFields)";
$get_acf_flexible_content_fields = $wpdb->get_results( $wpdb->prepare( $query, $flexible_fields ) );
}
if ( ! empty( $get_acf_flexible_content_fields ) ) {
foreach ( $get_acf_flexible_content_fields as $acf_pro_fc_fields ) {
$fc_customFields[ $acf_pro_fc_fields->post_title ] = $acf_pro_fc_fields->post_excerpt;
$check_exist_key = "FC: " . $acf_pro_fc_fields->post_title;
if ( array_key_exists( $check_exist_key, $customFields ) ) {
unset( $customFields[ $check_exist_key ] );
}
$get_sub_field_content = unserialize( $acf_pro_fc_fields->post_content );
if($get_sub_field_content['type'] !== 'flexible_content'){
if($get_sub_field_content['type'] == 'repeater'){
$inner_flexi_rep_query = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent = $acf_pro_fc_fields->ID ");
foreach($inner_flexi_rep_query as $inner_flexi_rep_values){
$customFields["FC"][ $inner_flexi_rep_values->post_name ]['label'] = $inner_flexi_rep_values->post_title;
//changed
$customFields["FC"][ $inner_flexi_rep_values->post_name ]['id'] = $inner_flexi_rep_values->post_name;
$customFields["FC"][ $inner_flexi_rep_values->post_name ]['name'] = $inner_flexi_rep_values->post_excerpt;
$customFields["FC"][ $inner_flexi_rep_values->post_name ]['backend_id'] = $inner_flexi_rep_values->post_name;
}
}
if($get_sub_field_content['type'] == 'group'){
$inner_flexi_grp_query = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent = $acf_pro_fc_fields->ID ");
foreach($inner_flexi_grp_query as $inner_flexi_grp_values){
$customFields["FC"][ $inner_flexi_grp_values->post_name ]['label'] = $inner_flexi_grp_values->post_title;
//changed
$customFields["FC"][ $inner_flexi_grp_values->post_name ]['id'] = $inner_flexi_grp_values->post_name;
$customFields["FC"][ $inner_flexi_grp_values->post_name ]['name'] = $inner_flexi_grp_values->post_excerpt;
$customFields["FC"][ $inner_flexi_grp_values->post_name ]['backend_id'] = $inner_flexi_grp_values->post_name;
}
}
else{
$flexible_fields1[] = $acf_pro_fc_fields->ID;
$customFields["FC"][ $acf_pro_fc_fields->post_name ]['label'] = $acf_pro_fc_fields->post_title;
//changed
$customFields["FC"][ $acf_pro_fc_fields->post_name ]['id'] = $acf_pro_fc_fields->post_name;
$customFields["FC"][ $acf_pro_fc_fields->post_name ]['name'] = $acf_pro_fc_fields->post_excerpt;
$customFields["FC"][ $acf_pro_fc_fields->post_name ]['backend_id'] = $acf_pro_fc_fields->post_name;
}
}
if($get_sub_field_content['type'] == 'flexible_content'){
$inner_flexi_query = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent = $acf_pro_fc_fields->ID ");
foreach($inner_flexi_query as $inner_flexi_values){
$customFields["FC"][ $inner_flexi_values->post_name ]['label'] = $inner_flexi_values->post_title;
//changed
$customFields["FC"][ $inner_flexi_values->post_name ]['id'] = $inner_flexi_values->post_name;
$customFields["FC"][ $inner_flexi_values->post_name ]['name'] = $inner_flexi_values->post_excerpt;
$customFields["FC"][ $inner_flexi_values->post_name ]['backend_id'] = $inner_flexi_values->post_name;
}
}
}
foreach($flexible_fields as $flexible_id){
$get_flexible_group = $wpdb->get_results("SELECT post_title , post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND ID = $flexible_id");
foreach($get_flexible_group as $get_flexible_value){
foreach($customFields["FC"] as $flexible_key => $flexible_value){
$customFields["FC"][$get_flexible_value->post_excerpt]['label'] = $get_flexible_value->post_title;
//changed
$customFields["FC"][$get_flexible_value->post_excerpt]['id'] = $get_flexible_value->post_name;
$customFields["FC"][$get_flexible_value->post_excerpt]['name'] = $get_flexible_value->post_excerpt;
$customFields["FC"][ $get_flexible_value->post_excerpt ]['backend_id'] = $get_flexible_value->post_name;
}
}
}
}
}
}
$requested_group_fields = array();
if(!empty($customFields[$group]))
$requested_group_fields[$group] = $customFields[$group];
$acf_pro_value = $this->convert_fields_to_array($requested_group_fields);
return $acf_pro_value;
}
public function fetchACFProRepeaterFields($repeater_field) {
global $wpdb;
$customFields = $rep_customFields = array();
$repeater_field_arr = '';
$get_sub_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' and post_parent in (%s)", array($repeater_field) ) );
foreach ( $get_sub_fields as $get_sub_key ) {
$get_sub_field_content = unserialize( $get_sub_key->post_content );
if ( $get_sub_field_content['type'] == 'repeater' || $get_sub_field_content['type'] == 'group') {
$repeater_field_arr .= $get_sub_key->ID . ",";
}
}
$repeater_field_arr = substr( $repeater_field_arr, 0, - 1 );
$repeater_fields = explode(',', $repeater_field_arr);
$repeater_field_placeholders = array_fill(0, count($repeater_fields), '%s');
$placeholdersForRepeaterFields = implode(', ', $repeater_field_placeholders);
if ( ! empty( $repeater_field_arr ) ) {
$query = "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_parent in ($placeholdersForRepeaterFields)";
$get_acf_repeater_fields = $wpdb->get_results( $wpdb->prepare( $query, $repeater_fields ) );
}
if ( ! empty( $get_acf_repeater_fields ) ) {
foreach ( $get_acf_repeater_fields as $acf_pro_repeater_fields ) {
$rep_customFields[ $acf_pro_repeater_fields->post_title ] = $acf_pro_repeater_fields->post_excerpt;
$check_exist_key = "ACF: " . $acf_pro_repeater_fields->post_title;
if ( array_key_exists( $check_exist_key, $customFields ) ) {
unset( $customFields[ $check_exist_key ] );
}
$customFields[ $acf_pro_repeater_fields->post_name ]['label'] = $acf_pro_repeater_fields->post_title;
$customFields[ $acf_pro_repeater_fields->post_name ]['name'] = $acf_pro_repeater_fields->post_excerpt;
}
}
return $customFields;
}
/**
* ACF Pro extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('advanced-custom-fields-pro/acf.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='Users' || $import_type =='WooCommerce'|| $import_type =='Taxonomies' || $import_type =='Tags' || $import_type =='Categories') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
class AllInOneSeoExtension extends ExtensionHandler
{
private static $instance = null;
public static function getInstance()
{
if (AllInOneSeoExtension::$instance == null)
{
AllInOneSeoExtension::$instance = new AllInOneSeoExtension;
}
return AllInOneSeoExtension::$instance;
}
/**
* Provides All In One Seo mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data)
{
$response = [];
$all_in_one_seo_Fields = array(
'NO INDEX' => 'noindex',
'NO FOLLOW' => 'nofollow',
'Canonical URL' => 'custom_link',
'Disable Analytics' => 'disable_analytics',
'NO ODP' => 'noodp',
'NO YDIR' => 'noydir',
'SEO Title' => 'aioseo_title',
'SEO description' => 'aioseo_description',
'Facebook Title' => 'og_title',
'Facebook Description' => 'og_description',
'Facebook Image Source' => 'og_image_type',
'Facebook Custom Image' => 'og_image_custom_url',
'Facebook Image Custom Fields' => 'og_image_custom_fields',
'Video URL' => 'og_video',
'Object Type' => 'og_object_type',
'Disable' => 'disable',
'Article Section' => 'og_article_section',
'Article Tags' => 'og_article_tags',
'Use Data from Facebook Tab' => 'twitter_use_og',
'Twitter Card Type' => 'twitter_card',
'Twitter Custom Image' => 'twitter_image_custom_url',
'Twitter Image Source' => 'twitter_image_type',
'TwitterImage Custom Fields' => 'twitter_image_custom_fields',
'Twitter Title' => 'twitter_title',
'Twitter Description' => 'twitter_description',
'Robots Settings' => 'robots_default',
'Robots No Archive' => 'robots_noarchive',
'Robots No Snippet' => 'robots_nosnippet',
'Robots No Image Index' => 'robots_noimageindex',
'Robots No Translate' => 'robots_notranslate',
'Robots Max Snippet' => 'robots_max_snippet',
'Robots Max Video Preview' => 'robots_max_videopreview',
'Robots Max Image Preview' => 'robots_max_imagepreview',
'Keyphrases' => 'keyphrases'
);
$all_in_one_seo_value = $this->convert_static_fields_to_array($all_in_one_seo_Fields);
$response['all_in_one_seo_fields'] = $all_in_one_seo_value;
return $response;
}
/**
* All In One Seo extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type)
{
if (is_plugin_active('all-in-one-seo-pack/all_in_one_seo_pack.php') || is_plugin_active('all-in-one-seo-pack-pro/all_in_one_seo_pack.php'))
{
if ($import_type == 'nav_menu_item')
{
return false;
}
$import_type = $this->import_name_as($import_type);
if ($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'WooCommerce')
{
return true;
}
else
{
return false;
}
}
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class BBPressExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (BBPressExtension::$instance == null) {
BBPressExtension::$instance = new BBPressExtension;
}
return BBPressExtension::$instance;
}
public function processExtension($data){
$import_type = $data;
$response = [];
//$import_type = $this->import_type_as($import_type);
if(is_plugin_active('bbpress/bbpress.php')){
if($import_type == 'forum'){
$bbpress_meta_fields = array(
'Type' => '_bbp_forum_type',
'Status' => '_bbp_status',
'Visibility' => 'Visibility',
'Forum Moderators' => 'bbp_moderators'
);
}
if($import_type == 'topic'){
$bbpress_meta_fields = array(
'Forum ID' => '_bbp_forum_id',
'Topic Status' => 'topic_status',
'Author' => 'author',
'Author IP' => '_bbp_author_ip',
'Topic Type' =>'topic_type',
);
}
if($import_type == 'reply'){
$bbpress_meta_fields = array(
'Forum ID' => '_bbp_forum_id',
'Topic ID' => '_bbp_topic_id',
'Reply Status' => 'reply_status',
'Reply author' => 'reply_author',
'Author IP' => '_bbp_author_ip',
'Reply' => 'reply'
);
}
}
$bbpress_meta_field_key = $this->convert_static_fields_to_array($bbpress_meta_fields);
if($data == 'forum'){
$response['forum_attributes_fields'] = $bbpress_meta_field_key;
}
if($data == 'topic'){
$response['topic_attributes_fields'] = $bbpress_meta_field_key;
}
if($data == 'reply'){
$response['reply_attributes_fields'] = $bbpress_meta_field_key;
}
return $response;
}
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('bbpress/bbpress.php')){
if($import_type == 'forum' || $import_type == 'topic' || $import_type == 'reply') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,52 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class BPExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (BPExtension::$instance == null) {
BPExtension::$instance = new BPExtension;
}
return BPExtension::$instance;
}
public function processExtension($data, $process_type = null ){
global $wpdb;
$response = [];
$all_buddy_fields = [];
$get_BPfields = $wpdb->get_results("SELECT id, name FROM {$wpdb->prefix}bp_xprofile_fields where type !='option'", ARRAY_A);
foreach($get_BPfields as $get_buddy_fields){
if($process_type == 'Export'){
$all_buddy_fields[$get_buddy_fields['name']] = $get_buddy_fields['name'];
}
else{
$all_buddy_fields[$get_buddy_fields['name']] = $get_buddy_fields['id'];
}
}
$bp_fields_key = $this->convert_static_fields_to_array($all_buddy_fields);
$response['bp_fields'] = $bp_fields_key;
return $response;
}
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('buddypress/bp-loader.php')){
if($import_type == 'Users'){
return true;
}
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class CCTMExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (CCTMExtension::$instance == null) {
CCTMExtension::$instance = new CCTMExtension;
}
return CCTMExtension::$instance;
}
/**
* Provides CCTM mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
$response['cctm_fields'] = null;
return $response;
}
/**
* CCTM extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('custom-content-type-manager/index.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='event' || $import_type =='location' || $import_type == 'event-recurring' || $import_type =='Users' || $import_type =='WooCommerce' || $import_type =='WPeCommerce') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,80 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class CFSExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (CFSExtension::$instance == null) {
CFSExtension::$instance = new CFSExtension;
}
return CFSExtension::$instance;
}
/**
* Provides CFS mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
global $wpdb;
$customFields = $cfs_field = array();
$get_cfs_groups = $wpdb->get_results($wpdb->prepare("select ID from {$wpdb->prefix}posts where post_type = %s and post_status = %s", 'cfs' , 'publish'),ARRAY_A);
$group_id_arr = [];
foreach ( $get_cfs_groups as $item => $group_rules ) {
$group_id_arr[] .= $group_rules['ID'] . ',';
}
if($group_id_arr != '') {
foreach($group_id_arr as $group_id){
$get_cfs_fields[]= $wpdb->get_results( $wpdb->prepare("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id IN (%s) and meta_key =%s ",$group_id,'cfs_fields'), ARRAY_A);
}
}
// Available CFS fields
if (!empty($get_cfs_fields)) {
foreach ($get_cfs_fields as $key => $value) {
$get_cfs_field = @unserialize($value[0]['meta_value']);
foreach($get_cfs_field as $fk => $fv){
$customFields["CFS"][$fv['name']]['label'] = $fv['label'];
$customFields["CFS"][$fv['name']]['name'] = $fv['name'];
$cfs_field[] = $fv['name'];
}
}
}
$cfs_value = $this->convert_fields_to_array($customFields);
$response['custom_fields_suite_fields'] = $cfs_value;
return $response;
}
/**
* CFS extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('custom-field-suite/cfs.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'event-recurring') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,55 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class CMB2Extension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (CMB2Extension::$instance == null) {
CMB2Extension::$instance = new CMB2Extension;
}
return CMB2Extension::$instance;
}
/**
* Provides CMB2 mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
$response['cmb2_fields'] = null;
return $response;
}
/**
* CMB2 extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('cmb2/init.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'event-recurring' ) {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class EPOExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (EPOExtension::$instance === null) {
EPOExtension::$instance = new EPOExtension();
}
return EPOExtension::$instance;
}
/**
* Provides EPO Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
// Fetch the option data
$option_data = get_option('thwepof_custom_sections');
// Unserialize the data safely
$unserialized_data = maybe_unserialize($option_data);
$pro_meta_fields = []; // Initialize the variable
// Validate the structure of the unserialized data
if (is_array($unserialized_data) && isset($unserialized_data['default']) && is_object($unserialized_data['default']) && isset($unserialized_data['default']->fields)) {
foreach ($unserialized_data['default']->fields as $field_key => $field_object) {
// Collect the field keys
$pro_meta_fields[$field_key] = $field_key;
}
}
$pro_meta_fields = $this->convert_static_fields_to_array($pro_meta_fields);
// Prepare the response
$response['epo_meta_fields'] = $pro_meta_fields;
return $response;
}
/**
* EPO Meta extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type) {
if (is_plugin_active('woo-extra-product-options/woo-extra-product-options.php')) {
$import_type = $this->import_name_as($import_type);
if ($import_type === 'WooCommerceOrders') {
return true;
}
else {
return false;
}
}
return false;
}
}

View File

@@ -0,0 +1,80 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ElementorExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ElementorExtension::$instance == null) {
ElementorExtension::$instance = new ElementorExtension;
}
return ElementorExtension::$instance;
}
/**
* Provides Product Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
// $import_type = $this->import_type_as($import_type);
$import_type = $this->import_name_as($import_type);
if( is_plugin_active('elementor/elementor.php') || is_plugin_active('elementor-pro/elementor-pro.php') ){
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'WooCommerce Product' || $import_type == 'CustomPosts'){
$pro_meta_fields = array(
'Elementor Template Type' => '_elementor_template_type',
'Elementor Version' => '_elementor_version',
'Elementor Pro Version' => '_elementor_pro_version',
'Page Template' => '_wp_page_template',
'Elementor Edit Mode' => '_elementor_edit_mode',
'Elementor Library Type' => 'elementor_library_type',
'Elementor Controls Usage' => '_elementor_controls_usage',
'Elementor Library Category' => 'elementor_library_category',
'Elementor CSS' => '_elementor_css',
'Elementor Conditions' => '_elementor_conditions',
'Elementor Page Assets' =>'_elementor_page_assets',
'Elementor Page Settings' => '_elementor_page_settings',
'Elementor Data' => '_elementor_data'
);
}
}
$pro_meta_fields_line = $this->convert_static_fields_to_array($pro_meta_fields);
$response['elementor_meta_fields'] = $pro_meta_fields_line;
return $response;
}
/**
* Product Meta extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
$import_type = $this->import_name_as($import_type);
if( is_plugin_active('elementor/elementor.php') || is_plugin_active('elementor-pro/elementor-pro.php')){
if($import_type == 'elementor_library' || $import_type == 'Pages' || $import_type == 'Posts' || $import_type == 'WooCommerce Product' || $import_type == 'CustomPosts') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,102 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class EventsManagerExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (EventsManagerExtension::$instance == null) {
EventsManagerExtension::$instance = new EventsManagerExtension;
}
return EventsManagerExtension::$instance;
}
/**
* Provides Events Manager mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
$import_type = $data;
if($import_type != 'Tickets' && $import_type != 'Recurring Events'){
$events_manager_Fields = array(
'Event_start_date' => 'event_start_date',
'Event_end_date' => 'event_end_date',
'Event_start_time' => 'event_start_time',
'Event_end_time' => 'event_end_time',
'Event_all_day' => 'event_all_day',
'Event_rsvp_date' => 'event_rsvp_date',
'Event_rsvp_time' => 'event_rsvp_time',
'Event_rsvp_spaces' => 'event_rsvp_spaces',
'Event_spaces' => 'event_spaces',
'Recurrence_interval' => 'recurrence_interval',
'Recurrence_freq' => 'recurrence_freq',
'Recurrence_byday' => 'recurrence_byday',
'Recurrence_byweekno'=>'recurrence_byweekno',
'Recurrence_days' => 'recurrence_days',
'Recurrence_rsvp_days' => 'recurrence_rsvp_days',
'Location_name' => 'location_name',
'Location_address' => 'location_address',
'Location_town' =>'location_town',
'Location_state' => 'location_state',
'Location_postcode' => 'location_postcode',
'Location_region' => 'location_region',
'Location_country' => 'location_country',
'Ticket_name' => 'ticket_name',
'Ticket_description' => 'ticket_description',
'Ticket_price' => 'ticket_price',
'Ticket_start_date' => 'ticket_start_date',
'Ticket_end_date' => 'ticket_end_date',
'Ticket_start_time' => 'ticket_start_time',
'Ticket_end_time' => 'ticket_end_time',
'Ticket_min' => 'ticket_min',
'Ticket_max' => 'ticket_max',
'Ticket_start_recurring_days'=>'ticket_start_recurring_days',
'Ticket_end_recurring_days'=>'ticket_end_recurring_days',
'Ticket_spaces' => 'ticket_spaces',
'Ticket_members' => 'ticket_members',
'Ticket_members_roles' =>'ticket_members_roles',
'Ticket_guests' => 'ticket_guests',
'Ticket_required' => 'ticket_required',
);
}
$events_manager_values = $this->convert_static_fields_to_array($events_manager_Fields);
$response['events_manager_fields'] = $events_manager_values;
// $response['events_manager_fields'] = null;
return $response;
}
/**
* Events Manager extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('events-manager/events-manager.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='event' || $import_type =='location' || $import_type == 'event-recurring' || $import_type == 'ticket') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class FIFUExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (FIFUExtension::$instance == null) {
FIFUExtension::$instance = new FIFUExtension;
}
return FIFUExtension::$instance;
}
/**
* Provides FIFU mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$mode = isset($_POST['Mode']) ? sanitize_text_field($_POST['Mode']) : "";
$import_type = $data;
$response = [];
if(is_plugin_active('featured-image-from-url/featured-image-from-url.php')){
if($import_type == 'Posts'){
$fifu_meta_fields = array(
'Fifu image url' => 'fifu_image_url',
'Fifu image alt' => 'fifu_image_alt',
);
}elseif($import_type == 'Pages'){
$fifu_meta_fields = array(
'Fifu image url' => 'fifu_image_url',
'Fifu image alt' => 'fifu_image_alt',
);
}else{
$fifu_meta_fields = array(
'Fifu image url' => 'fifu_image_url',
'Fifu image alt' => 'fifu_image_alt',
);
}
}
$fifu_meta_fields_line = $this->convert_static_fields_to_array($fifu_meta_fields);
if($data == 'Posts'){
$response['fifu_post_settings_fields'] = $fifu_meta_fields_line;
}elseif($data == 'Pages'){
$response['fifu_page_settings_fields'] = $fifu_meta_fields_line;
}else{
$response['fifu_custompost_settings_fields'] = $fifu_meta_fields_line;
}
return $response;
}
/**
* FIFU extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('featured-image-from-url/featured-image-from-url.php')){
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class FeaturedMediaExtension extends ExtensionHandler{
public static $instance = null;
public static function getInstance() {
if (FeaturedMediaExtension::$instance == null) {
FeaturedMediaExtension::$instance = new FeaturedMediaExtension;
}
return FeaturedMediaExtension::$instance;
}
/**
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$mode = isset($_POST['Mode']) ? sanitize_text_field($_POST['Mode']) : '';
$import_types = $data;
$import_type = $this->import_name_as($import_types);
$response = [];
if( $import_type == "Posts" || $import_type == "Pages" || $import_type == "CustomPosts" || $import_type == "WooCommerce"){
$wordpressfields = array(
'Title' => 'featured_image_title',
'Caption' => 'featured_image_caption',
'Alt text' => 'featured_image_alt_text',
'Description' => 'featured_image_description',
'File Name' => 'featured_file_name'
);
$wordpress_value = $this->convert_static_fields_to_array($wordpressfields);
$response['featured_fields'] = $wordpress_value ;
}
return $response;
}
/**
* CFS extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if( $import_type == "Posts" || $import_type == "Pages" || $import_type == "CustomPosts" || $import_type == "WooCommerce" || $import_types == "wp_font_family" || $import_types == "wp_font_face" || $import_types == 'wp_global_style' || $import_types == 'wp_template'){
return true;
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class JetBookingExtension extends ExtensionHandler
{
private static $instance = null;
public static function getInstance()
{
if (JetBookingExtension::$instance == null) {
JetBookingExtension::$instance = new JetBookingExtension;
}
return JetBookingExtension::$instance;
}
/**
* Provides JetBookingExtension Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data)
{
$import_type = $data;
$response = [];
$import_type = trim($this->import_post_types($import_type));
$post_type = trim(jet_abaf()->settings->get( 'apartment_post_type' ));
if (is_plugin_active('jet-booking/jet-booking.php') && isset($import_type) && isset($post_type) && $import_type == $post_type) {
$jet_meta_fields = array(
'Pricing Settings' => 'jet_abaf_price',
'Custom Schedule' => 'jet_abaf_custom_schedule',
'Date Picker Config' => 'jet_abaf_configuration',
'Unit Titles' => 'unit_title',
'Unit Number' => 'unit_number',
);
}
$jet_meta_fields = isset($jet_meta_fields) ? $jet_meta_fields : '';
$jet_booking_fields = $this->convert_static_fields_to_array($jet_meta_fields);
$response['jet_booking_fields'] = $jet_booking_fields;
return $response;
}
public function import_post_types($import_type, $importAs = null) {
$import_type = trim($import_type);
$module = array('Posts' => 'post', 'Pages' => 'page', 'JetReviews' => 'jet_reviews', 'Users' => 'user', 'Comments' => 'comments', 'Taxonomies' => $importAs, 'CustomerReviews' =>'wpcr3_review', 'Categories' => 'categories', 'Tags' => 'tags', 'WooCommerce' => 'product', 'WPeCommerce' => 'wpsc-product','WPeCommerceCoupons' => 'wpsc-product','WooCommerceOrders' => 'product', 'WooCommerceCoupons' => 'product', 'WooCommerceRefunds' => 'product', 'CustomPosts' => $importAs,'WooCommerceReviews' =>'reviews','GFEntries' => 'gfentries');
foreach (get_taxonomies() as $key => $taxonomy) {
$module[$taxonomy] = $taxonomy;
}
if(array_key_exists($import_type, $module)) {
return $module[$import_type];
}
else {
return $import_type;
}
}
/**
* Product Meta extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type)
{
if (is_plugin_active('jet-booking/jet-booking.php')) {
$import_type = $this->import_name_as($import_type);
if ($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'WooCommerce') {
return true;
} else {
return false;
}
}
}
}

View File

@@ -0,0 +1,124 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class JetEngineCCTExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (JetEngineCCTExtension::$instance == null) {
JetEngineCCTExtension::$instance = new JetEngineCCTExtension;
}
return JetEngineCCTExtension::$instance;
}
/**
* Provides default mapping fields for Jet Engine Pro plugin
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
$jet_engine_cct_fields = $this->JetEngineCCTFields($import_type);
$response['jetenginecct_fields'] = $jet_engine_cct_fields;
//$jet_engine_cct_rf_fields = $this->JetEngineCCTRFFields($import_type);
//$response['jetenginecct_rf_fields'] = $jet_engine_cct_rf_fields;
return $response;
}
/**
* Retrieves Jet Engine mapping fields
* @param string $import_type - selected import type
* @return array - mapping fields
*/
public function JetEngineCCTFields($import_type) {
global $wpdb;
$get_meta_fields = $wpdb->get_row(
$wpdb->prepare("SELECT meta_fields, args FROM {$wpdb->prefix}jet_post_types WHERE slug = %s AND status = %s",
$import_type,
'content-type'
));
// Initialize variables
$unserialized_meta = '';
$has_single_page = false;
$customFields = [];
if ($get_meta_fields) {
$unserialized_meta = maybe_unserialize($get_meta_fields->meta_fields);
$arg_data = maybe_unserialize($get_meta_fields->args);
if (!empty($arg_data) && !empty($arg_data['has_single'])) {
$has_single_page = $arg_data['has_single'];
}
}
if (is_array($unserialized_meta)) {
foreach ($unserialized_meta as $jet_key => $jet_value) {
$jet_field_label = $jet_value['title'];
$jet_field_name = $jet_value['name'];
$jet_field_type = $jet_value['type'];
$fields_object_type = $jet_value['object_type'];
if ($fields_object_type == 'field' && $jet_field_type != 'repeater' && $jet_field_type != 'html') {
$customFields["JECCT"][$jet_key] = [
'label' => $jet_field_label,
'name' => $jet_field_name
];
}
}
if ($has_single_page) {
$single_page_fields = ['CCT Single Post ID' => 'cct_single_post_id','CCT Single Post Title' => 'cct_single_post_title','CCT Single Post Content' => 'cct_single_post_content'];
foreach ($single_page_fields as $label => $name) {
$customFields["JECCT"][] = [
'label' => $label,
'name' => $name
];
}
}
}
// Convert custom fields to array if available
$jet_value = !empty($customFields) ? $this->convert_fields_to_array($customFields) : '';
return $jet_value;
}
/**
* Jet Engine extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('jet-engine/jet-engine.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type == 'jet-engine'||$import_type =='event' || $import_type =='location' || $import_type == 'event-recurring' || $import_type =='Users' || $import_type =='WooCommerce' || $import_type =='WooCommerceCategories' || $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type =='WPeCommerce' || $import_type =='Taxonomies' || $import_type =='Tags' || $import_type =='Categories' || $import_type == 'CustomerReviews' || $import_type ='Comments') {
return true;
}
if($import_type == 'ticket'){
if(is_plugin_active('events-manager/events-manager.php')){
return false;
}else{
return true;
}
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,100 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class JetEngineCPTExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (JetEngineCPTExtension::$instance == null) {
JetEngineCPTExtension::$instance = new JetEngineCPTExtension;
}
return JetEngineCPTExtension::$instance;
}
/**
* Provides default mapping fields for Jet Engine Pro plugin
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
$jet_engine_cpt_fields = $this->JetEngineCPTFields($import_type);
if(!empty($jet_engine_cpt_fields))
$response['jetenginecpt_fields'] = $jet_engine_cpt_fields;
return $response;
}
/**
* Retrieves Jet Engine custom post mapping fields
* @param string $import_type - selected import type
* @return array - mapping fields
*/
public function JetEngineCPTFields($import_type) {
global $wpdb;
//$get_meta_fields = $wpdb->get_results($wpdb->prepare("SELECT id, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = %s AND status = %s", $import_type, 'publish'));
$import_type = $this->import_post_types($import_type);
if($import_type == 'WooCommerce Product'){
$import_type = 'product';
}
$get_meta_fields = $wpdb->get_results("SELECT id, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE slug = '$import_type' AND status IN ('publish','built-in')");
if(isset($get_meta_fields[0])){
$unserialized_meta = maybe_unserialize($get_meta_fields[0]->meta_fields);
}
else{
$unserialized_meta = '';
}
if(is_array($unserialized_meta)){
foreach($unserialized_meta as $jet_key => $jet_value){
$jet_field_label = $jet_value['title'];
$jet_field_name = $jet_value['name'];
$jet_field_type = $jet_value['type'];
if($jet_field_type != 'repeater' && $jet_field_type != 'media' && $jet_field_type != 'gallery' && $jet_field_type != 'posts' && $jet_field_type != 'html' ){
$customFields["JECPT"][ $jet_key ]['label'] = $jet_field_label;
$customFields["JECPT"][ $jet_key ]['name'] = $jet_field_name;
}
}
}
if(isset($customFields)){
$jet_value = $this->convert_fields_to_array($customFields);
}
else{
$jet_value = '';
}
return $jet_value;
}
/**
* Jet Engine extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('jet-engine/jet-engine.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='event' || $import_type =='location' || $import_type == 'event-recurring' || $import_type =='Users' || $import_type =='WooCommerce' || $import_type =='WooCommerceCategories' || $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type =='WPeCommerce' || $import_type =='Taxonomies' || $import_type =='Tags' || $import_type =='Categories' || $import_type == 'CustomerReviews' || $import_type ='Comments') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,278 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class JetEngineExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (JetEngineExtension::$instance == null) {
JetEngineExtension::$instance = new JetEngineExtension;
}
return JetEngineExtension::$instance;
}
/**
* Provides default mapping fields for Jet Engine Pro plugin
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
$jet_engine_fields = $this->JetEngineFields($import_type);
$response['jetengine_fields'] = $jet_engine_fields;
$jet_engine_rf_fields = $this->JetEngineRFFields($import_type);
if(!empty($jet_engine_rf_fields)){
$response['jetengine_rf_fields'] = null;
}
return $response;
}
/**
* Retrieves Jet Engine mapping fields
* @param string $import_type - selected import type
* @return array - mapping fields
*/
public function JetEngineFields($import_type) {
$import_type = $this->import_post_types($import_type);
global $wpdb;
$get_meta_box_fields = $wpdb->get_results( $wpdb->prepare("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = %s",'jet_engine_meta_boxes'));
if(!empty($get_meta_box_fields)){
$unserialized_meta = maybe_unserialize($get_meta_box_fields[0]->option_value);
if(isset($unserialized_meta)){
$arraykeys = array_keys($unserialized_meta);
}
foreach($arraykeys as $val){
$values = explode('-',$val);
$v = $values[1];
}
$temp = 0;
if(isset($v)){
for($i=1 ; $i<=$v ; $i++){
$unserialized_meta['meta-'.$i] = isset($unserialized_meta['meta-'.$i]) ? $unserialized_meta['meta-'.$i] : '';
$fields = $unserialized_meta['meta-'.$i];
if(!empty($fields)){
$fields_object_type = $fields['args']['object_type'];
if($fields_object_type == 'post'){
$fields_allowed_post_type = $fields['args']['allowed_post_type'];
foreach($fields_allowed_post_type as $key => $fields_allowed_post_type_value){
if($fields_allowed_post_type_value == $import_type){
foreach($fields['meta_fields'] as $jet_key => $jet_value){
if($jet_value != 'repeater' && $jet_value != 'media' && $jet_value != 'gallery' && $jet_value != 'posts' && $jet_value != 'html' ){
$jet_field_label = $jet_value['title'];
$jet_field_name = $jet_value['name'];
$customFields["JE"][ $temp ]['label'] = $jet_field_label;
$customFields["JE"][ $temp ]['name'] = $jet_field_name;
$temp++;
}
}
}
}
}
if($fields_object_type == 'taxonomy'){
//if ($import_type == 'category' || $import_type == 'post_tag'|| $import_type == 'product_cat' || $import_type == 'product_tag'){
$allowed_tax = $fields['args']['allowed_tax'];
foreach($allowed_tax as $allowed_tax_key => $allowed_tax_val){
if($allowed_tax_val == $import_type){
foreach($fields['meta_fields'] as $jet_key => $jet_value){
if($jet_value != 'repeater' && $jet_value != 'media' && $jet_value != 'gallery' && $jet_value != 'posts' && $jet_value != 'html' ){
$jet_field_label = $jet_value['title'];
$jet_field_name = $jet_value['name'];
$customFields["JE"][ $temp ]['label'] = $jet_field_label;
$customFields["JE"][ $temp ]['name'] = $jet_field_name;
$temp++;
}
}
}
}
//}
}
if($fields_object_type == 'user'){
if($fields_object_type == $import_type){
foreach($fields['meta_fields'] as $jet_key => $jet_value){
if($jet_value != 'repeater' && $jet_value != 'media' && $jet_value != 'gallery' && $jet_value != 'posts' && $jet_value != 'html' ){
$jet_field_label = $jet_value['title'];
$jet_field_name = $jet_value['name'];
$customFields["JE"][ $temp ]['label'] = $jet_field_label;
$customFields["JE"][ $temp ]['name'] = $jet_field_name;
$temp++;
}
}
}
}
}
}
}
}
if(isset($customFields)){
$jet_value = $this->convert_fields_to_array($customFields);
}
else{
$jet_value = '';
}
return $jet_value;
}
public function JetEngineRFFields($import_type){
$import_type = $this->import_post_types($import_type);
global $wpdb;
$get_meta_fields = $wpdb->get_results( $wpdb->prepare("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = %s",'jet_engine_meta_boxes'));
if(!empty($get_meta_fields)){
$unserialized_meta = maybe_unserialize($get_meta_fields[0]->option_value);
if(isset($unserialized_meta)){
$arraykeys = array_keys($unserialized_meta);
}
foreach($arraykeys as $val){
$values = explode('-',$val);
$v = $values[1];
}
if(isset($v)){
for($i=1 ; $i<=$v ; $i++){
$unserialized_meta['meta-'.$i] = isset($unserialized_meta['meta-'.$i]) ? $unserialized_meta['meta-'.$i] : '';
$fields = $unserialized_meta['meta-'.$i];
if(!empty($fields)){
//foreach($fields as $jet_key => $jet_value){
$fields_object_type = $fields['args']['object_type'];
if($fields_object_type == 'post'){
$fields_allowed_post_type = $fields['args']['allowed_post_type'];
foreach($fields_allowed_post_type as $key => $fields_allowed_post_type_value){
if($fields_allowed_post_type_value == $import_type){
foreach($fields['meta_fields'] as $jet_key => $jet_value){
if($jet_value['type'] == 'repeater'){
$jet_rep_fields = $jet_value['repeater-fields'];
foreach($jet_rep_fields as $jet_rep_fkey => $jet_rep_fvalue){
$jet_field_label[] = $jet_rep_fvalue['title'];
$jet_field_name[]= $jet_rep_fvalue['name'];
// $customFields["JERF"][ $jet_rep_fkey ]['label'] =$jet_field_label;
// $customFields["JERF"][ $jet_rep_fkey ]['name'] = $jet_field_name;
}
}
}
}
}
}
if($fields_object_type == 'taxonomy'){
//if ($import_type == 'category' || $import_type == 'post_tag'){
$allowed_tax = $fields['args']['allowed_tax'];
foreach($allowed_tax as $allowed_tax_key => $allowed_tax_val){
if($allowed_tax_val == $import_type){
foreach($fields['meta_fields'] as $jet_key => $jet_value){
if($jet_value['type'] == 'repeater'){
$jet_rep_fields = $jet_value['repeater-fields'];
foreach($jet_rep_fields as $jet_rep_fkey => $jet_rep_fvalue){
$jet_field_label[] = $jet_rep_fvalue['title'];
$jet_field_name[] = $jet_rep_fvalue['name'];
//$customFields["JERF"][ $jet_rep_fkey ]['label'] =$jet_field_label;
//$customFields["JERF"][ $jet_rep_fkey ]['name'] = $jet_field_name;
}
}
}
}
}
//}
}
if($fields_object_type == 'user'){
if($fields_object_type == $import_type){
foreach($fields['meta_fields'] as $jet_key => $jet_value){
if($jet_value['type'] == 'repeater'){
$jet_rep_fields = $jet_value['repeater-fields'];
foreach($jet_rep_fields as $jet_rep_fkey => $jet_rep_fvalue){
$jet_field_label[] = $jet_rep_fvalue['title'];
$jet_field_name[] = $jet_rep_fvalue['name'];
//$customFields["JERF"][ $jet_rep_fkey ]['label'] =$jet_field_label;
//$customFields["JERF"][ $jet_rep_fkey ]['name'] = $jet_field_name;
}
}
}
}
}
//}
}
}
}
}
if(isset($jet_field_label)){
foreach($jet_field_label as $jet_label_key => $jet_label_value){
$customFields["JERF"][ $jet_label_key ]['label'] =$jet_label_value;
}
}
if(isset($jet_field_name)){
foreach($jet_field_name as $jet_name_key => $jet_name_value){
$customFields["JERF"][ $jet_name_key ]['name'] = $jet_name_value;
}
}
if(isset($customFields)){
$jet_value = $this->convert_fields_to_array($customFields);
}
else{
$jet_value = '';
}
//$jet_value = $this->convert_fields_to_array($customFields);
return $jet_value;
}
/**
* Jet Engine extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('jet-engine/jet-engine.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='Users' || $import_type =='WooCommerce' || $import_type =='Taxonomies' || $import_type =='Tags' || $import_type =='Categories') {
return true;
}
else{
return false;
}
}
}
function import_post_types($import_type, $importAs = null) {
$import_type = trim($import_type);
$module = array('Posts' => 'post', 'Pages' => 'page','WooCommerce Product' => 'product','WooCommerce' => 'product', 'CustomPosts' => $importAs);
foreach (get_taxonomies() as $key => $taxonomy) {
$module[$taxonomy] = $taxonomy;
}
if(array_key_exists($import_type, $module)) {
return $module[$import_type];
}
else {
return $import_type;
}
}
}

View File

@@ -0,0 +1,201 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class JetEngineRelationsExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (JetEngineRelationsExtension::$instance == null) {
JetEngineRelationsExtension::$instance = new JetEngineRelationsExtension;
}
return JetEngineRelationsExtension::$instance;
}
/**
* Provides default mapping fields for Jet Engine Pro plugin
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
$get_plugins_list = get_plugins();
$get_jetengine_plugin_version = $get_plugins_list['jet-engine/jet-engine.php']['Version'];
if($get_jetengine_plugin_version >= (int)'2.11.4'){
$jet_engine_fields = $this->JetEngineRelationsFields_New($import_type);
}
else{
$jet_engine_fields = $this->JetEngineRelationsFields($import_type);
}
$response['jetengine_rel_fields'] = $jet_engine_fields;
return $response;
}
/**
* Retrieves Jet Engine Relations mapping fields for jetengine version less than 2.11.4
* @param string $import_type - selected import type
* @return array - mapping fields
*/
public function JetEngineRelationsFields($import_type) {
global $wpdb;
$import_type = $this->import_post_types($import_type);
$get_import_types = $wpdb->get_results("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = 'jet_engine_relations' ");
if(!empty($get_import_types)){
$unserialized_meta = maybe_unserialize($get_import_types[0]->option_value);
if(isset($unserialized_meta)){
$arraykeys = array_keys($unserialized_meta);
}
foreach($arraykeys as $val){
$values = explode('-',$val);
$v = $values[1];
}
for($i=1 ; $i<=$v ; $i++){
$unserialized_meta['item-'.$i] = isset($unserialized_meta['item-'.$i]) ? $unserialized_meta['item-'.$i] : '';
$fields = $unserialized_meta['item-'.$i];
if(!empty($fields)){
$post_type_1 = $fields['post_type_1'];
$post_type_2 = $fields['post_type_2'];
if($import_type == $post_type_1 || $import_type == $post_type_2){
$customFields['JE']['relation_meta_key']['label'] = 'Jet Relation Metakey';
$customFields['JE']['relation_meta_key']['name'] = 'jet_relation_metakey';
$customFields['JE']['relation_meta_key']['slug'] = 'jet_relation_metakey';
$customFields['JE']['related_post']['label'] = 'Jet Related Post';
$customFields['JE']['related_post']['name'] = 'jet_related_post';
$customFields['JE']['related_post']['slug'] = 'jet_related_post';
}
}
}
}
if(isset($customFields)){
$jet_value = $this->convert_fields_to_array($customFields);
}
else{
$jet_value = '';
}
//$jet_value = $this->convert_fields_to_array($customFields);
return $jet_value;
}
/**
* Retrieves Jet Engine Relations mapping fields for jetengine version greater than 2.11.4
* @param string $import_type - selected import type
* @return array - mapping fields
*/
public function JetEngineRelationsFields_New($import_type) {
global $wpdb;
$get_rel_fields = $wpdb->get_results("SELECT id,labels, args, meta_fields FROM {$wpdb->prefix}jet_post_types WHERE status = 'relation' ", ARRAY_A);
if(!empty($get_rel_fields)){
$temp = 0;
foreach($get_rel_fields as $get_rel_values){
$jet_relation_names = maybe_unserialize($get_rel_values['labels']);
$jet_relation_name = maybe_unserialize($jet_relation_names['name']);
$jet_relation_type = maybe_unserialize($get_rel_values['args']);
$relate_type = $jet_relation_type['type'];
if($relate_type == 'one_to_one'){
$jet_relation_id = $get_rel_values['id'];
$get_rel_fields_args = maybe_unserialize($get_rel_values['args']);
$get_rel_parent_value = $get_rel_fields_args['parent_object'];
$get_rel_child_value = $get_rel_fields_args['child_object'];
$get_rel_parent1 = explode('::', $get_rel_parent_value);
$get_rel_parent = $get_rel_parent1[1];
$get_rel_child1 = explode('::', $get_rel_child_value);
$get_rel_child = $get_rel_child1[1];
$import_type = $this->import_post_types($import_type);
if($import_type == 'user'){
$import_type = 'users';
}
if($import_type == $get_rel_parent || $import_type == $get_rel_child){
$get_rel_metafields = maybe_unserialize($get_rel_values['meta_fields']);
foreach($get_rel_metafields as $get_rel_metavalue){
$customFields['JE'][$temp]['label'] = $get_rel_metavalue['title'];
$customFields['JE'][$temp]['name'] = $get_rel_metavalue['name'] . ' :: '.$jet_relation_id;
$temp++;
}
$customFields['JE'][$temp]['label'] = 'Jet Related Post' . ' :: '.$jet_relation_name;
$customFields['JE'][$temp]['name'] = 'jet_related_post' . ' :: '.$jet_relation_id;
$temp++;
}
}
}
}
if(isset($customFields)){
$jet_value = $this->convert_fields_to_array($customFields);
}
else{
$jet_value = '';
}
//$jet_value = $this->convert_fields_to_array($customFields);
return $jet_value;
}
/**
* Jet Engine extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('jet-engine/jet-engine.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='event' || $import_type =='location' || $import_type == 'event-recurring' || $import_type =='Users' || $import_type =='WooCommerce' || $import_type =='WooCommerceCategories' || $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type =='WPeCommerce' || $import_type =='Taxonomies' || $import_type =='Tags' || $import_type =='Categories' || $import_type == 'CustomerReviews' || $import_type ='Comments') {
return true;
}
if($import_type == 'ticket'){
if(is_plugin_active('events-manager/events-manager.php')){
return false;
}else{
return true;
}
}
else{
return false;
}
}
}
function import_post_types($import_type, $importAs = null) {
$import_type = trim($import_type);
$module = array('Posts' => 'post', 'Pages' => 'page', 'Users' => 'user', 'WooCommerce Product Variations' => 'product_variation', 'WooCommerce Refunds'=> 'shop_order_refund', 'WooCommerce Orders' => 'shop_order','WooCommerce Coupons' => 'shop_coupon', 'Comments' => 'comments', 'Taxonomies' => $importAs, 'WooCommerce Product' => 'product','WooCommerce' => 'product', 'CustomPosts' => $importAs);
foreach (get_taxonomies() as $key => $taxonomy) {
$module[$taxonomy] = $taxonomy;
}
if(array_key_exists($import_type, $module)) {
return $module[$import_type];
}
else {
return $import_type;
}
}
}

View File

@@ -0,0 +1,59 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class JetEngineTaxonomyExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (JetEngineTaxonomyExtension::$instance == null) {
JetEngineTaxonomyExtension::$instance = new JetEngineTaxonomyExtension;
}
return JetEngineTaxonomyExtension::$instance;
}
/**
* Provides default mapping fields for Jet Engine Pro plugin
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$response = [];
//$response['jetenginetaxonomy_fields'] = null;
//$response['jetenginetaxonomy_rf_fields'] = null;
return $response;
}
/**
* Jet Engine extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('jet-engine/jet-engine.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='event' || $import_type =='location' || $import_type == 'event-recurring' || $import_type =='Users' || $import_type =='WooCommerce' || $import_type =='WooCommerceCategories' || $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type =='WPeCommerce' || $import_type =='Taxonomies' || $import_type =='Tags' || $import_type =='Categories' || $import_type == 'CustomerReviews' || $import_type ='Comments') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,62 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class JobListingExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (JobListingExtension::$instance == null) {
JobListingExtension::$instance = new JobListingExtension;
}
return JobListingExtension::$instance;
}
/**
* Provides Job Manager mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
$jobFields = array(
'Application email/URL' => 'application',
'Company Website' => 'company_website',
'Company Twitter' => 'company_twitter',
'Position Filled' => 'filled',
'Listing Expiry Date' => 'job_expires',
'Location' => 'job_location',
'Company Name' => 'company_name',
'Company Tagline' => 'company_tagline',
'Company Video' => 'company_video',
'Featured Listing' => 'featured',
);
$job_listing_value = $this->convert_static_fields_to_array($jobFields);
$response['job_listing_fields'] = $job_listing_value ;
return $response;
}
/**
* Job Manager extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('wp-job-manager/wp-job-manager.php')){
if($import_type == 'job_listing') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,171 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class LearnPressExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (LearnPressExtension::$instance == null) {
LearnPressExtension::$instance = new LearnPressExtension;
}
return LearnPressExtension::$instance;
}
public function processExtension($data){
$import_type = $data;
$response = [];
//$import_type = $this->import_type_as($import_type);
if(is_plugin_active('learnpress/learnpress.php')){
if($import_type == 'lp_course'){
$learn_meta_fields = array(
'Duration' => '_lp_duration',
'Maximum Students' => '_lp_max_students',
'Students Enrolled' => '_lp_students',
'Re-Take Course' => '_lp_retake_count',
'Featured' => '_lp_featured',
'Block Lessons' => '_lp_block_lesson_content',
'External Link' => '_lp_external_link_buy_course',
'Show Item Links' => '_lp_submission',
'Course Result' => '_lp_course_result',
'Passing Condition Value' => '_lp_passing_condition',
'Price' => '_lp_price',
'Sale Price' => '_lp_sale_price',
'No Requirement Enroll' => '_lp_required_enroll',
'Author' => '_lp_course_author',
'Block Expire Duration' => '_lp_block_expire_duration',
'Block Finished' => '_lp_block_finished',
'Allow Course Repurchase' => '_lp_allow_course_repurchase',
'Course Repurchase Option' => '_lp_course_repurchase_option',
'Level' => '_lp_level',
'Finish Button' => '_lp_has_finish',
'Featured Review' => '_lp_featured_review',
'No Required Enroll' => '_lp_no_required_enroll',
'Requirements' => '_lp_requirements',
'Target Audience' => '_lp_target_audiences',
'Key Features' => '_lp_key_features',
'FAQs' => '_lp_faqs',
);
$learn_section_meta_fields = array(
'Curriculum Name' => 'curriculum_name',
'Curriculum Description' => 'curriculum_description',
'Lesson Name' => 'lesson_name',
'Lesson Description' => 'lesson_description',
'Lesson Duration' => '_lp_lesson_duration',
'Preview Lesson' => '_lp_preview',
'Quiz Name' => 'quiz_name',
'Quiz Description' => 'quiz_description',
'Duration' => '_lp_duration',
'Minus Points' => '_lp_minus_points',
'Minus for Skip' => '_lp_minus_skip_questions',
'Passing Grade' => '_lp_passing_grade',
'Re-Take' => '_lp_quiz_retake_count',
);
}
if($import_type == 'lp_lesson'){
$learn_meta_fields = array(
'Lesson Duration' => '_lp_lesson_duration',
'Preview Lesson' => '_lp_preview',
'Course Id' => 'course_id',
'Curriculum Name' => 'curriculum_name'
);
}
if($import_type == 'lp_quiz'){
$learn_meta_fields = array(
'Course Id' => 'course_id',
'Curriculum Name' => 'curriculum_name',
'Duration' => '_lp_duration',
'Minus Points' => '_lp_minus_points',
'Minus for Skip' => '_lp_minus_skip_questions',
'Passing Grade' => '_lp_passing_grade',
'Re-Take' => '_lp_quiz_retake_count',
'Question Title' => 'question_title',
'Question Description' => 'question_description',
'Mark for this Question' => '_lp_mark',
'Question explanation' => '_lp_explanation',
'Question hint' => '_lp_hint',
'Question type' => '_lp_type',
'Question Options' => 'question_options',
'Instant Check' => '_lp_instant_check',
'Nagative Marking' => '_lp_negative_marking',
'Pagination' => '_lp_pagination',
'Show Correct Review' => '_lp_show_correct_review',
'Review' => '_lp_review',
);
}
if($import_type == 'lp_question'){
$learn_meta_fields = array(
'Course Id' => 'course_id',
'Curriculum Name' => 'curriculum_name',
'Mark for this Question' => '_lp_mark',
'Question explanation' => '_lp_explanation',
'Question hint' => '_lp_hint',
'Question type' => '_lp_type',
'Question Options' => 'question_options',
'Quiz ID' => 'quiz_id'
);
}
if($import_type == 'lp_order'){
$learn_meta_fields = array(
'Item Id' => 'item_id',
'Item Quantity' => 'item_quantity',
'Customer' => 'user_id',
'Order Total' => '_order_total',
'Order Subtotal' => '_order_subtotal',
'Item Total' => '_item_total',
'Item Subtotal' => '_item_subtotal'
);
}
}
$learn_meta_fields_line = $this->convert_static_fields_to_array($learn_meta_fields);
if($data == 'lp_course'){
$learn_section_meta_fields_line = $this->convert_static_fields_to_array($learn_section_meta_fields);
$response['course_settings_fields'] = $learn_meta_fields_line;
$response['curriculum_settings_fields'] = $learn_section_meta_fields_line;
}
if($data == 'lp_lesson'){
$response['lesson_settings_fields'] = $learn_meta_fields_line;
}
if($data == 'lp_quiz'){
$response['quiz_settings_fields'] = $learn_meta_fields_line;
}
if($data == 'lp_question'){
$response['question_settings_fields'] = $learn_meta_fields_line;
}
if($data == 'lp_order'){
$response['order_settings_fields'] = $learn_meta_fields_line;
}
return $response;
}
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('learnpress/learnpress.php')){
if($import_type == 'nav_menu_item'){
return false;
}
// $import_type = $this->import_name_as($import_type);
if($import_type == 'lp_course' || $import_type == 'lp_lesson' || $import_type == 'lp_quiz' || $import_type == 'lp_question' || $import_type == 'lp_order') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,190 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class LifterLmsExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (LifterLmsExtension::$instance == null) {
LifterLmsExtension::$instance = new LifterLmsExtension;
}
return LifterLmsExtension::$instance;
}
public function processExtension($data){
$mode = isset($_POST['Mode']) ? sanitize_text_field($_POST['Mode']) : "";
$import_type = $data;
$response = [];
//$import_type = $this->import_type_as($import_type);
if(is_plugin_active('lifterlms/lifterlms.php')){
if($import_type == 'course'){
$lifter_meta_fields = array(
'Instructors' => '_llms_instructors',
'Sales Page Content Type' => '_llms_sales_page_content_type',
'Sales Page Content Id' => '_llms_sales_page_content_page_id',
'Sales Page Content Url' => '_llms_sales_page_content_url',
'Length' => '_llms_length',
'Course Difficulty' => '_llms_post_course_difficulty',
'Video Embed' => '_llms_video_embed',
'Featured Video' => '_llms_tile_featured_video',
'Audio Embed' => '_llms_audio_embed',
'Content Restricted Message' => '_llms_content_restricted_message',
'Enrollment Period' => '_llms_enrollment_period',
'Enrollment Start Date' => '_llms_enrollment_start_date',
'Enrollment End Date' => '_llms_enrollment_end_date',
'Enrollment Opens Message' => '_llms_enrollment_opens_message',
'Enrollment Closed Message' => '_llms_enrollment_closed_message',
'Time Period' => '_llms_time_period',
'Start Date' => '_llms_start_date',
'End Date' => '_llms_end_date',
'Course Opens Message' => '_llms_course_opens_message',
'Course Closed Message' => '_llms_course_closed_message',
'Has Prerequisite' => '_llms_has_prerequisite',
'Prerequisite' => '_llms_prerequisite',
'Prerequisite track' => '_llms_prerequisite_track',
'Enable Capacity' => '_llms_enable_capacity',
'Capacity' => '_llms_capacity',
'Capacity Message' => '_llms_capacity_message',
'Reviews Enabled' => '_llms_reviews_enabled',
'Display Reviews' => '_llms_display_reviews',
'Num Reviews' => '_llms_num_reviews',
'Multiple Reviews Disabled' => '_llms_multiple_reviews_disabled',
);
if($mode == 'Insert'){
unset($lifter_section_meta_fields['Lesson Id']);
unset($lifter_section_meta_fields['Quiz Id']);
}
}
global $wpdb;
$quiz=$wpdb->get_results("SELECT meta_key FROM {$wpdb->prefix}postmeta WHERE post_id = '_llms_quiz'");
if($import_type == 'lesson'){
$lifter_meta_fields = array(
'Reviews Enabled' => '_llms_reviews_enabled',
'Display Reviews' => '_llms_display_reviews',
'Num Reviews' => '_llms_num_reviews',
'Multiple Reviews disabled' => '_llms_multiple_reviews_disabled',
'Video Embed' => '_llms_video_embed',
'Audio Embed' => '_llms_audio_embed',
'Free Lesson' => '_llms_free_lesson',
'Has Prerequisite' => '_llms_has_prerequisite',
'Prerequisite' => '_llms_prerequisite',
'Drip Method' => '_llms_drip_method',
'Days Before Available' => '_llms_days_before_available',
'Date Available' => '_llms_date_available',
'Time Available' => '_llms_time_available',
'Require Passing Grade' =>'_llms_require_passing_grade',
'Thumbnail Id' => '_thumbnail_id',
'Order' => '_llms_order',
'Parent Course' => '_llms_parent_course',
'Parent Section' => '_llms_parent_section',
'Require Assignment Passing Grade' => '_llms_require_assignment_passing_grade',
'Points' => '_llms_points',
'Quiz Enabled' => '_llms_quiz_enabled',
'Lesson Id' => '_llms_lesson_id',
'Allowed Attempts' => '_llms_allowed_attempts',
'Limit Attempts' => '_llms_limit_attempts',
'Limit Time' => '_llms_limit_time',
'Passing Percent' => '_llms_passing_percent',
'Show Correct Answer' => '_llms_show_correct_answer',
'Time Limit' => '_llms_time_limit',
'Quiz' => '_llms_quiz',
);
}
if($import_type == 'llms_quiz'){
$lifter_meta_fields = array(
'Free Lesson' => '_llms_free_lesson',
'Days Before Available' => '_llms_days_before_available',
'Date Available' => '_llms_date_available',
'Time Available' => '_llms_time_available',
'Require Passing Grade' =>'_llms_require_passing_grade',
'Thumbnail Id' => '_thumbnail_id',
'Order' => '_llms_order',
'Parent Course' => '_llms_parent_course',
'Parent Section' => '_llms_parent_section',
'Require Assignment Passing Grade' => '_llms_require_assignment_passing_grade',
'Points' => '_llms_points',
'Quiz Enabled' => '_llms_quiz_enabled',
'Quiz' => '_llms_quiz',
);
if($mode == 'Insert'){
unset($learn_meta_fields['Question Id']);
}
}
if($import_type == 'llms_coupon'){
$lifter_meta_fields = array(
'Enable Trial Discount' => '_llms_enable_trial_discount',
'Trial Amount' => '_llms_trial_amount',
'Coupon Courses' => '_llms_coupon_courses',
'Coupon Membership' => '_llms_coupon_membership',
'Coupon Amount' => '_llms_coupon_amount',
'Usage Limit' => '_llms_usage_limit',
'Discount Type' => '_llms_discount_type',
'Description' => '_llms_description',
'Expiration Date' => '_llms_expiration_date',
'Plan Type' => '_llms_plan_type',
);
}
if($import_type == 'llms_review'){
$lifter_meta_fields = array(
'Thumbnail Id' => '_thumbnail_id',
'Reviews Enabled' => '_llms_reviews_enabled',
'Display Reviews' => '_llms_display_reviews',
'Num Reviews' => '_llms_num_reviews',
'Multiple Reviews Disabled' => '_llms_multiple_reviews_disabled',
);
}
}
$lifter_meta_fields_line = $this->convert_static_fields_to_array($lifter_meta_fields);
if($data == 'course'){
$lifter_section_meta_fields_line = $this->convert_static_fields_to_array($lifter_section_meta_fields);
$response['lifter_course_settings_fields'] = $lifter_meta_fields_line;
}
if($data == 'lesson'){
$response['lifter_lesson_settings_fields'] = $lifter_meta_fields_line;
}
if($data == 'llms_quiz'){
$response['lifter_quiz_settings_fields'] = $lifter_meta_fields_line;
}
if($data == 'llms_coupon'){
$response['lifter_coupon_settings_fields'] = $lifter_meta_fields_line;
}
if($data == 'llms_review'){
$response['lifter_review_settings_fields'] = $lifter_meta_fields_line;
}
return $response;
}
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('lifterlms/lifterlms.php')){
// $import_type = $this->import_name_as($import_type);
if($import_type == 'course' || $import_type == 'lesson' || $import_type == 'llms_quiz' || $import_type == 'llms_coupon' || $import_type == 'llms_review') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,107 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ListingExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ListingExtension::$instance == null) {
ListingExtension::$instance = new ListingExtension;
}
return ListingExtension::$instance;
}
/**
* Provides Listing Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
global $wpdb;
$import_type = $data;
$response = [];
$import_type = $this->import_name_as($import_type);
if(is_plugin_active('business-directory-plugin/business-directory-plugin.php') && $data == 'wpbdp_listing' ){
if($import_type == 'CustomPosts'){
$table_name = $wpdb->prefix . 'wpbdp_form_fields';
$results = $wpdb->get_results( "SELECT * FROM $table_name" );
if ( !empty( $results ) ) {
foreach ( $results as $field ) {
$pro_meta_fields[$field->label] = '_wpbdp[fields][' . $field->id . ']';
}
}
}
}
if(is_plugin_active('geodirectory/geodirectory.php') && $data == 'gd_place' ){
$pro_meta_fields = array(
'Address' => 'street',
'Country' => 'country',
'Region' => 'region',
'City' => 'city',
'Zoom' => 'mapzoom',
'Zip/PosT Code' => 'zip',
'Latitude' => 'latitude',
'longitude' => 'longitude',
'Map View' => 'mapview');
}
if(is_plugin_active('advanced-classifieds-and-directory-pro/acadp.php') && $data == 'acadp_listings'){
$pro_meta_fields = array(
'Price' => 'price',
'Views Count' => 'views',
'Address' => 'address',
'Zip Code' => 'zipcode',
'Phone' => 'phone',
'Email' => 'email',
'Website' => 'website',
'Image' => 'images',
'Video' => 'video',
'Latitude' => 'latitude',
'Longitude' => 'longitude');
}
$pro_meta_fields = $this->convert_static_fields_to_array($pro_meta_fields);
$response['listing_meta_fields'] = $pro_meta_fields;
return $response;
}
/**
* Listing Extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('business-directory-plugin/business-directory-plugin.php') || is_plugin_active('geodirectory/geodirectory.php') || is_plugin_active('connections/connections.php') || is_plugin_active('wpdirectorykit/wpdirectorykit.php') || is_plugin_active('advanced-classifieds-and-directory-pro/acadp.php')){
$import_type = $this->import_name_as($import_type);
if( $import_type =='CustomPosts' ) {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,315 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class MappingExtension {
private static $instance = null,$extension_handler ;
private static $extension = [];
private static $validatefile;
private function __construct(){
$plugin_pages = ['com.smackcoders.csvimporternew.menu'];
global $plugin_ajax_hooks;
$request_page = isset($_REQUEST['page']) ?sanitize_text_field($_REQUEST['page']) : '';
$request_action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
if (in_array($request_page, $plugin_pages) || in_array($request_action, $plugin_ajax_hooks)) {
add_action('wp_ajax_mappingfields',array($this,'mapping_field_function'));
}
}
public static function getInstance() {
if (MappingExtension::$instance == null) {
MappingExtension::$instance = new MappingExtension;
MappingExtension::$validatefile = new ValidateFile;
foreach(get_declared_classes() as $class){
if(is_subclass_of($class, 'Smackcoders\FCSV\ExtensionHandler')){
array_push(MappingExtension::$extension ,$class::getInstance() );
}
}
return MappingExtension::$instance;
}
return MappingExtension::$instance;
}
/**
* Ajax Call
* Provides all Widget Fields for Mapping Section
* @return array - mapping fields
*/
public function mapping_field_function(){
check_ajax_referer('smack-ultimate-csv-importer', 'securekey');
$import_type = sanitize_text_field($_POST['Types']);
if(isset($_POST['MediaType'])){
$media_type = sanitize_key($_POST['MediaType']);
}
$hash_key = sanitize_key($_POST['HashKey']);
$get_key = get_option('openAI_settings');
$mode = sanitize_text_field($_POST['Mode']);
global $wpdb;
$response = [];
$current_user = wp_get_current_user();
$current_user_role = $current_user->roles[0];
$response['currentuser']=$current_user_role;
$details = [];
$info = [];
$filename = '';
$table_name = $wpdb->prefix."smackcsv_file_events";
$fields = $wpdb->get_results("UPDATE $table_name SET mode ='$mode' WHERE hash_key = '$hash_key'");
$get_result = $wpdb->get_results("SELECT file_name, total_rows FROM $table_name WHERE hash_key = '$hash_key' ");
$filename = $get_result[0]->file_name;
$total_rows = $get_result[0]->total_rows;
$file_extension = pathinfo($filename, PATHINFO_EXTENSION);
if(empty($file_extension)){
$file_extension = 'xml';
}
if($file_extension == 'xlsx' || $file_extension == 'xls'){
$file_extension = 'csv';
}
$template_table_name = $wpdb->prefix."ultimate_csv_importer_mappingtemplate";
$smackcsv_instance = SmackCSV::getInstance();
$upload_dir = $smackcsv_instance->create_upload_dir();
if($file_extension == 'csv' || $file_extension == 'txt'){
if (version_compare(PHP_VERSION, '8.1.0', '<')) { // Only do this if PHP version is less than 8.1.0
if (!ini_get("auto_detect_line_endings")) {
ini_set("auto_detect_line_endings", true);
}
}
$info = [];
if (($h = fopen($upload_dir.$hash_key.'/'.$hash_key, "r")) !== FALSE)
{
// Convert each line into the local $data variable
$delimiters = array( ',','\t',';','|',':','&nbsp');
$file_path = $upload_dir . $hash_key . '/' . $hash_key;
$delimiter = MappingExtension::$validatefile->getFileDelimiter($file_path, 5);
$array_index = array_search($delimiter,$delimiters);
if($array_index == 5){
$delimiters[$array_index] = ' ';
}
if($delimiter == '\t'){
$delimiter ='~';
$temp=$file_path.'temp';
if (($handles = fopen($temp, 'r')) !== FALSE){
while (($data = fgetcsv($handles, 0, $delimiter)) !== FALSE)
{
$trimmed_array = array_map('trim', $data);
array_push($info , $trimmed_array);
$exp_line = $info[0];
$response['success'] = true;
$response['show_template'] = false;
$response['csv_fields'] = $exp_line;
$response['currentuser']=$current_user_role;
if(!empty($media_type) && $import_type == 'Media'){
$value = $this->media_mapping_fields($import_type,$mode,$media_type);
}else{
$value = $this->mapping_fields($import_type);
}
$response['fields'] = $value;
echo wp_json_encode($response);
wp_die();
}
}
fclose($handles);
}
else{
while (($data = fgetcsv($h, 0, $delimiters[$array_index])) !== FALSE)
{
// Read the data from a single line
$trimmed_info = array_map('trim', $data);
array_push($info , $trimmed_info);
$exp_line = $info[0];
$response['success'] = true;
$response['get_key'] = $get_key;
$response['show_template'] = false;
$response['csv_fields'] = $exp_line;
if(!empty($media_type) && $import_type == 'Media'){
$value = $this->media_mapping_fields($import_type,$mode,$media_type);
}else{
$value = $this->mapping_fields($import_type);
}
$response['fields'] = $value;
$response['total_records'] = (int)$total_rows;
echo wp_json_encode($response);
wp_die();
}
// Close the file
fclose($h);
}
}
}
if($file_extension == 'tsv'){
if (version_compare(PHP_VERSION, '8.1.0', '<')) { // Only do this if PHP version is less than 8.1.0
if (!ini_get("auto_detect_line_endings")) {
ini_set("auto_detect_line_endings", true);
}
}
$info = [];
if (($h = fopen($upload_dir.$hash_key.'/'.$hash_key, "r")) !== FALSE)
{
$file_path = $upload_dir . $hash_key . '/' . $hash_key;
$delimiter = MappingExtension::$validatefile->getFileDelimiter($file_path, 5);
if($delimiter == '\t'){
$hs = $upload_dir . $hash_key . '/' . $hash_key;
$line =file($hs, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
// Read the data from a single line
$data = explode("\t", $line[0]); // Split by tab
$trimmed_info = array_map('trim', $data);
array_push($info , $trimmed_info);
$exp_line = $info[0];
$response['success'] = true;
$response['get_key'] = $get_key;
$response['show_template'] = false;
$response['csv_fields'] = $exp_line;
if(!empty($media_type) && $import_type == 'Media'){
$value = $this->media_mapping_fields($import_type,$mode,$media_type);
}else{
$value = $this->mapping_fields($import_type);
}
$response['fields'] = $value;
$response['total_records'] = (int)$total_rows;
echo wp_json_encode($response);
wp_die();
}
}
}
if($file_extension == 'xml'){
$xml_class = new XmlHandler();
$upload_dir_path = $upload_dir. $hash_key;
if (!is_dir($upload_dir_path)) {
wp_mkdir_p( $upload_dir_path);
}
chmod($upload_dir_path, 0777);
$path = $upload_dir . $hash_key . '/' . $hash_key;
$xml = simplexml_load_file($path);
$xml_arr = json_decode( json_encode($xml) , 1);
foreach($xml->children() as $child){
$child_name = $child->getName();
}
$parse_xml = $xml_class->parse_xmls($hash_key);
$i = 0;
$headers=[];
foreach($parse_xml as $xml_key => $xml_value){
if(is_array($xml_value)){
foreach ($xml_value as $e_key => $e_value){
$headers[$i] = $e_value['name'];
$i++;
}
}
}
$response['success'] = true;
$response['show_template'] = false;
$response['csv_fields'] = $headers;
if(!empty($media_type) && $import_type == 'Media'){
$value = $this->media_mapping_fields($import_type,$mode,$media_type);
}else{
$value = $this->mapping_fields($import_type);
}
$response['fields'] = $value;
$response['total_records'] = (int)$total_rows;
echo wp_json_encode($response);
wp_die();
}
}
/**
* Provides active plugins
* @return array - active plugins
*/
public function get_active_plugins() {
$active_plugins = get_option('active_plugins');
return $active_plugins;
}
/**
* Provides all Widget Fields for Export Section
* @return array - mapping fields
*/
public function get_fields($module){
$import_type = $module;
$response = [];
$value = $this->mapping_fields($import_type,'Export');
$response['fields'] = $value;
return $response;
}
public function mapping_fields($import_type,$process_type = null){
$support_instance = [];
$value = [];
//SmackCSV::getInstance();
for($i = 0 ; $i < count(MappingExtension::$extension) ; $i++){
$extension_instance = MappingExtension::$extension[$i];
if($extension_instance->extensionSupportedImportType($import_type)){
array_push($support_instance , $extension_instance);
}
}
for($i = 0 ;$i < count($support_instance) ; $i++){
$supporting_instance = $support_instance[$i];
$fields = $supporting_instance->processExtension($import_type,$process_type);
array_push($value , $fields);
}
return $value;
}
public function media_mapping_fields($import_type,$mode =null,$media_type=null){
MappingExtension::$extension_handler = new ExtensionHandler();
$support_instance = [];
if($import_type == 'Media') {
if($media_type == 'local'){
$wordpressfields = array(
'File Name' => 'file_name',
'Caption' => 'caption',
'Alt text' => 'alt_text',
'Desctiption' => 'description',
'Title' => 'title',
'Media ID' => 'media_id',
);
if(trim($mode) == 'Insert'){
unset($wordpressfields['Media ID']);
}
}else{
$wordpressfields = array(
'Post ID' => 'post_id',
'Media ID' => 'media_id',
'Actual URL' => 'actual_url',
'File Name' => 'file_name',
'Title' => 'title',
'Caption' => 'caption',
'Alt text' => 'alt_text',
'Desctiption' => 'description'
);
if(trim($mode) == 'Insert'){
unset($wordpressfields['Post ID']);
unset($wordpressfields['Media ID']);
}
}
}
$wordpress_value = MappingExtension::$extension_handler->convert_static_fields_to_array($wordpressfields);
$response[]['core_fields'] = $wordpress_value ;
return $response;
}
}

View File

@@ -0,0 +1,172 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class MasterStudyLMSExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (MasterStudyLMSExtension::$instance == null) {
MasterStudyLMSExtension::$instance = new MasterStudyLMSExtension;
}
return MasterStudyLMSExtension::$instance;
}
public function processExtension($data){
$mode = isset($_POST['Mode']) ? sanitize_text_field($_POST['Mode']) : "";
$import_type = $data;
$response = [];
//$import_type = $this->import_type_as($import_type);
if(is_plugin_active('masterstudy-lms-learning-management-system/masterstudy-lms-learning-management-system.php')){
if($import_type == 'stm-courses'){
$masterstudy_meta_fields = array(
'Duration Info' => 'duration_info',
'Features' => 'featured',
'Views' => 'views',
'Level' => 'level',
'Current students' => 'current_students',
'Duration info' => 'duration_info',
'Video duration' => 'video_duration',
'Price' => 'price',
'Sale_price' => 'sale_price',
'Status' => 'status',
'Status dates' => 'status_dates',
'Status dates end' => 'status_dates_end',
'Status dates start' => 'status_dates_start',
'Faq'=>'faq',
'Expiration_course'=>'expiration_course',
'Not membership'=>'not_membership',
'End time'=>'end_time',
'Announcement'=>'announcement',
'Course files_pack'=>'course_files_pack',
);
$masterstudy_section_meta_fields = array(
'Curriculum' => 'curriculum',
'Lesson Name' => 'lesson_name',
'Quiz Name' => 'quiz_name',
'Quiz Id' => 'quiz_id',
'Lesson Id' => 'lesson_id',
);
if($mode == 'Insert'){
unset($learn_section_meta_fields['Lesson Id']);
unset($learn_section_meta_fields['Quiz Id']);
}
}
if($import_type == 'stm-lessons'){
$masterstudy_meta_fields = array(
'Type' => 'type',
'Duration' => 'duration',
'Preview' => 'preview',
'Lesson Excerpt' => 'lesson_excerpt',
'Thumbnail id' => '_thumbnail_id',
'Video type' => 'video_type',
'Lesson youtube url' => 'lesson_youtube_url',
'Presto player idx' => 'presto_player_idx',
'Lesson video' => 'lesson_video',
'Lesson video_poster' => 'lesson_video_poster',
'Lesson video_width' => 'lesson_video_width',
'Lesson shortcode' => 'lesson_shortcode',
'Lesson embed_ctx' => 'lesson_embed_ctx',
'Lesson stream_url' => 'lesson_stream_url',
'Lesson vimeo_url' => 'lesson_vimeo_url',
'Lesson ext_link_url' => 'lesson_ext_link_url',
'Lesson files pack' => 'lesson_files_pack'
);
}
if($import_type == 'stm-quizzes'){
$masterstudy_meta_fields = array(
'Duration' => 'duration',
'Thumbnail_id ' => 'thumbnail_id ',
'Lesson Excerpt' => 'lesson_excerpt',
'Quiz style' => 'quiz_style',
'Correct answer' => 'correct_answer',
'Passing grade' => 'passing_grade',
'Re take cut' => 're_take_cut',
'Random_questions' => 'random_questions',
'Questions' => 'questions',
);
if($mode == 'Insert'){
unset($masterstudy_meta_fields['Question Id']);
}
}
if($import_type == 'stm-questions'){
$masterstudy_meta_fields = array(
'Type' => 'type',
'Answers' => 'answers',
'Question explanation' => 'question_explanation',
'Question' => 'question',
'Question hint' => 'question_hint',
'question view type' => 'question_view_type',
'Image' => 'image'
);
}
if($import_type == 'stm-orders'){
$masterstudy_meta_fields = array(
'Status' => 'status',
);
}
}
$masterstudy_meta_fields_line = $this->convert_static_fields_to_array($masterstudy_meta_fields);
if($data == 'stm-courses'){
$masterstudy_section_meta_fields_line = $this->convert_static_fields_to_array($masterstudy_section_meta_fields);
$response['course_settings_fields_stm'] = $masterstudy_meta_fields_line;
$response['curriculum_settings_fields_stm'] = $masterstudy_section_meta_fields_line;
}
if($data == 'stm-lessons'){
$response['lesson_settings_fields_stm'] = $masterstudy_meta_fields_line;
}
if($data == 'stm-quizzes'){
$response['quiz_settings_fields_stm'] = $masterstudy_meta_fields_line;
}
if($data == 'stm-questions'){
$response['question_settings_fields_stm'] = $masterstudy_meta_fields_line;
}
if($data == 'stm-orders'){
$response['order_settings_fields_stm'] = $masterstudy_meta_fields_line;
}
return $response;
}
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('masterstudy-lms-learning-management-system/masterstudy-lms-learning-management-system.php')){
if($import_type == 'stm-courses' || $import_type == 'stm-lessons' || $import_type == 'stm-quizzes' || $import_type == 'stm-questions' || $import_type == 'stm-orders') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,77 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class MetaBoxExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (MetaBoxExtension::$instance == null) {
MetaBoxExtension::$instance = new MetaBoxExtension;
}
return MetaBoxExtension::$instance;
}
/**
* Provides Metabox mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
global $wpdb;
$response = [];
$import_type = $this->import_post_types($data);
$metabox_fields = [];
$listTaxonomy = get_taxonomies();
if($import_type == 'user'){
$get_metabox_fields = \rwmb_get_object_fields($import_type,'user');
}elseif(in_array($import_type, $listTaxonomy)){
$get_metabox_fields = \rwmb_get_object_fields($import_type,'term');
}else{
$get_metabox_fields = \rwmb_get_object_fields($import_type);
}
if(!empty($get_metabox_fields)){
foreach($get_metabox_fields as $meta_key => $meta_value){
$customFields[$meta_value['name']] = $meta_key;
}
$mb_value = $this->convert_static_fields_to_array($customFields);
}
else{
$mb_value = '';
}
$response['metabox_fields'] = $mb_value;
return $response;
}
/**
* Metabox extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('meta-box/meta-box.php') || is_plugin_active('meta-box-aio/meta-box-aio.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'event-recurring' || $import_type == 'Users' || $import_type == 'Taxonomies' || $import_type =='Tags' || $import_type =='Categories') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,189 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
class MetaBoxGroupExtension extends ExtensionHandler
{
private static $instance = null;
public static function getInstance()
{
if (MetaBoxGroupExtension::$instance == null)
{
MetaBoxGroupExtension::$instance = new MetaBoxGroupExtension;
}
return MetaBoxGroupExtension::$instance;
}
/**
* Provides Metabox mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data)
{
global $wpdb;
$response = [];
$import_type = $this->import_post_types($data);
$metabox_fields = [];
$taxonomies = get_taxonomies();
if ($import_type == 'user')
{
$get_metabox_fields = \rwmb_get_object_fields($import_type, 'user');
}
else if (array_key_exists($import_type, $taxonomies))
{
$get_metabox_fields = \rwmb_get_object_fields($import_type, 'term');
}
else
{
$get_metabox_fields = \rwmb_get_object_fields($import_type);
}
if (!empty($get_metabox_fields))
{
foreach($get_metabox_fields as $metakey => $metavalue){
if(isset($metavalue['type']) && $metavalue['type'] == 'group'){
//get the group field data
$customFields = $this->get_groupfields($metavalue['fields']);
}
$mb_value = isset($customFields) ? $this->convert_static_fields_to_array($customFields) : "";
}
}
else
{
$mb_value = '';
}
if(!empty($mb_value)){
$response['metabox_group_fields'] = null;
}
return $response;
}
public function get_groupfields($fields){
static $grpfields;
foreach($fields as $key => $fieldData){
if($fieldData['type'] == 'group'){
$grpfields = $this->get_groupfields($fieldData['fields']);
}
else {
$grpfields[$fieldData['id']] = $fieldData['name'];
}
}
return $grpfields;
}
/**
* Metabox extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type)
{
if (is_plugin_active('meta-box-aio/meta-box-aio.php'))
{
if ($import_type == 'nav_menu_item')
{
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'event-recurring' || $import_type == 'Users' || $import_type =='WooCommerce' || $import_type =='WooCommerceCategories' || $import_type == 'WooCommerceOrders' || $import_type == 'WooCommerceCoupons' || $import_type == 'WooCommerceRefunds'|| $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type =='WPeCommerce' || $import_type == 'Taxonomies' || $import_type =='Tags' || $import_type =='Categories')
{
return true;
}
else
{
return false;
}
}
}
function import_post_types($import_type, $importAs = null)
{
$import_type = trim($import_type);
$module = array(
'Posts' => 'post',
'Pages' => 'page',
'Users' => 'user',
'WooCommerce Product Variations' => 'product_variation',
'WooCommerce Refunds' => 'shop_order_refund',
'WooCommerce Orders' => 'shop_order',
'WooCommerce Coupons' => 'shop_coupon',
'Comments' => 'comments',
'Taxonomies' => $importAs,
'WooCommerce Product' => 'product',
'WooCommerce' => 'product',
'CustomPosts' => $importAs
);
foreach (get_taxonomies() as $key => $taxonomy)
{
$module[$taxonomy] = $taxonomy;
}
if (array_key_exists($import_type, $module))
{
return $module[$import_type];
}
else
{
return $import_type;
}
}
public function convert_static_fields_to_array($static_value){
if (is_array($static_value) || is_object($static_value)){
foreach($static_value as $key=>$values){
$static_fields_getting[] = array('label' => $values,
'name' => $key
);
}
}
$static_fields_getting=isset($static_fields_getting)?$static_fields_getting:'';
return $static_fields_getting;
}
public function import_name_as($import_type){
$taxonomies = get_taxonomies();
$customposts = $this->get_import_custom_post_types();
$import_type_as = $this->get_import_post_types();
if (in_array($import_type, $taxonomies)) {
if($import_type == 'category' || $import_type == 'product_category' || $import_type == 'product_cat' || $import_type == 'wpsc_product_category' || $import_type == 'event-categories'):
$import_types = 'Categories';
elseif($import_type == 'product_tag' || $import_type == 'event-tags' || $import_type == 'post_tag'):
$import_types = 'Tags';
elseif($import_type == 'comments'):
$import_types = 'Comments';
else:
$import_types = 'Taxonomies';
endif;
}
else if(array_key_exists($import_type , $import_type_as )){
if (in_array($import_type, $customposts))
$import_types = 'CustomPosts';
else
$import_types = $import_type_as[$import_type];
}
else{
$import_types = $import_type;
}
return $import_types;
}
}

View File

@@ -0,0 +1,157 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
class MetaBoxRelationsExtension extends ExtensionHandler
{
private static $instance = null;
public static function getInstance()
{
if (MetaBoxRelationsExtension::$instance == null)
{
MetaBoxRelationsExtension::$instance = new MetaBoxRelationsExtension;
}
return MetaBoxRelationsExtension::$instance;
}
/**
* Provides Metabox mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data)
{
global $wpdb;
$response = [];
$import_type = $this->import_post_types($data);
$metabox_fields = [];
$taxonomies = get_taxonomies();
if ($import_type == 'user')
{
$get_metabox_fields = \rwmb_get_object_fields($import_type, 'user');
}
else if (array_key_exists($import_type, $taxonomies))
{
$get_metabox_fields = \rwmb_get_object_fields($import_type, 'term');
}
else
{
$get_metabox_fields = \rwmb_get_object_fields($import_type);
}
if (!empty($get_metabox_fields))
{
$customFields =array();
foreach ($get_metabox_fields as $meta_key => $meta_value)
{
if(isset($meta_value['relationship'])) {
if (strpos($meta_key, '_to') !== false)
{
$meta_title = 'from';
}
else
{
$meta_title = 'to';
}
$meta_title_names = explode('_', $meta_key);
$meta_title_name = $meta_title_names[0];
$related = $meta_title_names[1];
$p_id = $wpdb->get_var("SELECT ID FROM {$wpdb->prefix}posts where post_name='$meta_title_name'");
$relation_value = $wpdb->get_var("SELECT meta_value FROM {$wpdb->prefix}postmeta where post_id='$p_id' AND meta_key='relationship'");
$relation_value = unserialize($relation_value);
if(!empty($relation_value) && is_array($relation_value)){
foreach ($relation_value as $relate_key => $relate_value)
{
if ($relate_key == $meta_title)
{
// $customFields[$relate_value['meta_box']['title']] = $meta_key;
$customFields[$relation_value[$related]['field']['name']] = $meta_key;
}
}
}
else{
$customFields[$meta_title_name] = $meta_key;
}
}
}
$mb_value = $this->convert_static_fields_to_array($customFields);
}
else
{
$mb_value = '';
}
if(!empty($mb_value)){
$response['metabox_relations_fields'] = null;
}
return $response;
}
/**
* Metabox extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type)
{
if (is_plugin_active('meta-box-aio/meta-box-aio.php'))
{
if ($import_type == 'nav_menu_item')
{
return false;
}
$import_type = $this->import_name_as($import_type);
if ($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'event-recurring' || $import_type == 'Users' || $import_type == 'Taxonomies' || $import_type == 'Categories' || $import_type == 'Tags'
|| $import_type =='WooCommerce' || $import_type =='WooCommerceCategories' || $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type =='WPeCommerce' || $import_type == 'WooCommerceOrders' || $import_type == 'WooCommerceCoupons' || $import_type == 'WooCommerceRefunds')
{
return true;
}
else
{
return false;
}
}
}
function import_post_types($import_type, $importAs = null)
{
$import_type = trim($import_type);
$module = array(
'Posts' => 'post',
'Pages' => 'page',
'Users' => 'user',
'WooCommerce Product Variations' => 'product_variation',
'WooCommerce Refunds' => 'shop_order_refund',
'WooCommerce Orders' => 'shop_order',
'WooCommerce Coupons' => 'shop_coupon',
'Comments' => 'comments',
'Taxonomies' => $importAs,
'WooCommerce Product' => 'product',
'WooCommerce' => 'product',
'CustomPosts' => $importAs
);
foreach (get_taxonomies() as $key => $taxonomy)
{
$module[$taxonomy] = $taxonomy;
}
if (array_key_exists($import_type, $module))
{
return $module[$import_type];
}
else
{
return $import_type;
}
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class NextGenExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (NextGenExtension::$instance == null) {
NextGenExtension::$instance = new NextGenExtension;
}
return NextGenExtension::$instance;
}
/**
* Provides Nextgen Gallery mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
// $nextgenFields = array(
// 'FILENAME' => 'filename',
// 'ALT & TITLE TEXT' => 'alttext',
// 'DESCRIPTION' => 'description',
// 'GALLERY NAME' => 'nextgen_gallery',
// 'IMAGE' => 'image_url'
// );
// $next_gen_value = $this->convert_static_fields_to_array($nextgenFields);
$response['nextgen_gallery_fields'] = null ;
return $response;
}
/**
* Nextgen Gallery extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
return false;
if(is_plugin_active('nextgen-gallery/nggallery.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'WooCommerce' || $import_type == 'WPeCommerce' || $import_type =='CustomPosts' ) {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class PPOMExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (PPOMExtension::$instance == null) {
PPOMExtension::$instance = new PPOMExtension;
}
return PPOMExtension::$instance;
}
/**
* Provides PPOM Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
global $wpdb;
$table_name = $wpdb->prefix . 'nm_personalized';
// Fetch all the PPOM field setups from the `wp_nm_personalized` table
$field_setups = $wpdb->get_results( "SELECT * FROM $table_name" );
if ( !empty( $field_setups ) ) {
foreach ( $field_setups as $setup ) {
$meta_data = json_decode( $setup->the_meta, true );
if ( is_array( $meta_data ) ) {
foreach ( $meta_data as $key => $field ) {
$pro_meta_fields[$field['title']] = $field['data_name'];
}
}
}
}
$pro_meta_fields = $this->convert_static_fields_to_array($pro_meta_fields);
$response['ppom_meta_fields'] = $pro_meta_fields;
return $response;
}
/**
* PPOM Meta extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('advanced-product-fields-for-woocommerce/advanced-product-fields-for-woocommerce.php') ) {
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'WooCommerceOrders') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,99 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class PodsExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (PodsExtension::$instance == null) {
PodsExtension::$instance = new PodsExtension;
}
return PodsExtension::$instance;
}
/**
* Provides Pods mapping fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
global $wpdb;
$import_type = $data;
$import_type = $this->import_type_as($import_type);
$response = [];
$podsFields = array();
$import_type = $this->import_post_types($import_type);
$post_id = $wpdb->get_results($wpdb->prepare("select ID from {$wpdb->prefix}posts where post_name= %s and post_type = %s", $import_type, '_pods_pod'));
if(empty($post_id) && $import_type == 'comments'){
$post_id = $wpdb->get_results($wpdb->prepare("select ID from {$wpdb->prefix}posts where post_name= %s and post_type = %s", 'comment', '_pods_pod'));
}
if(empty($post_id) && $import_type == 'Media'){
$post_id = $wpdb->get_results($wpdb->prepare("select ID from {$wpdb->prefix}posts where post_name= %s and post_type = %s", 'media', '_pods_pod'));
}
if(!empty($post_id)) {
$lastId = $post_id[0]->ID;
$get_pods_fields = $wpdb->get_results( $wpdb->prepare( "SELECT post_title, post_name FROM {$wpdb->prefix}posts where post_parent = %d AND post_type = %s", $lastId, '_pods_field' ) );
if ( ! empty( $get_pods_fields ) ) :
foreach ( $get_pods_fields as $pods_field ) {
$podsFields["PODS"][ $pods_field->post_name ]['label'] = $pods_field->post_title;
$podsFields["PODS"][ $pods_field->post_name ]['name'] = $pods_field->post_name;
}
endif;
}
$pods_value = $this->convert_fields_to_array($podsFields);
$response['pods_fields'] = $pods_value;
return $response;
}
/**
* Pods extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('pods/init.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'Taxonomies' || $import_type == 'Categories' || $import_type == 'Tags' || $import_type == 'event' || $import_type == 'event-recurring' || $import_type == 'location' || $import_type == 'Users' || $import_type == 'WooCommerce' || $import_type == 'WPeCommerce' || $import_type == 'Comments') {
return true;
}
if($import_type == 'ticket'){
if(is_plugin_active('events-manager/events-manager.php')){
return false;
}else{
return true;
}
}
else{
return false;
}
}
}
function import_post_types($import_type, $importAs = null) {
$import_type = trim($import_type);
$module = array('Posts' => 'post', 'Pages' => 'page', 'Users' => 'user', 'Comments' => 'comments', 'Taxonomies' => $importAs, 'CustomerReviews' =>'wpcr3_review', 'Categories' => 'categories', 'Tags' => 'tags', 'WooCommerce' => 'product', 'WPeCommerce' => 'wpsc-product','WPeCommerceCoupons' => 'wpsc-product', 'WooCommerceOrders' => 'product', 'WooCommerceCoupons' => 'product', 'WooCommerceRefunds' => 'product', 'CustomPosts' => $importAs);
foreach (get_taxonomies() as $key => $taxonomy) {
$module[$taxonomy] = $taxonomy;
}
if(array_key_exists($import_type, $module)) {
return $module[$import_type];
}
else {
return $import_type;
}
}
}

View File

@@ -0,0 +1,72 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class PolylangExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (PolylangExtension::$instance == null) {
PolylangExtension::$instance = new PolylangExtension;
}
return PolylangExtension::$instance;
}
public function processExtension($data) {
if(is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php')){
$response = [];
$import_type = $this->import_name_as($data);
$poly_settings=get_option('polylang');
if($import_type =='Tags' || $import_type =='Categories'){
$polylangFields = array(
'LANGUAGE_CODE' => 'language_code',
'TRANSLATED_TAXONOMY_TITLE' => 'translated_taxonomy_title');
}
else if($import_type == 'Media' ){
if($poly_settings['media_support'] == 1){
$polylangFields = array(
'LANGUAGE_CODE' => 'language_code');
}
else{
return true;
}
}
else{
$polylangFields = array(
'Language Code' => 'language_code',
'Translated Post Title' => 'translated_post_title');
}
$polylang_value = $this->convert_static_fields_to_array($polylangFields);
$response['Polylang_settings_fields'] = $polylang_value ;
return $response;
}
}
/**
* Nextgen Gallery extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('polylang/polylang.php') || is_plugin_active('polylang-pro/polylang.php')){
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'WooCommerce' || $import_type =='Pages'|| $import_type =='CustomPosts' || $import_type =='Tags' || $import_type =='Categories') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,139 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ProductAttributeExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ProductAttributeExtension::$instance == null) {
ProductAttributeExtension::$instance = new ProductAttributeExtension;
}
return ProductAttributeExtension::$instance;
}
public function processExtension($data,$process_type=null) {
$response = [];
$import_type = $data;
$import_type = $this->import_type_as($import_type);
$importas = $this->import_post_types($import_type);
$taxonomies = get_object_taxonomies( $importas, 'names' );
$count = 0;
$product_statuses = array('publish', 'draft', 'future', 'private', 'pending');
$products = [];
$page = 1;
$limit = 100; // Set limit per page
$variable_product_ids = []; // Initialize variable product ids array
// Loop through products with pagination
while ($page) {
$paged_products = wc_get_products([
'status' => $product_statuses,
'limit' => $limit,
'page' => $page, // Paginate by page number
]);
if (empty($paged_products)) {
break; // Exit loop if no products are found
}
// Process each product
foreach ($paged_products as $product) {
$product_all_attributes = $product->get_attributes();
$prod_attribute_name = [];
foreach ($product_all_attributes as $attribute_key => $attribute) {
$prod_attribute_name[] = str_replace('pa_', '', $attribute_key);
}
$prod_attribute_count = count($prod_attribute_name);
if ($prod_attribute_count > $count) {
$count = $prod_attribute_count;
}
if ($product->is_type('variable')) {
$variable_product_ids[] = $product->get_id();
}
}
$page++; // Move to the next page
}
$variation_id = [];
foreach($variable_product_ids as $variable_product_id){
if(!empty($variable_product_id)){
$variable_product = wc_get_product($variable_product_id);
$variation_id [] = $variable_product->get_children();
}
}
foreach($variation_id as $variation_ids){
if(!empty($variation_ids)){
$data = wc_get_product($variation_ids[0]);
$product_attributes=$data->get_attributes();
$attribute_name = array();
foreach ($product_attributes as $attribute_key => $attribute) {
$attribute_name[]= str_replace('pa_', '',$attribute_key);
}
$attribute_count = count($attribute_name);
if($attribute_count > $count){
$count = $attribute_count;
}
}
}
if($count == 0){
$count =1;
}
if($process_type == 'Export'){
$pro_attr_fields =array();
for($i=1; $i<=$count;$i++){
$pro_attr_fields += array(
'Product Attribute Name' . $i => 'product_attribute_name' . $i,
'Product Attribute Value' . $i => 'product_attribute_value' . $i,
'Product Attribute Visible' . $i => 'product_attribute_visible' . $i
);
}
$pro_attr_fields_line = $this->convert_static_fields_to_array($pro_attr_fields);
$response['product_attr_fields'] = $pro_attr_fields_line;
}
else{
$pro_attr_fields =array();
for($i=1; $i<=$count;$i++){
$pro_attr_fields[]= $this->convert_static_fields_to_array(array(
"Product Attribute Name$i" => "product_attribute_name$i",
"Product Attribute Value$i" => "product_attribute_value$i",
"Product Attribute Visible$i" => "product_attribute_visible$i",
));
}
$response['product_attr_fields'] = $pro_attr_fields;
}
$pro_attr_fields_line = $this->convert_static_fields_to_array($pro_attr_fields);
$response['product_attr_fields'] = $pro_attr_fields_line;
return $response;
}
/**
* Product Attribute extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if(is_plugin_active('woocommerce/woocommerce.php')){
$import_type = $this->import_name_as($import_type);
if($import_type == 'WooCommerce') {
return true;
}else{
return false;
}
}else{
return false;
}
}
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ProductBundleMetaExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ProductBundleMetaExtension::$instance == null) {
ProductBundleMetaExtension::$instance = new ProductBundleMetaExtension;
}
return ProductBundleMetaExtension::$instance;
}
/**
* Provides Product Bundle Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
$import_type = $this->import_type_as($import_type);
if(is_plugin_active('woocommerce/woocommerce.php')){
if(is_plugin_active('woocommerce-product-bundles/woocommerce-product-bundles.php')){
if($import_type == 'WooCommerce'){
$pro_meta_fields = array(
'Product Bundle Items' => 'product_bundle_items',
'Layout' => 'layout',
'Form Location' => 'form_location',
'Item Grouping' => 'item_grouping',
'Min Bundle Size' => 'min_bundle_size',
'Max Bundle Size' => 'max_bundle_size',
'Edit in Cart' => 'edit_in_cart',
'Product Bundle Regular Price' => 'pb_regular_price',
'Product Bundle Sale Price' => 'pb_sale_price',
'Optional' => 'optional',
'Quantity Minimum' => 'quantity_min',
'Quantity Maximum' => 'quantity_max',
'Priced Individually' => 'priced_individually',
'Discount' => 'discount',
'Product details' => 'single_product_visibility',
'Cart Visibility' => 'cart_visibility',
'Order Visibility ' => 'order_visibility',
'Product Price details' => 'single_product_price_visibility',
'Cart Price Visibility' => 'cart_price_visibility',
'Order Price Visibility' => 'order_price_visibility',
'Override Title' => 'override_title',
'Override Title Value' => 'override_title_value',
'Override Description' => 'override_description',
'Override Description Value' => 'override_description_value',
'Hide Thumbnail' => 'hide_thumbnail',
'Bundle Virtual'=>'_wc_pb_virtual_bundle',
'Bundle Min Qty '=>'_wcpb_min_qty_limit',
'Bundle Max Qty '=>'_wcpb_max_qty_limit'
);
}
}
}
$pro_meta_fields_line = $this->convert_static_fields_to_array($pro_meta_fields);
$response['product_bundle_meta_fields'] = $pro_meta_fields_line;
return $response;
}
/**
* Product Bundle Meta extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('woocommerce-product-bundles/woocommerce-product-bundles.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'WooCommerce') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,362 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ProductMetaExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ProductMetaExtension::$instance == null) {
ProductMetaExtension::$instance = new ProductMetaExtension;
}
return ProductMetaExtension::$instance;
}
/**
* Provides Product Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
$import_type = $this->import_type_as($import_type);
if(is_plugin_active('woocommerce/woocommerce.php')){
if($import_type == 'WooCommerce'){
$pro_meta_fields = array(
'Product Shipping Class' => 'product_shipping_class',
'Visibility' => 'visibility',
'Tax Status' => 'tax_status',
'Product Type' => 'product_type',
'Featured Product' => 'featured_product',
'Tax Class' => 'tax_class',
'File Paths' => 'file_paths',
'Edit Last' => 'edit_last',
'Edit Lock' => 'edit_lock',
'Thumbnail Id' => 'thumbnail_id',
'Manage Stock' => 'manage_stock',
'Stock' => 'stock',
'Stock Status' => 'stock_status',
'Low Stock Threshold' => 'low_stock_threshold',
'Stock Quantity' => 'stock_qty',
'Total Sales' => 'total_sales',
'Downloadable' => 'downloadable',
'Virtual' => 'virtual',
'Regular Price' => 'regular_price',
'Sale Price' => 'sale_price',
'Purchase Note' => 'purchase_note',
'Menu Order' => 'menu_order',
'Enable Reviews' => 'comment_status',
'Weight' => 'weight',
'Length' => 'length',
'Width' => 'width',
'Height' => 'height',
'SKU' => 'sku',
'UpSells ID' => 'upsell_ids',
'CrossSells ID' => 'crosssell_ids',
'Grouping ID' => 'grouping_product',
'Sales Price Date From' => 'sale_price_dates_from',
'Sales Price Date To' => 'sale_price_dates_to',
'Price' => 'price',
'Sold Individually' => 'sold_individually',
'Backorders' => 'backorders',
'Product Image Gallery' => 'product_image_gallery',
'Product URL' => 'product_url',
'Button Text' => 'button_text',
'Featured' => 'featured',
'Downloadable Files' => 'downloadable_files',
'Download Limit' => 'download_limit',
'Download Expiry' => 'download_expiry',
'Download Type' => 'download_type',
'parent' => 'parent',
'_global_unique_id' => '_global_unique_id',
'_subscription_period' => '_subscription_period',
'_subscription_period_interval' => '_subscription_period_interval',
'_subscription_length' => '_subscription_length',
'_subscription_trial_period' => '_subscription_trial_period',
'_subscription_trial_length' => '_subscription_trial_length',
'_subscription_price' => '_subscription_price',
);
if(is_plugin_active('yith-cost-of-goods-for-woocommerce-premium/init.php') && ($import_type == 'WooCommerce')){
$pro_meta_fields['yith_cog_cost'] = 'yith_cog_cost';
}
if(is_plugin_active('custom-woocommerce-extensions/custom-woocommerce-extensions.php') && ($import_type == 'WooCommerce')){
$pro_meta_fields['pdf_download_url'] = 'pdf_download_url';
}
if(is_plugin_active('woocommerce-min-max-quantities/woocommerce-min-max-quantities.php')){
$pro_meta_fields['minimum_allowed_quantity'] = 'minimum_allowed_quantity';
$pro_meta_fields['maximum_allowed_quantity'] = 'maximum_allowed_quantity';
}
if ( is_plugin_active( 'yith-woocommerce-barcodes-premium/init.php' ) && $import_type == 'WooCommerce') {
$pro_meta_fields['Barcode Protocol'] = '_ywbc_barcode_protocol';
$pro_meta_fields['Barcode Value'] = '_ywbc_barcode_value';
$pro_meta_fields['Barcode Display Value'] = '_ywbc_barcode_display_value';
}
if (is_plugin_active('variation-swatches-for-woocommerce/variation-swatches-for-woocommerce.php')) {
$pro_meta_fields['Product Attribute Type'] = 'product_attribute_type';
}
}
// if($import_type == 'WooCommerceVariations'){
// $pro_meta_fields = array(
// 'Featured' => 'featured',
// 'Downloadable Files' => 'downloadable_files',
// 'Download Limit' => 'download_limit',
// 'Download Expiry' => 'download_expiry',
// 'Price' => 'price',
// 'Sales Price Date From' => 'sale_price_dates_from',
// 'Sales Price Date To' => 'sale_price_dates_to',
// 'Regular Price' => 'regular_price',
// 'Sale Price' => 'sale_price',
// 'Purchase Note' => 'purchase_note',
// 'Default Attributes' => 'default_attributes',
// 'Custom Attributes' => 'custom_attributes',
// 'Enable Reviews' => 'comment_status',
// 'Tax Status' => 'tax_status',
// 'Tax Class' => 'tax_class',
// 'Weight' => 'weight',
// 'Length' => 'length',
// 'Width' => 'width',
// 'Height' => 'height',
// 'Downloadable' => 'downloadable',
// 'Virtual' => 'virtual',
// 'Stock' => 'stock',
// 'Stock Status' => 'stock_status',
// 'Low Stock Threshold' => 'low_stock_threshold',
// 'Stock Quantity' => 'stock_qty',
// 'Sold Individually' => 'sold_individually',
// 'Manage Stock' => 'manage_stock',
// 'Backorders' => 'backorders',
// 'Thumbnail Id' => 'thumbnail_id',
// '_subscription_period' => '_subscription_period',
// '_subscription_period_interval' => '_subscription_period_interval',
// '_subscription_length' => '_subscription_length',
// '_subscription_trial_period' => '_subscription_trial_period',
// '_subscription_trial_length' => '_subscription_trial_length',
// '_subscription_price' => '_subscription_price',
// '_subscription_sign_up_fee' => '_subscription_sign_up_fee',
// 'Variation Description' => 'variation_description',
// 'Variation Shipping Class' => 'variation_shipping_class'
// );
// }
if($import_type == 'WooCommerceOrders'){
$pro_meta_fields = array(
'Recorded Sales' => 'recorded_sales',
'Payment Method Title' => 'payment_method_title',
'Payment Method' => 'payment_method',
'Transaction Id' => 'transaction_id',
'Billing First Name' => 'billing_first_name',
'Billing Last Name' => 'billing_last_name',
'Billing Company' => 'billing_company',
'Billing Address1' => 'billing_address_1',
'Billing Address2' => 'billing_address_2',
'Billing City' => 'billing_city',
'Billing PostCode' => 'billing_postcode',
'Billing State' => 'billing_state',
'Billing Country' => 'billing_country',
'Billing Phone' => 'billing_phone',
'Billing Email' => 'billing_email',
'Shipping First Name' => 'shipping_first_name',
'Shipping Last Name' => 'shipping_last_name',
'Shipping Company' => 'shipping_company',
'Shipping Address1' => 'shipping_address_1',
'Shipping Address2' => 'shipping_address_2',
'Shipping City' => 'shipping_city',
'Shipping PostCode' => 'shipping_postcode',
'Shipping State' => 'shipping_state',
'Shipping Country' => 'shipping_country',
'Customer User' => 'customer_user',
'Order Currency' => 'order_currency',
'Order Shipping Tax' => 'order_shipping_tax',
'Order Tax' => 'order_tax',
'Order Total' => 'order_total',
'Cart Discount Tax' => 'cart_discount_tax',
'Cart Discount' => 'cart_discount',
'Order Shipping' => 'order_shipping',
'ITEM: name' => 'item_name',
'ITEM: type' => 'item_type',
'ITEM: variation_id' => 'item_variation_id',
'ITEM: product_id' => 'item_product_id',
'ITEM: line_subtotal' => 'item_line_subtotal',
'ITEM: line_subtotal_tax' => 'item_line_subtotal_tax',
'ITEM: line_total' => 'item_line_total',
'ITEM: line_tax' => 'item_line_tax',
'ITEM: line_tax_data' => 'item_line_tax_data',
'ITEM: tax_class' => 'item_tax_class',
'ITEM: qty' => 'item_qty',
'FEE: name' => 'fee_name',
'FEE: type' => 'fee_type',
'FEE: tax_class' => 'fee_tax_class',
'FEE: line_total' => 'fee_line_total',
'FEE: line_tax' => 'fee_line_tax',
'FEE: line_tax_data' => 'fee_line_tax_data',
'FEE: line_subtotal' => 'fee_line_subtotal',
'FEE: line_subtotal_tax' => 'fee_line_subtotal_tax',
'SHIPMENT: name' => 'shipment_name',
'SHIPMENT: method_id' => 'shipment_method_id',
'SHIPMENT: cost' => 'shipment_cost',
'SHIPMENT: taxes' => 'shipment_taxes',
);
if ( is_plugin_active( 'yith-woocommerce-order-tracking-premium/init.php' ) && $import_type == 'WooCommerceOrders') {
$pro_meta_fields['Tracking Coe'] = 'ywot_tracking_code';
$pro_meta_fields['Tracking PostCode'] = 'ywot_tracking_postcode';
$pro_meta_fields['Tracking Carrier ID'] = 'ywot_carrier_id';
$pro_meta_fields['Pick Up Date'] = 'ywot_pick_up_date';
$pro_meta_fields['Estimated Devliery Date'] = 'ywot_estimated_delivery_date';
$pro_meta_fields['Pick Up Status '] = 'ywot_picked_up';
}
}
if($import_type == 'WooCommerceCoupons'){
$pro_meta_fields = array(
'Discount Type' => 'discount_type',
'Coupon Amount' => 'coupon_amount',
'Individual Use' => 'individual_use',
'Product Ids' => 'product_ids',
'Exclude Product Ids' => 'exclude_product_ids',
'Usage Limit' => 'usage_limit',
'Usage Limit Per User' => 'usage_limit_per_user',
'Limit Usage' => 'limit_usage_to_x_items',
'Expiry Date' => 'expiry_date',
'Free Shipping' => 'free_shipping',
'Exclude Sale Items' => 'exclude_sale_items',
'Product Categories' => 'product_categories',
'Exclude Product Categories' => 'exclude_product_categories',
'Minimum Amount' => 'minimum_amount',
'Maximum Amount' => 'maximum_amount',
'Customer Email' => 'customer_email',
'Wildcard Value' => 'wildcard_value',
'Wildcard Type' => 'wildcard_type',
);
}
if($import_type == 'WooCommerceRefunds' ){
$pro_meta_fields = array(
'Recorded Sales' => 'recorded_sales',
'Refund Amount' => 'refund_amount',
'Order Shipping Tax' => 'order_shipping_tax',
'Order Tax' => 'order_tax',
'Order Shipping' => 'order_shipping',
'Cart Discount' => 'cart_discount',
'Cart Discount Tax' => 'cart_discount_tax',
'Order Total' => 'order_total',
'Customer User' =>'customer_user'
);
}
if(is_plugin_active('woocommerce-chained-products/woocommerce-chained-products.php') && $import_type == 'WooCommerce') {
$chain_product = array(
'Chained Product Detail' => 'chained_product_detail',
'Chained Product Manage Stock' => 'chained_product_manage_stock',
);
foreach($chain_product as $key => $value){
$pro_meta_fields[$key] = $value;
}
}
if(is_plugin_active('woocommerce-product-retailers/woocommerce-product-retailers.php') && $import_type == 'WooCommerce') {
$retailers = array(
'Retailers Only Purchase' => 'wc_product_retailers_retailer_only_purchase',
'Retailers Use Buttons' => 'wc_product_retailers_use_buttons',
'Retailers Product Button Text' => 'wc_product_retailers_product_button_text',
'Retailers Catalog Button Text' => 'wc_product_retailers_catalog_button_text',
'Retailers Id' => 'wc_product_retailers_id',
'Retailers Price' => 'wc_product_retailers_price',
'Retailers URL' => 'wc_product_retailers_url',
);
foreach($retailers as $key => $value){
$pro_meta_fields[$key] = $value;
}
}
if(is_plugin_active('woocommerce-product-addons/woocommerce-product-addons.php') && $import_type == 'WooCommerce') {
$product_Addons = array(
'Product Addons Exclude Global' => 'product_addons_exclude_global',
'Product Addons Group Name' => 'product_addons_group_name',
'Product Addons Group Description' => 'product_addons_group_description',
'Product Addons Type' => 'product_addons_type',
'Product Addons Position' => 'product_addons_position',
'Product Addons Required' => 'product_addons_required',
'Product Addons Label Name' => 'product_addons_label_name',
'Product Addons Price' => 'product_addons_price',
'Product Addons Minimum' => 'product_addons_minimum',
'Product Addons Maximum' => 'product_addons_maximum',
);
foreach($product_Addons as $key => $value){
$pro_meta_fields[$key] = $value;
}
}
if(is_plugin_active('woocommerce-warranty/woocommerce-warranty.php') && $import_type == 'WooCommerce' ) {
$warranty = array(
'Warranty Label' => 'warranty_label',
'Warranty Type' => 'warranty_type',
'Warranty Length' => 'warranty_length',
'Warranty Value' => 'warranty_value',
'Warranty Duration' => 'warranty_duration',
'Warranty Addons Amount' => 'warranty_addons_amount',
'Warranty Addons Value' => 'warranty_addons_value',
'Warranty Addons Duration' => 'warranty_addons_duration',
'No Warranty Option' => 'no_warranty_option',
);
foreach($warranty as $key => $value){
$pro_meta_fields[$key] = $value;
}
}
if(is_plugin_active('woocommerce-pre-orders/woocommerce-pre-orders.php') && $import_type == 'WooCommerce' ) {
$pre_orders = array(
'Pre-Orders Enabled' => 'preorders_enabled',
'Pre-Orders Fee' => 'preorders_fee',
'Pre-Orders When to Charge' => 'preorders_when_to_charge',
'Pre-Orders Availabilty Datetime' => 'preorders_availability_datetime'
);
foreach($pre_orders as $key => $value){
$pro_meta_fields[$key] = $value;
}
}
}
$pro_meta_fields_line = $this->convert_static_fields_to_array($pro_meta_fields);
if($data == 'WooCommerce Orders'){
$response['order_meta_fields'] = $pro_meta_fields_line;
}
if($data == 'WooCommerce Coupons'){
$response['coupon_meta_fields'] = $pro_meta_fields_line;
}
if($data == 'WooCommerce Refunds'){
$response['refund_meta_fields'] = $pro_meta_fields_line;
}
if($data !== 'WooCommerce Orders' && $data !== 'WooCommerce Coupons' && $data !== 'WooCommerce Refunds'){
$response['product_meta_fields'] = $pro_meta_fields_line;
}
return $response;
}
/**
* Product Meta extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('woocommerce/woocommerce.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'WooCommerce' || $import_type == 'WPeCommerce' || $import_type == 'WooCommerceOrders' || $import_type == 'WooCommerceCoupons' || $import_type == 'WooCommerceRefunds') {
return true;
}else{
return false;
}
}
}
}

View File

@@ -0,0 +1,156 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class RankMathExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (RankMathExtension::$instance == null) {
RankMathExtension::$instance = new RankMathExtension;
}
return RankMathExtension::$instance;
}
/**
* Provides Rank Math fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
if(is_plugin_active('seo-by-rank-math/rank-math.php') ){
$rankmathFields = array(
'Focus Keyword' => 'rank_math_focus_keyword',
'This post is Pillar Content' => 'rank_math_pillar_content',
'Robots Meta' => 'rank_math_robots',
'Advanced Robots Meta' => 'rank_math_advanced_robots',
'Canonical URL' => 'rank_math_canonical_url',
'Redirection Type' => 'redirection_type',
'Destination URL' => 'destination_url',
'Headline' => 'headline',
'Schema Description' => 'schema_description',
'Article Type'=>'article_type',
'General Title'=>'rank_math_title',
'Permalink'=>'_wp_old_slug',
'General Description'=>'rank_math_description',
'Facebook Title' =>'rank_math_facebook_title',
'Facebook Description' =>'rank_math_facebook_description',
'Facebook Image' => 'rank_math_facebook_image',
'Facebook Add icon overlay to thumbnail'=>'rank_math_facebook_enable_image_overlay',
'Facebook Icon overlay'=>'rank_math_facebook_image_overlay',
'Use Data from Facebook Tab'=>'rank_math_twitter_use_facebook',
'Twitter Title' =>'rank_math_twitter_title',
'Twitter Description' =>'rank_math_twitter_description',
'Twitter Image' => 'rank_math_twitter_image',
'Twitter Add icon overlay to thumbnail'=>'rank_math_twitter_enable_image_overlay',
'Twitter Icon overlay'=>'rank_math_twitter_image_overlay',
'Card Type'=>'rank_math_twitter_card_type',
'App Description'=>'rank_math_twitter_app_description',
'Dataset Name' => 'ds_name',
'Dataset Desc' => 'ds_description',
'Dataset URL' => 'ds_url',
'Dataset sameAs' => 'ds_sameAs',
'Dataset identifier' => 'ds_identifier',
'Dataset keywords' => 'ds_keywords',
'Dataset license' => 'ds_license',
'Dataset Catalog_name' => 'ds_cat_name',
'Dataset temporal coverage' => 'ds_temp_coverage',
'Dataset spatial coverage' => 'ds_spatial_coverage',
'Distribution Encode Format' => 'encodingFormat',
'Distribution Content URL' => 'contentUrl',
'Creator Type' => 'creator_type',
'Creator Name' => 'creator_name',
'Creator sameAs' => 'creator_sameAs',
'iPhone App Name'=>'rank_math_twitter_app_iphone_name',
'iPhone App ID'=>'rank_math_twitter_app_iphone_id',
'iPhone App URL'=>'rank_math_twitter_app_iphone_url',
'iPad App Name'=>'rank_math_twitter_app_ipad_name',
'iPad App ID'=>'rank_math_twitter_app_ipad_id',
'iPad App URL'=>'rank_math_twitter_app_ipad_url',
'Google Play App Name'=>'rank_math_twitter_app_googleplay_name',
'Google Play App ID'=>'rank_math_twitter_app_googleplay_id',
'Google Play App URL'=>'rank_math_twitter_app_googleplay_url',
'App Country'=>'rank_math_twitter_app_country',
'Player URL'=>'rank_math_twitter_player_url',
'Player Size'=>'rank_math_twitter_player_size',
'Stream URL'=>'rank_math_twitter_player_stream',
'Stream Content Type'=>'rank_math_twitter_player_stream_ctype'
);
if(in_array($data , get_taxonomies())){
unset($rankmathFields['Cornerstone Content']);
}
}
if(is_plugin_active('seo-by-rank-math-pro/rank-math-pro.php')){
$rankmathProFields=array(
'cssSelector'=>'cssSelector',
'Image Type'=>'image_type',
'Image Url'=>'image_url',
'Author Type'=>'author_type',
'Author Name'=>'author_name',
'Speakable Type'=>'speakable_type',
'Enable Speakable'=>'enable_speakable',
'DateModified'=>'date_modified',
'DatePublished'=>'date_published',
'Advanced Editor'=>'advanced_editor',
'Advanced Editor Group Values'=>'advanced_editor_group_values'
);
foreach($rankmathProFields as $key => $value){
$rankmathFields[$key] = $value;
}
}
if(is_plugin_active('seo-by-rank-math-pro/rank-math-pro.php')){
$rank_math_value = $this->convert_static_fields_to_array($rankmathFields);
$response['rank_math_pro_fields'] = $rank_math_value ;
return $response;
}
else{
$rank_math_value = $this->convert_static_fields_to_array($rankmathFields);
$response['rank_math_fields'] = $rank_math_value ;
return $response;
}
}
/**
* Rank Math extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('seo-by-rank-math/rank-math.php') || is_plugin_active('seo-by-rank-math-pro/rank-math-pro.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'event-recurring' || $import_type == 'location' || $import_type == 'WooCommerce' || $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type == 'WPeCommerce' || $import_type == 'Taxonomies' || $import_type == 'Tags' || $import_type == 'Categories' ) {
return true;
}
if($import_type == 'ticket'){
if(is_plugin_active('events-manager/events-manager.php')){
return false;
}else{
return true;
}
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class SeopressExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (SeopressExtension::$instance == null) {
SeopressExtension::$instance = new SeopressExtension;
}
return SeopressExtension::$instance;
}
/**
* Provides SEOPress fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
//return true;
$response = [];
$seoPressFields = array(
'SEO Title' => '_seopress_titles_title',
'Meta Description' => '_seopress_titles_desc',
'Robots Index' => '_seopress_robots_index',
'Robots Follow'=>'_seopress_robots_follow',
'Robots Imageindex' => '_seopress_robots_imageindex',
'Robots Archive' => '_seopress_robots_archive',
'Canonical' => '_seopress_robots_canonical',
'Target Keyword' =>'_seopress_analysis_target_kw',
'Robots Category' => '_seopress_robots_primary_cat',
'Robots Breadcrumbs' => '_seopress_robots_breadcrumbs', // 'bread-crumbs-title'
'Facebook Title' => '_seopress_social_fb_title',
'Facebook Description' => '_seopress_social_fb_desc',
'Facebook Image' => '_seopress_social_fb_img',
'Twitter Title' => '_seopress_social_twitter_title',
'Twitter Description' => '_seopress_social_twitter_desc',
'Twitter Image' => '_seopress_social_twitter_img',
'Redirections Type' => '_seopress_redirections_type',
'Redirections Value' => '_seopress_redirections_value',
'Enable redirection' => '_seopress_redirections_enabled',
'Redirection logged status' => '_seopress_redirections_logged_status'
);
$seopress_value = $this->convert_static_fields_to_array($seoPressFields);
$response['seopress_fields'] = $seopress_value ;
return $response;
}
/**
* Yoast SEOPress extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('wp-seopress/seopress.php') || is_plugin_active('wp-seopress-pro/seopress-pro.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
// print_r($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,112 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class TermsAndTaxonomies extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (TermsAndTaxonomies::$instance == null) {
TermsAndTaxonomies::$instance = new TermsAndTaxonomies;
}
return TermsAndTaxonomies::$instance;
}
/**
* Provides Terms and Taxonomies fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
$import_type = $data;
$import_type = $this->import_type_as($import_type);
$term_taxonomies = array();
$importas = $this->import_post_types($import_type);
$taxonomies = get_object_taxonomies( $importas, 'names' );
$search_array = array('post_format','product_type','product_visibility','product_shipping_class','language','post_translations');
foreach($search_array as $search_values){
if(in_array($search_values , $taxonomies)){
$search_format = array_search($search_values , $taxonomies);
unset($taxonomies[$search_format]);
}
}
// if(function_exists('wc_get_attribute_taxonomies')){
// $get_pro_attr = wc_get_attribute_taxonomies();
// foreach($get_pro_attr as $value){
// $attr_name = $value->attribute_name;
// $attribute = 'pa_'.$attr_name;
// if(in_array($attribute , $taxonomies));
// {
// $search_attr = array_search($attribute , $taxonomies);
// if($taxonomies[$search_attr] != 'category' && $taxonomies[$search_attr] != 'product_cat' ){
// unset($taxonomies[$search_attr]);
// }
// }
// }
// }else{
// #TODO
// }
if(!empty($taxonomies)) {
$temp = 0;
foreach ($taxonomies as $key => $value) {
//added - check for woocommerce product attribute values - if so unset it
$check_for_pro_attr = explode('_', $value);
if($check_for_pro_attr[0] == 'pa'){
unset($taxonomies[$key]);
continue;
}
$get_taxonomy_label = get_taxonomy($value);
$taxonomy_label = $get_taxonomy_label->name;
if($value == 'wpsc_product_category' || $value == 'product_cat'){
$value = 'product_category';
}elseif($value == 'category'){
$value = 'post_category';
}
$term_taxonomies['TERMS'][$temp]['label'] = $taxonomy_label;
$term_taxonomies['TERMS'][$temp]['name'] = $value;
$temp++;
}
}
$terms_value = $this->convert_fields_to_array($term_taxonomies);
$response['terms_and_taxonomies'] = $terms_value ;
return $response;
}
/**
* Terms and Taxonomies extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if($import_type == 'nav_menu_item' || $import_type == 'elementor_library'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type =='Posts' || $import_type =='Pages' || $import_type =='CustomPosts' || $import_type =='WooCommerce') {
return true;
}
else{
return false;
}
}
}

View File

@@ -0,0 +1,266 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class ToolsetExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (ToolsetExtension::$instance == null) {
ToolsetExtension::$instance = new ToolsetExtension;
}
return ToolsetExtension::$instance;
}
/**
* Provides Toolset fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
global $wpdb;
$import_types = $data;
$import_name_type = $this->import_name_as($import_types);
$response = [];
$typesFields = array();
if($import_types == 'Users') {
$getUserMetaFields = get_option('wpcf-usermeta');
if(is_array($getUserMetaFields)) {
foreach ($getUserMetaFields as $optKey => $optVal) {
$typesFields["TYPES"][$optVal['slug']]['label'] = $optVal['name'];
$typesFields["TYPES"][$optVal['slug']]['name'] = $optVal['slug'];
}
}
} else {
$import_type = $this->import_post_types($import_name_type);
$get_groups = $wpdb->get_results($wpdb->prepare("select ID from {$wpdb->prefix}posts where post_type = %s", 'wp-types-group'));
$get_groupsc = $wpdb->get_results($wpdb->prepare("select ID from {$wpdb->prefix}posts where post_type = %s", 'wp-types-term-group'));
if(!empty($get_groupsc && ($import_name_type == 'Categories' || $import_name_type == 'Tags' || $import_name_type == 'Taxonomies'))) {
$wptermsfields = array();
$wptermsfields = get_option('wpcf-termmeta');
foreach($get_groupsc as $item => $group) {
$lastId = $group->ID;
$rule_groups = $import_type;
$rule_groups = trim($rule_groups,',');
$rules = explode(',', $rule_groups);
if(in_array($import_type, $rules)) {
$fields = get_post_meta( $lastId, '_wp_types_group_fields', true );
$group_names = get_post_meta( $lastId, '_wp_types_associated_taxonomy', false );
if(in_array($import_types , $group_names) || empty($group_names)){
$fields = trim($fields, ',');
$types_fields = explode( ',', $fields );
$count = count( $types_fields );
if ( is_array( $types_fields ) ) {
for ( $i = 0; $i < $count; $i ++ ) {
foreach($wptermsfields as $term_field_value){
$search_value = $term_field_value['slug'] ;
if(in_array($search_value , $types_fields)){
$typesFields['TYPES'][ $search_value ]['name'] = $term_field_value['slug'];
$typesFields['TYPES'][ $search_value ]['slug'] = $term_field_value['slug'];
$typesFields['TYPES'][ $search_value ]['label'] = $term_field_value['name'];
}
}
}
}
}
}
}
}
if(!empty($get_groups && ($import_name_type !== 'Categories' && $import_name_type !== 'Tags' && $import_name_type !== 'Taxonomies'))) {
$import_type = $this->import_post_types($import_name_type);
$relation_group_name = false;
foreach($get_groups as $item => $group) {
$lastId = $group->ID;
$rule_groups = get_post_meta( $lastId, '_wp_types_group_post_types', true );
$rule_group = trim($rule_groups,',');
$rules = explode(',', $rule_group);
if($import_type == 'CustomPosts'){
$import_type = $import_types;
}
if(in_array($import_type , $rules)||in_array('all',$rules)){
$get_fields = $wpdb->get_results("SELECT post_id from {$wpdb->prefix}postmeta where meta_value = '$rule_groups' ");
foreach($get_fields as $get_id){
$ID = $get_id->post_id;
$get_status = $wpdb->get_var("SELECT post_status FROM {$wpdb->prefix}posts WHERE id = $ID");
if($get_status == 'publish'){
$fields = get_post_meta( $ID, '_wp_types_group_fields', true );
$fields = trim($fields, ',');
$types_fields = explode( ',', $fields );
$count = count( $types_fields );
$wptypesfields = get_option('wpcf-fields');
if ( is_array( $types_fields ) ) {
for ( $i = 0; $i < $count; $i ++ ) {
foreach ( $types_fields as $key => $value ) {
if(!empty($value)){
//change repeatable_group to user readable format
//$value = $this->changeRepeatableGroupName($value);
if(is_array($value)){
foreach($value as $repeat_value){
$typesFields['TYPES'][ $repeat_value ]['name'] = $repeat_value;
$typesFields['TYPES'][ $repeat_value ]['slug'] = $repeat_value;
$typesFields['TYPES'][ $repeat_value ]['label'] = $repeat_value;
}
$relation_group_name = true;
}
else{
if($wptypesfields[$value]['type'] !== 'image' && $wptypesfields[$value]['type'] !== 'file' && $wptypesfields[$value]['type'] !== 'video' && $wptypesfields[$value]['type'] !== 'post'){
$typesFields['TYPES'][ $value ]['name'] = $value;
$typesFields['TYPES'][ $value ]['slug'] = $value;
$typesFields['TYPES'][ $value ]['label'] = $value;
}
}
}
}
}
}
}
}
}
}
}
// if(is_plugin_active('types/wpcf.php')){
// $relationship_table_name = $wpdb->prefix . "toolset_relationships";
// $get_relationship = $wpdb->get_results( "SELECT id FROM $relationship_table_name" );
// }
// $import_type = $this->import_post_types($import_name_type);
// if($import_type == 'CustomPosts'){
// $import_type = $import_types;
// }
// if(!empty($get_relationship)){
// if($import_name_type !== 'Categories' && $import_name_type !== 'Tags' && $import_name_type !== 'Taxonomies'){
// $check_relation_id = array();
// $check_relationship = $wpdb->get_results("SELECT parent_types, child_types FROM $relationship_table_name WHERE origin = 'wizard' ");
// foreach($check_relationship as $check_relationship_values){
// $check_relation_id[] = $check_relationship_values->parent_types;
// $check_relation_id[] = $check_relationship_values->child_types;
// }
// $get_relation_types = array();
// foreach($check_relation_id as $get_relation_id){
// $get_relation_types[] = $wpdb->get_var("SELECT type FROM {$wpdb->prefix}toolset_type_sets WHERE set_id = $get_relation_id ");
// }
// $check_intermediate = $wpdb->get_results("SELECT slug, id, intermediary_type FROM $relationship_table_name where intermediary_type != '' ");
// $is_intermediate = false;
// if(!empty($check_intermediate)){
// $intermediate_rel = array();
// foreach($check_intermediate as $check_value){
// $intermediate_rel[] =$check_value->intermediary_type;
// $intermediate_fields= get_option('wpcf-listing-fields-'.$check_value->intermediary_type.'-'.$check_value->id);
// }
// if(in_array($import_types , $intermediate_rel)){
// $typesFields['TYPES']['intermediate']['label'] = 'Intermediate';
// $typesFields['TYPES']['intermediate']['name'] = 'intermediate';
// $typesFields['TYPES']['intermediate']['slug'] = 'intermediate';
// $is_intermediate = true;
// }
// }
// $is_relation = false;
// if(!$is_intermediate && in_array($import_type,$get_relation_types)){
// $typesFields['TYPES']['types_relationship']['label'] = 'Types Relationship';
// $typesFields['TYPES']['types_relationship']['name'] = 'types_relationship';
// $typesFields['TYPES']['types_relationship']['slug'] = 'types_relationship';
// $is_relation = true;
// }
// if($is_intermediate || $is_relation){
// $typesFields['TYPES']['relationship_slug']['label'] = 'Relationship Slug';
// $typesFields['TYPES']['relationship_slug']['name'] = 'relationship_slug';
// $typesFields['TYPES']['relationship_slug']['slug'] = 'relationship_slug';
// }
// if($relation_group_name){
// $typesFields['TYPES']['Parent_group']['label'] = 'Parent Group';
// $typesFields['TYPES']['Parent_group']['name'] = 'Parent_Group';
// $typesFields['TYPES']['Parent_group']['slug'] = 'Parent_Group';
// }
// }
// }
}
$tool_value = $this->convert_fields_to_array($typesFields);
if(!empty($tool_value)){
$response['types_fields'] = $tool_value;
}
// $response['types_fields'] = null;
return $response;
}
// public function changeRepeatableGroupName($value) {
// global $wpdb;
// $explode = explode('_',$value);
// if (count($explode)>1) {
// if (in_array('repeatable',$explode)) {
// $merge = [];
// $name = $wpdb->get_results("SELECT post_name FROM ".$wpdb->prefix."posts WHERE id ='{$explode[3]}'");
// $types_fields = array();
// $repeat_id = $explode[3];
// $repeat_fields = get_post_meta( $repeat_id, '_wp_types_group_fields', true );
// $repeat_field = trim($repeat_fields, ',');
// $types_fields = explode( ',', $repeat_field );
// array_push($types_fields , $name[0]->post_name);
// foreach($types_fields as $keys => $type_field_value){
// if (strpos($type_field_value, '_repeatable_group') !== false) {
// $type_fields = $this->changeRepeatableGroupName($type_field_value);
// unset($types_fields[$keys]);
// }
// }
// if(!empty($type_fields)){
// $merge = array_merge($types_fields ,$type_fields);
// }else{
// $merge = $types_fields;
// }
// return $merge;
// }else{
// return $value;
// }
// }else{
// return $value;
// }
// }
/**
* Toolset extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('types/wpcf.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'Users' || $import_type == 'WooCommerce' || $import_type == 'Taxonomies' || $import_type == 'Categories' || $import_type == 'Tags' ) {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class TotalpressExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (TotalpressExtension::$instance == null) {
TotalpressExtension::$instance = new TotalpressExtension;
}
return TotalpressExtension::$instance;
}
/**
* Provides SEOPress fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
global $wpdb;
$customFields = $cfs_field = array();
$getTPGroups = $wpdb->get_results($wpdb->prepare("select ID from {$wpdb->prefix}posts where post_type = %s and post_status = %s", 'manage_cpt_field' , 'publish'),ARRAY_A);
$groupIdArr = [];
foreach ( $getTPGroups as $item => $groupRules ) {
$groupIdArr[] .= $groupRules['ID'] . ',';
}
if($groupIdArr != '') {
foreach($groupIdArr as $groupId){
$getTPFields= $wpdb->get_results( $wpdb->prepare("SELECT meta_value FROM {$wpdb->prefix}postmeta WHERE post_id IN (%s) and meta_key =%s ",$groupId,'fields'), ARRAY_A);
}
}
$temp = 0;
if (!empty($getTPFields)) {
foreach ($getTPFields as $key => $value) {
$getTPField = @unserialize($value['meta_value']);
foreach($getTPField as $fk => $fv){
$customFields["TOTALPRESS"][$temp]['label'] = $fv['label'];
$customFields["TOTALPRESS"][$temp]['name'] = $fv['key'];
$temp++;
}
}
}
$tpValue = $this->convert_fields_to_array($customFields);
$response['totalpress_fields'] = $tpValue;
return $response;
}
/**
* Yoast SEOPress extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('custom-post-types/custom-post-types.php') ){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts') {
return true;
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,146 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class UsersExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (UsersExtension::$instance == null) {
UsersExtension::$instance = new UsersExtension;
}
return UsersExtension::$instance;
}
/**
* Provides Users fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data){
$import_type = $data;
$response = [];
if(is_plugin_active('woocommerce/woocommerce.php')){
$billing_fields = array(
'Billing First Name' => 'billing_first_name',
'Billing Last Name' => 'billing_last_name',
'Billing Company' => 'billing_company',
'Billing Address1' => 'billing_address_1',
'Billing Address2' => 'billing_address_2',
'Billing City' => 'billing_city',
'Billing PostCode' => 'billing_postcode',
'Billing State' => 'billing_state',
'Billing Country' => 'billing_country',
'Billing Phone' => 'billing_phone',
'Billing Email' => 'billing_email',
'Shipping First Name' => 'shipping_first_name',
'Shipping Last Name' => 'shipping_last_name',
'Shipping Company' => 'shipping_company',
'Shipping Address1' => 'shipping_address_1',
'Shipping Address2' => 'shipping_address_2',
'Shipping City' => 'shipping_city',
'Shipping PostCode' => 'shipping_postcode',
'Shipping State' => 'shipping_state',
'Shipping Country' => 'shipping_country',
'API Consumer Key' => 'woocommerce_api_consumer_key',
'API Consumer Secret' => 'woocommerce_api_consumer_secret',
'API Key Permissions' => 'woocommerce_api_key_permissions',
'Shipping Region' => '_wpsc_shipping_region' ,
'Billing Region' => '_wpsc_billing_region',
'Cart' => '_wpsc_cart'
);
}
$billing_fields = isset($billing_fields) ? $billing_fields :'';
$billing_value = $this->convert_static_fields_to_array($billing_fields);
$response['billing_and_shipping_information'] = $billing_value;
if(is_plugin_active( 'wp-members/wp-members.php')){
$wp_members_fields = $this->custom_fields_by_wp_members();
$response['custom_fields_wp_members'] = $wp_members_fields;
}
if(is_plugin_active( 'members/members.php')){
$members_fields = $this->custom_fields_by_members();
if(!empty($members_fields)){
$response['custom_fields_members'] = $members_fields;
}
}
// if(is_plugin_active( 'ultimate-member/ultimate-member.php')){
// $members_fields = $this->custom_fields_by_ultimate_member();
// if(!empty($members_fields)){
// $response['custom_ultimate_members'] = null;
// }
// }
return $response;
}
public function custom_fields_by_wp_members () {
$WPMemberFields = array();
$get_WPMembers_fields = get_option('wpmembers_fields');
$search_array = array('Choose a Username', 'First Name', 'Last Name', 'Email', 'Confirm Email', 'Website', 'Biographical Info', 'Password', 'Confirm Password', 'Terms of Service');
if (is_array($get_WPMembers_fields) && !empty($get_WPMembers_fields)) {
foreach ($get_WPMembers_fields as $get_fields) {
foreach($search_array as $search_values){
if(is_array($get_fields)){
if(in_array($search_values , $get_fields)){
unset($get_fields);
}
}
}
if(!empty($get_fields[2])){
$WPMemberFields['WPMEMBERS'][$get_fields[2]]['label'] = $get_fields[1];
$WPMemberFields['WPMEMBERS'][$get_fields[2]]['name'] = $get_fields[2];
}
}
}
$wp_mem_fields = $this->convert_fields_to_array($WPMemberFields);
return $wp_mem_fields;
}
public function custom_fields_by_members () {
$MemberFields = array();
$MemberFields['MULTIROLE']['multi_user_role']['label'] = 'Multi User Role';
$MemberFields['MULTIROLE']['multi_user_role']['name'] = 'multi_user_role';
$mem_fields = $this->convert_fields_to_array($MemberFields);
return $mem_fields;
}
// public function custom_fields_by_ultimate_member () {
// $WPUltimateMember = array();
// $get_WPUltimateMember = get_option('um_fields');
// if(is_array($get_WPUltimateMember) && !empty($get_WPUltimateMember)) {
// foreach($get_WPUltimateMember as $get_fields) {
// $WPUltimateMember['ULTIMATEMEMBER'][$get_fields['metakey']]['label'] = $get_fields['label'];
// $WPUltimateMember['ULTIMATEMEMBER'][$get_fields['metakey']]['name'] = $get_fields['metakey'];
// }
// }
// $ultimate_member_fields = $this->convert_fields_to_array($WPUltimateMember);
// return $ultimate_member_fields;
// }
/**
* Users extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
$test = WordpressCustomExtension::getInstance();
$import_type = $this->import_name_as($import_type);
if($import_type == 'Users' || $import_type == 'WooCommerceCustomer'){
return true;
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class WCPAExtension extends ExtensionHandler {
private static $instance = null;
public static function getInstance() {
if (WCPAExtension::$instance === null) {
WCPAExtension::$instance = new WCPAExtension();
}
return WCPAExtension::$instance;
}
/**
* Provides WCPA Meta fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
global $wpdb;
// Query to fetch meta values from wp_postmeta with meta key '_wcpa_fb_json_data'
$meta_results = $wpdb->get_results(
$wpdb->prepare(
"SELECT meta_value
FROM {$wpdb->postmeta}
WHERE meta_key = %s",
'_wcpa_fb_json_data'
),
ARRAY_A
);
// Initialize the headers array
$headers = [];
// Validate and process the meta results
if (!empty($meta_results)) {
foreach ($meta_results as $meta) {
if (!empty($meta['meta_value'])) {
$decoded_meta = json_decode($meta['meta_value'], true); // Decode JSON data
if (is_array($decoded_meta)) {
foreach ($decoded_meta as $section) {
if (isset($section['fields']) && is_array($section['fields'])) {
foreach ($section['fields'] as $fieldGroup) {
foreach ($fieldGroup as $field) {
if (isset($field['label']) && !empty($field['label'])) {
$headers[] = $field['label'];
}
}
}
}
}
}
}
}
}
// Prepare the response in the required format
$response = [];
foreach ($headers as $header) {
$response[] = [
'label' => $header,
'name' => sanitize_title($header), // Generate a machine-friendly name
];
}
// Return the headers
return ['wcpa_meta_fields' => $response];
}
/**
* WCPA Meta extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type) {
if (is_plugin_active('woo-custom-product-addons/start.php')) {
$import_type = $this->import_name_as($import_type);
if ($import_type === 'WooCommerceOrders') {
return true;
} else {
return false;
}
}
return false;
}
}

View File

@@ -0,0 +1,78 @@
<?php
/******************************************************************************************
* Copyright (C) Smackcoders. - All Rights Reserved under Smackcoders Proprietary License
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* You can contact Smackcoders at email address info@smackcoders.com.
*******************************************************************************************/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class WpcompleteExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (WpcompleteExtension::$instance == null) {
WpcompleteExtension::$instance = new WpcompleteExtension;
}
return WpcompleteExtension::$instance;
}
public function processExtension($data) {
$response = [];
$import_type = $this->import_name_as($data);
$wpcompletefields = array(
'Checkbox' => 'checkbox',
'Redirect URl' => 'redirect_url',
'Course' => 'course');
$wpcomplete_value = $this->convert_static_fields_to_array($wpcompletefields);
$response['wpcomplete_fields'] = $wpcomplete_value ;
return $response;
}
/**
* Wpcomplete extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active("wpcomplete/wpcomplete.php")){
$posttype =get_option('wpcomplete_post_type');
$types=explode(',',$posttype);
if($import_type == 'Posts'){
$import_types = 'post';
}
elseif($import_type == 'Pages'){
$import_types = 'page';
}
elseif($import_type == 'WooCommerce Product'){
$import_types = 'product';
}
else{
$import_types = $import_type;
}
if(in_array($import_types,$types)){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'WooCommerce' ) {
return true;
}
if($import_type == 'ticket'){
if(is_plugin_active('events-manager/events-manager.php')){
return false;
}else{
return true;
}
}
else{
return false;
}
}
}
}
}

View File

@@ -0,0 +1,98 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class WPMLExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (WPMLExtension::$instance == null) {
WPMLExtension::$instance = new WPMLExtension;
}
return WPMLExtension::$instance;
}
// public function processExtension($data) {
// global $uci_wpmlfunction_instance;
// $result = $uci_wpmlfunction_instance->processExtensionFunction($data);
// return $result;
// }
public function processExtension($data) {
$response = [];
$import_type = $this->import_name_as($data);
if($import_type == 'Posts' || $import_type =='Pages'){
$wpmlFields = array(
'LANGUAGE_CODE' => 'language_code',
'TRANSLATED_POST_TITLE' => 'translated_post_title');
}
if(!empty($wpmlFields)){
$wpml_value = $this->convert_static_fields_to_array($wpmlFields);
$response['wpml_fields'] = $wpml_value ;
return $response;
}else{
return $response;
}
}
/**
* WPML extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
global $sitepress;
global $wpdb;
if(is_plugin_active('wpml-import/plugin.php')){
return false;
}
if($sitepress != null) {
if($import_type == 'nav_menu_item'){
return false;
}
$get_custom_posts_wpml_sync_options = $wpdb->get_var("SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = 'icl_sitepress_settings' ");
$unser_custom_posts_wpml_sync_options = unserialize($get_custom_posts_wpml_sync_options);
$get_available_posttypes = array_intersect($unser_custom_posts_wpml_sync_options['custom_posts_sync_option'], $unser_custom_posts_wpml_sync_options['taxonomies_sync_option']);
$get_available_taxos = array_intersect($unser_custom_posts_wpml_sync_options['taxonomies_sync_option'], $unser_custom_posts_wpml_sync_options['custom_posts_sync_option']);
$get_all_availabilities = array_merge($get_available_posttypes, $get_available_taxos);
$import_types = $this->import_name_as($import_type);
$post_type_array = array(
'Posts' => 'post',
'Pages' => 'page',
//'WooCommerce Product' => 'product',
//'WooCommerce' => 'product'
);
//if($import_types == 'Posts' || $import_types == 'Pages' || $import_types == 'WooCommerce' || $import_types =='Taxonomies' || $import_types =='Tags' || $import_types =='Categories' || $import_types =='CustomPosts' ) {
if($import_types == 'Posts' || $import_types == 'Pages' ) {
if(array_key_exists($import_type, $post_type_array)){
$import_type = $post_type_array[$import_type];
}
if(array_key_exists($import_type, $get_all_availabilities)){
return true;
}
else{
return false;
}
}
else{
return false;
}
}
}
}

View File

@@ -0,0 +1,248 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class WordpressCustomExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (WordpressCustomExtension::$instance == null) {
WordpressCustomExtension::$instance = new WordpressCustomExtension;
}
return WordpressCustomExtension::$instance;
}
/**
* Provides Wordpress Custom fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
global $wpdb;
$import_types = $data;
$import_type = $this->import_type_as($import_types);
$response =[];
$module = $this->import_post_types($import_type);
$acf_values = $acfvalues = [];
$acf_values = array('admin_color', 'comment_shortcuts', 'community-events-location', 'dbem_phone', 'health-check', 'first_name', 'last_name', 'last_update', 'locale',
'nickname', 'orderby', 'rich_editing', 'syntax_highlighting', 'toolset-rg-view', 'username', 'use_ssl', 'session_tokens', 'smack_uci_import', 'description');
$get_acf_groups = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_content FROM {$wpdb->prefix}posts WHERE post_status != 'trash' AND post_type = %s", 'acf-field-group'));
foreach ( $get_acf_groups as $item => $group_rules ) {
$rule = maybe_unserialize($group_rules->post_content);
if(!empty($rule)) {
if ($import_types != 'Users') {
foreach($rule['location'] as $key => $value) {
if($value[0]['operator'] == '==' && $value[0]['value'] == $this->import_post_types($import_types)){
$group_id_arr[] = $group_rules->ID; #. ',';
}
elseif($value[0]['operator'] == '==' && $value[0]['value'] == 'all' && $value[0]['param'] == 'taxonomy' && in_array($this->import_post_types($import_types) , get_taxonomies())){
$group_id_arr[] = $group_rules->ID;
}
}
} else {
foreach($rule['location'] as $key => $value) {
if( $value[0]['operator'] == '==' && $value[0]['param'] == 'user_role'){
$group_id_arr[] = $group_rules->ID;
}
}
}
}
}
if ( !empty($group_id_arr) ) {
foreach($group_id_arr as $groupId) {
$get_acf_fields = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_title, post_content, post_excerpt, post_name FROM {$wpdb->prefix}posts where post_status != 'trash' AND post_parent in (%s)", array($groupId) ) );
if ( ! empty( $get_acf_fields ) ) {
foreach ( $get_acf_fields as $acf_pro_fields ) {
$acf_values[] = $acf_pro_fields->post_excerpt;
$acfvalues[] = $acf_pro_fields->post_excerpt;
}
}
}
}
$acf = [];
$get_acf_fields = $wpdb->get_results("SELECT post_excerpt FROM {$wpdb->prefix}posts where post_type = 'acf-field' ");
foreach($get_acf_fields as $acf_fields){
$acf[] = $acf_fields->post_excerpt;
}
$pods = [];
$get_pods_fields = $wpdb->get_results("SELECT post_name FROM {$wpdb->prefix}posts where post_type = '_pods_field' ");
foreach($get_pods_fields as $pods_fields){
$pods[] = $pods_fields->post_name;
}
if(is_plugin_active('meta-box/meta-box.php') || is_plugin_active('meta-box-aio/meta-box-aio.php')){
$metabox_fields = [];
$import_as = $this->import_post_types($import_types);
$get_metabox_fields = \rwmb_get_object_fields( $import_as );
$metabox_fields = array_keys($get_metabox_fields);
}
else{
$metabox_fields = '';
}
$jet_cpt = [];
$jet_meta_field = [];
if(is_plugin_active('jet-engine/jet-engine.php')){
$get_jet_cpt_fields = $wpdb->get_results("SELECT meta_fields FROM {$wpdb->prefix}jet_post_types where slug = '".$module."'");
foreach($get_jet_cpt_fields as $jet_cpt_fields){
$jet_cpt_fields = $jet_cpt_fields->meta_fields;
$unserialize_jet_cpt = unserialize($jet_cpt_fields);
}
if(isset($unserialize_jet_cpt) && is_array($unserialize_jet_cpt)){
foreach($unserialize_jet_cpt as $jet_cpt_field){
$jet_cpt[] = $jet_cpt_field['name'];
}
}
$jet_field = [];
$jet_fields = $wpdb->get_results("SELECT option_value FROM {$wpdb->prefix}options where option_name ='jet_engine_meta_boxes'");
foreach($jet_fields as $jetfield){
$jet_field_value = $jetfield->option_value;
$unserialize_jet_field_value = unserialize($jet_field_value);
}
foreach($unserialize_jet_field_value as $jet_fields_value){
$jet_field [] = $jet_fields_value['meta_fields'];
}
foreach($jet_field as $j_field){
foreach($j_field as $jfield){
$jet_meta_field[] = $jfield['name'];
}
}
}
$commonMetaFields = array();
if($module != 'user') {
//query to remove all acf fields from meta
$acf_not_like_query = '';
if(!empty($acfvalues)){
foreach($acfvalues as $acf_name){
$acf_not_like_query .= "meta_key NOT LIKE '%{$acf_name}%' AND ";
}
$acf_not_like_query = 'AND ' . rtrim($acf_not_like_query, 'AND ');
}
//query to remove all pods fields from meta
$pods_not_like_query = '';
if(!empty($pods)){
foreach($pods as $pods_name){
$pods_not_like_query .= "meta_key NOT LIKE '%{$pods_name}%' AND ";
}
$pods_not_like_query = 'AND ' . rtrim($pods_not_like_query, 'AND ');
}
//query to remove all metabox fields from meta
$metabox_not_like_query = '';
if(!empty($metabox_fields)){
foreach($metabox_fields as $metabox_name){
$metabox_not_like_query .= "meta_key NOT LIKE '%{$metabox_name}%' AND ";
}
$metabox_not_like_query = 'AND ' . rtrim($metabox_not_like_query, 'AND ');
}
$keys = $wpdb->get_col( "SELECT pm.meta_key FROM {$wpdb->prefix}posts p
JOIN {$wpdb->prefix}postmeta pm
ON p.ID = pm.post_id
WHERE p.post_type = '{$module}' AND NOT p.post_status = 'trash'
GROUP BY meta_key
HAVING meta_key NOT LIKE '\_%' and meta_key NOT LIKE 'rank_%'and meta_key NOT LIKE 'ywbc_%' and meta_key NOT LIKE 'field_%' and meta_key NOT LIKE 'wpcf-%' and meta_key NOT LIKE 'wpcr3_%' and meta_key NOT LIKE '%pods%' and meta_key NOT LIKE '%group_%' and meta_key NOT LIKE '%repeat_%' and meta_key NOT LIKE 'mp_%' $acf_not_like_query $pods_not_like_query $metabox_not_like_query
ORDER BY meta_key" );
} else {
$keys = $wpdb->get_col( "SELECT um.meta_key FROM {$wpdb->prefix}users u
JOIN {$wpdb->prefix}usermeta um
ON u.ID = um.user_id
GROUP BY meta_key
HAVING meta_key NOT LIKE '\_%' and meta_key NOT LIKE 'field_%' and meta_key NOT LIKE 'wpcf-%' and meta_key NOT LIKE 'wpcr3_%' and meta_key NOT LIKE '%pods%' and meta_key NOT LIKE '%group_%' and meta_key NOT LIKE '%repeat_%'
and meta_key NOT LIKE 'closedpostboxes_%' and meta_key NOT LIKE 'metaboxhidden_%' and meta_key NOT LIKE 'billing_%' and meta_key NOT LIKE 'aioseop_%' and meta_key NOT LIKE 'dismissed_%' and meta_key NOT LIKE 'manageedit-%'
and meta_key NOT LIKE 'wp_%' and AND meta_key NOT LIKE 'ywbc_%' AND meta_key NOT LIKE 'wc_%' and meta_key NOT LIKE 'mp_%' and meta_key NOT LIKE 'shipping_%' and meta_key NOT LIKE 'show_%' and meta_key NOT LIKE 'acf_%' and meta_key NOT LIKE 'user_%'
ORDER BY meta_key" );
}
foreach ($keys as $val) {
if(!in_array($val , $acf_values) && !empty($val) && !in_array($val , $pods) && !in_array($val , $acf) && !in_array($val,$jet_cpt) && !in_array($val,$jet_meta_field)){
$commonMetaFields['CORECUSTFIELDS'][$val]['label'] = $val;
$commonMetaFields['CORECUSTFIELDS'][$val]['name'] = $val;
}
}
$wp_custom_value = $this->convert_fields_to_array($commonMetaFields);
$response['wordpress_custom_fields'] = $wp_custom_value ;
return $response;
}
/**
* Wordpress Custom extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type){
if($import_type == 'nav_menu_item'){
return false;
}
if(!is_plugin_active('wpml-import/plugin.php')){
$active_plugin = array(
"masterstudy-lms-learning-management-system/masterstudy-lms-learning-management-system.php",
"seo-by-rank-math/rank-math.php",
"seo-by-rank-math-pro/rank-math-pro.php",
"jet-booking/jet-booking.php",
"jet-reviews/jet-reviews.php",
"jet-engine/jet-engine.php",
"advanced-custom-fields/acf.php",
"lifterlms/lifterlms.php",
"advanced-custom-fields-pro/acf.php",
"acf-repeater/acf-repeater.php",
"types/wpcf.php",
"pods/init.php",
"woocommerce/woocommerce.php",
"woocommerce-product-bundles/woocommerce-product-bundles.php",
"meta-box/meta-box.php",
"meta-box-aio/meta-box-aio.php",
"polylang/polylang.php",
"featured-image-from-url/featured-image-from-url.php",
"events-manager/events-manager.php",
"elementor-pro/elementor-pro.php",
"nextgen-gallery/nggallery.php",
"members/members.php",
"all-in-one-seo-pack/all_in_one_seo_pack.php",
"wp-seopress/seopress.php",
"wordpress-seo/wp-seo.php",
"bbpress/bbpress.php",
"learnpress/learnpress.php",
"sitepress-multilingual-cms/sitepress.php",
"wp-job-manager/wp-job-manager.php",
"wp-customer-reviews/wp-customer-reviews-3.php"
);
}
foreach($active_plugin as $value){
if(is_plugin_active("$value")){
return false;
}
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'Users' || $import_type == 'WooCommerce') {
return true;
}
}
}

View File

@@ -0,0 +1,97 @@
<?php
/**
* WP Ultimate CSV Importer plugin file.
*
* Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
*/
namespace Smackcoders\FCSV;
if ( ! defined( 'ABSPATH' ) )
exit; // Exit if accessed directly
class YoastSeoExtension extends ExtensionHandler{
private static $instance = null;
public static function getInstance() {
if (YoastSeoExtension::$instance == null) {
YoastSeoExtension::$instance = new YoastSeoExtension;
}
return YoastSeoExtension::$instance;
}
/**
* Provides Yoast Seo fields for specific post type
* @param string $data - selected import type
* @return array - mapping fields
*/
public function processExtension($data) {
$response = [];
$yoastseoFields = array(
'SEO Title' => 'title',
'Meta Description' => 'meta_desc',
'Meta Robots Index' => 'meta-robots-noindex',
'Meta Robots Follow' => 'meta-robots-nofollow',
'Meta Robots Advanced' => 'meta-robots-adv',
// It is comming as bctitle nowadays
'Breadcrumbs Title' => 'bctitle', // 'bread-crumbs-title',
// 'Include in Sitemap' => 'sitemap-include',
// 'Sitemap Priority' => 'sitemap-prio',
'Canonical URL' => 'canonical',
'301 Redirect' => 'redirect',
'Facebook Title' => 'opengraph-title',
'Facebook Description' => 'opengraph-description',
'Facebook Image' => 'opengraph-image',
'Twitter Title' => 'twitter-title',
'Twitter Description' => 'twitter-description',
'Twitter Image' => 'twitter-image',
'Google+ Title' => 'google-plus-title',
'Google+ Description' => 'google-plus-description',
'Google+ Image' => 'google-plus-image',
'Focus Keyword' => 'focus_keyword',
'Schema Page Type' => 'schema_page_type',
'Schema Article Type' => 'schema_article_type',
'Cornerstone Content' => 'cornerstone-content',
'Keyphrase' => 'focuskeywords',
'Synonyms' => 'keywordsynonyms'
);
//added - commented - cornerstone content is present in categories
// if(in_array($data , get_taxonomies())){
// unset($yoastseoFields['Cornerstone Content']);
// }
$yoast_seo_value = $this->convert_static_fields_to_array($yoastseoFields);
$response['yoast_seo_fields'] = $yoast_seo_value ;
return $response;
}
/**
* Yoast Seo extension supported import types
* @param string $import_type - selected import type
* @return boolean
*/
public function extensionSupportedImportType($import_type ){
if(is_plugin_active('wordpress-seo/wp-seo.php')){
if($import_type == 'nav_menu_item'){
return false;
}
$import_type = $this->import_name_as($import_type);
if($import_type == 'Posts' || $import_type == 'Pages' || $import_type == 'CustomPosts' || $import_type == 'event' || $import_type == 'event-recurring' || $import_type == 'location' || $import_type == 'WooCommerce' || $import_type =='WooCommerceattribute' || $import_type =='WooCommercetags' || $import_type == 'WPeCommerce' || $import_type == 'Taxonomies' || $import_type == 'Tags' || $import_type == 'Categories' ) {
return true;
}
if($import_type == 'ticket'){
if(is_plugin_active('events-manager/events-manager.php')){
return false;
}else{
return true;
}
}
else{
return false;
}
}
}
}