__( 'Access Groups', 'groups' ), GROUPS_ADMINISTER_GROUPS => __( 'Administer Groups', 'groups' ), GROUPS_ADMINISTER_OPTIONS => __( 'Administer Groups plugin options', 'groups' ), GROUPS_RESTRICT_ACCESS => __( 'Restrict Access', 'groups' ) ); $previous_legacy_enable = Groups_Options::get_option( GROUPS_LEGACY_ENABLE, GROUPS_LEGACY_ENABLE_DEFAULT ); // // handle options form submission // if ( isset( $_POST['submit'] ) ) { if ( wp_verify_nonce( $_POST[GROUPS_ADMIN_OPTIONS_NONCE], 'admin' ) ) { $post_types = get_post_types(); $selected_post_types = !empty( $_POST['add_meta_boxes'] ) && is_array( $_POST['add_meta_boxes'] ) ? $_POST['add_meta_boxes'] : array(); foreach( $post_types as $post_type ) { $handle_post_types[$post_type] = in_array( $post_type, $selected_post_types ); } Groups_Post_Access::set_handles_post_types( $handle_post_types ); // tree view if ( !empty( $_POST[GROUPS_SHOW_TREE_VIEW] ) ) { Groups_Options::update_option( GROUPS_SHOW_TREE_VIEW, true ); } else { Groups_Options::update_option( GROUPS_SHOW_TREE_VIEW, false ); } // show in user profiles Groups_Options::update_option( GROUPS_SHOW_IN_USER_PROFILE, !empty( $_POST[GROUPS_SHOW_IN_USER_PROFILE] ) ); // roles & capabilities $rolenames = $wp_roles->get_names(); foreach ( $rolenames as $rolekey => $rolename ) { $role = $wp_roles->get_role( $rolekey ); foreach ( $caps as $capkey => $capname ) { $role_cap_id = $rolekey.'-'.$capkey; if ( !empty($_POST[$role_cap_id] ) ) { $role->add_cap( $capkey ); } else { $role->remove_cap( $capkey ); } } } Groups_Controller::assure_capabilities(); if ( !$is_sitewide_plugin ) { // delete data if ( !empty( $_POST['delete-data'] ) ) { Groups_Options::update_option( 'groups_delete_data', true ); } else { Groups_Options::update_option( 'groups_delete_data', false ); } } // legacy enable ? if ( !empty( $_POST[GROUPS_LEGACY_ENABLE] ) ) { Groups_Options::update_option( GROUPS_LEGACY_ENABLE, true ); } else { Groups_Options::update_option( GROUPS_LEGACY_ENABLE, false ); } Groups_Admin::add_message( __( 'Options saved.', 'groups' ) ); } } echo '
'; echo '

' . __( 'Groups Options', 'groups' ) . '

'; echo Groups_Admin::render_messages(); $show_tree_view = Groups_Options::get_option( GROUPS_SHOW_TREE_VIEW, GROUPS_SHOW_TREE_VIEW_DEFAULT ); $show_in_user_profile = Groups_Options::get_option( GROUPS_SHOW_IN_USER_PROFILE, GROUPS_SHOW_IN_USER_PROFILE_DEFAULT ); $rolenames = $wp_roles->get_names(); $caps_table = ''; $caps_table .= ''; $caps_table .= ''; $caps_table .= ''; foreach ( $caps as $cap ) { $caps_table .= ''; } $caps_table .= ''; $caps_table .= ''; $caps_table .= ''; foreach ( $rolenames as $rolekey => $rolename ) { $role = $wp_roles->get_role( $rolekey ); $caps_table .= ''; $caps_table .= ''; foreach ( $caps as $capkey => $capname ) { if ( $role->has_cap( $capkey ) ) { $checked = ' checked="checked" '; } else { $checked = ''; } $caps_table .= ''; } $caps_table .= ''; } $caps_table .= ''; $caps_table .= '
'; $caps_table .= __( 'Role', 'groups' ); $caps_table .= ''; $caps_table .= $cap; $caps_table .= '
'; $caps_table .= translate_user_role( $rolename ); $caps_table .= ''; $role_cap_id = $rolekey.'-'.$capkey; $caps_table .= ''; $caps_table .= '
'; $delete_data = Groups_Options::get_option( 'groups_delete_data', false ); if ( isset( $_GET['dismiss-groups-extensions-box'] ) && isset( $_GET['groups-extensions-box-nonce'] ) && wp_verify_nonce( $_GET['groups-extensions-box-nonce'], 'dismiss-box' ) ) { Groups_Options::update_user_option( 'show-extensions-box', false ); } $extensions_box = ''; if ( Groups_Options::get_user_option( 'show-extensions-box', true ) ) { $dismiss_url = wp_nonce_url( add_query_arg( 'dismiss-groups-extensions-box', '1', admin_url( 'admin.php?page=groups-admin-options' ) ), 'dismiss-box', 'groups-extensions-box-nonce' ); $extensions_box = '
' . __( 'Enhanced functionality is available via official Extensions for Groups.', 'groups' ) . sprintf( 'x', esc_url( $dismiss_url ) ) . '
'; } // // print the options form // echo '
' . '
' . '

' . '' . $extensions_box . '

'; if ( _groups_admin_override() ) { echo '

' . __( 'Administrator Access Override', 'groups' ) . '

' . '

