| 1 |
<?php |
| 2 |
/** |
| 3 |
* Email Subscription Template |
| 4 |
* |
| 5 |
* @package Botmaster |
| 6 |
* @since 14.8.2 |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
wp_register_style( 'qlcd-wp-chatbot-admin-style-email', QCLD_wpCHATBOT_PLUGIN_URL . '/css/email_subscription.css', '', QCLD_wpCHATBOT_VERSION, 'screen' ); |
| 14 |
wp_enqueue_style( 'qlcd-wp-chatbot-admin-style-email' ); |
| 15 |
|
| 16 |
wp_register_script( 'qcld-wp-chatbot-email-subscription-js', QCLD_wpCHATBOT_PLUGIN_URL . '/js/email_subscription.js', array( 'jquery' ), true ); |
| 17 |
wp_enqueue_script( 'qcld-wp-chatbot-email-subscription-js' ); |
| 18 |
|
| 19 |
global $wpdb; |
| 20 |
if ( ! function_exists( 'wp_get_current_user' ) ) { |
| 21 |
include ABSPATH . 'wp-includes/pluggable.php'; |
| 22 |
} |
| 23 |
|
| 24 |
$table = $wpdb->prefix . 'wpbot_subscription'; |
| 25 |
|
| 26 |
if ( isset( $_POST['wpbot_email_subscription_remove'] ) && $_POST['wpbot_email_subscription_remove'] == '1' ) { |
| 27 |
if ( current_user_can( 'manage_options' ) && isset( $_POST['emails'] ) && is_array( $_POST['emails'] ) ) { |
| 28 |
foreach ( $_POST['emails'] as $email_id ) { |
| 29 |
$wpdb->delete( $table, array( 'id' => intval( $email_id ) ), array( '%d' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
| 30 |
} |
| 31 |
echo '<script>window.location.href="' . esc_url_raw( admin_url( 'admin.php?page=email-subscription&msg=success' ) ) . '";</script>'; |
| 32 |
exit; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
$current_user = wp_get_current_user(); |
| 37 |
$url = admin_url( 'edit.php?post_type=sld&page=qcsld_click_list' ); |
| 38 |
$customPagHTML = ''; |
| 39 |
// Main Report Area |
| 40 |
$sql1 = $wpdb->prepare( 'SELECT count(*) FROM %i where 1', $table ); |
| 41 |
|
| 42 |
$total = $wpdb->get_var( $sql1 ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching |
| 43 |
$items_per_page = 50; |
| 44 |
|
| 45 |
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;// phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 46 |
$offset = ( $page * $items_per_page ) - $items_per_page; |
| 47 |
|
| 48 |
$sql = $wpdb->prepare( 'SELECT * FROM %i where 1 order by id desc LIMIT %d, %d', $table, $offset, $items_per_page ); |
| 49 |
|
| 50 |
$rows = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter |
| 51 |
$totalPage = ceil( $total / $items_per_page ); |
| 52 |
|
| 53 |
if ( $totalPage > 1 ) { |
| 54 |
$customPagHTML = '<div><span class="wpbot_pagination">Page ' . esc_html( $page ) . ' of ' . esc_html( $totalPage ) . '</span>' . paginate_links( |
| 55 |
array( |
| 56 |
'base' => add_query_arg( 'cpage', '%#%' ), |
| 57 |
'format' => '', |
| 58 |
'prev_text' => esc_html__( '«' ), |
| 59 |
'next_text' => esc_html__( '»' ), |
| 60 |
'total' => esc_html( $totalPage ), |
| 61 |
'current' => esc_html( $page ), |
| 62 |
) |
| 63 |
) . '</div>'; |
| 64 |
} |
| 65 |
$mainurl = admin_url( 'admin.php?page=email-subscription' ); |
| 66 |
|
| 67 |
?> |
| 68 |
<div class="qchero_sliders_list_wrapper wpbot-userdata-page"> |
| 69 |
<div class="sld_menu_title"> |
| 70 |
<h2><?php echo esc_html__( 'User Data', 'wpchatbot' ); ?></h2> |
| 71 |
</div> |
| 72 |
|
| 73 |
<?php if ( $customPagHTML != '' ) : ?> |
| 74 |
<div class="sld_menu_title sld_menu_title_align wpbot-userdata-toolbar"> |
| 75 |
<div class="qcld-session-pagination"><?php echo wp_kses_post( $customPagHTML ); ?></div> |
| 76 |
</div> |
| 77 |
<?php endif; ?> |
| 78 |
|
| 79 |
<?php |
| 80 |
if ( isset( $_GET['msg'] ) && $_GET['msg'] == 'success' ) {// phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 81 |
echo '<div class="notice notice-success"><p>Record has beed Deleted Successfully!</p></div>'; |
| 82 |
} |
| 83 |
?> |
| 84 |
|
| 85 |
<form id="wpcs_form_sessions" class="wpbot-userdata-form" action="<?php echo esc_url( $mainurl ); ?>" method="POST"> |
| 86 |
<input type="hidden" name="wpbot_email_subscription_remove" /> |
| 87 |
|
| 88 |
<div class="wpbot-userdata-actions"> |
| 89 |
<button type="button" class="button-primary" id="wpbot_submit_email_form"><?php echo esc_html__( 'Delete', 'wpchatbot' ); ?></button> |
| 90 |
<a class="button-primary wpbot-userdata-export" href="<?php echo esc_url( admin_url( 'admin-post.php?action=wpbprint.csv' ) ); ?>"><?php echo esc_html__( 'Export All Contacts', 'wpchatbot' ); ?></a> |
| 91 |
<span class="wpbot-userdata-total"><?php echo esc_html__( 'Total', 'wpchatbot' ); ?> <strong><?php echo esc_html( $total ); ?></strong></span> |
| 92 |
</div> |
| 93 |
|
| 94 |
<div class="qchero_slider_table_area"> |
| 95 |
<div class="sld_payment_table"> |
| 96 |
<div class="sld_payment_row header"> |
| 97 |
|
| 98 |
<div class="sld_payment_cell"> |
| 99 |
<input type="checkbox" id="wpbot_checked_all" /> |
| 100 |
</div> |
| 101 |
|
| 102 |
<div class="sld_payment_cell"> |
| 103 |
<?php echo esc_html__( 'Date', 'wpchatbot' ); ?> |
| 104 |
</div> |
| 105 |
<div class="sld_payment_cell"> |
| 106 |
<?php echo esc_html__( 'Name', 'wpchatbot' ); ?> |
| 107 |
</div> |
| 108 |
<div class="sld_payment_cell"> |
| 109 |
<?php echo esc_html__( 'Email', 'wpchatbot' ); ?> |
| 110 |
</div> |
| 111 |
<div class="sld_payment_cell"> |
| 112 |
<?php echo esc_html__( 'Phone', 'wpchatbot' ); ?> |
| 113 |
</div> |
| 114 |
|
| 115 |
</div> |
| 116 |
|
| 117 |
<?php |
| 118 |
foreach ( $rows as $row ) { |
| 119 |
?> |
| 120 |
<div class="sld_payment_row"> |
| 121 |
|
| 122 |
<div class="sld_payment_cell"> |
| 123 |
|
| 124 |
<input type="checkbox" name="emails[]" class="wpbot_email_checkbox" value="<?php echo absint( $row->id ); ?>" /> |
| 125 |
</div> |
| 126 |
|
| 127 |
<div class="sld_payment_cell"> |
| 128 |
<div class="sld_responsive_head"><?php echo esc_html__( 'Date', 'wpchatbot' ); ?></div> |
| 129 |
<?php echo esc_html( date( 'm/d/Y', strtotime( $row->date ) ) ); ?> |
| 130 |
</div> |
| 131 |
<div class="sld_payment_cell"> |
| 132 |
<div class="sld_responsive_head"><?php echo esc_html__( 'Name', 'wpchatbot' ); ?></div> |
| 133 |
<?php echo esc_html( $row->name ); ?> |
| 134 |
</div> |
| 135 |
<div class="sld_payment_cell"> |
| 136 |
<div class="sld_responsive_head"><?php echo esc_html__( 'Email', 'wpchatbot' ); ?></div> |
| 137 |
<?php |
| 138 |
echo esc_html( $row->email ); |
| 139 |
?> |
| 140 |
</div> |
| 141 |
<div class="sld_payment_cell"> |
| 142 |
<div class="sld_responsive_head"><?php echo esc_html__( 'Phone', 'wpchatbot' ); ?></div> |
| 143 |
<?php |
| 144 |
echo esc_html( $row->phone ); |
| 145 |
|
| 146 |
?> |
| 147 |
</div> |
| 148 |
|
| 149 |
</div> |
| 150 |
<?php |
| 151 |
} |
| 152 |
?> |
| 153 |
|
| 154 |
</div> |
| 155 |
</div> |
| 156 |
</form> |
| 157 |
</div> |
| 158 |
|