• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_posts函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_posts函数的典型用法代码示例。如果您正苦于以下问题:PHP get_posts函数的具体用法?PHP get_posts怎么用?PHP get_posts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_posts函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: bap_ajaxP_loop

function bap_ajaxP_loop($offset = '')
{
    global $wp_query;
    $paged = get_query_var('page') ? get_query_var('page') : 1;
    $do_not_duplicate = array();
    // OFFSET SETTING
    if (!$offset == '' || !$offset == '0') {
        $argshidepost = array('numberposts' => $offset, 'post_type' => 'post', 'post_status' => 'publish');
        $hide_to_array = get_posts($argshidepost);
        // HIDE OFFSETED POSTS
        if ($hide_to_array) {
            foreach ($hide_to_array as $post) {
                $do_not_duplicate[] = $post->ID;
            }
        }
    }
    $argsmain = array('post_type' => 'post', 'post_status' => 'publish', 'paged' => $paged, 'order' => 'DESC', 'post__not_in' => $do_not_duplicate);
    $wp_query = new WP_Query($argsmain);
    if ($wp_query->have_posts()) {
        echo '<section id="' . bap_get_option_text('bap_loopContainer') . '">';
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            get_template_part('partials/listitem');
        }
        echo '</section>';
    }
    wp_reset_postdata();
}
开发者ID:Aventyret,项目名称:bentoWP_plugin_AjaxPagin,代码行数:28,代码来源:bap_functions.php


示例2: suggest_similar_questions

 /**
  * Show similar questions when asking a question.
  *
  * @since 2.0.1
  */
 public function suggest_similar_questions()
 {
     if (empty($_POST['value']) || !ap_verify_default_nonce() && !current_user_can('manage_options')) {
         wp_die('false');
     }
     $keyword = sanitize_text_field(wp_unslash($_POST['value']));
     $is_admin = (bool) $_POST['is_admin'];
     $questions = get_posts(array('post_type' => 'question', 'showposts' => 10, 's' => $keyword));
     if ($questions) {
         $items = '<div class="ap-similar-questions-head">';
         $items .= '<h3>' . ap_icon('check', true) . sprintf(__('%d similar questions found', 'anspress-question-answer'), count($questions)) . '</h3>';
         $items .= '<p>' . __('We\'ve found similar questions that have already been asked, click to read them.', 'anspress-question-answer') . '</p>';
         $items .= '</div>';
         $items .= '<div class="ap-similar-questions">';
         foreach ($questions as $p) {
             $count = ap_count_answer_meta($p->ID);
             $p->post_title = ap_highlight_words($p->post_title, $keyword);
             if ($is_admin) {
                 $items .= '<div class="ap-q-suggestion-item clearfix"><a class="select-question-button button button-primary button-small" href="' . add_query_arg(array('post_type' => 'answer', 'post_parent' => $p->ID), admin_url('post-new.php')) . '">' . __('Select', 'anspress-question-answer') . '</a><span class="question-title">' . $p->post_title . '</span><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'anspress-question-answer'), $count) . '</span></div>';
             } else {
                 $items .= '<a class="ap-sqitem clearfix" target="_blank" href="' . get_permalink($p->ID) . '"><span class="acount">' . sprintf(_n('1 Answer', '%d Answers', $count, 'anspress-question-answer'), $count) . '</span><span class="ap-title">' . $p->post_title . '</span></a>';
             }
         }
         $items .= '</div>';
         $result = array('status' => true, 'html' => $items);
     } else {
         $result = array('status' => false, 'message' => __('No related questions found', 'anspress-question-answer'));
     }
     $this->send($result);
 }
开发者ID:alaershov,项目名称:anspress,代码行数:35,代码来源:ajax.php


