pages
2 years ago
class-action-links.php
2 years ago
class-admin-menu.php
2 years ago
class-assets.php
1 year ago
class-groups-list-table.php
2 years ago
class-header.php
2 years ago
class-page-quick-edit.php
1 year ago
class-tinymce.php
2 years ago
index.php
2 years ago
class-tinymce.php
51 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The class is responsible for configuring the TinyMCE editor to allow unsafe link targets. |
| 4 | * |
| 5 | * @package AdvancedAds |
| 6 | * @author Advanced Ads <info@wpadvancedads.com> |
| 7 | * @since 1.47.0 |
| 8 | */ |
| 9 | |
| 10 | namespace AdvancedAds\Admin; |
| 11 | |
| 12 | use AdvancedAds\Framework\Interfaces\Integration_Interface; |
| 13 | |
| 14 | defined( 'ABSPATH' ) || exit; |
| 15 | |
| 16 | /** |
| 17 | * TinyMCE. |
| 18 | */ |
| 19 | class TinyMCE implements Integration_Interface { |
| 20 | |
| 21 | /** |
| 22 | * Hook into WordPress. |
| 23 | * |
| 24 | * @return void |
| 25 | */ |
| 26 | public function hooks(): void { |
| 27 | add_filter( 'tiny_mce_before_init', [ $this, 'allow_unsafe_link_target' ] ); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Configure TinyMCE to allow unsafe link target. |
| 32 | * |
| 33 | * @param bool $mce_init the tinyMce initialization array. |
| 34 | * |
| 35 | * @return bool|[] |
| 36 | */ |
| 37 | public function allow_unsafe_link_target( $mce_init ) { |
| 38 | // Early bail!! |
| 39 | if ( ! function_exists( 'get_current_screen' ) ) { |
| 40 | return $mce_init; |
| 41 | } |
| 42 | |
| 43 | $screen = get_current_screen(); |
| 44 | if ( 'advanced_ads' === ( $screen->id ?? '' ) ) { |
| 45 | $mce_init['allow_unsafe_link_target'] = true; |
| 46 | } |
| 47 | |
| 48 | return $mce_init; |
| 49 | } |
| 50 | } |
| 51 |