WP Show Posts - Version 1.1

Version Description

  • New: Allow multiple taxonomy terms to be selected
  • New: Choose the title HTML element
  • New: wpsp_disable_title_link filter
  • New: wpsp_disable_image_link filter
  • New: wpsp_read_more_output filter
  • New: wpsp_inside_wrapper hook
  • New: wpsp_image_attributes filter
  • New: wpsp_term_separator filter
  • New: Option to add comments number/link in post meta
  • New: Allow override of settings within shortcode parameter
  • New: Add standard post classes to each post
  • Tweak: Remove many function_exists() wrappers - check your custom functions!
  • Tweak: Pass list settings through hooks instead of using global
  • Tweak: Clean up code considerably
  • Tweak: Use the_excerpt() instead of custom function
  • Tweak: Remove border radius from read more buttons
  • Fix: Broken author setting
  • Fix: Remove image float on mobile
  • Fix: Missing color labels in WP 4.9
Download this release

Release Info

Developer edge22
Plugin Icon 128x128 WP Show Posts
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

admin/admin.php CHANGED
@@ -2,82 +2,81 @@
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- if ( ! function_exists( 'wpsp_admin_scripts' ) ) :
6
- /**
7
- * Add our admin scripts and styles
8
- * @since 0.1
9
- */
10
- add_action( 'admin_print_scripts-post-new.php', 'wpsp_admin_scripts', 11 );
11
- add_action( 'admin_print_scripts-post.php', 'wpsp_admin_scripts', 11 );
12
- function wpsp_admin_scripts()
13
- {
14
- global $post_type, $post;
15
- if( 'wp_show_posts' == $post_type ) :
16
- wp_enqueue_script( 'wpsp-admin-scripts', plugin_dir_url( __FILE__ ) . "js/admin-scripts.js", array( 'jquery' ), '', true );
17
- wp_localize_script( 'wpsp-admin-scripts', 'wpsp_object', array (
18
- 'post_id' => ( isset( $post ) ) ? $post->ID : false,
19
- 'nonce' => wp_create_nonce( 'wpsp_nonce' )
20
- ));
21
- endif;
22
- wp_enqueue_style( 'wpsp-admin', plugin_dir_url( __FILE__ ) . "css/admin.css" );
 
23
  }
24
- endif;
25
 
26
- if ( ! function_exists( 'wpsp_translatable_strings' ) ) :
27
- /**
28
- * Add some javascript variables to the admin head
29
- * @since 0.1
30
- */
31
- add_action( 'admin_head','wpsp_translatable_strings', 0 );
32
- function wpsp_translatable_strings()
33
- {
34
- ?>
35
- <script type="text/javascript">
36
- var wpsp_add_posts = '<?php _e( 'WP Show Posts','wp-show-posts' );?>';
37
- var wpsp_nonce = '<?php echo wp_create_nonce( 'wpsp_nonce' ); ?>';
38
- </script>
39
- <?php
40
  }
41
- endif;
42
 
43
- if ( ! function_exists( 'wpsp_add_shortcode_button' ) ) :
44
- /*
45
- * Set it up so we can register our TinyMCE button
46
- * @since 0.1
47
- */
48
- add_action('admin_init', 'wpsp_add_shortcode_button');
49
- function wpsp_add_shortcode_button()
50
- {
51
- // check user permissions
52
- if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) )
53
- return;
54
-
55
- // check if WYSIWYG is enabled
56
- if ( get_user_option( 'rich_editing' ) == 'true') {
57
- add_filter( 'mce_external_plugins', 'wpsp_shortcodes_add_tinymce_plugin' );
58
- add_filter( 'mce_buttons', 'wpsp_shortcodes_register_button' );
 
59
  }
60
  }
61
- endif;
62
 
63
- if ( ! function_exists( 'wpsp_shortcodes_add_tinymce_plugin' ) ) :
64
- /*
65
- * Register our tinyMCE button javascript
66
- * @since 0.1
67
- */
68
- function wpsp_shortcodes_add_tinymce_plugin( $plugin_array ) {
69
- $plugin_array[ 'wpsp_shortcode_button' ] = plugin_dir_url( __FILE__ ) . '/js/button.js';
70
- return $plugin_array;
 
71
  }
72
- endif;
73
 
74
- if ( ! function_exists( 'wpsp_shortcodes_register_button' ) ) :
75
- /*
76
- * Register our TinyMCE button
77
- * @since 0.1
78
- */
79
- function wpsp_shortcodes_register_button( $buttons ) {
80
- array_push( $buttons, 'wpsp_shortcode_button' );
81
- return $buttons;
 
82
  }
83
- endif;
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
+ if ( ! function_exists( 'wpsp_admin_scripts' ) ) {
6
+ add_action( 'admin_print_scripts-post-new.php', 'wpsp_admin_scripts', 11 );
7
+ add_action( 'admin_print_scripts-post.php', 'wpsp_admin_scripts', 11 );
8
+ /**
9
+ * Add our admin scripts and styles
10
+ * @since 0.1
11
+ */
12
+ function wpsp_admin_scripts() {
13
+ global $post_type, $post;
14
+ if ( 'wp_show_posts' == $post_type ) {
15
+ wp_enqueue_script( 'wpsp-admin-scripts', plugin_dir_url( __FILE__ ) . "js/admin-scripts.js", array( 'jquery' ), WPSP_VERSION, true );
16
+ wp_localize_script( 'wpsp-admin-scripts', 'wpsp_object', array (
17
+ 'post_id' => ( isset( $post ) ) ? $post->ID : false,
18
+ 'nonce' => wp_create_nonce( 'wpsp_nonce' )
19
+ ));
20
+ }
21
+
22
+ wp_enqueue_style( 'wpsp-admin', plugin_dir_url( __FILE__ ) . "css/admin.css", array(), WPSP_VERSION );
23
+ }
24
  }
 
25
 
26
+ if ( ! function_exists( 'wpsp_translatable_strings' ) ) {
27
+ add_action( 'admin_head','wpsp_translatable_strings', 0 );
28
+ /**
29
+ * Add some javascript variables to the admin head
30
+ * @since 0.1
31
+ */
32
+ function wpsp_translatable_strings() {
33
+ ?>
34
+ <script type="text/javascript">
35
+ var wpsp_add_posts = '<?php _e( 'WP Show Posts','wp-show-posts' );?>';
36
+ var wpsp_nonce = '<?php echo wp_create_nonce( 'wpsp_nonce' ); ?>';
37
+ </script>
38
+ <?php
39
+ }
40
  }
 
41
 
42
+ if ( ! function_exists( 'wpsp_add_shortcode_button' ) ) {
43
+ add_action( 'admin_init', 'wpsp_add_shortcode_button' );
44
+ /*
45
+ * Set it up so we can register our TinyMCE button
46
+ * @since 0.1
47
+ */
48
+ function wpsp_add_shortcode_button() {
49
+ // check user permissions
50
+ if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
51
+ return;
52
+ }
53
+
54
+ // check if WYSIWYG is enabled
55
+ if ( get_user_option( 'rich_editing' ) == 'true') {
56
+ add_filter( 'mce_external_plugins', 'wpsp_shortcodes_add_tinymce_plugin' );
57
+ add_filter( 'mce_buttons', 'wpsp_shortcodes_register_button' );
58
+ }
59
  }
60
  }
 
61
 
62
+ if ( ! function_exists( 'wpsp_shortcodes_add_tinymce_plugin' ) ) {
63
+ /*
64
+ * Register our tinyMCE button javascript
65
+ * @since 0.1
66
+ */
67
+ function wpsp_shortcodes_add_tinymce_plugin( $plugin_array ) {
68
+ $plugin_array[ 'wpsp_shortcode_button' ] = plugin_dir_url( __FILE__ ) . '/js/button.js';
69
+ return $plugin_array;
70
+ }
71
  }
 
72
 
73
+ if ( ! function_exists( 'wpsp_shortcodes_register_button' ) ) {
74
+ /*
75
+ * Register our TinyMCE button
76
+ * @since 0.1
77
+ */
78
+ function wpsp_shortcodes_register_button( $buttons ) {
79
+ array_push( $buttons, 'wpsp_shortcode_button' );
80
+ return $buttons;
81
+ }
82
  }
 
admin/ajax.php CHANGED
@@ -2,107 +2,108 @@
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- if ( ! function_exists( 'wpsp_get_json_option' ) ) :
6
- /**
7
- * Get the current option value
8
- * @since 0.1
9
- */
10
- add_action( 'wp_ajax_wpsp_get_json_option', 'wpsp_get_json_option' );
11
- function wpsp_get_json_option()
12
- {
13
- if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) )
14
- wp_die( 'Permission declined' );
15
-
16
- $option = ( get_post_meta( intval( $_POST[ 'id' ] ), sanitize_text_field( $_POST[ 'key' ] ) ) ) ? get_post_meta( intval( $_POST[ 'id' ] ), sanitize_text_field( $_POST[ 'key' ] ), true ) : false;
17
-
18
- if ( $option )
19
- echo wp_json_encode( $option );
20
-
21
- die();
22
- }
23
- endif;
24
-
25
- if ( ! function_exists( 'wpsp_get_terms' ) ) :
26
- /**
27
- * Get all of our terms depending on the set taxonomy
28
- * @since 0.1
29
- */
30
- add_action( 'wp_ajax_wpsp_get_terms', 'wpsp_get_terms' );
31
- function wpsp_get_terms()
32
- {
33
- if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) )
34
- wp_die( 'Permission declined' );
35
-
36
- $terms = get_terms( sanitize_text_field( $_POST[ 'taxonomy' ] ), 'orderby=count&hide_empty=1' );
37
- $count = count( $terms );
38
- $types = array();
39
- if ( $count > 0 ) {
40
- foreach ( $terms as $term ) {
41
- $types[] = $term->slug;
42
  }
43
- }
44
-
45
- echo wp_json_encode( $types );
46
 
47
- die();
48
- }
49
- endif;
50
-
51
- if ( ! function_exists( 'wpsp_get_taxonomies' ) ) :
52
- /**
53
- * Get out taxonomies based on the set post type
54
- * @since 0.1
55
- */
56
- add_action( 'wp_ajax_wpsp_get_taxonomies', 'wpsp_get_taxonomies' );
57
- function wpsp_get_taxonomies()
58
- {
59
- if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) )
60
- wp_die( 'Permission declined' );
61
-
62
- $terms = get_object_taxonomies( sanitize_text_field( $_POST[ 'post_type' ] ) );
63
- $count = count( $terms );
64
- $types = array();
65
- if ( $count > 0 ) {
66
- foreach ( $terms as $term ) {
67
- $types[] = $term;
68
  }
 
 
69
  }
70
-
71
- echo wp_json_encode( $types );
72
 
73
- die();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
- endif;
76
-
77
- if ( ! function_exists( 'wpsp_get_post_lists' ) ) :
78
- /**
79
- * Get all of our post lists
80
- * @since 0.1
81
- */
82
- add_action( 'wp_ajax_wpsp_get_post_lists', 'wpsp_get_post_lists' );
83
- function wpsp_get_post_lists()
84
- {
85
- if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) )
86
- wp_die( 'Permission declined' );
87
-
88
- $args = array(
89
- 'posts_per_page' => -1,
90
- 'post_type' => 'wp_show_posts',
91
- 'post_status' => 'publish',
92
- 'showposts' => -1
93
- );
94
- $posts = get_posts( $args );
95
-
96
- $count = count( $posts );
97
- $types = array();
98
- if ( $count > 0 ) {
99
- foreach ( $posts as $post ) {
100
- $types[] = array( 'text' => $post->post_title, 'value' => $post->ID );
101
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  }
103
-
104
- echo wp_json_encode( $types );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- die();
 
107
  }
108
- endif;
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
+ if ( ! function_exists( 'wpsp_get_json_option' ) ) {
6
+ add_action( 'wp_ajax_wpsp_get_json_option', 'wpsp_get_json_option' );
7
+ /**
8
+ * Get the current option value
9
+ * @since 0.1
10
+ */
11
+ function wpsp_get_json_option() {
12
+ if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
13
+ wp_die( 'Permission declined' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
 
 
 
15
 
16
+ $option = ( get_post_meta( intval( $_POST[ 'id' ] ), sanitize_text_field( $_POST[ 'key' ] ) ) ) ? get_post_meta( intval( $_POST[ 'id' ] ), sanitize_text_field( $_POST[ 'key' ] ), true ) : false;
17
+
18
+ if ( $option ) {
19
+ echo wp_json_encode( $option );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
+
22
+ die();
23
  }
24
+ }
 
25
 
26
+ if ( ! function_exists( 'wpsp_get_terms' ) ) {
27
+ add_action( 'wp_ajax_wpsp_get_terms', 'wpsp_get_terms' );
28
+ /**
29
+ * Get all of our terms depending on the set taxonomy
30
+ * @since 0.1
31
+ */
32
+ function wpsp_get_terms() {
33
+ if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
34
+ wp_die( 'Permission declined' );
35
+ }
36
+
37
+ $terms = get_terms( sanitize_key( $_POST[ 'taxonomy' ] ), 'orderby=count&hide_empty=1' );
38
+ $count = count( $terms );
39
+ $types = array();
40
+ if ( $count > 0 ) {
41
+ foreach ( $terms as $term ) {
42
+ $types[] = $term->slug;
43
+ }
44
+ }
45
+
46
+ echo wp_json_encode( $types );
47
+
48
+ die();
49
+ }
50
  }
51
+
52
+ if ( ! function_exists( 'wpsp_get_taxonomies' ) ) {
53
+ add_action( 'wp_ajax_wpsp_get_taxonomies', 'wpsp_get_taxonomies' );
54
+ /**
55
+ * Get out taxonomies based on the set post type
56
+ * @since 0.1
57
+ */
58
+ function wpsp_get_taxonomies() {
59
+ if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
60
+ wp_die( 'Permission declined' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
+
63
+ $terms = get_object_taxonomies( sanitize_text_field( $_POST[ 'post_type' ] ) );
64
+ $count = count( $terms );
65
+ $types = array();
66
+ if ( $count > 0 ) {
67
+ foreach ( $terms as $term ) {
68
+ $types[] = $term;
69
+ }
70
+ }
71
+
72
+ echo wp_json_encode( $types );
73
+
74
+ die();
75
  }
76
+ }
77
+
78
+ if ( ! function_exists( 'wpsp_get_post_lists' ) ) {
79
+ add_action( 'wp_ajax_wpsp_get_post_lists', 'wpsp_get_post_lists' );
80
+ /**
81
+ * Get all of our post lists
82
+ * @since 0.1
83
+ */
84
+ function wpsp_get_post_lists() {
85
+ if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
86
+ wp_die( 'Permission declined' );
87
+ }
88
+
89
+ $args = array(
90
+ 'posts_per_page' => -1,
91
+ 'post_type' => 'wp_show_posts',
92
+ 'post_status' => 'publish',
93
+ 'showposts' => -1
94
+ );
95
+ $posts = get_posts( $args );
96
+
97
+ $count = count( $posts );
98
+ $types = array();
99
+ if ( $count > 0 ) {
100
+ foreach ( $posts as $post ) {
101
+ $types[] = array( 'text' => $post->post_title, 'value' => $post->ID );
102
+ }
103
+ }
104
+
105
+ echo wp_json_encode( $types );
106
 
107
+ die();
108
+ }
109
  }
 
admin/css/admin.css CHANGED
@@ -25,7 +25,7 @@
25
  }
26
 
27
  #butterbean-ui-wp_show_posts input[type="checkbox"] {
28
- width: initial;
29
  height: 16px;
30
  }
31
 
@@ -34,4 +34,13 @@
34
  font: normal 20px/1 'dashicons';
35
  -webkit-font-smoothing: antialiased;
36
  -moz-osx-font-smoothing: grayscale;
37
- }
 
 
 
 
 
 
 
 
 
25
  }
26
 
27
  #butterbean-ui-wp_show_posts input[type="checkbox"] {
28
+ width: auto;
29
  height: 16px;
30
  }
31
 
34
  font: normal 20px/1 'dashicons';
35
  -webkit-font-smoothing: antialiased;
36
  -moz-osx-font-smoothing: grayscale;
37
+ }
38
+
39
+ #butterbean-control-wpsp_tax_term .butterbean-checkbox-list {
40
+ display: -webkit-flex;
41
+ display: flex;
42
+ -webkit-flex-flow: wrap column;
43
+ flex-flow: wrap column;
44
+ max-height: 250px;
45
+ overflow-y: scroll;
46
+ }
admin/js/admin-scripts.js CHANGED
@@ -11,7 +11,7 @@ function wpsp_get_taxonomy( type ) {
11
  async: false,
12
  dataType: 'json'
13
  });
14
-
15
  return response.responseJSON;
16
  }
17
 
@@ -28,7 +28,7 @@ function wpsp_get_terms( type ) {
28
  async: false,
29
  dataType: 'json'
30
  });
31
-
32
  return response.responseJSON;
33
  }
34
 
@@ -49,7 +49,7 @@ function wpsp_get_option( key ) {
49
  jQuery( '#butterbean-control-wpsp_taxonomy' ).css( 'display', 'block' );
50
  jQuery( '#butterbean-control-wpsp_tax_term' ).css( 'display', 'block' );
51
  });
52
-
53
  return response.responseJSON;
54
  }
55
 
@@ -65,29 +65,36 @@ jQuery( document ).ready( function( $ ) {
65
  // Set the selected taxonomy value on load
66
  $( '#wpsp-taxonomy' ).val( wpsp_get_option( 'wpsp_taxonomy' ) );
67
 
 
68
  var terms = wpsp_get_terms( $( '#wpsp-taxonomy' ).val() );
69
- $('#wpsp-terms').append( $( '<option></option>' ) );
70
  $.each(terms, function(key, value) {
71
- $('#wpsp-terms').append( $( '<option></option>' ).attr( 'value', value ).text( value ) );
 
 
 
 
 
 
 
 
72
  });
73
-
74
- // Set the selected term value on load
75
- $( '#wpsp-terms' ).val( wpsp_get_option( 'wpsp_tax_term' ) );
76
-
77
  // Hide the terms of taxonomy is empty on load
78
- if ( '' == $( '#wpsp-taxonomy' ).val() )
79
  $( '#butterbean-control-wpsp_tax_term' ).hide();
80
-
 
81
  // When changing the post type option
82
  $( '#wpsp-post-type' ).change(function() {
83
-
84
  $( '#butterbean-control-wpsp_tax_term' ).hide();
85
-
86
  $( '#wpsp-taxonomy' ).empty();
87
-
88
  $( '#wpsp-terms' ).empty();
89
  $( '#wpsp-terms' ).append( $( '<option></option>' ) );
90
-
91
  var selectValues = wpsp_get_taxonomy( $(this).val(), false );
92
 
93
  $('#wpsp-taxonomy').append( $( '<option></option>' ) );
@@ -100,29 +107,42 @@ jQuery( document ).ready( function( $ ) {
100
  $( '#butterbean-control-wpsp_taxonomy' ).show();
101
  }
102
  });
103
-
104
  // When changing the taxonomy option
105
  $( '#wpsp-taxonomy' ).change(function() {
106
-
107
- $( '#wpsp-terms' ).empty();
 
 
 
108
  var selectValues = wpsp_get_terms( $(this).val() );
109
 
110
- $('#wpsp-terms').append( $( '<option></option>' ) );
111
  $.each(selectValues, function(key, value) {
112
- $('#wpsp-terms').append( $( '<option></option>' ).attr( 'value', value ).text( value ) );
 
 
113
  });
114
 
115
- if ( '' == selectValues || ',' == selectValues )
 
116
  $( '#butterbean-control-wpsp_tax_term' ).hide();
117
- else
118
  $( '#butterbean-control-wpsp_tax_term' ).show();
 
119
  });
120
-
 
 
 
 
 
 
121
  // Dealing with the image options
122
  if ( ! $( '#wpsp-image' ).is( ':checked' ) ) {
123
  $( this ).parent().parent().siblings().hide();
124
  }
125
-
126
  $( '#wpsp-image' ).change(function() {
127
  if ( ! this.checked ) {
128
  $( this ).parent().parent().siblings().hide();
@@ -130,8 +150,8 @@ jQuery( document ).ready( function( $ ) {
130
  $( this ).parent().parent().siblings().show();
131
  }
132
  });
133
-
134
- // Excerpt or full content
135
  $( '#wpsp-content-type' ).change(function() {
136
  if ( 'excerpt' == $( this ).val() ) {
137
  $( '#butterbean-control-wpsp_excerpt_length' ).show();
@@ -139,12 +159,25 @@ jQuery( document ).ready( function( $ ) {
139
  $( '#butterbean-control-wpsp_excerpt_length' ).hide();
140
  }
141
  });
142
-
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  // Author location
144
  if ( ! $( '#wpsp-include-author' ).is( ':checked' ) ) {
145
  $( '#butterbean-control-wpsp_author_location' ).hide();
146
  }
147
-
148
  $( '#wpsp-include-author' ).change(function() {
149
  if ( ! this.checked ) {
150
  $( '#butterbean-control-wpsp_author_location' ).hide();
@@ -152,12 +185,12 @@ jQuery( document ).ready( function( $ ) {
152
  $( '#butterbean-control-wpsp_author_location' ).show();
153
  }
154
  });
155
-
156
  // Date location
157
  if ( ! $( '#wpsp-include-date' ).is( ':checked' ) ) {
158
  $( '#butterbean-control-wpsp_date_location' ).hide();
159
  }
160
-
161
  $( '#wpsp-include-date' ).change(function() {
162
  if ( ! this.checked ) {
163
  $( '#butterbean-control-wpsp_date_location' ).hide();
@@ -165,12 +198,12 @@ jQuery( document ).ready( function( $ ) {
165
  $( '#butterbean-control-wpsp_date_location' ).show();
166
  }
167
  });
168
-
169
  // Terms location
170
  if ( ! $( '#wpsp-include-terms' ).is( ':checked' ) ) {
171
  $( '#butterbean-control-wpsp_terms_location' ).hide();
172
  }
173
-
174
  $( '#wpsp-include-terms' ).change(function() {
175
  if ( ! this.checked ) {
176
  $( '#butterbean-control-wpsp_terms_location' ).hide();
@@ -178,13 +211,26 @@ jQuery( document ).ready( function( $ ) {
178
  $( '#butterbean-control-wpsp_terms_location' ).show();
179
  }
180
  });
181
-
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  // Dealing with the social options
183
  $( '#wpsp-social-sharing' ).parent().parent().siblings().hide();
184
  if ( $( '#wpsp-social-sharing' ).is( ':checked' ) ) {
185
  $( '#wpsp-social-sharing' ).parent().parent().siblings().show();
186
  }
187
-
188
  $( '#wpsp-social-sharing' ).change(function() {
189
  if ( ! this.checked ) {
190
  $( this ).parent().parent().siblings().hide();
@@ -192,12 +238,12 @@ jQuery( document ).ready( function( $ ) {
192
  $( this ).parent().parent().siblings().show();
193
  }
194
  });
195
-
196
  // Pagination
197
  if ( ! $( '#wpsp-pagination' ).is( ':checked' ) ) {
198
  $( '#butterbean-control-wpsp_ajax_pagination' ).hide();
199
  }
200
-
201
  $( '#wpsp-pagination' ).change(function() {
202
  if ( ! this.checked ) {
203
  $( '#butterbean-control-wpsp_ajax_pagination' ).hide();
@@ -205,4 +251,4 @@ jQuery( document ).ready( function( $ ) {
205
  $( '#butterbean-control-wpsp_ajax_pagination' ).show();
206
  }
207
  });
208
- });
11
  async: false,
12
  dataType: 'json'
13
  });
14
+
15
  return response.responseJSON;
16
  }
17
 
28
  async: false,
29
  dataType: 'json'
30
  });
31
+
32
  return response.responseJSON;
33
  }
34
 
49
  jQuery( '#butterbean-control-wpsp_taxonomy' ).css( 'display', 'block' );
50
  jQuery( '#butterbean-control-wpsp_tax_term' ).css( 'display', 'block' );
51
  });
52
+
53
  return response.responseJSON;
54
  }
55
 
65
  // Set the selected taxonomy value on load
66
  $( '#wpsp-taxonomy' ).val( wpsp_get_option( 'wpsp_taxonomy' ) );
67
 
68
+ // Show any selected terms
69
  var terms = wpsp_get_terms( $( '#wpsp-taxonomy' ).val() );
70
+
71
  $.each(terms, function(key, value) {
72
+ if ( null !== value ) {
73
+ if ( $.isArray( wpsp_get_option( 'wpsp_tax_term' ) ) ) {
74
+ var checked = ( $.inArray( value, wpsp_get_option( 'wpsp_tax_term' ) ) > -1 ) ? 'checked="checked"' : '';
75
+ } else {
76
+ var checked = ( value === wpsp_get_option( 'wpsp_tax_term' ) ) ? 'checked="checked"' : '';
77
+ }
78
+
79
+ $('#butterbean-control-wpsp_tax_term .butterbean-checkbox-list').append( $( '<li><label><input ' + checked + ' type="checkbox" value="' + value + '" name="butterbean_wp_show_posts_setting_wpsp_tax_term[]" />' + value + '</label></li>' ) );
80
+ }
81
  });
82
+
 
 
 
83
  // Hide the terms of taxonomy is empty on load
84
+ if ( '' == $( '#wpsp-taxonomy' ).val() ) {
85
  $( '#butterbean-control-wpsp_tax_term' ).hide();
86
+ }
87
+
88
  // When changing the post type option
89
  $( '#wpsp-post-type' ).change(function() {
90
+
91
  $( '#butterbean-control-wpsp_tax_term' ).hide();
92
+
93
  $( '#wpsp-taxonomy' ).empty();
94
+
95
  $( '#wpsp-terms' ).empty();
96
  $( '#wpsp-terms' ).append( $( '<option></option>' ) );
97
+
98
  var selectValues = wpsp_get_taxonomy( $(this).val(), false );
99
 
100
  $('#wpsp-taxonomy').append( $( '<option></option>' ) );
107
  $( '#butterbean-control-wpsp_taxonomy' ).show();
108
  }
109
  });
110
+
111
  // When changing the taxonomy option
112
  $( '#wpsp-taxonomy' ).change(function() {
113
+
114
+ // Empty the list of terms
115
+ $( '#butterbean-control-wpsp_tax_term .butterbean-checkbox-list' ).empty();
116
+
117
+ // Get any selected terms
118
  var selectValues = wpsp_get_terms( $(this).val() );
119
 
120
+ // For each selected term, add the checkbox
121
  $.each(selectValues, function(key, value) {
122
+ if ( null !== value ) {
123
+ $('#butterbean-control-wpsp_tax_term .butterbean-checkbox-list').append( $( '<li><label><input type="checkbox" value="' + value + '" name="butterbean_wp_show_posts_setting_wpsp_tax_term[]" />' + value + '</label></li>' ) );
124
+ }
125
  });
126
 
127
+ // Hide the terms area if we don't have any terms
128
+ if ( '' == selectValues || ',' == selectValues ) {
129
  $( '#butterbean-control-wpsp_tax_term' ).hide();
130
+ } else {
131
  $( '#butterbean-control-wpsp_tax_term' ).show();
132
+ }
133
  });
134
+
135
+ // Fix color label bug introduced in WP 4.9.
136
+ $( '.butterbean-control-color' ).each( function() {
137
+ var _this = $( this );
138
+ _this.find( '.wp-picker-input-wrap.hidden .butterbean-label' ).prependTo( _this );
139
+ } );
140
+
141
  // Dealing with the image options
142
  if ( ! $( '#wpsp-image' ).is( ':checked' ) ) {
143
  $( this ).parent().parent().siblings().hide();
144
  }
145
+
146
  $( '#wpsp-image' ).change(function() {
147
  if ( ! this.checked ) {
148
  $( this ).parent().parent().siblings().hide();
150
  $( this ).parent().parent().siblings().show();
151
  }
152
  });
153
+
154
+ // Excerpt or full content
155
  $( '#wpsp-content-type' ).change(function() {
156
  if ( 'excerpt' == $( this ).val() ) {
157
  $( '#butterbean-control-wpsp_excerpt_length' ).show();
159
  $( '#butterbean-control-wpsp_excerpt_length' ).hide();
160
  }
161
  });
162
+
163
+ // Title
164
+ if ( ! $( '#wpsp-include-title' ).is( ':checked' ) ) {
165
+ $( '#butterbean-control-wpsp_title_element' ).hide();
166
+ }
167
+
168
+ $( '#wpsp-include-title' ).change(function() {
169
+ if ( ! this.checked ) {
170
+ $( '#butterbean-control-wpsp_title_element' ).hide();
171
+ } else {
172
+ $( '#butterbean-control-wpsp_title_element' ).show();
173
+ }
174
+ });
175
+
176
  // Author location
177
  if ( ! $( '#wpsp-include-author' ).is( ':checked' ) ) {
178
  $( '#butterbean-control-wpsp_author_location' ).hide();
179
  }
180
+
181
  $( '#wpsp-include-author' ).change(function() {
182
  if ( ! this.checked ) {
183
  $( '#butterbean-control-wpsp_author_location' ).hide();
185
  $( '#butterbean-control-wpsp_author_location' ).show();
186
  }
187
  });
188
+
189
  // Date location
190
  if ( ! $( '#wpsp-include-date' ).is( ':checked' ) ) {
191
  $( '#butterbean-control-wpsp_date_location' ).hide();
192
  }
193
+
194
  $( '#wpsp-include-date' ).change(function() {
195
  if ( ! this.checked ) {
196
  $( '#butterbean-control-wpsp_date_location' ).hide();
198
  $( '#butterbean-control-wpsp_date_location' ).show();
199
  }
200
  });
201
+
202
  // Terms location
203
  if ( ! $( '#wpsp-include-terms' ).is( ':checked' ) ) {
204
  $( '#butterbean-control-wpsp_terms_location' ).hide();
205
  }
206
+
207
  $( '#wpsp-include-terms' ).change(function() {
208
  if ( ! this.checked ) {
209
  $( '#butterbean-control-wpsp_terms_location' ).hide();
211
  $( '#butterbean-control-wpsp_terms_location' ).show();
212
  }
213
  });
214
+
215
+ // Comments link location
216
+ if ( ! $( '#wpsp-include-comments-link' ).is( ':checked' ) ) {
217
+ $( '#butterbean-control-wpsp_comments_location' ).hide();
218
+ }
219
+
220
+ $( '#wpsp-include-comments-link' ).change(function() {
221
+ if ( ! this.checked ) {
222
+ $( '#butterbean-control-wpsp_comments_location' ).hide();
223
+ } else {
224
+ $( '#butterbean-control-wpsp_comments_location' ).show();
225
+ }
226
+ });
227
+
228
  // Dealing with the social options
229
  $( '#wpsp-social-sharing' ).parent().parent().siblings().hide();
230
  if ( $( '#wpsp-social-sharing' ).is( ':checked' ) ) {
231
  $( '#wpsp-social-sharing' ).parent().parent().siblings().show();
232
  }
233
+
234
  $( '#wpsp-social-sharing' ).change(function() {
235
  if ( ! this.checked ) {
236
  $( this ).parent().parent().siblings().hide();
238
  $( this ).parent().parent().siblings().show();
239
  }
240
  });
241
+
242
  // Pagination
243
  if ( ! $( '#wpsp-pagination' ).is( ':checked' ) ) {
244
  $( '#butterbean-control-wpsp_ajax_pagination' ).hide();
245
  }
246
+
247
  $( '#wpsp-pagination' ).change(function() {
248
  if ( ! this.checked ) {
249
  $( '#butterbean-control-wpsp_ajax_pagination' ).hide();
251
  $( '#butterbean-control-wpsp_ajax_pagination' ).show();
252
  }
253
  });
254
+ });
admin/metabox.php CHANGED
@@ -2,899 +2,969 @@
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- if ( ! function_exists( 'wpsp_remove_metaboxes' ) ) :
6
- /**
7
- * Remove all metaboxes from our WP Show Posts post type
8
- * @since 0.1
9
- */
10
- add_action('add_meta_boxes', 'wpsp_remove_metaboxes', 99);
11
- function wpsp_remove_metaboxes( $post_type ){
12
-
13
- // If we're not in the wp_show_posts post type, bail.
14
- if( ! in_array( $post_type, array( 'wp_show_posts' ) ) )
15
- return false;
16
-
17
- global $wp_meta_boxes;
18
-
19
- // Don't remove the below
20
- $exceptions = array(
21
- 'submitdiv',
22
- 'butterbean-ui-wp_show_posts',
23
- 'wpsp_shortcode_metabox'
24
- );
25
-
26
- // Loop through all our metaboxes
27
- if( ! empty( $wp_meta_boxes ) ) :
28
- foreach( $wp_meta_boxes as $page => $page_boxes ) :
29
- if ( ! empty( $page_boxes ) ) :
30
- foreach( $page_boxes as $context => $box_context ) :
31
- if( ! empty( $box_context ) ) :
32
- foreach( $box_context as $box_type ) :
33
- if( ! empty( $box_type ) ) :
34
- foreach( $box_type as $id => $box ) :
35
- /** Check to see if the meta box should be removed... */
36
- if( ! in_array( $id, $exceptions ) ) :
37
- remove_meta_box( $id, $page, $context );
38
- endif;
39
- endforeach;
40
- endif;
41
- endforeach;
42
- endif;
43
- endforeach;
44
- endif;
45
- endforeach;
46
- endif;
47
- }
48
- endif;
49
-
50
- if ( ! function_exists( 'wpsp_get_post_types' ) ) :
51
- /**
52
- * List of all our post types exluding our own
53
- * @since 0.1
54
- */
55
- function wpsp_get_post_types()
56
- {
57
- $post_types = get_post_types( array( 'public' => true ) );
58
- $types = array();
59
- foreach ( $post_types as $type ) {
60
- if ( 'wp_show_posts' !== $type && 'attachment' !== $type )
61
- $types[ $type ] = $type;
62
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- return $types;
 
65
  }
66
- endif;
67
-
68
- if ( ! function_exists( 'wpsp_load_butterbean' ) ) :
69
- /**
70
- * Load butterbean inside our post type
71
- * @since 0.1
72
- */
73
- add_action( 'plugins_loaded', 'wpsp_load_butterbean' );
74
- function wpsp_load_butterbean()
75
- {
76
- require_once( trailingslashit( dirname( __FILE__ ) ) . '/butterbean/butterbean.php' );
77
  }
78
- endif;
79
-
80
- if ( ! function_exists( 'wpsp_register' ) ) :
81
- /**
82
- * Create all of our metabox options
83
- * @since 0.1
84
- */
85
- add_action( 'butterbean_register', 'wpsp_register', 10, 2 );
86
- function wpsp_register( $butterbean, $post_type ) {
87
-
88
- $defaults = wpsp_get_defaults();
89
-
90
- // Register managers, sections, controls, and settings here.
91
- $butterbean->register_manager(
92
- 'wp_show_posts',
93
- array(
94
- 'label' => esc_html__( 'WP Show Posts', 'wp-show-posts' ),
95
- 'post_type' => 'wp_show_posts',
96
- 'context' => 'normal',
97
- 'priority' => 'high'
98
- )
99
- );
100
-
101
- $manager = $butterbean->get_manager( 'wp_show_posts' );
102
-
103
- $manager->register_section(
104
- 'wpsp_posts',
105
- array(
106
- 'label' => esc_html__( 'Posts', 'wp-show-posts' ),
107
- 'icon' => 'dashicons-admin-post'
108
- )
109
- );
110
-
111
- $manager->register_control(
112
- 'wpsp_post_type', // Same as setting name.
113
- array(
114
- 'type' => 'select',
115
- 'section' => 'wpsp_posts',
116
- 'label' => esc_html__( 'Post Type', 'wp-show-posts' ),
117
- 'choices' => wpsp_get_post_types(),
118
- 'attr' => array( 'id' => 'wpsp-post-type' )
119
- )
120
- );
121
-
122
- $manager->register_setting(
123
- 'wpsp_post_type', // Same as control name.
124
- array(
125
- 'sanitize_callback' => 'sanitize_text_field',
126
- 'default' => $defaults[ 'wpsp_post_type' ] ? $defaults[ 'wpsp_post_type' ] : ''
127
- )
128
- );
129
-
130
- $manager->register_control(
131
- 'wpsp_taxonomy', // Same as setting name.
132
- array(
133
- 'type' => 'select',
134
- 'section' => 'wpsp_posts',
135
- 'label' => esc_html__( 'Taxonomy', 'wp-show-posts' ),
136
- 'choices' => array(),
137
- 'attr' => array( 'id' => 'wpsp-taxonomy' )
138
- )
139
- );
140
-
141
- $manager->register_setting(
142
- 'wpsp_taxonomy', // Same as control name.
143
- array(
144
- 'sanitize_callback' => 'sanitize_text_field',
145
- 'default' => $defaults[ 'wpsp_taxonomy' ] ? $defaults[ 'wpsp_taxonomy' ] : ''
146
- )
147
- );
148
-
149
- $manager->register_control(
150
- 'wpsp_tax_term', // Same as setting name.
151
- array(
152
- 'type' => 'select',
153
- 'section' => 'wpsp_posts',
154
- 'label' => esc_html__( 'Terms', 'wp-show-posts' ),
155
- 'choices' => array(),
156
- 'attr' => array( 'id' => 'wpsp-terms' )
157
- )
158
- );
159
-
160
- $manager->register_setting(
161
- 'wpsp_tax_term', // Same as control name.
162
- array(
163
- 'sanitize_callback' => 'sanitize_text_field',
164
- 'default' => $defaults[ 'wpsp_tax_term' ] ? $defaults[ 'wpsp_tax_term' ] : ''
165
- )
166
- );
167
-
168
- $manager->register_control(
169
- 'wpsp_posts_per_page', // Same as setting name.
170
- array(
171
- 'type' => 'number',
172
- 'section' => 'wpsp_posts',
173
- 'label' => esc_html__( 'Posts per page', 'wp-show-posts' )
174
- )
175
- );
176
-
177
- $manager->register_setting(
178
- 'wpsp_posts_per_page', // Same as control name.
179
- array(
180
- 'sanitize_callback' => 'wpsp_sanitize_intval',
181
- 'default' => $defaults[ 'wpsp_posts_per_page' ] ? $defaults[ 'wpsp_posts_per_page' ] : 10
182
- )
183
- );
184
-
185
- $manager->register_control(
186
- 'wpsp_pagination',
187
- array(
188
- 'type' => 'checkbox',
189
- 'section' => 'wpsp_posts',
190
- 'label' => __( 'Pagination','wp-show-posts' ),
191
- 'description' => __( 'Pagination should only be used if your posts are the only thing in the content area to prevent duplicate content issues.','wp-show-posts' ),
192
- 'attr' => array( 'id' => 'wpsp-pagination' )
193
- )
194
- );
195
-
196
- $manager->register_setting(
197
- 'wpsp_pagination',
198
- array(
199
- 'sanitize_callback' => 'butterbean_validate_boolean',
200
- 'default' => $defaults[ 'wpsp_pagination' ] ? $defaults[ 'wpsp_pagination' ] : false
201
- )
202
- );
203
-
204
- $manager->register_section(
205
- 'wpsp_columns',
206
- array(
207
- 'label' => esc_html__( 'Columns', 'wp-show-posts' ),
208
- 'icon' => 'dashicons-grid-view'
209
- )
210
- );
211
-
212
- $manager->register_control(
213
- 'wpsp_columns', // Same as setting name.
214
- array(
215
- 'type' => 'select',
216
- 'section' => 'wpsp_columns',
217
- 'label' => esc_html__( 'Columns', 'wp-show-posts' ),
218
- 'choices' => array(
219
- 'col-12' => '1',
220
- 'col-6' => '2',
221
- 'col-4' => '3',
222
- 'col-3' => '4',
223
- 'col-20' => '5'
224
- ),
225
- 'attr' => array( 'id' => 'wpsp-columns' )
226
- )
227
- );
228
-
229
- $manager->register_setting(
230
- 'wpsp_columns', // Same as control name.
231
- array(
232
- 'sanitize_callback' => 'sanitize_text_field',
233
- 'default' => $defaults[ 'wpsp_columns' ] ? $defaults[ 'wpsp_columns' ] : '12'
234
- )
235
- );
236
-
237
- $manager->register_control(
238
- 'wpsp_columns_gutter', // Same as setting name.
239
- array(
240
- 'type' => 'text',
241
- 'section' => 'wpsp_columns',
242
- 'label' => esc_html__( 'Columns gutter', 'wp-show-posts' ),
243
- 'attr' => array( 'class' => 'widefat' ),
244
- )
245
- );
246
-
247
- $manager->register_setting(
248
- 'wpsp_columns_gutter', // Same as control name.
249
- array(
250
- 'sanitize_callback' => 'sanitize_text_field',
251
- 'default' => $defaults[ 'wpsp_columns_gutter' ] ? $defaults[ 'wpsp_columns_gutter' ] : ''
252
- )
253
- );
254
-
255
- $manager->register_section(
256
- 'wpsp_images',
257
- array(
258
- 'label' => esc_html__( 'Images', 'wp-show-posts' ),
259
- 'icon' => 'dashicons-format-image'
260
- )
261
- );
262
-
263
- $manager->register_control(
264
- 'wpsp_image',
265
- array(
266
- 'type' => 'checkbox',
267
- 'section' => 'wpsp_images',
268
- 'label' => __( 'Images','wp-show-posts' ),
269
- 'attr' => array( 'id' => 'wpsp-image' )
270
- )
271
- );
272
-
273
- $manager->register_setting(
274
- 'wpsp_image',
275
- array(
276
- 'sanitize_callback' => 'butterbean_validate_boolean',
277
- 'default' => $defaults[ 'wpsp_image' ]
278
- )
279
- );
280
-
281
- $manager->register_control(
282
- 'wpsp_image_width', // Same as setting name.
283
- array(
284
- 'type' => 'number',
285
- 'section' => 'wpsp_images',
286
- 'label' => esc_html__( 'Image width (px)', 'wp-show-posts' ),
287
- 'attr' => array( 'id' => 'wpsp-image-width' )
288
- )
289
- );
290
-
291
- $manager->register_setting(
292
- 'wpsp_image_width', // Same as control name.
293
- array(
294
- 'sanitize_callback' => 'wpsp_sanitize_absint',
295
- 'default' => $defaults[ 'wpsp_image_width' ] ? $defaults[ 'wpsp_image_width' ] : ''
296
- )
297
- );
298
-
299
- $manager->register_control(
300
- 'wpsp_image_height', // Same as setting name.
301
- array(
302
- 'type' => 'number',
303
- 'section' => 'wpsp_images',
304
- 'label' => esc_html__( 'Image height (px)', 'wp-show-posts' ),
305
- 'attr' => array( 'id' => 'wpsp-image-height' )
306
- )
307
- );
308
-
309
- $manager->register_setting(
310
- 'wpsp_image_height', // Same as control name.
311
- array(
312
- 'sanitize_callback' => 'wpsp_sanitize_absint',
313
- 'default' => $defaults[ 'wpsp_image_height' ] ? $defaults[ 'wpsp_image_height' ] : ''
314
- )
315
- );
316
-
317
- $manager->register_control(
318
- 'wpsp_image_alignment', // Same as setting name.
319
- array(
320
- 'type' => 'select',
321
- 'section' => 'wpsp_images',
322
- 'label' => esc_html__( 'Image alignment', 'wp-show-posts' ),
323
- 'choices' => array(
324
- 'left' => __( 'Left','wp-show-posts' ),
325
- 'center' => __( 'Center','wp-show-posts' ),
326
- 'right' => __( 'Right','wp-show-posts' )
327
- ),
328
- 'attr' => array( 'id' => 'wpsp-image-alignment' )
329
- )
330
- );
331
-
332
- $manager->register_setting(
333
- 'wpsp_image_alignment', // Same as control name.
334
- array(
335
- 'sanitize_callback' => 'sanitize_text_field',
336
- 'default' => $defaults[ 'wpsp_image_alignment' ] ? $defaults[ 'wpsp_image_alignment' ] : ''
337
- )
338
- );
339
-
340
- $manager->register_control(
341
- 'wpsp_image_location', // Same as setting name.
342
- array(
343
- 'type' => 'select',
344
- 'section' => 'wpsp_images',
345
- 'label' => esc_html__( 'Image location', 'wp-show-posts' ),
346
- 'choices' => array(
347
- 'below-title' => __( 'Below title','wp-show-posts' ),
348
- 'above-title' => __( 'Above title','wp-show-posts' )
349
- ),
350
- 'attr' => array( 'id' => 'wpsp-image-location' )
351
- )
352
- );
353
-
354
- $manager->register_setting(
355
- 'wpsp_image_location', // Same as control name.
356
- array(
357
- 'sanitize_callback' => 'sanitize_text_field',
358
- 'default' => $defaults[ 'wpsp_image_location' ] ? $defaults[ 'wpsp_image_location' ] : ''
359
- )
360
- );
361
-
362
- $manager->register_section(
363
- 'wpsp_content',
364
- array(
365
- 'label' => esc_html__( 'Content', 'wp-show-posts' ),
366
- 'icon' => 'dashicons-editor-alignleft'
367
- )
368
- );
369
-
370
- $manager->register_control(
371
- 'wpsp_content_type', // Same as setting name.
372
- array(
373
- 'type' => 'select',
374
- 'section' => 'wpsp_content',
375
- 'label' => esc_html__( 'Content type', 'wp-show-posts' ),
376
- 'choices' => array(
377
- 'excerpt' => __( 'Excerpt','wp-show-posts' ),
378
- 'full' => __( 'Full','wp-show-posts' ),
379
- 'none' => __( 'None','wp-show-posts' )
380
- ),
381
- 'attr' => array( 'id' => 'wpsp-content-type' )
382
- )
383
- );
384
-
385
- $manager->register_setting(
386
- 'wpsp_content_type', // Same as control name.
387
- array(
388
- 'sanitize_callback' => 'sanitize_text_field',
389
- 'default' => $defaults[ 'wpsp_content_type' ] ? $defaults[ 'wpsp_content_type' ] : ''
390
- )
391
- );
392
-
393
- $manager->register_control(
394
- 'wpsp_excerpt_length', // Same as setting name.
395
- array(
396
- 'type' => 'number',
397
- 'section' => 'wpsp_content',
398
- 'label' => esc_html__( 'Excerpt length (words)', 'wp-show-posts' ),
399
- 'attr' => array( 'id' => 'wpsp-excerpt-length' )
400
- )
401
- );
402
-
403
- $manager->register_setting(
404
- 'wpsp_excerpt_length', // Same as control name.
405
- array(
406
- 'sanitize_callback' => 'wpsp_sanitize_absint',
407
- 'default' => $defaults[ 'wpsp_excerpt_length' ] ? $defaults[ 'wpsp_excerpt_length' ] : ''
408
- )
409
- );
410
-
411
- $manager->register_control(
412
- 'wpsp_include_title',
413
- array(
414
- 'type' => 'checkbox',
415
- 'section' => 'wpsp_content',
416
- 'label' => __( 'Include title','wp-show-posts' ),
417
- 'attr' => array( 'id' => 'wpsp-include-title' )
418
- )
419
- );
420
-
421
- $manager->register_setting(
422
- 'wpsp_include_title',
423
- array(
424
- 'sanitize_callback' => 'butterbean_validate_boolean',
425
- 'default' => true
426
- )
427
- );
428
-
429
- $manager->register_control(
430
- 'wpsp_read_more_text', // Same as setting name.
431
- array(
432
- 'type' => 'text',
433
- 'section' => 'wpsp_content',
434
- 'label' => esc_html__( 'Read more text', 'wp-show-posts' )
435
- )
436
- );
437
-
438
- $manager->register_setting(
439
- 'wpsp_read_more_text', // Same as control name.
440
- array(
441
- 'sanitize_callback' => 'wp_kses_post',
442
- 'default' => $defaults[ 'wpsp_read_more_text' ] ? $defaults[ 'wpsp_read_more_text' ] : ''
443
- )
444
- );
445
-
446
- $manager->register_section(
447
- 'wpsp_post_meta',
448
- array(
449
- 'label' => esc_html__( 'Meta', 'wp-show-posts' ),
450
- 'icon' => 'dashicons-editor-ul'
451
- )
452
- );
453
-
454
- $manager->register_control(
455
- 'wpsp_include_author',
456
- array(
457
- 'type' => 'checkbox',
458
- 'section' => 'wpsp_post_meta',
459
- 'label' => __( 'Include author','wp-show-posts' ),
460
- 'attr' => array( 'id' => 'wpsp-include-author' )
461
- )
462
- );
463
-
464
- $manager->register_setting(
465
- 'wpsp_include_author',
466
- array(
467
- 'sanitize_callback' => 'butterbean_validate_boolean',
468
- 'default' => $defaults[ 'wpsp_include_author' ] ? $defaults[ 'wpsp_include_author' ] : false
469
- )
470
- );
471
-
472
- $manager->register_control(
473
- 'wpsp_author_location', // Same as setting name.
474
- array(
475
- 'type' => 'select',
476
- 'section' => 'wpsp_post_meta',
477
- 'label' => esc_html__( 'Author location', 'wp-show-posts' ),
478
- 'choices' => array(
479
- 'below-title' => __( 'Below title','wp-show-posts' ),
480
- 'below-post' => __( 'Below post','wp-show-posts' )
481
- ),
482
- 'attr' => array( 'id' => 'wpsp-author-location' )
483
- )
484
- );
485
-
486
- $manager->register_setting(
487
- 'wpsp_author_location', // Same as control name.
488
- array(
489
- 'sanitize_callback' => 'sanitize_text_field',
490
- 'default' => $defaults[ 'wpsp_author_location' ] ? $defaults[ 'wpsp_author_location' ] : ''
491
- )
492
- );
493
-
494
- $manager->register_control(
495
- 'wpsp_include_date',
496
- array(
497
- 'type' => 'checkbox',
498
- 'section' => 'wpsp_post_meta',
499
- 'label' => __( 'Include date','wp-show-posts' ),
500
- 'attr' => array( 'id' => 'wpsp-include-date' )
501
- )
502
- );
503
-
504
- $manager->register_setting(
505
- 'wpsp_include_date',
506
- array(
507
- 'sanitize_callback' => 'butterbean_validate_boolean',
508
- 'default' => $defaults[ 'wpsp_include_date' ] ? $defaults[ 'wpsp_include_date' ] : false
509
- )
510
- );
511
-
512
- $manager->register_control(
513
- 'wpsp_date_location', // Same as setting name.
514
- array(
515
- 'type' => 'select',
516
- 'section' => 'wpsp_post_meta',
517
- 'label' => esc_html__( 'Date location', 'wp-show-posts' ),
518
- 'choices' => array(
519
- 'below-title' => __( 'Below title','wp-show-posts' ),
520
- 'below-post' => __( 'Below post','wp-show-posts' )
521
- ),
522
- 'attr' => array( 'id' => 'wpsp-date-location' )
523
- )
524
- );
525
-
526
- $manager->register_setting(
527
- 'wpsp_date_location', // Same as control name.
528
- array(
529
- 'sanitize_callback' => 'sanitize_text_field',
530
- 'default' => $defaults[ 'wpsp_date_location' ] ? $defaults[ 'wpsp_date_location' ] : ''
531
- )
532
- );
533
-
534
- $manager->register_control(
535
- 'wpsp_include_terms',
536
- array(
537
- 'type' => 'checkbox',
538
- 'section' => 'wpsp_post_meta',
539
- 'label' => __( 'Include terms','wp-show-posts' ),
540
- 'attr' => array( 'id' => 'wpsp-include-terms' )
541
- )
542
- );
543
-
544
- $manager->register_setting(
545
- 'wpsp_include_terms',
546
- array(
547
- 'sanitize_callback' => 'butterbean_validate_boolean',
548
- 'default' => $defaults[ 'wpsp_include_terms' ] ? $defaults[ 'wpsp_include_terms' ] : false
549
- )
550
- );
551
-
552
- $manager->register_control(
553
- 'wpsp_terms_location', // Same as setting name.
554
- array(
555
- 'type' => 'select',
556
- 'section' => 'wpsp_post_meta',
557
- 'label' => esc_html__( 'Terms location', 'wp-show-posts' ),
558
- 'choices' => array(
559
- 'below-title' => __( 'Below title','wp-show-posts' ),
560
- 'below-post' => __( 'Below post','wp-show-posts' )
561
- ),
562
- 'attr' => array( 'id' => 'wpsp-terms-location' )
563
- )
564
- );
565
-
566
- $manager->register_setting(
567
- 'wpsp_terms_location', // Same as control name.
568
- array(
569
- 'sanitize_callback' => 'sanitize_text_field',
570
- 'default' => $defaults[ 'wpsp_terms_location' ] ? $defaults[ 'wpsp_terms_location' ] : ''
571
- )
572
- );
573
-
574
- $manager->register_section(
575
- 'wpsp_query_args',
576
- array(
577
- 'label' => esc_html__( 'More settings', 'wp-show-posts' ),
578
- 'icon' => 'dashicons-admin-generic',
579
- 'priority' => 999
580
- )
581
- );
582
-
583
- $manager->register_control(
584
- 'wpsp_author', // Same as setting name.
585
- array(
586
- 'type' => 'number',
587
- 'section' => 'wpsp_query_args',
588
- 'label' => esc_html__( 'Author ID', 'wp-show-posts' )
589
- )
590
- );
591
-
592
- $manager->register_setting(
593
- 'wpsp_author', // Same as control name.
594
- array(
595
- 'sanitize_callback' => 'wpsp_sanitize_absint',
596
- 'default' => $defaults[ 'wpsp_author' ] ? $defaults[ 'wpsp_author' ] : ''
597
- )
598
- );
599
-
600
- $manager->register_control(
601
- 'wpsp_exclude_current',
602
- array(
603
- 'type' => 'checkbox',
604
- 'section' => 'wpsp_query_args',
605
- 'label' => __( 'Exclude current','wp-show-posts' ),
606
- 'attr' => array( 'id' => 'wpsp-exclude-current' )
607
- )
608
- );
609
-
610
- $manager->register_setting(
611
- 'wpsp_exclude_current',
612
- array(
613
- 'sanitize_callback' => 'butterbean_validate_boolean',
614
- 'default' => $defaults[ 'wpsp_exclude_current' ] ? $defaults[ 'wpsp_exclude_current' ] : false
615
- )
616
- );
617
-
618
- $manager->register_control(
619
- 'wpsp_post_id', // Same as setting name.
620
- array(
621
- 'type' => 'text',
622
- 'section' => 'wpsp_query_args',
623
- 'label' => esc_html__( 'Post IDs', 'wp-show-posts' )
624
- )
625
- );
626
-
627
- $manager->register_setting(
628
- 'wpsp_post_id', // Same as control name.
629
- array(
630
- 'sanitize_callback' => 'sanitize_text_field',
631
- 'default' => $defaults[ 'wpsp_post_id' ] ? $defaults[ 'wpsp_post_id' ] : ''
632
- )
633
- );
634
-
635
- $manager->register_control(
636
- 'wpsp_exclude_post_id', // Same as setting name.
637
- array(
638
- 'type' => 'text',
639
- 'section' => 'wpsp_query_args',
640
- 'label' => esc_html__( 'Exclude Post IDs', 'wp-show-posts' )
641
- )
642
- );
643
-
644
- $manager->register_setting(
645
- 'wpsp_exclude_post_id', // Same as control name.
646
- array(
647
- 'sanitize_callback' => 'sanitize_text_field',
648
- 'default' => $defaults[ 'wpsp_exclude_post_id' ] ? $defaults[ 'wpsp_exclude_post_id' ] : ''
649
- )
650
- );
651
-
652
- $manager->register_control(
653
- 'wpsp_ignore_sticky_posts',
654
- array(
655
- 'type' => 'checkbox',
656
- 'section' => 'wpsp_query_args',
657
- 'label' => __( 'Ignore sticky posts','wp-show-posts' ),
658
- 'attr' => array( 'id' => 'wpsp-ignore-sticky-posts' )
659
- )
660
- );
661
-
662
- $manager->register_setting(
663
- 'wpsp_ignore_sticky_posts',
664
- array(
665
- 'sanitize_callback' => 'butterbean_validate_boolean',
666
- 'default' => $defaults[ 'wpsp_ignore_sticky_posts' ] ? $defaults[ 'wpsp_ignore_sticky_posts' ] : false
667
- )
668
- );
669
-
670
- $manager->register_control(
671
- 'wpsp_offset', // Same as setting name.
672
- array(
673
- 'type' => 'number',
674
- 'section' => 'wpsp_query_args',
675
- 'label' => esc_html__( 'Offset', 'wp-show-posts' )
676
- )
677
- );
678
-
679
- $manager->register_setting(
680
- 'wpsp_offset', // Same as control name.
681
- array(
682
- 'sanitize_callback' => 'wpsp_sanitize_absint',
683
- 'default' => $defaults[ 'wpsp_offset' ] ? $defaults[ 'wpsp_offset' ] : ''
684
- )
685
- );
686
-
687
- $manager->register_control(
688
- 'wpsp_order', // Same as setting name.
689
- array(
690
- 'type' => 'select',
691
- 'section' => 'wpsp_query_args',
692
- 'label' => esc_html__( 'Order', 'wp-show-posts' ),
693
- 'choices' => array(
694
- 'DESC' => __( 'Descending','wp-show-posts' ),
695
- 'ASC' => __( 'Ascending','wp-show-posts' )
696
- ),
697
- 'attr' => array( 'id' => 'wpsp-order' )
698
- )
699
- );
700
-
701
- $manager->register_setting(
702
- 'wpsp_order', // Same as control name.
703
- array(
704
- 'sanitize_callback' => 'sanitize_text_field',
705
- 'default' => $defaults[ 'wpsp_order' ] ? $defaults[ 'wpsp_order' ] : 'DESC'
706
- )
707
- );
708
-
709
- $manager->register_control(
710
- 'wpsp_orderby', // Same as setting name.
711
- array(
712
- 'type' => 'select',
713
- 'section' => 'wpsp_query_args',
714
- 'label' => esc_html__( 'Order by', 'wp-show-posts' ),
715
- 'choices' => array(
716
- 'none' => __( 'No order','wp-show-posts' ),
717
- 'ID' => __( 'ID','wp-show-posts' ),
718
- 'author' => __( 'Author','wp-show-posts' ),
719
- 'title' => __( 'Title','wp-show-posts' ),
720
- 'name' => __( 'Slug','wp-show-posts' ),
721
- 'type' => __( 'Post type','wp-show-posts' ),
722
- 'date' => __( 'Date','wp-show-posts' ),
723
- 'modified' => __( 'Modified','wp-show-posts' ),
724
- 'parent' => __( 'Parent','wp-show-posts' ),
725
- 'rand' => __( 'Random','wp-show-posts' ),
726
- 'comment_count' => __( 'Comment count','wp-show-posts' )
727
- ),
728
- 'attr' => array( 'id' => 'wpsp-orderby' )
729
- )
730
- );
731
-
732
- $manager->register_setting(
733
- 'wpsp_orderby', // Same as control name.
734
- array(
735
- 'sanitize_callback' => 'sanitize_text_field',
736
- 'default' => $defaults[ 'wpsp_orderby' ] ? $defaults[ 'wpsp_orderby' ] : 'date'
737
- )
738
- );
739
-
740
- $manager->register_control(
741
- 'wpsp_post_status', // Same as setting name.
742
- array(
743
- 'type' => 'select',
744
- 'section' => 'wpsp_query_args',
745
- 'label' => esc_html__( 'Status', 'wp-show-posts' ),
746
- 'choices' => array(
747
- 'publish' => __( 'Published','wp-show-posts' ),
748
- 'pending' => __( 'Pending','wp-show-posts' ),
749
- 'draft' => __( 'Draft','wp-show-posts' ),
750
- 'auto-draft' => __( 'Auto draft','wp-show-posts' ),
751
- 'future' => __( 'Future','wp-show-posts' ),
752
- 'private' => __( 'Private','wp-show-posts' ),
753
- 'inherit' => __( 'Inherit','wp-show-posts' ),
754
- 'trash' => __( 'Trash','wp-show-posts' ),
755
- 'any' => __( 'Any','wp-show-posts' )
756
- ),
757
- 'attr' => array( 'id' => 'wpsp-post-status' )
758
- )
759
- );
760
-
761
- $manager->register_setting(
762
- 'wpsp_post_status', // Same as control name.
763
- array(
764
- 'sanitize_callback' => 'sanitize_text_field',
765
- 'default' => $defaults[ 'wpsp_post_status' ] ? $defaults[ 'wpsp_post_status' ] : 'publish'
766
- )
767
- );
768
-
769
- $manager->register_control(
770
- 'wpsp_meta_key', // Same as setting name.
771
- array(
772
- 'type' => 'text',
773
- 'section' => 'wpsp_query_args',
774
- 'label' => esc_html__( 'Meta key', 'wp-show-posts' )
775
- )
776
- );
777
-
778
- $manager->register_setting(
779
- 'wpsp_meta_key', // Same as control name.
780
- array(
781
- 'sanitize_callback' => 'sanitize_text_field',
782
- 'default' => $defaults[ 'wpsp_meta_key' ] ? $defaults[ 'wpsp_meta_key' ] : ''
783
- )
784
- );
785
-
786
- $manager->register_control(
787
- 'wpsp_meta_value', // Same as setting name.
788
- array(
789
- 'type' => 'text',
790
- 'section' => 'wpsp_query_args',
791
- 'label' => esc_html__( 'Meta value', 'wp-show-posts' )
792
- )
793
- );
794
-
795
- $manager->register_setting(
796
- 'wpsp_meta_value', // Same as control name.
797
- array(
798
- 'sanitize_callback' => 'sanitize_text_field',
799
- 'default' => $defaults[ 'wpsp_meta_value' ] ? $defaults[ 'wpsp_meta_value' ] : ''
800
- )
801
- );
802
-
803
- $manager->register_control(
804
- 'wpsp_tax_operator', // Same as setting name.
805
- array(
806
- 'type' => 'select',
807
- 'section' => 'wpsp_query_args',
808
- 'label' => esc_html__( 'Tax operator', 'wp-show-posts' ),
809
- 'choices' => array(
810
- 'IN' => 'IN',
811
- 'NOT IN' => 'NOT IN',
812
- 'AND' => 'AND',
813
- 'EXISTS' => 'EXISTS',
814
- 'NOT EXISTS' => 'NOT EXISTS'
815
- ),
816
- 'attr' => array( 'id' => 'wpsp-tax-operator' )
817
- )
818
- );
819
-
820
- $manager->register_setting(
821
- 'wpsp_tax_operator', // Same as control name.
822
- array(
823
- 'sanitize_callback' => 'sanitize_text_field',
824
- 'default' => $defaults[ 'wpsp_tax_operator' ] ? $defaults[ 'wpsp_tax_operator' ] : 'IN'
825
- )
826
- );
827
-
828
- $manager->register_control(
829
- 'wpsp_no_results', // Same as setting name.
830
- array(
831
- 'type' => 'text',
832
- 'section' => 'wpsp_query_args',
833
- 'label' => esc_html__( 'No results message', 'wp-show-posts' )
834
- )
835
- );
836
-
837
- $manager->register_setting(
838
- 'wpsp_no_results', // Same as control name.
839
- array(
840
- 'sanitize_callback' => 'wp_kses_post',
841
- 'default' => $defaults[ 'wpsp_no_results' ] ? $defaults[ 'wpsp_no_results' ] : ''
842
- )
843
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
844
  }
845
- endif;
846
-
847
- if ( ! function_exists( 'wpsp_sanitize_intval' ) ) :
848
- /**
849
- * Sanitize our value so it has to be a positive integer
850
- * @since 0.1
851
- */
852
- function wpsp_sanitize_intval( $input ) {
853
- if ( '' == $input )
854
- return $input;
855
-
856
- return intval( $input );
 
857
  }
858
- endif;
859
-
860
- if ( ! function_exists( 'wpsp_sanitize_absint' ) ) :
861
- /**
862
- * Sanitize our value so it can be a negative or positive integer
863
- * @since 0.1
864
- */
865
- function wpsp_sanitize_absint( $input ) {
866
- if ( '' == $input )
867
- return $input;
868
-
869
- return absint( $input );
 
870
  }
871
- endif;
872
-
873
- if ( ! function_exists( 'wpsp_add_meta_boxes' ) ) :
874
- /**
875
- * Add our usage metabox
876
- * @since 0.1
877
- */
878
- add_action( 'add_meta_boxes_wp_show_posts', 'wpsp_add_meta_boxes' );
879
- function wpsp_add_meta_boxes( $post ){
880
- add_meta_box( 'wpsp_shortcode', __( 'Usage', 'wp-show-posts' ), 'wpsp_shortcode_metabox', 'wp_show_posts', 'side', 'low' );
881
  }
882
- endif;
883
-
884
- if ( ! function_exists( 'wpsp_shortcode_metabox' ) ) :
885
- /**
886
- * Meta box display callback.
887
- *
888
- * @param WP_Post $post Current post object.
889
- * @since 0.1
890
- */
891
- function wpsp_shortcode_metabox( $post ) {
892
- ?>
893
- <h4 style="margin-bottom:5px;"><?php _e( 'Shortcode','wp-show-posts' ); ?></h4>
894
- <input type="text" class="widefat" value='[wp_show_posts id="<?php echo $post->ID;?>"]' readonly />
895
-
896
- <h4 style="margin-bottom:5px;"><?php _e( 'Function','wp-show-posts' ); ?></h4>
897
- <input type="text" class="widefat" value='<?php echo esc_attr( "<?php if ( function_exists( 'wpsp_display' ) ) wpsp_display( " . $post->ID . " ); ?>" ); ?>' readonly />
898
- <?php
899
  }
900
- endif;
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
+ if ( ! function_exists( 'wpsp_remove_metaboxes' ) ) {
6
+ add_action( 'add_meta_boxes', 'wpsp_remove_metaboxes', 99 );
7
+ /**
8
+ * Remove all metaboxes from our WP Show Posts post type
9
+ * @since 0.1
10
+ */
11
+ function wpsp_remove_metaboxes( $post_type ){
12
+
13
+ // If we're not in the wp_show_posts post type, bail.
14
+ if ( ! in_array( $post_type, array( 'wp_show_posts' ) ) ) {
15
+ return false;
16
+ }
17
+
18
+ global $wp_meta_boxes;
19
+
20
+ // Don't remove the below
21
+ $exceptions = array(
22
+ 'submitdiv',
23
+ 'butterbean-ui-wp_show_posts',
24
+ 'wpsp_shortcode_metabox'
25
+ );
26
+
27
+ // Loop through all our metaboxes
28
+ if ( ! empty( $wp_meta_boxes ) ) {
29
+ foreach( $wp_meta_boxes as $page => $page_boxes ) {
30
+ if ( ! empty( $page_boxes ) ) {
31
+ foreach( $page_boxes as $context => $box_context ) {
32
+ if ( ! empty( $box_context ) ) {
33
+ foreach( $box_context as $box_type ) {
34
+ if ( ! empty( $box_type ) ) {
35
+ foreach( $box_type as $id => $box ) {
36
+ /** Check to see if the meta box should be removed... */
37
+ if ( ! in_array( $id, $exceptions ) ) {
38
+ remove_meta_box( $id, $page, $context );
39
+ }
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
+ }
50
+
51
+ if ( ! function_exists( 'wpsp_get_post_types' ) ) {
52
+ /**
53
+ * List of all our post types exluding our own
54
+ * @since 0.1
55
+ */
56
+ function wpsp_get_post_types() {
57
+ $post_types = get_post_types( array( 'public' => true ) );
58
+ $types = array();
59
+ foreach ( $post_types as $type ) {
60
+ if ( 'wp_show_posts' !== $type && 'attachment' !== $type ) {
61
+ $types[ $type ] = $type;
62
+ }
63
+ }
64
 
65
+ return $types;
66
+ }
67
  }
68
+
69
+ if ( ! function_exists( 'wpsp_load_butterbean' ) ) {
70
+ add_action( 'plugins_loaded', 'wpsp_load_butterbean' );
71
+ /**
72
+ * Load butterbean inside our post type
73
+ * @since 0.1
74
+ */
75
+ function wpsp_load_butterbean() {
76
+ require_once( trailingslashit( dirname( __FILE__ ) ) . '/butterbean/butterbean.php' );
77
+ }
 
78
  }
79
+
80
+ if ( ! function_exists( 'wpsp_register' ) ) {
81
+ add_action( 'butterbean_register', 'wpsp_register', 10, 2 );
82
+ /**
83
+ * Create all of our metabox options
84
+ * @since 0.1
85
+ */
86
+ function wpsp_register( $butterbean, $post_type ) {
87
+
88
+ $defaults = wpsp_get_defaults();
89
+
90
+ // Register managers, sections, controls, and settings here.
91
+ $butterbean->register_manager(
92
+ 'wp_show_posts',
93
+ array(
94
+ 'label' => esc_html__( 'WP Show Posts', 'wp-show-posts' ),
95
+ 'post_type' => 'wp_show_posts',
96
+ 'context' => 'normal',
97
+ 'priority' => 'high'
98
+ )
99
+ );
100
+
101
+ $manager = $butterbean->get_manager( 'wp_show_posts' );
102
+
103
+ $manager->register_section(
104
+ 'wpsp_posts',
105
+ array(
106
+ 'label' => esc_html__( 'Posts', 'wp-show-posts' ),
107
+ 'icon' => 'dashicons-admin-post'
108
+ )
109
+ );
110
+
111
+ $manager->register_control(
112
+ 'wpsp_post_type', // Same as setting name.
113
+ array(
114
+ 'type' => 'select',
115
+ 'section' => 'wpsp_posts',
116
+ 'label' => esc_html__( 'Post type', 'wp-show-posts' ),
117
+ 'choices' => wpsp_get_post_types(),
118
+ 'attr' => array( 'id' => 'wpsp-post-type' )
119
+ )
120
+ );
121
+
122
+ $manager->register_setting(
123
+ 'wpsp_post_type', // Same as control name.
124
+ array(
125
+ 'sanitize_callback' => 'sanitize_text_field',
126
+ 'default' => $defaults[ 'wpsp_post_type' ] ? $defaults[ 'wpsp_post_type' ] : ''
127
+ )
128
+ );
129
+
130
+ $manager->register_control(
131
+ 'wpsp_taxonomy', // Same as setting name.
132
+ array(
133
+ 'type' => 'select',
134
+ 'section' => 'wpsp_posts',
135
+ 'label' => esc_html__( 'Taxonomy', 'wp-show-posts' ),
136
+ 'choices' => array(),
137
+ 'attr' => array( 'id' => 'wpsp-taxonomy' )
138
+ )
139
+ );
140
+
141
+ $manager->register_setting(
142
+ 'wpsp_taxonomy', // Same as control name.
143
+ array(
144
+ 'sanitize_callback' => 'sanitize_text_field',
145
+ 'default' => $defaults[ 'wpsp_taxonomy' ] ? $defaults[ 'wpsp_taxonomy' ] : ''
146
+ )
147
+ );
148
+
149
+ $manager->register_control(
150
+ 'wpsp_tax_term', // Same as setting name.
151
+ array(
152
+ 'type' => 'checkboxes',
153
+ 'section' => 'wpsp_posts',
154
+ 'label' => esc_html__( 'Terms', 'wp-show-posts' ),
155
+ 'choices' => array(),
156
+ )
157
+ );
158
+
159
+ $manager->register_setting(
160
+ 'wpsp_tax_term', // Same as control name.
161
+ array(
162
+ 'sanitize_callback' => '',
163
+ 'default' => $defaults[ 'wpsp_tax_term' ] ? $defaults[ 'wpsp_tax_term' ] : ''
164
+ )
165
+ );
166
+
167
+ $manager->register_control(
168
+ 'wpsp_posts_per_page', // Same as setting name.
169
+ array(
170
+ 'type' => 'number',
171
+ 'section' => 'wpsp_posts',
172
+ 'label' => esc_html__( 'Posts per page', 'wp-show-posts' )
173
+ )
174
+ );
175
+
176
+ $manager->register_setting(
177
+ 'wpsp_posts_per_page', // Same as control name.
178
+ array(
179
+ 'sanitize_callback' => 'wpsp_sanitize_intval',
180
+ 'default' => $defaults[ 'wpsp_posts_per_page' ] ? $defaults[ 'wpsp_posts_per_page' ] : 10
181
+ )
182
+ );
183
+
184
+ $manager->register_control(
185
+ 'wpsp_pagination',
186
+ array(
187
+ 'type' => 'checkbox',
188
+ 'section' => 'wpsp_posts',
189
+ 'label' => __( 'Pagination','wp-show-posts' ),
190
+ 'description' => __( 'Pagination should only be used if your posts are the only thing in the content area to prevent duplicate content issues.','wp-show-posts' ),
191
+ 'attr' => array( 'id' => 'wpsp-pagination' )
192
+ )
193
+ );
194
+
195
+ $manager->register_setting(
196
+ 'wpsp_pagination',
197
+ array(
198
+ 'sanitize_callback' => 'butterbean_validate_boolean',
199
+ 'default' => $defaults[ 'wpsp_pagination' ] ? $defaults[ 'wpsp_pagination' ] : false
200
+ )
201
+ );
202
+
203
+ $manager->register_section(
204
+ 'wpsp_columns',
205
+ array(
206
+ 'label' => esc_html__( 'Columns', 'wp-show-posts' ),
207
+ 'icon' => 'dashicons-grid-view'
208
+ )
209
+ );
210
+
211
+ $manager->register_control(
212
+ 'wpsp_columns', // Same as setting name.
213
+ array(
214
+ 'type' => 'select',
215
+ 'section' => 'wpsp_columns',
216
+ 'label' => esc_html__( 'Columns', 'wp-show-posts' ),
217
+ 'choices' => array(
218
+ 'col-12' => '1',
219
+ 'col-6' => '2',
220
+ 'col-4' => '3',
221
+ 'col-3' => '4',
222
+ 'col-20' => '5'
223
+ ),
224
+ 'attr' => array( 'id' => 'wpsp-columns' )
225
+ )
226
+ );
227
+
228
+ $manager->register_setting(
229
+ 'wpsp_columns', // Same as control name.
230
+ array(
231
+ 'sanitize_callback' => 'sanitize_text_field',
232
+ 'default' => $defaults[ 'wpsp_columns' ] ? $defaults[ 'wpsp_columns' ] : '12'
233
+ )
234
+ );
235
+
236
+ $manager->register_control(
237
+ 'wpsp_columns_gutter', // Same as setting name.
238
+ array(
239
+ 'type' => 'text',
240
+ 'section' => 'wpsp_columns',
241
+ 'label' => esc_html__( 'Columns gutter', 'wp-show-posts' ),
242
+ 'attr' => array( 'class' => 'widefat' ),
243
+ )
244
+ );
245
+
246
+ $manager->register_setting(
247
+ 'wpsp_columns_gutter', // Same as control name.
248
+ array(
249
+ 'sanitize_callback' => 'sanitize_text_field',
250
+ 'default' => $defaults[ 'wpsp_columns_gutter' ] ? $defaults[ 'wpsp_columns_gutter' ] : ''
251
+ )
252
+ );
253
+
254
+ $manager->register_section(
255
+ 'wpsp_images',
256
+ array(
257
+ 'label' => esc_html__( 'Images', 'wp-show-posts' ),
258
+ 'icon' => 'dashicons-format-image'
259
+ )
260
+ );
261
+
262
+ $manager->register_control(
263
+ 'wpsp_image',
264
+ array(
265
+ 'type' => 'checkbox',
266
+ 'section' => 'wpsp_images',
267
+ 'label' => __( 'Images','wp-show-posts' ),
268
+ 'attr' => array( 'id' => 'wpsp-image' )
269
+ )
270
+ );
271
+
272
+ $manager->register_setting(
273
+ 'wpsp_image',
274
+ array(
275
+ 'sanitize_callback' => 'butterbean_validate_boolean',
276
+ 'default' => $defaults[ 'wpsp_image' ]
277
+ )
278
+ );
279
+
280
+ $manager->register_control(
281
+ 'wpsp_image_width', // Same as setting name.
282
+ array(
283
+ 'type' => 'number',
284
+ 'section' => 'wpsp_images',
285
+ 'label' => esc_html__( 'Image width (px)', 'wp-show-posts' ),
286
+ 'attr' => array( 'id' => 'wpsp-image-width' )
287
+ )
288
+ );
289
+
290
+ $manager->register_setting(
291
+ 'wpsp_image_width', // Same as control name.
292
+ array(
293
+ 'sanitize_callback' => 'wpsp_sanitize_absint',
294
+ 'default' => $defaults[ 'wpsp_image_width' ] ? $defaults[ 'wpsp_image_width' ] : ''
295
+ )
296
+ );
297
+
298
+ $manager->register_control(
299
+ 'wpsp_image_height', // Same as setting name.
300
+ array(
301
+ 'type' => 'number',
302
+ 'section' => 'wpsp_images',
303
+ 'label' => esc_html__( 'Image height (px)', 'wp-show-posts' ),
304
+ 'attr' => array( 'id' => 'wpsp-image-height' )
305
+ )
306
+ );
307
+
308
+ $manager->register_setting(
309
+ 'wpsp_image_height', // Same as control name.
310
+ array(
311
+ 'sanitize_callback' => 'wpsp_sanitize_absint',
312
+ 'default' => $defaults[ 'wpsp_image_height' ] ? $defaults[ 'wpsp_image_height' ] : ''
313
+ )
314
+ );
315
+
316
+ $manager->register_control(
317
+ 'wpsp_image_alignment', // Same as setting name.
318
+ array(
319
+ 'type' => 'select',
320
+ 'section' => 'wpsp_images',
321
+ 'label' => esc_html__( 'Image alignment', 'wp-show-posts' ),
322
+ 'choices' => array(
323
+ 'left' => __( 'Left','wp-show-posts' ),
324
+ 'center' => __( 'Center','wp-show-posts' ),
325
+ 'right' => __( 'Right','wp-show-posts' )
326
+ ),
327
+ 'attr' => array( 'id' => 'wpsp-image-alignment' )
328
+ )
329
+ );
330
+
331
+ $manager->register_setting(
332
+ 'wpsp_image_alignment', // Same as control name.
333
+ array(
334
+ 'sanitize_callback' => 'sanitize_text_field',
335
+ 'default' => $defaults[ 'wpsp_image_alignment' ] ? $defaults[ 'wpsp_image_alignment' ] : ''
336
+ )
337
+ );
338
+
339
+ $manager->register_control(
340
+ 'wpsp_image_location', // Same as setting name.
341
+ array(
342
+ 'type' => 'select',
343
+ 'section' => 'wpsp_images',
344
+ 'label' => esc_html__( 'Image location', 'wp-show-posts' ),
345
+ 'choices' => array(
346
+ 'below-title' => __( 'Below title','wp-show-posts' ),
347
+ 'above-title' => __( 'Above title','wp-show-posts' )
348
+ ),
349
+ 'attr' => array( 'id' => 'wpsp-image-location' )
350
+ )
351
+ );
352
+
353
+ $manager->register_setting(
354
+ 'wpsp_image_location', // Same as control name.
355
+ array(
356
+ 'sanitize_callback' => 'sanitize_text_field',
357
+ 'default' => $defaults[ 'wpsp_image_location' ] ? $defaults[ 'wpsp_image_location' ] : ''
358
+ )
359
+ );
360
+
361
+ $manager->register_section(
362
+ 'wpsp_content',
363
+ array(
364
+ 'label' => esc_html__( 'Content', 'wp-show-posts' ),
365
+ 'icon' => 'dashicons-editor-alignleft'
366
+ )
367
+ );
368
+
369
+ $manager->register_control(
370
+ 'wpsp_content_type', // Same as setting name.
371
+ array(
372
+ 'type' => 'select',
373
+ 'section' => 'wpsp_content',
374
+ 'label' => esc_html__( 'Content type', 'wp-show-posts' ),
375
+ 'choices' => array(
376
+ 'excerpt' => __( 'Excerpt','wp-show-posts' ),
377
+ 'full' => __( 'Full','wp-show-posts' ),
378
+ 'none' => __( 'None','wp-show-posts' )
379
+ ),
380
+ 'attr' => array( 'id' => 'wpsp-content-type' )
381
+ )
382
+ );
383
+
384
+ $manager->register_setting(
385
+ 'wpsp_content_type', // Same as control name.
386
+ array(
387
+ 'sanitize_callback' => 'sanitize_text_field',
388
+ 'default' => $defaults[ 'wpsp_content_type' ] ? $defaults[ 'wpsp_content_type' ] : ''
389
+ )
390
+ );
391
+
392
+ $manager->register_control(
393
+ 'wpsp_excerpt_length', // Same as setting name.
394
+ array(
395
+ 'type' => 'number',
396
+ 'section' => 'wpsp_content',
397
+ 'label' => esc_html__( 'Excerpt length (words)', 'wp-show-posts' ),
398
+ 'attr' => array( 'id' => 'wpsp-excerpt-length' )
399
+ )
400
+ );
401
+
402
+ $manager->register_setting(
403
+ 'wpsp_excerpt_length', // Same as control name.
404
+ array(
405
+ 'sanitize_callback' => 'wpsp_sanitize_absint',
406
+ 'default' => $defaults[ 'wpsp_excerpt_length' ] ? $defaults[ 'wpsp_excerpt_length' ] : ''
407
+ )
408
+ );
409
+
410
+ $manager->register_control(
411
+ 'wpsp_include_title',
412
+ array(
413
+ 'type' => 'checkbox',
414
+ 'section' => 'wpsp_content',
415
+ 'label' => __( 'Include title','wp-show-posts' ),
416
+ 'attr' => array( 'id' => 'wpsp-include-title' )
417
+ )
418
+ );
419
+
420
+ $manager->register_setting(
421
+ 'wpsp_include_title',
422
+ array(
423
+ 'sanitize_callback' => 'butterbean_validate_boolean',
424
+ 'default' => true
425
+ )
426
+ );
427
+
428
+ // Title element
429
+ $manager->register_control(
430
+ 'wpsp_title_element', // Same as setting name.
431
+ array(
432
+ 'type' => 'select',
433
+ 'section' => 'wpsp_content',
434
+ 'label' => esc_html__( 'Title element', 'wp-show-posts-pro' ),
435
+ 'choices' => array(
436
+ '' => '',
437
+ 'p' => 'p',
438
+ 'span' => 'span',
439
+ 'h1' => 'h1',
440
+ 'h2' => 'h2',
441
+ 'h3' => 'h3',
442
+ 'h4' => 'h4',
443
+ 'h5' => 'h5'
444
+ ),
445
+ 'attr' => array( 'id' => 'wpsp-title-element' )
446
+ )
447
+ );
448
+
449
+ $manager->register_setting(
450
+ 'wpsp_title_element', // Same as control name.
451
+ array(
452
+ 'sanitize_callback' => 'sanitize_text_field',
453
+ 'default' => $defaults[ 'wpsp_title_element' ] ? $defaults[ 'wpsp_title_element' ] : ''
454
+ )
455
+ );
456
+
457
+ $manager->register_control(
458
+ 'wpsp_read_more_text', // Same as setting name.
459
+ array(
460
+ 'type' => 'text',
461
+ 'section' => 'wpsp_content',
462
+ 'label' => esc_html__( 'Read more text', 'wp-show-posts' )
463
+ )
464
+ );
465
+
466
+ $manager->register_setting(
467
+ 'wpsp_read_more_text', // Same as control name.
468
+ array(
469
+ 'sanitize_callback' => 'wp_kses_post',
470
+ 'default' => $defaults[ 'wpsp_read_more_text' ] ? $defaults[ 'wpsp_read_more_text' ] : ''
471
+ )
472
+ );
473
+
474
+ $manager->register_section(
475
+ 'wpsp_post_meta',
476
+ array(
477
+ 'label' => esc_html__( 'Meta', 'wp-show-posts' ),
478
+ 'icon' => 'dashicons-editor-ul'
479
+ )
480
+ );
481
+
482
+ $manager->register_control(
483
+ 'wpsp_include_author',
484
+ array(
485
+ 'type' => 'checkbox',
486
+ 'section' => 'wpsp_post_meta',
487
+ 'label' => __( 'Include author','wp-show-posts' ),
488
+ 'attr' => array( 'id' => 'wpsp-include-author' )
489
+ )
490
+ );
491
+
492
+ $manager->register_setting(
493
+ 'wpsp_include_author',
494
+ array(
495
+ 'sanitize_callback' => 'butterbean_validate_boolean',
496
+ 'default' => $defaults[ 'wpsp_include_author' ] ? $defaults[ 'wpsp_include_author' ] : false
497
+ )
498
+ );
499
+
500
+ $manager->register_control(
501
+ 'wpsp_author_location', // Same as setting name.
502
+ array(
503
+ 'type' => 'select',
504
+ 'section' => 'wpsp_post_meta',
505
+ 'label' => esc_html__( 'Author location', 'wp-show-posts' ),
506
+ 'choices' => array(
507
+ 'below-title' => __( 'Below title','wp-show-posts' ),
508
+ 'below-post' => __( 'Below post','wp-show-posts' )
509
+ ),
510
+ 'attr' => array( 'id' => 'wpsp-author-location' )
511
+ )
512
+ );
513
+
514
+ $manager->register_setting(
515
+ 'wpsp_author_location', // Same as control name.
516
+ array(
517
+ 'sanitize_callback' => 'sanitize_text_field',
518
+ 'default' => $defaults[ 'wpsp_author_location' ] ? $defaults[ 'wpsp_author_location' ] : ''
519
+ )
520
+ );
521
+
522
+ $manager->register_control(
523
+ 'wpsp_include_date',
524
+ array(
525
+ 'type' => 'checkbox',
526
+ 'section' => 'wpsp_post_meta',
527
+ 'label' => __( 'Include date','wp-show-posts' ),
528
+ 'attr' => array( 'id' => 'wpsp-include-date' )
529
+ )
530
+ );
531
+
532
+ $manager->register_setting(
533
+ 'wpsp_include_date',
534
+ array(
535
+ 'sanitize_callback' => 'butterbean_validate_boolean',
536
+ 'default' => $defaults[ 'wpsp_include_date' ] ? $defaults[ 'wpsp_include_date' ] : false
537
+ )
538
+ );
539
+
540
+ $manager->register_control(
541
+ 'wpsp_date_location', // Same as setting name.
542
+ array(
543
+ 'type' => 'select',
544
+ 'section' => 'wpsp_post_meta',
545
+ 'label' => esc_html__( 'Date location', 'wp-show-posts' ),
546
+ 'choices' => array(
547
+ 'below-title' => __( 'Below title','wp-show-posts' ),
548
+ 'below-post' => __( 'Below post','wp-show-posts' )
549
+ ),
550
+ 'attr' => array( 'id' => 'wpsp-date-location' )
551
+ )
552
+ );
553
+
554
+ $manager->register_setting(
555
+ 'wpsp_date_location', // Same as control name.
556
+ array(
557
+ 'sanitize_callback' => 'sanitize_text_field',
558
+ 'default' => $defaults[ 'wpsp_date_location' ] ? $defaults[ 'wpsp_date_location' ] : ''
559
+ )
560
+ );
561
+
562
+ $manager->register_control(
563
+ 'wpsp_include_terms',
564
+ array(
565
+ 'type' => 'checkbox',
566
+ 'section' => 'wpsp_post_meta',
567
+ 'label' => __( 'Include terms','wp-show-posts' ),
568
+ 'attr' => array( 'id' => 'wpsp-include-terms' )
569
+ )
570
+ );
571
+
572
+ $manager->register_setting(
573
+ 'wpsp_include_terms',
574
+ array(
575
+ 'sanitize_callback' => 'butterbean_validate_boolean',
576
+ 'default' => $defaults[ 'wpsp_include_terms' ] ? $defaults[ 'wpsp_include_terms' ] : false
577
+ )
578
+ );
579
+
580
+ $manager->register_control(
581
+ 'wpsp_terms_location', // Same as setting name.
582
+ array(
583
+ 'type' => 'select',
584
+ 'section' => 'wpsp_post_meta',
585
+ 'label' => esc_html__( 'Terms location', 'wp-show-posts' ),
586
+ 'choices' => array(
587
+ 'below-title' => __( 'Below title','wp-show-posts' ),
588
+ 'below-post' => __( 'Below post','wp-show-posts' )
589
+ ),
590
+ 'attr' => array( 'id' => 'wpsp-terms-location' )
591
+ )
592
+ );
593
+
594
+ $manager->register_setting(
595
+ 'wpsp_terms_location', // Same as control name.
596
+ array(
597
+ 'sanitize_callback' => 'sanitize_text_field',
598
+ 'default' => $defaults[ 'wpsp_terms_location' ] ? $defaults[ 'wpsp_terms_location' ] : ''
599
+ )
600
+ );
601
+
602
+ $manager->register_control(
603
+ 'wpsp_include_comments',
604
+ array(
605
+ 'type' => 'checkbox',
606
+ 'section' => 'wpsp_post_meta',
607
+ 'label' => __( 'Include comments link','wp-show-posts' ),
608
+ 'attr' => array( 'id' => 'wpsp-include-comments-link' )
609
+ )
610
+ );
611
+
612
+ $manager->register_setting(
613
+ 'wpsp_include_comments',
614
+ array(
615
+ 'sanitize_callback' => 'butterbean_validate_boolean',
616
+ 'default' => $defaults[ 'wpsp_include_comments' ] ? $defaults[ 'wpsp_include_comments' ] : false
617
+ )
618
+ );
619
+
620
+ $manager->register_control(
621
+ 'wpsp_comments_location', // Same as setting name.
622
+ array(
623
+ 'type' => 'select',
624
+ 'section' => 'wpsp_post_meta',
625
+ 'label' => esc_html__( 'Comments link location', 'wp-show-posts' ),
626
+ 'choices' => array(
627
+ 'below-title' => __( 'Below title','wp-show-posts' ),
628
+ 'below-post' => __( 'Below post','wp-show-posts' )
629
+ ),
630
+ 'attr' => array( 'id' => 'wpsp-comments-link-location' )
631
+ )
632
+ );
633
+
634
+ $manager->register_setting(
635
+ 'wpsp_comments_location', // Same as control name.
636
+ array(
637
+ 'sanitize_callback' => 'sanitize_text_field',
638
+ 'default' => $defaults[ 'wpsp_comments_location' ] ? $defaults[ 'wpsp_comments_location' ] : ''
639
+ )
640
+ );
641
+
642
+ $manager->register_section(
643
+ 'wpsp_query_args',
644
+ array(
645
+ 'label' => esc_html__( 'More settings', 'wp-show-posts' ),
646
+ 'icon' => 'dashicons-admin-generic',
647
+ 'priority' => 999
648
+ )
649
+ );
650
+
651
+ $manager->register_control(
652
+ 'wpsp_author', // Same as setting name.
653
+ array(
654
+ 'type' => 'number',
655
+ 'section' => 'wpsp_query_args',
656
+ 'label' => esc_html__( 'Author ID', 'wp-show-posts' )
657
+ )
658
+ );
659
+
660
+ $manager->register_setting(
661
+ 'wpsp_author', // Same as control name.
662
+ array(
663
+ 'sanitize_callback' => 'wpsp_sanitize_absint',
664
+ 'default' => $defaults[ 'wpsp_author' ] ? $defaults[ 'wpsp_author' ] : ''
665
+ )
666
+ );
667
+
668
+ $manager->register_control(
669
+ 'wpsp_exclude_current',
670
+ array(
671
+ 'type' => 'checkbox',
672
+ 'section' => 'wpsp_query_args',
673
+ 'label' => __( 'Exclude current','wp-show-posts' ),
674
+ 'attr' => array( 'id' => 'wpsp-exclude-current' )
675
+ )
676
+ );
677
+
678
+ $manager->register_setting(
679
+ 'wpsp_exclude_current',
680
+ array(
681
+ 'sanitize_callback' => 'butterbean_validate_boolean',
682
+ 'default' => $defaults[ 'wpsp_exclude_current' ] ? $defaults[ 'wpsp_exclude_current' ] : false
683
+ )
684
+ );
685
+
686
+ $manager->register_control(
687
+ 'wpsp_post_id', // Same as setting name.
688
+ array(
689
+ 'type' => 'text',
690
+ 'section' => 'wpsp_query_args',
691
+ 'label' => esc_html__( 'Post IDs', 'wp-show-posts' )
692
+ )
693
+ );
694
+
695
+ $manager->register_setting(
696
+ 'wpsp_post_id', // Same as control name.
697
+ array(
698
+ 'sanitize_callback' => 'sanitize_text_field',
699
+ 'default' => $defaults[ 'wpsp_post_id' ] ? $defaults[ 'wpsp_post_id' ] : ''
700
+ )
701
+ );
702
+
703
+ $manager->register_control(
704
+ 'wpsp_exclude_post_id', // Same as setting name.
705
+ array(
706
+ 'type' => 'text',
707
+ 'section' => 'wpsp_query_args',
708
+ 'label' => esc_html__( 'Exclude Post IDs', 'wp-show-posts' )
709
+ )
710
+ );
711
+
712
+ $manager->register_setting(
713
+ 'wpsp_exclude_post_id', // Same as control name.
714
+ array(
715
+ 'sanitize_callback' => 'sanitize_text_field',
716
+ 'default' => $defaults[ 'wpsp_exclude_post_id' ] ? $defaults[ 'wpsp_exclude_post_id' ] : ''
717
+ )
718
+ );
719
+
720
+ $manager->register_control(
721
+ 'wpsp_ignore_sticky_posts',
722
+ array(
723
+ 'type' => 'checkbox',
724
+ 'section' => 'wpsp_query_args',
725
+ 'label' => __( 'Ignore sticky posts','wp-show-posts' ),
726
+ 'attr' => array( 'id' => 'wpsp-ignore-sticky-posts' )
727
+ )
728
+ );
729
+
730
+ $manager->register_setting(
731
+ 'wpsp_ignore_sticky_posts',
732
+ array(
733
+ 'sanitize_callback' => 'butterbean_validate_boolean',
734
+ 'default' => $defaults[ 'wpsp_ignore_sticky_posts' ] ? $defaults[ 'wpsp_ignore_sticky_posts' ] : false
735
+ )
736
+ );
737
+
738
+ $manager->register_control(
739
+ 'wpsp_offset', // Same as setting name.
740
+ array(
741
+ 'type' => 'number',
742
+ 'section' => 'wpsp_query_args',
743
+ 'label' => esc_html__( 'Offset', 'wp-show-posts' )
744
+ )
745
+ );
746
+
747
+ $manager->register_setting(
748
+ 'wpsp_offset', // Same as control name.
749
+ array(
750
+ 'sanitize_callback' => 'wpsp_sanitize_absint',
751
+ 'default' => $defaults[ 'wpsp_offset' ] ? $defaults[ 'wpsp_offset' ] : ''
752
+ )
753
+ );
754
+
755
+ $manager->register_control(
756
+ 'wpsp_order', // Same as setting name.
757
+ array(
758
+ 'type' => 'select',
759
+ 'section' => 'wpsp_query_args',
760
+ 'label' => esc_html__( 'Order', 'wp-show-posts' ),
761
+ 'choices' => array(
762
+ 'DESC' => __( 'Descending','wp-show-posts' ),
763
+ 'ASC' => __( 'Ascending','wp-show-posts' )
764
+ ),
765
+ 'attr' => array( 'id' => 'wpsp-order' )
766
+ )
767
+ );
768
+
769
+ $manager->register_setting(
770
+ 'wpsp_order', // Same as control name.
771
+ array(
772
+ 'sanitize_callback' => 'sanitize_text_field',
773
+ 'default' => $defaults[ 'wpsp_order' ] ? $defaults[ 'wpsp_order' ] : 'DESC'
774
+ )
775
+ );
776
+
777
+ $manager->register_control(
778
+ 'wpsp_orderby', // Same as setting name.
779
+ array(
780
+ 'type' => 'select',
781
+ 'section' => 'wpsp_query_args',
782
+ 'label' => esc_html__( 'Order by', 'wp-show-posts' ),
783
+ 'choices' => array(
784
+ 'none' => __( 'No order','wp-show-posts' ),
785
+ 'ID' => __( 'ID','wp-show-posts' ),
786
+ 'author' => __( 'Author','wp-show-posts' ),
787
+ 'title' => __( 'Title','wp-show-posts' ),
788
+ 'name' => __( 'Slug','wp-show-posts' ),
789
+ 'type' => __( 'Post type','wp-show-posts' ),
790
+ 'date' => __( 'Date','wp-show-posts' ),
791
+ 'modified' => __( 'Modified','wp-show-posts' ),
792
+ 'parent' => __( 'Parent','wp-show-posts' ),
793
+ 'rand' => __( 'Random','wp-show-posts' ),
794
+ 'comment_count' => __( 'Comment count','wp-show-posts' )
795
+ ),
796
+ 'attr' => array( 'id' => 'wpsp-orderby' )
797
+ )
798
+ );
799
+
800
+ $manager->register_setting(
801
+ 'wpsp_orderby', // Same as control name.
802
+ array(
803
+ 'sanitize_callback' => 'sanitize_text_field',
804
+ 'default' => $defaults[ 'wpsp_orderby' ] ? $defaults[ 'wpsp_orderby' ] : 'date'
805
+ )
806
+ );
807
+
808
+ $manager->register_control(
809
+ 'wpsp_post_status', // Same as setting name.
810
+ array(
811
+ 'type' => 'select',
812
+ 'section' => 'wpsp_query_args',
813
+ 'label' => esc_html__( 'Status', 'wp-show-posts' ),
814
+ 'choices' => array(
815
+ 'publish' => __( 'Published','wp-show-posts' ),
816
+ 'pending' => __( 'Pending','wp-show-posts' ),
817
+ 'draft' => __( 'Draft','wp-show-posts' ),
818
+ 'auto-draft' => __( 'Auto draft','wp-show-posts' ),
819
+ 'future' => __( 'Future','wp-show-posts' ),
820
+ 'private' => __( 'Private','wp-show-posts' ),
821
+ 'inherit' => __( 'Inherit','wp-show-posts' ),
822
+ 'trash' => __( 'Trash','wp-show-posts' ),
823
+ 'any' => __( 'Any','wp-show-posts' )
824
+ ),
825
+ 'attr' => array( 'id' => 'wpsp-post-status' )
826
+ )
827
+ );
828
+
829
+ $manager->register_setting(
830
+ 'wpsp_post_status', // Same as control name.
831
+ array(
832
+ 'sanitize_callback' => 'sanitize_text_field',
833
+ 'default' => $defaults[ 'wpsp_post_status' ] ? $defaults[ 'wpsp_post_status' ] : 'publish'
834
+ )
835
+ );
836
+
837
+ $manager->register_control(
838
+ 'wpsp_meta_key', // Same as setting name.
839
+ array(
840
+ 'type' => 'text',
841
+ 'section' => 'wpsp_query_args',
842
+ 'label' => esc_html__( 'Meta key', 'wp-show-posts' )
843
+ )
844
+ );
845
+
846
+ $manager->register_setting(
847
+ 'wpsp_meta_key', // Same as control name.
848
+ array(
849
+ 'sanitize_callback' => 'sanitize_text_field',
850
+ 'default' => $defaults[ 'wpsp_meta_key' ] ? $defaults[ 'wpsp_meta_key' ] : ''
851
+ )
852
+ );
853
+
854
+ $manager->register_control(
855
+ 'wpsp_meta_value', // Same as setting name.
856
+ array(
857
+ 'type' => 'text',
858
+ 'section' => 'wpsp_query_args',
859
+ 'label' => esc_html__( 'Meta value', 'wp-show-posts' )
860
+ )
861
+ );
862
+
863
+ $manager->register_setting(
864
+ 'wpsp_meta_value', // Same as control name.
865
+ array(
866
+ 'sanitize_callback' => 'sanitize_text_field',
867
+ 'default' => $defaults[ 'wpsp_meta_value' ] ? $defaults[ 'wpsp_meta_value' ] : ''
868
+ )
869
+ );
870
+
871
+ $manager->register_control(
872
+ 'wpsp_tax_operator', // Same as setting name.
873
+ array(
874
+ 'type' => 'select',
875
+ 'section' => 'wpsp_query_args',
876
+ 'label' => esc_html__( 'Tax operator', 'wp-show-posts' ),
877
+ 'choices' => array(
878
+ 'IN' => 'IN',
879
+ 'NOT IN' => 'NOT IN',
880
+ 'AND' => 'AND',
881
+ 'EXISTS' => 'EXISTS',
882
+ 'NOT EXISTS' => 'NOT EXISTS'
883
+ ),
884
+ 'attr' => array( 'id' => 'wpsp-tax-operator' )
885
+ )
886
+ );
887
+
888
+ $manager->register_setting(
889
+ 'wpsp_tax_operator', // Same as control name.
890
+ array(
891
+ 'sanitize_callback' => 'sanitize_text_field',
892
+ 'default' => $defaults[ 'wpsp_tax_operator' ] ? $defaults[ 'wpsp_tax_operator' ] : 'IN'
893
+ )
894
+ );
895
+
896
+ $manager->register_control(
897
+ 'wpsp_no_results', // Same as setting name.
898
+ array(
899
+ 'type' => 'text',
900
+ 'section' => 'wpsp_query_args',
901
+ 'label' => esc_html__( 'No results message', 'wp-show-posts' )
902
+ )
903
+ );
904
+
905
+ $manager->register_setting(
906
+ 'wpsp_no_results', // Same as control name.
907
+ array(
908
+ 'sanitize_callback' => 'wp_kses_post',
909
+ 'default' => $defaults[ 'wpsp_no_results' ] ? $defaults[ 'wpsp_no_results' ] : ''
910
+ )
911
+ );
912
+ }
913
  }
914
+
915
+ if ( ! function_exists( 'wpsp_sanitize_intval' ) ) {
916
+ /**
917
+ * Sanitize our value so it has to be a positive integer
918
+ * @since 0.1
919
+ */
920
+ function wpsp_sanitize_intval( $input ) {
921
+ if ( '' == $input ) {
922
+ return $input;
923
+ }
924
+
925
+ return intval( $input );
926
+ }
927
  }
928
+
929
+ if ( ! function_exists( 'wpsp_sanitize_absint' ) ) {
930
+ /**
931
+ * Sanitize our value so it can be a negative or positive integer
932
+ * @since 0.1
933
+ */
934
+ function wpsp_sanitize_absint( $input ) {
935
+ if ( '' == $input ) {
936
+ return $input;
937
+ }
938
+
939
+ return absint( $input );
940
+ }
941
  }
942
+
943
+ if ( ! function_exists( 'wpsp_add_meta_boxes' ) ) {
944
+ add_action( 'add_meta_boxes_wp_show_posts', 'wpsp_add_meta_boxes' );
945
+ /**
946
+ * Add our usage metabox
947
+ * @since 0.1
948
+ */
949
+ function wpsp_add_meta_boxes( $post ){
950
+ add_meta_box( 'wpsp_shortcode', __( 'Usage', 'wp-show-posts' ), 'wpsp_shortcode_metabox', 'wp_show_posts', 'side', 'low' );
951
+ }
952
  }
953
+
954
+ if ( ! function_exists( 'wpsp_shortcode_metabox' ) ) {
955
+ /**
956
+ * Meta box display callback.
957
+ *
958
+ * @param WP_Post $post Current post object.
959
+ * @since 0.1
960
+ */
961
+ function wpsp_shortcode_metabox( $post ) {
962
+ ?>
963
+ <h4 style="margin-bottom:5px;"><?php _e( 'Shortcode','wp-show-posts' ); ?></h4>
964
+ <input type="text" class="widefat" value='[wp_show_posts id="<?php echo $post->ID;?>"]' readonly />
965
+
966
+ <h4 style="margin-bottom:5px;"><?php _e( 'Function','wp-show-posts' ); ?></h4>
967
+ <input type="text" class="widefat" value='<?php echo esc_attr( "<?php if ( function_exists( 'wpsp_display' ) ) wpsp_display( " . $post->ID . " ); ?>" ); ?>' readonly />
968
+ <?php
969
+ }
970
  }
 
admin/post-type.php CHANGED
@@ -1,60 +1,62 @@
1
  <?php
2
  // No direct access, please
3
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
4
 
5
- if ( ! function_exists( 'wp_show_posts_type' ) ) :
6
- /**
7
- * Create our WP Show Posts post type
8
- * @since 0.1
9
- */
10
- add_action( 'init', 'wp_show_posts_type', 0 );
11
- function wp_show_posts_type() {
12
 
13
- $labels = array(
14
- 'name' => _x( 'Post Lists', 'Post Type General Name', 'wp-show-posts' ),
15
- 'singular_name' => _x( 'Post List', 'Post Type Singular Name', 'wp-show-posts' ),
16
- 'menu_name' => __( 'WP Show Posts', 'wp-show-posts' ),
17
- 'name_admin_bar' => __( 'WP Show Posts', 'wp-show-posts' ),
18
- 'archives' => __( 'List Archives', 'wp-show-posts' ),
19
- 'parent_item_colon' => __( 'Parent List:', 'wp-show-posts' ),
20
- 'all_items' => __( 'All Lists', 'wp-show-posts' ),
21
- 'add_new_item' => __( 'Add New List', 'wp-show-posts' ),
22
- 'add_new' => __( 'Add New', 'wp-show-posts' ),
23
- 'new_item' => __( 'New List', 'wp-show-posts' ),
24
- 'edit_item' => __( 'Edit List', 'wp-show-posts' ),
25
- 'update_item' => __( 'Update List', 'wp-show-posts' ),
26
- 'view_item' => __( 'View List', 'wp-show-posts' ),
27
- 'search_items' => __( 'Search List', 'wp-show-posts' ),
28
- 'not_found' => __( 'Not found', 'wp-show-posts' ),
29
- 'not_found_in_trash' => __( 'Not found in Trash', 'wp-show-posts' ),
30
- 'featured_image' => __( 'Featured Image', 'wp-show-posts' ),
31
- 'set_featured_image' => __( 'Set featured image', 'wp-show-posts' ),
32
- 'remove_featured_image' => __( 'Remove featured image', 'wp-show-posts' ),
33
- 'use_featured_image' => __( 'Use as featured image', 'wp-show-posts' ),
34
- 'insert_into_item' => __( 'Insert into list', 'wp-show-posts' ),
35
- 'uploaded_to_this_item' => __( 'Uploaded to this list', 'wp-show-posts' ),
36
- 'items_list' => __( 'Items list', 'wp-show-posts' ),
37
- 'items_list_navigation' => __( 'Items list navigation', 'wp-show-posts' ),
38
- 'filter_items_list' => __( 'Filter items list', 'wp-show-posts' ),
39
- );
40
- $args = array(
41
- 'label' => __( 'Post List', 'wp-show-posts' ),
42
- 'labels' => $labels,
43
- 'supports' => array( 'title' ),
44
- 'hierarchical' => false,
45
- 'public' => false,
46
- 'show_ui' => true,
47
- 'show_in_menu' => true,
48
- 'menu_position' => 5,
49
- 'show_in_admin_bar' => false,
50
- 'show_in_nav_menus' => false,
51
- 'can_export' => true,
52
- 'has_archive' => false,
53
- 'exclude_from_search' => true,
54
- 'publicly_queryable' => false,
55
- 'capability_type' => 'page',
56
- );
57
- register_post_type( 'wp_show_posts', $args );
58
 
 
59
  }
60
- endif;
1
  <?php
2
  // No direct access, please
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
 
7
+ if ( ! function_exists( 'wp_show_posts_type' ) ) {
8
+ add_action( 'init', 'wp_show_posts_type', 0 );
9
+ /**
10
+ * Create our WP Show Posts post type
11
+ * @since 0.1
12
+ */
13
+ function wp_show_posts_type() {
14
 
15
+ $labels = array(
16
+ 'name' => _x( 'Post Lists', 'Post Type General Name', 'wp-show-posts' ),
17
+ 'singular_name' => _x( 'Post List', 'Post Type Singular Name', 'wp-show-posts' ),
18
+ 'menu_name' => __( 'WP Show Posts', 'wp-show-posts' ),
19
+ 'name_admin_bar' => __( 'WP Show Posts', 'wp-show-posts' ),
20
+ 'archives' => __( 'List Archives', 'wp-show-posts' ),
21
+ 'parent_item_colon' => __( 'Parent List:', 'wp-show-posts' ),
22
+ 'all_items' => __( 'All Lists', 'wp-show-posts' ),
23
+ 'add_new_item' => __( 'Add New List', 'wp-show-posts' ),
24
+ 'add_new' => __( 'Add New', 'wp-show-posts' ),
25
+ 'new_item' => __( 'New List', 'wp-show-posts' ),
26
+ 'edit_item' => __( 'Edit List', 'wp-show-posts' ),
27
+ 'update_item' => __( 'Update List', 'wp-show-posts' ),
28
+ 'view_item' => __( 'View List', 'wp-show-posts' ),
29
+ 'search_items' => __( 'Search List', 'wp-show-posts' ),
30
+ 'not_found' => __( 'Not found', 'wp-show-posts' ),
31
+ 'not_found_in_trash' => __( 'Not found in Trash', 'wp-show-posts' ),
32
+ 'featured_image' => __( 'Featured Image', 'wp-show-posts' ),
33
+ 'set_featured_image' => __( 'Set featured image', 'wp-show-posts' ),
34
+ 'remove_featured_image' => __( 'Remove featured image', 'wp-show-posts' ),
35
+ 'use_featured_image' => __( 'Use as featured image', 'wp-show-posts' ),
36
+ 'insert_into_item' => __( 'Insert into list', 'wp-show-posts' ),
37
+ 'uploaded_to_this_item' => __( 'Uploaded to this list', 'wp-show-posts' ),
38
+ 'items_list' => __( 'Items list', 'wp-show-posts' ),
39
+ 'items_list_navigation' => __( 'Items list navigation', 'wp-show-posts' ),
40
+ 'filter_items_list' => __( 'Filter items list', 'wp-show-posts' ),
41
+ );
42
+ $args = array(
43
+ 'label' => __( 'Post List', 'wp-show-posts' ),
44
+ 'labels' => $labels,
45
+ 'supports' => array( 'title' ),
46
+ 'hierarchical' => false,
47
+ 'public' => false,
48
+ 'show_ui' => true,
49
+ 'show_in_menu' => true,
50
+ 'menu_position' => 5,
51
+ 'show_in_admin_bar' => false,
52
+ 'show_in_nav_menus' => false,
53
+ 'can_export' => true,
54
+ 'has_archive' => false,
55
+ 'exclude_from_search' => true,
56
+ 'publicly_queryable' => false,
57
+ 'capability_type' => 'page',
58
+ );
59
+ register_post_type( 'wp_show_posts', $args );
60
 
61
+ }
62
  }
 
admin/widget.php CHANGED
@@ -1,104 +1,112 @@
1
  <?php
2
  // No direct access, please
3
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
4
 
5
  /**
6
  * Adds WPSP_Widget widget.
7
  */
8
- if ( ! class_exists( 'WPSP_Widget' ) ) :
9
- class WPSP_Widget extends WP_Widget {
10
 
11
- /**
12
- * Register widget with WordPress.
13
- */
14
- function __construct() {
15
- parent::__construct(
16
- 'wpsp_widget', // Base ID
17
- __( 'WP Show Posts', 'wp-show-posts' )
18
- );
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- /**
22
- * Front-end display of widget.
23
- *
24
- * @see WP_Widget::widget()
25
- *
26
- * @param array $args Widget arguments.
27
- * @param array $instance Saved values from database.
28
- */
29
- public function widget( $args, $instance ) {
30
- echo $args['before_widget'];
31
- if ( ! empty( $instance['title'] ) ) {
32
- echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
33
  }
34
- if ( function_exists( 'wpsp_display' ) ) wpsp_display( absint( $instance['wpsp_id'] ) );
35
- echo $args['after_widget'];
36
- }
37
 
38
- /**
39
- * Back-end widget form.
40
- *
41
- * @see WP_Widget::form()
42
- *
43
- * @param array $instance Previously saved values from database.
44
- */
45
- public function form( $instance ) {
46
- $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
47
- $id = ! empty( $instance['wpsp_id'] ) ? $instance['wpsp_id'] : '';
48
- ?>
49
- <p>
50
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( esc_attr( 'Title:' ) ); ?></label>
51
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
52
- </p>
53
- <p>
54
- <select name="<?php echo $this->get_field_name( 'wpsp_id' );?>" id="<?php echo $this->get_field_id( 'wpsp_id' );?>">
55
- <option value=""></option>
56
- <?php
57
- $args = array(
58
- 'posts_per_page' => -1,
59
- 'post_type' => 'wp_show_posts',
60
- 'post_status' => 'publish',
61
- 'showposts' => -1
62
- );
63
- $posts = get_posts( $args );
64
 
65
- $count = count( $posts );
66
- $types = array();
67
- if ( $count > 0 ) {
68
- foreach ( $posts as $post ) {
69
- echo '<option value="' . $post->ID . '"' . selected( $id, $post->ID ) . '>' . $post->post_title . '</option>';
 
70
  }
71
- }
72
- ?>
73
- </select>
74
- </p>
75
- <?php
76
- }
77
 
78
- /**
79
- * Sanitize widget form values as they are saved.
80
- *
81
- * @see WP_Widget::update()
82
- *
83
- * @param array $new_instance Values just sent to be saved.
84
- * @param array $old_instance Previously saved values from database.
85
- *
86
- * @return array Updated safe values to be saved.
87
- */
88
- public function update( $new_instance, $old_instance ) {
89
- $instance = array();
90
- $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
91
- $instance['wpsp_id'] = ( ! empty( $new_instance['wpsp_id'] ) ) ? absint( $new_instance['wpsp_id'] ) : '';
92
 
93
- return $instance;
94
- }
95
 
96
- } // class WPSP_Widget
97
- endif;
98
 
99
- if ( ! function_exists( 'wpsp_register_widget' ) ) :
100
- add_action( 'widgets_init', 'wpsp_register_widget' );
101
- function wpsp_register_widget() {
102
- register_widget( 'WPSP_Widget' );
 
 
103
  }
104
- endif;
1
  <?php
2
  // No direct access, please
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
 
7
  /**
8
  * Adds WPSP_Widget widget.
9
  */
10
+ if ( ! class_exists( 'WPSP_Widget' ) ) {
11
+ class WPSP_Widget extends WP_Widget {
12
 
13
+ /**
14
+ * Register widget with WordPress.
15
+ */
16
+ function __construct() {
17
+ parent::__construct(
18
+ 'wpsp_widget', // Base ID
19
+ __( 'WP Show Posts', 'wp-show-posts' )
20
+ );
21
+ }
22
+
23
+ /**
24
+ * Front-end display of widget.
25
+ *
26
+ * @see WP_Widget::widget()
27
+ *
28
+ * @param array $args Widget arguments.
29
+ * @param array $instance Saved values from database.
30
+ */
31
+ public function widget( $args, $instance ) {
32
+ echo $args['before_widget'];
33
+
34
+ if ( ! empty( $instance['title'] ) ) {
35
+ echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
36
+ }
37
 
38
+ if ( function_exists( 'wpsp_display' ) ) {
39
+ wpsp_display( absint( $instance['wpsp_id'] ) );
40
+ }
41
+
42
+ echo $args['after_widget'];
 
 
 
 
 
 
 
43
  }
 
 
 
44
 
45
+ /**
46
+ * Back-end widget form.
47
+ *
48
+ * @see WP_Widget::form()
49
+ *
50
+ * @param array $instance Previously saved values from database.
51
+ */
52
+ public function form( $instance ) {
53
+ $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
54
+ $id = ! empty( $instance['wpsp_id'] ) ? $instance['wpsp_id'] : '';
55
+ ?>
56
+ <p>
57
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( esc_attr( 'Title:' ) ); ?></label>
58
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
59
+ </p>
60
+ <p>
61
+ <select name="<?php echo $this->get_field_name( 'wpsp_id' );?>" id="<?php echo $this->get_field_id( 'wpsp_id' );?>">
62
+ <option value=""></option>
63
+ <?php
64
+ $args = array(
65
+ 'posts_per_page' => -1,
66
+ 'post_type' => 'wp_show_posts',
67
+ 'post_status' => 'publish',
68
+ 'showposts' => -1
69
+ );
70
+ $posts = get_posts( $args );
71
 
72
+ $count = count( $posts );
73
+ $types = array();
74
+ if ( $count > 0 ) {
75
+ foreach ( $posts as $post ) {
76
+ echo '<option value="' . $post->ID . '"' . selected( $id, $post->ID ) . '>' . $post->post_title . '</option>';
77
+ }
78
  }
79
+ ?>
80
+ </select>
81
+ </p>
82
+ <?php
83
+ }
 
84
 
85
+ /**
86
+ * Sanitize widget form values as they are saved.
87
+ *
88
+ * @see WP_Widget::update()
89
+ *
90
+ * @param array $new_instance Values just sent to be saved.
91
+ * @param array $old_instance Previously saved values from database.
92
+ *
93
+ * @return array Updated safe values to be saved.
94
+ */
95
+ public function update( $new_instance, $old_instance ) {
96
+ $instance = array();
97
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
98
+ $instance['wpsp_id'] = ( ! empty( $new_instance['wpsp_id'] ) ) ? absint( $new_instance['wpsp_id'] ) : '';
99
 
100
+ return $instance;
101
+ }
102
 
103
+ } // class WPSP_Widget
104
+ }
105
 
106
+ if ( ! function_exists( 'wpsp_register_widget' ) ) {
107
+ add_action( 'widgets_init', 'wpsp_register_widget' );
108
+
109
+ function wpsp_register_widget() {
110
+ register_widget( 'WPSP_Widget' );
111
+ }
112
  }
 
css/wp-show-posts-min.css CHANGED
@@ -1 +1 @@
1
- body .wp-show-posts a{box-shadow:0 0 0 transparent}.wp-show-posts-entry-title a{text-decoration:none}a.wp-show-posts-read-more,a.wp-show-posts-read-more:visited{display:inline-block;padding:8px 15px;border:2px solid #222;border-radius:3px;color:#222;font-size:0.8em;text-decoration:none}.wpsp-read-more{margin:0 0 1em;display:inline-block}a.wp-show-posts-read-more:hover,a.wp-show-posts-read-more:focus{border:2px solid transparent;color:#fff;background:#222;text-decoration:none}.wp-show-posts-image{margin-bottom:1em}.wp-show-posts-image.wpsp-image-left{float:left;margin-right:1.5em}.wp-show-posts-image.wpsp-image-right{float:right;margin-left:1.5em}.wp-show-posts-image.wpsp-image-center{display:block;text-align:center}.wp-show-posts-image img{margin:0 !important;vertical-align:bottom;height:auto}.wp-show-posts-entry-header{margin:0 0 1em;padding:0}.wp-show-posts .wp-show-posts-entry-title{font-size:30px;line-height:35px;margin:0}.wp-show-posts-updated{display:none}.wp-show-posts-entry-summary,.wp-show-posts-entry-content{margin-bottom:1em}.wp-show-posts-entry-meta{font-size:0.8em}.wp-show-posts-separator{opacity:0.5}.wp-show-posts-meta a,.wp-show-posts-meta a:visited{color:rgba( 0,0,0,0.5 )}.stack-wp-show-posts-byline,.stack-wp-show-posts-posted-on{display:block}.wp-show-posts-entry-meta-below-post{margin-bottom:1em}.wp-show-posts-columns:not(.wp-show-posts-masonry){display:flex;flex-wrap:wrap}.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block){display:flex;flex-direction:row}.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block) .wp-show-posts-image img{flex:0 0 auto;object-fit:scale-down}.wpsp-clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0}.wp-show-posts:not(.wp-show-posts-columns) .wp-show-posts-single:not(:last-child){margin-bottom:2em}.wpsp-load-more{margin-top:2em}.wp-show-posts-columns .wp-show-posts-entry-title{font-size:25px}.wp-show-posts-columns .wp-show-posts-single.col-md-4 .wp-show-posts-entry-title,.wp-show-posts-columns .wp-show-posts-single.col-md-3 .wp-show-posts-entry-title,.wp-show-posts-columns .wp-show-posts-single.col-md-20 .wp-show-posts-entry-title{font-size:20px}.wp-show-posts-columns .wp-show-posts-inner{flex:1}@media (min-width: 768px){.wpsp-col-1,.wpsp-col-2,.wpsp-col-3,.wpsp-col-4,.wpsp-col-5,.wpsp-col-6,.wpsp-col-7,.wpsp-col-8,.wpsp-col-9,.wpsp-col-10,.wpsp-col-11,.wpsp-col-12,.wpsp-col-20{float:left}.wpsp-col-1{width:8.333333%}.wpsp-col-2{width:16.666667%}.wpsp-col-3{width:25%}.wpsp-col-4{width:33.333%}.wpsp-col-5{width:41.666667%}.wpsp-col-6{width:50%}.wpsp-col-7{width:58.333333%}.wpsp-col-8{width:66.666667%}.wpsp-col-9{width:75%}.wpsp-col-10{width:83.333333%}.wpsp-col-11{width:91.666667%}.wpsp-col-12{width:100%}.wpsp-col-20{width:20%}}@media (max-width: 767px){.wp-show-posts-columns,.wp-show-posts-inner{margin-left:0 !important;margin-right:0 !important}.wp-show-posts-columns .wp-show-posts-single{display:block;width:100%}}.wp-show-posts-inner *:last-child{margin-bottom:0}.screen-reader-text{clip:rect(1px, 1px, 1px, 1px);position:absolute !important}.screen-reader-text:hover,.screen-reader-text:active,.screen-reader-text:focus{background-color:#f1f1f1;border-radius:3px;box-shadow:0 0 2px 2px rgba(0, 0, 0, 0.6);clip:auto !important;color:#21759b;display:block;font-size:14px;font-weight:bold;height:auto;left:5px;line-height:normal;padding:15px 23px 14px;text-decoration:none;top:5px;width:auto;z-index:100000}.wpsp-clearfix:after{content:".";display:block;overflow:hidden;visibility:hidden;font-size:0;line-height:0;width:0;height:0}
1
+ body .wp-show-posts a{box-shadow:0 0 0 transparent}.wp-show-posts-entry-title a{text-decoration:none}a.wp-show-posts-read-more,a.wp-show-posts-read-more:visited{display:inline-block;padding:8px 15px;border:2px solid #222;color:#222;font-size:0.8em;text-decoration:none}.wpsp-read-more{margin:0 0 1em;display:inline-block}a.wp-show-posts-read-more:hover,a.wp-show-posts-read-more:focus{border:2px solid transparent;color:#fff;background:#222;text-decoration:none}.wp-show-posts-image{margin-bottom:1em}.wp-show-posts-image.wpsp-image-left{float:left;margin-right:1.5em}.wp-show-posts-image.wpsp-image-right{float:right;margin-left:1.5em}.wp-show-posts-image.wpsp-image-center{display:block;text-align:center}.wp-show-posts-image img{margin:0 !important;vertical-align:bottom;height:auto}.wp-show-posts-entry-header{margin:0 0 1em;padding:0}.wp-show-posts .wp-show-posts-entry-title{font-size:30px;line-height:1.5em;margin:0}.wp-show-posts-updated{display:none}.wp-show-posts-entry-summary,.wp-show-posts-entry-content{margin-bottom:1em}.wp-show-posts-entry-meta{font-size:0.8em}.wp-show-posts-separator{opacity:0.5}.wp-show-posts-meta a,.wp-show-posts-meta a:visited{color:rgba( 0,0,0,0.5 )}.stack-wp-show-posts-byline,.stack-wp-show-posts-posted-on{display:block}.wp-show-posts-entry-meta-below-post{margin-bottom:1em}.wp-show-posts-columns:not(.wp-show-posts-masonry){display:flex;flex-wrap:wrap}.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block){display:flex;flex-direction:row}.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block) .wp-show-posts-image img{flex:0 0 auto;object-fit:scale-down}.wpsp-clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0}.wp-show-posts:not(.wp-show-posts-columns) .wp-show-posts-single:not(:last-child){margin-bottom:2em}.wpsp-load-more{margin-top:2em}.wp-show-posts-columns .wp-show-posts-entry-title{font-size:25px}.wp-show-posts-columns .wp-show-posts-single.col-md-4 .wp-show-posts-entry-title,.wp-show-posts-columns .wp-show-posts-single.col-md-3 .wp-show-posts-entry-title,.wp-show-posts-columns .wp-show-posts-single.col-md-20 .wp-show-posts-entry-title{font-size:20px}.wp-show-posts-columns .wp-show-posts-inner{flex:1}.wp-show-posts-inner:after{clear:both;display:table;content:'';width:0;height:0;overflow:hidden;visibility:hidden}.wp-show-posts-single.post {margin-bottom: 0;}@media (min-width: 768px){.wpsp-col-1,.wpsp-col-2,.wpsp-col-3,.wpsp-col-4,.wpsp-col-5,.wpsp-col-6,.wpsp-col-7,.wpsp-col-8,.wpsp-col-9,.wpsp-col-10,.wpsp-col-11,.wpsp-col-12,.wpsp-col-20{float:left}.wpsp-col-1{width:8.333333%}.wpsp-col-2{width:16.666667%}.wpsp-col-3{width:25%}.wpsp-col-4{width:33.333%}.wpsp-col-5{width:41.666667%}.wpsp-col-6{width:50%}.wpsp-col-7{width:58.333333%}.wpsp-col-8{width:66.666667%}.wpsp-col-9{width:75%}.wpsp-col-10{width:83.333333%}.wpsp-col-11{width:91.666667%}.wpsp-col-12{width:100%}.wpsp-col-20{width:20%}}@media (max-width: 767px){.wp-show-posts-columns,.wp-show-posts-inner{margin-left:0 !important;margin-right:0 !important}.wp-show-posts-columns .wp-show-posts-single{display:block;width:100%}.wp-show-posts-image.wpsp-image-left,.wp-show-posts-image.wpsp-image-right{float:none;margin-right:0;margin-left:0}}.wp-show-posts-inner *:last-child{margin-bottom:0}.screen-reader-text{clip:rect(1px, 1px, 1px, 1px);position:absolute !important}.screen-reader-text:hover,.screen-reader-text:active,.screen-reader-text:focus{background-color:#f1f1f1;border-radius:3px;box-shadow:0 0 2px 2px rgba(0, 0, 0, 0.6);clip:auto !important;color:#21759b;display:block;font-size:14px;font-weight:bold;height:auto;left:5px;line-height:normal;padding:15px 23px 14px;text-decoration:none;top:5px;width:auto;z-index:100000}.wpsp-clearfix:after{content:".";display:block;overflow:hidden;visibility:hidden;font-size:0;line-height:0;width:0;height:0}
css/wp-show-posts.css CHANGED
@@ -11,7 +11,6 @@ a.wp-show-posts-read-more:visited {
11
  display: inline-block;
12
  padding: 8px 15px;
13
  border: 2px solid #222;
14
- border-radius: 3px;
15
  color: #222;
16
  font-size: 0.8em;
17
  text-decoration: none;
@@ -62,7 +61,7 @@ a.wp-show-posts-read-more:focus {
62
 
63
  .wp-show-posts .wp-show-posts-entry-title {
64
  font-size: 30px;
65
- line-height: 35px;
66
  margin: 0;
67
  }
68
 
@@ -142,6 +141,20 @@ a.wp-show-posts-read-more:focus {
142
  flex: 1;
143
  }
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  /* Bootstrap grid system */
146
  @media (min-width: 768px) {
147
  .wpsp-col-1, .wpsp-col-2, .wpsp-col-3, .wpsp-col-4, .wpsp-col-5, .wpsp-col-6, .wpsp-col-7, .wpsp-col-8, .wpsp-col-9, .wpsp-col-10, .wpsp-col-11, .wpsp-col-12, .wpsp-col-20 {
@@ -183,7 +196,7 @@ a.wp-show-posts-read-more:focus {
183
  .wpsp-col-12 {
184
  width: 100%;
185
  }
186
-
187
  /* 5 columns */
188
  .wpsp-col-20 {
189
  width: 20%;
@@ -200,6 +213,12 @@ a.wp-show-posts-read-more:focus {
200
  display: block;
201
  width: 100%;
202
  }
 
 
 
 
 
 
203
  }
204
 
205
  /* Spacing */
11
  display: inline-block;
12
  padding: 8px 15px;
13
  border: 2px solid #222;
 
14
  color: #222;
15
  font-size: 0.8em;
16
  text-decoration: none;
61
 
62
  .wp-show-posts .wp-show-posts-entry-title {
63
  font-size: 30px;
64
+ line-height: 1.5em;
65
  margin: 0;
66
  }
67
 
141
  flex: 1;
142
  }
143
 
144
+ .wp-show-posts-inner:after {
145
+ clear: both;
146
+ display: table;
147
+ content: '';
148
+ width: 0;
149
+ height: 0;
150
+ overflow: hidden;
151
+ visibility: hidden;
152
+ }
153
+
154
+ .wp-show-posts-single.post {
155
+ margin-bottom: 0;
156
+ }
157
+
158
  /* Bootstrap grid system */
159
  @media (min-width: 768px) {
160
  .wpsp-col-1, .wpsp-col-2, .wpsp-col-3, .wpsp-col-4, .wpsp-col-5, .wpsp-col-6, .wpsp-col-7, .wpsp-col-8, .wpsp-col-9, .wpsp-col-10, .wpsp-col-11, .wpsp-col-12, .wpsp-col-20 {
196
  .wpsp-col-12 {
197
  width: 100%;
198
  }
199
+
200
  /* 5 columns */
201
  .wpsp-col-20 {
202
  width: 20%;
213
  display: block;
214
  width: 100%;
215
  }
216
+ .wp-show-posts-image.wpsp-image-left,
217
+ .wp-show-posts-image.wpsp-image-right {
218
+ float: none;
219
+ margin-right: 0;
220
+ margin-left: 0;
221
+ }
222
  }
223
 
224
  /* Spacing */
inc/compat.php CHANGED
@@ -2,46 +2,45 @@
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- if ( ! function_exists( 'wpsp_pro_defaults' ) ) :
6
- /**
7
- * Set all of our pro defaults
8
- * This will only run if wpsp_pro_defaults() doesn't exist
9
- * WPSP Pro 0.5 and above won't need this
10
- */
11
- add_filter( 'wpsp_defaults','wpsp_pro_compat_defaults' );
12
- function wpsp_pro_compat_defaults( $defaults )
13
- {
14
- $defaults[ 'wpsp_image_lightbox' ] = false;
15
- $defaults[ 'wpsp_image_gallery' ] = false;
16
- $defaults[ 'wpsp_image_overlay_color' ] = '';
17
- $defaults[ 'wpsp_image_overlay_icon' ] = '';
18
- $defaults[ 'wpsp_ajax_pagination' ] = false;
19
- $defaults[ 'wpsp_masonry' ] = false;
20
- $defaults[ 'wpsp_social_sharing' ] = false;
21
- $defaults[ 'wpsp_social_sharing_alignment' ] = 'right';
22
- $defaults[ 'wpsp_twitter' ] = false;
23
- $defaults[ 'wpsp_facebook' ] = false;
24
- $defaults[ 'wpsp_googleplus' ] = false;
25
- $defaults[ 'wpsp_pinterest' ] = false;
26
- $defaults[ 'wpsp_love' ] = false;
27
- $defaults[ 'wpsp_featured_post' ] = false;
28
- $defaults[ 'wpsp_image_hover_effect' ] = '';
29
- $defaults[ 'wpsp_read_more_style' ] = 'hollow';
30
- $defaults[ 'wpsp_read_more_color' ] = 'black';
31
- $defaults[ 'wpsp_border' ] = '';
32
- $defaults[ 'wpsp_border_hover' ] = '';
33
- $defaults[ 'wpsp_filter' ] = false;
34
- $defaults[ 'wpsp_background' ] = '';
35
- $defaults[ 'wpsp_background_hover' ] = '';
36
- $defaults[ 'wpsp_title_color' ] = '';
37
- $defaults[ 'wpsp_title_color_hover' ] = '';
38
- $defaults[ 'wpsp_meta_color' ] = '';
39
- $defaults[ 'wpsp_meta_color_hover' ] = '';
40
- $defaults[ 'wpsp_text' ] = '';
41
- $defaults[ 'wpsp_link' ] = '';
42
- $defaults[ 'wpsp_link_hover' ] = '';
43
- $defaults[ 'wpsp_padding' ] = '';
44
-
45
- return $defaults;
46
- }
47
- endif;
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
+ if ( ! function_exists( 'wpsp_pro_defaults' ) ) {
6
+ add_filter( 'wpsp_defaults', 'wpsp_pro_compat_defaults' );
7
+ /**
8
+ * Set all of our pro defaults
9
+ * This will only run if wpsp_pro_defaults() doesn't exist
10
+ * WPSP Pro 0.5 and above won't need this
11
+ */
12
+ function wpsp_pro_compat_defaults( $defaults ) {
13
+ $defaults[ 'wpsp_image_lightbox' ] = false;
14
+ $defaults[ 'wpsp_image_gallery' ] = false;
15
+ $defaults[ 'wpsp_image_overlay_color' ] = '';
16
+ $defaults[ 'wpsp_image_overlay_icon' ] = '';
17
+ $defaults[ 'wpsp_ajax_pagination' ] = false;
18
+ $defaults[ 'wpsp_masonry' ] = false;
19
+ $defaults[ 'wpsp_social_sharing' ] = false;
20
+ $defaults[ 'wpsp_social_sharing_alignment' ] = 'right';
21
+ $defaults[ 'wpsp_twitter' ] = false;
22
+ $defaults[ 'wpsp_facebook' ] = false;
23
+ $defaults[ 'wpsp_googleplus' ] = false;
24
+ $defaults[ 'wpsp_pinterest' ] = false;
25
+ $defaults[ 'wpsp_love' ] = false;
26
+ $defaults[ 'wpsp_featured_post' ] = false;
27
+ $defaults[ 'wpsp_image_hover_effect' ] = '';
28
+ $defaults[ 'wpsp_read_more_style' ] = 'hollow';
29
+ $defaults[ 'wpsp_read_more_color' ] = 'black';
30
+ $defaults[ 'wpsp_border' ] = '';
31
+ $defaults[ 'wpsp_border_hover' ] = '';
32
+ $defaults[ 'wpsp_filter' ] = false;
33
+ $defaults[ 'wpsp_background' ] = '';
34
+ $defaults[ 'wpsp_background_hover' ] = '';
35
+ $defaults[ 'wpsp_title_color' ] = '';
36
+ $defaults[ 'wpsp_title_color_hover' ] = '';
37
+ $defaults[ 'wpsp_meta_color' ] = '';
38
+ $defaults[ 'wpsp_meta_color_hover' ] = '';
39
+ $defaults[ 'wpsp_text' ] = '';
40
+ $defaults[ 'wpsp_link' ] = '';
41
+ $defaults[ 'wpsp_link_hover' ] = '';
42
+ $defaults[ 'wpsp_padding' ] = '';
43
+
44
+ return $defaults;
45
+ }
46
+ }
 
inc/defaults.php CHANGED
@@ -2,61 +2,63 @@
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
- if ( ! function_exists( 'wpsp_get_defaults' ) ) :
6
- /**
7
- * Set all of our defaults
8
- * @since 0.1
9
- */
10
- function wpsp_get_defaults()
11
- {
12
- $defaults = array(
13
- 'wpsp_author' => '',
14
- 'wpsp_author_location' => 'below-post',
15
- 'wpsp_columns' => 'col-6',
16
- 'wpsp_columns_gutter' => '2em',
17
- 'wpsp_content_type' => 'excerpt',
18
- 'wpsp_date_location' => 'below-title',
19
- 'wpsp_exclude_current' => false,
20
- 'wpsp_excerpt_length' => 30,
21
- 'wpsp_post_id' => '',
22
- 'wpsp_exclude_post_id' => '',
23
- 'wpsp_ignore_sticky_posts' => false,
24
- 'wpsp_image' => true,
25
- 'wpsp_image_alignment' => 'center',
26
- 'wpsp_image_height' => '',
27
- 'wpsp_image_location' => 'below-title',
28
- 'wpsp_image_width' => '',
29
- 'wpsp_include_title' => true,
30
- 'wpsp_include_terms' => false,
31
- 'wpsp_include_author' => false,
32
- 'wpsp_include_date' => true,
33
- 'wpsp_inner_wrapper' => 'article',
34
- 'wpsp_inner_wrapper_class' => '',
35
- 'wpsp_inner_wrapper_style' => '',
36
- 'wpsp_itemtype' => 'CreativeWork',
37
- 'wpsp_meta_key' => '',
38
- 'wpsp_meta_value' => '',
39
- 'wpsp_offset' => 0,
40
- 'wpsp_order' => 'DESC',
41
- 'wpsp_orderby' => 'date',
42
- 'wpsp_pagination' => false,
43
- 'wpsp_post_meta_bottom_style' => 'stack',
44
- 'wpsp_post_meta_top_style' => 'inline',
45
- 'wpsp_post_status' => 'publish',
46
- 'wpsp_post_type' => 'post',
47
- 'wpsp_posts_per_page' => 10,
48
- 'wpsp_read_more_text' => '',
49
- 'wpsp_tax_operator' => 'IN',
50
- 'wpsp_tax_term' => '',
51
- 'wpsp_taxonomy' => 'category',
52
- 'wpsp_terms_location' => 'below-post',
53
- 'wpsp_wrapper' => 'section',
54
- 'wpsp_wrapper_class' => '',
55
- 'wpsp_wrapper_id' => false,
56
- 'wpsp_wrapper_style' => '',
57
- 'wpsp_no_results' => __( 'Sorry, no posts were found.','wp-show-posts' )
58
- );
59
-
60
- return apply_filters( 'wpsp_defaults', $defaults );
 
 
 
61
  }
62
- endif;
2
  // No direct access, please
3
  if ( ! defined( 'ABSPATH' ) ) exit;
4
 
5
+ if ( ! function_exists( 'wpsp_get_defaults' ) ) {
6
+ /**
7
+ * Set all of our defaults
8
+ * @since 0.1
9
+ */
10
+ function wpsp_get_defaults() {
11
+ $defaults = array(
12
+ 'wpsp_author' => '',
13
+ 'wpsp_author_location' => 'below-post',
14
+ 'wpsp_columns' => 'col-6',
15
+ 'wpsp_columns_gutter' => '2em',
16
+ 'wpsp_content_type' => 'excerpt',
17
+ 'wpsp_date_location' => 'below-title',
18
+ 'wpsp_exclude_current' => false,
19
+ 'wpsp_excerpt_length' => 30,
20
+ 'wpsp_post_id' => '',
21
+ 'wpsp_exclude_post_id' => '',
22
+ 'wpsp_ignore_sticky_posts' => false,
23
+ 'wpsp_image' => true,
24
+ 'wpsp_image_alignment' => 'center',
25
+ 'wpsp_image_height' => '',
26
+ 'wpsp_image_location' => 'below-title',
27
+ 'wpsp_image_width' => '',
28
+ 'wpsp_include_title' => true,
29
+ 'wpsp_title_element' => 'h2',
30
+ 'wpsp_include_terms' => false,
31
+ 'wpsp_include_author' => false,
32
+ 'wpsp_include_date' => true,
33
+ 'wpsp_include_comments' => false,
34
+ 'wpsp_comments_location' => 'below-post',
35
+ 'wpsp_inner_wrapper' => 'article',
36
+ 'wpsp_inner_wrapper_class' => '',
37
+ 'wpsp_inner_wrapper_style' => '',
38
+ 'wpsp_itemtype' => 'CreativeWork',
39
+ 'wpsp_meta_key' => '',
40
+ 'wpsp_meta_value' => '',
41
+ 'wpsp_offset' => 0,
42
+ 'wpsp_order' => 'DESC',
43
+ 'wpsp_orderby' => 'date',
44
+ 'wpsp_pagination' => false,
45
+ 'wpsp_post_meta_bottom_style' => 'stack',
46
+ 'wpsp_post_meta_top_style' => 'inline',
47
+ 'wpsp_post_status' => 'publish',
48
+ 'wpsp_post_type' => 'post',
49
+ 'wpsp_posts_per_page' => 10,
50
+ 'wpsp_read_more_text' => '',
51
+ 'wpsp_tax_operator' => 'IN',
52
+ 'wpsp_tax_term' => '',
53
+ 'wpsp_taxonomy' => 'category',
54
+ 'wpsp_terms_location' => 'below-post',
55
+ 'wpsp_wrapper' => 'section',
56
+ 'wpsp_wrapper_class' => '',
57
+ 'wpsp_wrapper_id' => false,
58
+ 'wpsp_wrapper_style' => '',
59
+ 'wpsp_no_results' => __( 'Sorry, no posts were found.','wp-show-posts' )
60
+ );
61
+
62
+ return apply_filters( 'wpsp_defaults', $defaults );
63
+ }
64
  }
 
inc/deprecated.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! function_exists( 'wpsp_get_min_suffix' ) ) {
3
+ /**
4
+ * Figure out if we should use minified scripts or not
5
+ * @since 0.1
6
+ */
7
+ function wpsp_get_min_suffix() {
8
+ return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '-min';
9
+ }
10
+ }
inc/functions.php CHANGED
@@ -1,409 +1,386 @@
1
  <?php
2
  // No direct access, please
3
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
4
 
5
- if ( ! function_exists( 'wpsp_excerpt' ) ) :
6
- /**
7
- * Build our excerpt
8
- * @since 0.9
9
  */
10
- function wpsp_excerpt( $excerpt_length )
11
- {
12
- global $post;
13
-
14
- // Run our content through wp_trim_words()
15
- $content = wp_trim_words( get_the_content(), $excerpt_length, apply_filters( 'wpsp_ellipses', '...' ) );
16
-
17
- // Strip shortcodes from our content
18
- $content = strip_shortcodes( $content );
19
-
20
- // Strip URLs from our excerpt (oembeds etc..)
21
- $content = preg_replace( '~http(s)?://[^\s]*~i', '', $content );
22
-
23
- // If we have a manual excerpt, use it instead
24
- if ( '' !== $post->post_excerpt ) {
25
- $content = $post->post_excerpt;
26
- }
27
-
28
- // Return our content
29
- echo $content;
30
  }
31
- endif;
32
 
33
- if ( ! function_exists( 'wpsp_meta' ) ) :
34
- /**
35
- * Build our post meta
36
- * @since 0.1
37
  */
38
- function wpsp_meta( $location, $post_meta_style )
39
- {
40
- global $wpsp_id;
41
-
42
- if ( ! isset( $wpsp_id ) )
43
- return;
44
-
45
- $author_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_author_location' ) );
46
- $date_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_date_location' ) );
47
- $include_author = filter_var( wpsp_get_setting( $wpsp_id, 'wpsp_include_author' ), FILTER_VALIDATE_BOOLEAN );
48
- $include_terms = filter_var( wpsp_get_setting( $wpsp_id, 'wpsp_include_terms' ), FILTER_VALIDATE_BOOLEAN );
49
- $include_date = filter_var( get_post_meta( $wpsp_id, 'wpsp_include_date', true ), FILTER_VALIDATE_BOOLEAN );
50
- $terms_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_terms_location' ) );
51
- $taxonomy = sanitize_key( wpsp_get_setting( $wpsp_id, 'wpsp_taxonomy' ) );
52
-
53
- $output = array();
54
- if ( ( $include_author && $location == $author_location ) || ( $include_date && $location == $date_location ) || ( $include_terms && $location == $terms_location ) )
55
- echo '<div class="wp-show-posts-entry-meta wp-show-posts-entry-meta-' . $location . ' post-meta-' . $post_meta_style . '">';
56
-
57
- // If our author is enabled, show it
58
- if ( $include_author && $location == $author_location ) :
59
- $output[] = sprintf( '<span class="wp-show-posts-byline wp-show-posts-meta">%1$s</span>',
60
- sprintf( '<span class="wp-show-posts-author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%3$s</span></a></span>',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
62
  esc_attr( sprintf( __( 'View all posts by %s', 'wp-show-posts' ), get_the_author() ) ),
63
  esc_html( get_the_author() )
64
- )
65
- );
66
- endif;
67
-
68
- // Show the date
69
- if ( $include_date && $location == $date_location ) :
70
- $time_string = '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
71
- if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) )
72
- $time_string .= '<time class="wp-show-posts-updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
73
-
74
- $time_string = sprintf( $time_string,
75
- esc_attr( get_the_date( 'c' ) ),
76
- esc_html( get_the_date() ),
77
- esc_attr( get_the_modified_date( 'c' ) ),
78
- esc_html( get_the_modified_date() )
79
- );
80
-
81
- // If our date is enabled, show it
82
- $output[] = sprintf( '<span class="wp-show-posts-posted-on wp-show-posts-meta">%1$s</span>',
83
- sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
 
 
 
84
  esc_url( get_permalink() ),
85
  esc_attr( get_the_time() ),
86
  $time_string
87
- )
88
- );
89
- endif;
90
-
91
- // Show the terms
92
- if ( $include_terms && $location == $terms_location ) :
93
- $output[] = sprintf( '<span class="wp-show-posts-terms wp-show-posts-meta">%1$s</span>',
94
- get_the_term_list( get_the_ID(), $taxonomy, '', ', ' )
95
- );
96
- endif;
97
-
98
- $separator = ( 'inline' == $post_meta_style ) ? ' <span class="wp-show-posts-separator">|</span> ' : '<br />';
99
- echo implode( $separator, $output);
100
-
101
- if ( ( $include_author && $location == $author_location ) || ( $include_date && $location == $date_location ) || ( $include_terms && $location == $terms_location ) )
102
- echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
- endif;
105
 
106
- if ( ! function_exists( 'wpsp_add_post_meta_after_title' ) ) :
107
- add_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' );
108
- function wpsp_add_post_meta_after_title()
109
- {
110
- global $wpsp_id;
111
-
112
- if ( ! isset( $wpsp_id ) )
113
- return;
114
-
115
- $author_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_author_location' ) );
116
- $date_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_date_location' ) );
117
- $terms_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_terms_location' ) );
118
- $include_author = filter_var( wpsp_get_setting( $wpsp_id, 'wpsp_include_author' ), FILTER_VALIDATE_BOOLEAN );
119
- $include_terms = filter_var( wpsp_get_setting( $wpsp_id, 'wpsp_include_terms' ), FILTER_VALIDATE_BOOLEAN );
120
- $include_date = filter_var( get_post_meta( $wpsp_id, 'wpsp_include_date', true ), FILTER_VALIDATE_BOOLEAN );
121
- $post_meta_top_style = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_post_meta_top_style' ) );
122
-
123
- if ( ( $include_author && 'below-title' == $author_location ) || ( $include_date && 'below-title' == $date_location ) || ( $include_terms && 'below-title' == $terms_location ) )
124
- wpsp_meta( 'below-title', $post_meta_top_style );
125
-
126
  }
127
- endif;
128
 
129
- if ( ! function_exists( 'wpsp_add_post_meta_after_content' ) ) :
130
- add_action( 'wpsp_after_content','wpsp_add_post_meta_after_content', 10 );
131
- function wpsp_add_post_meta_after_content()
132
- {
133
- global $wpsp_id;
134
-
135
- if ( ! isset( $wpsp_id ) )
136
- return;
137
-
138
- $author_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_author_location' ) );
139
- $date_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_date_location' ) );
140
- $terms_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_terms_location' ) );
141
- $include_author = filter_var( wpsp_get_setting( $wpsp_id, 'wpsp_include_author' ), FILTER_VALIDATE_BOOLEAN );
142
- $include_terms = filter_var( wpsp_get_setting( $wpsp_id, 'wpsp_include_terms' ), FILTER_VALIDATE_BOOLEAN );
143
- $include_date = filter_var( get_post_meta( $wpsp_id, 'wpsp_include_date', true ), FILTER_VALIDATE_BOOLEAN );
144
- $post_meta_bottom_style = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_post_meta_bottom_style' ) );
145
-
146
- if ( ( $include_author && 'below-post' == $author_location ) || ( $include_date && 'below-post' == $date_location ) || ( $include_terms && 'below-post' == $terms_location ) )
147
- wpsp_meta( 'below-post', $post_meta_bottom_style );
148
  }
149
- endif;
150
 
151
- if ( ! function_exists( 'wpsp_post_image' ) ) :
152
- /**
153
- * Build our post image
154
- * @since 0.1
155
- */
156
- function wpsp_post_image()
157
- {
158
- if ( ! has_post_thumbnail() )
159
- return;
160
-
161
- global $wpsp_id;
162
-
163
- if ( ! isset( $wpsp_id ) )
164
- return;
165
-
166
- $image = sanitize_text_field( get_post_meta( $wpsp_id, 'wpsp_image', true ), FILTER_VALIDATE_BOOLEAN );
167
- if ( ! isset( $image ) || ! $image )
168
- return;
169
-
170
- $image_alignment = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_image_alignment' ) );
171
- $image_height = absint( wpsp_get_setting( $wpsp_id, 'wpsp_image_height' ) );
172
- $image_width = absint( wpsp_get_setting( $wpsp_id, 'wpsp_image_width' ) );
173
- $image_overlay_color = wpsp_sanitize_hex_color( wpsp_get_setting( $wpsp_id, 'wpsp_image_overlay_color' ) );
174
- $image_overlay_icon = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_image_overlay_icon' ) );
175
- $image_hover_effect = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_image_hover_effect' ) );
176
- $columns = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_columns' ) );
177
-
178
- $image_id = get_post_thumbnail_id( get_the_ID(), 'full' );
179
- $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
180
- $image_atts = wpsp_image_attributes( $image_url[1], $image_url[2], $image_width, $image_height );
181
- $hover = ( '' !== $image_hover_effect ) ? $image_hover_effect : '';
182
- ?>
183
- <div class="wp-show-posts-image <?php echo $hover . ' wpsp-image-' . $image_alignment; ?> ">
184
- <?php
185
- do_action( 'wpsp_inside_image_container' );
186
-
187
- printf( '<a href="%1$s" %2$s title="%3$s">',
188
- apply_filters( 'wpsp_image_href', esc_url( get_the_permalink() ) ),
189
- apply_filters( 'wpsp_image_data', '' ),
190
- apply_filters( 'wpsp_image_title', esc_attr( get_the_title() ) )
191
- ); ?>
192
- <?php if ( ! empty( $image_atts ) ) : ?>
193
- <img src="<?php echo WPSP_Resize( $image_url[0], $image_atts[ 'width' ], $image_atts[ 'height' ], $image_atts[ 'crop' ], true, $image_atts[ 'upscale' ] ); ?>" alt="<?php esc_attr( the_title() ); ?>" itemprop="image" class="<?php echo $image_alignment; ?>" />
194
- <?php else :
195
- the_post_thumbnail( apply_filters( 'wpsp_default_image_size', 'full' ), array( 'itemprop' => 'image' ) );
196
- endif;
197
-
198
- if ( '' !== $image_overlay_color || '' !== $image_overlay_icon ) :
199
- $color = ( $image_overlay_color ) ? 'style="background-color:' . wpsp_hex2rgba( $image_overlay_color, apply_filters( 'wpsp_overlay_opacity', 0.7 ) ) . '"' : '';
200
- $icon = ( $image_overlay_icon ) ? $image_overlay_icon : 'no-icon';
201
- echo '<span class="wp-show-posts-image-overlay ' . $icon . '" ' . $color . '></span>';
202
- endif;
203
  ?>
204
- </a>
205
- </div>
206
- <?php
207
  }
208
- endif;
209
 
210
- if ( ! function_exists( 'wpsp_add_post_image_before_title' ) ) :
211
- add_action( 'wpsp_before_header','wpsp_add_post_image_before_title' );
212
- function wpsp_add_post_image_before_title()
213
- {
214
- global $wpsp_id;
215
-
216
- if ( ! isset( $wpsp_id ) )
217
- return;
218
-
219
- $image_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_image_location' ) );
220
-
221
- if ( 'above-title' == $image_location )
222
- wpsp_post_image();
223
- }
224
- endif;
225
 
226
- if ( ! function_exists( 'wpsp_add_post_image_before_content' ) ) :
227
- add_action( 'wpsp_before_content','wpsp_add_post_image_before_content' );
228
- function wpsp_add_post_image_before_content()
229
- {
230
- global $wpsp_id;
231
-
232
- if ( ! isset( $wpsp_id ) )
233
- return;
234
-
235
- $image_location = sanitize_text_field( wpsp_get_setting( $wpsp_id, 'wpsp_image_location' ) );
236
-
237
- if ( 'below-title' == $image_location )
238
- wpsp_post_image();
239
  }
240
- endif;
241
 
242
- if ( ! function_exists( 'wpsp_read_more' ) ) :
243
- add_action( 'wpsp_after_content','wpsp_read_more', 5 );
244
- function wpsp_read_more()
245
- {
246
- global $wpsp_id;
247
-
248
- if ( ! isset( $wpsp_id ) )
249
- return;
250
-
251
- $read_more_text = wp_kses_post( wpsp_get_setting( $wpsp_id, 'wpsp_read_more_text' ) );
252
-
253
- // The read more button
254
- if ( $read_more_text ) : ?>
255
- <div class="wpsp-read-more">
256
- <a title="<?php echo esc_attr( get_the_title() ); ?>" class="wp-show-posts-read-more" href="<?php esc_url( the_permalink() ); ?>"><?php echo $read_more_text; ?></a>
257
- </div>
258
- <?php endif;
259
  }
260
- endif;
261
 
262
- if ( ! function_exists( 'wpsp_hex2rgba' ) ) :
263
- /**
264
- * Convert hex to RGBA
265
- * @since 0.1
266
- */
267
- function wpsp_hex2rgba($color, $opacity = false) {
268
-
269
- $default = 'rgb(0,0,0)';
270
-
271
- // Return default if no color provided
272
- if(empty($color))
273
- return $default;
274
-
275
- // Sanitize $color if "#" is provided
276
- if ($color[0] == '#' ) {
277
- $color = substr( $color, 1 );
278
  }
 
 
 
 
 
 
 
 
279
 
280
- // Check if color has 6 or 3 characters and get values
281
- if (strlen($color) == 6) {
 
 
 
 
 
 
 
 
 
 
 
 
282
  $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
283
- } elseif ( strlen( $color ) == 3 ) {
284
  $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
285
- } else {
286
  return $default;
287
- }
288
 
289
- // Convert hexadec to rgb
290
- $rgb = array_map('hexdec', $hex);
291
 
292
- // Check if opacity is set(rgba or rgb)
293
- if($opacity){
294
- if(abs($opacity) > 1)
295
- $opacity = 1.0;
296
- $output = 'rgba('.implode(",",$rgb).','.$opacity.')';
297
- } else {
298
- $output = 'rgb('.implode(",",$rgb).')';
299
- }
 
300
 
301
- // Return rgb(a) color string
302
- return $output;
 
303
  }
304
- endif;
305
-
306
- if ( ! function_exists( 'wpsp_sanitize_hex_color' ) ) :
307
- function wpsp_sanitize_hex_color( $color ) {
308
- if ( '' === $color )
309
- return '';
310
-
311
- // 3 or 6 hex digits, or the empty string.
312
- if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) )
313
- return $color;
 
 
314
  }
315
- endif;
316
 
317
- if ( ! function_exists( 'wpsp_image_attributes' ) ) :
318
- /**
319
- * Build our image attributes
320
- * @since 0.1
321
- */
322
- function wpsp_image_attributes( $og_width = '', $og_height = '', $new_width = '', $new_height = '' )
323
- {
324
- $ignore_crop = array( '', '0', '9999' );
325
-
326
- $image_atts = array();
327
-
328
- $image_atts = array(
329
- 'width' => ( in_array( $new_width, $ignore_crop ) ) ? 9999 : intval( $new_width ),
330
- 'height' => ( in_array( $new_height, $ignore_crop ) ) ? 9999 : intval( $new_height ),
331
- 'crop' => ( in_array( $new_width, $ignore_crop ) || in_array( $new_height, $ignore_crop ) ) ? false : true
332
- );
333
-
334
- // If there's no height or width, empty the array
335
- if ( 9999 == $image_atts[ 'width' ] && 9999 == $image_atts[ 'height' ] )
336
- $image_atts = array();
337
-
338
- if ( ! empty( $image_atts ) ) :
339
- // Is our width larger than the OG image and not proportional?
340
- $width_upscale = $image_atts[ 'width' ] > $og_width && $image_atts[ 'width' ] < 9999 ? true : false;
341
-
342
- // Is our height larger than the OG image and not proportional?
343
- $height_upscale = $image_atts[ 'height' ] > $og_height && $image_atts[ 'height' ] < 9999 ? true : false;
344
-
345
- // If both the height and width are larger than the OG image, upscale
346
- $image_atts[ 'upscale' ] = $width_upscale && $height_upscale ? true : false;
347
-
348
- // If the width is larger than the OG image and the height isn't proportional, upscale
349
- $image_atts[ 'upscale' ] = $width_upscale && $image_atts[ 'height' ] < 9999 ? true : $image_atts[ 'upscale' ];
350
-
351
- // If the height is larger than the OG image and width isn't proportional, upscale
352
- $image_atts[ 'upscale' ] = $height_upscale && $image_atts[ 'width' ] < 9999 ? true : $image_atts[ 'upscale' ];
353
-
354
- // If we're upscaling, set crop to true
355
- $image_atts[ 'crop' ] = $image_atts[ 'upscale' ] ? true : $image_atts[ 'crop' ];
356
-
357
- // If one of our sizes is upscaling but the other is proportional, show the full image
358
- if ( $width_upscale && $image_atts[ 'height' ] == 9999 || $height_upscale && $image_atts[ 'width' ] == 9999 )
359
  $image_atts = array();
360
- endif;
361
-
362
- return apply_filters( 'generate_blog_image_attributes', $image_atts );
363
- }
364
- endif;
365
 
366
- if ( ! function_exists( 'wpsp_pagination' ) ) :
367
- /**
368
- * Build our regular pagination
369
- * @since 0.1
370
- */
371
- function wpsp_pagination( $max_num_pages ) {
372
- // Don't print empty markup if there's only one page.
373
- if ( $max_num_pages < 2 ) {
374
- return;
375
- }
376
-
377
- $paged_query = is_front_page() ? 'page' : 'paged';
378
- $paged = get_query_var( $paged_query ) ? intval( get_query_var( $paged_query ) ) : 1;
379
- $pagenum_link = html_entity_decode( get_pagenum_link() );
380
- $query_args = array();
381
- $url_parts = explode( '?', $pagenum_link );
382
-
383
- if ( isset( $url_parts[1] ) ) {
384
- wp_parse_str( $url_parts[1], $query_args );
 
 
 
 
 
 
 
385
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
 
387
- $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
388
- $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
389
-
390
- $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
391
- $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
392
-
393
- // Set up paginated links.
394
- $links = paginate_links( array(
395
- 'base' => $pagenum_link,
396
- 'format' => $format,
397
- 'total' => $max_num_pages,
398
- 'current' => $paged,
399
- 'mid_size' => apply_filters( 'wpsp_pagination_mid_size', 1 ),
400
- 'add_args' => array_map( 'urlencode', $query_args ),
401
- 'prev_text' => __( '&larr; Previous', 'wp-show-posts' ),
402
- 'next_text' => __( 'Next &rarr;', 'wp-show-posts' ),
403
- ) );
404
-
405
- if ( $links ) :
406
- echo '<div class="wpsp-load-more">' . $links . '</div>';
407
- endif;
 
 
 
 
 
408
  }
409
- endif;
1
  <?php
2
  // No direct access, please
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
 
7
+ /**
8
+ * Set the excerpt length.
9
+ *
10
+ * @since 1.1
11
  */
12
+ function wpsp_excerpt_length() {
13
+ global $wpsp_id;
14
+ return absint( wpsp_get_setting( $wpsp_id, 'wpsp_excerpt_length' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
 
16
 
17
+ /**
18
+ * Set the read more ellipses.
19
+ *
20
+ * @since 1.1
21
  */
22
+ function wpsp_excerpt_more() {
23
+ return apply_filters( 'wpsp_ellipses', '...' );
24
+ }
25
+
26
+ if ( ! function_exists( 'wpsp_excerpt' ) ) {
27
+ /**
28
+ * Build our excerpt
29
+ * @since 0.9
30
+ */
31
+ function wpsp_excerpt() {
32
+ add_filter( 'excerpt_length', 'wpsp_excerpt_length', 999 );
33
+ add_filter( 'excerpt_more', 'wpsp_excerpt_more', 999 );
34
+ the_excerpt();
35
+ remove_filter( 'excerpt_length', 'wpsp_excerpt_length', 999 );
36
+ remove_filter( 'excerpt_more', 'wpsp_excerpt_more', 999 );
37
+ }
38
+ }
39
+
40
+ if ( ! function_exists( 'wpsp_meta' ) ) {
41
+ /**
42
+ * Build our post meta.
43
+ *
44
+ * @since 0.1
45
+ */
46
+ function wpsp_meta( $location, $settings ) {
47
+ $output = array();
48
+
49
+ if ( 'below-post' == $location ) {
50
+ $post_meta_style = $settings[ 'post_meta_bottom_style' ];
51
+ } elseif ( 'below-title' == $location ) {
52
+ $post_meta_style = $settings[ 'post_meta_top_style' ];
53
+ }
54
+
55
+ if ( ( $settings[ 'include_author' ] && $location == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && $location == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && $location == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && $location == $settings[ 'comments_location' ] ) ) {
56
+ echo '<div class="wp-show-posts-entry-meta wp-show-posts-entry-meta-' . $location . ' post-meta-' . $post_meta_style . '">';
57
+ }
58
+
59
+ // If our author is enabled, show it
60
+ if ( $settings[ 'include_author' ] && $location == $settings[ 'author_location' ] ) {
61
+ $output[] = apply_filters( 'wpsp_author_output', sprintf(
62
+ '<span class="wp-show-posts-byline wp-show-posts-meta">
63
+ <span class="wp-show-posts-author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">
64
+ <a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url">
65
+ <span class="author-name" itemprop="name">%3$s</span>
66
+ </a>
67
+ </span>
68
+ </span>',
69
  esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
70
  esc_attr( sprintf( __( 'View all posts by %s', 'wp-show-posts' ), get_the_author() ) ),
71
  esc_html( get_the_author() )
72
+ ) );
73
+ }
74
+
75
+ // Show the date
76
+ if ( $settings[ 'include_date' ] && $location == $settings[ 'date_location' ] ) {
77
+ $time_string = '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
78
+
79
+ if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
80
+ $time_string .= '<time class="wp-show-posts-updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
81
+ }
82
+
83
+ $time_string = sprintf( $time_string,
84
+ esc_attr( get_the_date( 'c' ) ),
85
+ esc_html( get_the_date() ),
86
+ esc_attr( get_the_modified_date( 'c' ) ),
87
+ esc_html( get_the_modified_date() )
88
+ );
89
+
90
+ // If our date is enabled, show it
91
+ $output[] = apply_filters( 'wpsp_date_output', sprintf(
92
+ '<span class="wp-show-posts-posted-on wp-show-posts-meta">
93
+ <a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>
94
+ </span>',
95
  esc_url( get_permalink() ),
96
  esc_attr( get_the_time() ),
97
  $time_string
98
+ ) );
99
+ }
100
+
101
+ // Show the terms
102
+ if ( $settings[ 'include_terms' ] && $location == $settings[ 'terms_location' ] ) {
103
+ $output[] = apply_filters( 'wpsp_terms_output', sprintf( '<span class="wp-show-posts-terms wp-show-posts-meta">%1$s</span>',
104
+ get_the_term_list( get_the_ID(), $settings[ 'taxonomy' ], '', apply_filters( 'wpsp_term_separator', ', ' ) )
105
+ ) );
106
+ }
107
+
108
+ if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && ( $settings[ 'include_comments' ] && $location == $settings[ 'comments_location' ] ) ) {
109
+ ob_start();
110
+ echo '<span class="wp-show-posts-comments-link wp-show-posts-meta">';
111
+ comments_popup_link( __( 'Leave a comment', 'wp-show-posts' ), __( '1 Comment', 'wp-show-posts' ), __( '% Comments', 'wp-show-posts' ) );
112
+ echo '</span>';
113
+ $comments_link = ob_get_clean();
114
+ $output[] = $comments_link;
115
+ }
116
+
117
+ // Set up our separator
118
+ $separator = ( 'inline' == $post_meta_style ) ? ' <span class="wp-show-posts-separator">|</span> ' : '<br />';
119
+
120
+ // Echo our output
121
+ echo implode( $separator, $output);
122
+
123
+ if ( ( $settings[ 'include_author' ] && $location == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && $location == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && $location == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && $location == $settings[ 'comments_location' ] ) ) {
124
+ echo '</div>';
125
+ }
126
+ }
127
  }
 
128
 
129
+ if ( ! function_exists( 'wpsp_add_post_meta_after_title' ) ) {
130
+ add_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' );
131
+ function wpsp_add_post_meta_after_title( $settings ) {
132
+ if ( ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && 'below-title' == $settings[ 'comments_location' ] ) ) {
133
+ wpsp_meta( 'below-title', $settings );
134
+ }
135
+
136
+ }
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
 
138
 
139
+ if ( ! function_exists( 'wpsp_add_post_meta_after_content' ) ) {
140
+ add_action( 'wpsp_after_content','wpsp_add_post_meta_after_content', 10 );
141
+ function wpsp_add_post_meta_after_content( $settings ) {
142
+ if ( ( $settings[ 'include_author' ] && 'below-post' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-post' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-post' == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && 'below-post' == $settings[ 'comments_location' ] ) ) {
143
+ wpsp_meta( 'below-post', $settings );
144
+ }
145
+ }
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
 
147
 
148
+ if ( ! function_exists( 'wpsp_post_image' ) ) {
149
+ /**
150
+ * Build our post image
151
+ * @since 0.1
152
+ */
153
+ function wpsp_post_image( $settings ) {
154
+ if ( ! has_post_thumbnail() ) {
155
+ return;
156
+ }
157
+
158
+ if ( ! isset( $settings[ 'image' ] ) || ! $settings[ 'image' ] ) {
159
+ return;
160
+ }
161
+
162
+ $image_id = get_post_thumbnail_id( get_the_ID(), 'full' );
163
+ $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
164
+ $image_atts = wpsp_image_attributes( $image_url[1], $image_url[2], $settings[ 'image_width' ], $settings[ 'image_height' ] );
165
+ $hover = ( isset( $settings[ 'image_hover_effect' ] ) && '' !== $settings[ 'image_hover_effect' ] ) ? $settings[ 'image_hover_effect' ] : '';
166
+ $disable_link = apply_filters( 'wpsp_disable_image_link', false, $settings );
167
+ ?>
168
+ <div class="wp-show-posts-image <?php echo $hover . ' wpsp-image-' . $settings[ 'image_alignment' ]; ?> ">
169
+ <?php
170
+ do_action( 'wpsp_inside_image_container', $settings );
171
+
172
+ if ( ! $disable_link ) {
173
+ printf(
174
+ '<a href="%1$s" %2$s title="%3$s">',
175
+ esc_url( apply_filters( 'wpsp_image_href', get_the_permalink(), $settings ) ),
176
+ apply_filters( 'wpsp_image_data', '', $settings ),
177
+ esc_attr( apply_filters( 'wpsp_image_title', the_title_attribute( 'echo=0' ), $settings ) )
178
+ );
179
+ }
180
+
181
+ if ( ! empty( $image_atts ) ) : ?>
182
+ <img src="<?php echo WPSP_Resize( $image_url[0], $image_atts[ 'width' ], $image_atts[ 'height' ], $image_atts[ 'crop' ], true, $image_atts[ 'upscale' ] ); ?>" alt="<?php esc_attr( the_title() ); ?>" itemprop="image" class="<?php echo $settings[ 'image_alignment' ]; ?>" />
183
+ <?php else :
184
+ the_post_thumbnail( apply_filters( 'wpsp_default_image_size', 'full' ), array( 'itemprop' => 'image' ) );
185
+ endif;
186
+
187
+ if ( isset( $settings[ 'image_overlay_color' ] ) && ( '' !== $settings[ 'image_overlay_color' ] || '' !== $settings[ 'image_overlay_icon' ] ) ) {
188
+ $color = ( $settings[ 'image_overlay_color' ] ) ? 'style="background-color:' . wpsp_hex2rgba( $settings[ 'image_overlay_color' ], apply_filters( 'wpsp_overlay_opacity', 0.7 ) ) . '"' : '';
189
+ $icon = ( $settings[ 'image_overlay_icon' ] ) ? $settings[ 'image_overlay_icon' ] : 'no-icon';
190
+ echo '<span class="wp-show-posts-image-overlay ' . $icon . '" ' . $color . '></span>';
191
+ }
192
+
193
+ if ( ! $disable_link ) {
194
+ echo '</a>';
195
+ }
 
 
 
 
196
  ?>
197
+ </div>
198
+ <?php
199
+ }
200
  }
 
201
 
202
+ if ( ! function_exists( 'wpsp_add_post_image_before_title' ) ) {
203
+ add_action( 'wpsp_before_header','wpsp_add_post_image_before_title' );
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
+ function wpsp_add_post_image_before_title( $settings ) {
206
+ if ( 'above-title' == $settings[ 'image_location' ] ) {
207
+ wpsp_post_image( $settings );
208
+ }
209
+ }
 
 
 
 
 
 
 
 
210
  }
 
211
 
212
+ if ( ! function_exists( 'wpsp_add_post_image_before_content' ) ) {
213
+ add_action( 'wpsp_before_content','wpsp_add_post_image_before_content' );
214
+
215
+ function wpsp_add_post_image_before_content( $settings ) {
216
+ if ( 'below-title' == $settings[ 'image_location' ] ) {
217
+ wpsp_post_image( $settings );
218
+ }
219
+ }
 
 
 
 
 
 
 
 
 
220
  }
 
221
 
222
+ if ( ! function_exists( 'wpsp_read_more' ) ) {
223
+ add_action( 'wpsp_after_content','wpsp_read_more', 5 );
224
+
225
+ function wpsp_read_more( $settings ) {
226
+ if ( $settings[ 'read_more_text' ] ) {
227
+ echo apply_filters( 'wpsp_read_more_output', sprintf('<div class="wpsp-read-more"><a title="%1$s" class="wp-show-posts-read-more" href="%2$s">%3$s</a></div>',
228
+ the_title_attribute( 'echo=0' ),
229
+ esc_url( get_permalink() ),
230
+ $settings[ 'read_more_text' ]
231
+ ));
232
+ }
 
 
 
 
 
233
  }
234
+ }
235
+
236
+ if ( ! function_exists( 'wpsp_hex2rgba' ) ) {
237
+ /**
238
+ * Convert hex to RGBA
239
+ * @since 0.1
240
+ */
241
+ function wpsp_hex2rgba($color, $opacity = false) {
242
 
243
+ $default = 'rgb(0,0,0)';
244
+
245
+ // Return default if no color provided
246
+ if ( empty( $color ) ) {
247
+ return $default;
248
+ }
249
+
250
+ // Sanitize $color if "#" is provided
251
+ if ($color[0] == '#' ) {
252
+ $color = substr( $color, 1 );
253
+ }
254
+
255
+ // Check if color has 6 or 3 characters and get values
256
+ if ( strlen( $color ) == 6) {
257
  $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
258
+ } elseif ( strlen( $color ) == 3 ) {
259
  $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
260
+ } else {
261
  return $default;
262
+ }
263
 
264
+ // Convert hexadec to rgb
265
+ $rgb = array_map('hexdec', $hex);
266
 
267
+ // Check if opacity is set(rgba or rgb)
268
+ if ( $opacity ){
269
+ if( abs( $opacity ) > 1) {
270
+ $opacity = 1.0;
271
+ }
272
+ $output = 'rgba('.implode(",",$rgb).','.$opacity.')';
273
+ } else {
274
+ $output = 'rgb('.implode(",",$rgb).')';
275
+ }
276
 
277
+ // Return rgb(a) color string
278
+ return $output;
279
+ }
280
  }
281
+
282
+ if ( ! function_exists( 'wpsp_sanitize_hex_color' ) ) {
283
+ function wpsp_sanitize_hex_color( $color ) {
284
+ if ( '' === $color ) {
285
+ return '';
286
+ }
287
+
288
+ // 3 or 6 hex digits, or the empty string.
289
+ if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
290
+ return $color;
291
+ }
292
+ }
293
  }
 
294
 
295
+ if ( ! function_exists( 'wpsp_image_attributes' ) ) {
296
+ /**
297
+ * Build our image attributes
298
+ * @since 0.1
299
+ */
300
+ function wpsp_image_attributes( $og_width = '', $og_height = '', $new_width = '', $new_height = '' ) {
301
+ $ignore_crop = array( '', '0', '9999' );
302
+
303
+ $image_atts = array(
304
+ 'width' => ( in_array( $new_width, $ignore_crop ) ) ? 9999 : intval( $new_width ),
305
+ 'height' => ( in_array( $new_height, $ignore_crop ) ) ? 9999 : intval( $new_height ),
306
+ 'crop' => ( in_array( $new_width, $ignore_crop ) || in_array( $new_height, $ignore_crop ) ) ? false : true
307
+ );
308
+
309
+ // If there's no height or width, empty the array
310
+ if ( 9999 == $image_atts[ 'width' ] && 9999 == $image_atts[ 'height' ] ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  $image_atts = array();
312
+ }
 
 
 
 
313
 
314
+ if ( ! empty( $image_atts ) ) {
315
+ // Is our width larger than the OG image and not proportional?
316
+ $width_upscale = $image_atts[ 'width' ] > $og_width && $image_atts[ 'width' ] < 9999 ? true : false;
317
+
318
+ // Is our height larger than the OG image and not proportional?
319
+ $height_upscale = $image_atts[ 'height' ] > $og_height && $image_atts[ 'height' ] < 9999 ? true : false;
320
+
321
+ // If both the height and width are larger than the OG image, upscale
322
+ $image_atts[ 'upscale' ] = $width_upscale && $height_upscale ? true : false;
323
+
324
+ // If the width is larger than the OG image and the height isn't proportional, upscale
325
+ $image_atts[ 'upscale' ] = $width_upscale && $image_atts[ 'height' ] < 9999 ? true : $image_atts[ 'upscale' ];
326
+
327
+ // If the height is larger than the OG image and width isn't proportional, upscale
328
+ $image_atts[ 'upscale' ] = $height_upscale && $image_atts[ 'width' ] < 9999 ? true : $image_atts[ 'upscale' ];
329
+
330
+ // If we're upscaling, set crop to true
331
+ $image_atts[ 'crop' ] = $image_atts[ 'upscale' ] ? true : $image_atts[ 'crop' ];
332
+
333
+ // If one of our sizes is upscaling but the other is proportional, show the full image
334
+ if ( $width_upscale && $image_atts[ 'height' ] == 9999 || $height_upscale && $image_atts[ 'width' ] == 9999 ) {
335
+ $image_atts = array();
336
+ }
337
+ }
338
+
339
+ return apply_filters( 'wpsp_image_attributes', $image_atts );
340
  }
341
+ }
342
+
343
+ if ( ! function_exists( 'wpsp_pagination' ) ) {
344
+ /**
345
+ * Build our regular pagination
346
+ * @since 0.1
347
+ */
348
+ function wpsp_pagination( $max_num_pages ) {
349
+ // Don't print empty markup if there's only one page.
350
+ if ( $max_num_pages < 2 ) {
351
+ return;
352
+ }
353
+
354
+ $paged_query = is_front_page() ? 'page' : 'paged';
355
+ $paged = get_query_var( $paged_query ) ? intval( get_query_var( $paged_query ) ) : 1;
356
+ $pagenum_link = html_entity_decode( get_pagenum_link() );
357
+ $query_args = array();
358
+ $url_parts = explode( '?', $pagenum_link );
359
 
360
+ if ( isset( $url_parts[1] ) ) {
361
+ wp_parse_str( $url_parts[1], $query_args );
362
+ }
363
+
364
+ $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
365
+ $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
366
+
367
+ $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
368
+ $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
369
+
370
+ // Set up paginated links.
371
+ $links = paginate_links( array(
372
+ 'base' => $pagenum_link,
373
+ 'format' => $format,
374
+ 'total' => $max_num_pages,
375
+ 'current' => $paged,
376
+ 'mid_size' => apply_filters( 'wpsp_pagination_mid_size', 1 ),
377
+ 'add_args' => array_map( 'urlencode', $query_args ),
378
+ 'prev_text' => __( '&larr; Previous', 'wp-show-posts' ),
379
+ 'next_text' => __( 'Next &rarr;', 'wp-show-posts' ),
380
+ ) );
381
+
382
+ if ( $links ) {
383
+ echo '<div class="wpsp-load-more">' . $links . '</div>';
384
+ }
385
+ }
386
  }
 
inc/styling.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // No direct access, please
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ add_action( 'wpsp_before_wrapper', 'wpsp_basic_styling' );
8
+ function wpsp_basic_styling( $settings ) {
9
+ // Start the magic
10
+ $visual_css = array (
11
+
12
+ '.wp-show-posts-columns#wpsp-' . $settings[ 'list_id' ] => array(
13
+ 'margin-left' => ( '' !== $settings[ 'columns_gutter' ] && '12' !== $settings[ 'columns' ] ) ? '-' . $settings[ 'columns_gutter' ] : null
14
+ ),
15
+
16
+ '.wp-show-posts-columns#wpsp-' . $settings[ 'list_id' ] . ' .wp-show-posts-inner' => array(
17
+ 'margin' => ( '' !== $settings[ 'columns_gutter' ] && '12' !== $settings[ 'columns' ] ) ? '0 0 ' . $settings[ 'columns_gutter' ] . ' ' . $settings[ 'columns_gutter' ] : null,
18
+ ),
19
+
20
+ );
21
+
22
+ // Output the above CSS
23
+ $output = '';
24
+ foreach( $visual_css as $k => $properties ) {
25
+
26
+ if ( !count( $properties ) ) {
27
+ continue;
28
+ }
29
+
30
+ $temporary_output = $k . ' {';
31
+ $elements_added = 0;
32
+
33
+ foreach( $properties as $p => $v ) {
34
+
35
+ if ( empty( $v ) ) {
36
+ continue;
37
+ }
38
+
39
+ $elements_added++;
40
+ $temporary_output .= $p . ': ' . $v . '; ';
41
+
42
+ }
43
+
44
+ $temporary_output .= "}";
45
+
46
+ if ( $elements_added > 0 ) {
47
+ $output .= $temporary_output;
48
+ }
49
+
50
+ }
51
+
52
+ $output = str_replace(array("\r", "\n"), '', $output);
53
+
54
+ if ( '' !== $output ) {
55
+ echo '<style>';
56
+ echo $output;
57
+ echo '</style>';
58
+ }
59
+ }
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: edge22
3
  Donate link: https://wpshowposts.com
4
  Tags: show posts, display posts shortcode, portfolio, gallery, post columns
5
- Requires at least: 4.0
6
- Tested up to: 4.7
7
- Stable tag: 1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -21,7 +21,7 @@ You can pull posts from any post type like WooCommerce, Easy Digital Downloads e
21
  This plugin works with any theme.
22
 
23
  Here are the features in the free version:
24
-
25
  = Posts =
26
 
27
  * Post type
@@ -102,7 +102,7 @@ https://vimeo.com/175660953
102
  * Image lightbox
103
  * Image lightbox gallery
104
 
105
- = Content =
106
 
107
  * Read more style
108
  * Read more color
@@ -112,7 +112,7 @@ https://vimeo.com/175660953
112
  * Title color
113
  * Title color hover
114
 
115
- = Meta =
116
 
117
  * Meta color
118
  * Meta color hover
@@ -162,6 +162,27 @@ In most cases, #1 will work fine and is way easier.
162
 
163
  == Changelog ==
164
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  = 1.0 =
166
  * Add new hook inside image container: wpsp_inside_image_container
167
  * Fix issue with pagination and random post ordering
@@ -224,6 +245,27 @@ In most cases, #1 will work fine and is way easier.
224
 
225
  == Upgrade Notice ==
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  = 1.0 =
228
  * Add new hook inside image container: wpsp_inside_image_container
229
  * Fix issue with pagination and random post ordering
@@ -282,4 +324,4 @@ In most cases, #1 will work fine and is way easier.
282
  * Wrap read more button in div: .wpsp-read-more
283
 
284
  = 0.1 =
285
- * Initial release
2
  Contributors: edge22
3
  Donate link: https://wpshowposts.com
4
  Tags: show posts, display posts shortcode, portfolio, gallery, post columns
5
+ Requires at least: 4.5
6
+ Tested up to: 4.9
7
+ Stable tag: 1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
21
  This plugin works with any theme.
22
 
23
  Here are the features in the free version:
24
+
25
  = Posts =
26
 
27
  * Post type
102
  * Image lightbox
103
  * Image lightbox gallery
104
 
105
+ = Content =
106
 
107
  * Read more style
108
  * Read more color
112
  * Title color
113
  * Title color hover
114
 
115
+ = Meta =
116
 
117
  * Meta color
118
  * Meta color hover
162
 
163
  == Changelog ==
164
 
165
+ = 1.1 =
166
+ * New: Allow multiple taxonomy terms to be selected
167
+ * New: Choose the title HTML element
168
+ * New: wpsp_disable_title_link filter
169
+ * New: wpsp_disable_image_link filter
170
+ * New: wpsp_read_more_output filter
171
+ * New: wpsp_inside_wrapper hook
172
+ * New: wpsp_image_attributes filter
173
+ * New: wpsp_term_separator filter
174
+ * New: Option to add comments number/link in post meta
175
+ * New: Allow override of settings within shortcode parameter
176
+ * New: Add standard post classes to each post
177
+ * Tweak: Remove many function_exists() wrappers - check your custom functions!
178
+ * Tweak: Pass list settings through hooks instead of using global
179
+ * Tweak: Clean up code considerably
180
+ * Tweak: Use the_excerpt() instead of custom function
181
+ * Tweak: Remove border radius from read more buttons
182
+ * Fix: Broken author setting
183
+ * Fix: Remove image float on mobile
184
+ * Fix: Missing color labels in WP 4.9
185
+
186
  = 1.0 =
187
  * Add new hook inside image container: wpsp_inside_image_container
188
  * Fix issue with pagination and random post ordering
245
 
246
  == Upgrade Notice ==
247
 
248
+ = 1.1 =
249
+ * New: Allow multiple taxonomy terms to be selected
250
+ * New: Choose the title HTML element
251
+ * New: wpsp_disable_title_link filter
252
+ * New: wpsp_disable_image_link filter
253
+ * New: wpsp_read_more_output filter
254
+ * New: wpsp_inside_wrapper hook
255
+ * New: wpsp_image_attributes filter
256
+ * New: wpsp_term_separator filter
257
+ * New: Option to add comments number/link in post meta
258
+ * New: Allow override of settings within shortcode parameter
259
+ * New: Add standard post classes to each post
260
+ * Tweak: Remove many function_exists() wrappers - check your custom functions!
261
+ * Tweak: Pass list settings through hooks instead of using global
262
+ * Tweak: Clean up code considerably
263
+ * Tweak: Use the_excerpt() instead of custom function
264
+ * Tweak: Remove border radius from read more buttons
265
+ * Fix: Broken author setting
266
+ * Fix: Remove image float on mobile
267
+ * Fix: Missing color labels in WP 4.9
268
+
269
  = 1.0 =
270
  * Add new hook inside image container: wpsp_inside_image_container
271
  * Fix issue with pagination and random post ordering
324
  * Wrap read more button in div: .wpsp-read-more
325
 
326
  = 0.1 =
327
+ * Initial release
wp-show-posts.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Show Posts
4
  Plugin URI: https://wpshowposts.com
5
  Description: WP Show Posts allows you to list posts (from any post type) anywhere on your site. This includes WooCommerce products or any other post type you might have! Check out the pro version for even more features at https://wpshowposts.com.
6
- Version: 1.0
7
  Author: Tom Usborne
8
  Author URI: https://tomusborne.com
9
  License: GNU General Public License v2 or later
@@ -12,353 +12,371 @@ Text Domain: wp-show-posts
12
  */
13
 
14
  // No direct access, please
15
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
16
 
17
  // Define the current version
18
- define( 'WPSP_VERSION', 1.0 );
19
 
20
- // Add defaults
21
- require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/defaults.php';
 
 
22
 
23
- // Add post type
 
 
 
 
24
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/post-type.php';
25
-
26
- // Add admin metabox
27
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/metabox.php';
28
-
29
- // Add admin AJAX
30
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/ajax.php';
31
-
32
- // Add resizer script
33
- if ( ! class_exists( 'WPSP_Resize' ) ) require_once plugin_dir_path( __FILE__ ) . 'inc/image-resizer.php';
34
-
35
- // Add functions
36
- require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/functions.php';
37
-
38
- // Add admin functions
39
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/admin.php';
40
-
41
- // Add widget
42
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/widget.php';
43
 
44
- // Add compatibility with pro
45
- require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/compat.php';
46
-
47
- if ( ! function_exists( 'wpsp_load_textdomain' ) ) :
48
  /**
49
  * Load plugin textdomain.
50
  *
51
  * @since 0.5
52
  */
53
- add_action( 'plugins_loaded', 'wpsp_load_textdomain' );
54
- function wpsp_load_textdomain()
55
- {
56
- load_plugin_textdomain( 'wp-show-posts' );
57
- }
58
- endif;
59
-
60
- if ( ! function_exists( 'wpsp_get_min_suffix' ) ) :
61
- /**
62
- * Figure out if we should use minified scripts or not
63
- * @since 0.1
64
- */
65
- function wpsp_get_min_suffix()
66
- {
67
- return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '-min';
68
  }
69
- endif;
70
 
71
- if ( ! function_exists( 'wpsp_enqueue_scripts' ) ) :
72
  /*
73
  * Enqueue our CSS to the front end
 
74
  * @since 0.1
75
  */
76
- add_action( 'wp_enqueue_scripts', 'wpsp_enqueue_scripts' );
77
- function wpsp_enqueue_scripts()
78
- {
79
- $suffix = wpsp_get_min_suffix();
80
  wp_enqueue_style( 'wp-show-posts', plugins_url( "css/wp-show-posts{$suffix}.css", __FILE__ ), array(), WPSP_VERSION );
81
  }
82
- endif;
83
 
84
- if ( ! function_exists( 'wpsp_get_setting' ) ) :
85
  /*
86
  * Create a helpful wrapper to get our settings and defaults
 
87
  * @since 0.1
 
 
 
 
88
  */
89
- function wpsp_get_setting( $id, $key )
90
- {
91
  // Get our defaults
92
  $defaults = wpsp_get_defaults();
93
-
94
  // Bail if our default isn't set
95
- if ( ! isset( $defaults[ $key ] ) )
96
  return false;
97
-
 
98
  // If we have a default, let's return a value
99
  return get_post_meta( $id, $key ) ? get_post_meta( $id, $key, true ) : $defaults[ $key ];
100
  }
101
- endif;
102
 
103
- if ( ! function_exists( 'wpsp_display' ) ) :
104
  /*
105
  * Build the front end of the plugin
106
  * $id parameter needs to match ID of custom post type entry
 
107
  * @since 0.1
 
 
 
108
  */
109
- function wpsp_display( $id )
110
- {
111
  // Set the global ID of our object
112
  global $wpsp_id;
113
  $wpsp_id = $id;
114
-
115
  // Build our setting variables
116
- $author = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_author' ) );
117
- $columns = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_columns' ) );
118
- $columns_gutter = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_columns_gutter' ) );
119
- $content_type = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_content_type' ) );
120
- $exclude_current = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_exclude_current' ) );
121
- $excerpt_length = absint( wpsp_get_setting( $id, 'wpsp_excerpt_length' ) );
122
- $post_id = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_id' ) );
123
- $exclude_post_id = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_exclude_post_id' ) );
124
- $ignore_sticky_posts = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_ignore_sticky_posts' ) );
125
- $include_title = wp_validate_boolean( get_post_meta( $id, 'wpsp_include_title', true ) );
126
- $author_location = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_author_location' ) );
127
- $date_location = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_date_location' ) );
128
- $terms_location = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_terms_location' ) );
129
- $include_author = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_include_author' ) );
130
- $include_terms = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_include_terms' ) );
131
- $include_date = wp_validate_boolean( get_post_meta( $id, 'wpsp_include_date', true ) );
132
- $inner_wrapper = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_inner_wrapper' ) );
133
- $inner_wrapper_class = array_map( 'sanitize_html_class', ( explode( ' ', wpsp_get_setting( $id, 'wpsp_inner_wrapper_class' ) ) ) );
134
- $inner_wrapper_style = explode( ' ', esc_attr( wpsp_get_setting( $id, 'wpsp_inner_wrapper_style' ) ) );
135
- $itemtype = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_itemtype' ) );
136
- $meta_key = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_meta_key' ) );
137
- $meta_value = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_meta_value' ) );
138
- $offset = absint( wpsp_get_setting( $id, 'wpsp_offset' ) );
139
- $order = sanitize_key( wpsp_get_setting( $id, 'wpsp_order' ) );
140
- $orderby = sanitize_key( wpsp_get_setting( $id, 'wpsp_orderby' ) );
141
- $pagination = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_pagination' ) );
142
- $post_type = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_type' ) );
143
- $post_status = wpsp_get_setting( $id, 'wpsp_post_status' ); // Validated later
144
- $posts_per_page = intval( wpsp_get_setting( $id, 'wpsp_posts_per_page' ) );
145
- $tax_operator = wpsp_get_setting( $id, 'wpsp_tax_operator' ); // Validated later
146
- $tax_term = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_tax_term' ) );
147
- $taxonomy = sanitize_key( wpsp_get_setting( $id, 'wpsp_taxonomy' ) );
148
- $wrapper = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_wrapper' ) );
149
- $wrapper_class = array_map( 'sanitize_html_class', ( explode( ' ', wpsp_get_setting( $id, 'wpsp_wrapper_class' ) ) ) );
150
- $wrapper_style = explode( ' ', esc_attr( wpsp_get_setting( $id, 'wpsp_wrapper_style' ) ) );
151
- $no_results = wp_kses_post( wpsp_get_setting( $id, 'wpsp_no_results' ) );
152
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  // Grab initiate args for query
154
  $args = array();
155
-
156
- if ( '' !== $order )
157
- $args[ 'order' ] = $order;
158
-
159
- if ( '' !== $orderby )
160
- $args[ 'orderby' ] = $orderby;
161
-
162
- if ( 'rand' == $orderby && $pagination ) {
 
 
163
  $args[ 'orderby' ] = 'rand(' . $id . ')';
164
  }
165
-
166
- if ( '' !== $post_type )
167
- $args[ 'post_type' ] = $post_type;
168
-
169
- if ( '' !== $posts_per_page )
170
- $args[ 'posts_per_page' ] = $posts_per_page;
171
-
172
- if ( $ignore_sticky_posts )
173
- $args[ 'ignore_sticky_posts' ] = $ignore_sticky_posts;
174
-
175
- if ( '' !== $meta_key )
176
- $args[ 'meta_key' ] = $meta_key;
177
-
178
- if ( '' !== $meta_value )
179
- $args[ 'meta_value' ] = $meta_value;
180
-
181
- if ( $offset > 0 )
182
- $args[ 'offset' ] = $offset;
183
-
184
- if ( '' !== $author )
185
- $args[ 'author' ] = array( $author );
186
-
187
- if ( $pagination && ! is_single() ) :
 
 
 
 
 
 
 
188
  $paged_query = is_front_page() ? 'page' : 'paged';
189
  $args[ 'paged' ] = get_query_var( $paged_query );
190
- endif;
191
-
192
- // Post Status
193
- $post_status = explode( ', ', $post_status );
194
  $validated = array();
195
  $available = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash', 'any' );
196
-
197
- foreach ( $post_status as $unvalidated )
198
- if ( in_array( $unvalidated, $available ) )
199
  $validated[] = $unvalidated;
200
-
201
- if( !empty( $validated ) )
 
 
202
  $args['post_status'] = $validated;
203
-
 
204
  // If taxonomy attributes, create a taxonomy query
205
- if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
206
-
207
- if ( 'current' == $tax_term ) {
 
 
 
 
208
  global $post;
209
- $terms = wp_get_post_terms(get_the_ID(), $taxonomy);
210
- $tax_term = array();
211
  foreach ($terms as $term) {
212
- $tax_term[] = $term->slug;
213
  }
214
  } else {
215
  // Term string to array
216
- $tax_term = explode( ', ', $tax_term );
217
  }
218
-
219
  // Validate operator
220
- if( !in_array( $tax_operator, array( 'IN', 'NOT IN', 'AND' ) ) )
221
- $tax_operator = 'IN';
222
-
 
223
  $tax_args = array(
224
  'tax_query' => array(
225
  array(
226
- 'taxonomy' => $taxonomy,
227
  'field' => 'slug',
228
- 'terms' => $tax_term,
229
- 'operator' => $tax_operator
230
  )
231
  )
232
  );
233
-
234
  $args = array_merge( $args, $tax_args );
 
235
  }
236
-
237
  // If Post IDs
238
- if( $post_id ) {
239
- $posts_in = array_map( 'intval', explode( ',', $post_id ) );
240
  $args['post__in'] = $posts_in;
241
  }
242
-
243
  // If Exclude Post IDs
244
- if( $exclude_post_id ) {
245
- $posts_not_in = array_map( 'intval', explode( ',', $exclude_post_id ) );
246
  $args['post__not_in'] = $posts_not_in;
247
  }
248
-
249
  // If Exclude Current
250
- if( ( is_singular() && $exclude_current ) || is_single() )
251
  $args['post__not_in'] = array( get_the_ID() );
252
-
 
253
  // Border
254
- $border = wpsp_sanitize_hex_color( wpsp_get_setting( $id, 'wpsp_border' ) );
255
- if ( '' !== $border ) {
256
- $wrapper_class[] = 'include-border';
257
- if ( ! function_exists( 'wpsp_styling' ) ) :
258
- $border = 'border-color: ' . $border . ';';
259
- endif;
260
- }
261
-
 
 
262
  // Padding
263
- $padding = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_padding' ) );
264
- if ( '' !== $padding ) {
265
- $wrapper_class[] = 'include-padding';
266
- $padding = 'padding:' . $padding . ';';
 
 
267
  }
268
-
269
  // Columns
270
- if ( $columns !== 'col-12' ) :
271
  wp_enqueue_script( 'wpsp-matchHeight', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/jquery.matchHeight.js', array( 'jquery' ), WPSP_VERSION, true );
272
- $wrapper_class[] = 'wp-show-posts-columns';
273
- if ( ! function_exists( 'wpsp_styling' ) ) :
274
- $wrapper_style[] = 'margin-left:-' . $columns_gutter . ';';
275
- $inner_wrapper_style[] = 'margin: 0 0 ' . $columns_gutter . ' ' . $columns_gutter . ';' . $padding;
276
- endif;
277
- endif;
278
 
279
  // Featured post class
280
  $featured_post = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_featured_post' ) );
281
-
282
  $current_post = '';
283
- if ( $columns !== 'col-12' && $featured_post ) :
284
- if ( $columns == 'col-6' )
285
  $current_post = 'wpsp-col-12';
 
286
 
287
- if ( $columns == 'col-4' )
288
  $current_post = 'wpsp-col-8';
 
289
 
290
- if ( $columns == 'col-3' )
291
  $current_post = 'wpsp-col-6';
 
292
 
293
- if ( $columns == 'col-20' )
294
  $current_post = 'wpsp-col-6';
295
- endif;
 
296
 
297
  // Masonry
298
  $masonry = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_masonry' ) );
299
-
300
- if ( $masonry ) :
301
- $wrapper_class[] = 'wp-show-posts-masonry';
302
- $inner_wrapper_class[] = ' wp-show-posts-masonry-' . $columns;
303
- $inner_wrapper_class[] = ' wp-show-posts-masonry-block';
304
 
305
  wp_enqueue_script( 'wpsp-imagesloaded' );
306
  wp_enqueue_script( 'jquery-masonry' );
307
  wp_add_inline_script( 'jquery-masonry', 'jQuery(function($){var $container = $(".wp-show-posts-masonry");$container.imagesLoaded( function(){$container.fadeIn( 1000 ).masonry({itemSelector : ".wp-show-posts-masonry-block",columnWidth: ".grid-sizer"}).css("opacity","1");});});' );
308
- endif;
309
-
310
- // Filter
311
- // $filter = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_filter' ) );
312
- // if ( $filter ) :
313
- // wp_enqueue_script( 'wpsp-imagesloaded' );
314
- // wp_enqueue_script( 'wpsp-filterizr' );
315
- // wp_add_inline_script( 'wpsp-filterizr', 'jQuery(function($){ var $filterizd = $( ".wp-show-posts" );$filterizd.imagesLoaded( function(){ $( ".wp-show-posts" ).filterizr("setOptions", {layout: "sameWidth"}); } )});' );
316
- // $inner_wrapper_class[] = 'filtr-item';
317
- // endif;
318
 
319
  // Add the default inner wrapper class
320
  // We don't create the class element up here like below, as we need to add classes inside the loop below as well
321
- $inner_wrapper_class[] = 'wp-show-posts-single';
322
-
323
- if ( 'col-12' == $columns )
324
- $inner_wrapper_class[] = 'wpsp-clearfix';
 
325
 
326
  // Add the default wrapper class
327
- $wrapper_class[] = 'wp-show-posts';
328
 
329
  // Get the wrapper class
330
- if( !empty( $wrapper_class ) )
331
- $wrapper_class = ' class="' . implode( ' ', $wrapper_class ) . '"';
 
332
 
333
  // Get the wrapper style
334
- if( !empty( $wrapper_style ) )
335
- $wrapper_style = ' style="' . implode( ' ', $wrapper_style ) . '"';
 
336
 
337
  // Get the inner wrapper class
338
- if( !empty( $inner_wrapper_style ) )
339
- $inner_wrapper_style = ' style="' . implode( ' ', $inner_wrapper_style ) . '"';
 
340
 
341
  // Get the wrapper ID
342
  $wrapper_id = ' id="wpsp-' . $id . '"';
343
-
344
  $wrapper_atts = apply_filters( 'wpsp_wrapper_atts', '' );
345
 
346
- do_action( 'wpsp_before_wrapper' );
347
-
348
- // if ( $filter ) :
349
- // $post_terms = get_terms( sanitize_text_field( $taxonomy ), 'orderby=count&hide_empty=1' );
350
- // echo '<ul>';
351
- // foreach ( $post_terms as $term ) {
352
- // echo '<li data-filter="' . $term->term_id . '">' . $term->name . '</li>';
353
- // }
354
- // echo '</ul>';
355
- // endif;
356
-
357
  // Start the wrapper
358
- echo '<' . $wrapper . $wrapper_id . $wrapper_class . $wrapper_style . $wrapper_atts . '>';
 
 
359
 
360
- if ( $masonry )
361
- echo '<div class="grid-sizer wpsp-' . $columns . '"></div>';
 
362
 
363
  // Start the query
364
  $query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args ) );
@@ -366,146 +384,172 @@ function wpsp_display( $id )
366
  if ( $query->have_posts() ) {
367
  while ( $query->have_posts() ) {
368
  $query->the_post();
369
-
370
- // Get page
371
  $paged_query = is_front_page() ? 'page' : 'paged';
372
  $paged = ( get_query_var( $paged_query ) ) ? get_query_var( $paged_query ) : 1;
373
-
374
  $featured = '';
375
  $column_class = '';
 
376
  // Featured post
377
- if ( $columns !== 'col-12' && $featured_post ) :
378
  if ( $query->current_post == 0 && $paged == 1 ) {
379
  $featured = ' featured-column ' . $current_post;
380
  } else {
381
- $featured = ' wpsp-' . $columns;
382
  }
383
- elseif ( $columns !== 'col-12' ) :
384
- $column_class .= ' wpsp-' . $columns;
385
- endif;
386
-
387
- $terms_list = '';
388
- // if ( $filter ) :
389
- // $terms_list = wp_get_post_terms( get_the_ID(), $taxonomy );
390
- // $output_terms = array();
391
- // foreach ( $terms_list as $term ) {
392
- // $output_terms[] = $term->term_id;
393
- // }
394
- // $terms_list = 'data-category="' . implode( ', ', $output_terms ) . '"';
395
- // endif;
396
-
397
  // Start inner container
398
- echo '<' . $inner_wrapper . ' class="' . implode( ' ', $inner_wrapper_class ) . $column_class . $featured . '" itemtype="http://schema.org/' . $itemtype . '" itemscope ' . $terms_list . '>';
399
- echo '<div class="wp-show-posts-inner"' . $inner_wrapper_style . '>';
400
-
401
- do_action( 'wpsp_before_header' );
402
-
 
 
 
 
 
403
  // The title
404
- if ( $include_title || ( $include_author && 'below-title' == $author_location ) || ( $include_date && 'below-title' == $date_location ) || ( $include_terms && 'below-title' == $terms_location ) ) : ?>
405
  <header class="wp-show-posts-entry-header">
406
- <?php
407
-
408
- do_action( 'wpsp_before_title' );
409
-
410
- if ( $include_title )
411
- the_title( sprintf( '<h2 class="wp-show-posts-entry-title" itemprop="headline"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
412
-
413
- do_action( 'wpsp_after_title' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
414
  ?>
415
  </header><!-- .entry-header -->
416
  <?php endif;
417
-
418
- do_action( 'wpsp_before_content' );
419
-
420
  // Check to see if we have the more tag
421
  global $post;
422
- $more_tag = apply_filters( 'wpsp_more_tag', @strpos( $post->post_content, '<!--more-->' ) );
423
-
424
  // The excerpt or full content
425
- if ( 'excerpt' == $content_type && $excerpt_length && ! $more_tag && 'none' !== $content_type ) : ?>
426
  <div class="wp-show-posts-entry-summary" itemprop="text">
427
- <?php wpsp_excerpt( $excerpt_length ); ?>
428
  </div><!-- .entry-summary -->
429
- <?php elseif ( ( 'full' == $content_type || $more_tag ) && 'none' !== $content_type ) : ?>
430
  <div class="wp-show-posts-entry-content" itemprop="text">
431
  <?php the_content( false, false ); ?>
432
  </div><!-- .entry-content -->
433
  <?php endif;
434
-
435
- do_action( 'wpsp_after_content' );
436
-
437
  echo '</div><!-- wp-show-posts-inner -->';
438
- if ( 'col-12' == $columns ) echo '<div class="wpsp-clear"></div>';
 
 
 
 
439
  // End inner container
440
- echo '</' . $inner_wrapper . '>';
441
  }
442
  } else {
443
  // no posts found
444
- echo ( $columns !== 'col-12' ) ? '<div class="wpsp-no-results" style="margin-left: ' . $columns_gutter . ';">' : '';
445
- echo wpautop( $no_results );
446
- echo ( $columns !== 'col-12' ) ? '</div>' : '';
447
  }
448
- if ( $columns !== 'col-12' ) echo '<div class="wpsp-clear"></div>';
449
- echo '</' . $wrapper . '><!-- .wp-show-posts -->';
450
 
451
- do_action( 'wpsp_after_wrapper' );
452
-
 
 
 
 
 
 
453
  // Pagination
454
- if ( $pagination && $query->have_posts() && ! is_single() ) :
455
- $ajax_pagination = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_ajax_pagination' ) );
456
-
457
- if ( $ajax_pagination && function_exists( 'wpsp_ajax_pagination' ) ) :
458
-
459
  $max_page = $query->max_num_pages;
460
  $nextpage = intval( $paged ) + 1;
461
 
462
- if ( $nextpage <= $max_page )
463
  $next_page_url = next_posts( $max_page, false );
464
-
 
465
  wpsp_ajax_pagination( $next_page_url, $paged, $max_page );
466
  wp_enqueue_script( 'wpsp-imagesloaded' );
467
  wp_enqueue_script( 'wpsp-ajax-pagination' );
468
- else :
469
  wpsp_pagination( $query->max_num_pages );
470
- endif;
471
- endif;
472
-
473
- // Lightbox and gallery
474
- $image_lightbox = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_image_lightbox' ) );
475
- if ( $image_lightbox ) {
476
- wp_enqueue_script( 'wpsp-featherlight' );
477
- wp_enqueue_style( 'wpsp-featherlight' );
478
-
479
- $image_gallery = sanitize_text_field( wpsp_get_setting( $id, 'wpsp_image_gallery' ) );
480
- if ( $image_gallery ) {
481
- wp_enqueue_script( 'wpsp-featherlight-gallery' );
482
- wp_enqueue_style( 'wpsp-featherlight-gallery' );
483
  }
484
  }
485
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
486
  // Restore original Post Data
487
  wp_reset_postdata();
488
  }
489
- endif;
490
 
491
- if ( ! function_exists( 'wpsp_shortcode_function' ) ) :
492
  /*
493
  * Build the shortcode
 
494
  * @since 0.1
 
 
495
  */
496
- add_shortcode( 'wp_show_posts', 'wpsp_shortcode_function' );
497
- function wpsp_shortcode_function( $atts , $content = null ) {
498
- // Attributes
499
  $atts = shortcode_atts(
500
  array(
501
  'id' => '',
 
502
  ), $atts, 'wp_show_posts'
503
  );
 
504
  ob_start();
505
-
506
- if ( $atts[ 'id' ] )
507
- wpsp_display( $atts[ 'id' ] );
508
-
 
509
  return ob_get_clean();
510
  }
511
- endif;
3
  Plugin Name: WP Show Posts
4
  Plugin URI: https://wpshowposts.com
5
  Description: WP Show Posts allows you to list posts (from any post type) anywhere on your site. This includes WooCommerce products or any other post type you might have! Check out the pro version for even more features at https://wpshowposts.com.
6
+ Version: 1.1
7
  Author: Tom Usborne
8
  Author URI: https://tomusborne.com
9
  License: GNU General Public License v2 or later
12
  */
13
 
14
  // No direct access, please
15
+ if ( ! defined( 'ABSPATH' ) ) {
16
+ exit;
17
+ }
18
 
19
  // Define the current version
20
+ define( 'WPSP_VERSION', '1.1' );
21
 
22
+ // Add resizer script
23
+ if ( ! class_exists( 'WPSP_Resize' ) ) {
24
+ require_once plugin_dir_path( __FILE__ ) . 'inc/image-resizer.php';
25
+ }
26
 
27
+ require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/defaults.php';
28
+ require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/functions.php';
29
+ require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/compat.php';
30
+ require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/styling.php';
31
+ require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/deprecated.php';
32
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/post-type.php';
 
 
33
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/metabox.php';
 
 
34
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/ajax.php';
 
 
 
 
 
 
 
 
35
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/admin.php';
 
 
36
  require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/widget.php';
37
 
38
+ add_action( 'plugins_loaded', 'wpsp_load_textdomain' );
 
 
 
39
  /**
40
  * Load plugin textdomain.
41
  *
42
  * @since 0.5
43
  */
44
+ function wpsp_load_textdomain() {
45
+ load_plugin_textdomain( 'wp-show-posts' );
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
 
47
 
48
+ add_action( 'wp_enqueue_scripts', 'wpsp_enqueue_scripts' );
49
  /*
50
  * Enqueue our CSS to the front end
51
+ *
52
  * @since 0.1
53
  */
54
+ function wpsp_enqueue_scripts() {
55
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '-min';
 
 
56
  wp_enqueue_style( 'wp-show-posts', plugins_url( "css/wp-show-posts{$suffix}.css", __FILE__ ), array(), WPSP_VERSION );
57
  }
 
58
 
 
59
  /*
60
  * Create a helpful wrapper to get our settings and defaults
61
+ *
62
  * @since 0.1
63
+ *
64
+ * @param int $id The post ID.
65
+ * @param string $key The post meta key.
66
+ * @return mixed The value of our key.
67
  */
68
+ function wpsp_get_setting( $id, $key ) {
 
69
  // Get our defaults
70
  $defaults = wpsp_get_defaults();
71
+
72
  // Bail if our default isn't set
73
+ if ( ! isset( $defaults[ $key ] ) ) {
74
  return false;
75
+ }
76
+
77
  // If we have a default, let's return a value
78
  return get_post_meta( $id, $key ) ? get_post_meta( $id, $key, true ) : $defaults[ $key ];
79
  }
 
80
 
 
81
  /*
82
  * Build the front end of the plugin
83
  * $id parameter needs to match ID of custom post type entry
84
+ *
85
  * @since 0.1
86
+ *
87
+ * @param int $id The ID of the post.
88
+ * @param string|array $custom_settings Custom settings we can pass to our list.
89
  */
90
+ function wpsp_display( $id, $custom_settings = false ) {
 
91
  // Set the global ID of our object
92
  global $wpsp_id;
93
  $wpsp_id = $id;
94
+
95
  // Build our setting variables
96
+ $settings = apply_filters( 'wpsp_settings', array(
97
+ 'list_id' => absint( $id ),
98
+ 'author' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_author' ) ),
99
+ 'columns' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_columns' ) ),
100
+ 'columns_gutter' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_columns_gutter' ) ),
101
+ 'content_type' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_content_type' ) ),
102
+ 'exclude_current' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_exclude_current' ) ),
103
+ 'excerpt_length' => absint( wpsp_get_setting( $id, 'wpsp_excerpt_length' ) ),
104
+ 'post_id' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_id' ) ),
105
+ 'exclude_post_id' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_exclude_post_id' ) ),
106
+ 'ignore_sticky_posts' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_ignore_sticky_posts' ) ),
107
+ 'include_title' => wp_validate_boolean( get_post_meta( $id, 'wpsp_include_title', true ) ),
108
+ 'title_element' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_title_element' ) ),
109
+ 'image' => sanitize_text_field( get_post_meta( $id, 'wpsp_image', true ), FILTER_VALIDATE_BOOLEAN ),
110
+ 'image_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_image_location' ) ),
111
+ 'image_alignment' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_image_alignment' ) ),
112
+ 'image_height' => absint( wpsp_get_setting( $id, 'wpsp_image_height' ) ),
113
+ 'image_width' => absint( wpsp_get_setting( $id, 'wpsp_image_width' ) ),
114
+ 'include_author' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_include_author' ) ),
115
+ 'author_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_author_location' ) ),
116
+ 'include_terms' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_include_terms' ) ),
117
+ 'terms_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_terms_location' ) ),
118
+ 'include_date' => wp_validate_boolean( get_post_meta( $id, 'wpsp_include_date', true ) ),
119
+ 'date_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_date_location' ) ),
120
+ 'include_comments' => wp_validate_boolean( get_post_meta( $id, 'wpsp_include_comments', true ) ),
121
+ 'comments_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_comments_location' ) ),
122
+ 'inner_wrapper' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_inner_wrapper' ) ),
123
+ 'inner_wrapper_class' => array_map( 'sanitize_html_class', ( explode( ' ', wpsp_get_setting( $id, 'wpsp_inner_wrapper_class' ) ) ) ),
124
+ 'inner_wrapper_style' => explode( ' ', esc_attr( wpsp_get_setting( $id, 'wpsp_inner_wrapper_style' ) ) ),
125
+ 'itemtype' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_itemtype' ) ),
126
+ 'meta_key' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_meta_key' ) ),
127
+ 'meta_value' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_meta_value' ) ),
128
+ 'offset' => absint( wpsp_get_setting( $id, 'wpsp_offset' ) ),
129
+ 'order' => sanitize_key( wpsp_get_setting( $id, 'wpsp_order' ) ),
130
+ 'orderby' => sanitize_key( wpsp_get_setting( $id, 'wpsp_orderby' ) ),
131
+ 'pagination' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_pagination' ) ),
132
+ 'post_type' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_type' ) ),
133
+ 'post_status' => wpsp_get_setting( $id, 'wpsp_post_status' ), // Validated later
134
+ 'posts_per_page' => intval( wpsp_get_setting( $id, 'wpsp_posts_per_page' ) ),
135
+ 'tax_operator' => wpsp_get_setting( $id, 'wpsp_tax_operator' ), // Validated later
136
+ 'tax_term' => wpsp_get_setting( $id, 'wpsp_tax_term' ),
137
+ 'taxonomy' => sanitize_key( wpsp_get_setting( $id, 'wpsp_taxonomy' ) ),
138
+ 'read_more_text' => wp_kses_post( wpsp_get_setting( $id, 'wpsp_read_more_text' ) ),
139
+ 'wrapper' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_wrapper' ) ),
140
+ 'wrapper_class' => array_map( 'sanitize_html_class', ( explode( ' ', wpsp_get_setting( $id, 'wpsp_wrapper_class' ) ) ) ),
141
+ 'wrapper_style' => explode( ' ', esc_attr( wpsp_get_setting( $id, 'wpsp_wrapper_style' ) ) ),
142
+ 'no_results' => wp_kses_post( wpsp_get_setting( $id, 'wpsp_no_results' ) ),
143
+ 'post_meta_bottom_style' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_meta_bottom_style' ) ),
144
+ 'post_meta_top_style' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_meta_top_style' ) ),
145
+ ) );
146
+
147
+ // Replace args with any custom args.
148
+ if ( ! empty( $custom_settings ) ) {
149
+ if ( is_array( $custom_settings ) ) {
150
+ $settings = array_merge( $settings, $custom_settings );
151
+ }
152
+
153
+ if ( ! is_array( $custom_settings ) ) {
154
+ $settings_string = parse_str( $custom_settings, $custom_settings );
155
+ $settings = array_merge( $settings, $custom_settings );
156
+ }
157
+ }
158
+
159
  // Grab initiate args for query
160
  $args = array();
161
+
162
+ if ( '' !== $settings[ 'order' ] ) {
163
+ $args[ 'order' ] = $settings[ 'order' ];
164
+ }
165
+
166
+ if ( '' !== $settings[ 'orderby' ] ) {
167
+ $args[ 'orderby' ] = $settings[ 'orderby' ];
168
+ }
169
+
170
+ if ( 'rand' == $settings[ 'orderby' ] && $settings[ 'pagination' ] ) {
171
  $args[ 'orderby' ] = 'rand(' . $id . ')';
172
  }
173
+
174
+ if ( '' !== $settings[ 'post_type' ] ) {
175
+ $args[ 'post_type' ] = $settings[ 'post_type' ];
176
+ }
177
+
178
+ if ( '' !== $settings[ 'posts_per_page' ] ) {
179
+ $args[ 'posts_per_page' ] = $settings[ 'posts_per_page' ];
180
+ }
181
+
182
+ if ( $settings[ 'ignore_sticky_posts' ] ) {
183
+ $args[ 'ignore_sticky_posts' ] = $settings[ 'ignore_sticky_posts' ];
184
+ }
185
+
186
+ if ( '' !== $settings[ 'meta_key' ] ) {
187
+ $args[ 'meta_key' ] = $settings[ 'meta_key' ];
188
+ }
189
+
190
+ if ( '' !== $settings[ 'meta_value' ] ) {
191
+ $args[ 'meta_value' ] = $settings[ 'meta_value' ];
192
+ }
193
+
194
+ if ( $settings[ 'offset' ] > 0 ) {
195
+ $args[ 'offset' ] = $settings[ 'offset' ];
196
+ }
197
+
198
+ if ( '' !== $settings[ 'author' ] ) {
199
+ $args[ 'author' ] = $settings[ 'author' ];
200
+ }
201
+
202
+ if ( $settings[ 'pagination' ] && ! is_single() ) {
203
  $paged_query = is_front_page() ? 'page' : 'paged';
204
  $args[ 'paged' ] = get_query_var( $paged_query );
205
+ }
206
+
207
+ // Post Status
208
+ $settings[ 'post_status' ] = explode( ', ', $settings[ 'post_status' ] );
209
  $validated = array();
210
  $available = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash', 'any' );
211
+
212
+ foreach ( $settings[ 'post_status' ] as $unvalidated ) {
213
+ if ( in_array( $unvalidated, $available ) ) {
214
  $validated[] = $unvalidated;
215
+ }
216
+ }
217
+
218
+ if ( ! empty( $validated ) ) {
219
  $args['post_status'] = $validated;
220
+ }
221
+
222
  // If taxonomy attributes, create a taxonomy query
223
+ if ( ! empty( $settings[ 'taxonomy' ] ) && ! empty( $settings[ 'tax_term' ] ) ) {
224
+
225
+ if ( is_array( $settings[ 'tax_term' ] ) ) {
226
+ $settings[ 'tax_term' ] = implode( ', ', $settings[ 'tax_term' ] );
227
+ }
228
+
229
+ if ( 'current' == $settings[ 'tax_term' ] ) {
230
  global $post;
231
+ $terms = wp_get_post_terms(get_the_ID(), $settings[ 'taxonomy' ]);
232
+ $settings[ 'tax_term' ] = array();
233
  foreach ($terms as $term) {
234
+ $settings[ 'tax_term' ][] = $term->slug;
235
  }
236
  } else {
237
  // Term string to array
238
+ $settings[ 'tax_term' ] = explode( ', ', $settings[ 'tax_term' ] );
239
  }
240
+
241
  // Validate operator
242
+ if ( ! in_array( $settings[ 'tax_operator' ], array( 'IN', 'NOT IN', 'AND' ) ) ) {
243
+ $settings[ 'tax_operator' ] = 'IN';
244
+ }
245
+
246
  $tax_args = array(
247
  'tax_query' => array(
248
  array(
249
+ 'taxonomy' => $settings[ 'taxonomy' ],
250
  'field' => 'slug',
251
+ 'terms' => $settings[ 'tax_term' ],
252
+ 'operator' => $settings[ 'tax_operator' ]
253
  )
254
  )
255
  );
256
+
257
  $args = array_merge( $args, $tax_args );
258
+
259
  }
260
+
261
  // If Post IDs
262
+ if ( $settings[ 'post_id' ] ) {
263
+ $posts_in = array_map( 'intval', explode( ',', $settings[ 'post_id' ] ) );
264
  $args['post__in'] = $posts_in;
265
  }
266
+
267
  // If Exclude Post IDs
268
+ if ( $settings[ 'exclude_post_id' ] ) {
269
+ $posts_not_in = array_map( 'intval', explode( ',', $settings[ 'exclude_post_id' ] ) );
270
  $args['post__not_in'] = $posts_not_in;
271
  }
272
+
273
  // If Exclude Current
274
+ if ( ( is_singular() && $settings[ 'exclude_current' ] ) || is_single() ) {
275
  $args['post__not_in'] = array( get_the_ID() );
276
+ }
277
+
278
  // Border
279
+ if ( defined( 'WPSP_PRO_VERSION' ) && version_compare( WPSP_PRO_VERSION, '0.6', '<' ) ) {
280
+ $border = wpsp_sanitize_hex_color( wpsp_get_setting( $settings['list_id'], 'wpsp_border' ) );
281
+ if ( '' !== $border ) {
282
+ $settings['wrapper_class'][] = 'include-border';
283
+ if ( ! function_exists( 'wpsp_styling' ) ) {
284
+ $border = 'border-color: ' . $border . ';';
285
+ }
286
+ }
287
+ }
288
+
289
  // Padding
290
+ if ( defined( 'WPSP_PRO_VERSION' ) && version_compare( WPSP_PRO_VERSION, '0.6', '<' ) ) {
291
+ $padding = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_padding' ) );
292
+ if ( '' !== $padding ) {
293
+ $settings['wrapper_class'][] = 'include-padding';
294
+ $padding = 'padding:' . $padding . ';';
295
+ }
296
  }
297
+
298
  // Columns
299
+ if ( 'col-12' !== $settings[ 'columns' ] ) {
300
  wp_enqueue_script( 'wpsp-matchHeight', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/jquery.matchHeight.js', array( 'jquery' ), WPSP_VERSION, true );
301
+ $settings[ 'wrapper_class' ][] = 'wp-show-posts-columns';
302
+ }
 
 
 
 
303
 
304
  // Featured post class
305
  $featured_post = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_featured_post' ) );
306
+
307
  $current_post = '';
308
+ if ( 'col-12' !== $settings[ 'columns' ] && $featured_post ) {
309
+ if ( $settings[ 'columns' ] == 'col-6' ) {
310
  $current_post = 'wpsp-col-12';
311
+ }
312
 
313
+ if ( $settings[ 'columns' ] == 'col-4' ) {
314
  $current_post = 'wpsp-col-8';
315
+ }
316
 
317
+ if ( $settings[ 'columns' ] == 'col-3' ) {
318
  $current_post = 'wpsp-col-6';
319
+ }
320
 
321
+ if ( $settings[ 'columns' ] == 'col-20' ) {
322
  $current_post = 'wpsp-col-6';
323
+ }
324
+ }
325
 
326
  // Masonry
327
  $masonry = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_masonry' ) );
328
+
329
+ if ( $masonry ) {
330
+ $settings[ 'wrapper_class' ][] = 'wp-show-posts-masonry';
331
+ $settings[ 'inner_wrapper_class' ][] = ' wp-show-posts-masonry-' . $settings[ 'columns' ];
332
+ $settings[ 'inner_wrapper_class' ][] = ' wp-show-posts-masonry-block';
333
 
334
  wp_enqueue_script( 'wpsp-imagesloaded' );
335
  wp_enqueue_script( 'jquery-masonry' );
336
  wp_add_inline_script( 'jquery-masonry', 'jQuery(function($){var $container = $(".wp-show-posts-masonry");$container.imagesLoaded( function(){$container.fadeIn( 1000 ).masonry({itemSelector : ".wp-show-posts-masonry-block",columnWidth: ".grid-sizer"}).css("opacity","1");});});' );
337
+ }
 
 
 
 
 
 
 
 
 
338
 
339
  // Add the default inner wrapper class
340
  // We don't create the class element up here like below, as we need to add classes inside the loop below as well
341
+ $settings[ 'inner_wrapper_class' ][] = 'wp-show-posts-single';
342
+
343
+ if ( 'col-12' == $settings[ 'columns' ] ) {
344
+ $settings[ 'inner_wrapper_class' ][] = 'wpsp-clearfix';
345
+ }
346
 
347
  // Add the default wrapper class
348
+ $settings[ 'wrapper_class' ][] = 'wp-show-posts';
349
 
350
  // Get the wrapper class
351
+ if ( ! empty( $settings[ 'wrapper_class' ] ) ) {
352
+ $settings[ 'wrapper_class' ] = ' class="' . implode( ' ', $settings[ 'wrapper_class' ] ) . '"';
353
+ }
354
 
355
  // Get the wrapper style
356
+ if ( ! empty( $settings[ 'wrapper_style' ] ) ) {
357
+ $settings[ 'wrapper_style' ] = ' style="' . implode( ' ', $settings[ 'wrapper_style' ] ) . '"';
358
+ }
359
 
360
  // Get the inner wrapper class
361
+ if ( ! empty( $settings[ 'inner_wrapper_style' ] ) ) {
362
+ $settings[ 'inner_wrapper_style' ] = ' style="' . implode( ' ', $settings[ 'inner_wrapper_style' ] ) . '"';
363
+ }
364
 
365
  // Get the wrapper ID
366
  $wrapper_id = ' id="wpsp-' . $id . '"';
367
+
368
  $wrapper_atts = apply_filters( 'wpsp_wrapper_atts', '' );
369
 
370
+ do_action( 'wpsp_before_wrapper', $settings );
371
+
 
 
 
 
 
 
 
 
 
372
  // Start the wrapper
373
+ echo '<' . $settings[ 'wrapper' ] . $wrapper_id . $settings[ 'wrapper_class' ] . $settings[ 'wrapper_style' ] . $wrapper_atts . '>';
374
+
375
+ do_action( 'wpsp_inside_wrapper', $settings );
376
 
377
+ if ( $masonry ) {
378
+ echo '<div class="grid-sizer wpsp-' . $settings[ 'columns' ] . '"></div>';
379
+ }
380
 
381
  // Start the query
382
  $query = new WP_Query( apply_filters( 'wp_show_posts_shortcode_args', $args ) );
384
  if ( $query->have_posts() ) {
385
  while ( $query->have_posts() ) {
386
  $query->the_post();
387
+
388
+ // Get page
389
  $paged_query = is_front_page() ? 'page' : 'paged';
390
  $paged = ( get_query_var( $paged_query ) ) ? get_query_var( $paged_query ) : 1;
391
+
392
  $featured = '';
393
  $column_class = '';
394
+
395
  // Featured post
396
+ if ( $settings[ 'columns' ] !== 'col-12' && $featured_post ) {
397
  if ( $query->current_post == 0 && $paged == 1 ) {
398
  $featured = ' featured-column ' . $current_post;
399
  } else {
400
+ $featured = ' wpsp-' . $settings[ 'columns' ];
401
  }
402
+ } elseif ( $settings[ 'columns' ] !== 'col-12' ) {
403
+ $column_class .= ' wpsp-' . $settings[ 'columns' ];
404
+ }
405
+
406
+ // Merge our classes with the post classes.
407
+ $settings['inner_wrapper_class'] = array_merge( $settings['inner_wrapper_class'], get_post_class() );
408
+
 
 
 
 
 
 
 
409
  // Start inner container
410
+ printf( '<%1$s class="%2$s" itemtype="http://schema.org/%3$s" itemscope>',
411
+ $settings[ 'inner_wrapper' ],
412
+ implode( ' ', $settings[ 'inner_wrapper_class' ] ) . $column_class . $featured,
413
+ $settings[ 'itemtype' ]
414
+ );
415
+
416
+ echo '<div class="wp-show-posts-inner"' . $settings[ 'inner_wrapper_style' ] . '>';
417
+
418
+ do_action( 'wpsp_before_header', $settings );
419
+
420
  // The title
421
+ if ( $settings[ 'include_title' ] || ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) ) : ?>
422
  <header class="wp-show-posts-entry-header">
423
+ <?php
424
+
425
+ do_action( 'wpsp_before_title', $settings );
426
+
427
+ $before_title = sprintf(
428
+ '<%1$s class="wp-show-posts-entry-title" itemprop="headline"><a href="%2$s" rel="bookmark">',
429
+ $settings[ 'title_element' ],
430
+ esc_url( get_permalink() )
431
+ );
432
+
433
+ $after_title = '</a></' . $settings[ 'title_element' ] . '>';
434
+
435
+ if ( apply_filters( 'wpsp_disable_title_link', false, $settings ) ) {
436
+ $before_title = '<' . $settings[ 'title_element' ] . ' class="wp-show-posts-entry-title" itemprop="headline">';
437
+ $after_title = '</' . $settings[ 'title_element' ] . '>';
438
+ }
439
+
440
+ if ( $settings[ 'include_title' ] ) {
441
+ the_title( $before_title, $after_title );
442
+ }
443
+
444
+ do_action( 'wpsp_after_title', $settings );
445
  ?>
446
  </header><!-- .entry-header -->
447
  <?php endif;
448
+
449
+ do_action( 'wpsp_before_content', $settings );
450
+
451
  // Check to see if we have the more tag
452
  global $post;
453
+ $more_tag = apply_filters( 'wpsp_more_tag', strpos( $post->post_content, '<!--more-->' ) );
454
+
455
  // The excerpt or full content
456
+ if ( 'excerpt' == $settings[ 'content_type' ] && $settings[ 'excerpt_length' ] && ! $more_tag && 'none' !== $settings[ 'content_type' ] ) : ?>
457
  <div class="wp-show-posts-entry-summary" itemprop="text">
458
+ <?php wpsp_excerpt( $settings[ 'excerpt_length' ] ); ?>
459
  </div><!-- .entry-summary -->
460
+ <?php elseif ( ( 'full' == $settings[ 'content_type' ] || $more_tag ) && 'none' !== $settings[ 'content_type' ] ) : ?>
461
  <div class="wp-show-posts-entry-content" itemprop="text">
462
  <?php the_content( false, false ); ?>
463
  </div><!-- .entry-content -->
464
  <?php endif;
465
+
466
+ do_action( 'wpsp_after_content', $settings );
467
+
468
  echo '</div><!-- wp-show-posts-inner -->';
469
+
470
+ if ( 'col-12' == $settings[ 'columns' ] ) {
471
+ echo '<div class="wpsp-clear"></div>';
472
+ }
473
+
474
  // End inner container
475
+ echo '</' . $settings[ 'inner_wrapper' ] . '>';
476
  }
477
  } else {
478
  // no posts found
479
+ echo $settings[ 'columns' ] !== 'col-12' ? '<div class="wpsp-no-results" style="margin-left: ' . $settings[ 'columns_gutter' ] . ';">' : '';
480
+ echo wpautop( $settings[ 'no_results' ] );
481
+ echo $settings[ 'columns' ] !== 'col-12' ? '</div>' : '';
482
  }
 
 
483
 
484
+ if ( $settings[ 'columns' ] !== 'col-12' ) {
485
+ echo '<div class="wpsp-clear"></div>';
486
+ }
487
+
488
+ echo '</' . $settings[ 'wrapper' ] . '><!-- .wp-show-posts -->';
489
+
490
+ do_action( 'wpsp_after_wrapper', $settings );
491
+
492
  // Pagination
493
+ if ( $settings[ 'pagination' ] && $query->have_posts() && ! is_single() ) {
494
+ $ajax_pagination = wp_validate_boolean( wpsp_get_setting( $settings['list_id'], 'wpsp_ajax_pagination' ) );
495
+
496
+ if ( $ajax_pagination && function_exists( 'wpsp_ajax_pagination' ) ) {
497
+
498
  $max_page = $query->max_num_pages;
499
  $nextpage = intval( $paged ) + 1;
500
 
501
+ if ( $nextpage <= $max_page ) {
502
  $next_page_url = next_posts( $max_page, false );
503
+ }
504
+
505
  wpsp_ajax_pagination( $next_page_url, $paged, $max_page );
506
  wp_enqueue_script( 'wpsp-imagesloaded' );
507
  wp_enqueue_script( 'wpsp-ajax-pagination' );
508
+ } else {
509
  wpsp_pagination( $query->max_num_pages );
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  }
511
  }
512
+
513
+ if ( defined( 'WPSP_PRO_VERSION' ) && version_compare( WPSP_PRO_VERSION, '0.6', '<' ) ) {
514
+ // Lightbox and gallery
515
+ $image_lightbox = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_image_lightbox' ) );
516
+ if ( $image_lightbox ) {
517
+ wp_enqueue_script( 'wpsp-featherlight' );
518
+ wp_enqueue_style( 'wpsp-featherlight' );
519
+
520
+ $image_gallery = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_image_gallery' ) );
521
+ if ( $image_gallery ) {
522
+ wp_enqueue_script( 'wpsp-featherlight-gallery' );
523
+ wp_enqueue_style( 'wpsp-featherlight-gallery' );
524
+ }
525
+ }
526
+ }
527
+
528
  // Restore original Post Data
529
  wp_reset_postdata();
530
  }
 
531
 
532
+ add_shortcode( 'wp_show_posts', 'wpsp_shortcode_function' );
533
  /*
534
  * Build the shortcode
535
+ *
536
  * @since 0.1
537
+ *
538
+ * @param array $atts The shortcode attributes.
539
  */
540
+ function wpsp_shortcode_function( $atts ) {
 
 
541
  $atts = shortcode_atts(
542
  array(
543
  'id' => '',
544
+ 'settings' => ''
545
  ), $atts, 'wp_show_posts'
546
  );
547
+
548
  ob_start();
549
+
550
+ if ( $atts[ 'id' ] ) {
551
+ wpsp_display( $atts[ 'id' ], $atts[ 'settings' ] );
552
+ }
553
+
554
  return ob_get_clean();
555
  }