Ejemplo n.º 1
0
 public static function config(array $config = [])
 {
     Session::start();
     foreach ($config as $key => $value) {
         static::${$key} = $value;
     }
 }
Ejemplo n.º 2
0
 /**
  * Generates HTML code
  * 
  * @param object $post WordPress post object
  * @param array $data WordPress meta values
  */
 public function render($post, $data)
 {
     // Ptint the deacription of the meta box
     echo $this->description;
     // Nonce field for some validation
     wp_nonce_field($this->name . '_data', $this->name . '_nonce');
     // Loop through fields
     echo "<table class='form-table'>";
     foreach ($this->fields as $fieldName => $field) {
         // Get field object
         $fieldObject = $field['object'];
         // If post is not new
         if ($post->post_status !== 'auto-draft') {
             // Bind meta value to the field
             $fieldObject->value = $this->getMetaValue($fieldName, $post);
             // Get errors from session
             $fieldObject->errors = Session::manager()->getFlash($this->getMetaName($fieldName), []);
         }
         // Print field
         echo $fieldObject;
     }
     echo "</table>";
 }