当前位置: 首页>>代码示例>>PHP>>正文


PHP bp_get_member_types函数代码示例

本文整理汇总了PHP中bp_get_member_types函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_get_member_types函数的具体用法?PHP bp_get_member_types怎么用?PHP bp_get_member_types使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了bp_get_member_types函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add_change_member_type_selectbox

    public function add_change_member_type_selectbox($where = '')
    {
        //Since wp will not pass whether it is for top/bottom, let us use static var to deremine position
        static $position;
        if (!isset($position)) {
            $position = 'top';
            //assume it will be called from top
        } else {
            $position = 'bottom';
        }
        //only admin/super admin
        if (!current_user_can('edit_users')) {
            return;
        }
        $member_types = bp_get_member_types(array(), 'objects');
        if (empty($member_types)) {
            return;
        }
        $output = '<div class="alignright" id="bp-member-type-change-action_' . $position . '">' . '<label for="new_member_type_' . $position . '" class="screen-reader-text">' . __('Change member type to…', 'bp-member-type-generator') . '</label>
					<select id="new_member_type_' . $position . '" name="new_member_type_' . $position . '">
					<option value="">' . __('Change member type to…', 'bp-member-type-generator') . '</option>';
        foreach ($member_types as $key => $type) {
            $output .= sprintf('<option value="%s">%s</option>', esc_attr($key), $type->labels['singular_name']);
        }
        $output .= '</select>';
        $output .= get_submit_button(__('Change', 'bp-member-type-generator'), 'secondary', 'change-member-type', false);
        $output .= '</div>';
        echo $output;
    }
开发者ID:buddydev,项目名称:bp-member-type-generator,代码行数:29,代码来源:user-helper.php

示例2: cfbgr_migrate_xprofile_as_member_types

function cfbgr_migrate_xprofile_as_member_types()
{
    global $wpdb;
    $buddypress = buddypress();
    // Description of this tool, displayed to the user
    $statement = __('Migrating/Resetting xProfile data as member types: %s', 'buddypress-group-restrictions');
    // Default to failure text
    $result = __('No xProfile data needs to be migrated or reset.', 'buddypress-group-restrictions');
    // Default to unrepaired
    $repair = 0;
    $field = (int) bp_get_option('cfbgr_xfield_id', 0);
    if (empty($field)) {
        return array(0, sprintf($statement, $result));
    }
    $member_types = bp_get_member_types();
    // Walk through all users on the site
    $user_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->users}");
    foreach ($user_ids as $user_id) {
        $value = sanitize_key(xprofile_get_field_data($field, $user_id));
        // Do we have a matching member type ?
        if (isset($member_types[$value])) {
            // Set member types if empty or different
            if ($value !== bp_get_member_type($user_id)) {
                bp_set_member_type($user_id, $value);
                $repair += 1;
            }
        }
    }
    $result = sprintf(__('%d migrated or reset', 'buddypress-group-restrictions'), $repair);
    // All done!
    return array(0, sprintf($statement, $result));
}
开发者ID:WeFoster,项目名称:buddypress-group-restrictions,代码行数:32,代码来源:migrate.php

示例3: field_options

 public function field_options($field)
 {
     if ($field->type != 'membertype') {
         return $field;
     }
     $field->display = 'selectbox';
     $field->values = isset($_REQUEST[$field->code]) ? (array) $_REQUEST[$field->code] : array();
     $field->options = array();
     $registered_member_types = bp_get_member_types(null, 'object');
     foreach ($registered_member_types as $type_name => $member_type_object) {
         $field->options[$type_name] = $member_type_object->labels['singular_name'];
     }
     return $field;
 }
开发者ID:buddydev,项目名称:bp-xprofile-member-type-field,代码行数:14,代码来源:bp-profile-search-helper.php

