edit.php
228 lines
| 1 | <?php |
| 2 | |
| 3 | // Don't load directly. |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | die( '-1' ); |
| 6 | } |
| 7 | |
| 8 | // phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 9 | ?> |
| 10 | <div class="wrap pods-admin"> |
| 11 | <div id="icon-pods" class="icon32"><br /></div> |
| 12 | |
| 13 | <form action="" method="post" class="pods-submittable pods-form"> |
| 14 | <div class="pods-submittable-fields"> |
| 15 | <?php PodsForm::output_field( 'action', 'pods_admin_components', 'hidden' ); ?> |
| 16 | <?php PodsForm::output_field( 'component', $component, 'hidden' ); ?> |
| 17 | <?php PodsForm::output_field( 'method', $method, 'hidden' ); ?> |
| 18 | <?php PodsForm::output_field( 'id', $id, 'hidden' ); ?> |
| 19 | <?php PodsForm::output_field( '_wpnonce', wp_create_nonce( 'pods-component-' . $component . '-' . $method ), 'hidden' ); ?> |
| 20 | |
| 21 | <h2 class="italicized"><?php esc_html_e( 'Roles & Capabilities: Edit Role', 'pods' ); ?></h2> |
| 22 | |
| 23 | <?php |
| 24 | if ( isset( $_GET['do'] ) ) { |
| 25 | $action = __( 'saved', 'pods' ); |
| 26 | |
| 27 | if ( 'create' == pods_v( 'do', 'get', 'save' ) ) { |
| 28 | $action = __( 'created', 'pods' ); |
| 29 | } |
| 30 | |
| 31 | // translators: %1$s is the item label, %2$s is the action performed (created/updated). |
| 32 | $message = sprintf( __( '<strong>Success!</strong> %1$s %2$s successfully.', 'pods' ), $obj->item, $action ); |
| 33 | |
| 34 | $obj->message( wp_kses_post( $message ) ); |
| 35 | } |
| 36 | ?> |
| 37 | |
| 38 | <p><?php esc_html_e( 'Choose below which Capabilities you would like this existing user role to have.', 'pods' ); ?></p> |
| 39 | |
| 40 | <div id="poststuff" class="poststuff"> |
| 41 | <div id="post-body" class="metabox-holder columns-2"> |
| 42 | |
| 43 | <div id="postbox-container-1" class="postbox-container"> |
| 44 | <div id="side-sortables" class="meta-box-sortables ui-sortable"> |
| 45 | <!-- BEGIN PUBLISH DIV --> |
| 46 | <div id="submitdiv" class="postbox"> |
| 47 | <div class="handlediv" title="Click to toggle"><br /></div> |
| 48 | <h3 class="hndle"><span><?php esc_html_e( 'Manage', 'pods' ); ?></span></h3> |
| 49 | |
| 50 | <div class="inside"> |
| 51 | <div class="submitbox" id="submitpost"> |
| 52 | <div id="minor-publishing"> |
| 53 | <div id="major-publishing-actions"> |
| 54 | <div id="publishing-action"> |
| 55 | <img class="waiting" |
| 56 | src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" |
| 57 | alt="" /> |
| 58 | <input type="submit" name="publish" id="publish" |
| 59 | class="button-primary" |
| 60 | value="<?php esc_html_e( 'Save', 'pods' ); ?>" accesskey="p" /> |
| 61 | </div> |
| 62 | <!-- /#publishing-action --> |
| 63 | |
| 64 | <div class="clear"></div> |
| 65 | </div> |
| 66 | <!-- /#major-publishing-actions --> |
| 67 | </div> |
| 68 | <!-- /#minor-publishing --> |
| 69 | </div> |
| 70 | <!-- /#submitpost --> |
| 71 | </div> |
| 72 | <!-- /.inside --> |
| 73 | </div> |
| 74 | <!-- /#submitdiv --><!-- END PUBLISH DIV --><!-- TODO: minor column fields --> |
| 75 | </div> |
| 76 | <!-- /#side-sortables --> |
| 77 | </div> |
| 78 | <!-- /#side-info-column --> |
| 79 | |
| 80 | <div id="postbox-container-2" class="postbox-container"> |
| 81 | <div id="post-body-content"> |
| 82 | <div id="normal-sortables" class="meta-box-sortables ui-sortable"> |
| 83 | <div id="pods-meta-box" class="postbox" style=""> |
| 84 | <div class="handlediv" title="Click to toggle"><br /></div> |
| 85 | <h3 class="hndle"> |
| 86 | <span> |
| 87 | <?php esc_html_e( 'Assign the Capabilities for', 'pods' ); ?> |
| 88 | <strong><?php echo esc_html( $role_label ); ?></strong> |
| 89 | </span> |
| 90 | </h3> |
| 91 | |
| 92 | <div class="inside pods-manage-field pods-dependency"> |
| 93 | <div class="pods-field-option-group"> |
| 94 | <div class="pods-pick-values pods-pick-checkbox pods-zebra"> |
| 95 | <p> |
| 96 | <a href="#toggle" class="button" |
| 97 | id="toggle-all"><?php esc_html_e( 'Toggle All Capabilities on / off', 'pods' ); ?></a> |
| 98 | </p> |
| 99 | |
| 100 | <ul> |
| 101 | <?php |
| 102 | $zebra = false; |
| 103 | |
| 104 | foreach ( $capabilities as $capability ) { |
| 105 | $checked = false; |
| 106 | |
| 107 | if ( true === (bool) pods_v( $capability, $role_capabilities, false ) ) { |
| 108 | $checked = true; |
| 109 | } |
| 110 | |
| 111 | $class = ( $zebra ? 'even' : 'odd' ); |
| 112 | |
| 113 | $zebra = ( ! $zebra ); |
| 114 | ?> |
| 115 | <li class="pods-zebra-<?php echo esc_attr( $class ); ?>" |
| 116 | data-capability="<?php echo esc_attr( $capability ); ?>"> |
| 117 | <?php |
| 118 | PodsForm::output_field( 'capabilities[' . $capability . ']', pods_v( 'capabilities[' . $capability . ']', 'post', $checked ), 'boolean', [ |
| 119 | 'boolean_yes_label' => $capability, |
| 120 | 'disable_dfv' => true, |
| 121 | ] ); |
| 122 | ?> |
| 123 | </li> |
| 124 | <?php |
| 125 | } |
| 126 | ?> |
| 127 | </ul> |
| 128 | </div> |
| 129 | </div> |
| 130 | |
| 131 | <div class="pods-field-option-group"> |
| 132 | <p class="pods-field-option-group-label"> |
| 133 | <?php |
| 134 | PodsForm::output_label( 'custom_capabilities[0]', __( 'Custom Capabilities', 'pods' ), __( 'These capabilities will automatically be created and assigned to this role', 'pods' ) ); |
| 135 | ?> |
| 136 | </p> |
| 137 | |
| 138 | <div class="pods-pick-values pods-pick-checkbox"> |
| 139 | <ul id="custom-capabilities"> |
| 140 | <li class="pods-repeater hidden"> |
| 141 | <?php |
| 142 | PodsForm::output_field( 'custom_capabilities[--1]', '', 'text', [ |
| 143 | 'disable_dfv' => true, |
| 144 | ] ); |
| 145 | ?> |
| 146 | </li> |
| 147 | <li> |
| 148 | <?php |
| 149 | PodsForm::output_field( 'custom_capabilities[0]', '', 'text', [ |
| 150 | 'disable_dfv' => true, |
| 151 | ] ); |
| 152 | ?> |
| 153 | </li> |
| 154 | </ul> |
| 155 | |
| 156 | <p> |
| 157 | <a href="#add-capability" id="add-capability" |
| 158 | class="button"><?php esc_html_e( 'Add Another Custom Capability', 'pods' ); ?></a> |
| 159 | </p> |
| 160 | </div> |
| 161 | </div> |
| 162 | </div> |
| 163 | <!-- /.inside --> |
| 164 | </div> |
| 165 | <!-- /#pods-meta-box --> |
| 166 | </div> |
| 167 | <!-- /#normal-sortables --> |
| 168 | |
| 169 | <!-- <div id="advanced-sortables" class="meta-box-sortables ui-sortable"></div> --> |
| 170 | <!-- /#advanced-sortables --> |
| 171 | |
| 172 | </div> |
| 173 | <!-- /#post-body-content --> |
| 174 | |
| 175 | <br class="clear" /> |
| 176 | </div> |
| 177 | <!-- /#post-body --> |
| 178 | |
| 179 | <br class="clear" /> |
| 180 | |
| 181 | </div> |
| 182 | </div> |
| 183 | <!-- /#poststuff --> |
| 184 | </div> |
| 185 | </form> |
| 186 | <!-- /#pods-record --> |
| 187 | </div> |
| 188 | |
| 189 | <script type="text/javascript"> |
| 190 | var pods_admin_submit_callback = function( id ) { |
| 191 | id = parseInt( id ); |
| 192 | document.location |
| 193 | = 'admin.php?page=pods-component-<?php echo esc_js( $component ); ?>&action=edit&id=<?php echo esc_js( $id ); ?>&do=save'; |
| 194 | }; |
| 195 | |
| 196 | jQuery( function( $ ) { |
| 197 | $( document ).Pods( 'validate' ); |
| 198 | $( document ).Pods( 'submit' ); |
| 199 | $( document ).Pods( 'wizard' ); |
| 200 | $( document ).Pods( 'dependency' ); |
| 201 | $( document ).Pods( 'advanced' ); |
| 202 | $( document ).Pods( 'confirm' ); |
| 203 | $( document ).Pods( 'sluggable' ); |
| 204 | |
| 205 | var toggle_all = true; |
| 206 | |
| 207 | $( '#toggle-all' ).on( 'click', function( e ) { |
| 208 | e.preventDefault(); |
| 209 | |
| 210 | $( '.pods-field.pods-boolean input[type="checkbox"]' ).prop( 'checked', toggle_all ); |
| 211 | |
| 212 | toggle_all = ( |
| 213 | ! toggle_all |
| 214 | ); |
| 215 | } ); |
| 216 | |
| 217 | $( '#add-capability' ).on( 'click', function( e ) { |
| 218 | e.preventDefault(); |
| 219 | |
| 220 | var new_id = $( 'ul#custom-capabilities li' ).length; |
| 221 | var html = $( 'ul#custom-capabilities li.pods-repeater' ).html().replace( /\-\-1/g, new_id ); |
| 222 | |
| 223 | $( 'ul#custom-capabilities' ).append( '<li id="capability-' + new_id + '">' + html + '</li>' ); |
| 224 | $( 'li#capability-' + new_id + ' input' ).focus(); |
| 225 | } ); |
| 226 | } ); |
| 227 | </script> |
| 228 |