Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
open-source
hacklab-blocks
Commits
7187ee66
Commit
7187ee66
authored
2 years ago
by
Bruno Antunes Magrini
Browse files
Options
Download
Email Patches
Plain Diff
limpeza de arquivos não utilizados
parent
d954d6f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
47 deletions
+15
-47
blocks/post-meta/edit.js
blocks/post-meta/edit.js
+11
-20
blocks/post-meta/post-meta.php
blocks/post-meta/post-meta.php
+4
-27
No files found.
blocks/post-meta/edit.js
View file @
7187ee66
...
...
@@ -3,36 +3,27 @@
*/
import
classnames
from
'
classnames
'
;
import
{
unescape
}
from
'
lodash
'
;
import
ServerSideRender
from
'
@wordpress/server-side-render
'
;
/**
* WordPress dependencies
*/
import
{
AlignmentToolbar
,
InspectorControls
,
BlockControls
,
useBlockProps
,
ColorPalette
,
}
from
'
@wordpress/block-editor
'
;
import
{
Spinner
,
TextControl
,
ToggleControl
,
RangeControl
,
Panel
,
PanelBody
,
SelectControl
,
FormTokenField
}
from
'
@wordpress/components
'
;
import
{
useSelect
}
from
'
@wordpress/data
'
;
import
{
__
}
from
'
@wordpress/i18n
'
;
import
{
store
as
coreStore
}
from
'
@wordpress/core-data
'
;
import
ServerSideRender
from
'
@wordpress/server-side-render
'
;
/**
* Internal dependencies
*/
import
usePostTerms
from
'
./use-post-terms
'
;
export
default
function
Edit
(
props
)
{
const
attributes
=
props
.
attributes
;
...
...
@@ -40,7 +31,6 @@ export default function Edit(props) {
const
setAttributes
=
props
.
setAttributes
;
const
{
separator
,
selectedMeta
}
=
attributes
;
const
{
postId
,
postType
}
=
context
;
const
ctaxblock
=
window
.
ctaxblock
const
hasPost
=
postId
&&
postType
;
const
blockProps
=
useBlockProps
({
...
...
@@ -48,15 +38,9 @@ export default function Edit(props) {
}),
});
// if (!hasPost || !term) {
// return <div {...blockProps}>{__('Post Terms')}</div>;
// }
return
(
<
div
{...
useBlockProps
()}
>
<
BlockControls
>
<
div
{
...
useBlockProps
()
}
>
<
/BlockControls
>
<
InspectorControls
key
=
"
setting
"
>
<
Panel
>
<
PanelBody
title
=
{
__
(
'
Configurações do bloco
'
)}
>
...
...
@@ -80,7 +64,14 @@ export default function Edit(props) {
<
/PanelBody
>
<
/Panel
>
<
/InspectorControls
>
PostMeta
<
/div
>
<
div
className
=
"
configBlock
"
>
<
header
><
p
>
PostMeta
<
/p></
header
>
<
ServerSideRender
block
=
"
hacklab-blocks/post-meta
"
attributes
=
{
attributes
}
/
>
<
/div
>
<
/div
>
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
blocks/post-meta/post-meta.php
View file @
7187ee66
...
...
@@ -19,49 +19,26 @@ namespace hacklabBlocks;
add_action
(
'admin_enqueue_scripts'
,
'hacklabBlocks\\post_meta_admin_enqueue'
);
function
post_meta_admin_enqueue
()
{
$args
=
array
(
'public'
=>
true
,
);
$taxonomies
=
get_taxonomies
(
$args
,
'objects'
);
$tax_per_pt
=
[];
foreach
(
$taxonomies
as
$taxonomy
)
{
$post_types
=
$taxonomy
->
object_type
;
foreach
(
$post_types
as
$post_type
)
{
if
(
!
isset
(
$tax_per_pt
[
$post_type
]))
{
$tax_per_pt
[
$post_type
]
=
[];
}
$tax_per_pt
[
$post_type
][]
=
$taxonomy
->
name
;
}
}
wp_localize_script
(
'hacklab-blocks-post-meta-editor-script'
,
'ctaxblock'
,
[
'taxonomies'
=>
$taxonomies
,
'taxPerPt'
=>
$tax_per_pt
]);
}
function
post_meta_callback
(
$attributes
,
$content
,
$block
)
{
if
(
!
isset
(
$block
->
context
[
'postId'
])
||
!
isset
(
$attributes
[
'selectedMeta'
]))
{
return
''
;
}
$classes
=
''
;
$metadata
=
[];
foreach
(
$attributes
[
'selectedMeta'
]
as
$meta
)
{
$metadata
[]
=
get_post_meta
(
$block
->
context
[
'postId'
],
$meta
,
true
);
}
$html
=
''
;
if
(
count
(
$metadata
)){
$html
.
=
'<div class="post-meta">'
;
if
(
!
empty
(
$metadata
[
0
]
)){
$html
.
=
'<div class="
hacklab-
post-meta
-block
">'
;
$separator
=
empty
(
$attributes
[
'separator'
])
?
' '
:
$attributes
[
'separator'
];
$html_array
=
[];
foreach
(
$metadata
as
$meta
)
{
$html_array
[]
=
$meta
;
}
$html
=
implode
(
$separator
,
$html_array
);
$html
.
=
'</div>'
;
$html
.
=
implode
(
$separator
,
$html_array
);
$html
.
=
'</div>
<!--"hacklab-post-meta-block"-->
'
;
}
return
$html
;
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment