Plugin Directory

Changeset 3357912


Ignore:
Timestamp:
09/08/2025 12:51:35 PM (7 months ago)
Author:
netscoretechnologies2011
Message:

initial commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • netscore-connector/trunk/netscore-connector.php

    r3357896 r3357912  
    1515}
    1616
     17/**
     18 * Updated Netscore Connector main class - v1.0.3
     19 * - Enqueues admin CSS from css/cuf-styles.css
     20 * - Uses Settings API for saving options
     21 * - Adds capability checks and nonce where relevant
     22 */
     23
    1724class Netscore_Connector {
    1825
     26    private $option_group = 'netscore_connector_group';
     27
    1928    public function __construct() {
    20         // Add admin menu
    2129        add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
    22         // Enqueue admin CSS only on our page
    2330        add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_css' ) );
    24         // Register settings
    2531        add_action( 'admin_init', array( $this, 'register_settings' ) );
    2632    }
    2733
    28     /**
    29      * Add top-level menu page
    30      */
    3134    public function add_admin_menu() {
    3235        add_menu_page(
     
    4144    }
    4245
    43     /**
    44      * Enqueue external CSS file for the settings page
    45      */
    4646    public function enqueue_admin_css( $hook ) {
    47         // Only load on our plugin settings page
    4847        if ( $hook !== 'toplevel_page_netscore-connector' ) {
    4948            return;
     
    5352            plugin_dir_url( __FILE__ ) . 'css/cuf-styles.css',
    5453            array(),
    55             '1.0.2'
     54            '1.0.3'
    5655        );
    5756    }
    5857
    59     /**
    60      * Register settings using Settings API
    61      */
    6258    public function register_settings() {
    63         register_setting( 'netscore_connector_group', 'netscore_api_key', array(
     59        register_setting( $this->option_group, 'netscore_api_key', array(
    6460            'type' => 'string',
    6561            'sanitize_callback' => 'sanitize_text_field',
    6662            'default' => ''
    6763        ) );
    68         register_setting( 'netscore_connector_group', 'netscore_api_email', array(
     64        register_setting( $this->option_group, 'netscore_api_email', array(
    6965            'type' => 'string',
    7066            'sanitize_callback' => 'sanitize_email',
     
    7369    }
    7470
    75     /**
    76      * Output the settings page HTML
    77      */
    7871    public function settings_page() {
    7972        if ( ! current_user_can( 'manage_options' ) ) {
     
    8174        }
    8275
    83         // Handle notices after saving
    8476        if ( isset( $_GET['settings-updated'] ) ) {
    8577            add_settings_error( 'netscore_messages', 'netscore_message', __( 'Settings Saved', 'netscore-connector' ), 'updated' );
    8678        }
    8779        settings_errors( 'netscore_messages' );
     80
     81        $api_key = get_option( 'netscore_api_key', '' );
     82        $api_email = get_option( 'netscore_api_email', '' );
    8883        ?>
    8984        <div class="wrap">
     
    9287            </div>
    9388
    94             <form class="netscore-connector-form" method="post" action="options.php">
     89            <form class="netscore-connector-form" method="post" action="options.php" novalidate>
    9590                <?php
    96                 settings_fields( 'netscore_connector_group' );
    97                 do_settings_sections( 'netscore_connector_group' );
    98                 $api_key = get_option( 'netscore_api_key', '' );
    99                 $api_email = get_option( 'netscore_api_email', '' );
     91                settings_fields( $this->option_group );
     92                do_settings_sections( $this->option_group );
    10093                ?>
    10194
Note: See TracChangeset for help on using the changeset viewer.