Ejemplo n.º 1
0
 public function save()
 {
     $properties = array('name' => null, 'slug' => null, 'description' => null, 'parent' => null);
     $updates = array_intersect_key(get_object_vars($this), $properties);
     remove_filter('pre_term_description', 'wp_filter_kses');
     // Allow HTML in category descriptions
     if ($this->id) {
         wp_update_term($this->id, $this->taxonomy, $updates);
     } else {
         list($this->id, $this->term_taxonomy_id) = array_values(wp_insert_term($this->name, $this->taxonomy, $updates));
     }
     if (!$this->id) {
         return false;
     }
     // If the term successfully saves, save all meta data too
     foreach ($this->meta as $name => $Meta) {
         if (is_a($Meta, 'ShoppMetaObject')) {
             $MetaObject = $Meta;
         } else {
             $MetaObject = new ShoppMetaObject();
             $MetaObject->populate($Meta);
         }
         $MetaObject->parent = $this->id;
         $MetaObject->context = 'category';
         $MetaObject->save();
     }
     return true;
 }
Ejemplo n.º 2
0
 function load()
 {
     $args = func_get_args();
     if (empty($args[0])) {
         return false;
     }
     if (!is_array($args[0])) {
         return false;
     }
     $where = "";
     foreach ($args[0] as $key => $id) {
         $where .= ($where == "" ? "" : " AND ") . "{$key}='" . sDB::escape($id) . "'";
     }
     $r = sDB::query("SELECT * FROM {$this->_table} WHERE {$where}", 'array');
     foreach ($r as $row) {
         $meta = new ShoppMetaObject();
         $meta->populate($row, '', array());
         $this->meta[$meta->id] = $meta;
         $this->named[$meta->name] =& $this->meta[$meta->id];
     }
     if (isset($row) && count($row) == 0) {
         $this->_loaded = false;
     }
     $this->_loaded = true;
     return $this->_loaded;
 }
Ejemplo n.º 3
0
 public function metaloader(&$records, &$record)
 {
     if (empty($this->categories)) {
         return;
     }
     if (empty($record->name)) {
         return;
     }
     if (is_array($this->categories) && isset($this->categories[$record->parent])) {
         $target = $this->categories[$record->parent];
     } else {
         return;
     }
     $Meta = new ShoppMetaObject();
     $Meta->populate($record);
     $target->meta[$record->name] = $Meta;
     if (!isset($this->{$record->name})) {
         $target->{$record->name} =& $Meta->value;
     }
 }