prefix . 'wc_admail'; $table_exists = $wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name; $wc_activated = in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))); $bisn_icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZwoJdmVyc2lvbj0iMS4xIgoJeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgoJeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiCgl4PSIwJSIgeT0iMCUiCgl3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIgoJdmlld0JveD0iMCAwIDIwLjAgMjAuMCIKCWVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgMCAwIDIwLjAgMjAuMCIKCXhtbDpzcGFjZT0icHJlc2VydmUiPgoJPHBhdGgKCQlmaWxsPSIjMDAwMDAwIgoJCXN0cm9rZT0iI0ZGRkZGRiIKCQlmaWxsLW9wYWNpdHk9IjAuMDAwIgoJCXN0cm9rZS1vcGFjaXR5PSIxLjAwMCIKCQlmaWxsLXJ1bGU9Im5vbnplcm8iCgkJc3Ryb2tlLXdpZHRoPSIwLjE5OTk5OTk5IgoJCXN0cm9rZS1saW5lam9pbj0ibWl0ZXIiCgkJc3Ryb2tlLWxpbmVjYXA9InNxdWFyZSIKCQlkPSJNNC4xOSwwLjUyTDE1Ljg2LDAuNTJBMy41OSAzLjU5IDAgMCAxIDE5LjQ1LDQuMTFMMTkuNDUsMTUuOTZBMy41OSAzLjU5IDAgMCAxIDE1Ljg2LDE5LjU2TDQuMTksMTkuNTZBMy41OSAzLjU5IDAgMCAxIDAuNjAsMTUuOTZMMC42MCw0LjExQTMuNTkgMy41OSAwIDAgMSA0LjE5LDAuNTJ6Ii8+Cgk8cGF0aAoJCWZpbGw9IiNGRkZGRkYiCgkJc3Ryb2tlPSIjRkZGRkZGIgoJCW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MDAwIgoJCXN0cm9rZT0iI0ZGRkZGRiIKCQlmaWxsLW9wYWNpdHk9IjAuNzM3IgoJCXN0cm9rZS1vcGFjaXR5PSIwLjc0OSIKCQlmaWxsLXJ1bGU9Im5vbnplcm8iCgkJc3Ryb2tlLXdpZHRoPSIwLjk2MTg2MDY2IgoJCXN0cm9rZS1saW5lam9pbj0ibWl0ZXIiCgkJc3Ryb2tlLWxpbmVjYXA9InJvdW5kIgoJCWQ9Ik01LjA2LDEwLjA1TDcuMDksMTAuMDUiLz4KCTxwYXRoCgkJZmlsbD0iIzAwMDAwMCIKCQlzdHJva2U9IiNGRkZGRkYiCgkJZmlsbC1vcGFjaXR5PSIwLjczNyIKCQlzdHJva2Utb3BhY2l0eT0iMC43NDkiCgkJZmlsbC1ydWxlPSJub256ZXJvIgoJCXN0cm9rZS13aWR0aD0iMC45NjE4NjA2NiIKCQlzdHJva2UtbGluZWpvaW49Im1pdGVyIgoJCXN0cm9rZS1saW5lY2FwPSJyb3VuZCIKCQlkPSJNNC4yMSwxMi4zN0w2LjI0LDEyLjM3Ii8+Cjwvc3ZnPg=='; if(!$table_exists){ add_menu_page( 'AdMail', 'AdMail', 'manage_options', 'ambisn_error', 'ambisn_fallback_callback', $bisn_icon, 55.1); } elseif($wc_activated){ $admail = new AmbisnSubscriptions; $notification_count = count($admail->get_filtered_subscriptions('instock')); if($notification_count > 0){ if($notification_count > 100){ $notification_count = '100+'; } $main_menu = $notification_count ? sprintf('AdMail %d', $notification_count) : 'AdMail'; }else{ $main_menu = 'AdMail'; } add_menu_page( 'AdMail' , $main_menu, 'manage_options', 'ambisn', 'ambisn_callback', $bisn_icon, 55.1); add_submenu_page('ambisn', 'Collected Emails', 'Collected Emails', 'manage_options', 'ambisn_collected_email', 'ambisn_collected_emails_callback' ); add_submenu_page('', 'AdMail', 'AdMail', 'manage_options', 'ambisn_error', 'ambisn_fallback_callback' ); add_submenu_page('ambisn_nd', 'Sent', 'Sent', 'manage_options', 'ambisn_tab_sent', 'ambisn_tab_sent_callback' ); add_submenu_page('ambisn_nd', 'Out of stock ptoducts', 'Out of stock ptoducts', 'manage_options', 'ambisn_tab_ofs', 'ambisn_tab_ofs_callback' ); add_submenu_page('ambisn_nd', 'Available', 'Available', 'manage_options', 'ambisn_tab_waiting', 'ambisn_tab_available_callback' ); add_submenu_page('ambisn_nd', 'Trashed', 'Trashed', 'manage_options', 'ambisn_tab_trashed', 'ambisn_tab_trashed_callback' ); add_submenu_page('ambisn', 'Settings', 'Settings', 'manage_options', 'ambisn_settings', 'ambisn_settings_callback' ); if(!in_array('admail-pro/index.php', apply_filters( 'active_plugins', get_option('active_plugins')))){ add_submenu_page('ambisn', 'Get Pro', 'Get Pro - Free trial', 'manage_options', 'ambisn_get_pro', 'ambisn_get_pro_callback' ); } } else{ add_menu_page( 'AdMail', 'AdMail', 'manage_options', 'ambisn_error', 'ambisn_fallback_callback', $bisn_icon, 55.1); add_submenu_page('', 'AdMail', 'AdMail', 'manage_options', 'ambisn_error', 'ambisn_fallback_callback' ); add_submenu_page('', 'Sent', 'Sent', 'manage_options', 'ambisn_tab_sent', 'ambisn_fallback_callback' ); add_submenu_page('', 'Out of stock ptoducts', 'Out of stock ptoducts', 'manage_options', 'ambisn_tab_ofs', 'ambisn_fallback_callback' ); add_submenu_page('', 'Available', 'Available', 'manage_options', 'ambisn_tab_waiting', 'ambisn_fallback_callback' ); add_submenu_page('', 'Trashed', 'Trashed', 'manage_options', 'ambisn_tab_trashed', 'ambisn_fallback_callback' ); add_submenu_page('', 'settings', 'Settings', 'manage_options', 'ambisn_settings', 'ambisn_fallback_callback' ); add_submenu_page('', 'All product', 'All Products', 'manage_options', 'ambisn_all_products', 'ambisn_fallback_callback' ); } //add_action('admin_enqueue_scripts', 'ambisn_admin_scripts'); } function ambisn_fallback_callback() { include_once (AMBISN_PATH.'includes/blocks/fallback_content.php'); } function ambisn_callback(){ ?>

AdMail

Settings

'; ambisn_tabsPage('sent'); echo '
'; } function ambisn_tab_ofs_callback(){ echo '
'; ambisn_tabsPage('ofs'); echo '
'; } function ambisn_tab_available_callback(){ echo '
'; ambisn_tabsPage('instock'); echo '
'; } function ambisn_tab_trashed_callback(){ echo '
'; ambisn_tabsPage('trashed'); echo '
'; } function ambisn_tabsPage($tab){ echo '

Manage Subscriptions

'; echo '
'; include_once (AMBISN_PATH.'includes/blocks/tabs_filter.php'); $admail = new AmbisnSubscriptions; $subscritions_items = $admail->get_filtered_subscriptions($tab); $count = count($subscritions_items); if($count > 0){ ambisn_generateTable($tab, 5); }else{ ambisn_emptyResults(); } } if (isset($_POST['reset_admail_data'])) { $site = site_url(); $logo = esc_url(wp_get_attachment_image_src(get_theme_mod('custom_logo'), 'full')[0]); if(empty($logo)){ $logo = AMBISN_URL.'assets/images/wp-logo.png'; } $site_title = get_bloginfo('name'); $ambisn_settings = array( 'guests'=>'1', 'unsubscribe'=>'1', 'email_field'=>'1', 'auto_submission'=>'0', 'popup'=>'0', 'ajaxify_submission'=>'1', 'form_text'=>'Be the first to know once this product is back in stock', 'form_subscribed_text'=>'Your subscription request has been received!', 'form_previously_subscribed_notice'=>'A previous subscription with this email found!', 'button_text'=>'SUBSCRIBE', 'button_bg_color'=>'#fd6e4f', 'button_text_color'=>'#fff', 'button_border_radius'=>'0px', 'unsubscribe_text'=>'Unsubscribe?', 'store_logo'=> $logo, 'store_name'=>$site_title, 'store_email'=>'info', 'no_reply'=>'0', 'email_price'=>'1', 'email_qty'=>'1', 'email_subject'=>'The product you subscribed for is back in stock!', 'email_heading'=>'YOU ARE IN LUCK!', 'email_subheading'=>'The sold out product you liked is back in stock.', 'email_footer' => 'Sent with love by '.$site_title, 'email_template'=>'default', ); global $wpdb; $wpdb->hide_errors(); require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $table_name = $wpdb->prefix . 'wc_admail'; $charset_collate = $wpdb->get_charset_collate(); if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") !== $table_name) { $sql = "CREATE TABLE `$table_name` ( ID INT NOT NULL AUTO_INCREMENT, option_name TEXT, option_type TEXT, value TEXT, date DATE, PRIMARY KEY (ID) ) $charset_collate;"; $db_delta_result = dbDelta($sql); $wpdb->insert($table_name, array('option_name' => 'admail_settings', 'value' => serialize($ambisn_settings), 'option_type' => 'setting')); return $db_delta_result; }else{ $sql = "SELECT `value` FROM `$table_name` WHERE `option_name` = 'admail_settings' AND `option_type` = 'setting'"; $existing_settings = $wpdb->get_var($sql); $existing_settings = unserialize($existing_settings); $updated_settings = array_merge($ambisn_settings, $existing_settings); $wpdb->update($table_name, array('value' => serialize($updated_settings)), array('option_name' => 'admail_settings', 'option_type' => 'setting')); } } if (isset($_POST['ambisn_download_emails'])) { $emailArray = ambisn_collected_emails('emails', 'all'); $csvFileName = 'AdMail_Emails.csv'; $csvFilePath = fopen($csvFileName, 'w'); foreach ($emailArray as $email) { fputcsv($csvFilePath, array($email)); } fclose($csvFilePath); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="' . $csvFileName . '"'); readfile($csvFileName); unlink($csvFileName); exit; } function ambisn_collected_emails_callback(){ ?>

