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


PHP papi_is_property函数代码示例

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


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

示例1: papi_template

/**
 * Load a template array file and merge values with it.
 *
 * @param  string $file
 * @param  array $values
 * @param  bool $convert_to_object
 *
 * @return array
 */
function papi_template($file, $values = [], $convert_to_object = false)
{
    if (!is_string($file) || empty($file)) {
        return [];
    }
    $filepath = papi_get_file_path($file);
    if (empty($filepath) && is_file($file)) {
        $filepath = $file;
    }
    if (empty($filepath) || !file_exists($filepath) || is_dir($filepath)) {
        return [];
    }
    $template = (require $filepath);
    if (papi_is_property($template)) {
        foreach ($values as $key => $value) {
            $template->set_option($key, $value);
        }
        $result = $template;
    } else {
        $result = array_merge((array) $template, $values);
    }
    if ($convert_to_object) {
        return (object) $result;
    }
    return $result;
}
开发者ID:ekandreas,项目名称:papi,代码行数:35,代码来源:template.php

示例2: convert

 /**
  * Convert property value with the property type converter.
  *
  * @param  string $slug
  * @param  mixed  $value
  *
  * @return mixed
  */
 protected function convert($slug, $value)
 {
     $property = $this->get_property($slug);
     // If no property type is found, just return null.
     if (!papi_is_property($property)) {
         return;
     }
     if (papi_is_empty($value)) {
         if (!papi_is_empty($property->get_option('value'))) {
             return $property->get_option('value');
         }
         return;
     }
     // A property need to know about the page.
     $property->set_page($this);
     // Run load value method right after the value has been loaded from the database.
     $value = $property->load_value($value, $slug, $this->id);
     $value = papi_filter_load_value($property->type, $value, $slug, $this->id);
     // Format the value from the property class.
     $value = $property->format_value($value, $slug, $this->id);
     // Only fired when not in admin.
     if (!is_admin()) {
         $value = papi_filter_format_value($property->type, $value, $slug, $this->id);
     }
     if (is_array($value)) {
         $value = array_filter($value);
     }
     return $value;
 }
开发者ID:ekandreas,项目名称:papi,代码行数:37,代码来源:class-papi-core-page.php

示例3: prepare_rules

 /**
  * Prepare rules.
  *
  * @param  array $rules
  * @param  Papi_Core_Property $property
  *
  * @return array
  */
 public function prepare_rules(array $rules, $property = null)
 {
     if (!isset($rules['relation'])) {
         $rules['relation'] = 'OR';
     } else {
         $rules['relation'] = strtoupper($rules['relation']);
     }
     foreach ($rules as $index => $value) {
         if (is_string($index)) {
             continue;
         }
         if (is_array($value)) {
             $rules[$index] = new Papi_Core_Conditional_Rule($value);
             if (strpos($rules[$index]->slug, '.') === false && papi_is_property($property)) {
                 $rules[$index]->slug = $this->get_rule_slug($rules[$index], $property);
             }
         }
     }
     return $rules;
 }
开发者ID:wp-papi,项目名称:papi,代码行数:28,代码来源:class-papi-core-conditional.php

示例4: prepare_properties_data

 /**
  * Prepare properties data for saving.
  *
  * @param  array $data
  * @param  int   $post_id
  *
  * @return array
  */
 protected function prepare_properties_data(array $data = [], $post_id = 0)
 {
     // Since we are storing witch property it is in the $data array
     // we need to remove that and set the property type to the property
     // and make a array of the property type and the value.
     foreach ($data as $key => $value) {
         $property_type_key = papi_get_property_type_key();
         if (strpos($key, $property_type_key) === false) {
             continue;
         }
         $property_key = str_replace($property_type_key, '', $key);
         // Check if value exists.
         if (isset($data[$property_key])) {
             $data[$property_key] = ['type' => $value, 'value' => $data[$property_key]];
         }
         unset($data[$key]);
     }
     foreach ($data as $key => $item) {
         $property = papi_get_property_type($item['type']);
         unset($data[$key]);
         if (papi_is_property($property)) {
             // Run `update_value` method on the property class.
             $data[$key] = $property->update_value($item['value'], papi_remove_papi($key), $post_id);
             // Apply `update_value` filter so this can be changed from the theme for specified property type.
             $data[$key] = papi_filter_update_value($item['type']->type, $data[$key], papi_remove_papi($key), $post_id);
             if ($item['type']->overwrite) {
                 $slug = papi_remove_papi($key);
                 $this->overwrite[$slug] = $data[$key];
             }
         }
     }
     return $data;
 }
