| @@ -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,18 +27,30 @@ | ||
| 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 ) { |
| 43 | 51 | $exclude_tag_string .= '<' . $value . '>,'; |
| 44 | - } | |
| 52 | + }; | |
| 45 | 53 | return $exclude_tag_string; |
| 46 | 54 | } |
| 47 | 55 | |
| 48 | 56 | /** |
| @@ -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,11 +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 ); | |
| 107 | - $image_src = is_array( $image_src ) ? $image_src : array( '', '', '' ); | |
| 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 ); | |
| 108 | 114 | $image = $image_src[0]; |
| 109 | 115 | $image_width = $image_src[1]; |
| 110 | 116 | $image_height = $image_src[2]; |
| 111 | 117 | } elseif ( ! empty( $placeholder_img ) ) { |
| @@ -130,10 +136,10 @@ | ||
| 130 | 136 | */ |
| 131 | 137 | public static function pcp_get_post_meta( $post_meta_fields, $meta_separator ) { |
| 132 | 138 | $i = 0; |
| 133 | 139 | foreach ( $post_meta_fields as $each_meta ) { |
| 134 | - $selected_meta = $each_meta['select_post_meta']; | |
| 135 | - $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>' ) : ''; | |
| 136 | 142 | $meta_tag_start = apply_filters( 'pcp_post_meta_html_tag_start', '<li>' ); |
| 137 | 143 | $meta_tag_end = apply_filters( 'pcp_post_meta_html_tag_end', '</li>' ); |
| 138 | 144 | |
| 139 | 145 | switch ( $selected_meta ) { |
| @@ -138,41 +144,41 @@ | ||
| 138 | 144 | |
| 139 | 145 | switch ( $selected_meta ) { |
| 140 | 146 | case 'author': |
| 141 | 147 | if ( 0 < $i ) { |
| 142 | - echo esc_html( $meta_separator ); | |
| 148 | + echo $meta_separator; | |
| 143 | 149 | } |
| 144 | - echo wp_kses_post( $meta_tag_start ); | |
| 150 | + echo $meta_tag_start; | |
| 145 | 151 | ?> |
| 146 | 152 | <i class="fa fa-user"></i> |
| 147 | - <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" | |
| 148 | - 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> | |
| 149 | 155 | <?php |
| 150 | - echo wp_kses_post( $meta_tag_end ); | |
| 156 | + echo $meta_tag_end; | |
| 151 | 157 | break; |
| 152 | 158 | case 'date': |
| 153 | 159 | if ( 0 < $i ) { |
| 154 | - echo esc_html( $meta_separator ); | |
| 160 | + echo $meta_separator; | |
| 155 | 161 | } |
| 156 | - echo wp_kses_post( $meta_tag_start ); | |
| 162 | + echo $meta_tag_start; | |
| 157 | 163 | ?> |
| 158 | 164 | <i class="fa fa-calendar"></i> |
| 159 | 165 | |
| 160 | 166 | <time class="entry-date published updated"><?php echo esc_html( get_the_date() ); ?></time> |
| 161 | 167 | <?php |
| 162 | - echo wp_kses_post( $meta_tag_end ); | |
| 168 | + echo $meta_tag_end; | |
| 163 | 169 | break; |
| 164 | 170 | case 'comment_count': |
| 165 | 171 | if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { |
| 166 | 172 | if ( 0 < $i ) { |
| 167 | - echo esc_html( $meta_separator ); | |
| 173 | + echo $meta_separator; | |
| 168 | 174 | } |
| 169 | - echo wp_kses_post( $meta_tag_start ); | |
| 175 | + echo $meta_tag_start; | |
| 170 | 176 | ?> |
| 171 | 177 | <i class="fa fa-comments-o"></i> |
| 172 | 178 | <a href="<?php the_permalink(); ?>"><?php echo esc_html( get_comments_number() ); ?></a> |
| 173 | 179 | <?php |
| 174 | - echo wp_kses_post( $meta_tag_end ); | |
| 180 | + echo $meta_tag_end; | |
| 175 | 181 | } |
| 176 | 182 | break; |
| 177 | 183 | } |
| 178 | 184 | ++$i; |
| @@ -204,9 +210,9 @@ | ||
| 204 | 210 | * |
| 205 | 211 | * @return int |
| 206 | 212 | */ |
| 207 | 213 | public static function pcp_post_per_page( $limit, $post_per_page, $page ) { |
| 208 | - $limit = ( empty( $limit ) || '-1' === $limit ) ? 1000000 : $limit; | |
| 214 | + $limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : $limit; | |
| 209 | 215 | $offset = (int) $post_per_page * ( $page - 1 ); |
| 210 | 216 | $final_post_per_page = $post_per_page; |
| 211 | 217 | if ( intval( $post_per_page ) > $limit - $offset ) { |
| 212 | 218 | $final_post_per_page = $limit - $offset; |
| @@ -216,16 +222,16 @@ | ||
| 216 | 222 | |
| 217 | 223 | /** |
| 218 | 224 | * Pagination last page post |
| 219 | 225 | * |
| 220 | - * @param int $limit total post limit. | |
| 221 | - * @param int $post_per_page post per page. | |
| 222 | - * @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. | |
| 223 | 229 | * |
| 224 | 230 | * @return int. |
| 225 | 231 | */ |
| 226 | 232 | public static function pcp_last_page_post( $limit, $post_per_page, $total_page ) { |
| 227 | - $limit = ( empty( $limit ) || '-1' === $limit ) ? 10000000 : $limit; | |
| 233 | + $limit = ( empty( $limit ) || $limit === '-1' ) ? 10000000 : $limit; | |
| 228 | 234 | $offset = $post_per_page * ( $total_page - 1 ); |
| 229 | 235 | $pcp_last_page_post = $limit - $offset; |
| 230 | 236 | return $pcp_last_page_post; |
| 231 | 237 | } |