* @return void */ public function __construct() { ( \Affilizz\Core::get_instance() )->load_translations(); parent::__construct( __( 'Settings', 'affilizz' ), 'affilizz-settings', trailingslashit( AFFILIZZ_URL ) . 'assets/dist/images/logo/logo-type-white.svg', AFFILIZZ_DIRECTORY . 'templates/administration/page/settings', true, 'affilizz', 'manage_options', __( 'Affilizz plugin configuration', 'affilizz' ), __( 'Affilizz', 'affilizz' ) ); // Format correction - see https://developer.wordpress.org/apis/security/data-validation/ $bust_cache = (int) ( isset( $_REQUEST['bust_cache'] ) && sanitize_text_field( wp_unslash( $_REQUEST['bust_cache'] ) ) && check_admin_referer( 'affilizz-bust-cache' ) ); if ( $bust_cache ) { // The next page render downloads them again wp_delete_file( ( \Affilizz\Util\Assets::get_instance() )->get_diverted_js_file_path() ); wp_delete_file( ( \Affilizz\Util\Assets::get_instance() )->get_diverted_css_file_path() ); wp_safe_redirect( remove_query_arg( 'bust_cache' ) ); exit; } $this->set_description( __( 'Configure the general settings and define the important variables for the Affilizz plugin.', 'affilizz' ) ); } /** * Registers the fields used by this plugin. * @author Affilizz * @return void */ public function register_fields() { // Usable fields $this->available_fields = array( 'affilizz-rendering-mode' => 'affilizz_rendering_mode', 'affilizz-fragment-ttl' => 'affilizz_fragment_ttl', 'affilizz-api-country-code' => 'affilizz_api_country_code', 'affilizz-proxy-uuid' => 'affilizz_proxy_uuid', 'affilizz-disable-javascript' => 'affilizz_disable_javascript', 'affilizz-selective-enqueue' => 'affilizz_selective_enqueue', 'affilizz-javascript-debug-mode' => 'affilizz_javascript_debug_mode', 'affilizz-javascript-analytics' => 'affilizz_javascript_analytics', ); parent::register_fields(); } /** * Saves the settings. * @author Affilizz * @return void */ public function save() { parent::save(); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Parent Page::display() verifies affilizz-save-page-settings before save() is called. if ( isset( $_POST['refresh-uuid'] ) && sanitize_text_field( wp_unslash( $_POST['refresh-uuid'] ) ) ) { \Affilizz\Core::regenerate_uuid(); } // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Parent Page::display() verifies affilizz-save-page-settings before save() is called. $delete_table_confirmation = isset( $_POST['affilizz-confirm-table-deletion'] ) ? sanitize_text_field( wp_unslash( $_POST['affilizz-confirm-table-deletion'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Parent Page::display() verifies affilizz-save-page-settings before save() is called. $delete_table = isset( $_POST['affilizz-delete-codes-table'] ) ? sanitize_text_field( wp_unslash( $_POST['affilizz-delete-codes-table'] ) ) : ''; if ( ! empty( $delete_table ) && $delete_table_confirmation == AFFILIZZ_DELETE_TABLE_CONFIRMATION_TEXT ) { \Affilizz\Install::drop_table(); } } }