Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this is my contribution to improve this project #2

Open
dannyalfonzo opened this issue Feb 23, 2016 · 0 comments
Open

this is my contribution to improve this project #2

dannyalfonzo opened this issue Feb 23, 2016 · 0 comments

Comments

@dannyalfonzo
Copy link

for the video example:

a) The installation script:
wp-content/plugins/test-plugin/plugin.php

prefix . 'addressbook'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, name varchar(255) DEFAULT '' NOT NULL, phone varchar(255) NULL, email varchar(255) NULL, website varchar(255) NULL, address text NULL, date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, UNIQUE KEY id (id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); ``` b) Delete items wp-content/plugins/test-plugin/includes/address-functions.php add in the end /** - delete a single address from database * - @param int $id * - @return array */ function test_delete_address( $id = 0 ) { global $wpdb; return $wpdb->get_row( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'addressbook WHERE id = %d', $id ) ); } wp-content/plugins/test-plugin/includes/class-address-admin-menu.php add to the plugin_page() function the delete case: ``` public function plugin_page() { $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list'; $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0; switch ($action) { case 'view': $template = dirname( __FILE__ ) . '/views/address-single.php'; break; case 'edit': $template = dirname( __FILE__ ) . '/views/address-edit.php'; break; case 'new': $template = dirname( __FILE__ ) . '/views/address-new.php'; break; case 'delete': test_delete_address( $id ); $template = dirname( __FILE__ ) . '/views/address-was-delete.php'; break; default: $template = dirname( __FILE__ ) . '/views/address-list.php'; break; } if ( file_exists( $template ) ) { include $template; } } ``` Create the file wp-content/plugins/test-plugin/includes/views/address-was-delete.php

<?php echo sprintf( '<a href="%s" title="%s">%s</a>', admin_url( 'admin.php?page=addressbook'), __( 'Back to list', 'wedevs' ), __( 'Back to list', 'wedevs' ) ); ?>

c) remove Move to Trash

wp-content/plugins/test-plugin/includes/class-address-list-table.php

/**
* Set the bulk actions
*
* @return array
*/
function get_bulk_actions() {
$actions = array(
//'trash' => __( 'Move to Trash', 'wedevs' ),
);
return $actions;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant