• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP papi_to_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: set_driver_alias

 /**
  * Set driver alias.
  */
 protected function set_driver_alias()
 {
     foreach (papi_to_array($this->alias) as $alias) {
         if (is_string($alias) && !$this->porter->exists('driver.' . $alias)) {
             $this->set_driver_name($alias);
         }
     }
 }
开发者ID:ekandreas,项目名称:papi,代码行数:11,代码来源:class-papi-porter-driver.php


示例17: fire_filter

 /**
  * Fire filter.
  *
  * @param  array $options
  *
  * @throws Exception if `filter` is missing from options array.
  * @throws Exception if `value` is missing from options array.
  *
  * @return mixed
  */
 public function fire_filter(array $options)
 {
     if (!isset($options['type'])) {
         $options['type'] = 'after';
     }
     if (!isset($options['filter'])) {
         throw new Exception('Missing `filter` in options array.');
     }
     if (!isset($options['value'])) {
         throw new Exception('Missing `value` in options array.');
     }
     $arguments = [$this->driver->filter($options['type'], $options['filter'])];
     $value = $options['value'];
     foreach (papi_to_array($value) as $val) {
         $arguments[] = $val;
     }
     return call_user_func_array('apply_filters', $arguments);
 }
开发者ID:wp-papi,项目名称:papi,代码行数:28,代码来源:class-papi-porter.php


示例18: papi_sort_order

/**
 * Sort array based on given key and numeric value.
 *
 * @param  array  $array
 * @param  string $key
 *
 * @return array
 */
function papi_sort_order($array, $key = 'sort_order')
{
    if (empty($array) || !is_array($array) && !is_object($array)) {
        return [];
    }
    if (is_object($array)) {
        $array = papi_to_array($array);
    }
    $sorter = [];
    foreach ($array as $k => $value) {
        $value = is_array($value) ? (object) $value : $value;
        if (is_object($value) && isset($value->{$key})) {
            $sorter[$k] = $value->{$key};
            continue;
        }
    }
    $i = 0;
    $default_sort = papi_filter_settings_sort_order();
    foreach ($sorter as $k => $v) {
        if ($default_sort === $v) {
            $sorter[$k] = $v - $i;
            $i++;
        }
    }
    asort($sorter, SORT_NUMERIC);
    $result = [];
    foreach ($sorter as $k => $v) {
        $value = $array[$k];
        $value = is_array($value) ? (object) $value : $value;
        if (is_object($value) && isset($value->{$key})) {
            $result[$k] = $array[$k];
        }
    }
    return array_values($result);
}
开发者ID:ekandreas,项目名称:papi,代码行数:43,代码来源:utilities.php


示例19: papi_update_property_meta_value

/**
 * Update property values on the post with the given post id
 * or update property values on the option page.
 *
 * @param  array $meta
 *
 * @return bool
 */
function papi_update_property_meta_value(array $meta = [])
{
    $meta = array_merge(['post_id' => 0, 'slug' => '', 'type' => Papi_Post_Page::TYPE, 'value' => ''], $meta);
    $meta = (object) $meta;
    $option = $meta->type === 'option' || papi_is_option_page();
    $save_value = true;
    foreach (papi_to_array($meta->value) as $key => $value) {
        if (is_string($key)) {
            $save_value = false;
            break;
        }
    }
    if (!$save_value && is_array($meta->value)) {
        $meta->value = [$meta->value];
    }
    if (papi_is_empty($meta->value)) {
        return papi_delete_property_meta_value($meta->post_id, $meta->slug, $meta->type);
    }
    $result = true;
    foreach (papi_to_array($meta->value) as $key => $value) {
        papi_cache_delete($meta->slug, $meta->post_id);
        if (!is_array($value)) {
            if ($save_value) {
                $value = $meta->value;
            }
            if ($option) {
                $out = update_option(unpapify($meta->slug), $value);
                $result = $out ? $result : $out;
            } else {
                $out = update_post_meta($meta->post_id, unpapify($meta->slug), $value);
                $result = $out ? $result : $out;
            }
            continue;
        }
        foreach ($value as $child_key => $child_value) {
            if (papi_is_empty($child_value)) {
                papi_delete_property_meta_value($meta->post_id, $child_key, $meta->type);
            } else {
                if ($option) {
                    update_option(unpapify($child_key), $child_value);
                } else {
                    update_post_meta($meta->post_id, unpapify($child_key), $child_value);
                }
            }
        }
    }
    return $result;
}
开发者ID:ekandreas,项目名称:papi,代码行数:56,代码来源:property.php


示例20: parse_term_args

 /**
  * Parse term query arguments.
  *
  * @param  array $args
  *
  * @return array
  */
 protected function parse_term_args(array $args)
 {
     if (isset($args['taxonomy_type'])) {
         $args['entry_type'] = $args['taxonomy_type'];
         unset($args['taxonomy_type']);
     }
     $entry_type = papi_get_entry_type_by_id($args['entry_type']);
     if ($entry_type instanceof Papi_Taxonomy_Type) {
         $args['taxonomy'] = papi_to_array($entry_type->taxonomy);
     } else {
         $args['taxonomy'] = isset($args['taxonomy']) ? $args['taxonomy'] : '';
     }
     return $args;
 }
开发者ID:nlemoine,项目名称:papi,代码行数:21,代码来源:class-papi-query.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP par_pagenavi函数代码示例发布时间:2022-05-15
下一篇:
PHP papi_render_html_tag函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap