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


PHP papi_is_empty函数代码示例

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


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

示例1: 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

示例2: handle_papi_ajax

 /**
  * Handle Papi ajax.
  */
 public function handle_papi_ajax()
 {
     global $wp_query;
     if (!is_object($wp_query)) {
         return;
     }
     if (defined('DOING_AJAX') && DOING_AJAX) {
         return;
     }
     if (!papi_is_empty(papi_get_qs('action'))) {
         $wp_query->set('papi_ajax_action', papi_get_qs('action'));
     }
     $ajax_action = $wp_query->get('papi_ajax_action');
     if (is_user_logged_in() && has_action($this->action_prefix . $ajax_action) !== false) {
         if (!defined('DOING_AJAX')) {
             define('DOING_AJAX', true);
         }
         if (!defined('DOING_PAPI_AJAX')) {
             define('DOING_PAPI_AJAX', true);
         }
         status_header(200);
         do_action($this->action_prefix . $ajax_action);
         wp_die();
     }
 }
开发者ID:ekandreas,项目名称:papi,代码行数:28,代码来源:class-papi-admin-ajax.php

示例3: html

 /**
  * Render property html.
  */
 public function html()
 {
     $settings = $this->get_settings();
     $value = papi_cast_string_value($this->get_value());
     $options_html = [];
     // Override selected setting with
     // database value if not empty.
     if (!papi_is_empty($value)) {
         $settings->selected = $value;
     }
     $classes = 'papi-fullwidth';
     if ($settings->select2) {
         $classes .= ' papi-component-select2';
     }
     if (!empty($settings->placeholder)) {
         $options_html[] = papi_html_tag('option', ['value' => '', $settings->placeholder]);
     }
     // Create option html tags for all items.
     foreach ($this->get_items() as $key => $value) {
         $key = is_numeric($key) ? $value : $key;
         if (papi_is_empty($key)) {
             continue;
         }
         $options_html[] = papi_html_tag('option', ['selected' => $value === $settings->selected ? 'selected' : null, 'value' => $value, papi_convert_to_string($key)]);
     }
     papi_render_html_tag('select', ['class' => $classes, 'data-allow-clear' => true, 'data-placeholder' => $settings->placeholder, 'data-width' => '100%', 'id' => $this->html_id(), 'name' => $this->html_name(), $options_html]);
 }
开发者ID:ekandreas,项目名称:papi,代码行数:30,代码来源:class-papi-property-dropdown.php

示例4: html

 /**
  * Render property html.
  */
 public function html()
 {
     $options = $this->get_options();
     papi_render_html_tag('div', ['class' => 'papi-property-divider', 'data-papi-rule' => $this->html_name(), sprintf('<h3><span>%s</span></h3>', $options->title)]);
     if (!papi_is_empty($options->description)) {
         echo sprintf('<p>%s</p>', $options->description);
     }
 }
开发者ID:ekandreas,项目名称:papi,代码行数:11,代码来源:class-papi-property-divider.php

示例5: html

 /**
  * Render property html.
  */
 public function html()
 {
     $options = $this->get_options();
     $text = '';
     $options->description = $options->slug;
     if (!papi_is_empty($options->description)) {
         $text = sprintf('<p>%s</p>', $options->description);
     }
     papi_render_html_tag('div', ['class' => 'papi-property-divider', 'data-papi-rule' => esc_attr($this->html_name()), sprintf('<h3><span>%s</span></h3>%s', esc_html($options->title), $text)]);
 }
开发者ID:wp-papi,项目名称:papi,代码行数:13,代码来源:class-papi-property-divider.php

示例6: import_value

 /**
  * Import value to the property.
  *
  * @param  mixed  $value
  * @param  string $slug
  * @param  int    $post_id
  *
  * @return mixed
  */
 public function import_value($value, $slug, $post_id)
 {
     if (is_string($value) && !papi_is_empty($value)) {
         return [$value];
     }
     if (!is_array($value)) {
         return;
     }
     return $value;
 }
开发者ID:wp-papi,项目名称:papi,代码行数:19,代码来源:class-papi-property-checkbox.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 null.
     if (!papi_is_empty($value)) {
         $settings->selected = $value;
     }
     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_render_html_tag('input', ['id' => $this->html_id($key), 'name' => $this->html_name(), 'type' => 'radio', 'checked' => $value === $settings->selected ? 'checked' : null, 'value' => $value]), papi_convert_to_string($key)]);
         papi_render_html_tag('br');
     }
 }
