Passed
Push — master ( 505ae7...78ca0f )
by Jip
03:42
created

Stencil_Installable_Theme::get_slug()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Installable theme
4
 *
5
 * @package Stencil
6
 * @subpackage Upgrader
7
 */
8
9
/**
10
 * Class Stencil_Installable_Theme
11
 */
12
class Stencil_Installable_Theme extends Stencil_Abstract_Installable implements Stencil_Installable_Interface {
13
	/**
14
	 * Download format.
15
	 */
16
	const DOWNLOAD_FORMAT = 'https://github.com/moorscode/%s/archive/master.zip';
17
18
	/**
19
	 * Get the theme slug.
20
	 *
21
	 * @return string
22
	 */
23
	public function get_slug() {
24
		return sprintf( 'stencil-sample-theme-%s', $this->slug );
25
	}
26
27
	/**
28
	 * Get the download link
29
	 *
30
	 * @return bool|string
31
	 */
32
	public function get_download_link() {
33
		return sprintf( self::DOWNLOAD_FORMAT, $this->get_slug() );
34
	}
35
36
	/**
37
	 * Get base directory
38
	 *
39
	 * @return string
40
	 */
41
	public function get_directory() {
42
		return get_theme_root() . DIRECTORY_SEPARATOR . $this->get_slug();
43
	}
44
45
	/**
46
	 * Get file headers
47
	 *
48
	 * @return array
49
	 */
50
	public function get_file_data() {
51
		$path = $this->get_directory() . DIRECTORY_SEPARATOR . 'style.css';
52
53
		return get_file_data( $path, array( 'version' => 'Version' ) );
54
	}
55
56
	/**
57
	 * Upgrade
58
	 *
59
	 * @return bool
60
	 */
61
	public function upgrade() {
62
		return false;
63
	}
64
65
	/**
66
	 * Get upgrader needed.
67
	 *
68
	 * @param bool $upgrading Installing or upgrading.
69
	 *
70
	 * @return WP_Upgrader
71
	 */
72
	public function get_upgrader( $upgrading = false ) {
73
		$skin = ( $upgrading ) ? new Theme_Upgrader_Skin() : new Theme_Installer_Skin();
74
75
		return new Theme_Upgrader( $skin );
76
	}
77
}
78