tab-vc-roles.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. die( '-1' );
  4. }
  5. $tab = esc_attr( preg_replace( '/^vc\-/', '', $page->getSlug() ) );
  6. $editable_roles = get_editable_roles();
  7. require_once vc_path_dir( 'SETTINGS_DIR', 'class-vc-roles.php' );
  8. $vc_role = new Vc_Roles();
  9. ?>
  10. <form action="<?php echo esc_attr( admin_url( 'admin-ajax.php' ) ); ?>" method="post"
  11. id="vc_settings-<?php echo esc_attr( $tab ); ?>"
  12. class="vc_settings-tab-content vc_settings-tab-content-active"
  13. data-vc-roles="form">
  14. <div class="tab_intro">
  15. <p><?php esc_html_e( 'Control user group role access to the features and options of WPBakery Page Builder - manage WordPress default and custom roles.', 'js_composer' ); ?></p>
  16. </div>
  17. <!-- Settings template start -->
  18. <div class="vc_wp-settings">
  19. <div class="vc_wp-accordion" data-vc-action="collapseAll">
  20. <?php
  21. foreach ( $editable_roles as $role => $details ) :
  22. $name = translate_user_role( $details['name'] );
  23. $unique_id = 'vc_role-' . $role;
  24. $valid_roles = array();
  25. foreach ( $vc_role->getParts() as $part ) {
  26. if ( $vc_role->hasRoleCapability( $role, $vc_role->getPartCapability( $part ) ) ) {
  27. $valid_roles[] = $part;
  28. }
  29. }
  30. if ( count( $valid_roles ) > 0 ) :
  31. ?>
  32. <div
  33. class="vc_wp-accordion-panel vc_ui-settings-roles-role<?php echo ! isset( $next ) ? ' vc_active' : ''; ?>"
  34. data-vc-unique-id="<?php echo esc_attr( $unique_id ); ?>"
  35. data-vc-content=".vc_wp-accordion-panel-body"
  36. data-vc-role="<?php echo esc_attr( $role ); ?>">
  37. <div class="widget" data-vc-accordion=""
  38. data-vc-container=".vc_wp-accordion"
  39. data-vc-target="[data-vc-unique-id=<?php echo esc_attr( $unique_id ); ?>]">
  40. <div class="widget-top">
  41. <div class="widget-title-action">
  42. <button type="button" class="widget-action hide-if-no-js" aria-expanded="true">
  43. <span class="screen-reader-text">Edit widget: Search</span>
  44. <span class="toggle-indicator" aria-hidden="true"></span>
  45. </button>
  46. </div>
  47. <div class="widget-title">
  48. <h4>
  49. <?php echo esc_html( $name ); ?>
  50. <span class="in-widget-title"></span>
  51. </h4>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="vc_wp-accordion-panel-body">
  56. <table class="form-table">
  57. <tbody>
  58. <?php
  59. $next = true;
  60. foreach ( $valid_roles as $part ) {
  61. vc_include_template( 'pages/partials/vc-roles-parts/_' . $part . '.tpl.php', array(
  62. 'part' => $part,
  63. 'role' => $role,
  64. 'vc_role' => $vc_role,
  65. ) );
  66. }
  67. ?>
  68. </tbody>
  69. </table>
  70. </div>
  71. </div>
  72. <?php endif; ?>
  73. <?php endforeach; ?>
  74. </div>
  75. </div>
  76. <span class="vc_settings-spinner vc_ui-wp-spinner" style="display: none;" id="vc_wp-spinner"></span>
  77. <!-- Settings template end -->
  78. <?php
  79. wp_nonce_field( 'vc_settings-' . $tab . '-action', 'vc_nonce_field' );
  80. $submit_button_attributes = array();
  81. $submit_button_attributes = apply_filters( 'vc_settings-tab-submit-button-attributes', $submit_button_attributes, $tab );
  82. $submit_button_attributes = apply_filters( 'vc_settings-tab-submit-button-attributes-' . $tab, $submit_button_attributes, $tab );
  83. submit_button( esc_html__( 'Save Changes', 'js_composer' ), 'primary', 'submit_btn', true, $submit_button_attributes );
  84. ?>
  85. <input type="hidden" name="action" value="vc_roles_settings_save"
  86. id="vc_settings-<?php echo esc_attr( $tab ); ?>-action"/>
  87. </form>