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){ add_menu_page( 'AdMail', 'AdMail', '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' ); add_submenu_page('ambisn_nd', 'All product', 'All Products', 'manage_options', 'ambisn_all_products', 'ambisn_all_products_callback' ); if(!in_array('admail-pro/index.php', apply_filters( 'active_plugins', get_option('active_plugins')))){ add_submenu_page('ambisn', 'Get Pro', 'Get Pro', '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' ); } } function ambisn_hide_wp_notices() { global $parent_file; if($parent_file == 'ambisn' || $parent_file == 'ambisn_nd'){ echo ''; } } add_action( 'current_screen', 'ambisn_hide_wp_notices' ); function ambisn_get_pro_callback(){ wp_redirect('https://plugins.aleswebs.com/'); exit; } function ambisn_fallback_callback() { $debug_data = '
Fallback function called'; global $wpdb; $table_name = $wpdb->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'))); if ($table_exists && $wc_activated) { $redirect_url = admin_url('admin.php?page=ambisn'); wp_redirect($redirect_url); exit; } else { $plugin_icon_url = AMBISN_URL . 'assets/images/ambisn.svg'; ?>

OOPS, SOMETHING WENT WRONG

AdMail Table not found'; ?>

We encountered an issue while trying to find the necessary resources for AdMail to function correctly.

Note: Resetting AdMail data will restore the settings and collected data to their default values.

WooCommerce not activated'; ?>

And we think it's WooCommerce not being active.

'; } update_option('ambisn_debug_data',$debug_data); } function ambisn_callback(){ ?>

AdMail

'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_all_products_callback(){ ?>

AdMail

Settings

Collected Emails

Manage Subscriptions

0){ ambisn_generateTable($tab, 5); } else{ ambisn_emptyResults(); } ?>
Processing ...
' . $i . ''; } else{ $pagination_html .= '' . $i . ''; } } echo $pagination_html; } 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
$product_data){ foreach($product_data as $email => $status){ $count = $count + 1; } } return $count; } function ambisn_tabs_filter(){ ?>
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) { $subscriptions = ambisn_get_subscriptions($tab); $sub_product_ids = array_keys($subscriptions); $all_product_ids = array(); foreach($product_ids as $product_id){ $all_product_ids[] = $product_id; $product = wc_get_product($product_id); if ($product && $product->is_type('variation')) { $parent_id = wc_get_product_parent_id($product_id); $variation_ids = $parent_product->get_children(); $all_product_ids = array_merge($all_product_ids, $variation_ids); } elseif($product && $product->is_type('variable')){ $variation_ids = $product->get_children(); $all_product_ids = array_merge($all_product_ids, $variation_ids); } } $search_array = array(); foreach($all_product_ids as $product_id){ if(in_array($product_id, $sub_product_ids)){ $search_array = array($product_id); } } $subscription_items = array(); foreach ($subscriptions as $product_id => $product_data) { if (in_array($product_id, $search_array)){ foreach ($product_data as $email => $status) { $subscription_items[] = array('id' => $product_id, 'email' => $email, 'status' => $status); } } } return $subscription_items; } function ambisn_collected_emails_table($limit,$page){ $start = ($page * $limit) - $limit; $emails = ambisn_collected_emails('emails', 'all'); foreach( array_slice($emails, $start, $limit, true) as $collected_email){ ?> This user has cancelled the subscription.

'; } foreach($product_ids as $product_id){ $product = wc_get_product($product_id); $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(); } else{ $variation = wc_get_product($product_id); $url = $variation->get_permalink(); $name = $variation->get_name(); $image = wp_get_attachment_url( $variation->get_image_id()); } ?> is_in_stock( ); $parent_id = $product->get_parent_id(); $productSubscribers = get_post_meta($product_id, 'wc_admail_data', true); 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'; } $email = $item['email']; $date = $productSubscribers[$email]['date']; $from = strtotime($date); $today = time(); $difference = $today - $from; $in_days = floor($difference / 86400); if(empty($date)){ $in_days = '';} elseif($in_days == 0){ $in_days = 'Today';} elseif($in_days == 1){$in_days = $in_days.' day ago';} elseif($in_days > 1){$in_days = $in_days.' days ago';} else{$in_days = '';} 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"; } ?>

'.esc_html($in_days).''; ?>

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'); ambisn_collected_emails_page_content($total_count); } 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{ $subscritions_items = ambisn_get_subscriptions_items($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(){ if(isset($_REQUEST)){ $tab = sanitize_text_field($_REQUEST['tab']); $count = countTabs($tab); ob_start(); ambisn_tabs_filter(); $filter = ob_get_clean(); $response = array('filter' => $filter); ob_start(); if($count > 0){ ambisn_generateTable($tab, 5); } else{ ambisn_emptyResults(); } $table = ob_get_clean(); $response['table'] = $table; $json_response = json_encode($response); header('Content-Type: application/json'); echo $json_response; die(); } } add_action('wp_ajax_ambisn_load_tab_content','ambisn_load_tab_content'); function ambisn_most_wanted_products($limit){ $ambisn_products = ambisn_get_products(); $order = 0; foreach(array_slice($ambisn_products, 0, $limit, true) as $product_id => $subscribersCount){ if(filter_var($subscribersCount, FILTER_VALIDATE_INT) && $subscribersCount > 0){ $product = wc_get_product($product_id); $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(); $product_id.= ' -variation-'; $image = wp_get_attachment_url( $variation->get_image_id()); $label = ' -variation-'; } if(empty($image)){ $image = AMBISN_URL.'assets/images/no_image.png'; } if($subscribersCount > 1){ $countText = $subscribersCount.' subscribers'; }else{ $countText = $subscribersCount.' subscriber'; } if ($product->is_in_stock()){ $stock_status = 'In Stock'; } else{ $stock_status = 'Out of stock'; } $order++; ?>

#

ID:

View

Nothing Here!