当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_filter_object_list函数代码示例

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


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

示例1: download_and_process_email_replies

 /**
  * Primary method for downloading and processing email replies
  */
 public function download_and_process_email_replies($connection_details)
 {
     imap_timeout(IMAP_OPENTIMEOUT, apply_filters('supportflow_imap_open_timeout', 5));
     $ssl = $connection_details['imap_ssl'] ? '/ssl' : '';
     $ssl = apply_filters('supportflow_imap_ssl', $ssl, $connection_details['imap_host']);
     $mailbox = "{{$connection_details['imap_host']}:{$connection_details['imap_port']}{$ssl}}";
     $inbox = "{$mailbox}{$connection_details['inbox']}";
     $archive_box = "{$mailbox}{$connection_details['archive']}";
     $imap_connection = imap_open($mailbox, $connection_details['username'], $connection_details['password']);
     $redacted_connection_details = $connection_details;
     $redacted_connection_details['password'] = '[redacted]';
     // redact the password to avoid unnecessarily exposing it in logs
     $imap_errors = imap_errors();
     SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $imap_connection ? __('Successfully opened IMAP connection.', 'supportflow') : __('Failed to open IMAP connection.', 'supportflow'), compact('redacted_connection_details', 'mailbox', 'imap_errors'));
     if (!$imap_connection) {
         return new WP_Error('connection-error', __('Error connecting to mailbox', 'supportflow'));
     }
     // Check to see if the archive mailbox exists, and create it if it doesn't
     $mailboxes = imap_getmailboxes($imap_connection, $mailbox, '*');
     if (!wp_filter_object_list($mailboxes, array('name' => $archive_box))) {
         imap_createmailbox($imap_connection, $archive_box);
     }
     // Make sure here are new emails to process
     $email_count = imap_num_msg($imap_connection);
     if ($email_count < 1) {
         SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('No new messages to process.', 'supportflow'), compact('mailboxes'));
         return false;
     }
     $emails = imap_search($imap_connection, 'ALL', SE_UID);
     $email_count = min($email_count, apply_filters('supportflow_max_email_process_count', 20));
     $emails = array_slice($emails, 0, $email_count);
     $processed = 0;
     // Process each new email and put it in the archive mailbox when done.
     foreach ($emails as $uid) {
         $email = new stdClass();
         $email->uid = $uid;
         $email->msgno = imap_msgno($imap_connection, $email->uid);
         $email->headers = imap_headerinfo($imap_connection, $email->msgno);
         $email->structure = imap_fetchstructure($imap_connection, $email->msgno);
         $email->body = $this->get_body_from_connection($imap_connection, $email->msgno);
         if (0 === strcasecmp($connection_details['username'], $email->headers->from[0]->mailbox . '@' . $email->headers->from[0]->host)) {
             $connection_details['password'] = '[redacted]';
             // redact the password to avoid unnecessarily exposing it in logs
             SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, __('Skipping message because it was sent from a SupportFlow account.', 'supportflow'), compact('email'));
             continue;
         }
         // @todo Confirm this a message we want to process
         $result = $this->process_email($imap_connection, $email, $email->msgno, $connection_details['username'], $connection_details['account_id']);
         // If it was successful, move the email to the archive
         if ($result) {
             imap_mail_move($imap_connection, $email->uid, $connection_details['archive'], CP_UID);
             $processed++;
         }
     }
     imap_close($imap_connection, CL_EXPUNGE);
     $status_message = sprintf(__('Processed %d emails', 'supportflow'), $processed);
     SupportFlow()->extend->logger->log('email_retrieve', __METHOD__, $status_message);
     return $status_message;
 }
开发者ID:nagyistoce,项目名称:supportflow,代码行数:62,代码来源:class-supportflow-email-replies.php

示例2: submenu_get_children_ids

function submenu_get_children_ids($id, $items)
{
    $ids = wp_filter_object_list($items, array('menu_item_parent' => $id), 'and', 'ID');
    foreach ($ids as $id) {
        $ids = array_merge($ids, submenu_get_children_ids($id, $items));
    }
    return $ids;
}
开发者ID:CityOfPrescott,项目名称:tabula-rasa_city-of-prescott,代码行数:8,代码来源:functions-site.php

示例3: get_context_labels

 /**
  * Return translated context labels
  *
  * @return array Context label translations
  */
 public function get_context_labels()
 {
     global $wp_post_types;
     $post_types = wp_filter_object_list($wp_post_types, array(), null, 'label');
     $post_types = array_diff_key($post_types, array_flip($this->get_excluded_post_types()));
     add_action('registered_post_type', array($this, '_registered_post_type'), 10, 2);
     return $post_types;
 }