开发者ID:KristoferN,项目名称:papi,代码行数:41,代码来源:class-papi-core-data-handler.php

示例5: get_properties

 /**
  * Get properties via POST.
  *
  * POST /papi-ajax/?action=get_properties
  */
 public function get_properties()
 {
     if (!papi_get_sanitized_post('properties')) {
         $this->render_error('No properties found');
         return;
     }
     $items = json_decode(stripslashes($_POST['properties']), true);
     if (empty($items) || !is_array($items)) {
         $this->render_error('No properties found');
         return;
     }
     foreach ($items as $key => $item) {
         $property = papi_property((array) $item);
         if (!papi_is_property($property)) {
             unset($items[$key]);
             continue;
         }
         ob_start();
         $property->render_ajax_request();
         $items[$key] = trim(ob_get_clean());
     }
     $items = array_filter($items);
     if (empty($items)) {
         $this->render_error('No properties found');
     } else {
         wp_send_json(['html' => $items]);
     }
 }
开发者ID:ekandreas,项目名称:papi,代码行数:33,代码来源:class-papi-admin-ajax.php

示例6: papi_required_html

/**
 * Get require tag for property.
 *
 * @param  stdClass $property
 * @param  bool     $text
 *
 * @return string
 */
function papi_required_html($property, $text = false)
{
    if (!papi_is_property($property) || !$property->required) {
        return '';
    }
    return ' <span class="papi-rq" data-property-name="' . $property->title . '" data-property-id="' . $property->slug . '">' . ($text ? papi_require_text($property) : '*') . '</span>';
}
开发者ID:wp-papi,项目名称:papi,代码行数:15,代码来源:property.php

示例7: prepare_property_for_json

 /**
  * Prepare property for JSON.
  *
  * @param  Papi_Property $property
  *
  * @return bool|object
  */
 protected function prepare_property_for_json($property)
 {
     // Only real property objects and not properties that are disabled.
     if (!papi_is_property($property) || $property->disabled()) {
         return false;
     }
     $options = clone $property->get_options();
     if (isset($options->settings->items)) {
         foreach ($options->settings->items as $index => $property) {
             if (is_array($property) && isset($property['items'])) {
                 foreach ($property['items'] as $child_index => $child_property) {
                     $options->settings->items[$index]['items'][$child_index] = $this->prepare_property_for_json($child_property);
                 }
             }
             if ($property = $this->prepare_property_for_json($property)) {
                 $options->settings->items[$index] = $property;
             }
         }
     }
     return $options;
 }
开发者ID:nlemoine,项目名称:papi,代码行数:28,代码来源:class-papi-property-repeater.php

示例8: get_property_option

 /**
  * Get property option or default value.
  *
  * @param  string $slug
  * @param  string $option
  * @param  mixed  $default
  *
  * @return bool
  */
 public function get_property_option($slug, $option, $default = null)
 {
     $slug = unpapify($slug);
     $property = $this->property($slug);
     // If no property type is found, return default
     // value since we don't have a property.
     if (!papi_is_property($property)) {
         return $default;
     }
     $value = $property->get_option($option);
     if (papi_is_empty($value)) {
         return $default;
     }
     return $value;
 }
开发者ID:nlemoine,项目名称:papi,代码行数:24,代码来源:class-papi-core-meta-store.php

