本文整理汇总了PHP中arr::is_search方法的典型用法代码示例。如果您正苦于以下问题:PHP arr::is_search方法的具体用法?PHP arr::is_search怎么用?PHP arr::is_search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arr
的用法示例。
在下文中一共展示了arr::is_search方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mdjm_event_post_search
/**
* Customise the event post query during a search so that clients and employees are included in results.
*
* @since 1.0
* @param arr $query The WP_Query
* @return void
*/
function mdjm_event_post_search($query)
{
global $pagenow;
if (!is_admin() || 'mdjm-event' != $query->get('post_type') || !$query->is_search() || 'edit.php' != $pagenow) {
return;
}
// If searching it's only useful if we include clients and employees
$users = new WP_User_Query(array('search' => $_GET['s'], 'search_columns' => array('user_login', 'user_email', 'user_nicename', 'display_name')));
// WP_User_Query
$user_results = $users->get_results();
// Loop through WP_User_Query search looking for events where user is client or employee
if (!empty($user_results)) {
foreach ($user_results as $user) {
$results = get_posts(array('post_type' => 'mdjm-event', 'post_status' => 'any', 'posts_per_page' => -1, 'meta_query' => array('relation' => 'OR', array('key' => '_mdjm_event_dj', 'value' => $user->ID, 'type' => 'NUMERIC'), array('key' => '_mdjm_event_client', 'value' => $user->ID, 'type' => 'NUMERIC'), array('key' => '_mdjm_event_employees', 'value' => sprintf(':"%s";', $user->ID), 'compare' => 'LIKE'))));
// get_posts
if (!empty($results)) {
foreach ($results as $result) {
$events[] = $result->ID;
}
}
}
// foreach( $users as $user )
if (!empty($events)) {
$query->set('post__in', $events);
$query->set('post_status', array('mdjm-unattended', 'mdjm-enquiry', 'mdjm-contract', 'mdjm-approved', 'mdjm-failed', 'mdjm-rejected', 'mdjm-completed'));
}
}
// if( !empty( $users ) )
}