/**
 * Checking whether the email already exists or not.
 * 
 * @param  integer $email Email address to check.
 * @return boolean        Exists or not.
 * ------------------------------------------------------------------------------
 */
function nano_ed_email_exists($email)
{
    $emails = nano_ed_email_lists();
    //all the emails
    if (in_array($email, $emails)) {
        return true;
    } else {
        return false;
    }
}
예제 #2
0
function email_downloads_options_page_callback()
{
    ?>
	<div class="wrap">
		
		<form action='options.php' method='post'>

			<h2><?php 
    printf(__('Downloads via Email <small>by <a class="link-none" href="%s"><strong>nano</strong>designs</a></small>', 'email-downloads'), 'http://nanodesignsbd.com/');
    ?>
</h2>

			<div class="ed-row">
				<div class="ed-column-left">
					<?php 
    settings_fields('ed');
    do_settings_sections('ed');
    submit_button();
    ?>
				</div>
				<div class="ed-column-right">
					<?php 
    require_once '__nanodesigns_promo.php';
    ?>
				</div>
				<div class="ed-clearfix"></div>
			</div>

		</form>
			


	<?php 
    /**
     * Pagination in action.
     * @author  Tareq Hasan
     * @link http://tareq.wedevs.com/2011/07/simple-pagination-system-in-your-wordpress-plugins/
     * --------------
     */
    $pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1;
    $posts_per_page = get_option('posts_per_page');
    $offset = ($pagenum - 1) * $posts_per_page;
    $get_emails = nano_ed_email_lists($posts_per_page, $offset);
    if ($get_emails) {
        $_counter = 0;
        ?>
			<hr>

			<h2><?php 
        _e('Stored Email Address', 'email-downloads');
        ?>
</h2>
			<table class="wp-list-table widefat fixed striped">
				<thead>
					<tr>
						<th><?php 
        _e('Serial', 'email-downloads');
        ?>
</th>
						<th><?php 
        _e('Email', 'email-downloads');
        ?>
</th>
					</tr>
				</thead>
				<tbody>
				<?php 
        foreach ($get_emails as $emails) {
            $_counter++;
            ?>
				
					<tr>
						<td><?php 
            echo $_counter;
            ?>
</td>
						<td><?php 
            echo $emails->email;
            ?>
</td>
					</tr>
				<?php 
        }
        ?>
				</tbody>
			</table>
			<?php 
        global $wpdb;
        $table = $wpdb->prefix . 'download_email';
        $total = $wpdb->get_var("SELECT COUNT(*) FROM {$table} GROUP BY id");
        $num_of_pages = ceil($total / $posts_per_page);
        $page_links = paginate_links(array('base' => add_query_arg('pagenum', '%#%'), 'format' => '', 'prev_text' => '&laquo;', 'next_text' => '&raquo;', 'total' => $num_of_pages, 'current' => $pagenum));
        if ($page_links) {
            echo '<div class="tablenav"><div class="tablenav-pages" style="margin: 1em 0">' . $page_links . '</div></div>';
        }
        ?>
	<?php 
    }
    ?>

	</div> <!-- .wrap -->
	<?php 
}