/**
  * 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]);
 }
 /**
  * Format the value of the property before it's returned
  * to WordPress admin or the site.
  *
  * @param  mixed  $value
  * @param  string $slug
  * @param  int    $post_id
  *
  * @return mixed
  */
 public function format_value($value, $slug, $post_id)
 {
     if (!$this->get_setting('multiple')) {
         return $this->is_string_items() ? $value : papi_cast_string_value($value);
     }
     $value = is_array($value) ? $value : [];
     if (!$this->is_string_items()) {
         $value = array_map('papi_cast_string_value', $value);
     }
     return $value;
 }
 /**
  * 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');
     }
 }
 /**
  * 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>';
 }
 /**
  * Convert string number to int or float.
  *
  * @param  string $str
  *
  * @return float|int
  */
 private function convert_number($str)
 {
     return papi_cast_string_value($str);
 }
 /**
  * Convert string number to int or float.
  *
  * @param  string $str
  *
  * @return float|int
  */
 protected function convert_number($str)
 {
     return papi_cast_string_value($str);
 }