public function copy_to_theme() { foreach ($this->templates as $key => $template) { $file_path = $this->plugin_path . '/' . $this->plugin_folder_path . '/' . $key; $destination = trailingslashit($this->theme_template_path) . '/' . $key; $result = SB_PHP::copy($file_path, $destination); } }
public static function fetch_media($image_url) { $attach_id = 0; if (empty($image_url)) { return $attach_id; } $wp_upload_dir = wp_upload_dir(); $base_dir = trailingslashit($wp_upload_dir['basedir']) . 'sb-media'; $base_url = trailingslashit($wp_upload_dir['url']) . 'sb-media'; SB_PHP::create_folder($base_dir); $parts = pathinfo($image_url); $random = rand(); $random = md5($random); $file_name = 'sb-media-' . $parts['filename'] . '-' . $random . '.' . $parts['extension']; $file_path = trailingslashit($base_dir) . $file_name; $file_url = trailingslashit($base_url) . $file_name; if (SB_PHP::copy($image_url, $file_path)) { $attachment = array('guid' => $file_url); $attach_id = self::insert_attachment($attachment, $file_path); } return $attach_id; }