本文整理汇总了PHP中wp_list_pluck函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_list_pluck函数的具体用法?PHP wp_list_pluck怎么用?PHP wp_list_pluck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_list_pluck函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_comments
/**
* Get comments
*
* @since 0.0.1
*
* @param array $data Sanitized data from request
*
* @return array
*/
public static function get_comments($data)
{
$args = api_helper::get_comment_args($data['postID']);
$options = options::get_display_options();
$comments = get_comments($args);
if ('ASC' == $options['order']) {
$parents = array_combine(wp_list_pluck($comments, 'comment_ID'), wp_list_pluck($comments, 'comment_parent'));
asort($parents);
$comments = (array) $comments;
$comments = array_combine(wp_list_pluck($comments, 'comment_ID'), $comments);
$i = 0;
foreach ($comments as $id => $parent) {
$_comments[$i] = $comments[$id];
$i++;
}
rsort($_comments);
$comments = $_comments;
}
if (!empty($comments) && is_array($comments)) {
$comments = api_helper::improve_comment_response($comments, !api_helper::thread());
$comments = wp_json_encode($comments);
} else {
return false;
}
return array('comments' => $comments);
}
开发者ID:rpkoller,项目名称:epoch,代码行数:35,代码来源:api_process.php
示例2: test_dont_process_terms_if_taxonomy_does_not_allow_show_on_quick_edit
/**
* @ticket 26948
*/
public function test_dont_process_terms_if_taxonomy_does_not_allow_show_on_quick_edit()
{
register_taxonomy('wptests_tax_1', 'post', array('show_in_quick_edit' => false, 'hierarchical' => true));
register_taxonomy('wptests_tax_2', 'post', array('show_in_quick_edit' => true, 'hierarchical' => true));
$t1 = self::factory()->term->create(array('taxonomy' => 'wptests_tax_1'));
$t2 = self::factory()->term->create(array('taxonomy' => 'wptests_tax_2'));
// Become an administrator.
$this->_setRole('administrator');
$post = self::factory()->post->create_and_get(array('post_author' => get_current_user_id()));
// Set up a request.
$_POST['_inline_edit'] = wp_create_nonce('inlineeditnonce');
$_POST['post_ID'] = $post->ID;
$_POST['post_type'] = $post->post_type;
$_POST['content'] = $post->post_content;
$_POST['excerpt'] = $post->post_excerpt;
$_POST['_status'] = $post->post_status;
$_POST['post_status'] = $post->post_status;
$_POST['screen'] = 'post';
$_POST['post_view'] = 'excerpt';
$_POST['tax_input'] = array('wptests_tax_1' => array($t1), 'wptests_tax_2' => array($t2));
// Make the request.
try {
$this->_handleAjax('inline-save');
} catch (WPAjaxDieContinueException $e) {
unset($e);
}
// wptests_tax_1 terms should have been refused.
$post_terms_1 = wp_get_object_terms($post->ID, 'wptests_tax_1');
$this->assertEmpty($post_terms_1);
// wptests_tax_2 terms should have been added successfully.
$post_terms_2 = wp_get_object_terms($post->ID, 'wptests_tax_2');
$this->assertEqualSets(array($t2), wp_list_pluck($post_terms_2, 'term_id'));
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:36,代码来源:QuickEdit.php
示例3: query_report_data
/**
* Get all data needed for this report and store in the class
*/
private function query_report_data()
{
$this->report_data = new stdClass();
$this->report_data->orders = (array) $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales'), '_order_shipping' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping'), '_order_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_tax'), '_order_shipping_tax' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping_tax'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => array_merge(array('shop_order_refund'), wc_get_order_types('sales-reports')), 'order_status' => array('completed', 'processing', 'on-hold'), 'parent_order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->order_counts = (array) $this->get_order_report_data(array('data' => array('ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'count', 'distinct' => true), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->coupons = (array) $this->get_order_report_data(array('data' => array('order_item_name' => array('type' => 'order_item', 'function' => '', 'name' => 'order_item_name'), 'discount_amount' => array('type' => 'order_item_meta', 'order_item_type' => 'coupon', 'function' => 'SUM', 'name' => 'discount_amount'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'coupon', 'operator' => '=')), 'group_by' => $this->group_by_query . ', order_item_name', 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->order_items = (array) $this->get_order_report_data(array('data' => array('_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'line_item', 'operator' => '=')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('completed', 'processing', 'on-hold')));
$this->report_data->refunded_order_items = (array) $this->get_order_report_data(array('data' => array('_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'where' => array(array('key' => 'order_items.order_item_type', 'value' => 'line_item', 'operator' => '=')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('refunded')));
$this->report_data->partial_refunds = (array) $this->get_order_report_data(array('data' => array('_refund_amount' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_refund'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date'), '_qty' => array('type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'order_item_count')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_status' => false, 'parent_order_status' => array('completed', 'processing', 'on-hold')));
foreach ($this->report_data->partial_refunds as $key => $value) {
$this->report_data->partial_refunds[$key]->order_item_count = $this->report_data->partial_refunds[$key]->order_item_count * -1;
}
$this->report_data->order_items = array_merge($this->report_data->order_items, $this->report_data->partial_refunds);
$this->report_data->total_order_refunds = array_sum((array) absint($this->get_order_report_data(array('data' => array('ID' => array('type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders')), 'query_type' => 'get_var', 'filter_range' => true, 'order_types' => wc_get_order_types('order-count'), 'order_status' => array('refunded')))));
$this->report_data->full_refunds = (array) $this->get_order_report_data(array('data' => array('_order_total' => array('type' => 'meta', 'function' => 'SUM', 'name' => 'total_refund'), 'post_date' => array('type' => 'post_data', 'function' => '', 'name' => 'post_date')), 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_status' => array('refunded')));
$this->report_data->refunds = array_merge($this->report_data->partial_refunds, $this->report_data->full_refunds);
$this->report_data->total_sales = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_sales')), 2);
$this->report_data->total_tax = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_tax')), 2);
$this->report_data->total_shipping = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_shipping')), 2);
$this->report_data->total_shipping_tax = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->orders, 'total_shipping_tax')), 2);
$this->report_data->total_refunds = wc_format_decimal(array_sum(wp_list_pluck($this->report_data->partial_refunds, 'total_refund')) + array_sum(wp_list_pluck($this->report_data->full_refunds, 'total_refund')), 2);
$this->report_data->total_coupons = number_format(array_sum(wp_list_pluck($this->report_data->coupons, 'discount_amount')), 2);
$this->report_data->total_orders = absint(array_sum(wp_list_pluck($this->report_data->order_counts, 'count')));
$this->report_data->total_partial_refunds = array_sum(wp_list_pluck($this->report_data->partial_refunds, 'order_item_count')) * -1;
$this->report_data->total_item_refunds = array_sum(wp_list_pluck($this->report_data->refunded_order_items, 'order_item_count')) * -1;
$this->report_data->total_items = absint(array_sum(wp_list_pluck($this->report_data->order_items, 'order_item_count')) * -1);
$this->report_data->average_sales = wc_format_decimal($this->report_data->total_sales / ($this->chart_interval + 1), 2);
$this->report_data->net_sales = wc_format_decimal($this->report_data->total_sales - $this->report_data->total_shipping - $this->report_data->total_tax - $this->report_data->total_shipping_tax, 2);
}
开发者ID:amusiiko,项目名称:armo,代码行数:32,代码来源:class-wc-report-sales-by-date.php
示例4: bulky_woocommerce_cart_shipping_packages
public static function bulky_woocommerce_cart_shipping_packages($packages)
{
// Reset the packages
$packages = array();
// Bulky items
$free_items = array();
$regular_items = array();
// Sort free from others
foreach (WC()->cart->get_cart() as $item) {
if ($item['data']->needs_shipping()) {
if ($item['data']->get_shipping_class() == 'free' || $item['data']->get_shipping_class() == '') {
$free_items[] = $item;
} else {
$regular_items[] = $item;
}
}
}
// Put inside packages
if ($free_items) {
$packages[] = array('ship_via' => array('free_shipping'), 'contents' => $free_items, 'contents_cost' => array_sum(wp_list_pluck($free_items, 'line_total')), 'applied_coupons' => WC()->cart->applied_coupons, 'destination' => array('country' => WC()->customer->get_shipping_country(), 'state' => WC()->customer->get_shipping_state(), 'postcode' => WC()->customer->get_shipping_postcode(), 'city' => WC()->customer->get_shipping_city(), 'address' => WC()->customer->get_shipping_address(), 'address_2' => WC()->customer->get_shipping_address_2()));
}
if ($regular_items) {
$packages[] = array('ship_via' => array('flat_rate'), 'contents' => $regular_items, 'contents_cost' => array_sum(wp_list_pluck($regular_items, 'line_total')), 'applied_coupons' => WC()->cart->applied_coupons, 'destination' => array('country' => WC()->customer->get_shipping_country(), 'state' => WC()->customer->get_shipping_state(), 'postcode' => WC()->customer->get_shipping_postcode(), 'city' => WC()->customer->get_shipping_city(), 'address' => WC()->customer->get_shipping_address(), 'address_2' => WC()->customer->get_shipping_address_2()));
}
return $packages;
}
开发者ID:essenmitsosse,项目名称:woocommerce-bulk-shipping-seperated,代码行数:26,代码来源:woocommerce-bulk-shipping-seperated.php
示例5: list_
/**
* List terms in a taxonomy.
*
* ## OPTIONS
*
* <taxonomy>...
* : List terms of one or more taxonomies
*
* [--<field>=<value>]
* : Filter by one or more fields (see get_terms() $args parameter for a list of fields).
*
* [--field=<field>]
* : Prints the value of a single field for each term.
*
* [--fields=<fields>]
* : Limit the output to specific object fields.
*
* [--format=<format>]
* : Accepted values: table, csv, json, count, yaml. Default: table
*
* ## AVAILABLE FIELDS
*
* These fields will be displayed by default for each term:
*
* * term_id
* * term_taxonomy_id
* * name
* * slug
* * description
* * parent
* * count
*
* There are no optionally available fields.
*
* ## EXAMPLES
*
* wp term list category --format=csv
*
* wp term list post_tag --fields=name,slug
*
* @subcommand list
*/
public function list_($args, $assoc_args)
{
foreach ($args as $taxonomy) {
if (!taxonomy_exists($taxonomy)) {
WP_CLI::error("Taxonomy {$taxonomy} doesn't exist.");
}
}
$formatter = $this->get_formatter($assoc_args);
$defaults = array('hide_empty' => false);
$assoc_args = array_merge($defaults, $assoc_args);
if (!empty($assoc_args['term_id'])) {
$term = get_term_by('id', $assoc_args['term_id'], $args[0]);
$terms = array($term);
} else {
$terms = get_terms($args, $assoc_args);
}
$terms = array_map(function ($term) {
$term->count = (int) $term->count;
$term->parent = (int) $term->parent;
return $term;
}, $terms);
if ('ids' == $formatter->format) {
$terms = wp_list_pluck($terms, 'term_id');
echo implode(' ', $terms);
} else {
$formatter->display_items($terms);
}
}
开发者ID:ryanshoover,项目名称:wp-cli,代码行数:70,代码来源:term.php
示例6: 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:kivivuori,项目名称:jotain,代码行数:31,代码来源:filters.php
示例7: wc_get_product_terms
/**
* Wrapper for wp_get_post_terms which supports ordering by parent.
*
* NOTE: At this point in time, ordering by menu_order for example isn't possible with this function. wp_get_post_terms has no
* filters which we can utilise to modify it's query. https://core.trac.wordpress.org/ticket/19094
*
* @param int $product_id
* @param string $taxonomy
* @param array $args
* @return array
*/
function wc_get_product_terms($product_id, $taxonomy, $args = array())
{
if (!taxonomy_exists($taxonomy)) {
return array();
}
if (empty($args['orderby']) && taxonomy_is_product_attribute($taxonomy)) {
$args['orderby'] = wc_attribute_orderby($taxonomy);
}
// Support ordering by parent
if (!empty($args['orderby']) && $args['orderby'] == 'parent') {
$fields = isset($args['fields']) ? $args['fields'] : 'all';
// Unset for wp_get_post_terms
unset($args['orderby']);
unset($args['fields']);
$terms = wp_get_post_terms($product_id, $taxonomy, $args);
usort($terms, '_wc_get_product_terms_parent_usort_callback');
switch ($fields) {
case 'names':
$terms = wp_list_pluck($terms, 'name');
break;
case 'ids':
$terms = wp_list_pluck($terms, 'term_id');
break;
case 'slugs':
$terms = wp_list_pluck($terms, 'slug');
break;
}
} else {
$terms = wp_get_post_terms($product_id, $taxonomy, $args);
}
return $terms;
}
开发者ID:Joaquinsemp,项目名称:patriestausado,代码行数:43,代码来源:wc-term-functions.php
示例8: test_last_activity_should_bust_activity_with_last_activity_cache
/**
* @ticket BP7237
* @ticket BP6643
* @ticket BP7245
*/
public function test_last_activity_should_bust_activity_with_last_activity_cache()
{
global $wpdb;
$u1 = $this->factory->user->create();
$u2 = $this->factory->user->create();
$time_1 = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS);
$time_2 = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS * 2);
bp_update_user_last_activity($u1, $time_1);
bp_update_user_last_activity($u2, $time_2);
$activity_args_a = array('filter' => array('object' => buddypress()->members->id, 'action' => 'last_activity'), 'max' => 1);
$activity_args_b = array('filter' => array('action' => 'new_member'), 'fields' => 'ids');
// Prime bp_activity and bp_activity_with_last_activity caches.
$a1 = bp_activity_get($activity_args_a);
$expected = array($u1, $u2);
$found = array_map('intval', wp_list_pluck($a1['activities'], 'user_id'));
$this->assertSame($expected, $found);
$b1 = bp_activity_get($activity_args_b);
// Bump u2 activity so it should appear first.
$new_time = date('Y-m-d H:i:s', time() - HOUR_IN_SECONDS);
bp_update_user_last_activity($u2, $new_time);
$a2 = bp_activity_get($activity_args_a);
$expected = array($u2, $u1);
$found = array_map('intval', wp_list_pluck($a2['activities'], 'user_id'));
$this->assertSame($expected, $found);
$num_queries = $wpdb->num_queries;
// bp_activity cache should not have been touched.
$b2 = bp_activity_get($activity_args_b);
$this->assertEqualSets($b1, $b2);
$this->assertSame($num_queries, $wpdb->num_queries);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:35,代码来源:cache.php
示例9: wp_user_alerts_get_notices
/**
* Return array of notice alerts
*
* @since 0.1.0
*
* @return array
*/
function wp_user_alerts_get_notices()
{
// Dismissed notices are excluded
$dismissed = wp_list_pluck(wp_user_alerts_get_dismissed_notices(), 'ID');
// Get alerts
return wp_user_alerts_get_posts(array('numberposts' => 10, 'exclude' => $dismissed, 'meta_query' => wp_user_alerts_get_meta_query(array('user' => wp_user_alerts_get_meta_query_user(), 'role' => wp_user_alerts_get_meta_query_role(), 'method' => 'notice'))));
}
开发者ID:stuttter,项目名称:wp-user-alerts,代码行数:14,代码来源:notices.php
示例10: thatcamp_registrations_add_registration
/**
* Adds a single registration entry. This is a motley function.
*
* @param string The status of the registration record.
**/
function thatcamp_registrations_add_registration($status = 'pending')
{
global $wpdb;
$table = $wpdb->prefix . "thatcamp_registrations";
$_POST = stripslashes_deep($_POST);
// The user_id is set to the posted user ID, or null.
$user_id = isset($_POST['user_id']) ? $_POST['user_id'] : null;
$applicant_info = array();
$applicant_fields = wp_list_pluck(thatcamp_registrations_fields(), 'id');
foreach ($applicant_fields as $field) {
$applicant_info[$field] = isset($_POST[$field]) ? $_POST[$field] : null;
}
$date = isset($_POST['date']) ? $_POST['date'] : null;
$applicationText = isset($_POST['application_text']) ? $_POST['application_text'] : null;
// Lets serialize the applicant_info before putting it in the database.
$applicant_info = maybe_serialize($applicant_info);
$applicant_email = isset($_POST['user_email']) ? $_POST['user_email'] : null;
// Check for an existing registration
$user_exists = false;
if (!is_null($user_id) && thatcamp_registrations_get_registration_by_user_id($user_id) || thatcamp_registrations_get_registration_by_applicant_email($applicant_email)) {
$user_exists = true;
}
if ($user_exists) {
return 'You have already submitted your registration.';
} else {
$reg_id = $wpdb->insert($table, array('applicant_info' => $applicant_info, 'applicant_email' => $applicant_email, 'application_text' => $applicationText, 'status' => $status, 'date' => $date, 'user_id' => $user_id));
thatcamp_registrations_send_applicant_email($applicant_email);
thatcamp_registrations_send_admin_notification($wpdb->insert_id);
}
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:35,代码来源:thatcamp-registrations-functions.php
示例11: test_category__and_var
function test_category__and_var() {
$term_id = $this->factory->category->create( array( 'slug' => 'woo', 'name' => 'WOO!' ) );
$term_id2 = $this->factory->category->create( array( 'slug' => 'hoo', 'name' => 'HOO!' ) );
$post_id = $this->factory->post->create();
wp_set_post_categories( $post_id, $term_id );
$posts = $this->q->query( array( 'category__and' => array( $term_id ) ) );
$this->assertEmpty( $this->q->get( 'category__and' ) );
$this->assertCount( 0, $this->q->get( 'category__and' ) );
$this->assertNotEmpty( $this->q->get( 'category__in' ) );
$this->assertCount( 1, $this->q->get( 'category__in' ) );
$this->assertNotEmpty( $posts );
$this->assertEquals( array( $post_id ), wp_list_pluck( $posts, 'ID' ) );
$posts2 = $this->q->query( array( 'category__and' => array( $term_id, $term_id2 ) ) );
$this->assertNotEmpty( $this->q->get( 'category__and' ) );
$this->assertCount( 2, $this->q->get( 'category__and' ) );
$this->assertEmpty( $this->q->get( 'category__in' ) );
$this->assertCount( 0, $this->q->get( 'category__in' ) );
$this->assertEmpty( $posts2 );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:25,代码来源:query.php
示例12: has_field_type
/**
* Check whether settings has particular field type
*
* @param string field type
* @return bool
*/
function has_field_type($type)
{
if (in_array($type, wp_list_pluck($this->settings['fields'], 'type'))) {
return true;
}
return false;
}
开发者ID:andyhqtran,项目名称:divi-100-submodule,代码行数:13,代码来源:class-divi-100-settings.php
示例13: license_menu
/**
* Add Plugin License Menu
*
* @since 1.5.6
*/
function license_menu()
{
global $submenu;
if (isset($submenu[$this->main_menu_slug]) && !in_array($this->license_page_slug, wp_list_pluck($submenu[$this->main_menu_slug], 2))) {
add_submenu_page($this->main_menu_slug, __('Plugin License', 'feed-them-social'), __('Plugin License', 'feed-them-social'), 'manage_options', $this->license_page_slug, array($this, 'license_page'));
}
}
开发者ID:mattywebb,项目名称:cyclery-northside,代码行数:12,代码来源:namespaced_EDD_SL_Plugin_Licence_Manager.php
示例14: init
function init()
{
//move away from kl_ prefix
$opts = get_option('kl_addnewdefaultavatar', false);
if ($opts) {
update_option('add_new_default_avatar', $opts);
delete_option('kl_addnewdefaultavatar');
}
$opts = get_option('add_new_default_avatar', false);
//upgrade option, we can now save multiple avatar options
if (isset($opts['name'])) {
$opts = array($opts);
update_option('add_new_default_avatar', $opts);
}
if (!$opts) {
return;
}
//get current default opton
$current = get_option('avatar_default');
//get any custom created avatars
$unavailable = wp_list_pluck($opts, 'url');
//if the current wasn't created by this plugin, update the backup
if (!in_array($current, $unavailable)) {
update_option('pre_anda_avatar_default', $current);
}
}
开发者ID:stiyes,项目名称:ngionic,代码行数:26,代码来源:kl_addnewdefaultavatar.php
示例15: display_posts_filter
protected function display_posts_filter($args = array())
{
$default_args = array('post_type' => 'post', 'taxonomy' => 'category', 'query' => null, 'select' => 'all', 'show_category_filter' => true);
$args = wp_parse_args($args, $default_args);
$filter_args = array();
if ($args['show_category_filter']) {
// categorizer args
$filter_args = array('taxonomy' => $args['taxonomy'], 'post_type' => $args['post_type'], 'select' => $args['select']);
if ('only' == $args['select'] && $args['query'] && $args['query']->posts && isset($args['query']->tax_query->queried_terms[$args['taxonomy']]['terms'])) {
$filter_args['terms'] = array();
$queried_terms = $args['query']->tax_query->queried_terms[$args['taxonomy']]['terms'];
$posts_ids = wp_list_pluck($args['query']->posts, 'ID');
$posts_terms = wp_get_object_terms($posts_ids, $args['taxonomy']);
foreach ($posts_terms as $term) {
if (in_array($term->slug, $queried_terms)) {
$filter_args['terms'][] = intval($term->term_id);
}
}
$filter_args['terms'] = array_unique($filter_args['terms']);
}
}
$filter_class = '';
if (!$this->config->get('template.posts_filter.orderby.enabled') && !$this->config->get('template.posts_filter.order.enabled')) {
$filter_class .= ' extras-off';
}
// display categorizer
presscore_get_category_list(array('data' => dt_prepare_categorizer_data($filter_args), 'class' => 'filter iso-filter' . $filter_class));
}
开发者ID:10asfar,项目名称:WordPress-the7-theme-demo-,代码行数:28,代码来源:class-shortcode-masonry-posts.php
示例16: __construct
/**
* Create meta box based on given data
*
* @see demo/demo.php file for details
*
* @param array $meta_box Meta box definition
*
* @return \RW_Meta_Box
*/
function __construct($meta_box)
{
// Run script only in admin area
if (!is_admin()) {
return;
}
// Assign meta box values to local variables and add it's missed values
$this->meta_box = self::normalize($meta_box);
$this->fields =& $this->meta_box['fields'];
$this->validation =& $this->meta_box['validation'];
// List of meta box field types
$this->types = array_unique(wp_list_pluck($this->fields, 'type'));
// Enqueue common styles and scripts
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
foreach ($this->types as $type) {
$class = self::get_class_name($type);
// Add additional actions for fields
if (method_exists($class, 'add_actions')) {
call_user_func(array($class, 'add_actions'));
}
}
// Add meta box
foreach ($this->meta_box['pages'] as $page) {
add_action("add_meta_boxes_{$page}", array($this, 'add_meta_boxes'));
}
// Save post meta
add_action('save_post', array($this, 'save_post'));
}
开发者ID:rabisahar,项目名称:Spring,代码行数:37,代码来源:meta-box.php
示例17: test_static_front_page_search
public function test_static_front_page_search()
{
$this->tearDown();
$this->setUp();
$en_fp = $this->factory->post->create_and_get(array('post_type' => 'page', 'post_title' => 'Front Page'));
update_option('show_on_front', 'page');
update_option('page_on_front', $en_fp->ID);
$uk_fp = $this->create_post_translation($en_fp, 'en_GB');
$fr_fp = $this->create_post_translation($en_fp, 'fr_FR');
$posts = $this->create_test_posts();
// We shouldn't need to test all search scenarios in the context
// of a static front page
// UBIQUITOUS_WORD should be present in both US English posts
$this->go_to('/en/?s=UBIQUITOUS_WORD');
$matching_post_ids = wp_list_pluck($GLOBALS['wp_query']->posts, 'ID');
$expected_post_ids = wp_list_pluck(array($posts['en1'], $posts['en2']), 'ID');
$this->assertEqualSets($expected_post_ids, $matching_post_ids);
// UNIQUE_WORD_2 should only be in the second US English post
$this->go_to('/en/?s=UNIQUE_WORD_2_EN_US');
$matching_post_ids = wp_list_pluck($GLOBALS['wp_query']->posts, 'ID');
$expected_post_ids = wp_list_pluck(array($posts['en2']), 'ID');
$this->assertEqualSets($expected_post_ids, $matching_post_ids);
$this->set_post_types_to_locale('fr_FR');
// UNIQUE_WORD_2_FR_FR should only be in the second French post
$this->go_to('/fr/?s=UNIQUE_WORD_2_FR_FR');
$matching_post_ids = wp_list_pluck($GLOBALS['wp_query']->posts, 'ID');
$expected_post_ids = wp_list_pluck(array($posts['fr2']), 'ID');
$this->assertEqualSets($expected_post_ids, $matching_post_ids);
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:29,代码来源:test-search.php
示例18: status
public function status()
{
if ($this->_status) {
return $this->_status;
}
$info = get_plugins();
$installed = array_flip(wp_list_pluck($info, 'PluginURI'));
foreach ($this->plugins as $plugin) {
$slug = $plugin->slug;
$stat["link"] = false;
if (isset($installed[$slug])) {
$file = $installed[$slug];
$this->installed[$file] = true;
$stat["file"] = $file;
$stat["version"] = $info[$file]["Version"];
if (is_plugin_active($file)) {
// active
$stat["status"] = "active";
} else {
// installed
$stat["status"] = "installed";
$stat["link"] = wp_nonce_url(self_admin_url("plugins.php?action=activate&peredirect=1&plugin={$file}"), "activate-plugin_{$file}");
}
} else {
// not installed
$stat["status"] = "not-installed";
$stat["link"] = wp_nonce_url(self_admin_url("update.php?action=install-plugin&peredirect=1&plugin={$slug}"), "install-plugin_{$slug}");
}
$res[$slug] = (object) $stat;
}
// cache result
$this->_status = $res;
return $res;
}
开发者ID:JeffreyBue,项目名称:jb,代码行数:34,代码来源:class-pixelentity-theme-bundled-plugins.php
示例19: unplaceholdit
static function unplaceholdit($template, $content, $object_key = 'object')
{
/** Early bailout? */
if (strpos($template, '%%') === false) {
return $template;
}
/** First, get a list of all placeholders. */
$matches = $replaces = array();
preg_match_all('/%%([^%]+)%%/u', $template, $matches, PREG_SET_ORDER);
$searches = wp_list_pluck($matches, 0);
/* Cast the object */
$object = array_key_exists($object_key, $content) ? (array) $content[$object_key] : false;
foreach ($matches as $match) {
/**
* 0 => %%template_tag%%
* 1 => variable_name
*/
if ($object && isset($object[$match[1]])) {
array_push($replaces, $object[$match[1]]);
} else {
if (isset($content[$match[1]])) {
array_push($replaces, $content[$match[1]]);
} else {
array_push($replaces, $match[0]);
}
}
}
return str_replace($searches, $replaces, $template);
}
开发者ID:md2k,项目名称:wp-cli-deploy,代码行数:29,代码来源:helpers.php
示例20: fetch_items
public function fetch_items()
{
global $wpdb;
$vars = array(WPSC_Purchase_Log::ACCEPTED_PAYMENT, WPSC_Purchase_Log::JOB_DISPATCHED, WPSC_Purchase_Log::CLOSED_ORDER, get_current_user_id());
/* @todo: seems all we use here is fileid and product_id. Investigate benchmarking selecting only those two columns. */
$sql = $wpdb->prepare("\n\t\t\tSELECT\n\t\t\t\td.*\n\t\t\tFROM " . WPSC_TABLE_DOWNLOAD_STATUS . " AS d\n\t\t\tINNER JOIN " . WPSC_TABLE_PURCHASE_LOGS . " AS p\n\t\t\tON\n\t\t\t\td.purchid = p.id\n\t\t\tWHERE\n\t\t\t\td.active = 1 AND\n\t\t\t\tp.processed IN (%d, %d, %d) AND\n\t\t\t\tp.user_ID = %d\n\t\t\tORDER BY p.id DESC\n\t\t", $vars);
$downloadables = $wpdb->get_results($sql);
$product_ids = wp_list_pluck($downloadables, 'product_id');
$product_ids = array_unique(array_map('absint', $product_ids));
$this->items = get_posts(array('post_type' => 'wpsc-product', 'post__in' => $product_ids));
$this->total_items = count($this->items);
$this->digital_items = array();
foreach ($downloadables as $file) {
if (!in_array($file->product_id, $product_ids)) {
continue;
}
if (!array_key_exists($file->product_id, $this->digital_items)) {
$this->digital_items[$file->product_id] = array();
}
$this->digital_items[$file->product_id][] = $file;
}
// cache files
$files = wp_list_pluck($downloadables, 'fileid');
get_posts(array('post_type' => 'wpsc-product-file', 'post__in' => $files));
}
开发者ID:osuarcher,项目名称:WP-e-Commerce,代码行数:25,代码来源:digital-contents-table.php
注:本文中的wp_list_pluck函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论