/**
  * Get property html via GET.
  *
  * GET /papi-ajax/?action=get_property
  */
 public function get_property()
 {
     $default_options = Papi_Core_Property::create()->get_options();
     $keys = array_keys(get_object_vars($default_options));
     $options = papi_get_qs($keys, true);
     if ($property = papi_property($options)) {
         ob_start();
         $property->render_ajax_request();
         $html = ob_get_clean();
         wp_send_json(['html' => utf8_encode($html)]);
     } else {
         $this->render_error('No property found');
     }
 }
Beispiel #2
0
/**
 * Create a new property array or rendering a template property file.
 *
 * @param  mixed $file_or_options
 * @param  array $values
 *
 * @return null|Papi_Property
 */
function papi_property($file_or_options, $values = [])
{
    if (papi_is_empty($file_or_options)) {
        return;
    }
    if (is_array($file_or_options)) {
        $file_or_options = Papi_Core_Property::create($file_or_options)->get_options();
    }
    if (is_string($file_or_options) && is_array($values)) {
        $file_or_options = papi_template($file_or_options, $values);
    }
    if (is_object($file_or_options)) {
        return papi_get_property_type($file_or_options);
    }
}