开发者ID:azanebrain,项目名称:representme,代码行数:13,代码来源:class-connector-posts.php

示例4: has_tool

 /**
  * Whether the current page has any tools.
  *
  * @return bool
  */
 function has_tool()
 {
     $all_rules = dp_addthis_get_rules();
     $rule_contexts = array_unique(wp_filter_object_list($all_rules, '', 'and', 'context'));
     $current_contexts = dp_addthis_get_contexts();
     $has_contexts = array_intersect($rule_contexts, $current_contexts);
     return !empty($has_contexts);
 }
开发者ID:demixpress,项目名称:dp-addthis,代码行数:13,代码来源:dp-addthis.php

示例5: get_context_labels

 public static function get_context_labels()
 {
     global $wp_post_types;
     $post_types = wp_filter_object_list($wp_post_types, array(), null, 'label');
     $post_types = array_diff_key($post_types, array_flip(self::get_ignored_post_types()));
     add_action('registered_post_type', array(__CLASS__, '_registered_post_type'), 10, 2);
     return $post_types;
 }
开发者ID:HasClass0,项目名称:mainwp-child-reports,代码行数:8,代码来源:posts.php

示例6: wp_event_calendar_allowed_post_types

/**
 * Return an array of the post types that calendars are available on
 *
 * You can filter this to enable a post calendar for just about any kind of
 * post type with an interface.
 *
 * @since 0.1.0
 *
 * @return array
 */
function wp_event_calendar_allowed_post_types()
{
    global $_wp_post_type_features;
    // Get which post types support events
    $supports = wp_filter_object_list($_wp_post_type_features, array('events' => true));
    $types = array_keys($supports);
    // Filter & return
    return apply_filters('wp_event_calendar_allowed_post_types', $types, $supports);
}
开发者ID:stuttter,项目名称:wp-event-calendar,代码行数:19,代码来源:functions.php

示例7: get_children

 /**
  * Get all children
  */
 function get_children($parent, $items)
 {
     $children = wp_filter_object_list($items, array('menu_item_parent' => $parent->ID));
     if (0 === count($children)) {
         return array();
     }
     foreach ($children as $child) {
         $children = array_merge($children, $this->get_children($child, $items));
     }
     return $children;
 }
开发者ID:trendwerk,项目名称:widget-submenu,代码行数:14,代码来源:class-tp-submenu.php

示例8: findActiveDepth

 private function findActiveDepth($childItem, $parentItem, $allItems)
 {
     $depth = 0;
     while ($childItem->menu_item_parent) {
         $depth++;
         if ($childItem->menu_item_parent == $parentItem->ID) {
             return $depth;
         }
         $childItems = wp_filter_object_list($allItems, array('ID' => $childItem->menu_item_parent));
         $childItem = array_pop($childItems);
     }
 }
开发者ID:trendwerk,项目名称:post-type-menu-highlight,代码行数:12,代码来源:Highlight.php

示例9: test_orphan_nav_menu_item

 /**
  * @ticket 27113
  */
 function test_orphan_nav_menu_item()
 {
     // Create an orphan nav menu item
     $custom_item_id = wp_update_nav_menu_item(0, 0, array('menu-item-type' => 'custom', 'menu-item-title' => 'Wordpress.org', 'menu-item-link' => 'http://wordpress.org', 'menu-item-status' => 'publish'));
     // Confirm it saved properly
     $custom_item = wp_setup_nav_menu_item(get_post($custom_item_id));
     $this->assertEquals('Wordpress.org', $custom_item->title);
     // Update the orphan with an associated nav menu
     wp_update_nav_menu_item($this->menu_id, $custom_item_id, array('menu-item-title' => 'WordPress.org'));
     $menu_items = wp_get_nav_menu_items($this->menu_id);
     $custom_item = wp_filter_object_list($menu_items, array('db_id' => $custom_item_id));
     $custom_item = array_pop($custom_item);
     $this->assertEquals('WordPress.org', $custom_item->title);
 }
开发者ID:Benrajalu,项目名称:philRaj,代码行数:17,代码来源:nav-menu.php