示例3: widget

    /**
     * Displays the output
     *
     * @param array $args
     * @param array $instance
     * @since Achievements (3.3)
     */
    public function widget($args, $instance)
    {
        $settings = $this->parse_settings($instance);
        $settings['post_id'] = absint(apply_filters('dpa_featured_achievement_post_id', $settings['post_id'], $instance, $this->id_base));
        // Get the specified achievement
        $achievement = get_posts(array('no_found_rows' => true, 'numberposts' => 1, 'p' => $settings['post_id'], 'post_status' => 'publish', 'post_type' => dpa_get_achievement_post_type(), 'suppress_filters' => false));
        // Bail if it doesn't exist
        if (empty($achievement)) {
            return;
        }
        $achievement = array_shift($achievement);
        $title = dpa_get_achievement_title($achievement->ID);
        echo $args['before_widget'];
        echo $args['before_title'] . $title . $args['after_title'];
        if (has_post_thumbnail($achievement->ID)) {
            ?>
			<a href="<?php 
            dpa_achievement_permalink($achievement->ID);
            ?>
"><?php 
            echo get_the_post_thumbnail($achievement->ID, 'thumbnail', array('alt' => $title));
            ?>
</a>
		<?php 
        }
        dpa_achievement_excerpt($settings['post_id']);
        echo $args['after_widget'];
    }
开发者ID:rlybbert,项目名称:achievements,代码行数:35,代码来源:class-dpa-featured-achievement-widget.php


示例4: oxy_filter_import_menu_item

function oxy_filter_import_menu_item($new_menu_item, $menu_item, $one_click)
{
    switch ($menu_item['type']) {
        case 'post_type':
        case 'taxonomy':
            switch ($menu_item['object']) {
                case 'oxy_mega_menu':
                    $mega_menu = get_page_by_title('Mega Menu', 'OBJECT', 'oxy_mega_menu');
                    $new_menu_item['menu-item-object-id'] = $mega_menu->ID;
                    break;
                case 'oxy_mega_columns':
                    $columns = get_posts(array('post_type' => 'oxy_mega_columns'));
                    foreach ($columns as $column) {
                        if ($column->post_content === $menu_item['post_content']) {
                            $new_menu_item['menu-item-object-id'] = $column->ID;
                        }
                    }
                    break;
                default:
                    $new_id = $one_click->lookup_map($menu_item['object'], $menu_item['object_id']);
                    if ($new_id !== false) {
                        $new_menu_item['menu-item-object-id'] = $new_id;
                    }
                    break;
            }
            break;
        case 'custom':
        default:
            // do nothing
            break;
    }
    return $new_menu_item;
}
开发者ID:rinodung,项目名称:wordpress-demo,代码行数:33,代码来源:one-click-import.php


示例5: callback

 function callback($path = '', $blog_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     //upload_files can probably be used for other endpoints but we want contributors to be able to use media too
     if (!current_user_can('edit_posts')) {
         return new WP_Error('unauthorized', 'User cannot view media', 403);
     }
     $args = $this->query_args();
     if ($args['number'] < 1) {
         $args['number'] = 20;
     } elseif (100 < $args['number']) {
         return new WP_Error('invalid_number', 'The NUMBER parameter must be less than or equal to 100.', 400);
     }
     $media = get_posts(array('post_type' => 'attachment', 'post_parent' => $args['parent_id'], 'offset' => $args['offset'], 'numberposts' => $args['number'], 'post_mime_type' => $args['mime_type']));
     $response = array();
     foreach ($media as $item) {
         $response[] = $this->get_media_item($item->ID);
     }
     $_num = (array) wp_count_attachments();
     $_total_media = array_sum($_num) - $_num['trash'];
     $return = array('found' => $_total_media, 'media' => $response);
     return $return;
 }
开发者ID:StefanBonilla,项目名称:CoupSoup,代码行数:26,代码来源:class.wpcom-json-api-list-media-endpoint.php


示例6: woo_widget_tabs_latest

    function woo_widget_tabs_latest($posts = 5, $size = 45)
    {
        global $post;
        $latest = get_posts(array('suppress_filters' => false, 'ignore_sticky_posts' => 1, 'orderby' => 'post_date', 'order' => 'desc', 'numberposts' => $posts));
        foreach ($latest as $post) {
            setup_postdata($post);
            ?>
			<li>
				<?php 
            if ($size != 0) {
                woo_image('height=' . $size . '&width=' . $size . '&class=thumbnail&single=true');
            }
            ?>
				<a title="<?php 
            the_title_attribute();
            ?>
" href="<?php 
            the_permalink();
            ?>
"><?php 
            the_title();
            ?>
</a>
				<span class="meta"><?php 
            the_time(get_option('date_format'));
            ?>
</span>
				<div class="fix"></div>
			</li>
		<?php 
        }
        wp_reset_postdata();
    }
