|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the WordPress Standard project. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (c) 2015-2016 LIN3S <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace AppTheme\Widgets; |
|
13
|
|
|
|
|
14
|
|
|
use LIN3S\WPFoundation\Widgets\Widget; |
|
15
|
|
|
use Timber\Timber; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Social network widget. Is fully manageable inside Wordpress administrator panel. |
|
19
|
|
|
* This is a little pretty example that you can do extending WPFoundation's Widget class. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Gorka Laucirica <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
final class SocialNetworksWidget extends Widget |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* {@inheritdoc} |
|
27
|
|
|
*/ |
|
28
|
|
|
public function widget($args, $instance) |
|
29
|
|
|
{ |
|
30
|
|
|
$data = [ |
|
31
|
|
|
'beforeWidget' => $args['before_widget'], |
|
32
|
|
|
'afterWidget' => $args['after_widget'], |
|
33
|
|
|
'beforeTitle' => $args['before_title'], |
|
34
|
|
|
'afterTitle' => $args['after_title'], |
|
35
|
|
|
'twitterUrl' => (!empty($instance['twitterUrl'])) ? strip_tags($instance['twitterUrl']) : '', |
|
36
|
|
|
'facebookUrl' => (!empty($instance['facebookUrl'])) ? strip_tags($instance['facebookUrl']) : '', |
|
37
|
|
|
'pinterestUrl' => (!empty($instance['pinterestUrl'])) ? strip_tags($instance['pinterestUrl']) : '', |
|
38
|
|
|
'youtubeUrl' => (!empty($instance['youtubeUrl'])) ? strip_tags($instance['youtubeUrl']) : '', |
|
39
|
|
|
'rssUrl' => (!empty($instance['rssUrl'])) ? strip_tags($instance['rssUrl']) : '', |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
|
|
return Timber::render('widgets/front/socialNetworks.twig', $data); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* {@inheritdoc} |
|
47
|
|
|
*/ |
|
48
|
|
|
public function form($instance) |
|
49
|
|
|
{ |
|
50
|
|
|
$instance['widgetNumber'] = $this->number(); |
|
51
|
|
|
$instance['widgetName'] = $this->name(); |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
return Timber::render('widgets/admin/socialNetworks.twig', $instance); |
|
|
|
|
|
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* {@inheritdoc} |
|
58
|
|
|
*/ |
|
59
|
|
|
public function update($newInstance) |
|
60
|
|
|
{ |
|
61
|
|
|
$instance = [ |
|
62
|
|
|
'twitterUrl' => (!empty($newInstance['twitterUrl'])) ? strip_tags($newInstance['twitterUrl']) : '', |
|
63
|
|
|
'facebookUrl' => (!empty($newInstance['facebookUrl'])) ? strip_tags($newInstance['facebookUrl']) : '', |
|
64
|
|
|
'pinterestUrl' => (!empty($newInstance['pinterestUrl'])) ? strip_tags($newInstance['pinterestUrl']) : '', |
|
65
|
|
|
'youtubeUrl' => (!empty($newInstance['youtubeUrl'])) ? strip_tags($newInstance['youtubeUrl']) : '', |
|
66
|
|
|
'rssUrl' => (!empty($newInstance['rssUrl'])) ? strip_tags($newInstance['rssUrl']) : '', |
|
67
|
|
|
]; |
|
68
|
|
|
|
|
69
|
|
|
return $instance; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
|
|
|
|
|
72
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: