Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
rilwis committed Jan 9, 2025
2 parents 9901ecb + edafc4a commit bda7e82
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 25 deletions.
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions modules/mb-custom-post-type/app/controls/Input.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import { RawHTML } from '@wordpress/element';
import Tooltip from './Tooltip';

const Input = ( { label, name, value, update, tooltip = '', description = '', required = false } ) => (
const Input = ( { label, name, value, update, tooltip = '', description = '', required = false, placeholder = '', datalist = [] } ) => (
<div className="mb-cpt-field">
<label className="mb-cpt-label" htmlFor={ name }>
{ label }
{ required && <span className="mb-cpt-required">*</span> }
{ tooltip && <Tooltip id={ name } content={ tooltip } /> }
</label>
<div className="mb-cpt-input">
<input type="text" required={ required } id={ name } name={ name } value={ value } onChange={ update } />
<input type="text"
required={ required }
id={ name }
name={ name }
value={ value }
onChange={ update }
placeholder={ placeholder }
list={ `${ name }-list` }
/>

{ description && <div className="mb-cpt-description"><RawHTML>{ description }</RawHTML></div> }
{ datalist.length > 0 && <datalist id={ `${ name }-list` }>
{ datalist.map( item => <option key={ item } value={ item } /> ) }
</datalist> }
</div>
</div>
);
Expand Down
7 changes: 6 additions & 1 deletion modules/mb-custom-post-type/app/taxonomy/MainTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import CheckboxList from '../controls/CheckboxList';
import Control from '../controls/Control';
import { ReactComponent as Logo } from '../controls/logo.svg';
import Result from './Result';
import { AdvancedControls, BasicControls, CodeControls, LabelControls } from './constants/Data';
import { AdvancedControls, BasicControls, CodeControls, LabelControls, PermissionsControls } from './constants/Data';

const tabs = [
{
Expand All @@ -28,6 +28,10 @@ const tabs = [
name: 'types',
title: __( 'Post Types', 'mb-custom-post-type' ),
},
{
name: 'permissions',
title: __( 'Permissions', 'mb-custom-post-type' ),
},
{
name: 'code',
title: __( 'Get PHP Code', 'mb-custom-post-type' ),
Expand All @@ -42,6 +46,7 @@ const panels = {
general: BasicControls.map( ( field, key ) => <Control key={ key } field={ field } autoFills={ autoFills.filter( f => f.updateFrom === field.name ) } /> ),
labels: LabelControls.map( ( field, key ) => <Control key={ key } field={ field } /> ),
advanced: AdvancedControls.map( ( field, key ) => <Control key={ key } field={ field } /> ),
permissions: PermissionsControls.map( ( field, key ) => <Control key={ key } field={ field } /> ),
types: <CheckboxList name="types" options={ MBCPT.types } description={ __( 'Post types for the taxonomy:', 'mb-custom-post-type' ) } />,
code: (
<>
Expand Down
39 changes: 39 additions & 0 deletions modules/mb-custom-post-type/app/taxonomy/constants/Data.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,42 @@ export const AdvancedControls = [
tooltip: __( 'Whether terms in this taxonomy should be sorted', 'mb-custom-post-type' ),
},
];

export const PermissionsControls = [
{
type: 'text',
name: 'capabilities.manage_terms',
placeholder: 'manage_categories',
label: __( 'Manage terms', 'mb-custom-post-type' ),
description: __( 'The capability required for managing terms.', 'mb-custom-post-type' ),
tooltip: __( 'The capability required for managing terms.', 'mb-custom-post-type' ),
datalist: MBCPT.allCapabilities,
},
{
type: 'text',
name: 'capabilities.edit_terms',
placeholder: 'manage_categories',
label: __( 'Edit terms', 'mb-custom-post-type' ),
description: __( 'The capability required for editing terms.', 'mb-custom-post-type' ),
tooltip: __( 'The capability required for editing terms.', 'mb-custom-post-type' ),
datalist: MBCPT.allCapabilities,
},
{
type: 'text',
name: 'capabilities.delete_terms',
placeholder: 'manage_categories',
label: __( 'Delete terms', 'mb-custom-post-type' ),
description: __( 'The capability required for deleting terms.', 'mb-custom-post-type' ),
tooltip: __( 'The capability required for deleting terms.', 'mb-custom-post-type' ),
datalist: MBCPT.allCapabilities,
},
{
type: 'text',
name: 'capabilities.assign_terms',
placeholder: 'edit_posts',
label: __( 'Assign terms', 'mb-custom-post-type' ),
description: __( 'The capability required for assigning terms.', 'mb-custom-post-type' ),
tooltip: __( 'The capability required for assigning terms.', 'mb-custom-post-type' ),
datalist: MBCPT.allCapabilities,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const DefaultSettings = {
},
query_var : true,
sort : false,
capabilities: {
manage_terms: 'manage_categories',
edit_terms : 'manage_categories',
delete_terms: 'manage_categories',
assign_terms: 'edit_posts',
}
};

export default DefaultSettings;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'a8186c63c3cf6d8671f7');
<?php return array('dependencies' => array('react', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '308089ceac76fff92611');
2 changes: 1 addition & 1 deletion modules/mb-custom-post-type/assets/build/post-type.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '349d300fdb84ab791136');
<?php return array('dependencies' => array('react', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '957c6726d2cd9b091d92');
2 changes: 1 addition & 1 deletion modules/mb-custom-post-type/assets/build/taxonomy.js

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions modules/mb-custom-post-type/src/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private function js_vars(): array {
'modifiedtime' => get_post_modified_time( 'F d, Y g:i a', true, null, true ),
'saving' => __( 'Saving...', 'mb-custom-post-type' ),
'upgrade' => ! $this->is_premium_user(),
'allCapabilities' => $this->get_all_capabilities(),
];

if ( 'mb-post-type' === get_current_screen()->id ) {
Expand Down Expand Up @@ -240,4 +241,13 @@ private function get_reserved_terms() {
'year',
];
}

private function get_all_capabilities() {
global $wp_roles;
$capabilities = [];
foreach ( $wp_roles->roles as $role ) {
$capabilities = array_merge( $capabilities, array_keys( $role['capabilities'] ) );
}
return array_unique( $capabilities );
}
}
3 changes: 2 additions & 1 deletion modules/mb-custom-post-type/src/TaxonomyRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function register() {
],
];

register_post_type( 'mb-taxonomy', $args );
register_post_type( 'mb-taxonomy', $args );

// Get all registered custom taxonomies.
$taxonomies = $this->get_taxonomies();
Expand All @@ -96,6 +96,7 @@ public function register() {
unset( $args['meta_box_cb'] );
}
$types = empty( $args['types'] ) ? [] : $args['types'];

register_taxonomy( $slug, $types, $args );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
return;
}

echo esc_html( $data );
echo wp_kses_post( $data );
14 changes: 7 additions & 7 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,12 @@
"source": {
"type": "git",
"url": "[email protected]:wpmetabox/mb-custom-post-type.git",
"reference": "b2feb619f1d368863dee04c8e4b29c866689d93b"
"reference": "11c1a2b8e897812435eecfb049371bdc8965f69f"
},
"require": {
"meta-box/support": "dev-master"
},
"time": "2024-11-19T04:36:46+00:00",
"time": "2024-12-25T09:00:31+00:00",
"default-branch": true,
"type": "wordpress-plugin",
"installation-source": "source",
Expand Down Expand Up @@ -637,15 +637,15 @@
"source": {
"type": "git",
"url": "https://github.com/wpmetabox/mb-elementor-integrator.git",
"reference": "d9b335792c49d5d70abe570f711ba8ca8d034f8f"
"reference": "0f1740d7f79c6d618275f8e1fff2b87e26c6ede3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wpmetabox/mb-elementor-integrator/zipball/d9b335792c49d5d70abe570f711ba8ca8d034f8f",
"reference": "d9b335792c49d5d70abe570f711ba8ca8d034f8f",
"url": "https://api.github.com/repos/wpmetabox/mb-elementor-integrator/zipball/0f1740d7f79c6d618275f8e1fff2b87e26c6ede3",
"reference": "0f1740d7f79c6d618275f8e1fff2b87e26c6ede3",
"shasum": ""
},
"time": "2024-11-01T03:00:33+00:00",
"time": "2025-01-07T14:10:08+00:00",
"default-branch": true,
"type": "wordpress-plugin",
"installation-source": "dist",
Expand Down Expand Up @@ -678,7 +678,7 @@
],
"support": {
"issues": "https://github.com/wpmetabox/mb-elementor-integrator/issues",
"source": "https://github.com/wpmetabox/mb-elementor-integrator/tree/2.2.2"
"source": "https://github.com/wpmetabox/mb-elementor-integrator/tree/master"
},
"install-path": "../../modules/mb-elementor-integrator"
},
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
'wpmetabox/mb-custom-post-type' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'b2feb619f1d368863dee04c8e4b29c866689d93b',
'reference' => '11c1a2b8e897812435eecfb049371bdc8965f69f',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../modules/mb-custom-post-type',
'aliases' => array(
Expand All @@ -162,7 +162,7 @@
'wpmetabox/mb-elementor-integrator' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'd9b335792c49d5d70abe570f711ba8ca8d034f8f',
'reference' => '0f1740d7f79c6d618275f8e1fff2b87e26c6ede3',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../modules/mb-elementor-integrator',
'aliases' => array(
Expand Down

0 comments on commit bda7e82

Please sign in to comment.