示例#1
0
 /**
  * Renders the full calendar
  *
  * @param array $attr Attributes sent by WordPress defined in the editor
  * @return string
  */
 public function calendar($attr)
 {
     $attrs = shortcode_atts(array('id' => $this->theme->options('core_calendar_id')), $attr);
     $id = $attrs['id'];
     $this->theme->set(compact('id'));
     return $this->theme->render('calendar');
 }
示例#2
0
 /**
  * Transfers a recently uploaded file to S3, and deletes the local copy
  *
  * @param array $data Attachment data
  * @param integer $postID Post id
  * @return array
  */
 public function transferToS3($data, $postID)
 {
     // because sometimes it's not populated... #YAWPH
     $data['file'] = str_replace(DS, '/', get_attached_file($postID, true));
     if (!isset($data['sizes'])) {
         $data['sizes'] = array();
     }
     $s3Key = $this->theme->options('s3_access_key');
     $s3KeySecret = $this->theme->options('s3_access_secret');
     $bucket = $this->theme->options('s3_bucket');
     $S3 = new S3($s3Key, $s3KeySecret);
     $type = get_post_mime_type($postID);
     $file = array('type' => $type, 'file' => $data['file'], 'size' => filesize($data['file']));
     $s3filePath = $this->getS3Path($data['file']);
     if (file_exists($data['file'])) {
         if ($S3->putObject($file, $bucket, $s3filePath, $S3::ACL_PUBLIC_READ)) {
             unlink($data['file']);
         }
     }
     foreach ($data['sizes'] as $thumbkey => $info) {
         $fullThumbPath = str_replace(basename($data['file']), $info['file'], $data['file']);
         $fullThumbPath = str_replace('/', DS, $fullThumbPath);
         $s3ThumbPath = str_replace(basename($s3filePath), $info['file'], $s3filePath);
         $file = array('type' => $type, 'file' => $fullThumbPath, 'size' => filesize($fullThumbPath));
         if (file_exists($fullThumbPath)) {
             if ($S3->putObject($file, $bucket, $s3ThumbPath, $S3::ACL_PUBLIC_READ)) {
                 unlink($fullThumbPath);
             }
         }
     }
     return $data;
 }
示例#3
0
/**
 * Renders an ebulletin archive (generated via mailchimp)
 *
 * @param array $attr Attributes sent by WordPress defined in the editor
 * @return string
 */
	public function ebulletinArchive($attr) {
		$id = $this->theme->options('mailchimp_folder_id');
		if (empty($id)) {
			return null;
		}
		$this->theme->set(compact('id'));
		return $this->theme->render('ebulletin_archive');
	}