__( 'Forms', 'email-subscribers' ), // singular name of the listed records 'plural' => __( 'Forms', 'email-subscribers' ), // plural name of the listed records 'ajax' => false, // does this table support ajax?, 'screen' => 'es_forms', ) ); $this->db = new ES_DB_Forms(); $this->init(); } public function init() { add_action( 'ig_es_additional_form_options', array( $this, 'show_additional_form_setting' ) ); } /** * Add Screen Option * * @since 4.2.1 */ public static function screen_options() { $action = ig_es_get_request_data( 'action' ); if ( empty( $action ) ) { $option = 'per_page'; $args = array( 'label' => __( 'Number of forms per page', 'email-subscribers' ), 'default' => 20, 'option' => self::$option_per_page, ); add_screen_option( $option, $args ); } } /** * Render Forms list view * * @since 4.0 */ public function render() { $action = ig_es_get_request_data( 'action' ); ?>
' . $shortcode . '';
break;
case 'total_active_subscribers':
$total_active_subscribers = ES()->contacts_db->get_total_contacts_by_form_id( $item['id'] );
return number_format( $total_active_subscribers );
default:
return '';
}
}
/**
* Render the bulk edit checkbox
*
* @param array $item
*
* @return string
*/
public function column_cb( $item ) {
return sprintf(
'',
$item['id']
);
}
/**
* Method for name column
*
* @param array $item an array of DB data
*
* @return string
*/
public function column_name( $item ) {
$list_nonce = wp_create_nonce( 'es_form' );
$title = '' . stripslashes( $item['name'] ) . '';
$page = ig_es_get_request_data( 'page' );
$actions = array(
'edit' => '' . esc_html__( 'Edit', 'email-subscribers' ) . '',
'delete' => '' . esc_html__( 'Delete', 'email-subscribers' ) . '',
);
$actions = apply_filters('ig_es_form_table_row_actions', $actions, $item);
return $title . $this->row_actions( $actions );
}
/**
* Associative array of columns
*
* @return array
*/
public function get_columns() {
$columns = array(
'cb' => '',
'name' => __( 'Name', 'email-subscribers' ),
'shortcode' => __( 'Shortcode', 'email-subscribers' ),
'total_active_subscribers' => __( 'Subscribers', 'email-subscribers' ),
'created_at' => __( 'Created', 'email-subscribers' ),
);
return $columns;
}
/**
* Columns to make sortable.
*
* @return array
*/
public function get_sortable_columns() {
$sortable_columns = array(
'name' => array( 'name', true ),
'created_at' => array( 'created_at', true ),
);
return $sortable_columns;
}
/**
* Returns an associative array containing the bulk action
*
* @return array
*/
public function get_bulk_actions() {
return array(
'bulk_delete' => __( 'Delete', 'email-subscribers' ),
);
}
public function process_bulk_action() {
if ( 'delete' === $this->current_action() ) {
// In our file that handles the request, verify the nonce.
$nonce = ig_es_get_request_data( '_wpnonce' );
if ( ! wp_verify_nonce( $nonce, 'es_form' ) ) {
$message = __( 'You do not have permission to delete this form.', 'email-subscribers' );
ES_Common::show_message( $message, 'error' );
} else {
$form = ig_es_get_request_data( 'form' );
$this->db->delete_forms( array( $form ) );
$message = __( 'Form deleted successfully!', 'email-subscribers' );
ES_Common::show_message( $message, 'success' );
}
}
$action = ig_es_get_request_data( 'action' );
$action2 = ig_es_get_request_data( 'action2' );
// If the delete bulk action is triggered
if ( ( 'bulk_delete' === $action ) || ( 'bulk_delete' === $action2 ) ) {
$forms = ig_es_get_request_data( 'forms' );
if ( ! empty( $forms ) > 0 ) {
$this->db->delete_forms( $forms );
$message = __( 'Form(s) deleted successfully!', 'email-subscribers' );
ES_Common::show_message( $message, 'success' );
} else {
$message = __( 'Please select form(s) to delete.', 'email-subscribers' );
ES_Common::show_message( $message, 'error' );
return;
}
}
}
public function status_label_map( $status ) {
$statuses = array(
'enable' => __( 'Enable', 'email-subscribers' ),
'disable' => __( 'Disable', 'email-subscribers' ),
);
if ( ! in_array( $status, array_keys( $statuses ) ) ) {
return '';
}
return $statuses[ $status ];
}
public function search_box( $text, $input_id ) {
?>
'search-submit' ) ); ?>