Spaces:
No application file
No application file
| /** | |
| * Plugin Name: DevOps & Infrastructure Client Portal WordPress Plugin | |
| * Description: Secure client login, document sharing, project status updates, and messaging. Professional client experience without custom development. | |
| * Version: 1.0.0 | |
| * Author: Digital Forge | |
| * Text Domain: fx-1019f20d | |
| * License: GPL-2.0+ | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) exit; | |
| define( 'FX_1019F20D_VERSION', '1.0.0' ); | |
| define( 'FX_1019F20D_DIR', plugin_dir_path( __FILE__ ) ); | |
| class Fx1019f20d { | |
| private static $instance = null; | |
| public static function instance() { | |
| if ( null === self::$instance ) { | |
| self::$instance = new self(); | |
| } | |
| return self::$instance; | |
| } | |
| private function __construct() { | |
| add_action( 'init', [ $this, 'init' ] ); | |
| add_action( 'admin_menu', [ $this, 'admin_menu' ] ); | |
| add_action( 'admin_init', [ $this, 'settings_init' ] ); | |
| add_action( 'rest_api_init', [ $this, 'register_routes' ] ); | |
| add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_assets' ] ); | |
| load_plugin_textdomain( 'fx-1019f20d', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); | |
| } | |
| public function init() {} | |
| public function admin_menu() { | |
| add_options_page( | |
| esc_html__( 'DevOps & Infrastructure Client Portal WordPress Plugin Settings', 'fx-1019f20d' ), | |
| esc_html__( 'DevOps & Infrastructure Client Portal WordPress Plugin', 'fx-1019f20d' ), | |
| 'manage_options', | |
| 'fx-1019f20d-settings', | |
| [ $this, 'settings_page' ] | |
| ); | |
| } | |
| public function settings_init() { | |
| register_setting( 'fx-1019f20d_options', 'fx-1019f20d_options', [ $this, 'sanitize_options' ] ); | |
| add_settings_section( 'fx-1019f20d_main', '', '__return_false', 'fx-1019f20d-settings' ); | |
| add_settings_field( 'enabled', esc_html__( 'Enable', 'fx-1019f20d' ), [ $this, 'field_enabled' ], 'fx-1019f20d-settings', 'fx-1019f20d_main' ); | |
| } | |
| public function sanitize_options( $input ) { | |
| $clean = []; | |
| $clean['enabled'] = ! empty( $input['enabled'] ) ? 1 : 0; | |
| return $clean; | |
| } | |
| public function field_enabled() { | |
| $opts = get_option( 'fx-1019f20d_options', [] ); | |
| $val = ! empty( $opts['enabled'] ) ? 1 : 0; | |
| echo '<input type="checkbox" name="fx-1019f20d_options[enabled]" value="1"' . checked( $val, 1, false ) . ' />'; | |
| } | |
| public function settings_page() { | |
| if ( ! current_user_can( 'manage_options' ) ) return; | |
| <div class="wrap"> | |
| <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> | |
| <form method="post" action="options.php"> | |
| <?php settings_fields( 'fx-1019f20d_options' ); ?> | |
| <?php do_settings_sections( 'fx-1019f20d-settings' ); ?> | |
| <?php submit_button(); ?> | |
| </form> | |
| </div> | |
| <?php | |
| } | |
| public function register_routes() { | |
| register_rest_route( 'fx-1019f20d/v1', '/data', [ | |
| [ 'methods' => 'GET', 'callback' => [ $this, 'rest_get' ], 'permission_callback' => '__return_true' ], | |
| [ 'methods' => 'POST', 'callback' => [ $this, 'rest_post' ], 'permission_callback' => function() { return current_user_can( 'manage_options' ); } ], | |
| ] ); | |
| } | |
| public function rest_get( $request ) { | |
| return rest_ensure_response( [ 'status' => 'ok', 'plugin' => 'fx-1019f20d' ] ); | |
| } | |
| public function rest_post( $request ) { | |
| $data = $request->get_json_params(); | |
| return rest_ensure_response( [ 'received' => $data ] ); | |
| } | |
| public function enqueue_admin_assets( $hook ) { | |
| if ( 'settings_page_fx-1019f20d-settings' !== $hook ) return; | |
| wp_enqueue_style( 'fx-1019f20d-admin', plugin_dir_url( __FILE__ ) . 'assets/css/admin.css', [], '1.0.0' ); | |
| wp_enqueue_script( 'fx-1019f20d-admin', plugin_dir_url( __FILE__ ) . 'assets/js/admin.js', [ 'jquery' ], '1.0.0', true ); | |
| wp_localize_script( 'fx-1019f20d-admin', 'fx_1019f20d_vars', [ 'nonce' => wp_create_nonce( 'fx-1019f20d-nonce' ), 'ajax_url' => admin_url( 'admin-ajax.php' ) ] ); | |
| } | |
| public static function activate() { | |
| global $wpdb; | |
| $table = $wpdb->prefix . 'fx_1019f20d'; | |
| $charset = $wpdb->get_charset_collate(); | |
| $sql = "CREATE TABLE IF NOT EXISTS $table ( | |
| id bigint(20) NOT NULL AUTO_INCREMENT, | |
| data longtext NOT NULL, | |
| created_at datetime DEFAULT CURRENT_TIMESTAMP, | |
| PRIMARY KEY (id) | |
| ) $charset;"; | |
| require_once ABSPATH . 'wp-admin/includes/upgrade.php'; | |
| dbDelta( $sql ); | |
| add_option( 'fx-1019f20d_db_version', '1.0.0' ); | |
| } | |
| public static function deactivate() {} | |
| } | |
| register_activation_hook( __FILE__, [ 'Fx1019f20d', 'activate' ] ); | |
| register_deactivation_hook( __FILE__, [ 'Fx1019f20d', 'deactivate' ] ); | |
| Fx1019f20d::instance(); | |