-
Notifications
You must be signed in to change notification settings - Fork 0
/
Remove-Checkout-Fields-woo.php
66 lines (46 loc) · 1.79 KB
/
Remove-Checkout-Fields-woo.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
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Plugin Name: Remove Default Checkout Fields for Woocommerce
* Description: Remove default woocommerce Billing and Shipping Fields on Checkout page
*
* Author URI: https://khawais.com/
* Author: Khawaja Awais
* Version: 1.0
*
* Text Domain: Remove-Checkout-Fields
*
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
if (!defined('ABSPATH')) {
die('Access Denied');
}
add_action( 'activated_plugin', 'remvcheckoutfields_activation_redirect' );
function remvcheckoutfields_activation_redirect($plugin) {
if ( (class_exists( 'WC_Integration' )) && ( $plugin == plugin_basename( __FILE__ ) ) ) {
exit( wp_redirect( admin_url( 'admin.php?page=wc-settings&tab=remove_checkout_fields' ) ) );
}
}
//add settings link for plugin
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'rcf_settings_link' );
function rcf_settings_link ( $actions ) {
$rcf_settings = array(
'<a href="' . admin_url( 'admin.php?page=wc-settings&tab=remove_checkout_fields' ) . '">Settings</a>',
);
$actions = array_merge( $actions, $rcf_settings );
return $actions;
}
function remvcheckoutfields_admin_notice__error() {
if ( !class_exists( 'WC_Integration' ) ) {
$class = 'notice notice-error';
$message = __( " Plugin works only with woocommerce! You can deactivate plugin if you no longer use woocommerce.", 'Remove-Checkout-Fields' );
printf( '<div class="%1$s"><p><strong>Remove Checkout Fields</strong>%2$s</p></div>', esc_attr( $class ), esc_html( $message ) );
}
}
add_action( 'admin_notices', 'remvcheckoutfields_admin_notice__error' );
include('field-removal-options.php');
if (class_exists( 'RCF_WC_Remove_Checkout_Fields' )) {
RCF_WC_Remove_Checkout_Fields::init();
include('remove-fields.php');
}