本文整理汇总了PHP中WPCF_Roles::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF_Roles::getInstance方法的具体用法?PHP WPCF_Roles::getInstance怎么用?PHP WPCF_Roles::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF_Roles
的用法示例。
在下文中一共展示了WPCF_Roles::getInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upgrade_db_to_2010000
/**
* Upgrade database to 2010000 (Types 2.1)
*
* Batch fix types-768 for all non-superadmin users.
*/
function upgrade_db_to_2010000()
{
$roles_manager = WPCF_Roles::getInstance();
global $wpdb;
// Will find users without the administrator roles but with one of the Types management roles.
// A sign of the types-768 bug.
$user_query = new WP_User_Query(array('meta_query' => array('relation' => 'AND', array('key' => $wpdb->prefix . 'capabilities', 'value' => '"administrator"', 'compare' => 'NOT LIKE'), array('key' => $wpdb->prefix . 'capabilities', 'value' => '"wpcf_custom_post_type_view"', 'compare' => 'LIKE'))));
$users = $user_query->get_results();
foreach ($users as $user) {
$roles_manager->clean_the_mess_in_nonadmin_user_caps($user);
}
}
示例2: switch
<?php
/**
*
* Admin functions
*
*
*/
require_once WPCF_ABSPATH . '/marketing.php';
require_once WPCF_ABSPATH . '/includes/classes/class.wpcf.roles.php';
WPCF_Roles::getInstance();
/*
* This needs to be called after main 'init' hook.
* Main init hook calls required Types code for frontend.
* Admin init hook only in admin area.
*
* TODO Revise it to change to 'admin_init'
*/
add_action('admin_init', 'wpcf_admin_init_hook', 11);
add_action('init', 'wpcf_init_admin_pages');
add_action('admin_menu', 'wpcf_admin_menu_hook');
add_action('wpcf_admin_page_init', 'wpcf_enqueue_scripts');
add_action('admin_enqueue_scripts', 'wpcf_admin_enqueue_scripts');
// OMG, why so early? At this point we don't even have embedded Types (with functions.php).
if (defined('DOING_AJAX')) {
require_once WPCF_INC_ABSPATH . '/ajax.php';
if (isset($_REQUEST['action'])) {
switch ($_REQUEST['action']) {
/**
* post edit screen
*/