| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikWP - Libraries |
| 4 |
* @subpackage adapter.component |
| 5 |
* @author E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved. |
| 7 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
JLoader::import('adapter.component.registry'); |
| 15 |
|
| 16 |
/** |
| 17 |
* Component helper class |
| 18 |
* |
| 19 |
* @since 10.0 |
| 20 |
*/ |
| 21 |
class JComponentHelper |
| 22 |
{ |
| 23 |
/** |
| 24 |
* Gets the parameter object for the component. |
| 25 |
* |
| 26 |
* @param string $option The option for the component. |
| 27 |
* @param boolean $strict If set and the component does not exist, false will be returned. |
| 28 |
* |
| 29 |
* @return JComponentRegistry |
| 30 |
*/ |
| 31 |
public static function getParams($option, $strict = false) |
| 32 |
{ |
| 33 |
return new JComponentRegistry($option); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Get the component information. |
| 38 |
* |
| 39 |
* @param string $option The component option. |
| 40 |
* @param boolean $strict If set and the component does not exist, the enabled attribute will be set to false. |
| 41 |
* |
| 42 |
* @return mixed An object with the information for the component. |
| 43 |
* |
| 44 |
* @since 10.1.16 |
| 45 |
*/ |
| 46 |
public static function getComponent($option, $strict = false) |
| 47 |
{ |
| 48 |
// always return NULL on WordPress to avoid triggering native Joomla updates |
| 49 |
return null; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Applies the global text filters to arbitrary text as per settings for current user groups. |
| 54 |
* |
| 55 |
* @param string $text The string to filter. |
| 56 |
* |
| 57 |
* @return string The filtered string. |
| 58 |
* |
| 59 |
* @since 10.1.33 |
| 60 |
*/ |
| 61 |
public static function filterText($text) |
| 62 |
{ |
| 63 |
// get all tags and attributes supported by WordPress |
| 64 |
$allowed = wp_kses_allowed_html('post'); |
| 65 |
|
| 66 |
// always support iframe, mainly for YouTube videos |
| 67 |
$allowed['iframe'] = array( |
| 68 |
'name' => true, |
| 69 |
'src' => true, |
| 70 |
'width' => true, |
| 71 |
'height' => true, |
| 72 |
'allow' => true, |
| 73 |
'allowfullscreen' => true, |
| 74 |
); |
| 75 |
|
| 76 |
/** |
| 77 |
* Sanitize HTML by using wp_kses. |
| 78 |
* It is possible to extend the supported HTML tags by |
| 79 |
* using the "wp_kses_allowed_html" hook. |
| 80 |
*/ |
| 81 |
return wp_kses(wp_unslash($text), $allowed); |
| 82 |
} |
| 83 |
} |
| 84 |
|