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