PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.2.10
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.2.10
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
← All changes | public/helpers/class-post-functions.php +38 -31 2.4.11 → 2.2.10 View file →
@@ -15,12 +15,8 @@
15 15 */
16 16 class SP_PC_Functions {
17 17 /**
18 18 * WP Version compare
19 - *
20 - * @param int $version_to_compare The WP version.
21 - * @param string $operator Compare operator.
22 - * @return mixed
23 19 */
24 20 public static function wp_version_compare( $version_to_compare, $operator = '>=' ) {
25 21 if ( empty( $version_to_compare ) ) {
26 22 return true;
@@ -31,12 +27,24 @@
31 27 return version_compare( $wp_version, $version_to_compare, $operator );
32 28 }
33 29
34 30 /**
31 + * Post title character limit.
32 + *
33 + * @param string $pcp_title The post title.
34 + * @param integer $limit_length The length for the title.
35 + * @param string $pcp_after_string The string after title.
36 + * @return statement
37 + */
38 + // public static function limit_post_title( $pcp_title, $limit_length, $pcp_after_string = '...' ) {
39 + // return mb_strimwidth( $pcp_title, 0, $limit_length, apply_filters( 'pcp_post_title_ellipsis', $pcp_after_string ) );
40 + // }
41 +
42 + /**
35 43 * Tag name to full tag conversion.
36 44 *
37 - * @param array $meta_tag Tag option.
38 - * @return string
45 + * @param string $meta_tag Tag option.
46 + * @return return
39 47 */
40 48 public static function short_tag_to_html( $meta_tag ) {
41 49 $exclude_tag_string = '';
42 50 foreach ( $meta_tag as $key => $value ) {
@@ -52,19 +60,18 @@
52 60 * @param string $type Content type.
53 61 * @return return
54 62 */
55 63 public static function pcp_content( $view_options, $type ) {
56 - global $wp_embed;
64 + // $post_content_length = isset( $view_options['pcp_content_limit'] ) ? $view_options['pcp_content_limit'] : '';
57 65 $post_content_ellipsis = isset( $view_options['post_content_ellipsis'] ) ? $view_options['post_content_ellipsis'] : '';
58 66 $pcp_strip_tags = isset( $view_options['pcp_strip_tags'] ) ? $view_options['pcp_strip_tags'] : '';
59 67 $pcp_allow_tag_name = isset( $view_options['pcp_allow_tag_name'] ) ? $view_options['pcp_allow_tag_name'] : '';
60 68 $allowed_tags = explode( ',', $pcp_allow_tag_name );
61 - if ( 'full_content' === $type ) {
69 + if ( 'excerpt' === $type ) {
70 + $pcp_post_content = get_the_excerpt();
71 + } elseif ( 'full_content' === $type ) {
62 72 $pcp_post_content = get_the_content();
63 - } else {
64 - $pcp_post_content = get_the_excerpt();
65 73 }
66 - $pcp_post_content = do_shortcode( $wp_embed->autoembed( wpautop( trim( $pcp_post_content ) ) ) );
67 74 return $pcp_post_content;
68 75 }
69 76
70 77 /**
@@ -101,10 +108,10 @@
101 108 $thumb_id = attachment_url_to_postid( $placeholder_img );
102 109 }
103 110
104 111 if ( ! empty( $thumb_id ) ) {
105 - $image_sizes = isset( $post_thumb_setting['pcp_thumb_sizes'] ) ? $post_thumb_setting['pcp_thumb_sizes'] : '';
106 - $image_src = wp_get_attachment_image_src( $thumb_id, $image_sizes );
112 + $image_sizes = isset( $post_thumb_setting['pcp_thumb_sizes'] ) ? $post_thumb_setting['pcp_thumb_sizes'] : '';
113 + $image_src = wp_get_attachment_image_src( $thumb_id, $image_sizes );
107 114 $image = $image_src[0];
108 115 $image_width = $image_src[1];
109 116 $image_height = $image_src[2];
110 117 } elseif ( ! empty( $placeholder_img ) ) {
@@ -129,10 +136,10 @@
129 136 */
130 137 public static function pcp_get_post_meta( $post_meta_fields, $meta_separator ) {
131 138 $i = 0;
132 139 foreach ( $post_meta_fields as $each_meta ) {
133 - $selected_meta = $each_meta['select_post_meta'];
134 - $meta_icon = ! empty( $each_meta['select_meta_icon'] ) ? sprintf( '<i class="' . $each_meta['select_meta_icon'] . '"></i>' ) : '';
140 + $selected_meta = $each_meta['select_post_meta'];
141 + $meta_icon = ! empty( $each_meta['select_meta_icon'] ) ? sprintf( '<i class="' . $each_meta['select_meta_icon'] . '"></i>' ) : '';
135 142 $meta_tag_start = apply_filters( 'pcp_post_meta_html_tag_start', '<li>' );
136 143 $meta_tag_end = apply_filters( 'pcp_post_meta_html_tag_end', '</li>' );
137 144
138 145 switch ( $selected_meta ) {
@@ -137,41 +144,41 @@
137 144
138 145 switch ( $selected_meta ) {
139 146 case 'author':
140 147 if ( 0 < $i ) {
141 - echo esc_html( $meta_separator );
148 + echo $meta_separator;
142 149 }
143 - echo wp_kses_post( $meta_tag_start );
150 + echo $meta_tag_start;
144 151 ?>
145 152 <i class="fa fa-user"></i>
146 - <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"
147 - rel="author"><?php echo esc_html( get_the_author() ); ?></a>
153 +<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"
154 + rel="author"><?php echo esc_html( get_the_author() ); ?></a>
148 155 <?php
149 - echo wp_kses_post( $meta_tag_end );
156 + echo $meta_tag_end;
150 157 break;
151 158 case 'date':
152 159 if ( 0 < $i ) {
153 - echo esc_html( $meta_separator );
160 + echo $meta_separator;
154 161 }
155 - echo wp_kses_post( $meta_tag_start );
162 + echo $meta_tag_start;
156 163 ?>
157 164 <i class="fa fa-calendar"></i>
158 165
159 166 <time class="entry-date published updated"><?php echo esc_html( get_the_date() ); ?></time>
160 167 <?php
161 - echo wp_kses_post( $meta_tag_end );
168 + echo $meta_tag_end;
162 169 break;
163 170 case 'comment_count':
164 171 if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
165 172 if ( 0 < $i ) {
166 - echo esc_html( $meta_separator );
173 + echo $meta_separator;
167 174 }
168 - echo wp_kses_post( $meta_tag_start );
175 + echo $meta_tag_start;
169 176 ?>
170 177 <i class="fa fa-comments-o"></i>
171 178 <a href="<?php the_permalink(); ?>"><?php echo esc_html( get_comments_number() ); ?></a>
172 179 <?php
173 - echo wp_kses_post( $meta_tag_end );
180 + echo $meta_tag_end;
174 181 }
175 182 break;
176 183 }
177 184 ++$i;
@@ -203,9 +210,9 @@
203 210 *
204 211 * @return int
205 212 */
206 213 public static function pcp_post_per_page( $limit, $post_per_page, $page ) {
207 - $limit = ( empty( $limit ) || '-1' === $limit ) ? 1000000 : $limit;
214 + $limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : $limit;
208 215 $offset = (int) $post_per_page * ( $page - 1 );
209 216 $final_post_per_page = $post_per_page;
210 217 if ( intval( $post_per_page ) > $limit - $offset ) {
211 218 $final_post_per_page = $limit - $offset;
@@ -215,16 +222,16 @@
215 222
216 223 /**
217 224 * Pagination last page post
218 225 *
219 - * @param int $limit total post limit.
220 - * @param int $post_per_page post per page.
221 - * @param int $total_page last post page.
226 + * @param [type] $limit total post limit.
227 + * @param [type] $post_per_page post per page.
228 + * @param [type] $total_page last post page.
222 229 *
223 230 * @return int.
224 231 */
225 232 public static function pcp_last_page_post( $limit, $post_per_page, $total_page ) {
226 - $limit = ( empty( $limit ) || '-1' === $limit ) ? 10000000 : $limit;
233 + $limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : $limit;
227 234 $offset = $post_per_page * ( $total_page - 1 );
228 235 $pcp_last_page_post = $limit - $offset;
229 236 return $pcp_last_page_post;
230 237 }