' . __( 'Administrators override all access permissions derived from Groups capabilities.', 'groups' ) . '

' . '

' . __( 'To disable, do not define the constant GROUPS_ADMINISTRATOR_OVERRIDE or set it to false.', 'groups' ) . '

' . '

' . __( 'Enabling this on production sites is not recommended.', 'groups' ) . '

'; } echo '

'; echo __( 'Access restricions', 'groups' ); echo '

'; echo '

'; echo __( 'Post types', 'groups' ); echo '

'; echo '

'; echo __( 'Show access restrictions for these post types.', 'groups' ); // @todo change wording to '...handles access...' ? echo '

'; $post_type_objects = get_post_types( array(), 'objects' ); uasort( $post_type_objects, 'groups_admin_options_compare_post_types' ); echo '
    '; foreach( $post_type_objects as $post_type => $post_type_object ) { echo '
  • '; echo ''; echo '
  • '; } echo '
      '; echo '

      ' . __( 'This determines for which post types access restriction settings are offered.', 'groups' ) . '
      ' . __( 'Disabling this setting for a post type also disables existing access restrictions on individual posts of that type.', 'groups' ) . '
      ' . '

      '; echo '

      ' . __( 'User profiles', 'groups' ) . '

      ' . '

      ' . '' . '

      '; echo '

      ' . __( 'Tree view', 'groups' ) . '

      ' . '

      ' . '' . '

      '; echo '

      ' . __( 'Permissions', 'groups' ) . '

      ' . '

      ' . __( 'These permissions apply to Groups management. They do not apply to access permissions derived from Groups capabilities.', 'groups' ) . '

      ' . $caps_table . '

      ' . __( 'A minimum set of permissions will be preserved.', 'groups' ) . '
      ' . __( 'If you lock yourself out, please ask an administrator to help.', 'groups' ) . '

      '; if ( !$is_sitewide_plugin ) { echo '

      ' . __( 'Deactivation and data persistence', 'groups' ) . '

      ' . '

      ' . '' . '

      ' . '

      ' . __( 'CAUTION: If this option is active while the plugin is deactivated, ALL plugin settings and data will be DELETED. If you are going to use this option, now would be a good time to make a backup. By enabling this option you agree to be solely responsible for any loss of data or any other consequences thereof.', 'groups' ) . '

      '; } $groups_legacy_enable = Groups_Options::get_option( GROUPS_LEGACY_ENABLE, GROUPS_LEGACY_ENABLE_DEFAULT ); echo '

      ' . __( 'Legacy Settings', 'groups' ) . '

      '; echo '

      ' . '' . '

      '; if ( $groups_legacy_enable ) { require_once GROUPS_LEGACY_LIB . '/admin/groups-admin-options-legacy.php'; do_action( 'groups_admin_options_legacy', $groups_legacy_enable !== $previous_legacy_enable ); } echo '

      ' . wp_nonce_field( 'admin', GROUPS_ADMIN_OPTIONS_NONCE, true, false ) . '' . '

      ' . '
' . '
'; echo '
'; // .groups-options } /** * Network administration options. */ function groups_network_admin_options() { if ( !current_user_can( GROUPS_ADMINISTER_OPTIONS ) ) { wp_die( __( 'Access denied.', 'groups' ) ); } echo '
' . '

' . __( 'Groups network options', 'groups' ) . '

' . '
'; // handle options form submission if ( isset( $_POST['submit'] ) ) { if ( wp_verify_nonce( $_POST[GROUPS_ADMIN_OPTIONS_NONCE], 'admin' ) ) { // delete data if ( !empty( $_POST['delete-data'] ) ) { Groups_Options::update_option( 'groups_network_delete_data', true ); } else { Groups_Options::update_option( 'groups_network_delete_data', false ); } } } $delete_data = Groups_Options::get_option( 'groups_network_delete_data', false ); // options form echo '
' . '
' . '

' . __( 'Network deactivation and data persistence', 'groups' ) . '

' . '

' . '' . '

' . '

' . __( 'CAUTION: If this option is active while the plugin is deactivated, ALL plugin settings and data will be DELETED for all sites. If you are going to use this option, now would be a good time to make a backup. By enabling this option you agree to be solely responsible for any loss of data or any other consequences thereof.', 'groups' ) . '

' . '

' . wp_nonce_field( 'admin', GROUPS_ADMIN_OPTIONS_NONCE, true, false ) . '' . '

' . '
' . '
'; } /** * Compare two post types, considering those that have $public and/or $show_ui true as coming first. * @param object $o1 * @param object $o2 * @return int */ function groups_admin_options_compare_post_types( $o1, $o2 ) { $name_1 = isset( $o1->name ) ? $o1->name : ''; $name_2 = isset( $o2->name ) ? $o2->name : ''; $public_1 = isset( $o1->public ) && $o1->public; $public_2 = isset( $o2->public ) && $o2->public; $show_ui_1 = isset( $o1->show_ui ) && $o1->show_ui; $show_ui_2 = isset( $o2->show_ui ) && $o2->show_ui; $n1 = 0; $n2 = 0; if ( $public_1 ) { $n1--; } if ( $show_ui_1 ) { $n1--; } if ( $public_2 ) { $n2--; } if ( $show_ui_2 ) { $n2--; } return ( $n1 - $n2 ) * 10 + strcmp( $name_1, $name_2 ); }