Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mehrshaddarzi/simple-import-export

Simple Process For Big Data in WordPress ( Import/Export )
https://github.com/mehrshaddarzi/simple-import-export

woocommerce wordpress wordpress-development wordpress-plugin

Last synced: 26 days ago
JSON representation

Simple Process For Big Data in WordPress ( Import/Export )

Awesome Lists containing this project

README

        

### Simple Process For Big Data in WordPress ( Import/Export )

#### Add New Export Method

```php
add_filter('simple_import_export_type_lists_at_export', [$this, 'method']);
add_filter('simple_prepare_data_for_export', [$this, 'export'], 20, 3);
add_action('simple_import_export_form_fields_export', [$this, 'export_custom_form_field']);

public function method($array)
{
$array['wp_posts'] = __('WordPress Posts', 'simple-import-export');
return $array;
}

public function export($data, $type, $extension)
{
if ($type != 'wp_posts') {
return $data;
}

// Get Data
$posts = new \WP_Query(array(
'post_type' => trim($_REQUEST['post_type']),
'post_status' => 'publish',
'posts_per_page' => '-1',
'order' => 'ASC',
'fields' => 'all',
'cache_results' => false,
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'suppress_filters' => true
));

// Setup PHP Array
$columns = array(
'ID',
'Title',
'Date'
);
$data = [$columns];

// Setup Item
foreach ($posts as $post) {
$data[] = array(
$post->ID,
$post->post_title,
$post->post_date
);
}

// Return
return $data;
}

public function export_custom_form_field()
{
?>










labels->singular_name; ?> [name; ?>]





post_title;
$new_title = trim($row[1]); // Title
if (!empty($new_title) and $new_title != $before_post_title and $option['input']['post_status'] == $post->post_status) {

$arg = array(
'ID' => $post_id,
'post_title' => $new_title
);
wp_update_post($arg);
}
}

return $return;
}

public function import_custom_form_field()
{
?>










label; ?> [name; ?>]





__('Import/Export', 'simple-import-export'),
'page_title' => __('Simple Import / Export', 'simple-import-export'),
'capability' => 'manage_options',
'icon' => 'dashicons-database',
'position' => 90
];
}
```