示例10: get

 /**
  * Retrieve a list of registered modules.
  *
  * @since 1.1
  * @return array
  */
 public static function get(array $args = null, $operator = 'AND')
 {
     if (empty($args)) {
         return self::$modules;
     }
     $filtered = array();
     $count = count($args);
     foreach (self::$modules as $key => $obj) {
         $matched = 0;
         foreach ($args as $m_key => $m_value) {
             if (property_exists($obj, $m_key)) {
                 $obj_prop = $obj[$m_key];
                 if (is_array($obj_prop) && is_array($m_value)) {
                     $m_akey = wp_filter_object_list(array($obj_prop), $m_value, $operator);
                     if (!empty($m_akey)) {
                         $matched++;
                     }
                 } elseif ($obj_prop == $m_value) {
                     $matched++;
                 }
             }
         }
         $b = false;
         switch (strtoupper($operator)) {
             default:
             case 'AND':
                 $b = $matched == $count;
                 break;
             case 'OR':
                 $b = $matched > 0;
                 break;
             case 'NOT':
                 $b = $matched == 0;
                 break;
         }
         if ($b) {
             $filtered[$key] = $obj;
         }
     }
     return $filtered;
 }
开发者ID:emados,项目名称:Momtaz-Framework,代码行数:47,代码来源:modules.php

示例11: filter_menu_items

 public function filter_menu_items($menu_items, $form_id, $compact)
 {
     $form_meta = GFFormsModel::get_form_meta($form_id);
     $results_fields = $this->get_fields($form_meta);
     if (false === empty($results_fields)) {
         $form_id = $form_meta["id"];
         $link_class = "";
         if (rgget("page") == "gf_new_form") {
             $link_class = "gf_toolbar_disabled";
         } else {
             if (rgget("page") == "gf_entries" && rgget("view") == "gf_results_" . $this->_slug) {
                 $link_class = "gf_toolbar_active";
             }
         }
         $sub_menu_items = array();
         $sub_menu_items[] = array('label' => $this->_title, 'title' => __("View results generated by this form", "gravityforms"), 'link_class' => $link_class, 'url' => admin_url("admin.php?page=gf_entries&view=gf_results_{$this->_slug}&id={$form_id}"), 'capabilities' => $this->_capabilities);
         $duplicate_submenus = wp_filter_object_list(rgars($menu_items, "results/sub_menu_items"), array("label" => $sub_menu_items[0]["label"]));
         if (count($duplicate_submenus) > 0) {
             return $menu_items;
         }
         // If there's already a menu item with the key "results" then merge the two.
         if (isset($menu_items["results"])) {
             $existing_link_class = $menu_items["results"]["link_class"];
             $link_class == empty($existing_link_class) ? $link_class : $existing_link_class;
             $existing_capabilities = $menu_items["results"]["capabilities"];
             $merged_capabilities = array_merge($existing_capabilities, $this->_capabilities);
             $existing_sub_menu_items = $menu_items["results"]["sub_menu_items"];
             $merged_sub_menu_items = array_merge($existing_sub_menu_items, $sub_menu_items);
             $menu_items["results"]["link_class"] = $link_class;
             $menu_items["results"]["capabilities"] = $merged_capabilities;
             $menu_items["results"]["sub_menu_items"] = $merged_sub_menu_items;
             $menu_items["results"]["label"] = __("Results", "gravityforms");
         } else {
             // so far during the page cycle this is the only menu item for this key
             $menu_items["results"] = array('label' => $compact ? __("Results", "gravityforms") : $this->_title, 'title' => __("View results generated by this form", "gravityforms"), 'url' => "", 'onclick' => "return false;", 'menu_class' => 'gf_form_toolbar_results', 'link_class' => $link_class, 'capabilities' => $this->_capabilities, 'sub_menu_items' => $sub_menu_items, 'priority' => 750);
         }
     }
     return $menu_items;
 }
开发者ID:danaiser,项目名称:hollandLawns,代码行数:39,代码来源:class-gf-results.php

示例12: get_columns

 public function get_columns()
 {
     $posts_columns = array();
     $posts_columns['cb'] = '<input type="checkbox" />';
     $posts_columns['icon'] = '';
     /* translators: column name */
     $posts_columns['title'] = _x('File', 'column name');
     $posts_columns['author'] = __('Author');
     $taxonomies = get_taxonomies_for_attachments('objects');
     $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name');
     /**
      * Filter the taxonomy columns for attachments in the Media list table.
      *
      * @since 3.5.0
      *
      * @param array $taxonomies An array of registered taxonomies to show for attachments.
      * @param string $post_type The post type. Default 'attachment'.
      */
     $taxonomies = apply_filters('manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment');
     $taxonomies = array_filter($taxonomies, 'taxonomy_exists');
     foreach ($taxonomies as $taxonomy) {
         if ('category' == $taxonomy) {
             $column_key = 'categories';
         } elseif ('post_tag' == $taxonomy) {
             $column_key = 'tags';
         } else {
             $column_key = 'taxonomy-' . $taxonomy;
         }
         $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name;
     }
     /* translators: column name */
     if (!$this->detached) {
         $posts_columns['parent'] = _x('Uploaded to', 'column name');
         if (post_type_supports('attachment', 'comments')) {
             $posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__('Comments') . '" class="comment-grey-bubble"></span></span>';
         }
     }
     /* translators: column name */
     $posts_columns['date'] = _x('Date', 'column name');
     /**
      * Filter the Media list table columns.
      *
      * @since 2.5.0
      *
      * @param array $posts_columns An array of columns displayed in the Media list table.
      * @param bool $detached Whether the list table contains media not attached
      *                             to any posts. Default true.
      */
     $posts_columns = apply_filters('manage_media_columns', $posts_columns, $this->detached);
     return $posts_columns;
 }
