1
1
<?php
2
2
if ( ! class_exists ( 'Higgs_Portfolio ' ) ) :
3
- /**
4
- * Displays recent portfolio posts.
5
- *
6
- * @since 1.0.0.
7
- * @package Higgs
8
- */
9
- class Higgs_Portfolio extends Stag_Widget {
10
- public function __construct () {
11
- $ this ->widget_id = 'higgs_portfolio ' ;
12
- $ this ->widget_cssclass = 'section-portfolio ' ;
13
- $ this ->widget_description = __ ( 'Display recent portfolio post in grid style. ' , 'higgs-assistant ' );
14
- $ this ->widget_name = __ ( 'Section: Portfolio ' , 'higgs-assistant ' );
15
- $ this ->settings = array (
16
- 'title ' => array (
17
- 'type ' => 'text ' ,
18
- 'std ' => '' ,
19
- 'label ' => __ ( 'Title: ' , 'higgs-assistant ' ),
20
- ),
21
- 'orderby ' => array (
22
- 'type ' => 'select ' ,
23
- 'std ' => 'post_date ' ,
24
- 'label ' => __ ( 'Sort by: ' , 'higgs-assistant ' ),
25
- 'options ' => array (
26
- 'post_date ' => __ ( 'Date ' , 'higgs-assistant ' ),
27
- 'title ' => __ ( 'Title ' , 'higgs-assistant ' ),
28
- 'rand ' => __ ( 'Random ' , 'higgs-assistant ' ),
3
+ /**
4
+ * Displays recent portfolio posts.
5
+ *
6
+ * @since 1.0.0.
7
+ * @package Higgs
8
+ */
9
+ class Higgs_Portfolio extends Stag_Widget {
10
+ public function __construct () {
11
+ $ this ->widget_id = 'higgs_portfolio ' ;
12
+ $ this ->widget_cssclass = 'section-portfolio ' ;
13
+ $ this ->widget_description = __ ( 'Display recent portfolio post in grid style. ' , 'higgs-assistant ' );
14
+ $ this ->widget_name = __ ( 'Section: Portfolio ' , 'higgs-assistant ' );
15
+ $ this ->settings = array (
16
+ 'title ' => array (
17
+ 'type ' => 'text ' ,
18
+ 'std ' => '' ,
19
+ 'label ' => __ ( 'Title: ' , 'higgs-assistant ' ),
29
20
),
30
- ),
31
- 'number ' => array (
32
- 'type ' => 'number ' ,
33
- 'std ' => '6 ' ,
34
- 'label ' => __ ( 'Count: ' , 'higgs-assistant ' ),
35
- 'step ' => '1 ' ,
36
- 'min ' => '1 ' ,
37
- 'max ' => '20 ' ,
38
- ),
39
- 'more_text ' => array (
40
- 'type ' => 'text ' ,
41
- 'std ' => __ ( 'View all Posts ' , 'higgs-assistant ' ),
42
- 'label ' => __ ( 'More Posts text: ' , 'higgs-assistant ' ),
43
- ),
44
- );
45
-
46
- parent ::__construct ();
47
- }
21
+ 'orderby ' => array (
22
+ 'type ' => 'select ' ,
23
+ 'std ' => 'post_date ' ,
24
+ 'label ' => __ ( 'Sort by: ' , 'higgs-assistant ' ),
25
+ 'options ' => array (
26
+ 'post_date ' => __ ( 'Date ' , 'higgs-assistant ' ),
27
+ 'title ' => __ ( 'Title ' , 'higgs-assistant ' ),
28
+ 'rand ' => __ ( 'Random ' , 'higgs-assistant ' ),
29
+ ),
30
+ ),
31
+ 'number ' => array (
32
+ 'type ' => 'number ' ,
33
+ 'std ' => '6 ' ,
34
+ 'label ' => __ ( 'Count: ' , 'higgs-assistant ' ),
35
+ 'step ' => '1 ' ,
36
+ 'min ' => '1 ' ,
37
+ 'max ' => '20 ' ,
38
+ ),
39
+ 'more_text ' => array (
40
+ 'type ' => 'text ' ,
41
+ 'std ' => __ ( 'View all Posts ' , 'higgs-assistant ' ),
42
+ 'label ' => __ ( 'More Posts text: ' , 'higgs-assistant ' ),
43
+ ),
44
+ );
45
+
46
+ parent ::__construct ();
47
+ }
48
48
49
- function widget ( $ args , $ instance ) {
50
- if ( $ this ->get_cached_widget ( $ args ) )
51
- return ;
49
+ function widget ( $ args , $ instance ) {
50
+ if ( $ this ->get_cached_widget ( $ args ) ) {
51
+ return ;
52
+ }
52
53
53
- ob_start ();
54
+ ob_start ();
54
55
55
- extract ( $ args );
56
+ extract ( $ args );
56
57
57
- $ title = apply_filters ( 'widget_title ' , $ instance ['title ' ], $ instance , $ this ->id_base );
58
- $ orderby = $ instance ['orderby ' ];
59
- $ number = absint ( $ instance ['number ' ] );
60
- $ more_text = strip_tags ( $ instance ['more_text ' ] );
58
+ $ title = apply_filters ( 'widget_title ' , $ instance ['title ' ], $ instance , $ this ->id_base );
59
+ $ orderby = $ instance ['orderby ' ];
60
+ $ number = absint ( $ instance ['number ' ] );
61
+ $ more_text = wp_strip_all_tags ( $ instance ['more_text ' ] );
61
62
62
- echo $ before_widget ;
63
+ echo $ before_widget ;
63
64
64
- $ link = get_post_type_archive_link ( 'jetpack-portfolio ' );
65
+ $ link = get_post_type_archive_link ( 'jetpack-portfolio ' );
65
66
66
- if ( $ title ) :
67
- echo $ before_title ;
68
- echo $ title ;
69
- if ( '' != $ link ) : ?>
67
+ if ( $ title ) :
68
+ echo $ before_title ;
69
+ echo $ title ;
70
+ if ( '' != = $ link ) : ?>
70
71
<span class="custom-link">
71
72
<a href="<?php echo esc_url ( $ link ); ?> "><?php echo esc_html ( $ more_text ); ?> <span class="genericon genericon-next"></span></a>
72
73
</span>
73
- <?php endif ;
74
- echo $ after_title ;
75
- endif ;
76
-
77
- add_filter ( 'subtitle_view_supported ' , '__return_false ' );
78
-
79
- $ p = new WP_Query ( apply_filters ( 'higgs_portfolio_args ' , array (
80
- 'post_type ' => 'jetpack-portfolio ' ,
81
- 'post_status ' => 'publish ' ,
82
- 'orderby ' => $ orderby ,
83
- 'posts_per_page ' => $ number ,
84
- 'no_found_rows ' => true ,
85
- 'ignore_sticky_posts ' => true ,
86
- 'meta_query ' => array ( array ( 'key ' => '_thumbnail_id ' ) ),
87
- ) ) );
88
-
89
- if ( $ p ->have_posts () ) : ?>
74
+ <?php
75
+ endif ;
76
+ echo $ after_title ;
77
+ endif ;
78
+
79
+ add_filter ( 'subtitle_view_supported ' , '__return_false ' );
80
+
81
+ $ p = new WP_Query (
82
+ apply_filters (
83
+ 'higgs_portfolio_args ' ,
84
+ array (
85
+ 'post_type ' => 'jetpack-portfolio ' ,
86
+ 'post_status ' => 'publish ' ,
87
+ 'orderby ' => $ orderby ,
88
+ 'posts_per_page ' => $ number ,
89
+ 'no_found_rows ' => true ,
90
+ 'ignore_sticky_posts ' => true ,
91
+ 'meta_query ' => array ( array ( 'key ' => '_thumbnail_id ' ) ),
92
+ )
93
+ )
94
+ );
95
+
96
+ if ( $ p ->have_posts () ) :
97
+ ?>
90
98
91
99
<div id="portfolio-container" class="portfolio-container">
92
100
<div class="portfolio-loader">
@@ -99,33 +107,38 @@ function widget( $args, $instance ) {
99
107
</div>
100
108
</div>
101
109
102
- <?php while ( $ p ->have_posts () ) : $ p ->the_post ();
103
- get_template_part ( 'partials/content ' , 'portfolio-archive ' );
104
- endwhile ; ?>
110
+ <?php
111
+ while ( $ p ->have_posts () ) :
112
+ $ p ->the_post ();
113
+ get_template_part ( 'partials/content ' , 'portfolio-archive ' );
114
+ endwhile ;
115
+ ?>
105
116
106
117
<div id="gutter-sizer"></div>
107
118
</div>
108
- <?php endif ;
119
+ <?php
120
+ endif ;
109
121
110
- remove_all_filters ( 'subtitle_view_supported ' );
122
+ remove_all_filters ( 'subtitle_view_supported ' );
111
123
112
- wp_reset_postdata ();
124
+ wp_reset_postdata ();
113
125
114
- ?>
126
+ ?>
115
127
116
- <?php echo $ after_widget ;
128
+ <?php
129
+ echo $ after_widget ;
117
130
118
- $ content = ob_get_clean ();
131
+ $ content = ob_get_clean ();
119
132
120
- echo $ content ;
133
+ echo $ content ;
121
134
122
- $ this ->cache_widget ( $ args , $ content );
123
- }
135
+ $ this ->cache_widget ( $ args , $ content );
136
+ }
124
137
125
- public static function register () {
126
- register_widget ( __CLASS__ );
138
+ public static function register () {
139
+ register_widget ( __CLASS__ );
140
+ }
127
141
}
128
- }
129
142
endif ;
130
143
131
144
add_action ( 'widgets_init ' , array ( 'Higgs_Portfolio ' , 'register ' ) );
0 commit comments