本文整理汇总了PHP中WPSEO_Utils::get_roles方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Utils::get_roles方法的具体用法?PHP WPSEO_Utils::get_roles怎么用?PHP WPSEO_Utils::get_roles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Utils
的用法示例。
在下文中一共展示了WPSEO_Utils::get_roles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enrich_defaults
/**
* Add dynamically created default options based on available post types and taxonomies
*
* @return void
*/
public function enrich_defaults()
{
$user_roles = WPSEO_Utils::get_roles();
$filtered_user_roles = apply_filters('wpseo_sitemaps_supported_user_roles', $user_roles);
if (is_array($filtered_user_roles) && $filtered_user_roles !== array()) {
foreach ($filtered_user_roles as $role_name => $role_value) {
$this->defaults['user_role-' . $role_name . '-not_in_sitemap'] = false;
unset($user_role);
}
unset($role_name, $role_value);
}
unset($user_roles, $filtered_user_roles);
$post_type_names = get_post_types(array('public' => true), 'names');
$filtered_post_types = apply_filters('wpseo_sitemaps_supported_post_types', $post_type_names);
if (is_array($filtered_post_types) && $filtered_post_types !== array()) {
foreach ($filtered_post_types as $pt) {
if ($pt !== 'attachment') {
$this->defaults['post_types-' . $pt . '-not_in_sitemap'] = false;
} else {
$this->defaults['post_types-' . $pt . '-not_in_sitemap'] = true;
}
}
unset($pt);
}
unset($post_type_names, $filtered_post_types);
$taxonomy_objects = get_taxonomies(array('public' => true), 'objects');
$filtered_taxonomies = apply_filters('wpseo_sitemaps_supported_taxonomies', $taxonomy_objects);
if (is_array($filtered_taxonomies) && $filtered_taxonomies !== array()) {
foreach ($filtered_taxonomies as $tax) {
if (isset($tax->labels->name) && trim($tax->labels->name) != '') {
$this->defaults['taxonomies-' . $tax->name . '-not_in_sitemap'] = false;
}
}
unset($tax);
}
unset($taxonomy_objects, $filtered_taxonomies);
}
示例2: wpseo_get_roles
/**
* List all the available user roles
*
* @deprecated 1.6.1
* @deprecated use WPSEO_Utils::get_roles()
* @see WPSEO_Utils::get_roles()
*
* @return array $roles
*/
function wpseo_get_roles()
{
_deprecated_function(__FUNCTION__, 'WPSEO 1.6.1', 'WPSEO_Utils::get_roles()');
return WPSEO_Utils::get_roles();
}
示例3: __
$yform->textinput('entries-per-page', __('Max entries per sitemap', 'wordpress-seo'));
?>
</div>
<div id="user-sitemap" class="wpseotab">
<?php
$yform->checkbox('disable_author_sitemap', __('Disable author/user sitemap', 'wordpress-seo'), false);
?>
<div id="xml_user_block">
<p><strong><?php
_e('Exclude users without posts', 'wordpress-seo');
?>
</strong><br/>
<?php
$yform->checkbox('disable_author_noposts', __('Disable all users with zero posts', 'wordpress-seo'), false);
$roles = WPSEO_Utils::get_roles();
if (is_array($roles) && $roles !== array()) {
echo '<p><strong>' . __('Exclude user roles', 'wordpress-seo') . '</strong><br/>';
echo __('Please check the appropriate box below if there\'s a user role that you do <strong>NOT</strong> want to include in your sitemap:', 'wordpress-seo') . '</p>';
foreach ($roles as $role_key => $role_name) {
$yform->checkbox('user_role-' . $role_key . '-not_in_sitemap', $role_name);
}
}
?>
</div>
</div>
<div id="post-types" class="wpseotab">
<?php
$post_types = apply_filters('wpseo_sitemaps_supported_post_types', get_post_types(array('public' => true), 'objects'));
示例4: get_excluded_roles
/**
* Retrieve array of roles, excluded in settings.
*
* @return array
*/
protected function get_excluded_roles()
{
static $excluded_roles;
if (isset($excluded_roles)) {
return $excluded_roles;
}
$options = WPSEO_Options::get_all();
$roles = WPSEO_Utils::get_roles();
foreach ($roles as $role_slug => $role_name) {
if (!empty($options["user_role-{$role_slug}-not_in_sitemap"])) {
$excluded_roles[] = $role_name;
}
}
if (!empty($excluded_roles)) {
// Otherwise it's handled by who=>authors query.
$excluded_roles[] = 'Subscriber';
}
return $excluded_roles;
}