| @@ -1,0 +1,60 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Extension Factory | |
| 5 | + * | |
| 6 | + * @package NotificationX\Extensions | |
| 7 | + */ | |
| 8 | + | |
| 9 | +namespace NotificationX\Admin; | |
| 10 | + | |
| 11 | +use NotificationX\GetInstance; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * @method static XSS get_instance($args = null) | |
| 15 | + */ | |
| 16 | +class XSS { | |
| 17 | + use GetInstance; | |
| 18 | + | |
| 19 | + public function __construct() { | |
| 20 | + add_filter( 'nx_settings', [ $this, 'save_settings' ] ); | |
| 21 | + add_filter( 'nx_settings_tab_miscellaneous', [ $this, 'settings_tab_help' ] ); | |
| 22 | + } | |
| 23 | + | |
| 24 | + public function save_settings( $settings ) { | |
| 25 | + if ( isset( $settings['xss_code'] ) ) { | |
| 26 | + unset( $settings['xss_code'] ); | |
| 27 | + } | |
| 28 | + return $settings; | |
| 29 | + } | |
| 30 | + | |
| 31 | + | |
| 32 | + public function settings_tab_help( $tabs ) { | |
| 33 | + | |
| 34 | + $tabs['fields']['xss_settings'] = array( | |
| 35 | + 'name' => 'xss_settings', | |
| 36 | + 'type' => 'section', | |
| 37 | + 'label' => __( 'Cross Domain Notice', 'notificationx' ), | |
| 38 | + 'priority' => 30, | |
| 39 | + 'fields' => array( | |
| 40 | + 'xss_code' => array( | |
| 41 | + 'name' => 'xss_code', | |
| 42 | + 'type' => 'codeviewer', | |
| 43 | + 'label' => __( 'Cross Domain Notice', 'notificationx' ), | |
| 44 | + 'button_text' => __( 'Click to Copy', 'notificationx' ), | |
| 45 | + 'success_text' => __( 'Copied to clipboard.', 'notificationx' ), | |
| 46 | + 'is_pro' => true, | |
| 47 | + 'copyOnClick' => true, | |
| 48 | + 'readOnly' => true, | |
| 49 | + /* translators: %s: Cross Domain Notice link URL */ | |
| 50 | + 'help' => sprintf( __( 'Show your Notification Alerts in another website using <a target="_blank" href="%s">Cross Domain Notice</a>.', 'notificationx' ), 'https://notificationx.com/docs/notificationx-cross-domain-notice/' ), | |
| 51 | + // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript, WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- Default value of a setting shown to the user to copy, not output by the plugin; nx_ is this plugin's established hook prefix. | |
| 52 | + 'default' => apply_filters( 'nx_settings_xss_code_default', "<div id='notificationx-frontend'></div>\n<script>....</script>\n<script src='....../crossSite.js'></script>" ), | |
| 53 | + 'priority' => 1, | |
| 54 | + ), | |
| 55 | + ), | |
| 56 | + ); | |
| 57 | + | |
| 58 | + return $tabs; | |
| 59 | + } | |
| 60 | +} | |