示例4: user_admin_member_type_metabox

        /**
         * Render the Member Type metabox.
         *
         * @since 2.2.0
         *
         * @param WP_User|null $user The WP_User object to be edited.
         */
        public function user_admin_member_type_metabox($user = null)
        {
            // Bail if no user ID.
            if (empty($user->ID)) {
                return;
            }
            $types = bp_get_member_types(array(), 'objects');
            $current_type = bp_get_member_type($user->ID);
            ?>

		<label for="bp-members-profile-member-type" class="screen-reader-text"><?php 
            esc_html_e('Select member type', 'buddypress');
            ?>
</label>
		<select name="bp-members-profile-member-type" id="bp-members-profile-member-type">
			<option value="" <?php 
            selected('', $current_type);
            ?>
><?php 
            /* translators: no option picked in select box */
            esc_attr_e('----', 'buddypress');
            ?>
</option>
			<?php 
            foreach ($types as $type) {
                ?>
				<option value="<?php 
                echo esc_attr($type->name);
                ?>
" <?php 
                selected($type->name, $current_type);
                ?>
><?php 
                echo esc_html($type->labels['singular_name']);
                ?>
</option>
			<?php 
            }
            ?>
		</select>

		<?php 
            wp_nonce_field('bp-member-type-change-' . $user->ID, 'bp-member-type-nonce');
        }
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:51,代码来源:class-bp-members-admin.php

示例5: bp_get_member_type_object

/**
 * Retrieve a member type object by name.
 *
 * @since 2.2.0
 *
 * @param string $member_type The name of the member type.
 * @return object A member type object.
 */
function bp_get_member_type_object($member_type)
{
    $types = bp_get_member_types(array(), 'objects');
    if (empty($types[$member_type])) {
        return null;
    }
    return $types[$member_type];
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:16,代码来源:bp-members-functions.php

示例6: bp_core_set_uri_globals


//.........这里部分代码省略.........
        return false;
    }
    $wp_rewrite->use_verbose_page_rules = false;
    // Find the offset. With $root_profile set, we fudge the offset down so later parsing works.
    $slug = !empty($match) ? explode('/', $match->slug) : '';
    $uri_offset = empty($root_profile) ? 0 : -1;
    // Rejig the offset.
    if (!empty($slug) && 1 < count($slug)) {
        // Only offset if not on a root profile. Fixes issue when Members page is nested.
        if (false === $root_profile) {
            array_pop($slug);
            $uri_offset = count($slug);
        }
    }
    // Global the unfiltered offset to use in bp_core_load_template().
    // To avoid PHP warnings in bp_core_load_template(), it must always be >= 0.
    $bp->unfiltered_uri_offset = $uri_offset >= 0 ? $uri_offset : 0;
    // We have an exact match.
    if (isset($match->key)) {
        // Set current component to matched key.
        $bp->current_component = $match->key;
        // If members component, do more work to find the actual component.
        if ('members' == $match->key) {
            $after_member_slug = false;
            if (!empty($bp_uri[$uri_offset + 1])) {
                $after_member_slug = $bp_uri[$uri_offset + 1];
            }
            // Are we viewing a specific user?
            if ($after_member_slug) {
                // If root profile, we've already queried for the user.
                if ($root_profile instanceof WP_User) {
                    $bp->displayed_user->id = $root_profile->ID;
                    // Switch the displayed_user based on compatibility mode.
                } elseif (bp_is_username_compatibility_mode()) {
                    $bp->displayed_user->id = (int) bp_core_get_userid(urldecode($after_member_slug));
                } else {
                    $bp->displayed_user->id = (int) bp_core_get_userid_from_nicename($after_member_slug);
                }
            }
            // Is this a member type directory?
            if (!bp_displayed_user_id() && $after_member_slug === apply_filters('bp_members_member_type_base', _x('type', 'member type URL base', 'buddypress')) && !empty($bp_uri[$uri_offset + 2])) {
                $matched_types = bp_get_member_types(array('has_directory' => true, 'directory_slug' => $bp_uri[$uri_offset + 2]));
                if (!empty($matched_types)) {
                    $bp->current_member_type = reset($matched_types);
                    unset($bp_uri[$uri_offset + 1]);
                }
            }
            // If the slug matches neither a member type nor a specific member, 404.
            if (!bp_displayed_user_id() && !bp_get_current_member_type() && $after_member_slug) {
                // Prevent components from loading their templates.
                $bp->current_component = '';
                bp_do_404();
                return;
            }
            // If the displayed user is marked as a spammer, 404 (unless logged-in user is a super admin).
            if (bp_displayed_user_id() && bp_is_user_spammer(bp_displayed_user_id())) {
                if (bp_current_user_can('bp_moderate')) {
                    bp_core_add_message(__('This user has been marked as a spammer. Only site admins can view this profile.', 'buddypress'), 'warning');
                } else {
                    bp_do_404();
                    return;
                }
            }
            // Bump the offset.
            if (bp_displayed_user_id()) {
                if (isset($bp_uri[$uri_offset + 2])) {
                    $bp_uri = array_merge(array(), array_slice($bp_uri, $uri_offset + 2));
                    $bp->current_component = $bp_uri[0];
                    // No component, so default will be picked later.
                } else {
                    $bp_uri = array_merge(array(), array_slice($bp_uri, $uri_offset + 2));
                    $bp->current_component = '';
                }
                // Reset the offset.
                $uri_offset = 0;
            }
        }
    }
    // Determine the current action.
    $current_action = isset($bp_uri[$uri_offset + 1]) ? $bp_uri[$uri_offset + 1] : '';
    /*
     * If a BuddyPress directory is set to the WP front page, URLs like example.com/members/?s=foo
     * shouldn't interfere with blog searches.
     */
    if (empty($current_action) && !empty($_GET['s']) && 'page' == get_option('show_on_front') && !empty($match->id)) {
        $page_on_front = (int) get_option('page_on_front');
        if ((int) $match->id === $page_on_front) {
            $bp->current_component = '';
            return false;
        }
    }
    $bp->current_action = $current_action;
    // Slice the rest of the $bp_uri array and reset offset.
    $bp_uri = array_slice($bp_uri, $uri_offset + 2);
    $uri_offset = 0;
    // Set the entire URI as the action variables, we will unset the current_component and action in a second.
    $bp->action_variables = $bp_uri;
    // Reset the keys by merging with an empty array.
    $bp->action_variables = array_merge(array(), $bp->action_variables);
}
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:101,代码来源:bp-core-catchuri.php

