premium-addons-for-elementor
Last commit date
admin
8 years ago
assets
8 years ago
includes
8 years ago
widgets
8 years ago
elementor-helper.php
8 years ago
index.php
8 years ago
premium-addons.php
8 years ago
queries.php
8 years ago
readme.txt
8 years ago
wp-updates-plugin.php
8 years ago
queries.php
60 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | function premium_blog_get_post_data($args, $paged, $new_offset){ |
| 5 | $defaults = array( |
| 6 | 'category' => '', |
| 7 | 'posts_per_page' => 1, |
| 8 | 'paged' => $paged, |
| 9 | 'offset' => $new_offset, |
| 10 | ); |
| 11 | |
| 12 | $atts = wp_parse_args($args,$defaults); |
| 13 | |
| 14 | $posts = get_posts($atts); |
| 15 | |
| 16 | return $posts; |
| 17 | } |
| 18 | |
| 19 | function premium_blog_get_post_settings($settings){ |
| 20 | $post_args['category'] = $settings['premium_blog_categories']; |
| 21 | $post_args['posts_per_page'] = $settings['premium_blog_number_of_posts']; |
| 22 | |
| 23 | return $post_args; |
| 24 | } |
| 25 | |
| 26 | function premium_addons_get_excerpt_by_id($post_id,$excerpt_length){ |
| 27 | $the_post = get_post($post_id); //Gets post ID |
| 28 | |
| 29 | $the_excerpt = null; |
| 30 | if ($the_post) |
| 31 | { |
| 32 | $the_excerpt = $the_post->post_excerpt ? $the_post->post_excerpt : $the_post->post_content; |
| 33 | } |
| 34 | |
| 35 | $the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); //Strips tags and images |
| 36 | $words = explode(' ', $the_excerpt, $excerpt_length + 1); |
| 37 | |
| 38 | if(count($words) > $excerpt_length) : |
| 39 | array_pop($words); |
| 40 | array_push($words, '…'); |
| 41 | $the_excerpt = implode(' ', $words); |
| 42 | endif; |
| 43 | |
| 44 | return $the_excerpt; |
| 45 | } |
| 46 | |
| 47 | function premium_addons_post_type_categories(){ |
| 48 | $terms = get_terms( array( |
| 49 | 'taxonomy' => 'category', |
| 50 | 'hide_empty' => true, |
| 51 | )); |
| 52 | |
| 53 | if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ |
| 54 | foreach ( $terms as $term ) { |
| 55 | $options[ $term->term_id ] = $term->name; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | return $options; |
| 60 | } |