本文整理汇总了PHP中em_paginate函数的典型用法代码示例。如果您正苦于以下问题:PHP em_paginate函数的具体用法?PHP em_paginate怎么用?PHP em_paginate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了em_paginate函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: em_admin_paginate
/**
* Creates a wp-admin style navigation. All this does is wrap some html around the em_paginate function result to make it style correctly in the admin area.
* @param string $link
* @param int $total
* @param int $limit
* @param int $page
* @param int $pagesToShow
* @return string
* @uses em_paginate()
*/
function em_admin_paginate($link, $total, $limit, $page = 1, $pagesToShow = 5)
{
$return = '<div class="tablenav-pages">';
$return .= sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>', number_format_i18n(($page - 1) * $limit + 1), number_format_i18n(min($page * $limit, $total)), number_format_i18n($total));
$return .= em_paginate($link, $total, $limit, $page, $pagesToShow);
$return .= '</div>';
return $return;
}
示例2: get_option
if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'search_events') {
$args['pagination'] = false;
if (get_option('dbem_event_list_groupby')) {
$args['mode'] = get_option('dbem_event_list_groupby');
$args['date_format'] = get_option('dbem_event_list_groupby_format');
echo em_events_list_grouped($args);
} else {
echo EM_Events::output($args);
}
//do some custom pagination (if needed/requested)
if (!empty($args['limit']) && $events_count > $args['limit']) {
//Show the pagination links (unless there's less than $limit events), note that we set em_search instead of search to prevent conflicts
$search_args = array_merge(EM_Events::get_post_search(), array('pno' => '%PAGE%', 'action' => 'search_events', 'search' => null, 'em_search' => $args['search']));
$page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], $search_args, false);
//don't html encode, so em_paginate does its thing
echo apply_filters('em_events_output_pagination', em_paginate($page_link_template, $events_count, $args['limit'], $args['pno']), $page_link_template, $events_count, $args['limit'], $args['pno']);
}
} else {
if (get_option('dbem_event_list_groupby')) {
$args['mode'] = get_option('dbem_event_list_groupby');
$args['date_format'] = get_option('dbem_event_list_groupby_format');
echo em_events_list_grouped($args);
} else {
echo EM_Events::output($args);
}
}
} else {
echo get_option('dbem_no_events_message');
}
if (get_option('dbem_events_page_ajax', defined('EM_AJAX_SEARCH'))) {
echo "</div>";
示例3: output
/**
* Output a set of matched of events
* @param array $args
* @return string
*/
function output($args)
{
global $EM_Location;
$EM_Location_old = $EM_Location;
//When looping, we can replace EM_Location global with the current event in the loop
//Can be either an array for the get search or an array of EM_Location objects
if (is_object(current($args)) && get_class(current($args)) == 'EM_Location') {
$func_args = func_get_args();
$locations = $func_args[0];
$args = !empty($func_args[1]) ? $func_args[1] : array();
$args = apply_filters('em_locations_output_args', self::get_default_search($args), $locations);
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
$locations_count = count($locations);
} else {
$args = apply_filters('em_locations_output_args', self::get_default_search($args));
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
$args_count = $args;
$args_count['limit'] = 0;
$args_count['offset'] = 0;
$args_count['page'] = 1;
$locations_count = self::count($args_count);
$locations = self::get($args);
}
//What format shall we output this to, or use default
$format = $args['format'] == '' ? get_option('dbem_location_list_item_format') : $args['format'];
$output = "";
$locations = apply_filters('em_locations_output_locations', $locations);
if (count($locations) > 0) {
foreach ($locations as $EM_Location) {
$output .= $EM_Location->output($format);
}
//Add headers and footers to output
if ($format == get_option('dbem_location_list_item_format')) {
$single_event_format_header = get_option('dbem_location_list_item_format_header');
$single_event_format_footer = get_option('dbem_location_list_item_format_footer');
$output = $single_event_format_header . $output . $single_event_format_footer;
}
//Pagination (if needed/requested)
if (!empty($args['pagination']) && !empty($limit) && $locations_count >= $limit) {
//Show the pagination links (unless there's less than 10 events
$page_link_template = preg_replace('/(&|\\?)pno=\\d+/i', '', $_SERVER['REQUEST_URI']);
$page_link_template = em_add_get_params($page_link_template, array('pno' => '%PAGE%'), false);
//don't html encode, so em_paginate does its thing
$output .= apply_filters('em_events_output_pagination', em_paginate($page_link_template, $locations_count, $limit, $page), $page_link_template, $locations_count, $limit, $page);
}
} else {
$output = get_option('dbem_no_locations_message');
}
//FIXME check if reference is ok when restoring object, due to changes in php5 v 4
$EM_Location_old = $EM_Location;
return apply_filters('em_locations_output', $output, $locations, $args);
}
示例4: output
/**
* Output a set of matched of events. You can pass on an array of EM_Events as well, in this event you can pass args in second param.
* Note that you can pass a 'pagination' boolean attribute to enable pagination, default is enabled (true).
* @param array $args
* @param array $secondary_args
* @return string
*/
function output($args)
{
global $EM_Event;
$EM_Event_old = $EM_Event;
//When looping, we can replace EM_Event global with the current event in the loop
//Can be either an array for the get search or an array of EM_Event objects
$func_args = func_get_args();
$page = 1;
//default
if (!array_key_exists('page', $args) && !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno'])) {
$page = $args['page'] = $_REQUEST['pno'];
}
if (is_object(current($args)) && get_class(current($args)) == 'EM_Event') {
$func_args = func_get_args();
$events = $func_args[0];
$args = !empty($func_args[1]) && is_array($func_args[1]) ? $func_args[1] : array();
$args = apply_filters('em_events_output_args', self::get_default_search($args), $events);
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : $page;
$events_count = count($events);
} else {
//Firstly, let's check for a limit/offset here, because if there is we need to remove it and manually do this
$args = apply_filters('em_events_output_args', $args);
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : $page;
$args_count = $args;
$args_count['limit'] = false;
$args_count['offset'] = false;
$args_count['page'] = false;
$events_count = self::count($args_count);
$events = self::get($args);
}
//What format shall we output this to, or use default
$format = empty($args['format']) ? get_option('dbem_event_list_item_format') : $args['format'];
$output = "";
$events = apply_filters('em_events_output_events', $events);
if ($events_count > 0) {
foreach ($events as $EM_Event) {
$output .= $EM_Event->output($format);
}
//Add headers and footers to output
if ($format == get_option('dbem_event_list_item_format')) {
$format_header = get_option('dbem_event_list_item_format_header') == '' ? '' : get_option('dbem_event_list_item_format_header');
$format_footer = get_option('dbem_event_list_item_format_footer') == '' ? '' : get_option('dbem_event_list_item_format_footer');
} else {
$format_header = !empty($args['format_header']) ? $args['format_header'] : '';
$format_footer = !empty($args['format_footer']) ? $args['format_footer'] : '';
}
$output = $format_header . $output . $format_footer;
//Pagination (if needed/requested)
if (!empty($args['pagination']) && !empty($limit) && $events_count > $limit) {
//Show the pagination links (unless there's less than $limit events)
$page_link_template = preg_replace('/(&|\\?)pno=\\d+/i', '', $_SERVER['REQUEST_URI']);
$page_link_template = em_add_get_params($page_link_template, array('pno' => '%PAGE%'), false);
//don't html encode, so em_paginate does its thing;
$output .= apply_filters('em_events_output_pagination', em_paginate($page_link_template, $events_count, $limit, $page), $page_link_template, $events_count, $limit, $page);
}
} else {
$output = get_option('dbem_no_events_message');
}
//TODO check if reference is ok when restoring object, due to changes in php5 v 4
$EM_Event = $EM_Event_old;
$output = apply_filters('em_events_output', $output, $events, $args);
return $output;
}
示例5: get_pagination_links
/**
* Generates pagination for classes like EM_Events based on supplied arguments and whether AJAX is enabled.
*
* @param array $args The arguments being searched for
* @param integer $count The number of total items to paginate through
* @param string $search_action The name of the action query var used to trigger a search - used in AJAX requests and normal searches
* @param array $default_args The default arguments and values this object accepts, used to compare against $args to create a querystring
* @param array $accepted_args Variables that can be passed on via a querystring and should be added to pagination links, objects should make use of this since the default may be EM_Object::get_default_search() due to late static binding issues
* @return string
* @uses em_paginate()
*/
public static function get_pagination_links($args, $count, $search_action, $default_args = array())
{
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
$pno = !empty($args['page_queryvar']) ? $args['page_queryvar'] : 'pno';
$default_pag_args = array($pno => '%PAGE%', 'page' => null, 'search' => null, 'action' => null, 'pagination' => null);
//clean out the bad stuff, set up page number template
$page_url = $_SERVER['REQUEST_URI'];
//$default_args are values that can be added to the querystring for use in searching events in pagination either in searches or ajax pagination
if (!empty($_REQUEST['action']) && $_REQUEST['action'] == $search_action && empty($default_args)) {
//due to late static binding issues in PHP, this'll always return EM_Object::get_default_search so this is a fall-back
$default_args = self::get_default_search();
}
//go through default arguments (if defined) and build a list of unique non-default arguments that should go into the querystring
$unique_args = array();
//this is the set of unique arguments we'll add to the querystring
$ignored_args = array('offset', 'ajax', 'array', 'pagination', 'format', 'format_header', 'format_footer');
foreach ($default_args as $arg_key => $arg_default_val) {
if (array_key_exists($arg_key, $args) && !in_array($arg_key, $ignored_args)) {
//if array exists, implode it in case one value is already imploded for matching purposes
$arg_val = is_array($args[$arg_key]) ? implode(',', $args[$arg_key]) : $args[$arg_key];
$arg_default_val = is_array($arg_default_val) ? implode(',', $arg_default_val) : $arg_default_val;
if ($arg_val != $arg_default_val) {
$unique_args[$arg_key] = $arg_val;
}
}
}
if (!empty($unique_args['search'])) {
$unique_args['em_search'] = $unique_args['search'];
//special case, since em_search is used in links rather than search, which we remove below
unset($unique_args['search']);
}
//build general page link with all arguments
$pag_args = array_merge($unique_args, $default_pag_args);
//if we're using ajax or already did an events search via a form, add the action here for pagination links
if (!empty($args['ajax']) || !empty($_REQUEST['action']) && $_REQUEST['action'] == $search_action) {
$unique_args['action'] = $pag_args['action'] = $search_action;
}
//if we're in an ajax call, make sure we aren't calling admin-ajax.php
if (defined('DOING_AJAX')) {
$page_url = wp_get_referer();
}
//finally, glue the url with querystring and pass onto pagination function
$page_link_template = em_add_get_params($page_url, $pag_args, false);
//don't html encode, so em_paginate does its thing;
if (empty($args['ajax']) || defined('DOING_AJAX')) {
$unique_args = array();
}
//don't use data method if ajax is disabled or if we're already in an ajax request (SERP irrelevenat)
$return = apply_filters('em_object_get_pagination_links', em_paginate($page_link_template, $count, $limit, $page, $unique_args), $page_link_template, $count, $limit, $page);
//if PHP is 5.3 or later, you can specifically filter by class e.g. em_events_output_pagination - this replaces the old filter originally located in the actual child classes
if (function_exists('get_called_class')) {
$return = apply_filters(strtolower(get_called_class()) . '_output_pagination', $return, $page_link_template, $count, $limit, $page);
}
return $return;
}
示例6: em_add_get_params
$limit = !empty($_GET['limit']) ? $_GET['limit'] : 20;
//Default limit
$page = !empty($_GET['pno']) ? $_GET['pno'] : 1;
$offset = $page > 1 ? ($page - 1) * $limit : 0;
echo $EM_Notices;
?>
<div class='em-my-bookings'>
<?php
if ($bookings_count >= $limit) {
?>
<div class='tablenav'>
<?php
if ($bookings_count >= $limit) {
$link = em_add_get_params($_SERVER['REQUEST_URI'], array('pno' => '%PAGE%'), false);
//don't html encode, so em_paginate does its thing
$bookings_nav = em_paginate($link, $bookings_count, $limit, $page);
echo $bookings_nav;
}
?>
<div class="clear"></div>
</div>
<?php
}
?>
<div class="clear"></div>
<?php
if ($bookings_count > 0) {
?>
<div class='table-wrap'>
<table id='dbem-bookings-table' class='widefat post fixed'>
<thead>
示例7: em_get_events_list_grouped
/**
* Generate a grouped list of events by year, month, week or day.
* @since 4.213
* @param array $args
* @return string
*/
function em_get_events_list_grouped($args)
{
//Reset some args to include pagination for if pagination is requested.
$args['limit'] = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$args['page'] = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
$args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : $args['page'];
$args['offset'] = ($args['page'] - 1) * $args['limit'];
$args['orderby'] = 'event_start_date,event_start_time,event_name';
// must override this to display events in right cronology.
//Reset some vars for counting events and displaying set arrays of events
$atts = (array) $args;
$atts['pagination'] = false;
$atts['limit'] = false;
$atts['page'] = false;
$atts['offset'] = false;
//decide what form of dates to show
$EM_Events = EM_Events::get($args);
$events_count = EM_Events::count($atts);
ob_start();
switch ($args['mode']) {
case 'yearly':
//go through the events and put them into a monthly array
$format = !empty($args['date_format']) ? $args['date_format'] : 'Y';
$events_dates = array();
foreach ($EM_Events as $EM_Event) {
$events_dates[date_i18n($format, $EM_Event->start)][] = $EM_Event;
}
foreach ($events_dates as $year => $events) {
echo '<h2>' . $year . '</h2>';
echo EM_Events::output($events, $atts);
}
break;
case 'monthly':
//go through the events and put them into a monthly array
$format = !empty($args['date_format']) ? $args['date_format'] : 'M Y';
$events_dates = array();
foreach ($EM_Events as $EM_Event) {
$events_dates[date_i18n($format, $EM_Event->start)][] = $EM_Event;
}
foreach ($events_dates as $month => $events) {
echo '<h2>' . $month . '</h2>';
echo EM_Events::output($events, $atts);
}
break;
case 'weekly':
$format = !empty($args['date_format']) ? $args['date_format'] : get_option('date_format');
$events_dates = array();
foreach ($EM_Events as $EM_Event) {
$start_of_week = get_option('start_of_week');
$day_of_week = date('w', $EM_Event->start);
$day_of_week = date('w', $EM_Event->start);
$offset = $day_of_week - $start_of_week;
if ($offset < 0) {
$offset += 7;
}
$offset = $offset * 60 * 60 * 24;
//days in seconds
$start_day = strtotime($EM_Event->start_date);
$events_dates[$start_day - $offset][] = $EM_Event;
}
foreach ($events_dates as $event_day_ts => $events) {
echo '<h2>' . date_i18n($format, $event_day_ts) . ' - ' . date_i18n($format, $event_day_ts + 60 * 60 * 24 * 6) . '</h2>';
echo EM_Events::output($events, $atts);
}
break;
default:
//daily
//go through the events and put them into a daily array
$format = !empty($args['date_format']) ? $args['date_format'] : get_option('date_format');
$events_dates = array();
foreach ($EM_Events as $EM_Event) {
$events_dates[strtotime($EM_Event->start_date)][] = $EM_Event;
}
foreach ($events_dates as $event_day_ts => $events) {
echo '<h2>' . date_i18n($format, $event_day_ts) . '</h2>';
echo EM_Events::output($events, $atts);
}
break;
}
if (!empty($args['limit']) && $events_count > $args['limit'] && (!empty($args['pagination']) || !isset($args['pagination']))) {
//Show the pagination links (unless there's less than $limit events)
$page_link_template = add_query_arg(array('pno' => '%PAGE%'));
echo em_paginate($page_link_template, $events_count, $args['limit'], $args['page']);
}
return ob_get_clean();
}
示例8: em_admin_locations
function em_admin_locations($message = '', $fill_fields = false)
{
$limit = !empty($_REQUEST['limit']) ? $_REQUEST['limit'] : 20;
//Default limit
$page = !empty($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
$offset = $page > 1 ? ($page - 1) * $limit : 0;
$locations = EM_Locations::get();
$locations_count = count($locations);
?>
<div class='wrap'>
<div id='icon-edit' class='icon32'>
<br/>
</div>
<h2>
<?php
_e('Locations', 'dbem');
?>
<a href="admin.php?page=events-manager-locations&action=add" class="button add-new-h2"><?php
_e('Add New');
?>
</a>
</h2>
<?php
if ($message != "") {
?>
<div id='message' class='updated fade below-h2'>
<p><?php
echo $message;
?>
</p>
</div>
<?php
}
?>
<form id='bookings-filter' method='post' action=''>
<input type='hidden' name='page' value='locations'/>
<input type='hidden' name='limit' value='<?php
echo $limit;
?>
' />
<input type='hidden' name='p' value='<?php
echo $page;
?>
' />
<?php
if ($locations_count > 0) {
?>
<div class='tablenav'>
<div class="alignleft actions">
<select name="action">
<option value="" selected="selected"><?php
_e('Bulk Actions');
?>
</option>
<option value="delete"><?php
_e('Delete selected', 'dbem');
?>
</option>
</select>
<input type="submit" value="<?php
_e('Apply');
?>
" id="doaction2" class="button-secondary action" />
<?php
//Pagination (if needed/requested)
if ($locations_count >= $limit) {
//Show the pagination links (unless there's less than 10 events
$page_link_template = preg_replace('/(&|\\?)p=\\d+/i', '', $_SERVER['REQUEST_URI']);
$page_link_template = em_add_get_params($page_link_template, array('pno' => '%PAGE%'));
$locations_nav = em_paginate($page_link_template, $locations_count, $limit, $page);
echo $locations_nav;
}
?>
</div>
</div>
<table class='widefat'>
<thead>
<tr>
<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
<th><?php
_e('Name', 'dbem');
?>
</th>
<th><?php
_e('Address', 'dbem');
?>
</th>
<th><?php
_e('Town', 'dbem');
?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<th class='manage-column column-cb check-column' scope='col'><input type='checkbox' class='select-all' value='1'/></th>
<th><?php
//.........这里部分代码省略.........
示例9: output
function output($args)
{
global $EM_Category;
$EM_Category_old = $EM_Category;
//When looping, we can replace EM_Category global with the current event in the loop
//Can be either an array for the get search or an array of EM_Category objects
if (is_object(current($args)) && get_class(current($args)) == 'EM_Category') {
$func_args = func_get_args();
$categories = $func_args[0];
$args = !empty($func_args[1]) ? $func_args[1] : array();
$args = apply_filters('em_categories_output_args', self::get_default_search($args), $categories);
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
} else {
$args = apply_filters('em_categories_output_args', self::get_default_search($args));
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$offset = !empty($args['offset']) && is_numeric($args['offset']) ? $args['offset'] : 0;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
$args['limit'] = false;
$args['offset'] = false;
$args['page'] = false;
$categories = self::get($args);
}
//What format shall we output this to, or use default
$format = $args['format'] == '' ? get_option('dbem_categories_list_item_format') : $args['format'];
$output = "";
$categories_count = count($categories);
$categories = apply_filters('em_categories_output_categories', $categories);
if (count($categories) > 0) {
$category_count = 0;
$categories_shown = 0;
foreach ($categories as $EM_Category) {
if (($categories_shown < $limit || empty($limit)) && ($category_count >= $offset || $offset === 0)) {
$output .= $EM_Category->output($format);
$categories_shown++;
}
$category_count++;
}
//Add headers and footers to output
if ($format == get_option('dbem_categories_list_item_format')) {
$single_event_format_header = get_option('dbem_categories_list_item_format_header');
$single_event_format_header = $single_event_format_header != '' ? $single_event_format_header : "<ul class='em-categories-list'>";
$single_event_format_footer = get_option('dbem_categories_list_item_format_footer');
$single_event_format_footer = $single_event_format_footer != '' ? $single_event_format_footer : "</ul>";
$output = $single_event_format_header . $output . $single_event_format_footer;
}
//Pagination (if needed/requested)
if (!empty($args['pagination']) && !empty($limit) && $categories_count >= $limit) {
//Show the pagination links (unless there's less than 10 events, or the custom limit)
$page_link_template = preg_replace('/(&|\\?)page=\\d+/i', '', $_SERVER['REQUEST_URI']);
$page_link_template = em_add_get_params($page_link_template, array('page' => '%PAGE%'));
$output .= apply_filters('em_events_output_pagination', em_paginate($page_link_template, $categories_count, $limit, $page), $page_link_template, $categories_count, $limit, $page);
}
} else {
$output = get_option('dbem_no_categories_message');
}
//FIXME check if reference is ok when restoring object, due to changes in php5 v 4
$EM_Category_old = $EM_Category;
return apply_filters('em_categories_output', $output, $categories, $args);
}
示例10: get_pagination_links
/**
* Generates pagination for classes like EM_Events based on supplied arguments and whether AJAX is enabled.
*
* @param array $args The arguments being searched for
* @param integer $count The number of total items to paginate through
* @param string $search_action The name of the action query var used to trigger a search - used in AJAX requests and normal searches
* @param array $default_args The default arguments and values this object accepts, used to compare against $args to create a querystring
* @param array $accepted_args Variables that can be passed on via a querystring and should be added to pagination links
* @return string
* @uses em_paginate()
*/
public static function get_pagination_links($args, $count, $search_action, $default_args = array(), $accepted_args = array())
{
$limit = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false;
$page = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1;
$default_pag_args = array('pno' => '%PAGE%', 'page' => null, 'search' => null, 'action' => null, 'pagination' => null);
//clean out the bad stuff, set up page number template
$page_url = $_SERVER['REQUEST_URI'];
//if we're dealing with searches, then we need to add to the pagination querystring template
$default_args = !empty($default_args) && is_array($default_args) ? $default_args : self::get_default_search();
$unique_args = array();
if (!empty($_REQUEST['action']) && $_REQUEST['action'] == $search_action && empty($accepted_args)) {
//$accepted_args are values that are force-added to the querystring, we only assign default object post search values if we're actually doing a searcy (AJAX or via REQUEST)
$accepted_args = self::get_post_search($args, true, $args);
}
foreach ($accepted_args as $arg_key => $arg_val) {
//carful with comparisons here, we need to typecast stuff into the right types
//we don't care about the actual default value, only if it's the same rough 'type'
if (isset($default_args[$arg_key])) {
if (!is_array($args)) {
$args = (string) $args;
$default_args[$arg_key] = (string) $default_args[$arg_key];
}
//anything other than above is either an object, array, or string which needs to be exactly the same
if ($arg_val != $default_args[$arg_key]) {
$unique_args[$arg_key] = $arg_val;
}
}
}
if (!empty($unique_args['search'])) {
$unique_args['em_search'] = $unique_args['search'];
//special case, since em_search is used in links rather than search, which we remove below
unset($unique_args['search']);
}
//build general page link with all arguments
$pag_args = array_merge($unique_args, $default_pag_args);
//if we're using ajax or already did an events search via a form, add the action here for pagination links
if (!empty($args['ajax']) || !empty($_REQUEST['action']) && $_REQUEST['action'] == $search_action) {
$unique_args['action'] = $pag_args['action'] = $search_action;
}
//if we're in an ajax call, make sure we aren't calling admin-ajax.php
if (defined('DOING_AJAX')) {
$page_url = wp_get_referer();
}
//finally, glue the url with querystring and pass onto pagination function
$page_link_template = em_add_get_params($page_url, $pag_args, false);
//don't html encode, so em_paginate does its thing;
if (empty($args['ajax']) || defined('DOING_AJAX')) {
$unique_args = array();
}
//don't use data method if ajax is disabled or if we're already in an ajax request (SERP irrelevenat)
return em_paginate($page_link_template, $count, $limit, $page, $unique_args);
}