开发者ID:shramee,项目名称:test-ppb,代码行数:33,代码来源:woo-tabs.php


示例7: property_post_list

function property_post_list()
{
    $propid_array = array();
    $args = array('numberposts' => -1, 'meta_key' => 'property_id');
    $posts_array = get_posts($args);
    if (count($posts_array) > 0) {
        foreach ($posts_array as $p) {
            //print_r($posts_array);exit();
            $propid = get_post_custom_values('property_id', $p->ID);
            if (!empty($propid)) {
                $prop_array[$p->ID] = $propid;
            }
        }
    }
    ?>
	<script>
		var prop_post_array = new Array();
	<?php 
    foreach ($prop_array as $po => $pr) {
        ?>
		prop_post_array[<?php 
        echo $pr[0];
        ?>
] = <?php 
        echo $po;
        ?>
;
		<?php 
    }
    ?>
	</script>
    <?php 
}
开发者ID:alfiedawes,项目名称:WP-InstaSites,代码行数:33,代码来源:property.php


示例8: output

    /**
     * Output the metabox
     */
    public static function output($post)
    {
        $metrics = get_post_meta($post->ID, 'sp_metrics', true);
        $args = array('post_type' => 'sp_metric', 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC');
        $vars = get_posts($args);
        if ($vars) {
            foreach ($vars as $var) {
                ?>
			<p><strong><?php 
                echo $var->post_title;
                ?>
</strong></p>
			<p><input type="text" name="sp_metrics[<?php 
                echo $var->post_name;
                ?>
]" value="<?php 
                echo esc_attr(sp_array_value($metrics, $var->post_name, ''));
                ?>
" /></p>
			<?php 
            }
        } else {
            sp_post_adder('sp_metric', __('Add New', 'sportspress'));
        }
    }
开发者ID:engrmostafijur,项目名称:SportsPress,代码行数:28,代码来源:class-sp-meta-box-player-metrics.php


示例9: ctc_get_locations

/**
 * Get locations
 *
 * This can optionally be used by the template.
 * $this->instance is sanitized before being made available here.
 *
 * @since 0.9
 * @return array Posts for widget template
 */
function ctc_get_locations($instance)
{
    // Get posts
    $posts = get_posts(array('post_type' => 'ctc_location', 'orderby' => $instance['orderby'], 'order' => $instance['order'], 'numberposts' => $instance['limit'], 'suppress_filters' => false));
    // Return filtered
    return apply_filters('ctc_locations_widget_get_posts', $posts);
}
开发者ID:faithmade,项目名称:churchthemes,代码行数:16,代码来源:locations.php


示例10: add_post_details

 private function add_post_details()
 {
     $post_ids = array();
     $posts = array();
     foreach ($this->response['comments'] as $id => $comment) {
         $post_ids[$comment['comment_post_ID']] = true;
     }
     $post_ids = array_keys($post_ids);
     if (!empty($post_ids)) {
         $posts = get_posts(array('post__in' => $post_ids));
     }
     foreach ($posts as $post) {
         $id = $post->ID;
         $post = (array) $post;
         unset($post['ID']);
         unset($post['post_content']);
         unset($post['post_excerpt']);
         unset($post['post_password']);
         unset($post['post_modified']);
         unset($post['post_modified_gmt']);
         unset($post['to_ping']);
         unset($post['pinged']);
         unset($post['post_content_filtered']);
         unset($post['menu_order']);
         unset($post['filter']);
         $this->response['posts'][$id] = $post;
     }
 }
开发者ID:jimlongo56,项目名称:rdiv,代码行数:28,代码来源:get-comment-details.php


示例11: gmb_show_upgrade_notices

/**
 * Display Upgrade Notices.
 *
 * @since 2.0
 * @return void
 */
function gmb_show_upgrade_notices()
{
    // Don't show notices on the upgrades page.
    if (isset($_GET['page']) && $_GET['page'] == 'gmb-upgrades') {
        return;
    }
    //Check to see if we have any posts.
    $gmb_posts = get_posts(array('post_type' => 'google_maps', 'posts_per_page' => 10));
    if (empty($gmb_posts)) {
        update_option('gmb_refid_upgraded', 'upgraded');
        //mark as updated.
        return;
        //Don't run if there's no posts!
    }
    $gmb_version = get_option('gmb_version');
    if (!$gmb_version) {
        // 2.0 is the first version to use this option so we must add it.
        $gmb_version = '2.0';
    }
    update_option('gmb_version', GMB_VERSION);
    $gmb_version = preg_replace('/[^0-9.].*/', '', $gmb_version);
    if (version_compare($gmb_version, '2.0', '<=') && !get_option('gmb_refid_upgraded')) {
        printf('<div class="updated"><p><strong>' . __('Maps Builder Update Required', 'google-maps-builder') . ':</strong> ' . esc_html__('Google has updated their Maps API to use the new Google Places ID rather than previous Reference ID. The old method will soon be deprecated and eventually go offline. We are being proactive and would like to update your maps to use the new Places ID. Once you upgrade, your maps should work just fine but remember to make a backup prior to upgrading. If you choose not to upgrade Google will eventually take the old reference ID offline (no date has been given). Please contact WordImpress support via our website if you have any further questions or issues. %sClick here to upgrade your maps to use the new Places ID%s', 'google-maps-builder') . '</p></div>', '<br><a href="' . esc_url(admin_url('options.php?page=gmb-upgrades')) . '" class="button button-primary" style="margin-top:10px;">', '</a>');
    } elseif (version_compare($gmb_version, '2.1', '<=') && !gmb_has_upgrade_completed('gmb_markers_upgraded')) {
        printf('<div class="updated"><p><strong>' . __('Maps Builder Update Required', 'google-maps-builder') . ':</strong> ' . esc_html__('An upgrade is required to update your Google maps with the latest plugin version. Please perform a site backup and then upgrade. %sClick here to upgrade your maps%s', 'google-maps-builder') . '</p></div>', '<br><a href="' . esc_url(admin_url('options.php?page=gmb-upgrades')) . '" class="button button-primary" style="margin-top:10px;">', '</a>');
    }
}
开发者ID:WordImpress,项目名称:maps-builder-core,代码行数:33,代码来源:upgrade-functions.php


示例12: legacy_upgrade

    /**
     * Performs a legacy upgrade for sliders from v1 to v2.
     *
     * @since 1.0.0
     */
    public function legacy_upgrade()
    {
        // If the option exists for upgrading, do nothing.
        $upgrade = get_option('soliloquy_upgrade');
        if ($upgrade) {
            return;
        }
        // If the option exists for already checking for sliders from previous versions, bail.
        $has_sliders = get_option('soliloquy_lite_upgrade');
        if ($has_sliders) {
            return;
        }
        // If we have no sliders, only run this check once. Set option to prevent again.
        $sliders = get_posts(array('post_type' => 'soliloquy', 'posts_per_page' => -1));
        if (!$sliders) {
            update_option('soliloquy_lite_upgrade', true);
            return;
        }
        ?>
        <div class="error">
            <p><?php 
        printf(__('Soliloquy Lite is now rocking v2! <strong>You need to upgrade your legacy v1 sliders to v2.</strong> <a href="%s">Click here to begin the upgrade process.</a>', 'soliloquy'), add_query_arg('page', 'soliloquy-lite-settings', admin_url('edit.php?post_type=soliloquy')));
        ?>
</p>
        </div>
        <?php 
    }
开发者ID:javed2015,项目名称:WindowsDefender,代码行数:32,代码来源:common.php


示例13: sys_recent_posts

function sys_recent_posts($atts, $content = null)
{
    extract(shortcode_atts(array('limit' => '2', 'description' => '40', 'cat_id' => '23', 'thumb' => 'true', 'postdate' => ''), $atts));
    $out = '<div class="widget_postslist sc">';
    $out .= '<ul>';
    global $wpdb;
    $myposts = get_posts("numberposts={$limit}&offset=0&cat={$cat_id}");
    foreach ($myposts as $post) {
        $post_date = $post->post_date;
        $post_date = mysql2date('F j, Y', $post_date, false);
        $out .= "<li>";
        if ($thumb == "true") {
            $thumbid = get_post_thumbnail_id($post->ID);
            $imgsrc = wp_get_attachment_image_src($thumbid, array(9999, 9999));
            $out .= '<div class="thumb"><a href="' . get_permalink($post->ID) . '" title="' . $post->post_title . '">';
            if ($thumbid) {
                $out .= atp_resize('', $imgsrc['0'], '50', '50', 'imgborder', '');
            } else {
                //$out .= '<img class="imgborder" src="'.THEME_URI.'/images/no-image.jpg'.'"  alt="' .$post->post_title. '" />';
            }
            $out .= '</a></div>';
        }
        $out .= '<div class="pdesc"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . $post->post_title . '</a>';
        if ($postdate == "true") {
            $out .= '<div class="w-postmeta"><span>' . $post_date . '</span></div>';
        } else {
            $out .= '<p>' . wp_html_excerpt($post->post_content, $description, '...') . '</p>';
        }
        $out .= '</div></li>';
    }
    $out .= '</ul></div>';
    return $out;
    wp_reset_query();
}
开发者ID:pryspry,项目名称:MusicPlay,代码行数:34,代码来源:recentposts.php


示例14: get_years

function get_years()
{
    global $wpdb;
    $yearliest_year = $wpdb->get_results("SELECT YEAR(post_date) AS year\n         FROM {$wpdb->posts}\n         WHERE post_status = 'publish'\n         AND post_type = 'post'\n         ORDER BY post_date\n         DESC LIMIT 1\n\n    ");
    //If there are any posts
    if ($yearliest_year) {
        $this_year = date('Y');
        $months = array(1 => "January", 2 => "February", 3 => "March", 4 => "April", 5 => "May", 6 => "June", 7 => "July", 8 => "August", 9 => "September", 10 => "October", 11 => "November", 12 => "December");
        $current_year = $yearliest_year[0]->year;
        while ($current_year > $this_year - 2) {
            echo "<div class='fullDiv'><h3 class='year'><a href='/" . $current_year . "'>" . $current_year . "</a></h3>";
            //                echo "<h3><a href='". $current_year ."'> " . $current_year . " </a></h3>";
            echo "<ul class='month_container'>";
            foreach ($months as $month_num => $month) {
                if ($search_month = $wpdb->query("SELECT MONTHNAME(post_date) as month\n\n                            FROM {$wpdb->posts}\n                            WHERE MONTHNAME(post_date) = '{$month}'\n                            AND YEAR(post_date) = {$current_year}\n                            AND post_type = 'post'\n                            AND post_status = 'publish'\n                            LIMIT 1\n\n                ")) {
                    $countposts = get_posts("year={$current_year}&monthnum={$month_num}");
                    echo "<li class='month'><i class='s'>></i><a href='" . get_bloginfo('url') . "/" . $current_year . "/" . $month_num . "/'><span class='archive-month'>" . $month . "</span><span>" . count($countposts) . "</span></a></li>";
                } else {
                }
            }
            echo "</ul></div>";
            $current_year--;
        }
    } else {
        echo "No Posts Found.";
    }
}
开发者ID:Erazik,项目名称:moustafahamwi,代码行数:27,代码来源:functions.php


示例15: fruitframe_get_attachments

function fruitframe_get_attachments($id = NULL, $excludeIds = array())
{
    if (!$id) {
        $id = get_the_ID();
    }
    return get_posts(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'numberposts' => -1, 'orderby' => 'menu_order', 'post__not_in' => $excludeIds));
}
开发者ID:slavic18,项目名称:cats,代码行数:7,代码来源:images.php


示例16: thesis_nav_array

function thesis_nav_array($id, $nav_items, $current = false)
{
    $raw_children = get_posts('numberposts=-1&post_type=page&post_parent=' . $id);
    #wp
    foreach ($raw_children as $child) {
        if (in_array($child->ID, $nav_items)) {
            $possible_children[] = $child->ID;
        }
    }
    // This conditional construct exists solely to sort the submenu items according to the user's input
    if ($possible_children) {
        foreach ($nav_items as $nav_item) {
            if (in_array($nav_item, $possible_children)) {
                $children[] = thesis_nav_array($nav_item, $nav_items, $current);
            }
        }
    }
    $item['id'] = $id;
    $item['children'] = $children ? $children : '';
    $item['current'] = $item['id'] == $current['id'] ? true : false;
    if (is_array($current['ancestors'])) {
        $item['ancestor'] = in_array($id, $current['ancestors']) ? true : false;
    } else {
        $item['ancestor'] = false;
    }
    return $item;
}
开发者ID:JGrubb,项目名称:Almond-Tree,代码行数:27,代码来源:nav_menu.php


