@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -20,23 +20,23 @@ discard block |
||
20 | 20 | public $templates_url; |
21 | 21 | |
22 | 22 | /** |
23 | - * Class constructor. |
|
24 | - * |
|
25 | - * @since 1.0.19 |
|
26 | - */ |
|
27 | - public function __construct() { |
|
23 | + * Class constructor. |
|
24 | + * |
|
25 | + * @since 1.0.19 |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | 28 | |
29 | 29 | $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' ); |
30 | 30 | $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' ); |
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | - * Checks if this is a preview page |
|
35 | - * |
|
36 | - * @since 1.0.19 |
|
37 | - * @return bool |
|
38 | - */ |
|
39 | - public function is_preview() { |
|
34 | + * Checks if this is a preview page |
|
35 | + * |
|
36 | + * @since 1.0.19 |
|
37 | + * @return bool |
|
38 | + */ |
|
39 | + public function is_preview() { |
|
40 | 40 | return |
41 | 41 | $this->is_divi_preview() || |
42 | 42 | $this->is_elementor_preview() || |
@@ -48,73 +48,73 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * Checks if this is an elementor preview page |
|
52 | - * |
|
53 | - * @since 1.0.19 |
|
54 | - * @return bool |
|
55 | - */ |
|
56 | - public function is_elementor_preview() { |
|
57 | - return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Checks if this is a DIVI preview page |
|
62 | - * |
|
63 | - * @since 1.0.19 |
|
64 | - * @return bool |
|
65 | - */ |
|
66 | - public function is_divi_preview() { |
|
67 | - return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Checks if this is a beaver builder preview page |
|
72 | - * |
|
73 | - * @since 1.0.19 |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function is_beaver_preview() { |
|
77 | - return isset( $_REQUEST['fl_builder'] ); |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Checks if this is a siteorigin builder preview page |
|
82 | - * |
|
83 | - * @since 1.0.19 |
|
84 | - * @return bool |
|
85 | - */ |
|
86 | - public function is_siteorigin_preview() { |
|
87 | - return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Checks if this is a cornerstone builder preview page |
|
92 | - * |
|
93 | - * @since 1.0.19 |
|
94 | - * @return bool |
|
95 | - */ |
|
96 | - public function is_cornerstone_preview() { |
|
97 | - return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Checks if this is a fusion builder preview page |
|
102 | - * |
|
103 | - * @since 1.0.19 |
|
104 | - * @return bool |
|
105 | - */ |
|
106 | - public function is_fusion_preview() { |
|
107 | - return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Checks if this is an oxygen builder preview page |
|
112 | - * |
|
113 | - * @since 1.0.19 |
|
114 | - * @return bool |
|
115 | - */ |
|
116 | - public function is_oxygen_preview() { |
|
117 | - return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
51 | + * Checks if this is an elementor preview page |
|
52 | + * |
|
53 | + * @since 1.0.19 |
|
54 | + * @return bool |
|
55 | + */ |
|
56 | + public function is_elementor_preview() { |
|
57 | + return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Checks if this is a DIVI preview page |
|
62 | + * |
|
63 | + * @since 1.0.19 |
|
64 | + * @return bool |
|
65 | + */ |
|
66 | + public function is_divi_preview() { |
|
67 | + return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Checks if this is a beaver builder preview page |
|
72 | + * |
|
73 | + * @since 1.0.19 |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function is_beaver_preview() { |
|
77 | + return isset( $_REQUEST['fl_builder'] ); |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Checks if this is a siteorigin builder preview page |
|
82 | + * |
|
83 | + * @since 1.0.19 |
|
84 | + * @return bool |
|
85 | + */ |
|
86 | + public function is_siteorigin_preview() { |
|
87 | + return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Checks if this is a cornerstone builder preview page |
|
92 | + * |
|
93 | + * @since 1.0.19 |
|
94 | + * @return bool |
|
95 | + */ |
|
96 | + public function is_cornerstone_preview() { |
|
97 | + return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Checks if this is a fusion builder preview page |
|
102 | + * |
|
103 | + * @since 1.0.19 |
|
104 | + * @return bool |
|
105 | + */ |
|
106 | + public function is_fusion_preview() { |
|
107 | + return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Checks if this is an oxygen builder preview page |
|
112 | + * |
|
113 | + * @since 1.0.19 |
|
114 | + * @return bool |
|
115 | + */ |
|
116 | + public function is_oxygen_preview() { |
|
117 | + return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
125 | 125 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
126 | 126 | */ |
127 | - public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
127 | + public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
128 | 128 | |
129 | 129 | // Load the defaults for the template path and default path. |
130 | 130 | $template_path = empty( $template_path ) ? 'invoicing' : $template_path; |
@@ -145,22 +145,22 @@ discard block |
||
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
148 | - * Loads a template |
|
149 | - * |
|
150 | - * @since 1.0.19 |
|
151 | - * @return bool |
|
152 | - */ |
|
153 | - protected function load_template( $template_name, $template_path, $args ) { |
|
148 | + * Loads a template |
|
149 | + * |
|
150 | + * @since 1.0.19 |
|
151 | + * @return bool |
|
152 | + */ |
|
153 | + protected function load_template( $template_name, $template_path, $args ) { |
|
154 | 154 | |
155 | 155 | if ( is_array( $args ) ){ |
156 | 156 | extract( $args ); |
157 | 157 | } |
158 | 158 | |
159 | 159 | // Fires before loading a template. |
160 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
160 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
161 | 161 | |
162 | 162 | // Load the template. |
163 | - include( $template_path ); |
|
163 | + include( $template_path ); |
|
164 | 164 | |
165 | 165 | // Fires after loading a template. |
166 | 166 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $args ); |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
178 | 178 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
179 | 179 | */ |
180 | - public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
180 | + public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
181 | 181 | |
182 | 182 | // Locate the template. |
183 | 183 | $located = $this->locate_template( $template_name, $template_path, $default_path ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
203 | 203 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
204 | 204 | */ |
205 | - public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
205 | + public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
206 | 206 | ob_start(); |
207 | 207 | $this->display_template( $template_name, $args, $template_path, $default_path ); |
208 | 208 | return ob_get_clean(); |