forked from AyeCode/invoicing-quotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpinv-quote.php
143 lines (126 loc) · 5.49 KB
/
wpinv-quote.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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://wpinvoicing.com
* @since 1.0.0
* @package Wpinv_Quotes
*
* @wordpress-plugin
* Plugin Name: Invoicing - Quotes
* Plugin URI: https://wpinvoicing.com/
* Description: Create quotes for customers, if accepted it will convert to an invoice that can be paid.
* Version: 1.0.6
* Author: AyeCode Ltd
* Author URI: https://wpinvoicing.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: wpinv-quotes
* Domain Path: /languages
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
define('WPINV_QUOTES_VERSION', '1.0.6');
define('WPINV_QUOTES_PATH', plugin_dir_path(__FILE__));
define('WPINV_QUOTES_URL', plugin_dir_url(__FILE__));
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-wpinv-quotes-activator.php
*/
function activate_wpinv_quotes($network_wide = false)
{
require_once plugin_dir_path(__FILE__) . 'includes/class-wpinv-quotes-activator.php';
Wpinv_Quotes_Activator::activate($network_wide);
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-wpinv-quotes-deactivator.php
*/
function deactivate_wpinv_quotes()
{
require_once plugin_dir_path(__FILE__) . 'includes/class-wpinv-quotes-deactivator.php';
Wpinv_Quotes_Deactivator::deactivate();
}
register_activation_hook(__FILE__, 'activate_wpinv_quotes');
register_deactivation_hook(__FILE__, 'deactivate_wpinv_quotes');
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
require plugin_dir_path(__FILE__) . 'includes/class-wpinv-quotes.php';
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-wpinv-quotes-deactivator.php
*/
function wpinv_invoice_plugin_notice()
{
echo '<div class="error"><p>Quote Plugin requires the <a href="https://wordpress.org/plugins/invoicing/" target="_blank">invoicing</a> plugin to be installed and active.</p></div>';
}
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 1.0.0
*/
function run_wpinv_quotes()
{
if ( is_admin() && current_user_can( 'activate_plugins' ) && !class_exists( 'WPInv_Plugin' ) ) {
/**
* The plugin activation class that will install and activate Invoicing if missing.
*/
require plugin_dir_path(__FILE__) . 'includes/class-tgm-plugin-activation.php';
add_action( 'tgmpa_register', 'wpinv_quotes_register_required_plugins' );
/**
* Require the Invoicing plugin to be installed.
*/
function wpinv_quotes_register_required_plugins() {
/*
* Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
$plugins = array(
array(
'name' => 'Invoicing',
'slug' => 'invoicing',
'required' => true,
'force_activation' => true
)
);
/*
* Array of configuration settings. Amend each line as needed.
*
* TGMPA will start providing localized text strings soon. If you already have translations of our standard
* strings available, please help us make TGMPA even better by giving us access to these translations or by
* sending in a pull-request with .po file(s) with the translations.
*
* Only uncomment the strings in the config array if you want to customize the strings.
*/
$config = array(
'id' => 'wpinv-quotes', // Unique ID for hashing notices for multiple instances of TGMPA.
'parent_slug' => 'plugins.php', // Parent menu slug.
'capability' => 'manage_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => false, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => true, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
);
tgmpa( $plugins, $config );
}
add_action( 'admin_notices', 'wpinv_invoice_plugin_notice' ) ;
return;
}
$plugin = new Wpinv_Quotes();
$plugin->run();
}
add_action('plugins_loaded', 'run_wpinv_quotes'); // wait until 'plugins_loaded' hook fires, for WP Multisite compatibility