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


PHP papi_to_array函数代码示例

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


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

示例1: get_posts

 /**
  * Get posts.
  *
  * @param  stdClass $settings
  *
  * @return array
  */
 protected function get_posts($settings)
 {
     // By default we add posts per page key with the value -1 (all).
     if (!isset($settings->query['posts_per_page'])) {
         $settings->query['posts_per_page'] = -1;
     }
     // Prepare arguments for WP_Query.
     $args = array_merge($settings->query, ['post_type' => papi_to_array($settings->post_type), 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false]);
     $query = new WP_Query($args);
     $posts = $query->get_posts();
     // Keep only objects.
     $posts = papi_get_only_objects($posts);
     $results = [];
     // Set labels.
     foreach ($posts as $post) {
         $obj = get_post_type_object($post->post_type);
         if (empty($obj)) {
             continue;
         }
         if (!isset($results[$obj->labels->menu_name])) {
             $results[$obj->labels->menu_name] = [];
         }
         $results[$obj->labels->menu_name][] = $post;
     }
     return $results;
 }
开发者ID:ekandreas,项目名称:papi,代码行数:33,代码来源:class-papi-property-post.php

示例2: mce_buttons

 /**
  * Filter TinyMCE buttons (Visual tab).
  *
  * @param  array $buttons
  *
  * @return array
  */
 public function mce_buttons(array $buttons = [])
 {
     if ($new = papi_to_array($this->get_setting(current_filter(), []))) {
         return $new;
     }
     return $buttons;
 }
开发者ID:wp-papi,项目名称:papi,代码行数:14,代码来源:class-papi-property-editor.php

示例3: register_papi_directory

/**
 * Register Papi directory.
 *
 * @param  array|string $directory
 *
 * @return bool
 */
function register_papi_directory($directory)
{
    // Bail if not a array or string.
    if (!is_array($directory) && !is_string($directory)) {
        return false;
    }
    // Bail if directory don't exists.
    if (is_string($directory) && (!file_exists($directory) || !is_dir($directory))) {
        return false;
    }
    // Add directory to directories filter.
    return add_filter('papi/settings/directories', function ($directories) use($directory) {
        $directories = is_string($directories) ? [$directories] : $directories;
        $directories = is_array($directories) ? $directories : [];
        // Create a array of directory.
        $directory = papi_to_array($directory);
        // Check if directory exists before adding it.
        foreach ($directory as $index => $dir) {
            if (!file_exists($dir) || !is_dir($dir)) {
                unset($directory[$index]);
            }
        }
        return array_merge($directories, $directory);
    });
}
开发者ID:wp-papi,项目名称:papi,代码行数:32,代码来源:io.php

示例4: get_settings_properties

 /**
  * Get settings properties.
  *
  * @return array
  */
 protected function get_settings_properties()
 {
     $settings = $this->get_settings();
     if (is_null($settings)) {
         return [];
     }
     return array_filter(papi_to_array($settings->items), 'papi_is_property');
 }
开发者ID:wp-papi,项目名称:papi,代码行数:13,代码来源:class-papi-property-group.php

示例5: papi_get_taxonomies

/**
 * Get all taxonomies Papi should work with.
 *
 * @return array
 */
function papi_get_taxonomies()
{
    $taxonomies = [];
    $entry_types = papi_get_all_entry_types(['types' => 'taxonomy']);
    foreach ($entry_types as $entry_type) {
        $taxonomies = array_merge($taxonomies, papi_to_array($entry_type->taxonomy));
    }
    return array_unique($taxonomies);
}
开发者ID:nlemoine,项目名称:papi,代码行数:14,代码来源:taxonomy.php

示例6: get_items

 /**
  * Get users as dropdown items.
  *
  * @return array
  */
 public function get_items()
 {
     $capabilities = papi_to_array($this->get_setting('capabilities'));
     $users = get_users();
     $items = [];
     foreach ($users as $user) {
         $allcaps = $user->allcaps;
         if (count(array_diff($capabilities, array_keys($allcaps))) === 0) {
             $items[$user->display_name] = $user->ID;
         }
     }
     return $items;
 }
开发者ID:KristoferN,项目名称:papi,代码行数:18,代码来源:class-papi-property-user.php

示例7: html

 /**
  * Render property html.
  */
 public function html()
 {
     $settings = $this->get_settings();
     $value = papi_cast_string_value($this->get_value());
     // Override selected setting with
     // database value if not empty.
     if (!papi_is_empty($value)) {
         $settings->selected = $value;
     }
     $settings->selected = papi_to_array($settings->selected);
     foreach ($settings->items as $key => $value) {
         $key = is_numeric($key) ? $value : $key;
         papi_render_html_tag('label', ['class' => 'light', 'for' => $this->html_id($key), papi_html_tag('input', ['checked' => in_array($value, $settings->selected) ? 'checked' : null, 'id' => $this->html_id($key), 'name' => $this->html_name() . '[]', 'type' => 'checkbox', 'value' => $value]), papi_convert_to_string($key)]);
         papi_render_html_tag('br');
     }
 }
开发者ID:ekandreas,项目名称:papi,代码行数:19,代码来源:class-papi-property-checkbox.php

