private function set($key, $value) { $this->data[$key] = $value; //update cache mpp_add_media_to_cache($this); }
/** * Retrieves Media data given a media id or media object. * * @param int|object $media media id or media object. Optional, default is the current media from the loop. * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N. * @param string $filter Optional, default is raw. * @return MPP_Media|null MPP_Media on success or null on failure */ function mpp_get_media($media = null, $output = OBJECT) { $_media = null; $needs_caching = false; //if a media is not given but we are inside the media loop if (empty($media) && mediapress()->current_media) { $media = mediapress()->current_media; } if (!$media) { return null; } //if already an instance of gallery object if (is_a($media, 'MPP_Media')) { $_media = $media; } elseif (is_numeric($media)) { $_media = mpp_get_media_from_cache($media); if (!$_media) { $_media = new MPP_Media($media); $needs_caching = true; } } elseif (is_object($media)) { $_media = new MPP_Media($media); $needs_caching = true; } //save to cache if not already in cache if ($needs_caching && !empty($_media) && $_media->id) { mpp_add_media_to_cache($_media); } if (empty($_media)) { return null; } if (!$_media->id) { return; } if ($output == ARRAY_A) { return $_media->to_array(); } elseif ($output == ARRAY_N) { return array_values($_media->to_array()); } return $_media; }