示例7: _e

</h1>
                <p><?php 
_e('Import your existing member types, that were created <strong>Manually with Code</strong> or from another <strong>Plugin</strong> ( needs to be active )', 'bp-member-types');
?>
</p><br/>

                <input type="submit" value="Run Migration" id="bmt-import-submit" name="bmt-import-submit" class="button-primary">
            </div>
        </form>
    </div>
</div>
<br />

<?php 
if (isset($_POST['bmt-import-submit'])) {
    $registered_member_types = bp_get_member_types();
    $created_member_types = bmt_get_active_member_types();
    $active_member_types = array();
    foreach ($created_member_types as $created_member_type) {
        $name = strtolower(get_post_meta($created_member_type, '_bp_member_type_label_singular_name', true));
        $name = str_replace(array(' ', ','), array('-', '-'), $name);
        array_push($active_member_types, $name);
    }
    $registered_member_types = array_diff($registered_member_types, $active_member_types);
    if (empty($registered_member_types)) {
        ?>
            <div class="wrap">
                <div class="error notice " id="message"><p><?php 
        _e('Nothing to import');
        ?>
</p></div>
开发者ID:tvolmari,项目名称:hammydowns,代码行数:31,代码来源:bmt-import.php

示例8: xprofile_admin_field

/**
 * Handles the WYSIWYG display of each profile field on the edit screen.
 *
 * @since 1.5.0
 *
 * @param object $admin_field Admin field.
 * @param object $admin_group Admin group object.
 * @param string $class       Classes to append to output.
 */
function xprofile_admin_field($admin_field, $admin_group, $class = '')
{
    global $field;
    $field = $admin_field;
    ?>

	<fieldset id="draggable_field_<?php 
    echo esc_attr($field->id);
    ?>
"class="sortable<?php 
    echo ' ' . $field->type;
    if (!empty($class)) {
        echo ' ' . $class;
    }
    ?>
">
		<legend>
			<span>
				<?php 
    bp_the_profile_field_name();
    ?>

				<?php 
    if (empty($field->can_delete)) {
        esc_html_e('(Primary)', 'buddypress');
    }
    ?>
				<?php 
    bp_the_profile_field_required_label();
    ?>
				<?php 
    if (bp_xprofile_get_meta($field->id, 'field', 'signup_position')) {
        esc_html_e('(Sign-up)', 'buddypress');
    }
    ?>
				<?php 
    if (bp_get_member_types()) {
        echo $field->get_member_type_label();
    }
    ?>

				<?php 
    /**
     * Fires at end of legend above the name field in base xprofile group.
     *
     * @since 2.2.0
     *
     * @param BP_XProfile_Field $field Current BP_XProfile_Field
     *                                 object being rendered.
     */
    do_action('xprofile_admin_field_name_legend', $field);
    ?>
			</span>
		</legend>
		<div class="field-wrapper">

			<?php 
    if (in_array($field->type, array_keys(bp_xprofile_get_field_types()))) {
        $field_type = bp_xprofile_create_field_type($field->type);
        $field_type->admin_field_html();
    } else {
        /**
         * Fires after the input if the current field is not in default field types.
         *
         * @since 1.5.0
         *
         * @param BP_XProfile_Field $field Current BP_XProfile_Field
         *                                 object being rendered.
         * @param int               $value Integer 1.
         */
        do_action('xprofile_admin_field', $field, 1);
    }
    ?>

			<?php 
    if ($field->description) {
        ?>

				<p class="description"><?php 
        echo esc_attr($field->description);
        ?>
</p>

			<?php 
    }
    ?>

			<div class="actions">
				<a class="button edit" href="users.php?page=bp-profile-setup&amp;group_id=<?php 
    echo esc_attr($admin_group->id);
    ?>
//.........这里部分代码省略.........
开发者ID:boonebgorges,项目名称:BuddyPress-1,代码行数:101,代码来源:bp-xprofile-admin.php

示例9: get_member_types

 /**
  * Get member types as associative array
  * 
  * @staticvar array $member_types
  * @return array
  */
 private static function get_member_types()
 {
     static $member_types = null;
     if (isset($member_types)) {
         return $member_types;
     }
     $registered_member_types = bp_get_member_types(null, 'object');
     if (empty($registered_member_types)) {
         $member_types = $registered_member_types;
         return $member_types;
     }
     foreach ($registered_member_types as $type_name => $member_type_object) {
         $member_types[$type_name] = $member_type_object->labels['singular_name'];
     }
     return $member_types;
 }
开发者ID:buddydev,项目名称:bp-xprofile-member-type-field,代码行数:22,代码来源:class-member-type-field.php

示例10: bp_displayed_user_get_front_template

/**
 * Locate a custom user front template if it exists.
 *
 * @since 2.6.0
 *
 * @param  object|null $displayed_user Optional. Falls back to current user if not passed.
 * @return string|bool                 Path to front template on success; boolean false on failure.
 */
function bp_displayed_user_get_front_template($displayed_user = null)
{
    if (!is_object($displayed_user) || empty($displayed_user->id)) {
        $displayed_user = bp_get_displayed_user();
    }
    if (!isset($displayed_user->id)) {
        return false;
    }
    if (isset($displayed_user->front_template)) {
        return $displayed_user->front_template;
    }
    // Init the hierarchy
    $template_names = array('members/single/front-id-' . sanitize_file_name($displayed_user->id) . '.php', 'members/single/front-nicename-' . sanitize_file_name($displayed_user->userdata->user_nicename) . '.php');
    /**
     * Check for member types and add it to the hierarchy
     *
     * Make sure to register your member
     * type using the hook 'bp_register_member_types'
     */
    if (bp_get_member_types()) {
        $displayed_user_member_type = bp_get_member_type($displayed_user->id);
        if (!$displayed_user_member_type) {
            $displayed_user_member_type = 'none';
        }
        $template_names[] = 'members/single/front-member-type-' . sanitize_file_name($displayed_user_member_type) . '.php';
    }
    // Add The generic template to the end of the hierarchy
    $template_names[] = 'members/single/front.php';
    /**
     * Filters the hierarchy of user front templates corresponding to a specific user.
     *
     * @since 2.6.0
     *
     * @param array  $template_names Array of template paths.
     */
    return bp_locate_template(apply_filters('bp_displayed_user_get_front_template', $template_names), false, true);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:45,代码来源:bp-members-template.php

示例11: member_type_metabox

    /**
     * Private method used to output field Member Type metabox.
     *
     * @since 2.4.0
     */
    private function member_type_metabox()
    {
        // The primary field is for all, so bail.
        if (1 === (int) $this->id) {
            return;
        }
        // Bail when no member types are registered.
        if (!($member_types = bp_get_member_types(array(), 'objects'))) {
            return;
        }
        $field_member_types = $this->get_member_types();
        ?>

		<div id="member-types-div" class="postbox">
			<h2><?php 
        _e('Member Types', 'buddypress');
        ?>
</h2>
			<div class="inside">
				<p class="description"><?php 
        _e('This field should be available to:', 'buddypress');
        ?>
</p>

				<ul>
					<?php 
        foreach ($member_types as $member_type) {
            ?>
					<li>
						<label for="member-type-<?php 
            echo $member_type->labels['name'];
            ?>
">
							<input name="member-types[]" id="member-type-<?php 
            echo $member_type->labels['name'];
            ?>
" class="member-type-selector" type="checkbox" value="<?php 
            echo $member_type->name;
            ?>
" <?php 
            checked(in_array($member_type->name, $field_member_types));
            ?>
/>
							<?php 
            echo $member_type->labels['name'];
            ?>
						</label>
					</li>
					<?php 
        }
        ?>

					<li>
						<label for="member-type-none">
							<input name="member-types[]" id="member-type-none" class="member-type-selector" type="checkbox" value="null" <?php 
        checked(in_array('null', $field_member_types));
        ?>
/>
							<?php 
        _e('Users with no member type', 'buddypress');
        ?>
						</label>
					</li>

				</ul>
				<p class="description member-type-none-notice<?php 
        if (!empty($field_member_types)) {
            ?>
 hide<?php 
        }
        ?>
"><?php 
        _e('Unavailable to all members.', 'buddypress');
        ?>
</p>
			</div>

			<input type="hidden" name="has-member-types" value="1" />
		</div>

		<?php 
    }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:87,代码来源:class-bp-xprofile-field.php

示例12: kleo_bp_set_has_members_type_arg

function kleo_bp_set_has_members_type_arg($args)
{
    $member_type = bp_get_current_member_type();
    $member_types = bp_get_member_types(array(), 'names');
    if (isset($args['scope']) && !isset($args['member_type']) && in_array($args['scope'], $member_types)) {
        if ($member_type) {
            unset($args['scope']);
        } else {
            $args['member_type'] = $args['scope'];
        }
    }
    return $args;
}
开发者ID:quyip8818,项目名称:wps,代码行数:13,代码来源:config.php

示例13: get

 /**
  * Populates the BP_XProfile_Group object with profile field groups, fields,
  * and field data
  *
  * @package BuddyPress XProfile
  *
  * @global object $wpdb WordPress DB access object.
  *
  * @param array $args {
  *  Array of optional arguments:
  *      @type int          $profile_group_id  Limit results to a single profile group.
  *      @type int          $user_id           Required if you want to load a specific user's data.
  *                                            Default: displayed user's ID.
  *      @type array|string $member_type       Limit fields by those restricted to a given member type, or array of
  *                                            member types. If `$user_id` is provided, the value of `$member_type`
  *                                            will be overridden by the member types of the provided user. The
  *                                            special value of 'any' will return only those fields that are
  *                                            unrestricted by member type - i.e., those applicable to any type.
  *      @type bool         $hide_empty_groups True to hide groups that don't have any fields. Default: false.
  *      @type bool         $hide_empty_fields True to hide fields where the user has not provided data.
  *                                            Default: false.
  *      @type bool         $fetch_fields      Whether to fetch each group's fields. Default: false.
  *      @type bool         $fetch_field_data  Whether to fetch data for each field. Requires a $user_id.
  *                                            Default: false.
  *      @type array        $exclude_groups    Comma-separated list or array of group IDs to exclude.
  *      @type array        $exclude_fields    Comma-separated list or array of field IDs to exclude.
  *      @type bool         $update_meta_cache Whether to pre-fetch xprofilemeta for all retrieved groups, fields,
  *                                            and data. Default: true.
  * }
  * @return array $groups
  */
 public static function get($args = array())
 {
     global $wpdb;
     // Parse arguments.
     $r = wp_parse_args($args, array('profile_group_id' => false, 'user_id' => bp_displayed_user_id(), 'member_type' => false, 'hide_empty_groups' => false, 'hide_empty_fields' => false, 'fetch_fields' => false, 'fetch_field_data' => false, 'fetch_visibility_level' => false, 'exclude_groups' => false, 'exclude_fields' => false, 'update_meta_cache' => true));
     // Keep track of object IDs for cache-priming.
     $object_ids = array('group' => array(), 'field' => array(), 'data' => array());
     // WHERE.
     if (!empty($r['profile_group_id'])) {
         $where_sql = $wpdb->prepare('WHERE g.id = %d', $r['profile_group_id']);
     } elseif ($r['exclude_groups']) {
         $exclude = join(',', wp_parse_id_list($r['exclude_groups']));
         $where_sql = "WHERE g.id NOT IN ({$exclude})";
     } else {
         $where_sql = '';
     }
     $bp = buddypress();
     // Include or exclude empty groups.
     if (!empty($r['hide_empty_groups'])) {
         $group_ids = $wpdb->get_col("SELECT DISTINCT g.id FROM {$bp->profile->table_name_groups} g INNER JOIN {$bp->profile->table_name_fields} f ON g.id = f.group_id {$where_sql} ORDER BY g.group_order ASC");
     } else {
         $group_ids = $wpdb->get_col("SELECT DISTINCT g.id FROM {$bp->profile->table_name_groups} g {$where_sql} ORDER BY g.group_order ASC");
     }
     // Get all group data.
     $groups = self::get_group_data($group_ids);
     // Bail if not also getting fields.
     if (empty($r['fetch_fields'])) {
         return $groups;
     }
     // Get the group ids from the groups we found.
     $group_ids = wp_list_pluck($groups, 'id');
     // Store for meta cache priming.
     $object_ids['group'] = $group_ids;
     // Bail if no groups found.
     if (empty($group_ids)) {
         return $groups;
     }
     // Setup IN query from group IDs.
     $group_ids_in = implode(',', (array) $group_ids);
     // Support arrays and comma-separated strings.
     $exclude_fields_cs = wp_parse_id_list($r['exclude_fields']);
     // Visibility - Handled here so as not to be overridden by sloppy use of the
     // exclude_fields parameter. See bp_xprofile_get_hidden_fields_for_user().
     $hidden_user_fields = bp_xprofile_get_hidden_fields_for_user($r['user_id']);
     $exclude_fields_cs = array_merge($exclude_fields_cs, $hidden_user_fields);
     $exclude_fields_cs = implode(',', $exclude_fields_cs);
     // Set up NOT IN query for excluded field IDs.
     if (!empty($exclude_fields_cs)) {
         $exclude_fields_sql = "AND id NOT IN ({$exclude_fields_cs})";
     } else {
         $exclude_fields_sql = '';
     }
     // Set up IN query for included field IDs.
     $include_field_ids = array();
     // Member-type restrictions.
     if (bp_get_member_types()) {
         if ($r['user_id'] || false !== $r['member_type']) {
             $member_types = $r['member_type'];
             if ($r['user_id']) {
                 $member_types = bp_get_member_type($r['user_id'], false);
                 if (empty($member_types)) {
                     $member_types = array('null');
                 }
             }
             $member_types_fields = BP_XProfile_Field::get_fields_for_member_type($member_types);
             $include_field_ids += array_keys($member_types_fields);
         }
     }
     $in_sql = '';
//.........这里部分代码省略.........
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:101,代码来源:class-bp-xprofile-group.php

示例14: bps_get_fields

function bps_get_fields()
{
    global $group, $field;
    static $groups = array();
    static $fields = array();
    if (count($groups)) {
        return array($groups, $fields);
    }
    if (!function_exists('bp_has_profile')) {
        printf('<p class="bps_error">' . __('%s: The BuddyPress Extended Profiles component is not active.', 'bp-profile-search') . '</p>', '<strong>BP Profile Search ' . BPS_VERSION . '</strong>');
        return array($groups, $fields);
    }
    $args = array('hide_empty_fields' => false, 'member_type' => bp_get_member_types());
    if (bp_has_profile($args)) {
        while (bp_profile_groups()) {
            bp_the_profile_group();
            $group->name = str_replace('&amp;', '&', stripslashes($group->name));
            $groups[$group->name] = array();
            while (bp_profile_fields()) {
                bp_the_profile_field();
                $field->name = str_replace('&amp;', '&', stripslashes($field->name));
                $field->description = str_replace('&amp;', '&', stripslashes($field->description));
                $groups[$group->name][] = array('id' => $field->id, 'name' => $field->name);
                $fields[$field->id] = $field;
            }
        }
    }
    list($groups, $fields) = apply_filters('bps_get_fields', array($groups, $fields));
    return array($groups, $fields);
}
开发者ID:Kemitestech,项目名称:WordPress-Skeleton,代码行数:30,代码来源:bps-functions.php

示例15: 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' => __('&#8592; 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' => __('&#8592; 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');
}
开发者ID:socialray,项目名称:surfied-2-0,代码行数:96,代码来源:rendez-vous-editor.php


注:本文中的bp_get_member_types函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。