PluginProbe
Additional Terms Lite for WooCommerce / 1.6.1
Additional Terms Lite for WooCommerce v1.6.1
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 1.6.1, at src/File.php

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