示例9: get_property

 /**
  * Get property from entry type.
  *
  * @param  string $slug
  * @param  string $child_slug
  *
  * @return Papi_Property
  */
 public function get_property($slug, $child_slug = '')
 {
     $boxes = $this->get_boxes();
     $parts = preg_split('/\\[\\d+\\]/', $slug);
     $parts = array_map(function ($part) {
         return preg_replace('/(\\[|\\])/', '', $part);
     }, $parts);
     if (count($parts) > 1) {
         $property = null;
         for ($i = 0, $l = count($parts); $i < $l; $i++) {
             $child = isset($parts[$i + 1]) ? $parts[$i + 1] : '';
             $property = $this->get_property($parts[$i], $child);
             if (isset($parts[$i + 1])) {
                 $i++;
             }
         }
         /**
          * Modify property.
          *
          * @param  Papi_Core_Property $property
          */
         return apply_filters('papi/get_property', $property);
     }
     foreach ($boxes as $box) {
         foreach ($box->properties as $property) {
             $property = papi_get_property_type($property);
             if (papi_is_property($property) && $property->match_slug($slug)) {
                 if (empty($child_slug)) {
                     /**
                      * Modify property.
                      *
                      * @param  Papi_Core_Property $property
                      */
                     return apply_filters('papi/get_property', $property);
                 }
                 $property = $property->get_child_property($child_slug);
                 if (papi_is_property($property)) {
                     /**
                      * Modify property.
                      *
                      * @param  Papi_Core_Property $property
                      */
                     return apply_filters('papi/get_property', $property);
                 }
             }
         }
     }
 }
开发者ID:nlemoine,项目名称:papi,代码行数:56,代码来源:class-papi-entry-type.php

示例10: prepare_properties_data

 /**
  * Prepare properties data for saving.
  *
  * @param  array $data
  * @param  int   $post_id
  *
  * @return array
  */
 protected function prepare_properties_data(array $data = [], $post_id = 0)
 {
     // Since we are storing witch property it is in the `$data` array
     // we need to remove that and set the property type to the property
     // and make a array of the property type and the value.
     foreach ($data as $key => $value) {
         if (papi_is_property_type_key($key)) {
             continue;
         }
         $property_type_key = papify(papi_get_property_type_key($key));
         // Check if value exists.
         if (!isset($data[$key]) && !isset($data[$property_type_key])) {
             continue;
         }
         // Pair property value with property type object.
         $data[$key] = ['type' => $data[$property_type_key], 'value' => $value];
         // Remove property type object since it's not needed anymore.
         unset($data[$property_type_key]);
     }
     foreach ($data as $key => $item) {
         if (papi_is_property_type_key($key)) {
             continue;
         }
         $property = papi_get_property_type($item['type']);
         unset($data[$key]);
         if (papi_is_property($property)) {
             // Run `update_value` method on the property class.
             $data[$key] = $property->update_value($item['value'], unpapify($key), $post_id);
             // Apply `update_value` filter so this can be changed from
             // the theme for specified property type.
             $data[$key] = papi_filter_update_value($item['type']->type, $data[$key], unpapify($key), $post_id, papi_get_meta_type());
             if ($item['type']->overwrite) {
                 $slug = unpapify($key);
                 $this->overwrite[$slug] = $data[$key];
                 unset($data[$key]);
             }
         }
     }
     return $data;
 }
开发者ID:wp-papi,项目名称:papi,代码行数:48,代码来源:class-papi-core-data-handler.php

示例11: get_property

 /**
  * Get property from page type.
  *
  * @param  string $slug
  * @param  string $child_slug
  *
  * @return null|Papi_Property
  */
 public function get_property($slug, $child_slug = '')
 {
     $boxes = $this->get_boxes();
     $parts = preg_split('/\\[\\d+\\]/', $slug);
     $parts = array_map(function ($part) {
         return preg_replace('/(\\[|\\])/', '', $part);
     }, $parts);
     if (count($parts) > 1) {
         $property = null;
         for ($i = 0, $l = count($parts); $i < $l; $i++) {
             $child = isset($parts[$i + 1]) ? $parts[$i + 1] : '';
             $property = $this->get_property($parts[$i], $child);
             if (isset($parts[$i + 1])) {
                 $i++;
             }
         }
         return $property;
     }
     if (empty($boxes)) {
         return;
     }
     foreach ($boxes as $box) {
         $properties = isset($box[1][0]->properties) ? $box[1][0]->properties : $box[1];
         foreach ($properties as $property) {
             $property = papi_get_property_type($property);
             if (papi_is_property($property) && $property->match_slug($slug)) {
                 if (empty($child_slug)) {
                     return $property;
                 }
                 $result = $this->get_child_property($property->get_child_properties(), $child_slug);
                 if (is_object($result)) {
                     return papi_get_property_type($result);
                 }
             }
         }
     }
 }
