|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Widget class for Custom widget |
|
4
|
|
|
* |
|
5
|
|
|
* extends WP_Widget WordPress class and overrides necessary functions |
|
6
|
|
|
* for necessary functionality of the widget |
|
7
|
|
|
* |
|
8
|
|
|
* @package DesignFly |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
class Designfly_Portfolio_Widget extends WP_Widget { |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
// setup the widget name, description, etc... |
|
14
|
|
|
public function __construct() { |
|
15
|
|
|
|
|
16
|
|
|
$widget_ops = array( |
|
17
|
|
|
'classname' => 'designfly_portfolio_widget', // html class name |
|
18
|
|
|
'description' => esc_html__( 'Custom DesignFly Portfolio Widget', 'designfly' ) |
|
|
|
|
|
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
parent::__construct( 'designfly_portfolio', 'Designfly Portfolio', $widget_ops ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
// handles the back-end of the widget(rendering) |
|
25
|
|
|
public function form( $instance ) { |
|
26
|
|
|
if ( isset( $instance[ 'title' ] ) ) { |
|
27
|
|
|
$title = $instance[ 'title' ]; |
|
28
|
|
|
} else { |
|
29
|
|
|
$title = 'Portfolio'; |
|
30
|
|
|
} |
|
31
|
|
|
?> |
|
32
|
|
|
<p> |
|
33
|
|
|
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title' ); ?>:</label> |
|
|
|
|
|
|
34
|
|
|
<input class="widget_portfolio_title" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> |
|
|
|
|
|
|
35
|
|
|
</p> |
|
36
|
|
|
<?php |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
// handles the front-end of the widget |
|
40
|
|
|
public function widget( $args, $instance ) { |
|
41
|
|
|
echo $args[ 'before_widget' ]; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* render out portfolio items |
|
45
|
|
|
*/ |
|
46
|
|
|
$query = new WP_Query( array( |
|
|
|
|
|
|
47
|
|
|
'post_type' => 'df-portfolio', |
|
48
|
|
|
'posts_per_page' => 8, |
|
49
|
|
|
) |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
if ( $query -> have_posts() ): |
|
53
|
|
|
?> |
|
54
|
|
|
<h2 class="widget-title"> |
|
55
|
|
|
<?php |
|
56
|
|
|
if ( isset( $instance[ 'title' ] ) ) { |
|
57
|
|
|
$title = $instance[ 'title' ]; |
|
58
|
|
|
} else { |
|
59
|
|
|
$title = 'Portfolio'; |
|
60
|
|
|
} |
|
61
|
|
|
echo $title; |
|
62
|
|
|
?> |
|
63
|
|
|
</h2> |
|
64
|
|
|
<div id="portfolio-widget-wrapper"> |
|
65
|
|
|
|
|
66
|
|
|
<?php |
|
67
|
|
|
while ( $query -> have_posts() ): |
|
68
|
|
|
$query -> the_post(); |
|
69
|
|
|
get_template_part( 'template-parts/content', 'df-portfolio' ); |
|
|
|
|
|
|
70
|
|
|
endwhile; |
|
71
|
|
|
?> |
|
72
|
|
|
</div> |
|
73
|
|
|
|
|
74
|
|
|
<?php |
|
75
|
|
|
else: |
|
76
|
|
|
?> |
|
77
|
|
|
<p> |
|
78
|
|
|
<?php _e( 'Sorry, no portfolio items found.', 'textdomain' ); ?> |
|
|
|
|
|
|
79
|
|
|
</p> |
|
80
|
|
|
<?php |
|
81
|
|
|
endif; |
|
82
|
|
|
|
|
83
|
|
|
// done rendering |
|
84
|
|
|
|
|
85
|
|
|
echo $args[ 'after_widget' ]; |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
add_action( 'widgets_init', function() { |
|
|
|
|
|
|
90
|
|
|
register_widget( 'Designfly_Portfolio_Widget' ); |
|
|
|
|
|
|
91
|
|
|
} ); |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths