コード例 #1
1
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();
}
コード例 #2
0
ファイル: ajax.php プロジェクト: alaershov/anspress
 /**
  * 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);
 }
コード例 #3
0
    /**
     * 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'];
    }
コード例 #4
0
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;
}
 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;
 }
コード例 #6
0
ファイル: woo-tabs.php プロジェクト: shramee/test-ppb
    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();
    }
コード例 #7
0
ファイル: property.php プロジェクト: alfiedawes/WP-InstaSites
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 
}
コード例 #8
0
    /**
     * 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'));
        }
    }
コード例 #9
0
ファイル: locations.php プロジェクト: faithmade/churchthemes
/**
 * 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);
}
コード例 #10
0
 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;
     }
 }
コード例 #11
0
/**
 * 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>');
    }
}
コード例 #12
0
ファイル: common.php プロジェクト: javed2015/WindowsDefender
    /**
     * 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 
    }
コード例 #13
0
ファイル: recentposts.php プロジェクト: pryspry/MusicPlay
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();
}
コード例 #14
0
ファイル: functions.php プロジェクト: Erazik/moustafahamwi
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.";
    }
}
コード例 #15
0
ファイル: images.php プロジェクト: slavic18/cats
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));
}
コード例 #16
0
ファイル: nav_menu.php プロジェクト: JGrubb/Almond-Tree
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;
}
コード例 #17
0
 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";
         }
     }
 }
コード例 #18
0
 /**
  * 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;
 }
コード例 #19
0
ファイル: install.php プロジェクト: Infernosaint/WPSetupTest2
/**
 * 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']);
}
コード例 #20
0
ファイル: filters.php プロジェクト: WordPressArt/conisia
 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;
 }
 private function get_class_list()
 {
     global $wpdb;
     $classes = array();
     $columns = array();
     if ($categories = isset($_POST['pd-categories']) ? (array) $_POST['pd-categories'] : false) {
         $posts = get_posts(array('post_type' => 'product', 'numberposts' => -1, 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $categories))));
         if ($posts) {
             $columns = array('Class', 'Students');
             foreach ($posts as $post) {
                 $orders = $wpdb->get_results("\n\t\t\t\t\t\tSELECT order_id FROM {$wpdb->prefix}woocommerce_order_items WHERE order_item_id in (SELECT order_item_id FROM {$wpdb->prefix}woocommerce_order_itemmeta WHERE meta_key='_product_id' and meta_value={$post->ID})\n\t\t\t\t\t\t");
                 $students = array();
                 if ($orders) {
                     foreach ($orders as $order) {
                         if ($order = new WC_Order($order->order_id)) {
                             if ($customer_ID = get_post_meta($order->id, '_customer_user', true)) {
                                 $user = new WP_User($customer_ID);
                                 $students[$customer_ID] = $user->display_name;
                             }
                         }
                     }
                 }
                 $classes[] = array($post->post_title, implode(',', $students));
             }
         }
     }
     return array('columns' => $columns, 'rows' => $classes);
 }
コード例 #22
0
 function form($instance)
 {
     $defaults = array('title' => '', 'venue_ID' => null, 'count' => 3, 'hide_if_empty' => true);
     $venues = get_posts(array('post_type' => TribeEvents::VENUE_POST_TYPE, 'orderby' => 'title', 'nopaging' => true));
     $instance = wp_parse_args((array) $instance, $defaults);
     include TribeEventsPro::instance()->pluginPath . 'admin-views/widget-admin-venue.php';
 }
コード例 #23
0
 /**
  * Displaying Prodcuts
  *
  * Does prepare the data for displaying the products in the table.
  */
 function display_seller_review()
 {
     $data = array();
     $prefix = FARMTOYOU_META_PREFIX;
     //if search is call then pass searching value to function for displaying searching values
     $args = array('post_type' => FARMTOYOU_SELLER_REVIEW_POST_TYPE, 'post_status' => 'any', 'posts_per_page' => '-1');
     //get seller_review data from database
     $all_seller_review = get_posts($args);
     foreach ($all_seller_review as $key => $value) {
         $seller_id = get_post_meta($value->ID, $prefix . 'seller_id', true);
         $store_info = dokan_get_store_info($seller_id);
         $store_name = isset($store_info['store_name']) ? esc_html($store_info['store_name']) : __('N/A', 'dokan');
         $curr_user_id = get_post_meta($value->ID, $prefix . 'current_user_id', true);
         $user_info = get_userdata($curr_user_id);
         $first_name = $user_info->first_name;
         $last_name = $user_info->last_name;
         $user_email = $user_info->user_email;
         $data[$key]['ID'] = isset($value->ID) ? $value->ID : '';
         $data[$key]['seller_store'] = $store_name;
         $data[$key]['curr_user_name'] = $first_name . " " . $last_name;
         $data[$key]['curr_user_email'] = $user_email;
         $data[$key]['user_rating'] = get_post_meta($value->ID, $prefix . 'seller_rating', true);
         $data[$key]['user_comment'] = get_post_meta($value->ID, $prefix . 'user_comment', true);
         $data[$key]['post_status'] = isset($value->post_status) ? $value->post_status : '';
         $data[$key]['post_date'] = isset($value->post_date) ? $value->post_date : '';
     }
     return $data;
 }
コード例 #24
0
/**
 * Create the function to output the contents of our Dashboard Widget.
 */
function bbconnect_workqueues_actions_dashboard_widget_function()
{
    echo ' <table cellspacing="0" class="widefat gf_dashboard_view" style="border:0px;">' . "\n";
    echo '        <thead>' . "\n";
    echo '            <tr>' . "\n";
    echo '                <td class="gf_dashboard_form_title_header" style="font-style: italic; font-weight: bold; padding: 8px 18px!important; text-align: left">Workqueue</td>' . "\n";
    echo '                <td class="gf_dashboard_entries_unread_header" style="font-style: italic; font-weight: bold; padding: 8px 18px!important; text-align: center">For Action</td>' . "\n";
    echo '            </tr>' . "\n";
    echo '        </thead>' . "\n";
    echo '        <tbody class="list:user user-list">' . "\n";
    $taxonomies = array('bb_note_type');
    $args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => true, 'fields' => 'all');
    $note_types = get_terms($taxonomies, $args);
    foreach ($note_types as $note_type) {
        if ($note_type->parent == 0) {
            continue;
        }
        // Display whatever it is you want to show.
        $args = array('posts_per_page' => -1, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'bb_note', 'post_status' => 'publish', 'meta_query' => array(array('key' => '_bbc_action_required', 'value' => 'true')), 'bb_note_type' => $note_type->slug);
        $notes = get_posts($args);
        if (count($notes) > 0) {
            echo bbconnect_workqueues_actions_dashboard_widget_row($note_type->term_id, $note_type->name, $note_type->slug, count($notes));
        }
    }
    echo '         </tbody>' . "\n";
    echo '     </table>' . "\n";
}
コード例 #25
0
 function _process($data = array())
 {
     $entries = get_posts($data['label'], 1, $data['num_posts'], 'desc', true);
     $data['latest_posts'] = $entries['entries'];
     // don't forget to store to widget_data property
     $this->widget_data = $data;
 }
コード例 #26
0
ファイル: Post.php プロジェクト: silversite/silverwp
 /**
  * Latest blog posts
  *
  * @param int    $limit post display limit
  *
  * @param string $thumbnail_size
  *
  * @return array
  */
 public static function getRecent($limit = 10, $thumbnail_size = 'thumbnail')
 {
     $args = array('numberposts' => $limit, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending', 'suppress_filters' => true);
     $array_out = array();
     $recent_posts = \get_posts(\wp_parse_args($args));
     /*$like_bool    = Option::get_theme_option( 'blog_list_like' );
       if ( $like_bool === '1' ) {
           $PostLike = \SilverWp\Ajax\PostLike::getInstance();
       }*/
     foreach ($recent_posts as $key => $recent) {
         \setup_postdata($recent);
         $post_id = $recent->ID;
         //$array_out[ $key ] = $recent;
         $array_out[$key]['ID'] = $post_id;
         $array_out[$key]['post_title'] = \get_the_title($post_id);
         $array_out[$key]['url'] = \get_the_permalink($post_id);
         $array_out[$key]['post_author'] = \get_the_author();
         $array_out[$key]['post_date'] = \get_the_date('', $post_id);
         $array_out[$key]['post_date_utc'] = \get_the_time('c', $post_id);
         //$array_out[ $key ]['post_like'] = ($like_bool === '1') ? $PostLike->getPostLikeCount($post_id) : '';
         $array_out[$key]['post_comment_count'] = $recent->comment_count;
         if (strpos($recent->post_content, '<!--more-->') || empty($recent->post_excerpt)) {
             $array_out[$key]['post_excerpt'] = \get_the_excerpt();
         } else {
             $array_out[$key]['post_excerpt'] = $recent->post_excerpt;
         }
         $array_out[$key]['image_html'] = \get_the_post_thumbnail($post_id, $thumbnail_size);
         // Thumbnail
         $array_out[$key]['categories'] = self::getTaxonomy($post_id);
     }
     \wp_reset_postdata();
     return $array_out;
 }
コード例 #27
0
ファイル: update.php プロジェクト: lieison/IndustriasFenix
/**
 * 1.3.0
 */
function yit_update_1_3_0()
{
    /* ====== Update CPTU ====== */
    global $wpdb;
    $temp = array();
    $prefixes = array('sliders' => 'sl_', 'portfolios' => 'po_', 'feature-tabs' => 'ft_', 'teams' => 'team_');
    foreach ($prefixes as $post_type => $prefix) {
        $args = array('post_type' => $post_type, 'posts_per_page' => -1, 'post_status' => 'publish');
        $post_types = get_posts($args);
        foreach ($post_types as $the) {
            $from = substr($prefix . $the->post_name, 0, 20);
            $to = yit_avoid_duplicate(str_replace('-', '_', substr($prefix . $the->post_name, 0, 16)), $temp);
            $temp[] = $to;
            $to_parent = substr($to, 3);
            /* Update Child Post Type*/
            $wpdb->update($wpdb->posts, array('post_type' => $to), array('post_type' => $from));
            /* Update Parent Post Name */
            $wpdb->update($wpdb->posts, array('post_name' => $to_parent), array('post_name' => $the->post_name));
            /* Update Slider Name in Post Meta */
            if ('sliders' == $post_type) {
                $where = array('meta_key' => '_slider_name', 'meta_value' => $the->post_name);
                $wpdb->update($wpdb->postmeta, array('meta_value' => $to_parent), $where);
            }
        }
    }
    set_transient('cptu_1_3_0_update', true);
}
コード例 #28
0
 public function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1;
     $termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand');
     if ($group = $instance['group']) {
         $termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group));
     }
     $terms = get_posts($termargs);
     if ($terms && count($terms)) {
         echo '<ul class="wpglossary widget-list">';
         foreach ($terms as $term) {
             setup_postdata($term);
             $title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>';
             $desc = '';
             $display = $instance['display'];
             if ($display && $display != 'title') {
                 $desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt());
                 $desc = '<br>' . $desc;
             }
             echo '<li>' . $title . $desc . '</li>';
         }
         wp_reset_postdata();
         echo '</ul>';
     } else {
         echo '<em>' . __('No terms available', 'wp-glossary') . '</em>';
     }
     echo $after_widget;
 }
コード例 #29
0
ファイル: rest-api.php プロジェクト: SelaInc/eassignment
 public function store_commission_data($data, $query_mode, $api_object)
 {
     if ('store-commissions' != $query_mode) {
         return $data;
     }
     $user_id = $api_object->get_user();
     if (!user_can($user_id, 'view_shop_reports')) {
         return $data;
     }
     $data = array('commissions' => array());
     $paged = $api_object->get_paged();
     $status = isset($_REQUEST['status']) ? sanitize_text_field($_REQUEST['status']) : 'unpaid';
     $commission_args = array('post_type' => 'edd_commission', 'post_status' => 'publish', 'posts_per_page' => $api_object->per_page(), 'paged' => $paged);
     if ($status) {
         $commission_args['tax_query'] = array(array('taxonomy' => 'edd_commission_status', 'terms' => $status, 'field' => 'slug'));
     }
     $commissions = get_posts($commission_args);
     if ($commissions) {
         foreach ($commissions as $commission) {
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true);
             $renewal = (bool) get_post_meta($commission->ID, '_edd_commission_is_renewal', true);
             $data['commissions'][] = array('amount' => edd_sanitize_amount($commission_meta['amount']), 'rate' => $commission_meta['rate'], 'currency' => $commission_meta['currency'], 'item' => get_the_title($download_id), 'status' => eddc_get_commission_status($commission->ID), 'date' => $commission->post_date, 'renewal' => $renewal ? 1 : 0);
         }
         wp_reset_postdata();
     }
     $data['total_unpaid'] = eddc_get_unpaid_totals();
     return $data;
 }
コード例 #30
0
 protected function match_existing_post(array $record)
 {
     $start_date = $this->get_event_start_date($record);
     $end_date = $this->get_event_end_date($record);
     $all_day = $this->get_boolean_value_by_key($record, 'event_all_day');
     // Base query - only the meta query will be different
     $query_args = array('post_type' => Tribe__Events__Main::POSTTYPE, 'post_title' => $this->get_value_by_key($record, 'event_name'), 'fields' => 'ids', 'posts_per_page' => 1);
     // When trying to find matches for all day events, the comparison should only be against the date
     // component only since a) the time is irrelevant and b) the time may have been adjusted to match
     // the eod cutoff setting
     if (Tribe__Events__Date_Utils::is_all_day($all_day)) {
         $meta_query = array(array('key' => '_EventStartDate', 'value' => $this->get_event_start_date($record, true), 'compare' => 'LIKE'), array('key' => '_EventAllDay', 'value' => 'yes'));
         // For regular, non-all day events, use the full date *and* time in the start date comparison
     } else {
         $meta_query = array(array('key' => '_EventStartDate', 'value' => $start_date));
     }
     // Optionally use the end date/time for matching, where available
     if (!empty($end_date) && !$all_day) {
         $meta_query[] = array('key' => '_EventEndDate', 'value' => $end_date);
     }
     $query_args['meta_query'] = $meta_query;
     add_filter('posts_search', array($this, 'filter_query_for_title_search'), 10, 2);
     $matches = get_posts($query_args);
     remove_filter('posts_search', array($this, 'filter_query_for_title_search'), 10, 2);
     if (empty($matches)) {
         return 0;
     }
     return reset($matches);
 }