-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgfexcel.php
145 lines (117 loc) · 4.23 KB
/
gfexcel.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
144
145
<?php
/**
* Plugin Name: GravityExport Lite
* Version: 2.3.7
* Plugin URI: https://gfexcel.com
* Description: Export all Gravity Forms entries to Excel (.xlsx) or CSV via a secret shareable URL.
* Author: GravityKit
* Author URI: https://www.gravitykit.com/extensions/gravityexport/
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: gk-gravityexport-lite
* Domain Path: /languages
*
* @package GFExcel
*/
defined( 'ABSPATH' ) or die( 'No direct access!' );
use GFExcel\Action\ActionAwareInterface;
use GFExcel\Addon\GravityExportAddon;
use GFExcel\Container\Container;
use GFExcel\GFExcel;
use GFExcel\ServiceProvider\AddOnProvider;
use GFExcel\ServiceProvider\BaseServiceProvider;
if ( ! defined( 'GFEXCEL_PLUGIN_FILE' ) ) {
define( 'GFEXCEL_PLUGIN_FILE', __FILE__ );
}
if ( ! defined( 'GFEXCEL_PLUGIN_VERSION' ) ) {
define( 'GFEXCEL_PLUGIN_VERSION', '2.3.7' );
}
if ( ! defined( 'GFEXCEL_MIN_PHP_VERSION' ) ) {
define( 'GFEXCEL_MIN_PHP_VERSION', '7.2' );
}
$src_folder = __DIR__ . '/build/vendor_prefixed/gravitykit/gravityexport-lite-src';
if ( ! is_readable( $src_folder ) ) {
$src_folder = __DIR__ . '/src';
}
define( 'GFEXCEL_SRC_FOLDER', $src_folder );
if ( version_compare( phpversion(), GFEXCEL_MIN_PHP_VERSION, '<' ) ) {
$show_minimum_php_version_message = function () {
$message = wpautop( sprintf( esc_html__( 'GravityExport Lite requires PHP %s or newer.', 'gk-gravityexport-lite' ), GFEXCEL_MIN_PHP_VERSION ) );
echo "<div class='error'>$message</div>";
};
add_action( 'admin_notices', $show_minimum_php_version_message );
return;
}
add_action( 'init', static function (): void {
load_plugin_textdomain( 'gk-gravityexport-lite', false, basename( __DIR__ ) . '/languages' );
} );
add_action( 'gform_loaded', static function (): void {
if ( ! class_exists( 'GFForms' ) || ! method_exists( 'GFForms', 'include_addon_framework' ) ) {
return;
}
GFForms::include_addon_framework();
GFForms::include_feed_addon_framework();
if ( ! class_exists( 'GFExport' ) ) {
require_once( GFCommon::get_base_path() . '/export.php' );
}
$autoload_file = __DIR__ . '/build/vendor/autoload.php';
$is_build = true;
if ( ! file_exists( $autoload_file ) ) {
$autoload_file = __DIR__ . '/vendor/autoload.php';
$is_build = false;
}
require_once $autoload_file;
if ( $is_build ) {
// Make old class names available as aliases if possible.
$class_aliases = [
'PhpOffice\PhpSpreadsheet\Document\Properties',
'PhpOffice\PhpSpreadsheet\IOFactory',
'PhpOffice\PhpSpreadsheet\Worksheet\PageSetup',
'PhpOffice\PhpSpreadsheet\Writer\Exception',
'PhpOffice\PhpSpreadsheet\Spreadsheet',
'PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf',
'PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf',
];
foreach ( $class_aliases as $alias ) {
if (
class_exists( $alias )
|| interface_exists( $alias )
) {
continue;
}
class_alias( 'GFExcel\Vendor\\' . $alias, $alias );
}
// Also autoload any old class as possible class aliases.
spl_autoload_register( function ( string $class ) {
if ( strpos( $class, 'PhpOffice\\PhpSpreadsheet\\' ) === 0 ) {
$target = 'GFExcel\\Vendor\\' . $class;
if ( class_exists( $target ) || interface_exists( $target ) ) {
class_alias( $target, $class );
}
}
} );
}
// Start DI container.
$container = ( new Container() )
// add internal service provider
->addServiceProvider( new BaseServiceProvider() )
->addServiceProvider( new AddOnProvider() );
// Instantiate add on from container.
$addon = $container->get( GravityExportAddon::class );
// Set instance for Gravity Forms and register the add-on.
GravityExportAddon::set_instance( $addon );
GFAddOn::register( GravityExportAddon::class );
$addon->setAssetsDir( plugin_dir_url( GFEXCEL_PLUGIN_FILE ) . 'public/' );
// Dispatch event including the container.
do_action( 'gfexcel_loaded', $container );
// Start actions
if ( $container->has( ActionAwareInterface::ACTION_TAG ) ) {
$container->get( ActionAwareInterface::ACTION_TAG );
}
if ( $container->has( AddOnProvider::AUTOSTART_TAG ) ) {
$container->get( AddOnProvider::AUTOSTART_TAG );
}
if ( ! is_admin() ) {
$container->get( GFExcel::class );
}
} );