Files
Testing/blog/wp-content/plugins/secureprivacy/admin/class-secureprivacy-admin.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

350 lines
12 KiB
PHP

<?php
/**
* The admin-specific functionality of the plugin.
*
* @link http://secureprivacy.ai/
* @since 1.0.0
*
* @package Secureprivacy
* @subpackage Secureprivacy/admin
*/
/**
* The admin-specific functionality of the plugin.
*
* Defines the plugin name, version, and two examples hooks for how to
* enqueue the admin-specific stylesheet and JavaScript.
*
* @package Secureprivacy
* @subpackage Secureprivacy/admin
* @author Secure Privacy <hello@secureprivacy.ai>
*/
class Secureprivacy_Admin {
/**
* The ID of this plugin.
*
* @since 1.0.0
* @access private
* @var string $plugin_name The ID of this plugin.
*/
private $plugin_name;
/**
* The options name to be used in this plugin
*
* @since 1.0.0
* @access private
* @var string $option_name Option name of this plugin
*/
private $option_name = 'outdated_notice';
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;
/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $plugin_name, $version ) {
$this->plugin_name = $plugin_name;
$this->version = $version;
}
/**
* Register the stylesheets for the admin area.
*
* @since 1.0.0
*/
public function enqueue_styles() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Secureprivacy_Loader as all of the hooks are defined
* in that particular class.
*
* The Secureprivacy_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
$styleVer = rand(10,100000000);
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/secureprivacy-admin.css', array(), $styleVer, 'all' );
}
/**
* Register the JavaScript for the admin area.
*
* @since 1.0.0
*/
public function enqueue_scripts() {
/**
* This function is provided for demonstration purposes only.
*
* An instance of this class should be passed to the run() function
* defined in Secureprivacy_Loader as all of the hooks are defined
* in that particular class.
*
* The Secureprivacy_Loader will then create the relationship
* between the defined hooks and the functions defined in this
* class.
*/
$newVer = rand(10,100000000);
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/secureprivacy-admin.js' , array( 'jquery' ), $newVer , false );
}
/**
* Add an options page under the Settings submenu
*
* @since 1.0.0
*/
public function add_options_page() {
add_menu_page('Secure Privacy', 'Secure Privacy', 'manage_options', 'dashboard', array( $this, 'display_dashboard_page' ), plugin_dir_url( __FILE__ ) . 'images/secureprivacy-01-white.png', 6);
add_submenu_page( null, '', 'Login Page', 'manage_options', 'login', array( $this,'display_login_page'));
add_submenu_page( null, '', 'Forgot Password', 'manage_options', 'forgotpassword', array( $this,'display_forgotPassword_page'));
add_submenu_page( null, '', 'Onboarding', 'manage_options', 'onboarding', array( $this,'display_Onboarding_page'));
add_submenu_page( null, '', 'Welcome', 'manage_options', 'welcome', array( $this,'display_options_page'));
add_submenu_page( null, '', 'Banners', 'manage_options', 'banners', array( $this,'display_banners_page'));
add_submenu_page( null, '', 'Prior Consent', 'manage_options', 'priorConsent', array( $this,'display_priorconsent_page'));
add_submenu_page( null, '', 'Consent Tracking', 'manage_options', 'consentTracking', array( $this,'display_consentTracking_page'));
add_submenu_page( null, '', 'Privacy Policy', 'manage_options', 'privacyPolicy', array( $this,'display_privacyPolicy_page'));
add_submenu_page( null, '', 'Account', 'manage_options', 'account', array( $this,'display_account_page'));
add_submenu_page( null, '', 'Login Success', 'manage_options', 'loginSuccess', array( $this,'display_loginSuccess_page'));
add_submenu_page( null, '', 'Settings', 'manage_options', 'settings', array( $this,'display_settings_page'));
}
/**
* Render the options page for plugin
*
* @since 1.0.0
*/
public function display_options_page() {
include_once 'partials/secureprivacy-admin-display.php';
}
public function display_login_page() {
include_once 'partials/login-partial.php';
}
public function display_forgotPassword_page() {
include_once 'partials/forgot-password-partial.php';
}
public function display_settings_page() {
include_once 'partials/settings-partial.php';
}
public function display_banners_page() {
include_once 'partials/banners-partial.php';
}
public function display_Onboarding_page() {
include_once 'partials/onboarding-partial.php';
}
public function display_priorconsent_page() {
include_once 'partials/prior-consent-partial.php';
}
public function display_consentTracking_page() {
include_once 'partials/consent-tracking-partial.php';
}
public function display_privacyPolicy_page() {
include_once 'partials/privacy-policy-partial.php';
}
public function display_account_page() {
include_once 'partials/account-partial.php';
}
public function display_loginSuccess_page() {
include_once 'partials/login-success.php';
}
public function display_dashboard_page() {
include_once 'partials/dashboard-partial.php';
}
/**
* Register all related settings of this plugin
*
* @since 1.0.0
*/
public function register_setting() {
add_settings_section(
$this->option_name . '_general',
__( '', 'secure-privacy' ),
array( $this, $this->option_name . '_general_cb' ),
$this->plugin_name
);
add_settings_field(
$this->option_name . '_adminId',
__( 'API Key', 'secure-privacy' ),
array( $this, $this->option_name . '_adminId_cb' ),
$this->plugin_name,
$this->option_name . '_general',
array( 'label_for' => $this->option_name . '_adminId', 'class' => 'hidden' )
);
add_settings_field(
$this->option_name . '_sessionId',
__( 'Session Key', 'secure-privacy' ),
array( $this, $this->option_name . '_sessionId_cb' ),
$this->plugin_name,
$this->option_name . '_general',
// array( 'label_for' => $this->option_name . '_sessionId' )
array( 'label_for' => $this->option_name . '_sessionId' , 'class' => 'hidden')
);
add_settings_field(
$this->option_name . '_domainId',
__( 'Domain Id', 'secure-privacy' ),
array( $this, $this->option_name . '_domainId_cb' ),
$this->plugin_name,
$this->option_name . '_general',
array( 'label_for' => $this->option_name . '_domainId' , 'class' => 'hidden')
);
add_settings_field(
$this->option_name . '_planName',
__( 'Plan Name', 'secure-privacy' ),
array( $this, $this->option_name . '_planName_cb' ),
$this->plugin_name,
$this->option_name . '_general',
array( 'label_for' => $this->option_name . '_planName' , 'class' => 'hidden')
);
add_settings_field(
$this->option_name . '_client_id',
__( 'Client Id', 'secure-privacy' ),
array( $this, $this->option_name . '_client_id_cb' ),
$this->plugin_name,
$this->option_name . '_general',
array( 'label_for' => $this->option_name . '_client_id' , 'class' => 'hidden')
);
add_settings_field(
$this->option_name . '_client_secret',
__( 'Client secret', 'secure-privacy' ),
array( $this, $this->option_name . '_client_secret_cb' ),
$this->plugin_name,
$this->option_name . '_general',
array( 'label_for' => $this->option_name . '_client_secret' , 'class' => 'hidden')
);
register_setting( $this->plugin_name, $this->option_name . '_adminId', 'string' );
register_setting( $this->plugin_name, $this->option_name . '_sessionId', 'string' );
register_setting( $this->plugin_name, $this->option_name . '_domainId', 'string' );
register_setting( $this->plugin_name, $this->option_name . '_planName', 'string' );
register_setting( $this->plugin_name, $this->option_name . '_client_id', 'string' );
register_setting( $this->plugin_name, $this->option_name . '_client_secret', 'string' );
}
/**
* Render the text for the general section
*
* @since 1.0.0
*/
public function outdated_notice_general_cb() {
// echo '<p>' . __( 'Enter your API Key.', 'secure-privacy' ) . '</p>';
}
/**
* Render the radio input field for position option
*
* @since 1.0.0
*/
public function outdated_notice_position_cb() {
$position = get_option( $this->option_name . '_position' );
?>
<fieldset>
<label>
<input type="radio" name="<?php echo $this->option_name . '_position' ?>" id="<?php echo $this->option_name . '_position' ?>" value="bottomLeft" <?php checked( $position, 'bottomLeft' ); ?>>
<?php _e( 'Bottom Left', 'secure-privacy' ); ?>
</label>
<label>
<input type="radio" name="<?php echo $this->option_name . '_position' ?>" value="bottomRight" <?php checked( $position, 'bottomRight' ); ?>>
<?php _e( 'Bottom Right', 'secure-privacy' ); ?>
</label>
<label>
<input type="radio" name="<?php echo $this->option_name . '_position' ?>" value="topRight" <?php checked( $position, 'topRight' ); ?>>
<?php _e( 'Top Right', 'secure-privacy' ); ?>
</label>
<label>
<input type="radio" name="<?php echo $this->option_name . '_position' ?>" value="topLeft" <?php checked( $position, 'topLeft' ); ?>>
<?php _e( 'Top Left', 'secure-privacy' ); ?>
</label>
</fieldset>
<?php
}
/**
* Render the treshold adminId input for this plugin
*
* @since 1.0.0
*/
public function outdated_notice_adminId_cb() {
$adminId = get_option( $this->option_name . '_adminId' );
echo '<input style="width:500px;" type="text" name="' . $this->option_name . '_adminId' . '" id="' . $this->option_name . '_adminId' . '" value="' . $adminId . '"> ';
}
public function outdated_notice_sessionId_cb() {
$sessionId = get_option( $this->option_name . '_sessionId' );
echo '<input style="width:500px;" type="text" name="' . $this->option_name . '_sessionId' . '" id="' . $this->option_name . '_sessionId' . '" value="' . $sessionId . '"> ';
}
public function outdated_notice_domainId_cb() {
$domainId = get_option( $this->option_name . '_domainId' );
echo '<input style="width:500px;" type="text" name="' . $this->option_name . '_domainId' . '" id="' . $this->option_name . '_domainId' . '" value="' . $domainId . '"> ';
}
public function outdated_notice_planName_cb() {
$planName = get_option( $this->option_name . '_planName' );
echo '<input style="width:500px;" type="text" name="' . $this->option_name . '_planName' . '" id="' . $this->option_name . '_planName' . '" value="' . $planName . '"> ';
}
public function outdated_notice_client_id_cb() {
$client_id = get_option( $this->option_name . '_client_id' );
echo '<input style="width:500px;" type="text" name="' . $this->option_name . '_client_id' . '" id="' . $this->option_name . '_client_id' . '" value="' . $client_id . '"> ';
}
public function outdated_notice_client_secret_cb() {
$client_secret = get_option( $this->option_name . '_client_secret' );
echo '<input style="width:500px;" type="text" name="' . $this->option_name . '_client_secret' . '" id="' . $this->option_name . '_client_secret' . '" value="' . $client_secret . '"> ';
}
/**
* Sanitize the text position value before being saved to database
*
* @param string $position $_POST value
* @since 1.0.0
* @return string Sanitized value
*/
public function outdated_notice_sanitize_position( $position ) {
if ( in_array( $position, array( 'topLeft', 'topRight' , 'bottomRight' , 'bottomLeft' ), true ) ) {
return $position;
}
}
}