forked from baselbers/woocommerce-pdf-invoices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.php
executable file
·100 lines (84 loc) · 2.83 KB
/
bootstrap.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
<?php
/**
* Plugin Name: WooCommerce PDF Invoices
* Plugin URI: https://wordpress.org/plugins/woocommerce-pdf-invoices
* Description: Automatically generate and attach customizable PDF Invoices to WooCommerce emails and connect with Dropbox, Google Drive, OneDrive or Egnyte.
* Version: 3.1.4
* Author: Bas Elbers
* Author URI: http://wcpdfinvoices.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: woocommerce-pdf-invoices
* Domain Path: /lang
* WC requires at least: 3.0.0
* WC tested up to: 4.5
*/
defined( 'ABSPATH' ) || exit;
define( 'WPI_VERSION', '3.1.4' );
/**
* Load WooCommerce PDF Invoices plugin.
*/
function _bewpi_load_plugin() {
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
if ( ! defined( 'WPI_FILE' ) ) {
define( 'WPI_FILE', __FILE__ );
}
if ( ! defined( 'WPI_DIR' ) ) {
define( 'WPI_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
}
if ( file_exists( WPI_DIR . '/vendor/autoload.php' ) ) {
require_once WPI_DIR . '/vendor/autoload.php';
}
/**
* Main instance of BE_WooCommerce_PDF_Invoices.
*
* @return BE_WooCommerce_PDF_Invoices
* @since 2.9.1
*/
function WPI() {
return BE_WooCommerce_PDF_Invoices::instance();
}
WPI();
if ( is_admin() ) {
add_action( 'admin_init', '_bewpi_on_plugin_update' );
}
}
add_action( 'plugins_loaded', '_bewpi_load_plugin', 10 );
/**
* On plugin update.
*
* @since 2.5.0
*/
function _bewpi_on_plugin_update() {
// As per 3.0.9 we need to change the company logo to the attachment id.
$company_logo_url = WPI()->get_option( 'template', 'company_logo' );
if ( version_compare( WPI_VERSION, '3.0.9' ) >= 0 && ! empty( $company_logo_url ) && filter_var( $company_logo_url, FILTER_VALIDATE_URL ) ) {
$template_settings = get_option( 'bewpi_template_settings' );
$template_settings['bewpi_company_logo'] = (string) attachment_url_to_postid( $company_logo_url );
update_option( 'bewpi_template_settings', $template_settings );
}
if ( WPI_VERSION !== get_site_option( 'bewpi_version' ) ) {
WPI()->setup_directories();
WPI()->setup_options();
update_site_option( 'bewpi_version', WPI_VERSION );
}
}
/**
* Save install date, plugin version to db and set transient to show activation notice.
*
* @since 2.5.0
*/
function _bewpi_on_plugin_activation() {
add_site_option( 'bewpi_install_date', current_time( 'mysql' ) );
set_transient( 'bewpi-admin-notice-activation', true, 30 );
}
register_activation_hook( __FILE__, '_bewpi_on_plugin_activation' );
/**
* Plugin uninstall hook.
*/
function _bewpi_on_plugin_uninstall() {
delete_site_option( 'bewpi_version' );
}
register_uninstall_hook( __FILE__, '_bewpi_on_plugin_uninstall' );