Entity System - Property Attributes

What is Attributes Entity? Attributes entity object is a PHP class for managing the Property Attributes entry to a property type. It is recommended to use this class when need to alter a Property Attributes programatically only.

What is property attributes? Property Attributes is a simple version of Property Fields, where user can create custom attributes via front end editor without the need to know PHP. As it is intended to be as simple as possible, the features is also limited comparing to a true field.

Where does a property attributes stores its data? All attributes will store its data in form or a taxonomy terms, it can be a terms id or free tagging terms depending on the selection of the attributes metabox form settings format. Available Hook actionsProperty plugin Attribute Entity is alterable via hooks :

Hook Action – vtcore_property_attribute_init This hook is invoked as the last action when the attribute entity is constructed.

Hook Action – vtcore_property_attribute_after_entity_load This action is invoked after the type entity object finished loading attribute entity data from WordPress options table with row key vtcore_property_attributes into the object.

Hook Action – vtcore_property_type_before_entity_save This action is triggered after the attribute entity object performing saving into the database regardless whether the saving process is success or failed.

Hook Action – vtcore_property_attribute_after_entity_delete This action is triggered after the attribute data is removed from the database and also after the deleted attributes removed from all property type entity entry and all WordPress post entry.

Example on altering attributes entity

/**
 * Hooking into type entity init hook 
 */
add_action('vtcore_property_attribute_init', 'alter_my_attribute'); 

function alter_my_type($object) { 

  /**
   * Use dotted notation and object getter
   * Just a simple demonstration to change all the 
   * type form label
   */
  $object->mutate('label', 'Newly altered label');

  /**
   * Don't allow all attributes to be searched
   */
  $object->mutate('search', false);
 
}

 

Show All