Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: CRUD
- **/
- function create_address_database_table() {
- global $wpdb;
- $table_name = $wpdb->prefix . 'afaddresss';
- $sql = "CREATE TABLE $table_name (
- id mediumint(9) unsigned NOT NULL AUTO_INCREMENT,
- name varchar(50) NOT NULL,
- email longtext NOT NULL,
- phone_no longtext NOT NULL,
- address longtext NOT NULL,
- photo longtext NOT NULL,
- PRIMARY KEY (id)
- );";
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
- dbDelta( $sql );
- }
- register_activation_hook( __FILE__, 'create_address_database_table' );
- add_action('admin_menu', 'addMenu');
- function addMenu() {
- add_menu_page( 'Addresses', 'Addresses', 'manage_options', 'addresses', 'addressPage', 'dashicons-media-spreadsheet', 26 );
- add_submenu_page( 'addresses', 'Addresses', 'All Addresses', 'manage_options', 'addressPage', 'addressPage' );
- add_submenu_page( 'addresses', 'Add New Address', 'Add New', 'manage_options', 'newAddress', 'newAddress' );
- remove_submenu_page('addresses','addresses');
- }
- function addressPage() {
- include __DIR__.'/addressTable.php';
- $addressTable = new addressTable();
- $addressTable->prepare_items();
- echo '<form method="get">
- <input type="hidden" name="page" value="'.$_REQUEST['page'].'" />';
- echo '<div class="wrap"><h1 class="wp-heading-inline">Addresses</h1>
- <a href="http://127.0.0.1/wordpress1/wp-admin/post-new.php?post_type=page" class="page-title-action">Add New</a>';
- $addressTable->search_box('search', 'search_id');
- echo '</div></form>';
- $addressTable->display();
- }
- function newAddress() {
- include __DIR__.'/newAddress.php';
- }
- add_action('admin_post_my_action', 'my_callback_fn');
- function my_callback_fn() {
- ?>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US">
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Conversion Result</title>
- </head>
- <body>
- <h1>Conversion Results</h1>
- <?php
- echo 'Hello world!';
- ?>
- </body>
- </html>
- <?php
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement