PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / jetpack_vendor / quadlayers / wp-notice-plugin-promote / src / Traits / PluginDataByFile.php

PluginDataByFile.php in QuadMenu – Mega Menu 3.3.8, at jetpack_vendor/quadlayers/wp-notice-plugin-promote/src/Traits/PluginDataByFile.php

102 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * QuadLayers WP Notice Plugin Promote
4 *
5 * @package quadlayers/wp-notice-plugin-promote
6 * @author QuadLayers
7 * @link https://github.com/quadlayers/wp-notice-plugin-promote
8 * @copyright Copyright (c) 2023
9 * @license GPL-3.0
10 */
11
12 namespace QuadLayers\WP_Notice_Plugin_Promote\Traits;
13
14 /**
15 * Trait PluginDataByFile
16 *
17 * @package QuadLayers\WP_Notice_Plugin_Promote\Traits\PluginDataByFile
18 * @since 1.0.0
19 */
20 trait PluginDataByFile {
21
22 /**
23 * Plugin file path
24 *
25 * @var string
26 */
27 private $plugin_file;
28
29 /**
30 * Plugin slug
31 *
32 * @var string
33 */
34 private $plugin_slug;
35
36 /**
37 * Plugin base folder
38 *
39 * @var string
40 */
41 private $plugin_base;
42
43 /**
44 * Check if plugin is valid.
45 *
46 * @return bool
47 */
48 public function is_valid() {
49 if ( ! $this->get_file() ) {
50 return false;
51 }
52 if ( ! is_file( $this->get_file() ) ) {
53 return false;
54 }
55
56 return true;
57 }
58
59 /**
60 * Get plugin file path.
61 *
62 * @return string
63 */
64 public function get_file() {
65 return $this->plugin_file;
66 }
67
68 /**
69 * Get plugin slug.
70 *
71 * @return string
72 */
73 public function get_slug() {
74 if ( $this->plugin_slug ) {
75 return $this->plugin_slug;
76 }
77 if ( ! $this->get_file() ) {
78 return false;
79 }
80 $plugin_slug = basename( $this->get_file(), '.php' );
81 $this->plugin_slug = $plugin_slug;
82 return $this->plugin_slug;
83 }
84
85 /**
86 * Get plugin base folder.
87 *
88 * @return string
89 */
90 public function get_base() {
91 if ( $this->plugin_base ) {
92 return $this->plugin_base;
93 }
94 if ( ! $this->get_file() ) {
95 return false;
96 }
97 $plugin_base = plugin_basename( $this->get_file() );
98 $this->plugin_base = $plugin_base;
99 return $this->plugin_base;
100 }
101 }
102