本文整理汇总了PHP中arr::set方法的典型用法代码示例。如果您正苦于以下问题:PHP arr::set方法的具体用法?PHP arr::set怎么用?PHP arr::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arr
的用法示例。
在下文中一共展示了arr::set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mdjm_limit_results_to_employee_quotes
/**
* Hook into pre_get_posts and limit employees quotes to their own events
* if their permissions are not full.
*
* @since 1.0
* @param arr $query The WP_Query
* @return void
*/
function mdjm_limit_results_to_employee_quotes($query)
{
if (!is_admin() || 'mdjm-quotes' != $query->get('post_type') || mdjm_employee_can('list_all_quotes')) {
return;
}
global $user_ID;
$events = mdjm_get_employee_events($user_ID);
foreach ($events as $event) {
$quote = mdjm_get_event_quote_id($event->ID);
if (!empty($quote)) {
$quotes[] = $quote;
}
}
if (!empty($quotes)) {
$query->set('post__in', $quotes);
}
}
示例2: mdjm_limit_results_to_employee_addons
/**
* Hook into pre_get_posts and limit employees addons if their permissions are not full.
*
* @since 1.4
* @param arr $query The WP_Query
* @return void
*/
function mdjm_limit_results_to_employee_addons($query)
{
if (!is_admin() || 'mdjm-addon' != $query->get('post_type') || mdjm_employee_can('mdjm_package_edit')) {
return;
}
global $user_ID;
$query->set('meta_query', array(array('key' => '_addon_employees', 'value' => sprintf(':"%s";', $user_ID), 'compare' => 'LIKE')));
}
示例3: mdjm_transaction_post_filtered
/**
* Adjust the query when the transactions are filtered.
*
* @since 1.3
* @param arr $query The WP_Query
* @return void
*/
function mdjm_transaction_post_filtered($query)
{
global $pagenow;
$post_type = isset($_GET['post_type']) ? $_GET['post_type'] : '';
if ('edit.php' != $pagenow || 'mdjm-transaction' != $post_type || !is_admin()) {
return;
}
// Filter by transaction type
if (!empty($_GET['mdjm_filter_type'])) {
$type = isset($_GET['mdjm_filter_type']) ? $_GET['mdjm_filter_type'] : 0;
if ($type != 0) {
$query->set('tax_query', array(array('taxonomy' => 'transaction-types', 'field' => 'term_id', 'terms' => $type)));
}
}
}
示例4: 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 ) )
}