Collected Emails

Send promotional emails
Processing ...
= ($total_pages - 3)) { $pages = array(1, $total_pages - 4, $total_pages - 3, $total_pages - 2, $total_pages - 1, $total_pages); } else { $pages = array(1, $page - 1, $page, $page + 1, $total_pages); } $pages = array_values(array_unique(array_map('intval', $pages))); sort($pages); echo ''; $previous_page = 0; foreach ($pages as $current_page) { if ($previous_page && $current_page > ($previous_page + 1)) { echo ''; } $active = ($current_page === $page) ? ' active' : ''; $aria_current = ($current_page === $page) ? ' aria-current="page"' : ''; echo ''; $previous_page = $current_page; } echo ''; } function ambisn_allProducts(){ ?>

Most Wanted Products

$subscribersCount){ $product = wc_get_product($product_id); $product_availability = $product->is_in_stock( ); $parent_id = $product->get_parent_id(); if($parent_id == '0'){ $image = wp_get_attachment_url( $product->get_image_id()); $url = $product->get_permalink(); $name = $product->get_title(); $label = ''; } else{ $variation = wc_get_product($product_id); $url = $variation->get_permalink(); $name = $variation->get_name(); $label = ' -variation-'; $image = wp_get_attachment_url( $variation->get_image_id()); } if(empty($image)){ $image = AMBISN_URL.'assets/images/no_image.png'; } $url = $product->get_permalink(); if ($product->is_in_stock()){ $stock_status = 'In Stock'; } else{ $stock_status = 'Out of stock'; } if($subscribersCount > 1){ $countText = $subscribersCount.' subscribers'; }else{ $countText = $subscribersCount.' subscriber'; } $order++; ?>

#

ID:

View
get_filtered_subscriptions($tab); $limit = esc_attr(get_option('ambisn_table_items_per_page')); if(empty($limit)){ $limit = 50; } ?>
Product Customer's Email Subscribed on Stock Status
$limit){ echo '
'; ambisn_table_pagination($total_count , $limit, $page); echo '
'; } ?>
$product_data){ foreach($product_data as $email => $status){ $subscritions_items[] = array('id'=>$product_id, 'email'=> $email, 'status'=>$status); } } return $subscritions_items; } function ambisn_get_subscriptions_by_product($tab, $product_ids) { $admail = new AmbisnSubscriptions; $subscritions_items = $admail->get_filtered_subscriptions($tab); $filtered_items = array(); foreach($subscritions_items as $item){ $product_id = $item['product_id']; if(in_array($product_id, $product_ids)){ $filtered_items[] = $item; } } return $filtered_items; } function ambisn_collected_emails_table($limit,$page){ $admail = new AmbisnSubscriptions; $emails = $admail->get_emails(); $start = ($page * $limit) - $limit; foreach( array_slice($emails, $start, $limit, true) as $collected_email){ ?> get_products($collected_email); if(count($product_ids) == '0'){ echo '

The subscription has been canceled or deleted.

'; }foreach($product_ids as $product_id){ $product = wc_get_product($product_id); if($product){ $is_variation = false; $parent_id = $product->get_parent_id(); if($parent_id != '0'){ $is_variation = true; } $image = wp_get_attachment_url( $product->get_image_id()); if(empty($image)){ $image = AMBISN_URL.'assets/images/no_image.png'; } $url = $product->get_permalink(); ?> is_in_stock( ); $is_variation = false; if($product->get_parent_id() != '0'){ $is_variation = true; } $label = ''; $image = wp_get_attachment_url( $product->get_image_id()); $url = $product->get_permalink(); if($is_variation){ $name = $product->get_name(); $label = ' -variation-'; }else{ $name = $product->get_title(); } if(empty($image)){ $image = AMBISN_URL.'assets/images/no_image.png'; } $email = $item['email']; $date = $item['subscription_date']; if(isset($item['lang']) && $item['lang'] != ''){ $lang = $item['lang']; $lang_html = ''.esc_html($lang).''; }else{ $lang = '-'; $lang_html = 'Language undefined'; } $dateFormat = get_option('date_format'); $timeFormat = get_option('time_format'); if (strpos($date, ' ') !== false) { $formattedDate = date($dateFormat . ' ' . $timeFormat, strtotime($date)); } else { $formattedDate = date($dateFormat, strtotime($date)); } $time_difference = ambisn_getTimeDifference($date); if(email_exists($email)){ $user = get_user_by('email',$email); $username = $user->display_name; $userHTML = '

'.$username.'Registred

'; } else{ $userHTML = '
'; } if ($product->is_in_stock()){ $stock_status = 'In Stock'; $avail_class = "in-stock"; } else{ $stock_status = 'Out of stock'; $avail_class = "out-of-stock"; } ?>

get_filtered_subscriptions($tab); $count = count($subscritions_items); if($count > 0){ ambisn_generateTable($tab, 5); } else{ ambisn_emptyResults(); } die(); } } add_action('wp_ajax_ambisn_update_items_per_page','ambisn_update_items_per_page'); function ambisn_update_emails_per_page(){ if(isset($_REQUEST)){ $value = sanitize_text_field($_REQUEST['value']); update_option('ambisn_table_emails_per_page', $value); if($value > 0){ include_once (AMBISN_PATH.'includes/collected_emails_page.php'); } } die(); } add_action('wp_ajax_ambisn_update_emails_per_page','ambisn_update_emails_per_page'); function ambisn_load_table_pagination_rows(){ if(isset($_REQUEST)){ $page = sanitize_text_field($_REQUEST['selectedPage']); $tab = sanitize_text_field($_REQUEST['tab']); if(empty($limit)){ $limit = 50; } if($tab == 'emails'){ $limit = esc_attr(get_option('ambisn_table_emails_per_page')); $emails = ambisn_collected_emails('emails', 'all'); ambisn_collected_emails_table($limit,$page); }else{ $admail = new AmbisnSubscriptions; $subscritions_items = $admail->get_filtered_subscriptions($tab); $limit = esc_attr(get_option('ambisn_table_items_per_page')); ambisn_table_rows($subscritions_items, $limit, $page, $tab); } die(); } } add_action('wp_ajax_ambisn_load_table_pagination_rows','ambisn_load_table_pagination_rows'); function ambisn_load_tab_content(){ $response = array(); if(isset($_REQUEST['tab'])){ $tab = sanitize_text_field($_REQUEST['tab']); $admail = new AmbisnSubscriptions; $subscritions_items = $admail->get_filtered_subscriptions($tab); $count = count($subscritions_items); ob_start(); include_once (AMBISN_PATH.'includes/blocks/tabs_filter.php'); $response['filter'] = ob_get_clean(); ob_start(); if($count > 0){ ambisn_generateTable($tab, 5); }else{ ambisn_emptyResults(); } $response['table'] = ob_get_clean(); echo json_encode($response); } die(); } add_action('wp_ajax_ambisn_load_tab_content','ambisn_load_tab_content'); function ambisn_emptyResults(){ ?>

Nothing Here!

#wpbody-content > .notice, #wpbody-content > .error { display: none !important; }'; } } add_action( 'current_screen', 'ambisn_hide_wp_notices' ); function ambisn_get_pro_callback(){ wp_redirect('https://plugins.aleswebs.com/'); exit; }