-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigration.php
More file actions
123 lines (110 loc) · 4.06 KB
/
migration.php
File metadata and controls
123 lines (110 loc) · 4.06 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
* @package Awesome Support Migration
* @author ThemeAvenue <web@themeavenue.net>
* @license GPL-2.0+
* @link http://themeavenue.net
* @copyright 2014 ThemeAvenue
*
* @wordpress-plugin
* Plugin Name: Awesome Support Migration
* Plugin URI: http://getawesomesupport.com
* Description: This tool will help you migrate from Awesome Support version 2.x to version 3
* Version: 0.1.0
* Author: ThemeAvenue
* Author URI: http://themeavenue.net
* Text Domain: wpas
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'ASM_VERSION', '0.1.0' );
define( 'ASM_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'ASM_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
add_action( 'admin_menu', 'asm_tools_submenu' );
/**
* Add the Tools item submneu.
*
* @return void
*/
function asm_tools_submenu() {
add_submenu_page( 'tools.php', 'Awesome Support Migration', 'AS Migration', 'manage_options', 'wpas-upgrade', 'asm_migrate_page' );
}
/**
* Display the migration tool admin page content.
*
* @return void
*/
function asm_migrate_page() {
require_once( ASM_PATH . 'includes/views/migration.php' );
}
add_action( 'admin_print_scripts', 'asm_load_scripts' );
/**
* Load the plugin script.
*
* @since 1.0.0
* @return bool Whether or not the script was enqueued
*/
function asm_load_scripts() {
if ( isset( $_GET['page'] ) && 'wpas-upgrade' === $_GET['page'] ) {
wp_enqueue_script( 'asm_migration', ASM_URL . 'migration.js', array( 'jquery' ), ASM_VERSION, true );
}
}
/**
* Everything that happens now must be limited to the upgrade page only.
*/
if ( isset( $_GET['page'] ) && 'wpas-upgrade' === filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ) ) {
/**
* Load all converters.
*/
require_once( ASM_PATH . 'includes/class-wpas-migrate-tickets.php' );
require_once( ASM_PATH . 'includes/class-wpas-migrate-ticket.php' );
require_once( ASM_PATH . 'includes/class-wpas-migrate-attachment.php' );
require_once( ASM_PATH . 'includes/class-wpas-migrate-custom-fields.php' );
add_action( 'init', 'asm_register_taxonomies' );
/**
* Register the taxonomies used in version 2.
*
* We need those taxonomies in order to retrieve all the values
* that we want to convert.
*
* @return void
*/
function asm_register_taxonomies() {
$status_labels = array(
'name' => _x( 'Status', 'taxonomy general name', 'wpas' ),
'singular_name' => _x( 'Status', 'taxonomy singular name', 'wpas' ),
'search_items' => __( 'Search Statuses', 'wpas' ),
'all_items' => __( 'All Statuses', 'wpas' ),
'parent_item' => __( 'Parent Status', 'wpas' ),
'parent_item_colon' => __( 'Parent Status:', 'wpas' ),
'edit_item' => __( 'Edit Status', 'wpas' ),
'update_item' => __( 'Update Status', 'wpas' ),
'add_new_item' => __( 'Add New Status', 'wpas' ),
'new_item_name' => __( 'New Status Name', 'wpas' ),
'menu_name' => __( 'Status', 'wpas' )
);
$status_args = array(
'hierarchical' => true,
'labels' => $status_labels,
'show_ui' => false,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'status' ),
'capabilities' => array(
'manage_terms' => 'cannot_do',
'edit_terms' => 'cannot_do',
'delete_terms' => 'cannot_do',
'assign_terms' => 'close_ticket'
),
);
register_taxonomy( 'status', array( 'ticket', 'tickets' ), $status_args );
register_taxonomy( 'type', array( 'ticket', 'tickets' ), array( 'labels' => array( 'name' => 'Type' ) ) );
register_taxonomy( 'priority', array( 'ticket', 'tickets' ), array( 'labels' => array( 'name' => 'Priority' ) ) );
register_taxonomy( 'state', array( 'ticket', 'tickets' ), array( 'labels' => array( 'name' => 'State' ) ) );
}
}