-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
54 lines (45 loc) · 1.65 KB
/
main.php
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
<?php
/*
* Plugin Name: WC Postcode Names
* Plugin URI: https://www.enigmaweb.com.au
* Description: Allows you to specify shipping zone names in WooCommerce using WooCommerce Postcodes
* Author: Enigma Web
* Author URI: https://www.enigmaweb.com.au
* Version: 1.0
*/
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
include( ABSPATH . 'wp-content\plugins\woocommerce\includes\class-wc-shipping-zones.php' );
include 'includes/WCPostCodes.php';
$postcodes = null;
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
register_activation_hook( plugin_basename( 'wc-postcode-names\main.php' ), array( $this, 'onActivation' ) );
add_action( 'admin_menu', 'adminMenu' );
} else {
deactivate_plugins( plugin_basename( 'wc-postcode-names\main.php' ) );
errorMsg( 'Shipping Zones plugin requires WooCommerce to be activated in order to work. Please install and
activate WooCommerce and then try again.', 'deactivated' );
}
function errorMsg( $message, $identifier ) {
echo '<div class="notice notice-error is-dismissible">';
echo '<p>' . __( $message,
'wc-postcode-names-' . $identifier ) . '</p>';
echo '</div>';
}
function onActivation() {
}
function adminMenu() {
add_submenu_page(
'woocommerce' //Parent Slug
, 'Shipping Zones' //Page Title
, 'Shipping Zones' //Menu Title
, 'manage_options' // User Capability
, 'shipping_zones' // Menu slug
, 'pluginPage' // Call back function
);
}
function pluginPage() {
$postcodes = new WCPostCodes();
echo '<pre>';
print_r( $postcodes->PostcodeToShipzones() );
echo '</pre>';
}