__( '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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( groups_verify_post_nonce( GROUPS_ADMIN_OPTIONS_NONCE, 'admin' ) ) { $post_types = get_post_types(); $selected_post_types = groups_sanitize_post( 'add_meta_boxes' ) ?? array(); $handle_post_types = 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] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing 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] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing // 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( groups_sanitize_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'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing 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] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing 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 '

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

'; echo Groups_Admin::render_messages(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $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 .= esc_html__( 'Role', 'groups' ); $caps_table .= ''; $caps_table .= esc_html( $cap ); $caps_table .= '
'; $caps_table .= esc_html( 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 ( groups_sanitize_get( 'dismiss-groups-extensions-box' ) && groups_verify_get_nonce( 'groups-extensions-box-nonce', 'dismiss-box' ) ) { Groups_Options::update_user_option( 'show-extensions-box', time() ); } $extensions_box = ''; $show_extensions_box = Groups_Options::get_user_option( 'show-extensions-box', 0 ); if ( ( time() - $show_extensions_box ) > GROUPS_SHOW_EXTENSIONS_BOX_INTERVAL ) { // $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 = '
'; // $extensions_box .= sprintf( '', esc_attr_x( 'Dismiss', 'title of dismiss notice link', 'groups' ), esc_url( $dismiss_url ) ); $extensions_box .= '

'; $extensions_box .= esc_html__( 'Your support matters!', 'groups' ); $extensions_box .= '

'; $extensions_box .= '

'; $extensions_box .= sprintf( /* translators: 1: opening tag 2: closing tag */ esc_html__( 'Enhanced functionality is available via official %1$sExtensions%2$s for Groups.', 'groups' ), '', '' ); $extensions_box .= '

'; $extensions_box .= '

'; $extensions_box .= esc_html__( 'By getting an official extension, you fund the work that is necessary to maintain and improve Groups.', 'groups' ); $extensions_box .= '

'; $extensions_box .= '
'; } require_once GROUPS_ADMIN_LIB . '/class-groups-admin-bitcoin.php'; $bitcoin_box = Groups_Admin_Bitcoin::get_groups_bitcoin_box( array( 'where' => 'options' ) ); // // print the options form // echo '
' . '
' . '

' . '' . $bitcoin_box . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped $extensions_box . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped '

'; if ( _groups_admin_override() ) { echo '

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

' . '

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

' . '

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

' . '

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

'; } echo '

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

'; echo '

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

'; echo '

'; echo esc_html__( '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 '

      '; esc_html_e( 'This determines for which post types access restriction settings are offered.', 'groups' ); echo ' '; esc_html_e( 'Disabling this setting for a post type also disables existing access restrictions on individual posts of that type.', 'groups' ); echo ' '; esc_html_e( 'Some post types shown may not offer access restrictions even though they appear enabled here.', 'groups' ); echo '

      '; echo '

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

      ' . '

      ' . '' . '

      '; echo '

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

      ' . '

      ' . '' . '

      '; echo '

      ' . esc_html__( 'Permissions', 'groups' ) . '

      ' . '

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

      ' . $caps_table . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped '

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

      '; if ( !$is_sitewide_plugin ) { echo '

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

      ' . '

      ' . '' . '

      ' . '

      ' . esc_html__( '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 ); if ( defined( 'GROUPS_SHOW_LEGACY_SETTINGS' ) && GROUPS_SHOW_LEGACY_SETTINGS === true || $groups_legacy_enable ) { echo '

      ' . esc_html__( '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 ); } $legacy_enabled = Groups_Options::get_option( GROUPS_LEGACY_ENABLE ); echo '

      '; /* translators: version number */ printf( esc_html__( 'Switching to Groups %s', 'groups' ), esc_html( $groups_version ) ); echo '

      '; echo '

      '; /* translators: version number */ printf( esc_html__( 'Groups %s features a simpler model for access restrictions based on groups instead of capabilities used in Groups 1.x.', 'groups' ), esc_html( $groups_version ) ); echo ' '; esc_html_e( 'To put it simple, previously you would have used capabilities to restrict access to posts and now you simply use groups.', 'groups' ); echo ' '; esc_html_e( 'To make it easier to transition to the new model for those who migrate from a previous version, we have included legacy access control based on capabilities.', 'groups' ); echo '

      '; echo '
      '; echo '

      '; esc_html_e( 'The following is only of interest if you have upgraded from Groups 1.x:', 'groups' ); echo '
      '; if ( $legacy_enabled ) { esc_html_e( 'You are running the system with legacy access control based on capabilities enabled.', 'groups' ); echo ' '; esc_html_e( 'This means that if you had access restrictions in place that were based on capabilities, your entries will still be protected.', 'groups' ); } else { esc_html_e( 'You are running the system with legacy access control based on capabilities disabled.', 'groups' ); echo ' '; esc_html_e( 'This could be important!', 'groups' ); echo ' '; esc_html_e( 'If you had any access restrictions in place based on capabilities, the entries will now be unprotected, unless you enable legacy access restrictions or place appropriate access restrictions based on groups on the desired entries.', 'groups' ); } echo '

      '; echo '

      '; esc_html_e( 'If you would like to switch to access restrictions based on groups (recommended) instead of capabilities, you can easily do so by setting the appropriate groups on your protected posts, pages and other entries to restrict access.', 'groups' ); echo ' '; esc_html_e( 'Once you have adjusted your access restrictions based on groups, you can disable legacy access control.', 'groups' ); echo ' '; echo sprintf( /* translators: documentation pages link */ esc_html__( 'Please refer to the %s for details on how to switch to and use the new access restrictions.', 'groups' ), sprintf( '%s', esc_html__( 'Documentation', 'groups' ) ) ); echo '

      '; echo '
      '; // .indent } echo '

      ' . wp_nonce_field( 'admin', GROUPS_ADMIN_OPTIONS_NONCE, true, false ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped '' . '

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

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

'; // handle options form submission if ( isset( $_POST['submit'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( groups_verify_post_nonce( GROUPS_ADMIN_OPTIONS_NONCE, 'admin' ) ) { // delete data if ( !empty( $_POST['delete-data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing 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 '
' . '
' . '

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

' . '

' . '' . '

' . '

' . wp_kses_post( __( '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 ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped '' . '

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