本文整理匯總了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
*/