开发者ID:ajspencer,项目名称:NCSSM-SG-WordPress,代码行数:51,代码来源:class-wp-media-list-table.php

示例13: update_confirmation

 public static function update_confirmation($form, $lead = null, $event = '')
 {
     if (!is_array(rgar($form, 'confirmations'))) {
         return $form;
     }
     if (!empty($event)) {
         $confirmations = wp_filter_object_list($form['confirmations'], array('event' => $event));
     } else {
         $confirmations = $form['confirmations'];
     }
     // if there is only one confirmation, don't bother with the conditional logic, just return it
     // this is here mostly to avoid the semi-costly GFFormsModel::create_lead() function unless we really need it
     if (is_array($form['confirmations']) && count($confirmations) <= 1) {
         $form['confirmation'] = reset($confirmations);
         return $form;
     }
     if (empty($lead)) {
         $lead = GFFormsModel::create_lead($form);
     }
     foreach ($confirmations as $confirmation) {
         if (rgar($confirmation, 'event') != $event) {
             continue;
         }
         if (rgar($confirmation, 'isDefault')) {
             continue;
         }
         if (isset($confirmation['isActive']) && !$confirmation['isActive']) {
             continue;
         }
         $logic = rgar($confirmation, 'conditionalLogic');
         if (GFCommon::evaluate_conditional_logic($logic, $form, $lead)) {
             $form['confirmation'] = $confirmation;
             return $form;
         }
     }
     $filtered_list = wp_filter_object_list($form['confirmations'], array('isDefault' => true));
     $form['confirmation'] = reset($filtered_list);
     return $form;
 }
开发者ID:timk85,项目名称:DIT,代码行数:39,代码来源:form_display.php

示例14: bbp_has_topics

/**
 * The main topic loop. WordPress makes this easy for us
 *
 * @since 2.0.0 bbPress (r2485)
 *
 * @param array $args All the arguments supported by {@link WP_Query}
 * @uses current_user_can() To check if the current user can edit other's topics
 * @uses bbp_get_topic_post_type() To get the topic post type
 * @uses WP_Query To make query and get the topics
 * @uses is_page() To check if it's a page
 * @uses bbp_is_single_forum() To check if it's a forum
 * @uses bbp_get_forum_id() To get the forum id
 * @uses bbp_get_paged() To get the current page value
 * @uses bbp_get_super_stickies() To get the super stickies
 * @uses bbp_get_stickies() To get the forum stickies
 * @uses bbp_use_pretty_urls() To check if the site is using pretty URLs
 * @uses get_permalink() To get the permalink
 * @uses add_query_arg() To add custom args to the url
 * @uses apply_filters() Calls 'bbp_topics_pagination' with the pagination args
 * @uses paginate_links() To paginate the links
 * @uses apply_filters() Calls 'bbp_has_topics' with
 *                        bbPres::topic_query::have_posts()
 *                        and bbPres::topic_query
 * @return object Multidimensional array of topic information
 */