示例17: delete_cpts

 public function delete_cpts($delete_posts, $force_delete)
 {
     $args = array('numberposts' => -1, 'post_type' => 'trail-route', 'post_status' => 'any');
     $posts = get_posts($args);
     if (is_array($posts)) {
         foreach ($posts as $post) {
             wp_delete_post($post->ID, $force_delete);
             echo "Deleted Post: " . $post->title . "\r\n";
         }
     }
     $args = array('numberposts' => -1, 'post_type' => 'trail-story', 'post_status' => 'any');
     $posts = get_posts($args);
     if (is_array($posts)) {
         foreach ($posts as $post) {
             wp_delete_post($post->ID, $force_delete);
             echo "Deleted Post: " . $post->title . "\r\n";
         }
     }
     $args = array('numberposts' => -1, 'post_type' => 'trail-condition', 'post_status' => 'any');
     $posts = get_posts($args);
     if (is_array($posts)) {
         foreach ($posts as $post) {
             wp_delete_post($post->ID, $force_delete);
             echo "Deleted Post: " . $post->title . "\r\n";
         }
     }
     $args = array('numberposts' => -1, 'post_type' => 'itinerary', 'post_status' => 'any');
     $posts = get_posts($args);
     if (is_array($posts)) {
         foreach ($posts as $post) {
             wp_delete_post($post->ID, $force_delete);
             echo "Deleted Post: " . $post->title . "\r\n";
         }
     }
 }
开发者ID:amgxyz,项目名称:interactive-geo-trail-map,代码行数:35,代码来源:uninstall.php


示例18: forms_dropdown

 /**
  * Renders an HTML Dropdown of all the Give Forms
  *
  * @access public
  * @since  1.0
  *
  * @param array $args Arguments for the dropdown
  *
  * @return string $output Give forms dropdown
  */
 public function forms_dropdown($args = array())
 {
     $defaults = array('name' => 'forms', 'id' => 'forms', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'number' => 30, 'placeholder' => sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()));
     $args = wp_parse_args($args, $defaults);
     $forms = get_posts(array('post_type' => 'give_forms', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => $args['number']));
     $options = array();
     if ($forms) {
         $options[0] = sprintf(__('Select a %s', 'give'), give_get_forms_label_singular());
         foreach ($forms as $form) {
             $options[absint($form->ID)] = esc_html($form->post_title);
         }
     } else {
         $options[0] = __('No Give Forms Found', 'give');
     }
     // This ensures that any selected forms are included in the drop down
     if (is_array($args['selected'])) {
         foreach ($args['selected'] as $item) {
             if (!in_array($item, $options)) {
                 $options[$item] = get_the_title($item);
             }
         }
     } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
         if (!in_array($args['selected'], $options)) {
             $options[$args['selected']] = get_the_title($args['selected']);
         }
     }
     $output = $this->select(array('name' => $args['name'], 'selected' => $args['selected'], 'id' => $args['id'], 'class' => $args['class'], 'options' => $options, 'chosen' => $args['chosen'], 'multiple' => $args['multiple'], 'placeholder' => $args['placeholder'], 'show_option_all' => false, 'show_option_none' => false));
     return $output;
 }
开发者ID:duongnguyen92,项目名称:tvd12v2,代码行数:39,代码来源:class-give-html-elements.php


示例19: mc4wp_pro_install

/**
 * Runs on plugin activations
 * - Transfer any settings which may have been set in the Lite version of the plugin
 * - Creates a post type 'mc4wp-form' and enters the form mark-up from the Lite version
 */