开发者ID:ekandreas,项目名称:papi,代码行数:18,代码来源:class-papi-property-radio.php

示例8: html

 /**
  * Render property html.
  */
 public function html()
 {
     $settings = $this->get_settings();
     $value = $this->get_value();
     // If range type is used change the default values if empty.
     if ($settings->type === 'range') {
         $settings->max = papi_is_empty($settings->max) ? 100 : $settings->max;
         $settings->min = papi_is_empty($settings->min) ? 0 : $settings->min;
         $settings->step = papi_is_empty($settings->step) ? 1 : $settings->step;
     }
     if ($settings->min !== 0 && $value < $settings->min) {
         $value = $settings->min;
     }
     papi_render_html_tag('input', ['id' => $this->html_id(), 'max' => $settings->max, 'min' => $settings->min, 'name' => $this->html_name(), 'step' => $settings->step, 'type' => $settings->type, 'value' => $value]);
 }
开发者ID:ekandreas,项目名称:papi,代码行数:18,代码来源:class-papi-property-number.php

示例9: 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 null.
     if (!papi_is_empty($value)) {
         $settings->selected = $value;
     }
     echo '<div class="papi-property-radio">';
     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' => 'radio', 'checked' => $value === $settings->selected, 'value' => $value]), esc_html(papi_convert_to_string($key))])]);
     }
     echo '</div>';
 }
开发者ID:wp-papi,项目名称:papi,代码行数:19,代码来源:class-papi-property-radio.php

示例10: format_value

 /**
  * Format the value of the property before it's returned
  * to WordPress admin or the site.
  *
  * @param  mixed  $values
  * @param  string $repeater_slug
  * @param  int    $post_id
  *
  * @return array
  */
 public function format_value($values, $repeater_slug, $post_id)
 {
     if (!is_array($values)) {
         return [];
     }
     foreach ($values as $index => $layout) {
         foreach ($layout as $slug => $value) {
             if (is_string($value) && preg_match($this->layout_value_regex, $value)) {
                 if (isset($values[$index][$this->layout_key])) {
                     unset($values[$index][$slug]);
                     continue;
                 }
                 $values[$index][$this->layout_key] = $value;
                 unset($values[$index][$slug]);
                 continue;
             }
             if (papi_is_property_type_key($slug)) {
                 continue;
             }
             $property_type_slug = papi_get_property_type_key_f($slug);
             if (!isset($values[$index][$property_type_slug])) {
                 continue;
             }
             $property_type_value = $values[$index][$property_type_slug];
             $property_type = papi_get_property_type($property_type_value);
             if (!is_object($property_type)) {
                 continue;
             }
             // Get property child slug.
             $child_slug = $this->get_child_slug($repeater_slug, $slug);
             // Create cache key.
             $cache_key = sprintf('%s_%d_%s', $repeater_slug, $index, $slug);
             // Get raw value from cache if enabled.
             if ($this->cache) {
                 $raw_value = papi_cache_get($cache_key, $post_id, $this->get_meta_type());
             } else {
                 $raw_value = false;
             }
             // Load the value.
             if ($raw_value === null || $raw_value === false) {
                 $values[$index][$slug] = $property_type->load_value($value, $child_slug, $post_id);
                 $values[$index][$slug] = papi_filter_load_value($property_type->type, $values[$index][$slug], $child_slug, $post_id, papi_get_meta_type());
                 if (!papi_is_empty($values[$index][$slug]) && $this->cache) {
                     papi_cache_set($cache_key, $post_id, $values[$index][$slug], $this->get_meta_type());
                 }
             } else {
                 $values[$index][$slug] = $raw_value;
             }
             if (strtolower($property_type->type) === 'repeater') {
                 $property_type->cache = false;
             }
             // Format the value from the property class.
             $values[$index][$slug] = $property_type->format_value($values[$index][$slug], $child_slug, $post_id);
             if (!is_admin()) {
                 $values[$index][$slug] = papi_filter_format_value($property_type->type, $values[$index][$slug], $child_slug, $post_id, papi_get_meta_type());
             }
             $values[$index][$property_type_slug] = $property_type_value;
         }
     }
     if (!is_admin()) {
         foreach ($values as $index => $row) {
             foreach ($row as $slug => $value) {
                 if (is_string($value) && preg_match($this->layout_value_regex, $value)) {
                     unset($values[$index][$slug]);
                     $values[$index]['_layout'] = preg_replace($this->layout_value_regex, '', $value);
                 }
                 if (papi_is_property_type_key($slug)) {
                     unset($values[$index][$slug]);
                 }
                 if (papi_is_empty($value)) {
                     unset($values[$index][$slug]);
                 }
             }
         }
     }
     return $values;
 }
