Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
External Permalinks Redux
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
External Permalinks Redux
Commits
f0fdf6a8
Commit
f0fdf6a8
authored
2 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Allow meta to be edited via REST API
parent
744cbf7c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!14
Add native block-editor support
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
assets/src/js/panel-body.js
+3
-3
3 additions, 3 deletions
assets/src/js/panel-body.js
inc/class-external-permalinks-redux-block-editor.php
+24
-0
24 additions, 0 deletions
inc/class-external-permalinks-redux-block-editor.php
with
27 additions
and
3 deletions
assets/src/js/panel-body.js
+
3
−
3
View file @
f0fdf6a8
...
@@ -22,16 +22,16 @@ const View = ( { setTarget, setType, target, type } ) => {
...
@@ -22,16 +22,16 @@ const View = ( { setTarget, setType, target, type } ) => {
'
To restore the original permalink, remove the link entered above.
'
,
'
To restore the original permalink, remove the link entered above.
'
,
'
external-permalinks-redux
'
'
external-permalinks-redux
'
)
}
)
}
onChange
=
{
setTarget
}
type
=
"
url
"
type
=
"
url
"
value
=
{
target
}
value
=
{
target
}
onChange
=
{
setTarget
}
/
>
/
>
<
SelectControl
<
SelectControl
label
=
{
__
(
'
Redirect Type:
'
,
'
external-permalinks-redux
'
)
}
label
=
{
__
(
'
Redirect Type:
'
,
'
external-permalinks-redux
'
)
}
options
=
{
statusCodes
}
selected
=
{
type
}
onChange
=
{
setType
}
onChange
=
{
setType
}
options
=
{
statusCodes
}
value
=
{
type
}
/
>
/
>
<
/
>
<
/
>
);
);
...
...
This diff is collapsed.
Click to expand it.
inc/class-external-permalinks-redux-block-editor.php
+
24
−
0
View file @
f0fdf6a8
...
@@ -42,6 +42,7 @@ class External_Permalinks_Redux_Block_Editor {
...
@@ -42,6 +42,7 @@ class External_Permalinks_Redux_Block_Editor {
*/
*/
protected
function
_setup
()
{
protected
function
_setup
()
{
add_action
(
'rest_api_init'
,
array
(
$this
,
'register_meta'
)
);
add_action
(
'rest_api_init'
,
array
(
$this
,
'register_meta'
)
);
add_filter
(
'is_protected_meta'
,
array
(
$this
,
'allow_meta_updates'
),
10
,
3
);
add_action
(
'enqueue_block_editor_assets'
,
array
(
$this
,
'enqueue'
)
);
add_action
(
'enqueue_block_editor_assets'
,
array
(
$this
,
'enqueue'
)
);
}
}
...
@@ -93,6 +94,29 @@ class External_Permalinks_Redux_Block_Editor {
...
@@ -93,6 +94,29 @@ class External_Permalinks_Redux_Block_Editor {
);
);
}
}
/**
* Allow meta updates from REST API.
*
* @param bool $protected Whether meta is protected or not.
* @param string $meta_key Meta key.
* @param string $meta_type Meta key type.
* @return bool
*/
public
function
allow_meta_updates
(
$protected
,
$meta_key
,
$meta_type
)
{
if
(
'post'
!==
$meta_type
)
{
return
$protected
;
}
if
(
$meta_key
===
external_permalinks_redux
::
get_instance
()
->
meta_key_target
||
$meta_key
===
external_permalinks_redux
::
get_instance
()
->
meta_key_type
)
{
return
false
;
}
return
$protected
;
}
/**
/**
* Enqueue block-editor script.
* Enqueue block-editor script.
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment