Skip to content

Commit d63146d

Browse files
author
Miika Arponen
committed
Added the option to disable DustPress via an action hook
1 parent 37590a1 commit d63146d

File tree

1 file changed

+35
-12
lines changed

1 file changed

+35
-12
lines changed

dustpress.php

+35-12
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class DustPress {
4040
// Possible errors to disable
4141
private $errors;
4242

43+
// Is DustPress disabled?
44+
public $disabled;
45+
4346
/*
4447
* __construct
4548
*
@@ -392,20 +395,22 @@ public function create_instance() {
392395
global $post;
393396
global $dustpress;
394397

395-
// Initialize an array for debugging.
396-
$debugs = array();
398+
if ( ! $this->disabled ) {
399+
// Initialize an array for debugging.
400+
$debugs = array();
397401

398-
// Get current template name tidied up a bit.
399-
$template = $this->get_template_filename( $debugs );
402+
// Get current template name tidied up a bit.
403+
$template = $this->get_template_filename( $debugs );
400404

401-
// If class exists with the template's name, create new instance with it.
402-
// We do not throw error if the class does not exist, to ensure that you can still create
403-
// templates in traditional style if needed.
404-
if ( class_exists ( $template ) ) {
405-
new $template( $dustpress, null, true );
406-
}
407-
else {
408-
die("DustPress error: No suitable model found. One of these is required: ". implode(", ", $debugs));
405+
// If class exists with the template's name, create new instance with it.
406+
// We do not throw error if the class does not exist, to ensure that you can still create
407+
// templates in traditional style if needed.
408+
if ( class_exists ( $template ) ) {
409+
new $template( $dustpress, null, true );
410+
}
411+
else {
412+
die("DustPress error: No suitable model found. One of these is required: ". implode(", ", $debugs));
413+
}
409414
}
410415
}
411416

@@ -1450,6 +1455,24 @@ public function do_not_render() {
14501455
$dustpress->do_not_render = true;
14511456
}
14521457

1458+
/*
1459+
* disable
1460+
*
1461+
* Disable DustPress from doing pretty much anything.
1462+
*
1463+
* @type function
1464+
* @date 2/6/2016
1465+
* @since 0.0.9.1
1466+
*
1467+
* @param N/A
1468+
* @return N/A
1469+
*/
1470+
public function disable() {
1471+
global $dustpress;
1472+
1473+
$dustpress->disabled = true;
1474+
}
1475+
14531476
/*
14541477
* array_search_recursive
14551478
*

0 commit comments

Comments
 (0)