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
Guaraci WordPress Plugin
Commits
9971e852
Commit
9971e852
authored
5 years ago
by
Bruno Antunes Magrini
Browse files
Options
Download
Email Patches
Plain Diff
add new fields and add conditionals to show images and excerpts
parent
49fe62a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
32 deletions
+60
-32
pagebuilder-components/widgets/posts-list/posts-list.php
pagebuilder-components/widgets/posts-list/posts-list.php
+34
-12
pagebuilder-components/widgets/posts-list/tpl/template.php
pagebuilder-components/widgets/posts-list/tpl/template.php
+26
-20
No files found.
pagebuilder-components/widgets/posts-list/posts-list.php
View file @
9971e852
...
...
@@ -11,28 +11,50 @@ namespace widgets;
class
PostsList
extends
\
SiteOrigin_Widget
{
function
__construct
()
{
$css_classes
=
[
'featured'
=>
__
(
'Destaque'
,
'guaraci'
),
'horizontal-list'
=>
__
(
'Lista horizontal'
,
'guaraci'
),
'vertical-list'
=>
__
(
'Lista vertical'
,
'guaraci'
),
];
$css_classes
=
apply_filters
(
__CLASS__
.
':'
.
'css_classes'
,
$css_classes
);
$fields
=
[
'
exibicao
'
=>
[
'
css_class
'
=>
[
'type'
=>
'select'
,
'label'
=>
__
(
'Exibição'
,
'guaraci'
),
'options'
=>
[
'featured'
=>
__
(
'Destaque'
,
'guaraci'
),
'block'
=>
__
(
'Bloco'
,
'guaraci'
),
'list'
=>
__
(
'List'
,
'guaraci'
),
]
'label'
=>
__
(
'Selecione o estilo do título'
,
'guaraci'
),
'default'
=>
'featured'
,
'options'
=>
$css_classes
],
'columns'
=>
[
'type'
=>
'number'
,
'label'
=>
__
(
'Cards por linha'
,
'guaraci'
),
'default'
=>
'1'
],
'hide_
imag
es'
=>
[
'hide_
categori
es'
=>
[
'type'
=>
'checkbox'
,
'label'
=>
__
(
'Não exibir
imagem
'
,
'guaraci'
),
'label'
=>
__
(
'Não exibir
categorias
'
,
'guaraci'
),
],
'hide_excerpt'
=>
[
'type'
=>
'checkbox'
,
'label'
=>
__
(
'Não resumo'
,
'guaraci'
),
'show_images'
=>
[
'type'
=>
'radio'
,
'label'
=>
__
(
'Exibição de imagens'
,
'guaraci'
),
'default'
=>
'show_images'
,
'options'
=>
[
'all_images'
=>
__
(
'Mostrar todas'
,
'guaraci'
),
'first_image'
=>
__
(
'Mostrar a primeira'
,
'guaraci'
),
'hide_images'
=>
__
(
'Esconder as imagens'
,
'guaraci'
)
]
],
'show_excerpt'
=>
[
'type'
=>
'radio'
,
'label'
=>
__
(
'Exibição de Resumo'
,
'guaraci'
),
'default'
=>
'show_all'
,
'options'
=>
[
'all_excerpts'
=>
__
(
'Mostrar todos'
,
'guaraci'
),
'first_excerpt'
=>
__
(
'Mostrar o primeiro'
,
'guaraci'
),
'hide_excerpt'
=>
__
(
'Esconder resumos'
,
'guaraci'
)
]
],
'link'
=>
[
'type'
=>
'section'
,
...
...
This diff is collapsed.
Click to expand it.
pagebuilder-components/widgets/posts-list/tpl/template.php
View file @
9971e852
<?php
use
guaraci\images
;
$hide_images
=
$instance
[
'hide_images'
]
==
'on'
;
$show_images
=
$instance
[
'show_images'
];
$show_excerpt
=
$instance
[
'show_excerpt'
];
$hide_categories
=
$instance
[
'hide_categories'
];
$horizontal
=
$instance
[
'horizontal'
]
==
'off'
;
$is_block
=
$instance
[
'exibicao'
]
==
'block'
;
$estilo
=
$instance
[
'estilo'
]
==
'featured'
;
$query
=
new
WP_Query
(
$query_args
);
$i
=
0
;
?>
<div
class=
"posts-list
<?=
$hide_images
?
'hide-images'
:
''
?>
<?=
$instance
[
'e
xibica
o'
]
?>
"
>
<div
class=
"posts-list
<?=
$hide_images
?
'hide-images'
:
''
?>
<?=
$instance
[
'e
stil
o'
]
?>
"
>
<div
class=
"row"
>
<?php
while
(
$query
->
have_posts
())
:
...
...
@@ -15,33 +20,34 @@ $i = 0;
$img_tag
=
images
::
tag
(
'card-large'
,
'card--image'
);
?>
<div
class=
"column large-
<?=
12
/
$instance
[
'columns'
]
?>
mb-15"
>
<div
class=
"card"
>
<?php
if
(
!
$hide_images
&&
$img_tag
!=
''
&&
(
(
$i
==
1
&&
$is_block
)
||
!
$is_block
)
)
:
?>
<div
class=
"card
<?=
$horizontal
?
'horizontal'
:
''
?>
"
>
<?php
if
(
$img_tag
!=
''
&&
(
$show_images
==
'all_images'
||
(
$show_images
==
'first_image'
&&
$i
==
1
)
)
)
:
?>
<a
tabindex=
"-1"
href=
"
<?=
get_the_permalink
()
?>
"
class=
"card--image-wrapper"
>
<?=
$img_tag
?>
</a>
</a>
<?php
endif
;
?>
<div
class=
"card--content"
>
<div
class=
"categories-list"
>
<?php
$post_categories
=
wp_get_post_categories
(
get_the_ID
()
);
foreach
(
$post_categories
as
$category_id
){
$category
=
get_category
(
$category_id
);
<?php
if
(
(
!
$hide_categories
)
:
?>
<div
class=
"categories-list"
>
<?php
$post_categories
=
wp_get_post_categories
(
get_the_ID
()
);
foreach
(
$post_categories
as
$category_id
){
$category
=
get_category
(
$category_id
);
?>
<div
class=
"categories-list--category category-
<?=
$category
->
slug
?>
"
>
<a
href=
"
<?=
esc_url
(
get_term_link
(
$category
,
'category'
))
?>
"
>
<?=
$category
->
name
?>
</a>
</div>
<?php
}
?>
<div
class=
"categories-list--category category-
<?=
$category
->
slug
?>
"
>
<a
href=
"
<?=
esc_url
(
get_term_link
(
$category
,
'category'
))
?>
"
>
<?=
$category
->
name
?>
</a>
</div>
<?php
}
?>
</div>
</div>
<?php
endif
;
?>
<h4
class=
"card--title"
>
<a
href=
"
<?=
get_the_permalink
()
?>
"
>
<?php
the_title
()
?>
</a>
</h4>
<?php
if
(
has_excerpt
()
&&
$instance
[
'hide_excerpt'
]
!=
'on'
)
:
?>
<?php
if
(
(
$show_excerpt
==
'all_excerpts'
||
(
$hide_images
==
'first_excerpt'
&&
$i
==
1
)
)
)
:
?>
<div
class=
"card-excerpt"
>
<?php
the_excerpt
()
?>
</div>
<?php
endif
;
?>
</div>
...
...
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