PluginProbe
Float menu – awesome floating side menu / 6.0
Float menu – awesome floating side menu v6.0
7.2.5 trunk 2.1 2.2 3.0.1 3.1 3.2.2 3.3.1 3.5 3.5.1 3.5.2 3.5.3. 3.5.4 4.0 4.1 4.1.1 4.2 4.3 4.3.1 4.3.2 5.0 5.0.1 5.0.2 5.0.3 5.1 All 57 releases
float-menu / classes / Admin / DashboardHelper.php

DashboardHelper.php in Float menu – awesome floating side menu 6.0, at classes/Admin/DashboardHelper.php

99 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class DashboardHelper
5 *
6 * Helper class for managing the dashboard.
7 *
8 * @package WowPlugin
9 * @subpackage Admin
10 * @author Dmytro Lobov <dev@wow-company.com>, Wow-Company
11 * @copyright 2024 Dmytro Lobov
12 * @license GPL-2.0+
13 *
14 */
15
16 namespace FloatMenuLite\Admin;
17
18 defined( 'ABSPATH' ) || exit;
19
20 use FloatMenuLite\WOWP_Plugin;
21
22 class DashboardHelper {
23
24 public static function first_file( $folder ) {
25
26 $files = self::get_files( $folder );
27 if ( empty( $files ) ) {
28 return false;
29 }
30
31 return reset( $files )['file'];
32 }
33
34 public static function get_files( $folder ): array {
35 $scan_files = scandir( self::get_folder_path( $folder ) );
36 $files = [];
37 foreach ( $scan_files as $file ) {
38 if ( $file === '.' || $file === '..' || $file === 'index.php' ) {
39 continue;
40 }
41 $extension = pathinfo( $file, PATHINFO_EXTENSION );
42
43 $matches = explode( '.', $file );
44
45 if ( ! is_numeric( $matches[0] ) ) {
46 continue;
47 }
48
49 $file_name = self::get_file_name( $file, $folder );
50
51 $files[ $matches[0] ] = [ 'file' => $matches[1], 'name' => $file_name ];
52 }
53
54 return $files;
55 }
56
57 public static function get_file_name( $file, $folder ): string {
58
59 $file_path = self::get_folder_path( $folder ) . '/' . $file;
60 $file_data = get_file_data( $file_path, array( 'name' => 'Page Name' ) );
61
62 return $file_data['name'];
63
64 }
65
66 public static function get_folder_path( $folder ): string {
67 return WOWP_Plugin::dir() . 'admin/' . $folder;
68 }
69
70 public static function get_file( $current, $folder ) {
71 $files = scandir( self::get_folder_path( $folder ) );
72 foreach ( $files as $file ) {
73 $matches = explode( '.', $file );
74 if ( isset( $matches[1] ) && $matches[1] === $current ) {
75 return $file;
76 }
77 }
78
79 return false;
80 }
81
82 public static function search_value( $array, $value ): bool {
83
84 foreach ( $array as $item ) {
85 if ( is_array( $item ) ) {
86 if ( self::search_value( $item, $value ) ) {
87 return true;
88 }
89 } else {
90 if ( $item === $value ) {
91 return true;
92 }
93 }
94 }
95
96 return false;
97 }
98
99 }