function bbp_has_topics($args = array())
{
    /** Defaults **************************************************************/
    // Other defaults
    $default_topic_search = !empty($_REQUEST['ts']) ? $_REQUEST['ts'] : false;
    $default_show_stickies = (bool) (bbp_is_single_forum() || bbp_is_topic_archive()) && false === $default_topic_search;
    $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any';
    // Default argument array
    $default = array('post_type' => bbp_get_topic_post_type(), 'post_parent' => $default_post_parent, 'meta_key' => '_bbp_last_active_time', 'meta_type' => 'DATETIME', 'orderby' => 'meta_value', 'order' => 'DESC', 'posts_per_page' => bbp_get_topics_per_page(), 'paged' => bbp_get_paged(), 'show_stickies' => $default_show_stickies, 'max_num_pages' => false);
    // Only add 's' arg if searching for topics
    // See https://bbpress.trac.wordpress.org/ticket/2607
    if (!empty($default_topic_search)) {
        $default['s'] = $default_topic_search;
    }
    // What are the default allowed statuses (based on user caps)
    if (bbp_get_view_all()) {
        // Default view=all statuses
        $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id());
        // Add support for private status
        if (current_user_can('read_private_topics')) {
            $post_statuses[] = bbp_get_private_status_id();
        }
        // Join post statuses together
        $default['post_status'] = implode(',', $post_statuses);
        // Lean on the 'perm' query var value of 'readable' to provide statuses
    } else {
        $default['perm'] = 'readable';
    }
    // Maybe query for topic tags
    if (bbp_is_topic_tag()) {
        $default['term'] = bbp_get_topic_tag_slug();
        $default['taxonomy'] = bbp_get_topic_tag_tax_id();
    }
    /** Setup *****************************************************************/
    // Parse arguments against default values
    $r = bbp_parse_args($args, $default, 'has_topics');
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    $bbp->topic_query = new WP_Query($r);
    // Set post_parent back to 0 if originally set to 'any'
    if ('any' === $r['post_parent']) {
        $r['post_parent'] = 0;
    }
    // Limited the number of pages shown
    if (!empty($r['max_num_pages'])) {
        $bbp->topic_query->max_num_pages = $r['max_num_pages'];
    }
    /** Stickies **************************************************************/
    // Put sticky posts at the top of the posts array
    if (!empty($r['show_stickies']) && $r['paged'] <= 1) {
        // Get super stickies and stickies in this forum
        $stickies = bbp_get_super_stickies();
        // Get stickies for current forum
        if (!empty($r['post_parent'])) {
            $stickies = array_merge($stickies, bbp_get_stickies($r['post_parent']));
        }
        // Remove any duplicate stickies
        $stickies = array_unique($stickies);
        // We have stickies
        if (is_array($stickies) && !empty($stickies)) {
            // Start the offset at -1 so first sticky is at correct 0 offset
            $sticky_offset = -1;
            // Loop over topics and relocate stickies to the front.
            foreach ($stickies as $sticky_index => $sticky_ID) {
                // Get the post offset from the posts array
                $post_offsets = wp_filter_object_list($bbp->topic_query->posts, array('ID' => $sticky_ID), 'OR', 'ID');
                // Continue if no post offsets
                if (empty($post_offsets)) {
                    continue;
                }
                // Loop over posts in current query and splice them into position
                foreach (array_keys($post_offsets) as $post_offset) {
                    $sticky_offset++;
                    $sticky = $bbp->topic_query->posts[$post_offset];
//.........这里部分代码省略.........
开发者ID:joeyblake,项目名称:bbpress,代码行数:101,代码来源:template.php

示例15: settings_page_output

    /**
     * Output HTML for the settings page
     * Called from add_options_page
     */
    function settings_page_output()
    {
        $arr_settings_tabs = $this->getSettingsTabs();
        ?>
		<div class="wrap">

			<h1 class="SimpleHistoryPageHeadline">
				<div class="dashicons dashicons-backup SimpleHistoryPageHeadline__icon"></div>
				<?php 
        _e("Simple History Settings", "simple-history");
        ?>
			</h1>

			<?php 
        $active_tab = isset($_GET["selected-tab"]) ? $_GET["selected-tab"] : "settings";
        $settings_base_url = menu_page_url(SimpleHistory::SETTINGS_MENU_SLUG, 0);
        ?>

			<h2 class="nav-tab-wrapper">
				<?php 
        foreach ($arr_settings_tabs as $one_tab) {
            $tab_slug = $one_tab["slug"];
            printf('<a href="%3$s" class="nav-tab %4$s">%1$s</a>', $one_tab["name"], $tab_slug, esc_url(add_query_arg("selected-tab", $tab_slug, $settings_base_url)), $active_tab == $tab_slug ? "nav-tab-active" : "");
        }
        ?>
			</h2>

			<?php 
        // Output contents for selected tab
        $arr_active_tab = wp_filter_object_list($arr_settings_tabs, array("slug" => $active_tab));
        $arr_active_tab = current($arr_active_tab);
        // We must have found an active tab and it must have a callable function
        if (!$arr_active_tab || !is_callable($arr_active_tab["function"])) {
            wp_die(__("No valid callback found", "simple-history"));
        }
        $args = array("arr_active_tab" => $arr_active_tab);
        call_user_func_array($arr_active_tab["function"], $args);
        ?>

		</div>
		<?php 
    }
开发者ID:ConductiveIO,项目名称:mbrady,代码行数:46,代码来源:SimpleHistory.php


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