includes(); $this->api = new AfterShip_API(); $options = get_option('aftership_option_name'); if ($options) { if (isset($options['plugin'])) { $plugin = $options['plugin']; if ($plugin == 'aftership') { add_action('admin_print_scripts', array(&$this, 'library_scripts')); add_action('in_admin_footer', array(&$this, 'include_footer_script')); add_action('admin_print_styles', array(&$this, 'admin_styles')); add_action('add_meta_boxes', array(&$this, 'add_meta_box')); add_action('woocommerce_process_shop_order_meta', array(&$this, 'save_meta_box'), 0, 2); add_action('plugins_loaded', array($this, 'load_plugin_textdomain')); $this->couriers = $options['couriers']; } // View Order Page $this->plugin = $plugin; } else { $this->plugin = ''; } if (isset($options['use_track_button'])) { $this->use_track_button = $options['use_track_button']; } else { $this->use_track_button = false; } if (isset($options['custom_domain'])) { $this->custom_domain = $options['custom_domain']; } else { $this->custom_domain = ''; } add_action('woocommerce_view_order', array(&$this, 'display_tracking_info')); add_action('woocommerce_email_before_order_table', array(&$this, 'email_display')); } // user profile api key add_action('show_user_profile', array($this, 'add_api_key_field')); add_action('edit_user_profile', array($this, 'add_api_key_field')); add_action('personal_options_update', array($this, 'generate_api_key')); add_action('edit_user_profile_update', array($this, 'generate_api_key')); register_activation_hook(__FILE__, array($this, 'install')); } public function install() { global $wp_roles; if (class_exists('WP_Roles')) { if (!isset($wp_roles)) { $wp_roles = new WP_Roles(); } } if (is_object($wp_roles)) { $wp_roles->add_cap('administrator', 'manage_aftership'); } } private function includes() { include_once('aftership-fields.php'); $this->aftership_fields = $aftership_fields; include_once('class-aftership-api.php'); include_once('class-aftership-settings.php'); } /** * Localisation */ public function load_plugin_textdomain() { load_plugin_textdomain('aftership', false, dirname(plugin_basename(__FILE__)) . '/languages/'); } public function admin_styles() { wp_enqueue_style('aftership_styles_chosen', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.min.css'); wp_enqueue_style('aftership_styles', plugins_url(basename(dirname(__FILE__))) . '/assets/css/admin.css'); } public function library_scripts() { wp_enqueue_script('aftership_styles_chosen_jquery', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.jquery.min.js'); wp_enqueue_script('aftership_styles_chosen_proto', plugins_url(basename(dirname(__FILE__))) . '/assets/plugin/chosen/chosen.proto.min.js'); wp_enqueue_script('aftership_script_util', plugins_url(basename(dirname(__FILE__))) . '/assets/js/util.js'); wp_enqueue_script('aftership_script_couriers', plugins_url(basename(dirname(__FILE__))) . '/assets/js/couriers.js'); wp_enqueue_script('aftership_script_admin', plugins_url(basename(dirname(__FILE__))) . '/assets/js/admin.js'); } public function include_footer_script() { wp_enqueue_script('aftership_script_footer', plugins_url(basename(dirname(__FILE__))) . '/assets/js/footer.js', true); } /** * Add the meta box for shipment info on the order page * * @access public */ public function add_meta_box() { add_meta_box('woocommerce-aftership', __('AfterShip', 'wc_aftership'), array(&$this, 'meta_box'), 'shop_order', 'side', 'high'); } /** * Show the meta box for shipment info on the order page * * @access public */ public function meta_box() { // just draw the layout, no data global $post; $selected_provider = get_post_meta($post->ID, '_aftership_tracking_provider', true); echo '
';
echo '
Update carrier list';
echo '';
echo '';
foreach ($this->aftership_fields as $field) {
if ($field['type'] == 'date') {
woocommerce_wp_text_input(array(
'id' => $field['id'],
'label' => __($field['label'], 'wc_aftership'),
'placeholder' => $field['placeholder'],
'description' => $field['description'],
'class' => $field['class'],
'value' => ($date = get_post_meta($post->ID, '_' . $field['id'], true)) ? date('Y-m-d', $date) : ''
));
} else {
woocommerce_wp_text_input(array(
'id' => $field['id'],
'label' => __($field['label'], 'wc_aftership'),
'placeholder' => $field['placeholder'],
'description' => $field['description'],
'class' => $field['class'],
'value' => get_post_meta($post->ID, '_' . $field['id'], true),
));
}
}
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_provider_name',
// 'label' => __('', 'wc_aftership'),
// 'placeholder' => '',
// 'description' => '',
// 'class' => 'hidden',
// 'value' => get_post_meta($post->ID, '_aftership_tracking_provider_name', true),
// ));
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_required_fields',
// 'label' => __('', 'wc_aftership'),
// 'placeholder' => '',
// 'description' => '',
// 'class' => 'hidden',
// 'value' => get_post_meta($post->ID, '_aftership_tracking_required_fields', true),
// ));
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_number',
// 'label' => __('Tracking number:', 'wc_aftership'),
// 'placeholder' => '',
// 'description' => '',
// 'value' => get_post_meta($post->ID, '_aftership_tracking_number', true),
// ));
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_shipdate',
// 'label' => __('Date shipped:', 'wc_aftership'),
// 'placeholder' => 'YYYY-MM-DD',
// 'description' => '',
// 'class' => 'date-picker-field hidden-field',
// 'value' => ($date = get_post_meta($post->ID, '_aftership_tracking_shipdate', true)) ? date('Y-m-d', $date) : ''
// ));
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_postal',
// 'label' => __('Postal Code:', 'wc_aftership'),
// 'placeholder' => '',
// 'description' => '',
// 'class' => 'hidden-field',
// 'value' => get_post_meta($post->ID, '_aftership_tracking_postal', true),
// ));
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_account',
// 'label' => __('Account name:', 'wc_aftership'),
// 'placeholder' => '',
// 'description' => '',
// 'class' => 'hidden-field',
// 'value' => get_post_meta($post->ID, '_aftership_tracking_account', true),
// ));
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_key',
// 'label' => __('Tracking key:', 'wc_aftership'),
// 'placeholder' => '',
// 'description' => '',
// 'class' => 'hidden-field',
// 'value' => get_post_meta($post->ID, '_aftership_tracking_key', true),
// ));
//
// woocommerce_wp_text_input(array(
// 'id' => 'aftership_tracking_destination_country',
// 'label' => __('Destination Country:', 'wc_aftership'),
// 'placeholder' => '',
// 'description' => '',
// 'class' => 'hidden-field',
// 'value' => get_post_meta($post->ID, '_aftership_tracking_destination_country', true),
// ));
echo '
aftership_wp_api_key)) : ?>
aftership_wp_api_key ?>
|