本文整理汇总了PHP中bp_sort_by_key函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_sort_by_key函数的具体用法?PHP bp_sort_by_key怎么用?PHP bp_sort_by_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_sort_by_key函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_alpha_sort_by_key
/**
* Sort an array of objects or arrays by alphabetically sorting by a specific key/property.
*
* For instance, if you have an array of WordPress post objects, you can sort
* them by post_name as follows:
* $sorted_posts = bp_alpha_sort_by_key( $posts, 'post_name' );
*
* @since BuddyPress (1.9.0)
*
* @param array $items The items to be sorted. Its constituent items can be either associative arrays or objects.
* @param string|int $key The array index or property name to sort by.
* @return array $items The sorted array.
*/
function bp_alpha_sort_by_key($items, $key)
{
return bp_sort_by_key($items, $key, 'alpha');
}
示例2: bp_activity_set_action
/**
* Register an activity 'type' and its action description/callback.
*
* Activity actions are strings used to describe items in the activity stream,
* such as 'Joe became a registered member' or 'Bill and Susie are now
* friends'. Each activity type (such as 'new_member' or 'friendship_created')
* used by a component should be registered using this function.
*
* While it's possible to post items to the activity stream whose types are
* not registered using bp_activity_set_action(), it is not recommended;
* unregistered types will not be displayed properly in the activity admin
* panel, and dynamic action generation (which is essential for multilingual
* sites, etc) will not work.
*
* @since 1.1.0
*
* @param string $component_id The unique string ID of the component.
* @param string $type The action type.
* @param string $description The action description.
* @param callable|bool $format_callback Callback for formatting the action string.
* @param string|bool $label String to describe this action in the activity stream filter dropdown.
* @param array $context Optional. Activity stream contexts where the filter should appear.
* Values: 'activity', 'member', 'member_groups', 'group'.
* @param int $position Optional. The position of the action when listed in dropdowns.
* @return bool False if any param is empty, otherwise true.
*/
function bp_activity_set_action($component_id, $type, $description, $format_callback = false, $label = false, $context = array(), $position = 0)
{
$bp = buddypress();
// Return false if any of the above values are not set.
if (empty($component_id) || empty($type) || empty($description)) {
return false;
}
// Set activity action.
if (!isset($bp->activity->actions) || !is_object($bp->activity->actions)) {
$bp->activity->actions = new stdClass();
}
// Verify callback.
if (!is_callable($format_callback)) {
$format_callback = '';
}
if (!isset($bp->activity->actions->{$component_id}) || !is_object($bp->activity->actions->{$component_id})) {
$bp->activity->actions->{$component_id} = new stdClass();
}
/**
* Filters the action type being set for the current activity item.
*
* @since 1.1.0
*
* @param array $array Array of arguments for action type being set.
* @param string $component_id ID of the current component being set.
* @param string $type Action type being set.
* @param string $description Action description for action being set.
* @param callable $format_callback Callback for formatting the action string.
* @param string $label String to describe this action in the activity stream filter dropdown.
* @param array $context Activity stream contexts where the filter should appear. 'activity', 'member',
* 'member_groups', 'group'.
*/
$bp->activity->actions->{$component_id}->{$type} = apply_filters('bp_activity_set_action', array('key' => $type, 'value' => $description, 'format_callback' => $format_callback, 'label' => $label, 'context' => $context, 'position' => $position), $component_id, $type, $description, $format_callback, $label, $context);
// Sort the actions of the affected component.
$action_array = (array) $bp->activity->actions->{$component_id};
$action_array = bp_sort_by_key($action_array, 'position', 'num');
// Restore keys.
$bp->activity->actions->{$component_id} = new stdClass();
foreach ($action_array as $key_ordered) {
$bp->activity->actions->{$component_id}->{$key_ordered['key']} = $key_ordered;
}
return true;
}
示例3: bp_attachments_enqueue_scripts
/**
* Enqueues the script needed for the Uploader UI.
*
* @see BP_Attachment::script_data() && BP_Attachment_Avatar::script_data() for examples showing how
* to set specific script data.
*
* @since 2.3.0
*
* @param string $class name of the class extending BP_Attachment (eg: BP_Attachment_Avatar).
*
* @return null|WP_Error
*/
function bp_attachments_enqueue_scripts($class = '')
{
// Enqueue me just once per page, please.
if (did_action('bp_attachments_enqueue_scripts')) {
return;
}
if (!$class || !class_exists($class)) {
return new WP_Error('missing_parameter');
}
// Get an instance of the class and get the script data
$attachment = new $class();
$script_data = $attachment->script_data();
$args = bp_parse_args($script_data, array('action' => '', 'file_data_name' => '', 'max_file_size' => 0, 'browse_button' => 'bp-browse-button', 'container' => 'bp-upload-ui', 'drop_element' => 'drag-drop-area', 'bp_params' => array(), 'extra_css' => array(), 'extra_js' => array(), 'feedback_messages' => array()), 'attachments_enqueue_scripts');
if (empty($args['action']) || empty($args['file_data_name'])) {
return new WP_Error('missing_parameter');
}
// Get the BuddyPress uploader strings
$strings = bp_attachments_get_plupload_l10n();
// Get the BuddyPress uploader settings
$settings = bp_attachments_get_plupload_default_settings();
// Set feedback messages
if (!empty($args['feedback_messages'])) {
$strings['feedback_messages'] = $args['feedback_messages'];
}
// Use a temporary var to ease manipulation
$defaults = $settings['defaults'];
// Set the upload action
$defaults['multipart_params']['action'] = $args['action'];
// Set BuddyPress upload parameters if provided
if (!empty($args['bp_params'])) {
$defaults['multipart_params']['bp_params'] = $args['bp_params'];
}
// Merge other arguments
$ui_args = array_intersect_key($args, array('file_data_name' => true, 'browse_button' => true, 'container' => true, 'drop_element' => true));
$defaults = array_merge($defaults, $ui_args);
if (!empty($args['max_file_size'])) {
$defaults['filters']['max_file_size'] = $args['max_file_size'] . 'b';
}
// Specific to BuddyPress Avatars
if ('bp_avatar_upload' === $defaults['multipart_params']['action']) {
// Include the cropping informations for avatars
$settings['crop'] = array('full_h' => bp_core_avatar_full_height(), 'full_w' => bp_core_avatar_full_width());
// Avatar only need 1 file and 1 only!
$defaults['multi_selection'] = false;
// Does the object already has an avatar set
$has_avatar = $defaults['multipart_params']['bp_params']['has_avatar'];
// What is the object the avatar belongs to
$object = $defaults['multipart_params']['bp_params']['object'];
// Init the Avatar nav
$avatar_nav = array('upload' => array('id' => 'upload', 'caption' => __('Upload', 'buddypress'), 'order' => 0), 'delete' => array('id' => 'delete', 'caption' => __('Delete', 'buddypress'), 'order' => 100, 'hide' => (int) (!$has_avatar)));
// Create the Camera Nav if the WebCam capture feature is enabled
if (bp_avatar_use_webcam() && 'user' === $object) {
$avatar_nav['camera'] = array('id' => 'camera', 'caption' => __('Take Photo', 'buddypress'), 'order' => 10);
// Set warning messages
$strings['camera_warnings'] = array('requesting' => __('Please allow us to access to your camera.', 'buddypress'), 'loading' => __('Please wait as we access your camera.', 'buddypress'), 'loaded' => __('Camera loaded. Click on the "Capture" button to take your photo.', 'buddypress'), 'noaccess' => __('It looks like you do not have a webcam or we were unable to get permission to use your webcam. Please upload a photo instead.', 'buddypress'), 'errormsg' => __('Your browser is not supported. Please upload a photo instead.', 'buddypress'), 'videoerror' => __('Video error. Please upload a photo instead.', 'buddypress'), 'ready' => __('Your profile photo is ready. Click on the "Save" button to use this photo.', 'buddypress'), 'nocapture' => __('No photo was captured. Click on the "Capture" button to take your photo.', 'buddypress'));
}
/**
* Use this filter to add a navigation to a custom tool to set the object's avatar.
*
* @since 2.3.0
*
* @param array $avatar_nav An associative array of available nav items where each item is an array organized this way:
* $avatar_nav[ $nav_item_id ] {
* @type string $nav_item_id The nav item id in lower case without special characters or space.
* @type string $caption The name of the item nav that will be displayed in the nav.
* @type int $order An integer to specify the priority of the item nav, choose one.
* between 1 and 99 to be after the uploader nav item and before the delete nav item.
* @type int $hide If set to 1 the item nav will be hidden
* (only used for the delete nav item).
* }
* @param string $object the object the avatar belongs to (eg: user or group)
*/
$settings['nav'] = bp_sort_by_key(apply_filters('bp_attachments_avatar_nav', $avatar_nav, $object), 'order', 'num');
// Specific to BuddyPress cover images
} elseif ('bp_cover_image_upload' === $defaults['multipart_params']['action']) {
// Cover images only need 1 file and 1 only!
$defaults['multi_selection'] = false;
// Default cover component is xprofile
$cover_component = 'xprofile';
// Get the object we're editing the cover image of
$object = $defaults['multipart_params']['bp_params']['object'];
// Set the cover component according to the object
if ('group' === $object) {
$cover_component = 'groups';
} elseif ('user' !== $object) {
$cover_component = apply_filters('bp_attachments_cover_image_ui_component', $cover_component);
}
// Get cover image advised dimensions
//.........这里部分代码省略.........
示例4: test_bp_sort_by_key_num_should_respect_0
/**
* @group bp_sort_by_key
*/
public function test_bp_sort_by_key_num_should_respect_0()
{
$items = array(array('foo' => 'bar', 'value' => 2), array('foo' => 'bar', 'value' => 0), array('foo' => 'bar', 'value' => 4));
$expected = array(array('foo' => 'bar', 'value' => 0), array('foo' => 'bar', 'value' => 2), array('foo' => 'bar', 'value' => 4));
$this->assertEquals($expected, bp_sort_by_key($items, 'value', 'num'));
}
示例5: bp_activity_get_actions
/**
* Get all components' activity actions, sorted by their position attribute.
*
* @since 2.2.0
*
* @return object Actions ordered by their position.
*/
function bp_activity_get_actions()
{
$bp = buddypress();
$post_types = bp_activity_get_post_types_tracking_args();
// Create the actions for the post types, if they haven't already been created.
if (!empty($post_types)) {
foreach ($post_types as $post_type) {
if (isset($bp->activity->actions->{$post_type->component_id}->{$post_type->action_id})) {
continue;
}
bp_activity_set_action($post_type->component_id, $post_type->action_id, $post_type->admin_filter, $post_type->format_callback, $post_type->front_filter, $post_type->contexts, $post_type->position);
}
}
// Sort the actions by their position within each component.
foreach ($bp->activity->actions as $component => $actions) {
$actions = (array) $actions;
$temp = bp_sort_by_key($actions, 'position', 'num');
// Restore keys.
$bp->activity->actions->{$component} = new stdClass();
foreach ($temp as $key_ordered) {
$bp->activity->actions->{$component}->{$key_ordered['key']} = $key_ordered;
}
}
return $bp->activity->actions;
}
示例6: setup_admin_bar
/**
* Set up the component entries in the WordPress Admin Bar.
*
* @since 1.5.0
*
* @see WP_Admin_Bar::add_menu() for a description of the syntax
* required by each item in the $wp_admin_nav parameter array.
* @global object $wp_admin_bar
*
* @param array $wp_admin_nav An array of nav item arguments. Each item in this parameter
* array is passed to {@link WP_Admin_Bar::add_menu()}.
* See that method for a description of the required syntax for
* each item.
*/
public function setup_admin_bar($wp_admin_nav = array())
{
// Bail if this is an ajax request.
if (defined('DOING_AJAX')) {
return;
}
// Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false.
if (!bp_use_wp_admin_bar()) {
return;
}
/**
* Filters the admin navigation passed into setup_admin_bar.
*
* This is a dynamic hook that is based on the component string ID.
*
* @since 1.9.0
*
* @param array $wp_admin_nav Array of navigation items to add.
*/
$wp_admin_nav = apply_filters('bp_' . $this->id . '_admin_nav', $wp_admin_nav);
// Do we have Toolbar menus to add?
if (!empty($wp_admin_nav)) {
// Fill in position if one wasn't passed for backpat.
$pos = 0;
$not_set_pos = 1;
foreach ($wp_admin_nav as $key => $nav) {
if (!isset($nav['position'])) {
$wp_admin_nav[$key]['position'] = $pos + $not_set_pos;
if (9 !== $not_set_pos) {
++$not_set_pos;
}
} else {
$pos = $nav['position'];
// Reset not set pos to 1
if ($pos % 10 === 0) {
$not_set_pos = 1;
}
}
}
// Sort admin nav by position.
$wp_admin_nav = bp_sort_by_key($wp_admin_nav, 'position', 'num');
// Set this objects menus.
$this->admin_menu = $wp_admin_nav;
// Define the WordPress global.
global $wp_admin_bar;
// Add each admin menu.
foreach ($this->admin_menu as $admin_menu) {
$wp_admin_bar->add_menu($admin_menu);
}
}
/**
* Fires at the end of the setup_admin_bar method inside BP_Component.
*
* This is a dynamic hook that is based on the component string ID.
*
* @since 1.5.0
*/
do_action('bp_' . $this->id . '_setup_admin_bar');
}
示例7: get_friendships
/**
* Get the friendships for a given user.
*
* @since 2.6.0
*
* @param int $user_id ID of the user whose friends are being retrieved.
* @param array $args {
* Optional. Filter parameters.
* @type int $id ID of specific friendship to retrieve.
* @type int $initiator_user_id ID of friendship initiator.
* @type int $friend_user_id ID of specific friendship to retrieve.
* @type int $is_confirmed Whether the friendship has been accepted.
* @type int $is_limited Whether the friendship is limited.
* @type string $order_by Column name to order by.
* @type string $sort_order ASC or DESC. Default DESC.
* }
* @param string $operator Optional. Operator to use in `wp_list_filter()`.
*
* @return array $friendships Array of friendship objects.
*/
public static function get_friendships($user_id, $args = array(), $operator = 'AND')
{
if (empty($user_id)) {
$user_id = bp_loggedin_user_id();
}
$r = bp_parse_args($args, array('id' => null, 'initiator_user_id' => null, 'friend_user_id' => null, 'is_confirmed' => null, 'is_limited' => null, 'order_by' => 'date_created', 'sort_order' => 'DESC', 'page' => null, 'per_page' => null), 'bp_get_user_friendships');
// First, we get all friendships that involve the user.
$friendship_ids = wp_cache_get($user_id, 'bp_friends_friendships_for_user');
if (false === $friendship_ids) {
$friendship_ids = self::get_friendship_ids_for_user($user_id);
wp_cache_set($user_id, $friendship_ids, 'bp_friends_friendships_for_user');
}
// Prime the membership cache.
$uncached_friendship_ids = bp_get_non_cached_ids($friendship_ids, 'bp_friends_friendships');
if (!empty($uncached_friendship_ids)) {
$uncached_friendships = self::get_friendships_by_id($uncached_friendship_ids);
foreach ($uncached_friendships as $uncached_friendship) {
wp_cache_set($uncached_friendship->id, $uncached_friendship, 'bp_friends_friendships');
}
}
// Assemble filter array.
$filters = wp_array_slice_assoc($r, array('id', 'initiator_user_id', 'friend_user_id', 'is_confirmed', 'is_limited'));
foreach ($filters as $filter_name => $filter_value) {
if (is_null($filter_value)) {
unset($filters[$filter_name]);
}
}
// Populate friendship array from cache, and normalize.
$friendships = array();
$int_keys = array('id', 'initiator_user_id', 'friend_user_id');
$bool_keys = array('is_confirmed', 'is_limited');
foreach ($friendship_ids as $friendship_id) {
// Create a limited BP_Friends_Friendship object (don't fetch the user details).
$friendship = new BP_Friends_Friendship($friendship_id, false, false);
// Sanity check.
if (!isset($friendship->id)) {
continue;
}
// Integer values.
foreach ($int_keys as $index) {
$friendship->{$index} = intval($friendship->{$index});
}
// Boolean values.
foreach ($bool_keys as $index) {
$friendship->{$index} = (bool) $friendship->{$index};
}
// We need to support the same operators as wp_list_filter().
if ('OR' == $operator || 'NOT' == $operator) {
$matched = 0;
foreach ($filters as $filter_name => $filter_value) {
if (isset($friendship->{$filter_name}) && $filter_value == $friendship->{$filter_name}) {
$matched++;
}
}
if ('OR' == $operator && $matched > 0 || 'NOT' == $operator && 0 == $matched) {
$friendships[$friendship->id] = $friendship;
}
} else {
/*
* This is the more typical 'AND' style of filter.
* If any of the filters miss, we move on.
*/
foreach ($filters as $filter_name => $filter_value) {
if (!isset($friendship->{$filter_name}) || $filter_value != $friendship->{$filter_name}) {
continue 2;
}
}
$friendships[$friendship->id] = $friendship;
}
}
// Sort the results on a column name.
if (in_array($r['order_by'], array('id', 'initiator_user_id', 'friend_user_id'))) {
$friendships = bp_sort_by_key($friendships, $r['order_by'], 'num', true);
}
// Adjust the sort direction of the results.
if ('ASC' === strtoupper($r['sort_order'])) {
// `true` to preserve keys.
$friendships = array_reverse($friendships, true);
}
// Paginate the results.
//.........这里部分代码省略.........
示例8: bp_get_user_groups
/**
* Get a list of groups of which the specified user is a member.
*
* Get a list of the groups to which this member belongs,
* filtered by group membership status and role.
* Usage examples: Used with no arguments specified,
*
* bp_get_user_groups( bp_loggedin_user_id() );
*
* returns an array of the groups in which the logged-in user
* is an unpromoted member. To fetch an array of all groups that
* the current user belongs to, in any membership role,
* member, moderator or administrator, use
*
* bp_get_user_groups( $user_id, array(
* 'is_admin' => null,
* 'is_mod' => null,
* ) );
*
* @since 2.6.0
*
* @param int $user_id ID of the user.
* @param array $args {
* Array of optional args.
* @param bool|null $is_confirmed Whether to return only confirmed memberships. Pass `null` to disable this
* filter. Default: true.
* @param bool|null $is_banned Whether to return only banned memberships. Pass `null` to disable this filter.
* Default: false.
* @param bool|null $is_admin Whether to return only admin memberships. Pass `null` to disable this filter.
* Default: false.
* @param bool|null $is_mod Whether to return only mod memberships. Pass `null` to disable this filter.
* Default: false.
* @param bool|null $invite_sent Whether to return only memberships with 'invite_sent'. Pass `null` to disable
* this filter. Default: false.
* @param string $orderby Field to order by. Accepts 'id' (membership ID), 'group_id', 'date_modified'.
* Default: 'group_id'.
* @param string $order Sort order. Accepts 'ASC' or 'DESC'. Default: 'ASC'.
* }
* @return array Array of matching group memberships, keyed by group ID.
*/
function bp_get_user_groups($user_id, $args = array())
{
$r = bp_parse_args($args, array('is_confirmed' => true, 'is_banned' => false, 'is_admin' => false, 'is_mod' => false, 'invite_sent' => null, 'orderby' => 'group_id', 'order' => 'ASC'), 'get_user_groups');
$user_id = intval($user_id);
$membership_ids = wp_cache_get($user_id, 'bp_groups_memberships_for_user');
if (false === $membership_ids) {
$membership_ids = BP_Groups_Member::get_membership_ids_for_user($user_id);
wp_cache_set($user_id, $membership_ids, 'bp_groups_memberships_for_user');
}
// Prime the membership cache.
$uncached_membership_ids = bp_get_non_cached_ids($membership_ids, 'bp_groups_memberships');
if (!empty($uncached_membership_ids)) {
$uncached_memberships = BP_Groups_Member::get_memberships_by_id($uncached_membership_ids);
foreach ($uncached_memberships as $uncached_membership) {
wp_cache_set($uncached_membership->id, $uncached_membership, 'bp_groups_memberships');
}
}
// Assemble filter array for use in `wp_list_filter()`.
$filters = wp_array_slice_assoc($r, array('is_confirmed', 'is_banned', 'is_admin', 'is_mod', 'invite_sent'));
foreach ($filters as $filter_name => $filter_value) {
if (is_null($filter_value)) {
unset($filters[$filter_name]);
}
}
// Populate group membership array from cache, and normalize.
$groups = array();
$int_keys = array('id', 'group_id', 'user_id', 'inviter_id');
$bool_keys = array('is_admin', 'is_mod', 'is_confirmed', 'is_banned', 'invite_sent');
foreach ($membership_ids as $membership_id) {
$membership = wp_cache_get($membership_id, 'bp_groups_memberships');
// Sanity check.
if (!isset($membership->group_id)) {
continue;
}
// Integer values.
foreach ($int_keys as $index) {
$membership->{$index} = intval($membership->{$index});
}
// Boolean values.
foreach ($bool_keys as $index) {
$membership->{$index} = (bool) $membership->{$index};
}
foreach ($filters as $filter_name => $filter_value) {
if (!isset($membership->{$filter_name}) || $filter_value != $membership->{$filter_name}) {
continue 2;
}
}
$group_id = (int) $membership->group_id;
$groups[$group_id] = $membership;
}
// By default, results are ordered by membership id.
if ('group_id' === $r['orderby']) {
ksort($groups);
} elseif (in_array($r['orderby'], array('id', 'date_modified'))) {
$groups = bp_sort_by_key($groups, $r['orderby']);
}
// By default, results are ordered ASC.
if ('DESC' === strtoupper($r['order'])) {
// `true` to preserve keys.
$groups = array_reverse($groups, true);
//.........这里部分代码省略.........
示例9: rendez_vous_enqueue_editor
/**
* Enqueues the Rendez Vous editor scripts, css, settings and strings
*
* Inspired by wp_enqueue_media()
*
* @package Rendez Vous
* @subpackage Editor
* @since Rendez Vous (1.0.0)
*/
function rendez_vous_enqueue_editor($args = array())
{
// Enqueue me just once per page, please.
if (did_action('rendez_vous_enqueue_editor')) {
return;
}
$defaults = array('post' => null, 'user_id' => bp_loggedin_user_id(), 'callback' => null, 'group_id' => null);
$args = wp_parse_args($args, $defaults);
// We're going to pass the old thickbox media tabs to `media_upload_tabs`
// to ensure plugins will work. We will then unset those tabs.
$tabs = array('type' => '', 'type_url' => '', 'gallery' => '', 'library' => '');
$tabs = apply_filters('media_upload_tabs', $tabs);
unset($tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library']);
$props = array('link' => bp_get_option('image_default_link_type'), 'align' => bp_get_option('image_default_align'), 'size' => bp_get_option('image_default_size'));
$settings = array('tabs' => $tabs, 'tabUrl' => esc_url(add_query_arg(array('chromeless' => true), admin_url('admin-ajax.php'))), 'mimeTypes' => false, 'captions' => !apply_filters('disable_captions', ''), 'nonce' => array('sendToEditor' => wp_create_nonce('media-send-to-editor'), 'rendezvous' => wp_create_nonce('rendez-vous-editor')), 'post' => array('id' => 0), 'defaultProps' => $props, 'embedExts' => false);
$post = $hier = null;
$settings['user'] = intval($args['user_id']);
$settings['group_id'] = intval($args['group_id']);
if (!empty($args['callback'])) {
$settings['callback'] = esc_url($args['callback']);
}
// Do we have member types ?
$rendez_vous_member_types = array();
$member_types = bp_get_member_types(array(), 'objects');
if (!empty($member_types) && is_array($member_types)) {
$rendez_vous_member_types['rdvMemberTypesAll'] = esc_html__('All member types', 'rendez-vous');
foreach ($member_types as $type_key => $type) {
$rendez_vous_member_types['rdvMemberTypes'][] = array('type' => $type_key, 'text' => esc_html($type->labels['singular_name']));
}
}
if (!empty($rendez_vous_member_types)) {
$settings = array_merge($settings, $rendez_vous_member_types);
}
$strings = array('url' => __('URL', 'rendez-vous'), 'addMedia' => __('Add Media', 'rendez-vous'), 'search' => __('Search', 'rendez-vous'), 'select' => __('Select', 'rendez-vous'), 'cancel' => __('Cancel', 'rendez-vous'), 'selected' => __('%d selected', 'rendez-vous'), 'dragInfo' => __('Drag and drop to reorder images.', 'rendez-vous'), 'uploadFilesTitle' => __('Upload Files', 'rendez-vous'), 'uploadImagesTitle' => __('Upload Images', 'rendez-vous'), 'mediaLibraryTitle' => __('Media Library', 'rendez-vous'), 'insertMediaTitle' => __('Insert Media', 'rendez-vous'), 'createNewGallery' => __('Create a new gallery', 'rendez-vous'), 'returnToLibrary' => __('← Return to library', 'rendez-vous'), 'allMediaItems' => __('All media items', 'rendez-vous'), 'noItemsFound' => __('No items found.', 'rendez-vous'), 'insertIntoPost' => $hier ? __('Insert into page', 'rendez-vous') : __('Insert into post', 'rendez-vous'), 'uploadedToThisPost' => $hier ? __('Uploaded to this page', 'rendez-vous') : __('Uploaded to this post', 'rendez-vous'), 'warnDelete' => __("You are about to permanently delete this item.\n 'Cancel' to stop, 'OK' to delete.", 'rendez-vous'), 'insertFromUrlTitle' => __('Insert from URL', 'rendez-vous'), 'setFeaturedImageTitle' => __('Set Featured Image', 'rendez-vous'), 'setFeaturedImage' => __('Set featured image', 'rendez-vous'), 'createGalleryTitle' => __('Create Gallery', 'rendez-vous'), 'editGalleryTitle' => __('Edit Gallery', 'rendez-vous'), 'cancelGalleryTitle' => __('← Cancel Gallery', 'rendez-vous'), 'insertGallery' => __('Insert gallery', 'rendez-vous'), 'updateGallery' => __('Update gallery', 'rendez-vous'), 'addToGallery' => __('Add to gallery', 'rendez-vous'), 'addToGalleryTitle' => __('Add to Gallery', 'rendez-vous'), 'reverseOrder' => __('Reverse order', 'rendez-vous'));
$rendez_vous_strings = apply_filters('rendez_vous_view_strings', array('rdvMainTitle' => _x('Rendez-vous', 'RendezVous editor main title', 'rendez-vous'), 'whatTab' => _x('What?', 'RendezVous editor tab what name', 'rendez-vous'), 'whenTab' => _x('When?', 'RendezVous editor tab when name', 'rendez-vous'), 'whoTab' => _x('Who?', 'RendezVous editor tab who name', 'rendez-vous'), 'rdvInsertBtn' => __('Add to invites', 'rendez-vous'), 'rdvNextBtn' => __('Next', 'rendez-vous'), 'rdvPrevBtn' => __('Prev', 'rendez-vous'), 'rdvSrcPlaceHolder' => __('Search', 'rendez-vous'), 'invited' => __('%d to invite', 'rendez-vous'), 'removeInviteBtn' => __('Remove Invite', 'rendez-vous'), 'saveButton' => __('Save Rendez-Vous', 'rendez-vous')));
// Use the filter at your own risks!
$rendez_vous_fields = array('what' => apply_filters('rendez_vous_editor_core_fields', array(array('id' => 'title', 'order' => 0, 'type' => 'text', 'placeholder' => esc_html__('What is this about ?', 'rendez-vous'), 'label' => esc_html__('Title', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => 'required'), array('id' => 'venue', 'order' => 10, 'type' => 'text', 'placeholder' => esc_html__('Where ?', 'rendez-vous'), 'label' => esc_html__('Venue', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => ''), array('id' => 'description', 'order' => 20, 'type' => 'textarea', 'placeholder' => esc_html__('Some details about this rendez-vous ?', 'rendez-vous'), 'label' => esc_html__('Description', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => ''), array('id' => 'duration', 'order' => 30, 'type' => 'duree', 'placeholder' => '00:00', 'label' => esc_html__('Duration', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => 'required'), array('id' => 'privacy', 'order' => 40, 'type' => 'checkbox', 'placeholder' => esc_html__('Restrict to the selected members of the Who? tab', 'rendez-vous'), 'label' => esc_html__('Access', 'rendez-vous'), 'value' => '0', 'tab' => 'what', 'class' => ''), array('id' => 'utcoffset', 'order' => 50, 'type' => 'timezone', 'placeholder' => '', 'label' => '', 'value' => '', 'tab' => 'what', 'class' => ''))));
// Do we have rendez-vous types ?
if (rendez_vous_has_types()) {
$rendez_vous_types_choices = array();
$rendez_vous_types_placeholder = array();
foreach (rendez_vous()->types as $rendez_vous_type) {
$rendez_vous_types_choices[] = $rendez_vous_type->term_id;
$rendez_vous_types_placeholder[] = $rendez_vous_type->name;
}
// Set the rendez-voys types field arg
$rendez_vous_types_args = array('id' => 'type', 'order' => 15, 'type' => 'selectbox', 'placeholder' => $rendez_vous_types_placeholder, 'label' => esc_html__('Type', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => '', 'choices' => $rendez_vous_types_choices);
// Merge with other rendez-vous fields
$rendez_vous_fields['what'] = array_merge($rendez_vous_fields['what'], array($rendez_vous_types_args));
}
/**
* Use 'rendez_vous_editor_extra_fields' to add custom fields, you should be able
* to save them using the 'rendez_vous_after_saved' action.
*/
$rendez_vous_extra_fields = apply_filters('rendez_vous_editor_extra_fields', array());
$rendez_vous_add_fields = array();
if (!empty($rendez_vous_extra_fields) && is_array($rendez_vous_extra_fields)) {
// Some id are restricted to the plugin usage
$restricted = array('title' => true, 'venue' => true, 'type' => true, 'description' => true, 'duration' => true, 'privacy' => true, 'utcoffset' => true);
foreach ($rendez_vous_extra_fields as $rendez_vous_extra_field) {
// The id is required and some ids are restricted.
if (empty($rendez_vous_extra_field['id']) || !empty($restricted[$rendez_vous_extra_field['id']])) {
continue;
}
// Make sure all needed arguments have default values
$rendez_vous_add_fields[] = wp_parse_args($rendez_vous_extra_field, array('id' => '', 'order' => 60, 'type' => 'text', 'placeholder' => '', 'label' => '', 'value' => '', 'tab' => 'what', 'class' => ''));
}
}
if (!empty($rendez_vous_add_fields)) {
$rendez_vous_fields['what'] = array_merge($rendez_vous_fields['what'], $rendez_vous_add_fields);
}
// Sort by the order key
$rendez_vous_fields['what'] = bp_sort_by_key($rendez_vous_fields['what'], 'order', 'num');
$rendez_vous_date_strings = array('daynames' => array(esc_html__('Sunday', 'rendez-vous'), esc_html__('Monday', 'rendez-vous'), esc_html__('Tuesday', 'rendez-vous'), esc_html__('Wednesday', 'rendez-vous'), esc_html__('Thursday', 'rendez-vous'), esc_html__('Friday', 'rendez-vous'), esc_html__('Saturday', 'rendez-vous')), 'daynamesmin' => array(esc_html__('Su', 'rendez-vous'), esc_html__('Mo', 'rendez-vous'), esc_html__('Tu', 'rendez-vous'), esc_html__('We', 'rendez-vous'), esc_html__('Th', 'rendez-vous'), esc_html__('Fr', 'rendez-vous'), esc_html__('Sa', 'rendez-vous')), 'monthnames' => array(esc_html__('January', 'rendez-vous'), esc_html__('February', 'rendez-vous'), esc_html__('March', 'rendez-vous'), esc_html__('April', 'rendez-vous'), esc_html__('May', 'rendez-vous'), esc_html__('June', 'rendez-vous'), esc_html__('July', 'rendez-vous'), esc_html__('August', 'rendez-vous'), esc_html__('September', 'rendez-vous'), esc_html__('October', 'rendez-vous'), esc_html__('November', 'rendez-vous'), esc_html__('December', 'rendez-vous')), 'format' => _x('mm/dd/yy', 'rendez-vous date format', 'rendez-vous'), 'firstday' => intval(bp_get_option('start_of_week', 0)), 'alert' => esc_html__('You already selected this date', 'rendez-vous'));
$settings = apply_filters('media_view_settings', $settings, $post);
$strings = apply_filters('media_view_strings', $strings, $post);
$strings = array_merge($strings, array('rendez_vous_strings' => $rendez_vous_strings, 'rendez_vous_fields' => $rendez_vous_fields, 'rendez_vous_date_strings' => $rendez_vous_date_strings));
$strings['settings'] = $settings;
wp_localize_script('rendez-vous-media-views', '_wpMediaViewsL10n', $strings);
wp_enqueue_script('rendez-vous-modal');
wp_enqueue_style('rendez-vous-modal-style');
rendez_vous_plupload_settings();
require_once ABSPATH . WPINC . '/media-template.php';
add_action('admin_footer', 'wp_print_media_templates');
add_action('wp_footer', 'wp_print_media_templates');
do_action('rendez_vous_enqueue_editor');
}
示例10: test_bp_sort_by_key_num_should_respect_0_preserve_keys
/**
* @group bp_sort_by_key
*/
public function test_bp_sort_by_key_num_should_respect_0_preserve_keys()
{
$items = array('s' => array('foo' => 'bar', 'value' => 2), 't' => array('foo' => 'bar', 'value' => 0), 'u' => array('foo' => 'bar', 'value' => 4));
$expected = array('t' => array('foo' => 'bar', 'value' => 0), 's' => array('foo' => 'bar', 'value' => 2), 'u' => array('foo' => 'bar', 'value' => 4));
$this->assertEquals($expected, bp_sort_by_key($items, 'value', 'num', true));
}