PluginProbe
Additional Terms Lite for WooCommerce / trunk
Additional Terms Lite for WooCommerce vtrunk
1.7.3 1.7.2.1 trunk 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 All 35 releases
woo-additional-terms / src / File.php

File.php in Additional Terms Lite for WooCommerce trunk, at src/File.php

121 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The plugin file path class.
4 *
5 * @since 1.0.0
6 *
7 * @package woo-additional-terms
8 */
9
10 namespace Woo_Additional_Terms;
11
12 /**
13 * Class File.
14 */
15 class File {
16
17 /**
18 * The plugin file path.
19 *
20 * @since 1.0.0
21 *
22 * @var string
23 */
24 private $file;
25
26 /**
27 * Constructor.
28 *
29 * @since 1.0.0
30 *
31 * @param string $file The plugin file.
32 *
33 * @return void
34 */
35 public function __construct( $file ) {
36
37 $this->file = $file;
38 }
39
40 /**
41 * Return the plugin file.
42 *
43 * @since 1.0.0
44 *
45 * @return string
46 */
47 public function plugin_file() {
48
49 return $this->file;
50 }
51
52 /**
53 * Return the plugin base name.
54 *
55 * @since 1.0.0
56 *
57 * @return string
58 */
59 public function plugin_basename() {
60
61 return plugin_basename( $this->file );
62 }
63
64 /**
65 * Return the plugin path.
66 *
67 * @since 1.0.0
68 *
69 * @param string $path The path to the file.
70 *
71 * @return string
72 */
73 public function plugin_path( $path = '' ) {
74
75 return path_join( plugin_dir_path( $this->file ), $path );
76 }
77
78 /**
79 * Return the plugin url.
80 *
81 * @since 1.0.0
82 *
83 * @param string $path The path to the file.
84 *
85 * @return string
86 */
87 public function plugin_url( $path = '' ) {
88
89 return plugins_url( $path, $this->file );
90 }
91
92 /**
93 * Return plugin dirname.
94 *
95 * @since 1.6.0
96 *
97 * @return string
98 */
99 public function dirname() {
100
101 return dirname( plugin_basename( $this->file ) );
102 }
103
104 /**
105 * Returns a full path for the asset (static resource CSS/JS) file.
106 *
107 * @since 1.0.0
108 *
109 * @param string $file_name Asset file name (filename).
110 *
111 * @return string
112 */
113 public function asset_path( $file_name ) {
114
115 $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : trailingslashit( 'minified' );
116 $directory = pathinfo( $file_name, PATHINFO_EXTENSION );
117
118 return woo_additional_terms()->service( 'file' )->plugin_url( "assets/{$directory}/{$min}{$file_name}" );
119 }
120 }
121