Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Guaraci WordPress Plugin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
Guaraci WordPress Plugin
Commits
1ebd9c62
Commit
1ebd9c62
authored
Jan 27, 2020
by
Bruno Antunes Magrini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move functions from template to widget php file
parent
057a6d9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
22 deletions
+16
-22
pagebuilder-components/widgets/most-read-posts-list/most-read-posts-list.php
...nts/widgets/most-read-posts-list/most-read-posts-list.php
+14
-4
pagebuilder-components/widgets/most-read-posts-list/tpl/template.php
...-components/widgets/most-read-posts-list/tpl/template.php
+2
-18
No files found.
pagebuilder-components/widgets/most-read-posts-list/most-read-posts-list.php
View file @
1ebd9c62
...
...
@@ -12,15 +12,25 @@ if(!class_exists('\\AjaxPageviews')){
}
class
MostReadPostsList
extends
PostsList
{
function
__construct
()
{
parent
::
__construct
(
false
);
$fields
=
$this
->
fields
;
parent
::
__construct
(
'most-read-posts-list'
,
'Lista de posts Mais lidos'
,
''
,
''
,
''
,
plugin_dir_path
(
__FILE__
));
}
function
get_template_variables
(
$instance
,
$args
)
{
if
(
isset
(
$instance
[
'conteudo'
]))
{
parse_str
(
$instance
[
'conteudo'
],
$conteudo
);
$date
=
json_decode
(
$conteudo
[
'date_query'
]);
}
$posts_query_args
=
siteorigin_widget_post_selector_process_query
(
$instance
[
'conteudo'
]);
$most_read
=
\AjaxPageviews
::
get_top_viewed
(
1000
,
[
'post_type'
=>
$conteudo
[
'post_type'
],
'from'
=>
$date
->
after
]);
$ids
=
array
();
foreach
(
$most_read
as
$post
=>
$value
)
{
array_push
(
$ids
,
$value
->
post_id
);
}
$posts_query_args
[
'post__in'
]
=
$ids
;
$posts_query_args
[
'orderby'
]
=
'post__in'
;
$most_read_query
=
new
\WP_Query
(
$posts_query_args
);
return
[
'query
_args'
=>
$posts_query_args
,
'link'
=>
(
object
)
$instance
[
'link'
]
'query
'
=>
$most_read_query
,
'link'
=>
(
object
)
$instance
[
'link'
]
];
}
}
...
...
pagebuilder-components/widgets/most-read-posts-list/tpl/template.php
View file @
1ebd9c62
...
...
@@ -4,23 +4,7 @@ $show_images = $instance['show_images'];
$show_excerpt
=
$instance
[
'show_excerpt'
];
$hide_categories
=
$instance
[
'hide_categories'
];
$css_classes
=
$instance
[
'css_class'
];
$link
=
$instance
[
'link'
];
if
(
isset
(
$instance
[
'conteudo'
]))
{
parse_str
(
$instance
[
'conteudo'
],
$conteudo
);
$date
=
json_decode
(
$conteudo
[
'date_query'
]);
}
$i
=
0
;
$most_read
=
AjaxPageviews
::
get_top_viewed
(
1000
,
[
'post_type'
=>
$conteudo
[
'post_type'
],
'from'
=>
$date
->
after
]);
$ids
=
array
();
foreach
(
$most_read
as
$post
=>
$value
)
{
array_push
(
$ids
,
$value
->
post_id
);
}
$query_args
[
'post__in'
]
=
$ids
;
$query_args
[
'orderby'
]
=
'post__in'
;
$query
=
new
WP_Query
(
$query_args
);
?>
<div
class=
"posts-list
<?=
$css_classes
?>
"
>
<div
class=
"row"
>
...
...
@@ -70,9 +54,9 @@ $query = new WP_Query($query_args);
wp_reset_postdata
();
?>
</div>
<?php
if
(
$link
[
'url'
]
)
:
?>
<?php
if
(
$link
->
url
)
:
?>
<div
class=
"read-more"
>
<a
class=
"read-more-link"
href=
"
<?=
$link
[
'url'
]
?>
"
class=
"goto"
>
<?=
$link
[
'label'
]
?>
</a>
<a
class=
"read-more-link"
href=
"
<?=
$link
->
url
?>
"
class=
"goto"
>
<?=
$link
->
label
?>
</a>
</div>
<?php
endif
;
?>
</div>
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