开发者ID:KristoferN,项目名称:papi,代码行数:45,代码来源:class-papi-page-type.php

示例12: render_json_template

 /**
  * Render property JSON template.
  *
  * @param string $slug
  */
 protected function render_json_template($slug)
 {
     $options = $this->get_options();
     $options->settings->items = papi_to_array($options->settings->items);
     foreach ($options->settings->items as $key => $value) {
         if (!papi_is_property($value)) {
             unset($options->settings->items[$key]);
             continue;
         }
         $options->settings->items[$key] = clone $value->get_options();
     }
     papi_render_html_tag('script', ['data-papi-json' => sprintf('%s_repeater_json', $slug), 'type' => 'application/json', json_encode([$options])]);
 }
开发者ID:ekandreas,项目名称:papi,代码行数:18,代码来源:class-papi-property-repeater.php

示例13: papi_update_field

/**
 * Update field with new value. The old value will be deleted.
 *
 * @param  int    $id
 * @param  string $slug
 * @param  mixed  $value
 * @param  string $type
 *
 * @return bool
 */
function papi_update_field($id = null, $slug = null, $value = null, $type = 'post')
{
    if (!is_numeric($id) && is_string($id)) {
        $type = empty($value) ? $value : $type;
        $value = $slug;
        $slug = $id;
        $id = null;
    }
    if (!is_string($slug) || empty($slug)) {
        return false;
    }
    if (papi_is_empty($value)) {
        return papi_delete_field($id, $slug, $type);
    }
    $id = papi_get_meta_id($type, $id);
    $store = papi_get_meta_store($id, $type);
    if (is_null($store)) {
        return false;
    }
    $property = $store->get_property($slug);
    if (!papi_is_property($property)) {
        return false;
    }
    papi_delete_field($id, $slug, $type);
    $value = $property->update_value($value, $slug, $id);
    $value = papi_filter_update_value($property->get_option('type'), $value, $slug, $id, $type);
    return papi_update_property_meta_value(['type' => $type, 'id' => $id, 'slug' => $slug, 'value' => $value]);
}
开发者ID:nlemoine,项目名称:papi,代码行数:38,代码来源:page.php

示例14: get_value

 /**
  * Get property value.
  *
  * @param  Papi_Core_Conditional_Rule $rule
  *
  * @return mixed
  */
 private function get_value(Papi_Core_Conditional_Rule $rule)
 {
     if (papi_doing_ajax()) {
         $source = $rule->get_source();
         $meta_id = papi_get_meta_id();
         $entry_type = papi_get_entry_type_by_meta_id($meta_id);
         if (!papi_is_empty($source) && $entry_type instanceof Papi_Entry_Type !== false) {
             if (papi_is_property($entry_type->get_property($rule->slug))) {
                 return $this->get_deep_value($rule->slug, $source);
             }
         }
     }
     if (!papi_is_empty($rule->get_source())) {
         return $this->get_deep_value($rule->slug, $rule->get_source());
     }
     $slug = $rule->get_field_slug();
     $type = papi_get_meta_type();
     $value = papi_get_field($slug, null, $type);
     return $this->get_deep_value($slug, $value);
 }
开发者ID:nlemoine,项目名称:papi,代码行数:27,代码来源:class-papi-conditional-rules.php

示例15: setup_options_settings

 /**
  * Setup options settings.
  *
  * @param  stdClass $options
  *
  * @return stdClass
  */
 private function setup_options_settings($options)
 {
     $property_class = self::factory($options->type);
     if (papi_is_property($property_class)) {
         $options->settings = array_merge((array) $property_class->get_default_settings(), (array) $options->settings);
     }
     return (object) $options->settings;
 }
开发者ID:nlemoine,项目名称:papi,代码行数:15,代码来源:class-papi-core-property.php


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