/** * 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); } }
<?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 */