Skip to content

Commit b927f02

Browse files
author
Maxime CULEA
committed
refactor to work with single export/import view
1 parent 1864d8b commit b927f02

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed

classes/admin/class-export.php

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
<?php
1+
<?php class MPT_Admin_Export {
22

3-
class MPT_Admin_Export {
43
public function __construct() {
4+
add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
55
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
66
}
77

8+
public static function admin_menu() {
9+
$hook = add_submenu_page( 'edit.php?post_type=member', self::get_page_title(), self::get_page_title(), 'manage_options', 'member-export', array( __CLASS__, 'page' ) );
10+
add_action( 'admin_head-' . $hook, array( __CLASS__, 'admin_head' ) );
11+
}
12+
13+
public static function admin_head() {
14+
wp_enqueue_style( MPT_CPT_NAME . '-post', MPT_URL . 'assets/css/admin.css', array(), MPT_VERSION, 'all' );
15+
}
16+
17+
public static function page() {
18+
include( MPT_DIR . 'views/admin/page-export.php' );
19+
}
20+
821
public static function admin_init() {
922
if ( isset( $_POST['mpt_action'] ) && $_POST['mpt_action'] == 'mpt_export_action' ) {
1023
return self::admin_init_export();
@@ -108,4 +121,17 @@ public static function prefix_header_meta( $name ) {
108121

109122
return 'meta:' . $name;
110123
}
124+
125+
/**
126+
* Get the import page title
127+
*
128+
* @author Maxime CULEA
129+
*
130+
* @since 0.6.0
131+
*
132+
* @return string
133+
*/
134+
public static function get_page_title() {
135+
return esc_html( __( 'Export members', 'mpt' ) );
136+
}
111137
}

classes/admin/class-import.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<?php
2-
3-
class MPT_Admin_Import {
1+
<?php class MPT_Admin_Import {
42
private static $_rapport_arr = array();
53
const option_name = "mpt_last_import_report";
64

@@ -10,10 +8,7 @@ public function __construct() {
108
}
119

1210
public static function admin_menu() {
13-
$hook = add_submenu_page( 'edit.php?post_type=member', MPT_Admin_Post_Type::get_import_export_title_page(), MPT_Admin_Post_Type::get_import_export_title_page(), 'manage_options', 'member-import-export', array(
14-
__CLASS__,
15-
'page'
16-
) );
11+
$hook = add_submenu_page( 'edit.php?post_type=member', self::get_page_title(), self::get_page_title(), 'manage_options', 'member-import', array( __CLASS__, 'page' ) );
1712
add_action( 'admin_head-' . $hook, array( __CLASS__, 'admin_head' ) );
1813
}
1914

@@ -24,7 +19,7 @@ public static function admin_head() {
2419
public static function page() {
2520
$report = get_option( self::option_name );
2621

27-
include( MPT_DIR . 'views/admin/page-import-export.php' );
22+
include( MPT_DIR . 'views/admin/page-import.php' );
2823
}
2924

3025
public static function admin_init() {
@@ -199,7 +194,7 @@ public static function insert_members( $rows ) {
199194
}
200195
}
201196
}
202-
197+
203198
return true;
204199
}
205200

@@ -246,4 +241,17 @@ private static function parse_headers( $headers ) {
246241
return $default_headers;
247242
}
248243
}
244+
245+
/**
246+
* Get the import page title
247+
*
248+
* @author Maxime CULEA
249+
*
250+
* @since 0.6.0
251+
*
252+
* @return string
253+
*/
254+
public static function get_page_title() {
255+
return esc_html( __( 'Import members', 'mpt' ) );
256+
}
249257
}

0 commit comments

Comments
 (0)