@@ -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,29 +20,29 @@ 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 | // Oxygen plugin |
| 33 | - if ( defined( 'CT_VERSION' ) ) { |
|
| 34 | - add_filter( 'wpinv_locate_template', array( $this, 'oxygen_override_template' ), 11, 4 ); |
|
| 35 | - } |
|
| 33 | + if ( defined( 'CT_VERSION' ) ) { |
|
| 34 | + add_filter( 'wpinv_locate_template', array( $this, 'oxygen_override_template' ), 11, 4 ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | - * Checks if this is a preview page |
|
| 41 | - * |
|
| 42 | - * @since 1.0.19 |
|
| 43 | - * @return bool |
|
| 44 | - */ |
|
| 45 | - public function is_preview() { |
|
| 40 | + * Checks if this is a preview page |
|
| 41 | + * |
|
| 42 | + * @since 1.0.19 |
|
| 43 | + * @return bool |
|
| 44 | + */ |
|
| 45 | + public function is_preview() { |
|
| 46 | 46 | return |
| 47 | 47 | $this->is_divi_preview() || |
| 48 | 48 | $this->is_elementor_preview() || |
@@ -54,73 +54,73 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * Checks if this is an elementor preview page |
|
| 58 | - * |
|
| 59 | - * @since 1.0.19 |
|
| 60 | - * @return bool |
|
| 61 | - */ |
|
| 62 | - public function is_elementor_preview() { |
|
| 63 | - return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Checks if this is a DIVI preview page |
|
| 68 | - * |
|
| 69 | - * @since 1.0.19 |
|
| 70 | - * @return bool |
|
| 71 | - */ |
|
| 72 | - public function is_divi_preview() { |
|
| 73 | - return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Checks if this is a beaver builder preview page |
|
| 78 | - * |
|
| 79 | - * @since 1.0.19 |
|
| 80 | - * @return bool |
|
| 81 | - */ |
|
| 82 | - public function is_beaver_preview() { |
|
| 83 | - return isset( $_REQUEST['fl_builder'] ); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Checks if this is a siteorigin builder preview page |
|
| 88 | - * |
|
| 89 | - * @since 1.0.19 |
|
| 90 | - * @return bool |
|
| 91 | - */ |
|
| 92 | - public function is_siteorigin_preview() { |
|
| 93 | - return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * Checks if this is a cornerstone builder preview page |
|
| 98 | - * |
|
| 99 | - * @since 1.0.19 |
|
| 100 | - * @return bool |
|
| 101 | - */ |
|
| 102 | - public function is_cornerstone_preview() { |
|
| 103 | - return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Checks if this is a fusion builder preview page |
|
| 108 | - * |
|
| 109 | - * @since 1.0.19 |
|
| 110 | - * @return bool |
|
| 111 | - */ |
|
| 112 | - public function is_fusion_preview() { |
|
| 113 | - return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Checks if this is an oxygen builder preview page |
|
| 118 | - * |
|
| 119 | - * @since 1.0.19 |
|
| 120 | - * @return bool |
|
| 121 | - */ |
|
| 122 | - public function is_oxygen_preview() { |
|
| 123 | - return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
| 57 | + * Checks if this is an elementor preview page |
|
| 58 | + * |
|
| 59 | + * @since 1.0.19 |
|
| 60 | + * @return bool |
|
| 61 | + */ |
|
| 62 | + public function is_elementor_preview() { |
|
| 63 | + return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Checks if this is a DIVI preview page |
|
| 68 | + * |
|
| 69 | + * @since 1.0.19 |
|
| 70 | + * @return bool |
|
| 71 | + */ |
|
| 72 | + public function is_divi_preview() { |
|
| 73 | + return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Checks if this is a beaver builder preview page |
|
| 78 | + * |
|
| 79 | + * @since 1.0.19 |
|
| 80 | + * @return bool |
|
| 81 | + */ |
|
| 82 | + public function is_beaver_preview() { |
|
| 83 | + return isset( $_REQUEST['fl_builder'] ); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Checks if this is a siteorigin builder preview page |
|
| 88 | + * |
|
| 89 | + * @since 1.0.19 |
|
| 90 | + * @return bool |
|
| 91 | + */ |
|
| 92 | + public function is_siteorigin_preview() { |
|
| 93 | + return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * Checks if this is a cornerstone builder preview page |
|
| 98 | + * |
|
| 99 | + * @since 1.0.19 |
|
| 100 | + * @return bool |
|
| 101 | + */ |
|
| 102 | + public function is_cornerstone_preview() { |
|
| 103 | + return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Checks if this is a fusion builder preview page |
|
| 108 | + * |
|
| 109 | + * @since 1.0.19 |
|
| 110 | + * @return bool |
|
| 111 | + */ |
|
| 112 | + public function is_fusion_preview() { |
|
| 113 | + return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Checks if this is an oxygen builder preview page |
|
| 118 | + * |
|
| 119 | + * @since 1.0.19 |
|
| 120 | + * @return bool |
|
| 121 | + */ |
|
| 122 | + public function is_oxygen_preview() { |
|
| 123 | + return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
| 131 | 131 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 132 | 132 | */ |
| 133 | - public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 133 | + public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
| 134 | 134 | |
| 135 | 135 | // Load the defaults for the template path and default path. |
| 136 | 136 | $template_path = empty( $template_path ) ? 'invoicing' : $template_path; |
@@ -151,22 +151,22 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | - * Loads a template |
|
| 155 | - * |
|
| 156 | - * @since 1.0.19 |
|
| 157 | - * @return bool |
|
| 158 | - */ |
|
| 159 | - protected function load_template( $template_name, $template_path, $args ) { |
|
| 154 | + * Loads a template |
|
| 155 | + * |
|
| 156 | + * @since 1.0.19 |
|
| 157 | + * @return bool |
|
| 158 | + */ |
|
| 159 | + protected function load_template( $template_name, $template_path, $args ) { |
|
| 160 | 160 | |
| 161 | 161 | if ( is_array( $args ) ){ |
| 162 | 162 | extract( $args ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Fires before loading a template. |
| 166 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
| 166 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
| 167 | 167 | |
| 168 | 168 | // Load the template. |
| 169 | - include( $template_path ); |
|
| 169 | + include( $template_path ); |
|
| 170 | 170 | |
| 171 | 171 | // Fires after loading a template. |
| 172 | 172 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $args ); |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 184 | 184 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 185 | 185 | */ |
| 186 | - public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 186 | + public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 187 | 187 | |
| 188 | 188 | // Locate the template. |
| 189 | 189 | $located = $this->locate_template( $template_name, $template_path, $default_path ); |
@@ -208,74 +208,74 @@ discard block |
||
| 208 | 208 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
| 209 | 209 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
| 210 | 210 | */ |
| 211 | - public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 211 | + public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
| 212 | 212 | ob_start(); |
| 213 | 213 | $this->display_template( $template_name, $args, $template_path, $default_path ); |
| 214 | 214 | return ob_get_clean(); |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | /** |
| 218 | - * Get the geodirectory templates theme path. |
|
| 219 | - * |
|
| 220 | - * |
|
| 221 | - * @return string Template path. |
|
| 222 | - */ |
|
| 223 | - public static function get_theme_template_path() { |
|
| 224 | - $template = get_template(); |
|
| 225 | - $theme_root = get_theme_root( $template ); |
|
| 226 | - |
|
| 227 | - return $theme_root . '/' . $template . '/' . untrailingslashit( wpinv_get_theme_template_dir_name() ); |
|
| 228 | - |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Oxygen locate theme template. |
|
| 233 | - * |
|
| 234 | - * @param string $template The template. |
|
| 235 | - * @return string The theme template. |
|
| 236 | - */ |
|
| 237 | - public static function oxygen_locate_template( $template ) { |
|
| 238 | - |
|
| 239 | - if ( empty( $template ) ) { |
|
| 240 | - return ''; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - $has_filter = has_filter( 'template', 'ct_oxygen_template_name' ); |
|
| 244 | - |
|
| 245 | - // Remove template filter |
|
| 246 | - if ( $has_filter ) { |
|
| 247 | - remove_filter( 'template', 'ct_oxygen_template_name' ); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - $template = self::get_theme_template_path() . '/' . $template; |
|
| 251 | - |
|
| 252 | - if ( ! file_exists( $template ) ) { |
|
| 253 | - $template = ''; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - // Add template filter |
|
| 257 | - if ( $has_filter ) { |
|
| 258 | - add_filter( 'template', 'ct_oxygen_template_name' ); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - return $template; |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Oxygen override theme template. |
|
| 266 | - * |
|
| 267 | - * @param string $located Located template. |
|
| 268 | - * @param string $template_name Template name. |
|
| 269 | - * @return string Located template. |
|
| 270 | - */ |
|
| 271 | - public function oxygen_override_template( $located, $template_name ) { |
|
| 218 | + * Get the geodirectory templates theme path. |
|
| 219 | + * |
|
| 220 | + * |
|
| 221 | + * @return string Template path. |
|
| 222 | + */ |
|
| 223 | + public static function get_theme_template_path() { |
|
| 224 | + $template = get_template(); |
|
| 225 | + $theme_root = get_theme_root( $template ); |
|
| 226 | + |
|
| 227 | + return $theme_root . '/' . $template . '/' . untrailingslashit( wpinv_get_theme_template_dir_name() ); |
|
| 228 | + |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Oxygen locate theme template. |
|
| 233 | + * |
|
| 234 | + * @param string $template The template. |
|
| 235 | + * @return string The theme template. |
|
| 236 | + */ |
|
| 237 | + public static function oxygen_locate_template( $template ) { |
|
| 238 | + |
|
| 239 | + if ( empty( $template ) ) { |
|
| 240 | + return ''; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + $has_filter = has_filter( 'template', 'ct_oxygen_template_name' ); |
|
| 244 | + |
|
| 245 | + // Remove template filter |
|
| 246 | + if ( $has_filter ) { |
|
| 247 | + remove_filter( 'template', 'ct_oxygen_template_name' ); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + $template = self::get_theme_template_path() . '/' . $template; |
|
| 251 | + |
|
| 252 | + if ( ! file_exists( $template ) ) { |
|
| 253 | + $template = ''; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + // Add template filter |
|
| 257 | + if ( $has_filter ) { |
|
| 258 | + add_filter( 'template', 'ct_oxygen_template_name' ); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + return $template; |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Oxygen override theme template. |
|
| 266 | + * |
|
| 267 | + * @param string $located Located template. |
|
| 268 | + * @param string $template_name Template name. |
|
| 269 | + * @return string Located template. |
|
| 270 | + */ |
|
| 271 | + public function oxygen_override_template( $located, $template_name ) { |
|
| 272 | 272 | |
| 273 | 273 | $oxygen_overide = self::oxygen_locate_template( $template_name ); |
| 274 | - if ( ! empty( $oxygen_overide ) ) { |
|
| 275 | - return $oxygen_overide; |
|
| 276 | - } |
|
| 274 | + if ( ! empty( $oxygen_overide ) ) { |
|
| 275 | + return $oxygen_overide; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - return $located; |
|
| 279 | - } |
|
| 278 | + return $located; |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | 281 | } |