WealthFromAI's picture
FORGE-X: Upload source (c9e9f864.zip)
faa1080 verified
Raw
History Blame Contribute Delete
5.06 kB
<?php
/**
* Plugin Name: DevOps & Infrastructure A/B Testing and Conversion Optimization WordPress Plugin
* Description: Test headlines, layouts, CTAs, and pricing without external tools. Optimize conversions without monthly A/B testing subscriptions.
* Version: 1.0.0
* Author: Digital Forge
* Text Domain: c9e9f864
* License: GPL-2.0+
*/
if ( ! defined( 'ABSPATH' ) ) exit;
define( 'C9E9F864_VERSION', '1.0.0' );
define( 'C9E9F864_DIR', plugin_dir_path( __FILE__ ) );
class C9e9f864 {
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( 'c9e9f864', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
public function init() {}
public function admin_menu() {
add_options_page(
esc_html__( 'DevOps & Infrastructure A/B Testing and Conversion Optimization WordPress Plugin Settings', 'c9e9f864' ),
esc_html__( 'DevOps & Infrastructure A/B Testing and Conversion Optimization WordPress Plugin', 'c9e9f864' ),
'manage_options',
'c9e9f864-settings',
[ $this, 'settings_page' ]
);
}
public function settings_init() {
register_setting( 'c9e9f864_options', 'c9e9f864_options', [ $this, 'sanitize_options' ] );
add_settings_section( 'c9e9f864_main', '', '__return_false', 'c9e9f864-settings' );
add_settings_field( 'enabled', esc_html__( 'Enable', 'c9e9f864' ), [ $this, 'field_enabled' ], 'c9e9f864-settings', 'c9e9f864_main' );
}
public function sanitize_options( $input ) {
$clean = [];
$clean['enabled'] = ! empty( $input['enabled'] ) ? 1 : 0;
return $clean;
}
public function field_enabled() {
$opts = get_option( 'c9e9f864_options', [] );
$val = ! empty( $opts['enabled'] ) ? 1 : 0;
echo '<input type="checkbox" name="c9e9f864_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( 'c9e9f864_options' ); ?>
<?php do_settings_sections( 'c9e9f864-settings' ); ?>
<?php submit_button(); ?>
</form>
</div>
<?php
}
public function register_routes() {
register_rest_route( 'c9e9f864/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' => 'c9e9f864' ] );
}
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_c9e9f864-settings' !== $hook ) return;
wp_enqueue_style( 'c9e9f864-admin', plugin_dir_url( __FILE__ ) . 'assets/css/admin.css', [], '1.0.0' );
wp_enqueue_script( 'c9e9f864-admin', plugin_dir_url( __FILE__ ) . 'assets/js/admin.js', [ 'jquery' ], '1.0.0', true );
wp_localize_script( 'c9e9f864-admin', 'c9e9f864_vars', [ 'nonce' => wp_create_nonce( 'c9e9f864-nonce' ), 'ajax_url' => admin_url( 'admin-ajax.php' ) ] );
}
public static function activate() {
global $wpdb;
$table = $wpdb->prefix . 'c9e9f864';
$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( 'c9e9f864_db_version', '1.0.0' );
}
public static function deactivate() {}
}
register_activation_hook( __FILE__, [ 'C9e9f864', 'activate' ] );
register_deactivation_hook( __FILE__, [ 'C9e9f864', 'deactivate' ] );
C9e9f864::instance();