开发者ID:nlemoine,项目名称:papi,代码行数:87,代码来源:class-papi-property-flexible.php

示例11: render_row_html

    /**
     * Render the final html that is displayed in the table.
     */
    protected function render_row_html()
    {
        $display_class = $this->display() ? '' : ' papi-hide';
        $rules_class = papi_is_empty($this->get_rules()) ? '' : ' papi-rules-exists';
        $css_class = trim($display_class . $rules_class);
        if ($this->get_option('raw')) {
            echo sprintf('<div class="%s">', $css_class);
            $this->render_property_html();
            echo '</div>';
        } else {
            ?>
			<tr class="<?php 
            echo $css_class;
            ?>
">
				<?php 
            if ($this->get_option('sidebar')) {
                ?>
					<td>
						<?php 
                $this->render_label_html();
                $this->render_description_html();
                ?>
					</td>
				<?php 
            }
            ?>
				<td <?php 
            echo $this->get_option('sidebar') ? '' : 'colspan="2"';
            ?>
>
					<?php 
            $this->render_property_html();
            ?>
				</td>
			</tr>
			<?php 
        }
    }
开发者ID:ekandreas,项目名称:papi,代码行数:42,代码来源:class-papi-property.php

示例12: html

    /**
     * Render property html.
     */
    public function html()
    {
        $settings = $this->get_settings();
        $value = $this->get_value();
        if (is_object($value)) {
            $value = $value->ID;
        } else {
            $value = 0;
        }
        $posts = $this->get_posts($settings);
        $render_label = count($posts) > 1;
        $classes = 'papi-fullwidth';
        if ($settings->select2) {
            $classes = ' papi-component-select2';
        }
        ?>

		<div class="papi-property-post">
			<select
				id="<?php 
        echo $this->html_id();
        ?>
"
				name="<?php 
        echo $this->html_name();
        ?>
"
				class="<?php 
        echo $classes;
        ?>
"
				data-allow-clear="true"
				data-placeholder="<?php 
        echo $settings->placeholder;
        ?>
"
				data-width="100%">

				<?php 
        if (!empty($settings->placeholder)) {
            ?>
					<option value=""></option>
				<?php 
        }
        ?>

				<?php 
        foreach ($posts as $label => $items) {
            ?>

					<?php 
            if ($render_label && is_string($label)) {
                ?>
						<optgroup label="<?php 
                echo $label;
                ?>
">
					<?php 
            }
            ?>

					<?php 
            foreach ($items as $post) {
                if (papi_is_empty($post->post_title)) {
                    continue;
                }
                papi_render_html_tag('option', ['value' => $post->ID, 'selected' => $value === $post->ID ? 'selected' : null, $post->post_title]);
            }
            ?>

					<?php 
            if ($render_label) {
                ?>
						</optgroup>
					<?php 
            }
            ?>

				<?php 
        }
        ?>

			</select>
		</div>
		<?php 
    }
开发者ID:ekandreas,项目名称:papi,代码行数:89,代码来源:class-papi-property-post.php

