';
}
public function settings_page() {
if ( ! current_user_can( 'manage_options' ) ) return;
?>
'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();