admin
10 years ago
forms
10 years ago
integrations
10 years ago
mailchimp
10 years ago
views
10 years ago
class-api.php
10 years ago
class-array-bag.php
10 years ago
class-container.php
10 years ago
class-debug-log-reader.php
10 years ago
class-debug-log.php
10 years ago
class-dynamic-content-tags.php
10 years ago
class-field-formatter.php
10 years ago
class-field-guesser.php
10 years ago
class-field-map.php
10 years ago
class-mailchimp.php
10 years ago
class-plugin.php
10 years ago
class-queue-job.php
10 years ago
class-queue.php
10 years ago
class-request.php
10 years ago
class-tools.php
10 years ago
class-validator.php
10 years ago
class-visitor-tracking.php
10 years ago
default-actions.php
10 years ago
default-filters.php
10 years ago
deprecated-functions.php
10 years ago
functions.php
10 years ago
class-plugin.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class MC4WP_Plugin |
| 5 | * |
| 6 | * Helper class for easy access to information like the plugin file or plugin directory. |
| 7 | * |
| 8 | * @access public |
| 9 | * @ignore |
| 10 | */ |
| 11 | class MC4WP_Plugin { |
| 12 | |
| 13 | /** |
| 14 | * @var string The plugin version. |
| 15 | */ |
| 16 | protected $version; |
| 17 | |
| 18 | /** |
| 19 | * @var string The main plugin file. |
| 20 | */ |
| 21 | protected $file; |
| 22 | |
| 23 | /** |
| 24 | * @param string $file The plugin version. |
| 25 | * @param string $version The main plugin file. |
| 26 | */ |
| 27 | public function __construct( $file, $version ) { |
| 28 | $this->file = $file; |
| 29 | $this->version = $version; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get the main plugin file. |
| 34 | * |
| 35 | * @return string |
| 36 | */ |
| 37 | public function file() { |
| 38 | return $this->file; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get the plugin version. |
| 43 | * |
| 44 | * @return string |
| 45 | */ |
| 46 | public function version() { |
| 47 | return $this->version; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Gets the directory the plugin lives in. |
| 52 | * |
| 53 | * @param string $path |
| 54 | * |
| 55 | * @return string |
| 56 | */ |
| 57 | public function dir( $path = '' ) { |
| 58 | |
| 59 | // ensure path has leading slash |
| 60 | if( '' !== $path ) { |
| 61 | $path = '/' . ltrim( $path, '/' ); |
| 62 | } |
| 63 | |
| 64 | return dirname( $this->file ) . $path; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Gets the URL to the plugin files. |
| 69 | * |
| 70 | * @param string $path |
| 71 | * |
| 72 | * @return string |
| 73 | */ |
| 74 | public function url( $path = '' ) { |
| 75 | return plugins_url( $path, $this->file ); |
| 76 | } |
| 77 | } |