function mc4wp_pro_install()
{
    // check if PRO option exists and contains data entered by user
    $pro_options = get_option('mc4wp', false);
    if ($pro_options !== false) {
        return false;
    }
    $default_options = array();
    $default_options['general'] = array('api_key' => '', 'license_key' => '');
    $default_options['checkbox'] = array('label' => 'Sign me up for the newsletter!', 'precheck' => 1, 'css' => 0, 'show_at_comment_form' => 0, 'show_at_registration_form' => 0, 'show_at_multisite_form' => 0, 'show_at_buddypress_form' => 0, 'show_at_edd_checkout' => 0, 'show_at_woocommerce_checkout' => 0, 'show_at_bbpress_forms' => 0, 'lists' => array(), 'double_optin' => 1, 'send_welcome' => 0);
    $default_options['form'] = array('css' => 0, 'custom_theme_color' => '#1af', 'ajax' => 1, 'double_optin' => 1, 'update_existing' => 0, 'replace_interests' => 1, 'send_welcome' => 0, 'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.', 'text_error' => 'Oops. Something went wrong. Please try again later.', 'text_invalid_email' => 'Please provide a valid email address.', 'text_already_subscribed' => 'Given email address is already subscribed, thank you!', 'redirect' => '', 'hide_after_success' => 0, 'send_email_copy' => 0);
    $lite_settings = array('general' => (array) get_option('mc4wp_lite'), 'checkbox' => (array) get_option('mc4wp_lite_checkbox'), 'form' => (array) get_option('mc4wp_lite_form'));
    foreach ($default_options as $group_key => $options) {
        foreach ($options as $option_key => $option_value) {
            if (isset($lite_settings[$group_key][$option_key]) && !empty($lite_settings[$group_key][$option_key])) {
                $default_options[$group_key][$option_key] = $lite_settings[$group_key][$option_key];
            }
        }
    }
    // Transfer form from Lite, but only if no Pro forms exist yet.
    $forms = get_posts(array('post_type' => 'mc4wp-form', 'post_status' => 'publish'));
    if (false == $forms) {
        // no forms found, try to transfer from lite.
        $form_markup = isset($lite_settings['form']['markup']) ? $lite_settings['form']['markup'] : "<p>\n\t<label for=\"mc4wp_email\">Email address: </label>\n\t<input type=\"email\" id=\"mc4wp_email\" name=\"EMAIL\" required placeholder=\"Your email address\" />\n</p>\n\n<p>\n\t<input type=\"submit\" value=\"Sign up\" />\n</p>";
        $form_ID = wp_insert_post(array('post_type' => 'mc4wp-form', 'post_title' => 'Sign-Up Form #1', 'post_content' => $form_markup, 'post_status' => 'publish'));
        $lists = isset($lite_settings['form']['lists']) ? $lite_settings['form']['lists'] : array();
        update_post_meta($form_ID, '_mc4wp_settings', array('lists' => $lists));
        update_option('mc4wp_default_form_id', $form_ID);
    }
    // store options
    update_option('mc4wp', $default_options['general']);
    update_option('mc4wp_checkbox', $default_options['checkbox']);
    update_option('mc4wp_form', $default_options['form']);
}
开发者ID:Infernosaint,项目名称:WPSetupTest2,代码行数:39,代码来源:install.php


示例20: get_pages

 public function get_pages($pages, $args)
 {
     $language = empty($args['lang']) ? $this->curlang : $this->model->get_language($args['lang']);
     if (empty($language) || empty($pages) || !$this->model->is_translated_post_type($args['post_type'])) {
         return $pages;
     }
     static $once = false;
     // obliged to redo the get_pages query if we want to get the right number
     if (!empty($args['number']) && !$once) {
         $once = true;
         // avoid infinite loop
         $r = array('lang' => 0, 'numberposts' => -1, 'nopaging' => true, 'post_type' => $args['post_type'], 'fields' => 'ids', 'tax_query' => array(array('taxonomy' => 'language', 'field' => 'term_taxonomy_id', 'terms' => $language->term_taxonomy_id, 'operator' => 'NOT IN')));
         $args['exclude'] = array_merge($args['exclude'], get_posts($r));
         $pages = get_pages($args);
     }
     $ids = wp_list_pluck($pages, 'ID');
     // filters the queried list of pages by language
     if (!$once) {
         $ids = array_intersect($ids, $this->model->get_objects_in_language($language));
         foreach ($pages as $key => $page) {
             if (!in_array($page->ID, $ids)) {
                 unset($pages[$key]);
             }
         }
     }
     // not done by WP but extremely useful for performance when manipulating taxonomies
     update_object_term_cache($ids, $args['post_type']);
     $once = false;
     // in case get_pages is called another time
     return $pages;
 }
开发者ID:WordPressArt,项目名称:conisia,代码行数:31,代码来源:filters.php



注:本文中的get_posts函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_posts_by_author_sql函数代码示例发布时间:2022-05-15
下一篇:
PHP get_postdata函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap