本文整理汇总了PHP中wp_array_slice_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_array_slice_assoc函数的具体用法?PHP wp_array_slice_assoc怎么用?PHP wp_array_slice_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_array_slice_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gramm_list_authors
/**
* Custom List Users
*
* Custom function to generate a list of blog authors,
* built based on WordPress' native wp_list_users function.
*
* @since Grammatizator 0.6
*/
function gramm_list_authors($args = '')
{
// SET up variables
global $wpdb;
$defaults = array('orderby' => 'name', 'order' => 'ASC', 'role' => '', 'include' => array(), 'biolength' => 55, 'heading_tag' => 'h3', 'echo' => true);
$args = wp_parse_args($args, $defaults);
$return = '';
// GET data from database with database query
// Use this to get the paramenters we need for get_users() out of the default $args
$query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'role', 'include'));
// Used to request only an array of user IDs from get_users()
$query_args['fields'] = 'ids';
$authors = get_users($query_args);
// STEP through the data
foreach ($authors as $authorid) {
// GET individual user data and save in temporary variables
$author = get_userdata($authorid);
/* Test me */
// print_r();
// First Last name
// Bio
// Twitter handle
// Link to users's posts
// Image (get later)
// BUILD output
}
// End foreach loop
// OUTPUT results
}
示例2: get_image
function get_image($image_id)
{
$attachment_data = wp_prepare_attachment_for_js($image_id);
$image = wp_array_slice_assoc($attachment_data, array('sizes', 'caption', 'description'));
if (empty($image)) {
return false;
}
foreach ($this->sizes as $size) {
$size_name = $size;
if (!isset($image['sizes'][$size])) {
$size = 'full';
$image['error'] = "wrong-size";
}
// Format Data
$image[$size_name]['img'] = $image['sizes'][$size]['url'];
$image[$size_name]['width'] = $image['sizes'][$size]['width'];
$image[$size_name]['height'] = $image['sizes'][$size]['height'];
}
$image['id'] = $image_id;
$image['desc'] = $image['description'];
unset($image['sizes'], $image['description']);
if (!$this->has_descriptions && !empty($image['description'])) {
$this->has_descriptions = true;
}
$image['desc'] = htmlspecialchars(str_replace('"', '"', $image['desc']), ENT_QUOTES);
$image['caption'] = htmlspecialchars(str_replace('"', '"', $image['caption']), ENT_QUOTES);
return $image;
}
示例3: cbnr_the_exchange
/**
* Output the exchange rates
* This is the shortcode callback function
*/
function cbnr_the_exchange($attrs = '')
{
$rates = cbnr_get_rates();
if (is_array($attrs)) {
foreach ($attrs as &$atr) {
$atr = strtolower($atr);
}
unset($atr);
$rates = wp_array_slice_assoc($rates, $attrs);
}
if (empty($rates)) {
return;
}
$html = '';
if (!is_array($attrs) || !in_array('nocss', $attrs)) {
$html .= '<style type="text/css">@import url("' . plugins_url('style.css', __FILE__) . '");</style>';
}
$html .= '<div class="cbnr">';
$html .= ' <h3>Curs Valutar <img src="' . cbnr_get_icon_url('ron') . '"></h3>';
$html .= ' <div class="cbnr_date">' . date('j F Y') . '</div>';
foreach ($rates as $key => $value) {
$html .= ' <div class="cbnr_row">';
$html .= ' <div class="cnbr_flag"><img src="' . cbnr_get_icon_url($key) . '" title="' . strtoupper($key) . '"></div>';
$html .= ' <div class="cbnr_currency">' . strtoupper($key) . '</div>';
$html .= ' <div class="cbnr_value">' . $value . ' RON</div>';
$html .= ' </div>';
}
$html .= ' <span class="cbnr_credits">Curs oferit de <a href="http://www.bnro.ro">Banca Națională a României</a></span>';
$html .= '</div>';
return $html;
}
示例4: gramm_list_authors
/**
* Custom List Users
*
* Custom function to generate a list of blog authors,
* built based on WordPress' native wp_list_users function.
*
* @since Grammatizator 0.6
*/
function gramm_list_authors($args = '')
{
// SET up variables
global $wpdb;
$defaults = array('orderby' => 'name', 'order' => 'ASC', 'role' => '', 'include' => array(), 'biolength' => 55, 'heading_tag' => 'h5', 'echo' => true);
$args = wp_parse_args($args, $defaults);
$return = '';
// GET data from database with database query
// Use this to get the paramenters we need for get_users() out of the default $args
$query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'role', 'include'));
// Used to request only an array of user IDs from get_users()
$query_args['fields'] = 'ids';
$authors = get_users($query_args);
// STEP through the data
foreach ($authors as $authorid) {
// GET individual user data and save in temporary variables
$author = get_userdata($authorid);
// First Last name
if ($author->first_name && $author->last_name) {
$name = "{$author->first_name} {$author->last_name}";
} else {
$name = $author->display_name;
}
// Bio
if (get_the_author_meta('description', $author->ID)) {
$bio = get_the_author_meta('description', $author->ID);
} else {
$bio = '';
}
// Twitter handle
if (get_the_author_meta('twitter', $author->ID)) {
$twit = '<p class="social-links"><a class="twitter" href="https://twitter.com/' . get_the_author_meta('twitter', $author->ID) . '" title="' . esc_attr(sprintf(__("%s on Twitter"), $author->display_name)) . '">@' . get_the_author_meta('twitter', $author->ID) . '</a></p>';
} else {
$twit = '';
}
// Link to users's posts
$authorlink = '<a class="fn" href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__("Posts by %s"), $author->display_name)) . '">' . $name . '</a>';
// BUILD output
$return .= '<section class="author byline vcard">';
// Image
$return .= '<div class="avatar-wrap avatar-size-90">';
$return .= get_avatar($author->ID, 90);
$return .= '</div>';
$return .= '<div class="bio-wrap">';
$return .= '<' . $args['heading_tag'] . '>' . $authorlink . '</' . $args['heading_tag'] . '>';
$return .= $twit;
if ($args['biolength'] > 0 && $bio) {
$return .= '<p class="author-bio">';
$return .= wptexturize($bio);
$return .= '</p>';
}
$return .= '</div><!-- close .bio-wrap -->';
$return .= '</section>';
// End output
}
// End foreach loop
// OUTPUT results
// guesses?
}
示例5: user_query
static function user_query($query)
{
if (isset($query->_p2p_capture)) {
return;
}
// Don't overwrite existing P2P query
if (isset($query->query_vars['connected_type'])) {
return;
}
_p2p_append($query->query_vars, wp_array_slice_assoc($_GET, P2P_URL_Query::get_custom_qv()));
}
示例6: json
/**
* Gather the parameters passed to client JavaScript via JSON.
*
* @since 4.1.0
* @return array The array to be exported to the client as JSON.
*/
public function json()
{
$array = wp_array_slice_assoc((array) $this, array('id', 'title', 'description', 'priority', 'type'));
$array['content'] = $this->get_content();
$array['active'] = $this->active();
$array['instanceNumber'] = $this->instance_number;
// BEGIN Redux Additions
$array['width'] = isset($this->section['customizer_width']) ? $this->section['customizer_width'] : '';
$array['icon'] = isset($this->section['icon']) && !empty($this->section['icon']) ? $this->section['icon'] : 'hide';
// EMD Redux Additions
return $array;
}
示例7: get_url
static function get_url($context = 'display', $redirect_to = '')
{
$args = wp_array_slice_assoc($_GET, array('checkemail', 'registration', 'loggedout'));
if (!empty($redirect_to)) {
$args['redirect_to'] = urlencode($redirect_to);
}
if ($page_id = self::get_id()) {
$permalink = get_permalink($page_id);
} else {
$permalink = site_url('wp-login.php');
}
return esc_url(add_query_arg($args, $permalink), null, $context);
}
示例8: get_comments_queried_language
/**
* Get the language to filter a comments query
*
* @since 2.0
*
* @param object $query
* @return object|bool the language(s) to use in the filter, false otherwise
*/
protected function get_comments_queried_language($query)
{
// Don't filter comments if comment ids or post ids are specified
$plucked = wp_array_slice_assoc($query->query_vars, array('comment__in', 'parent', 'post_id', 'post__in', 'post_parent'));
$fields = array_filter($plucked);
if (!empty($fields)) {
return false;
}
// Don't filter comments if a non translated post type is specified
if (!empty($query->query_vars['post_type']) && !$this->model->is_translated_post_type($query->query_vars['post_type'])) {
return false;
}
return empty($query->query_vars['lang']) ? $this->curlang : $this->model->get_language($query->query_vars['lang']);
}
示例9: query
/**
* Run a search query.
*
* @since 1.5
* @uses apply_filters() geo_mashup_search_query_args Filter the geo query arguments.
*
* @param string|array $args Search parameters.
* @return array Search results.
**/
public function query($args)
{
$default_args = array('object_name' => 'post', 'object_ids' => null, 'exclude_object_ids' => null, 'units' => 'km', 'location_text' => '', 'radius' => null, 'sort' => 'distance_km ASC');
$this->query_vars = wp_parse_args($args, $default_args);
/** @var $units */
extract($this->query_vars);
$this->results = array();
$this->result_count = 0;
$this->result = null;
$this->current_result = -1;
$this->units = $units;
$this->max_km = 20000;
$this->distance_factor = 'km' == $units ? 1 : self::MILES_PER_KILOMETER;
$this->near_location = GeoMashupDB::blank_location(ARRAY_A);
$geo_query_args = wp_array_slice_assoc($this->query_vars, array('object_name', 'sort', 'exclude_object_ids', 'limit'));
if (!empty($near_lat) and !empty($near_lng)) {
$this->near_location['lat'] = $near_lat;
$this->near_location['lng'] = $near_lng;
} else {
if (!empty($location_text)) {
$geocode_text = empty($geolocation) ? $location_text : $geolocation;
if (!GeoMashupDB::geocode($geocode_text, $this->near_location)) {
// No search center was found, we can't continue
return $this->results;
}
} else {
// No coordinates to search near
return $this->results;
}
}
$radius_km = $this->max_km;
if (!empty($radius)) {
$radius_km = abs($radius) / $this->distance_factor;
}
$geo_query_args['radius_km'] = $radius_km;
$geo_query_args['near_lat'] = $this->near_location['lat'];
$geo_query_args['near_lng'] = $this->near_location['lng'];
if (isset($map_cat)) {
$geo_query_args['map_cat'] = $map_cat;
}
$geo_query_args = apply_filters('geo_mashup_search_query_args', $geo_query_args);
$this->results = GeoMashupDB::get_object_locations($geo_query_args);
$this->result_count = count($this->results);
if ($this->result_count > 0) {
$this->max_km = $this->results[$this->result_count - 1]->distance_km;
} else {
$this->max_km = $radius_km;
}
return $this->results;
}
示例10: __construct
/**
* Build it.
*
* @uses wp_array_slice_assoc()
* @uses wp_parse_args()
*
* @since 1.0.0
*
* @param array $args The array of arguments.
*/
public function __construct($args = array())
{
if (!isset($args['api_key'], $args['latitude'], $args['longitude'])) {
return false;
}
// Limit the arguments keys listed in the default array, then parse the submitted arguments
$limit_keys = array_keys($this->defaults);
$args = wp_array_slice_assoc($args, $limit_keys);
$this->args = wp_parse_args($args, $this->defaults);
// Build the query arguments for the forecast url
$query = !empty($this->query) && is_array($this->query) ? '?' . http_build_query($this->query) : '';
// Build the request url
$this->request_url = self::API_ENDPOINT . esc_attr($this->api_key) . '/' . floatval($this->latitude) . ',' . floatval($this->longitude) . (is_null($this->time) ? '' : ',' . $this->time) . $query;
// Get and save the response
$this->response = $this->get_response($this->clear_cache);
}
示例11: gramm_list_authors
/**
* Custom List Users
*
* Custom function to generate a list of blog authors,
* built based on WordPress' native wp_list_users function.
*
* @since Grammatizator 0.6
*/
function gramm_list_authors($args = '')
{
// SET up variables
global $wpdb;
$defaults = array('orderby' => 'name', 'order' => 'ASC', 'role' => '', 'include' => array(), 'biolength' => 55, 'heading_tag' => 'h3', 'echo' => true);
$args = wp_parse_args($args, $defaults);
$return = '';
// GET data from database with database query
// Use this to get the paramenters we need for get_users() out of the default $args
$query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'role', 'include'));
// Used to request only an array of user IDs from get_users()
$query_args['fields'] = 'ids';
$authors = get_users($query_args);
// STEP through the data
foreach ($authors as $authorid) {
// GET individual user data and save in temporary variables
$author = get_userdata($authorid);
// First Last name
if ($author->first_name && $author->last_name) {
$name = "{$author->first_name} {$author->last_name}";
} else {
$name = $author->display_name;
}
// Bio
if (get_the_author_meta('description', $author->ID)) {
$bio = get_the_author_meta('description', $author->ID);
} else {
$bio = '';
}
// Twitter handle
if (get_the_author_meta('twitter', $author->ID)) {
$twit = '<p class="social-links"><a class="twitter" href="https://twitter.com/' . get_the_author_meta('twitter', $author->ID) . '" title="' . esc_attr(sprintf(__("%s on Twitter"), $author->display_name)) . '">@' . get_the_author_meta('twitter', $author->ID) . '</a></p>';
} else {
$twit = '';
}
// Link to users's posts
$authorlink = '<a class="fn" href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__("Posts by %s"), $author->display_name)) . '">' . $name . '</a>';
/* Test me INSIDE the loop */
// TESTHERE
// Image (get later)
// BUILD output
}
// End foreach loop
/* Test me OUTSIDE the loop too! */
// TESTHERE
// OUTPUT results
}
示例12: register
public static function register($args)
{
if (isset($args['name'])) {
if (strlen($args['name']) > 44) {
trigger_error(sprintf("Connection name '%s' is longer than 44 characters.", $args['name']), E_USER_WARNING);
return false;
}
} else {
trigger_error("Connection types without a 'name' parameter are deprecated.", E_USER_WARNING);
}
$args = wp_parse_args($args, array('name' => false, 'from_object' => 'post', 'to_object' => 'post', 'from' => 'post', 'to' => 'post', 'from_query_vars' => array(), 'to_query_vars' => array(), 'data' => array(), 'cardinality' => 'many-to-many', 'prevent_duplicates' => true, 'self_connections' => false, 'sortable' => false, 'title' => array(), 'from_labels' => '', 'to_labels' => '', 'reciprocal' => false));
$sides = array();
foreach (array('from', 'to') as $direction) {
$object = _p2p_pluck($args, $direction);
if ('user' == $object) {
$args[$direction . '_object'] = 'user';
} elseif ('attachment' == $object) {
$args[$direction . '_object'] = 'attachment';
}
if ('post' == $args[$direction . '_object']) {
$validated = array();
foreach ((array) $object as $ptype) {
if (!post_type_exists($ptype)) {
trigger_error("Post type '{$ptype}' is not defined.");
} else {
$validated[] = $ptype;
}
}
if (empty($validated)) {
$validated = array('post');
}
$args[$direction . '_query_vars']['post_type'] = $validated;
}
}
if (!$args['name']) {
$args['name'] = md5(serialize(array_values(wp_array_slice_assoc($args, array('from_object', 'to_object', 'from_query_vars', 'to_query_vars', 'data')))));
}
$args = apply_filters('p2p_connection_type_args', $args);
$ctype = new P2P_Connection_Type($args);
if (isset(self::$instances[$ctype->name])) {
trigger_error("Connection type '{$ctype->name}' is already defined.", E_USER_NOTICE);
}
self::$instances[$ctype->name] = $ctype;
return $ctype;
}
示例13: user_query
static function user_query($query)
{
if (!function_exists('get_current_screen')) {
return;
}
$current_screen = get_current_screen();
if ($current_screen && 'users' != $current_screen->id) {
return;
}
if (isset($query->_p2p_capture)) {
return;
}
// Don't overwrite existing P2P query
if (isset($query->query_vars['connected_type'])) {
return;
}
_p2p_append($query->query_vars, wp_array_slice_assoc($_GET, self::get_custom_qv()));
}
示例14: json
/**
* Gather the parameters passed to client JavaScript via JSON.
*
* @since 4.1.0
* @return array The array to be exported to the client as JSON.
*/
public function json()
{
$array = wp_array_slice_assoc((array) $this, array('id', 'title', 'description', 'priority', 'panel', 'type'));
$array['content'] = $this->get_content();
$array['active'] = $this->active();
$array['instanceNumber'] = $this->instance_number;
if ($this->panel) {
/* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */
$array['customizeAction'] = sprintf(__('Customizing ▸ %s', 'redux-framework'), esc_html($this->manager->get_panel($this->panel)->title));
} else {
$array['customizeAction'] = __('Customizing', 'redux-framework');
}
// BEGIN Redux Additions
$array['width'] = isset($this->section['customizer_width']) ? $this->section['customizer_width'] : '';
$array['icon'] = isset($this->section['icon']) && !empty($this->section['icon']) ? $this->section['icon'] : 'hide';
// EMD Redux Additions
return $array;
}
示例15: stt2extat_default_setting
function stt2extat_default_setting($option = '')
{
global $stt2extat_sanitize;
$args = $stt2extat_sanitize->sanitize();
switch ($option) {
case 'update':
return $args;
break;
case 'shortcode':
$default = array('text_header', 'html_heading', 'number', 'display', 'count', 'convert');
$args = wp_array_slice_assoc($args, $default);
return $args;
break;
default:
$args = apply_filters('stt2extat_default_settings', $args);
return $args;
break;
}
}