factory() public static method

Create a new instance of the given type or a empty core property if no type is given.
public static factory ( ) : null | object
return null | object
Beispiel #1
0
/**
 * Render the given property.
 *
 * @param mixed $property
 */
function papi_render_property($property)
{
    $property = Papi_Core_Property::factory($property);
    if (!papi_is_property($property)) {
        return;
    }
    $property->render();
}
Beispiel #2
0
 /**
  * Get property html via GET.
  *
  * GET /papi-ajax/?action=get_property
  */
 public function get_property()
 {
     $default_options = Papi_Core_Property::factory()->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)]);
         return;
     }
     $this->render_error('No property found');
 }