| 1 |
<?php |
| 2 |
|
| 3 |
namespace Getwid; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class AllowedCssTags |
| 7 |
* @package Getwid |
| 8 |
*/ |
| 9 |
class AllowedCssTags { |
| 10 |
|
| 11 |
/** |
| 12 |
* AllowedCssTags constructor. |
| 13 |
*/ |
| 14 |
public function __construct() { |
| 15 |
|
| 16 |
add_filter( 'safe_style_css', [ $this, 'allowed_css' ], 20); |
| 17 |
$this->allowed_tags(); |
| 18 |
} |
| 19 |
|
| 20 |
public function allowed_tags() { |
| 21 |
global $allowedposttags; |
| 22 |
|
| 23 |
$allowedposttags['canvas'] = array( |
| 24 |
'class' => array(), |
| 25 |
'id' => array(), |
| 26 |
'style' => array(), |
| 27 |
'width' => array(), |
| 28 |
'height' => array(), |
| 29 |
); |
| 30 |
} |
| 31 |
|
| 32 |
public function allowed_css($allowed_attr) { |
| 33 |
|
| 34 |
$new_allowed_attr = array( |
| 35 |
'background-position', |
| 36 |
'background-attachment', |
| 37 |
'background-size', |
| 38 |
'background-repeat', |
| 39 |
|
| 40 |
'opacity', |
| 41 |
'flex-direction', |
| 42 |
'flex-wrap', |
| 43 |
'justify-content', |
| 44 |
'align-content', |
| 45 |
'align-items', |
| 46 |
'order', |
| 47 |
'flex', |
| 48 |
'align-self', |
| 49 |
); |
| 50 |
|
| 51 |
foreach ($new_allowed_attr as $key => $value) { |
| 52 |
if (!in_array($value, $allowed_attr)){ |
| 53 |
$allowed_attr[] = $value; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
return $allowed_attr; |
| 58 |
} |
| 59 |
|
| 60 |
} |
| 61 |
|