示例8: html

 /**
  * Render property html.
  */
 public function html()
 {
     $settings = $this->get_settings();
     $value = papi_cast_string_value($this->get_value());
     // Override selected setting with
     // database value if not empty.
     if (!papi_is_empty($value)) {
         $settings->selected = $value;
     }
     $settings->selected = papi_to_array($settings->selected);
     echo '<div class="papi-property-checkbox">';
     foreach ($settings->items as $key => $value) {
         $key = is_numeric($key) ? $value : $key;
         papi_render_html_tag('p', [papi_html_tag('label', ['class' => 'light', 'for' => esc_attr($this->html_id($key)), papi_html_tag('input', ['id' => esc_attr($this->html_id($key)), 'name' => esc_attr($this->html_name()) . '[]', 'type' => 'hidden']), papi_html_tag('input', ['checked' => in_array($value, $settings->selected, true), 'id' => esc_attr($this->html_id($key)), 'name' => esc_attr($this->html_name()) . '[]', 'type' => 'checkbox', 'value' => esc_attr($value)]), esc_html(papi_convert_to_string($key))])]);
     }
     echo '</div>';
 }
开发者ID:wp-papi,项目名称:papi,代码行数:20,代码来源:class-papi-property-checkbox.php

示例9: get_settings_layouts

 /**
  * Get layouts.
  *
  * @return array
  */
 protected function get_settings_layouts()
 {
     $settings = $this->get_settings();
     return $this->prepare_properties(papi_to_array($settings->items));
 }
开发者ID:nlemoine,项目名称:papi,代码行数:10,代码来源:class-papi-property-flexible.php

示例10: setup_post_types

 /**
  * Setup post types array.
  */
 protected function setup_post_types()
 {
     $this->post_type = papi_to_array($this->post_type);
     // Set a default value to post types array
     // if we don't have a array or a empty array.
     if (empty($this->post_type)) {
         $this->post_type = ['page'];
     }
     if (count($this->post_type) === 1 && $this->post_type[0] === 'any') {
         $this->post_type = get_post_types('', 'names');
         $this->post_type = array_values($this->post_type);
     }
 }
开发者ID:wp-papi,项目名称:papi,代码行数:16,代码来源:class-papi-page-type.php

示例11: papi_get_post_types

/**
 * Get all post types Papi should work with.
 *
 * @return array
 */
function papi_get_post_types()
{
    $page_types = papi_get_all_page_types(true);
    $post_types = [];
    foreach ($page_types as $page_type) {
        $post_types = array_merge($post_types, papi_to_array($page_type->post_type));
    }
    if (empty($post_types)) {
        return ['page'];
    }
    return array_unique($post_types);
}
开发者ID:KristoferN,项目名称:papi,代码行数:17,代码来源:page.php

示例12: remove

 /**
  * Remove post type support. Runs once, on page load.
  *
  * @param array $post_type_supports
  */
 protected function remove($post_type_supports = [])
 {
     $this->post_type_supports = array_merge($this->post_type_supports, papi_to_array($post_type_supports));
 }
开发者ID:KristoferN,项目名称:papi,代码行数:9,代码来源:class-papi-page-type.php

示例13: populate_post_type

 /**
  * Populate post type.
  *
  * @param  array|string $post_type
  *
  * @return string
  */
 private function populate_post_type($post_type)
 {
     $post_id = papi_get_post_id();
     if ($post_id !== 0) {
         return get_post_type($post_id);
     }
     // Get the post type that we currently are on if it exist in the array of post types.
     $post_type = array_filter(papi_to_array($post_type), function ($post_type) {
         // Support fake post types.
         if (strpos($post_type, '_papi') !== false) {
             return true;
         }
         return !empty($post_type) && strtolower($post_type) === strtolower(papi_get_or_post('post_type'));
     });
     if (!empty($post_type)) {
         return $post_type[0];
     }
     return 'page';
 }
开发者ID:KristoferN,项目名称:papi,代码行数:26,代码来源:class-papi-admin-meta-box.php

示例14: setup_options

 /**
  * Setup property options.
  *
  * @param  mixed $options
  *
  * @return mixed
  */
 private function setup_options($options = [])
 {
     // When a object is sent in, just return it.
     if (is_object($options)) {
         return $options;
     }
     // Only arrays can be handled.
     if (!is_array($options)) {
         $options = [];
     }
     // Merge default options with the given options array.
     $options = array_merge($this->default_options, $options);
     $options = (object) $options;
     // Capabilities should be a array.
     $options->capabilities = papi_to_array($options->capabilities);
     // Setup property slug.
     $options->slug = $this->setup_options_slug($options);
     // Setup property settings.
     $options->settings = $this->setup_options_settings($options);
     // Type should always be lowercase.
     $options->type = strtolower($options->type);
     // Escape all options except those that are send it as second argument.
     return papi_esc_html($options, ['before_html', 'html', 'after_html']);
 }
开发者ID:nlemoine,项目名称:papi,代码行数:31,代码来源:class-papi-core-property.php

示例15: setup_post_types

 /**
  * Setup post types array.
  */
 private function setup_post_types()
 {
     $this->post_type = papi_to_array($this->post_type);
     // Set a default value to post types array
     // if we don't have a array or a empty array.
     if (empty($this->post_type)) {
         $this->post_type = ['page'];
     }
 }
开发者ID:KristoferN,项目名称:papi,代码行数:12,代码来源:class-papi-page-type-meta.php


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