Support for PHP 7 instead of PHP 4
Refactor control_html class to use constructor for initialization
This commit is contained in:
parent
1e08e2ba83
commit
b51e86fb73
@ -202,40 +202,41 @@ function htmlposts_parse(&$message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new class to control the parser options easily
|
// Create a new class to control the parser options easily
|
||||||
if (!class_exists("control_html"))
|
if (!class_exists("control_html"))
|
||||||
{
|
{
|
||||||
class control_html
|
class control_html
|
||||||
{
|
{
|
||||||
public $html_enabled;
|
public $html_enabled;
|
||||||
|
|
||||||
function control_html()
|
function __construct()
|
||||||
{
|
{
|
||||||
// Is it enabled already? Save it in a var to later disallow disabling
|
// Is it enabled already? Save it in a var to later disallow disabling
|
||||||
$this->html_enabled = $parser->options['allow_html'];
|
global $parser;
|
||||||
}
|
$this->html_enabled = $parser->options['allow_html'];
|
||||||
|
}
|
||||||
function set_html($status)
|
|
||||||
{
|
function set_html($status)
|
||||||
$status = (int)$status;
|
{
|
||||||
if ($status != 0 && $status != 1) return false;
|
$status = (int)$status;
|
||||||
|
if ($status != 0 && $status != 1) return false;
|
||||||
// if we're trying to disable it but it's enabled by default, disallow the action
|
|
||||||
if ($status == 0 && $this->html_enabled == 1)
|
// if we're trying to disable it but it's enabled by default, disallow the action
|
||||||
return false;
|
if ($status == 0 && $this->html_enabled == 1)
|
||||||
|
return false;
|
||||||
global $parser;
|
|
||||||
|
global $parser;
|
||||||
// Set to desired status
|
|
||||||
$parser->options['allow_html'] = $status;
|
// Set to desired status
|
||||||
// for previewing posts
|
$parser->options['allow_html'] = $status;
|
||||||
global $parser_options;
|
// for previewing posts
|
||||||
if (!empty($parser_options))
|
global $parser_options;
|
||||||
$parser_options['allow_html'] = $status;
|
if (!empty($parser_options))
|
||||||
|
$parser_options['allow_html'] = $status;
|
||||||
return true;
|
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create object if it doesn't exist
|
// Create object if it doesn't exist
|
||||||
if (!is_object($control_html))
|
if (!is_object($control_html))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user