-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgwiz-batcher.php
More file actions
49 lines (40 loc) · 1.27 KB
/
Copy pathgwiz-batcher.php
File metadata and controls
49 lines (40 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
* Plugin Name: Gravity Wiz Batcher: Media Library Upload Previously Uploaded Files
* Plugin URI: http://gravitywiz.com
* Description: Batcher to import all media files uploaded before the GP Media Library Perk was activated.
* Author: Gravity Wiz
* Version: 0.1
* Author URI: http://gravitywiz.com
*/
add_action( 'init', 'gwiz_batcher' );
function gwiz_batcher() {
if ( ! is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
return;
}
require_once( plugin_dir_path( __FILE__ ) . 'class-gwiz-batcher.php' );
new Gwiz_Batcher( array(
'title' => 'GPML Importer',
'id' => 'gpml-importer',
'size' => 100,
'show_form_selector' => true,
'get_items' => function ( $size, $offset, $form_id = null ) {
$paging = array(
'offset' => $offset,
'page_size' => $size,
);
$search_criteria = array(
'status' => 'active',
);
$entries = GFAPI::get_entries( $form_id, $search_criteria, null, $paging, $total );
return array(
'items' => $entries,
'total' => $total,
);
},
'process_item' => function ( $entry ) {
$form = GFAPI::get_form( $entry['form_id'] );
gp_media_library()->maybe_upload_to_media_library( $entry, $form );
},
) );
}