示例13: 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(['id' => 0, 'slug' => '', 'type' => 'post', 'value' => ''], $meta);
    $meta = (object) $meta;
    $meta->type = papi_get_meta_type($meta->type);
    $save_value = true;
    // Set the right update value function for the type.
    $update_value_fn = $meta->type === 'option' ? 'update_option' : 'update_metadata';
    /**
     * Change update function.
     *
     * @param string $update_value_fn
     */
    $update_value_fn = apply_filters('papi/core/update_value_fn', $update_value_fn);
    // Check so the function is callable before using it.
    if (!is_callable($update_value_fn)) {
        return;
    }
    // Check for string keys in the array if any.
    foreach (papi_to_array($meta->value) as $key => $value) {
        if (is_string($key)) {
            $save_value = false;
            break;
        }
    }
    // If main value shouldn't be saved it should be array.
    if (!$save_value && is_array($meta->value)) {
        $meta->value = [$meta->value];
    }
    // Delete saved value if empty.
    if (papi_is_empty($meta->value)) {
        return papi_delete_property_meta_value($meta->id, $meta->slug, $meta->type);
    }
    $result = true;
    foreach (papi_to_array($meta->value) as $key => $value) {
        // Delete saved value if value is empty.
        if (papi_is_empty($value) || $value === '[]' || $value === '{}') {
            return papi_delete_property_meta_value($meta->id, $meta->slug, $meta->type);
        }
        // Delete main value cache.
        papi_cache_delete($meta->slug, $meta->id, $meta->type);
        // If not a array we can save the value.
        if (!is_array($value)) {
            if ($save_value) {
                $value = $meta->value;
            }
            if (papi_get_meta_type($meta->type) === 'option') {
                $out = call_user_func_array($update_value_fn, [unpapify($meta->slug), $value]);
                $result = $out ? $result : $out;
            } else {
                $out = call_user_func_array($update_value_fn, [$meta->type, $meta->id, unpapify($meta->slug), $value]);
                $result = $out ? $result : $out;
            }
            continue;
        }
        // Delete all child value caches.
        papi_update_property_meta_value_cache_delete($meta, $value);
        // Update metadata or option value for all child values.
        foreach ($value as $child_key => $child_value) {
            if (papi_is_empty($child_value)) {
                papi_delete_property_meta_value($meta->id, $child_key, $meta->type);
            } else {
                if (papi_get_meta_type($meta->type) === 'option') {
                    call_user_func_array($update_value_fn, [unpapify($child_key), $child_value]);
                } else {
                    call_user_func_array($update_value_fn, [$meta->type, $meta->id, unpapify($child_key), $child_value]);
                }
            }
        }
    }
    return $result;
}
开发者ID:wp-papi,项目名称:papi,代码行数:80,代码来源:property.php

示例14: 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

示例15: html

 /**
  * Render property html.
  */
 public function html()
 {
     // Setup variables needed.
     $settings = $this->get_settings();
     $value = $this->get_value();
     $options_html = [];
     // Properties that extends dropdown property
     // maybe don't have this setting.
     if (!isset($settings->multiple)) {
         $settings->multiple = false;
     }
     // Override selected setting with
     // database value if not empty.
     if (!papi_is_empty($value)) {
         $settings->selected = $value;
     }
     $classes = 'papi-fullwidth';
     if ($settings->select2) {
         $classes .= ' papi-component-select2';
     }
     // Add placeholder if any.
     if (!empty($settings->placeholder)) {
         $options_html[] = papi_html_tag('option', ['value' => '', $settings->placeholder]);
     }
     // Create option html tags for all items.
     foreach ($this->get_items() as $key => $value) {
         $key = is_numeric($key) ? $value : $key;
         if (papi_is_empty($key)) {
             continue;
         }
         // When a multiple we need to check with
         // `in_array` since the value is a array.
         if ($settings->multiple) {
             $selected = in_array($value, $settings->selected, true);
         } else {
             $selected = $value === $settings->selected;
         }
         $options_html[] = papi_html_tag('option', ['data-edit-url' => get_edit_post_link($value), 'selected' => $selected ? 'selected' : null, 'value' => $value, esc_html(papi_convert_to_string($key))]);
     }
     // When selectize is empty this will be used.
     papi_render_html_tag('input', ['name' => $this->html_name() . ($settings->multiple ? '[]' : ''), 'type' => 'hidden']);
     papi_render_html_tag('select', ['class' => $classes, 'data-allow-clear' => !empty($settings->placeholder), 'data-placeholder' => $settings->placeholder, 'data-width' => '100%', 'id' => $this->html_id() . ($settings->multiple ? '[]' : ''), 'multiple' => $settings->multiple ? 'multiple' : null, 'name' => $this->html_name() . ($settings->multiple ? '[]' : ''), $options_html]);
 }
开发者ID:wp-papi,项目名称:papi,代码行数:46,代码来源:class-papi-property-dropdown.php


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