add.php
187 lines
| 1 | <div class="wrap pods-admin"> |
| 2 | <div id="icon-pods" class="icon32"><br /></div> |
| 3 | |
| 4 | <form action="" method="post" class="pods-submittable"> |
| 5 | <div class="pods-submittable-fields"> |
| 6 | <?php echo PodsForm::field( 'action', 'pods_admin_components', 'hidden' ); ?> |
| 7 | <?php echo PodsForm::field( 'component', $component, 'hidden' ); ?> |
| 8 | <?php echo PodsForm::field( 'method', $method, 'hidden' ); ?> |
| 9 | <?php echo PodsForm::field( '_wpnonce', wp_create_nonce( 'pods-component-' . $component . '-' . $method ), 'hidden' ); ?> |
| 10 | |
| 11 | <h2 class="italicized"><?php _e( 'Roles & Capabilities: Add New Role', 'pods' ); ?></h2> |
| 12 | |
| 13 | <img src="<?php echo esc_url( PODS_URL ); ?>ui/images/pods-logo-notext-rgb-transparent.png" class="pods-leaf-watermark-right" /> |
| 14 | |
| 15 | <div id="pods-wizard-box" class="pods-wizard-steps-2"> |
| 16 | <div id="pods-wizard-heading"> |
| 17 | <ul> |
| 18 | <li class="pods-wizard-menu-current" data-step="1"> |
| 19 | <i></i> <span>1</span> <?php esc_html_e( 'Step 1: Naming', 'pods' ); ?> |
| 20 | <em></em> |
| 21 | </li> |
| 22 | <li data-step="2"> |
| 23 | <i></i> <span>2</span> <?php esc_html_e( 'Step 2: Capabilities', 'pods' ); ?> |
| 24 | <em></em> |
| 25 | </li> |
| 26 | </ul> |
| 27 | </div> |
| 28 | <div id="pods-wizard-main"> |
| 29 | <div id="pods-wizard-panel-1" class="pods-wizard-panel"> |
| 30 | <div class="pods-wizard-content"> |
| 31 | <p><?php esc_html_e( 'Roles allow you to specify which capabilities a user should be able to do within WordPress.', 'pods' ); ?></p> |
| 32 | </div> |
| 33 | |
| 34 | <div class="stuffbox"> |
| 35 | <h3><label for="link_name"><?php esc_html_e( 'Name your new Role', 'pods' ); ?></label></h3> |
| 36 | |
| 37 | <div class="inside pods-manage-field"> |
| 38 | <div class="pods-field__container"> |
| 39 | <?php |
| 40 | echo PodsForm::label( 'role_label', __( 'Label', 'pods' ), __( 'Users will see this as the name of their role', 'pods' ) ); |
| 41 | echo PodsForm::field( 'role_label', pods_v( 'role_label', 'post' ), 'text', [ |
| 42 | 'class' => 'pods-validate pods-validate-required', |
| 43 | ] ); |
| 44 | ?> |
| 45 | </div> |
| 46 | |
| 47 | <div class="pods-field__container"> |
| 48 | <?php |
| 49 | echo PodsForm::label( 'role_name', __( 'Name', 'pods' ), __( 'You will use this name to programmatically reference this role throughout WordPress', 'pods' ) ); |
| 50 | echo PodsForm::field( 'role_name', pods_v( 'role_name', 'post' ), 'slug', [ |
| 51 | 'slug_sluggable' => 'role_label', |
| 52 | 'class' => 'pods-validate pods-validate-required pods-slugged-lower pods-slugged-sanitize-title', |
| 53 | ] ); |
| 54 | ?> |
| 55 | </div> |
| 56 | </div> |
| 57 | </div> |
| 58 | </div> |
| 59 | <div id="pods-wizard-panel-2" class="pods-wizard-panel pods-wizard-option-content"> |
| 60 | <div class="pods-wizard-content"> |
| 61 | <p><?php esc_html_e( 'Choose below which Capabilities you would like this new user role to have.', 'pods' ); ?></p> |
| 62 | </div> |
| 63 | |
| 64 | <div class="stuffbox"> |
| 65 | <h3><label for="link_name"><?php esc_html_e( 'Assign the Capabilities for', 'pods' ); ?> |
| 66 | <strong class="pods-slugged" data-sluggable="role_label"></strong></label></h3> |
| 67 | |
| 68 | <div class="inside pods-manage-field pods-dependency"> |
| 69 | <div class="pods-field-option-group"> |
| 70 | <div class="pods-pick-values pods-pick-checkbox pods-zebra"> |
| 71 | <p> |
| 72 | <a href="#toggle" class="button" id="toggle-all"><?php esc_html_e( 'Toggle All Capabilities on / off', 'pods' ); ?></a> |
| 73 | </p> |
| 74 | |
| 75 | <ul> |
| 76 | <?php |
| 77 | $zebra = false; |
| 78 | |
| 79 | foreach ( $capabilities as $capability ) { |
| 80 | $checked = false; |
| 81 | |
| 82 | if ( in_array( $capability, $defaults, true ) ) { |
| 83 | $checked = true; |
| 84 | } |
| 85 | |
| 86 | $class = ( $zebra ? 'even' : 'odd' ); |
| 87 | |
| 88 | $zebra = ( ! $zebra ); |
| 89 | ?> |
| 90 | <li class="pods-zebra-<?php echo esc_attr( $class ); ?>" data-capability="<?php echo esc_attr( $capability ); ?>"> |
| 91 | <?php echo PodsForm::field( 'capabilities[' . $capability . ']', pods_v( 'capabilities[' . $capability . ']', 'post', $checked ), 'boolean', [ |
| 92 | 'boolean_yes_label' => $capability, |
| 93 | 'disable_dfv' => true, |
| 94 | ] ); ?> |
| 95 | </li> |
| 96 | <?php |
| 97 | } |
| 98 | ?> |
| 99 | </ul> |
| 100 | </div> |
| 101 | </div> |
| 102 | |
| 103 | <div class="pods-field-option-group"> |
| 104 | <p class="pods-field-option-group-label"> |
| 105 | <?php |
| 106 | echo PodsForm::label( 'custom_capabilities[0]', __( 'Custom Capabilities', 'pods' ), __( 'These capabilities will automatically be created and assigned to this role', 'pods' ) ); |
| 107 | ?> |
| 108 | </p> |
| 109 | |
| 110 | <div class="pods-pick-values pods-pick-checkbox"> |
| 111 | <ul id="custom-capabilities"> |
| 112 | <li class="pods-repeater hidden"> |
| 113 | <?php |
| 114 | echo PodsForm::field( 'custom_capabilities[--1]', '', 'text', [ |
| 115 | 'disable_dfv' => true, |
| 116 | ] ); |
| 117 | ?> |
| 118 | </li> |
| 119 | <li> |
| 120 | <?php |
| 121 | echo PodsForm::field( 'custom_capabilities[0]', '', 'text', [ |
| 122 | 'disable_dfv' => true, |
| 123 | ] ); |
| 124 | ?> |
| 125 | </li> |
| 126 | </ul> |
| 127 | |
| 128 | <p> |
| 129 | <a href="#add-capability" id="add-capability" class="button">Add Another Custom Capability</a> |
| 130 | </p> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | </div> |
| 135 | </div> |
| 136 | |
| 137 | <div id="pods-wizard-actions" class="pods-wizard-button-interface"> |
| 138 | <div id="pods-wizard-toolbar"> |
| 139 | <button id="pods-wizard-start" class="button button-secondary hidden"><?php esc_html_e( 'Start Over', 'pods' ); ?></button> |
| 140 | <button id="pods-wizard-next" class="button button-primary" data-next="<?php esc_attr_e( 'Next Step', 'pods' ); ?>" data-finished="<?php esc_attr_e( 'Finished', 'pods' ); ?>" data-processing="<?php esc_attr_e( 'Processing', 'pods' ); ?>.."><?php esc_html_e( 'Next Step', 'pods' ); ?></button> |
| 141 | </div> |
| 142 | <div id="pods-wizard-finished"> |
| 143 | |
| 144 | </div> |
| 145 | </div> |
| 146 | </div> |
| 147 | </div> |
| 148 | </div> |
| 149 | </form> |
| 150 | </div> |
| 151 | <script type="text/javascript"> |
| 152 | var pods_admin_submit_callback = function ( id ) { |
| 153 | id = parseInt( id ); |
| 154 | document.location = 'admin.php?page=pods-component-<?php echo esc_js( $component ); ?>&do=create'; |
| 155 | }; |
| 156 | |
| 157 | jQuery( function ( $ ) { |
| 158 | $( document ).Pods( 'validate' ); |
| 159 | $( document ).Pods( 'submit' ); |
| 160 | $( document ).Pods( 'wizard' ); |
| 161 | $( document ).Pods( 'dependency' ); |
| 162 | $( document ).Pods( 'advanced' ); |
| 163 | $( document ).Pods( 'confirm' ); |
| 164 | $( document ).Pods( 'sluggable' ); |
| 165 | |
| 166 | var toggle_all = true; |
| 167 | |
| 168 | $( '#toggle-all' ).on( 'click', function ( e ) { |
| 169 | e.preventDefault(); |
| 170 | |
| 171 | $( '.pods-field.pods-boolean input[type="checkbox"]' ).prop( 'checked', toggle_all ); |
| 172 | |
| 173 | toggle_all = (!toggle_all); |
| 174 | } ); |
| 175 | |
| 176 | $( '#add-capability' ).on( 'click', function ( e ) { |
| 177 | e.preventDefault(); |
| 178 | |
| 179 | var new_id = $( 'ul#custom-capabilities li' ).length; |
| 180 | var html = $( 'ul#custom-capabilities li.pods-repeater' ).html().replace( '--1', new_id ); |
| 181 | |
| 182 | $( 'ul#custom-capabilities' ).append( '<li id="capability-' + new_id + '">' + html + '</li>' ); |
| 183 | $( 'li#capability-' + new_id + ' input' ).focus(); |
| 184 | } ); |
| 185 | } ); |
| 186 | </script> |
| 187 |