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
f87415f6
Commit
f87415f6
authored
5 years ago
by
Isaque Melo
Browse files
Options
Download
Email Patches
Plain Diff
adiciona cache
parent
9240c4fa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
7 deletions
+11
-7
pagebuilder-components/widgets/featured-videos/tpl/template.php
...ilder-components/widgets/featured-videos/tpl/template.php
+11
-7
No files found.
pagebuilder-components/widgets/featured-videos/tpl/template.php
100644 → 100755
View file @
f87415f6
...
...
@@ -10,16 +10,19 @@ if($instance['youtube_list'] == 'playlist'){
$url
=
"https://www.googleapis.com/youtube/v3/search?key=
{
$api_key
}
&channelId=
{
$list_id
}
&maxResults=
{
$num
}
&part=snippet,id&order=date"
;
}
$cache_key
=
__FILE__
.
':'
.
$url
;
if
(
apcu_exists
(
$cache_key
)){
$result
=
apcu_fetch
(
$cache_key
);
}
else
{
$cache_key
=
"featured-videos:"
.
md5
(
$url
);
if
(
!
(
$result
=
wp_cache_get
(
$cache_key
))){
$result
=
json_decode
(
file_get_contents
(
$url
));
apcu_store
(
$cache_key
,
$result
,
300
);
if
(
is_object
(
$result
)
&&
!
$result
->
error
){
wp_cache_add
(
$cache_key
,
$result
,
''
,
30
*
MINUTE_IN_SECONDS
);
}
else
{
$result
=
(
object
)
[
'items'
=>
[]];
wp_cache_add
(
$cache_key
,
$result
,
''
,
3
*
MINUTE_IN_SECONDS
);
}
}
if
(
!
is_object
(
$result
)
||
count
(
$result
->
items
)
===
0
)
{
$
re
sult
=
(
object
)
[
'items'
=>
[]]
;
if
(
!
$result
->
items
){
re
turn
;
}
$extract_vid
=
function
(
$video
){
...
...
@@ -29,6 +32,7 @@ $extract_vid = function($video){
return
$video
->
id
->
videoId
;
}
};
?>
<div
class=
"custom-so-widget alignfull featured-videos"
>
...
...
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