??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/netecfwd.co.uk/wp-content/plugins/sureforms/inc/onboarding.php
⬅ Kembali
<?php
/**
* Onboarding Class
*
* Handles the onboarding process for the SureForms plugin.
*
* @package sureforms
*/
namespace SRFM\Inc;
use SRFM\Inc\Traits\Get_Instance;
use WP_Error;
use WP_REST_Request;
use WP_REST_Response;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Onboarding Class
*
* Handles the onboarding process for the SureForms plugin.
*/
class Onboarding {
use Get_Instance;
/**
* User-meta key recording that the user dismissed the migration
* banner on the Forms listing page. The banner stays gone until a
* fresh install or a manual delete of the meta.
*
* @since 2.11.0
*/
public const MIGRATION_BANNER_DISMISSED_META_KEY = 'srfm_onboarding_migration_banner_dismissed';
/**
* Onboarding completion setting key.
*
* @var string
*/
private $onboarding_status_key = 'onboarding_completed';
/**
* Constructor — wire the dismiss-migration-banner REST endpoint via
* the existing `srfm_rest_api_endpoints` filter. Keeps the route
* registration consistent with the migrator + rest-api modules.
*
* @since 2.11.0
*/
public function __construct() {
add_filter( 'srfm_rest_api_endpoints', [ $this, 'register_routes' ] );
}
/**
* Append onboarding-related REST routes to the SureForms registry.
*
* @since 2.11.0
*
* @param array<string,array<string,mixed>> $endpoints Existing registry.
* @return array<string,array<string,mixed>>
*/
public function register_routes( $endpoints ) {
if ( ! is_array( $endpoints ) ) {
$endpoints = [];
}
$endpoints['user-meta/dismiss-migration-banner'] = [
'methods' => 'POST',
'callback' => [ $this, 'rest_dismiss_migration_banner' ],
// Dismissing one's own banner is a per-user UX-preference write, so a
// logged-in check is the right scope (not the heavier manage_options
// the migrator endpoints need to create posts) — review #6.
'permission_callback' => static function () {
return is_user_logged_in();
},
];
return $endpoints;
}
/**
* REST callback — persist the dismissal flag on the current user's
* meta so the migration banner stays gone across reloads.
*
* @since 2.11.0
*
* @param WP_REST_Request $request REST request.
* @return WP_REST_Response|WP_Error
*/
public function rest_dismiss_migration_banner( $request ) {
// Verify the REST nonce, matching the migrator callbacks' convention
// (the JS sends X-WP-Nonce via apiFetch) — review #3.
$nonce = $request->get_header( 'X-WP-Nonce' );
if ( ! is_string( $nonce ) || ! wp_verify_nonce( $nonce, 'wp_rest' ) ) {
return new WP_Error(
'srfm_invalid_nonce',
__( 'Invalid or missing security token.', 'sureforms' ),
[ 'status' => 403 ]
);
}
// permission_callback (is_user_logged_in) guarantees a real user here.
update_user_meta( get_current_user_id(), self::MIGRATION_BANNER_DISMISSED_META_KEY, '1' );
return new WP_REST_Response(
[ 'dismissed' => true ],
200
);
}
/**
* Whether the current user has dismissed the migration banner.
* Surfaced to the admin React app via `srfm_admin.migration_banner_dismissed`.
*
* @since 2.11.0
*
* @return bool
*/
public function is_migration_banner_dismissed() {
$user_id = get_current_user_id();
if ( 0 === $user_id ) {
return false;
}
return (bool) get_user_meta( $user_id, self::MIGRATION_BANNER_DISMISSED_META_KEY, true );
}
/**
* Set onboarding completion status.
*
* @since 1.9.1
* @param string $completed Whether the onboarding is completed.
* @return void
*/
public function set_onboarding_status( $completed = 'no' ) {
Helper::update_srfm_option( $this->onboarding_status_key, $completed );
}
/**
* Get onboarding completion status.
*
* @since 1.9.1
* @return bool
*/
public function get_onboarding_status() {
return Helper::get_srfm_option( $this->onboarding_status_key, 'no' ) === 'yes';
}
}
Nama
Tipe
Ukuran
Diubah
Aksi
📁 abilities
dir
—
2026-06-25 16:24
📁 admin
dir
—
2026-06-25 16:24
📁 ai-form-builder
dir
—
2026-06-25 16:24
📁 blocks
dir
—
2026-06-25 16:24
📁 compatibility
dir
—
2026-06-25 16:24
📁 database
dir
—
2026-06-25 16:24
📁 email
dir
—
2026-06-25 16:24
📁 fields
dir
—
2026-06-25 16:24
📁 global-settings
dir
—
2026-06-25 16:24
📁 lib
dir
—
2026-06-25 16:24
📁 migrator
dir
—
2026-06-25 16:24
📁 page-builders
dir
—
2026-06-25 16:24
📁 payments
dir
—
2026-06-25 16:24
📁 single-form-settings
dir
—
2026-06-25 16:24
📁 traits
dir
—
2026-06-25 16:24
🐘 activator.php
php
1 KB
2026-06-25 16:24
🐘 admin-ajax.php
php
13.4 KB
2026-06-25 16:24
🐘 background-process.php
php
4.8 KB
2026-06-25 16:24
🐘 create-new-form.php
php
4.9 KB
2026-06-25 16:24
🐘 duplicate-form.php
php
8.4 KB
2026-06-25 16:24
🐘 entries.php
php
24.3 KB
2026-06-25 16:24
🐘 events-scheduler.php
php
1.3 KB
2026-06-25 16:24
🐘 export.php
php
11.8 KB
2026-06-25 16:24
🐘 field-validation.php
php
22.9 KB
2026-06-25 16:24
🐘 form-restriction.php
php
11.2 KB
2026-06-25 16:24
🐘 form-styling.php
php
7 KB
2026-06-25 16:24
🐘 form-submit.php
php
55.7 KB
2026-06-25 16:24
🐘 forms-data.php
php
7.1 KB
2026-06-25 16:24
🐘 frontend-assets.php
php
16.3 KB
2026-06-25 16:24
🐘 generate-form-markup.php
php
49.9 KB
2026-06-25 16:24
🐘 gutenberg-hooks.php
php
10.9 KB
2026-06-25 16:24
🐘 helper.php
php
92.4 KB
2026-06-25 16:24
🐘 learn.php
php
13.5 KB
2026-06-25 16:24
🐘 onboarding.php
php
3.9 KB
2026-06-25 16:24
🐘 post-types.php
php
48.4 KB
2026-06-25 16:24
🐘 rest-api.php
php
56.7 KB
2026-06-25 16:24
🐘 smart-tags.php
php
28.1 KB
2026-06-25 16:24
🐘 submit-token.php
php
4.6 KB
2026-06-25 16:24
🐘 translatable.php
php
5.9 KB
2026-06-25 16:24
🐘 updater-callbacks.php
php
3.3 KB
2026-06-25 16:24
🐘 updater.php
php
5.1 KB
2026-06-25 16:24