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