public static function select_post($args = array()) { $name = self::get_name($args); $value = isset($args['value']) ? trim($args['value']) : ''; $field_class = isset($args['field_class']) ? trim($args['field_class']) : ''; $label = isset($args['label']) ? $args['label'] : ''; $post_type = isset($args['post_type']) ? $args['post_type'] : 'post'; $query_args = array('post_type' => $post_type, 'posts_per_page' => -1); global $post; $tmp = $post; $query = SB_Query::get($query_args); if ($query->have_posts()) { ?> <p> <label for="<?php echo esc_attr($name); ?> "><?php echo $label; ?> :</label> <select class="<?php echo $field_class; ?> " id="<?php echo esc_attr($name); ?> " name="<?php echo esc_attr($name); ?> " autocomplete="off"> <option value="0" <?php selected(0, get_the_ID()); ?> >--<?php _e('Choose', 'sb-core'); ?> <?php echo SB_PHP::uppercase_first_char($post_type); ?> --</option> <?php while ($query->have_posts()) { $query->the_post(); ?> <option value="<?php the_ID(); ?> " <?php selected($value, get_the_ID()); ?> ><?php the_title(); ?> </option> <?php } wp_reset_postdata(); ?> </select> </p> <?php } $post = $tmp; }
public static function get_post_by_term($term_id, $taxonomy, $args = array()) { $tax_item = array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => $term_id); $args = SB_Query::build_tax_query($tax_item, $args); return self::get($args); }
public static function get_all($post_type = 'post') { $args = array('post_type' => $post_type, 'posts_per_page' => -1); return SB_Query::get($args); }
public static function is_support_post_likes() { global $wpdb; $query = $wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s", 'likes'); $likes = SB_Query::get_results($query); if (count($likes) > 0) { return true; } return false; }