PluginProbe
Bubble Menu – Floating Button Menu with Sticky Navigation / 4.0
Bubble Menu – Floating Button Menu with Sticky Navigation v4.0
trunk 1.3 2.0 2.2 2.2.1 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.1 3.1.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.1 4.1.1
bubble-menu / classes / Admin / DashboardHelper.php

DashboardHelper.php in Bubble Menu – Floating Button Menu with Sticky Navigation 4.0, at classes/Admin/DashboardHelper.php

102 lines 2.1 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
9 namespace BubbleMenu\Admin;
10
11 defined( 'ABSPATH' ) || exit;
12
13 use /**
14 * The BubbleMenu\WOWP_Plugin class is responsible for initializing and managing the functionality of the WP Buttons plugin.
15 *
16 * @package BubbleMenu
17 */
18 BubbleMenu\WOWP_Plugin;
19
20 /**
21 * Class DashboardHelper
22 *
23 * This class provides various helper methods for handling dashboard operations.
24 */
25 class DashboardHelper {
26
27 public static function first_file( $folder ) {
28
29 $files = self::get_files( $folder );
30 if ( empty( $files ) ) {
31 return false;
32 }
33
34 return reset( $files )['file'];
35 }
36
37 public static function get_files( $folder ): array {
38 $scan_files = scandir( self::get_folder_path( $folder ) );
39 $files = [];
40 foreach ( $scan_files as $file ) {
41 if ( $file === '.' || $file === '..' || $file === 'index.php' ) {
42 continue;
43 }
44 $extension = pathinfo( $file, PATHINFO_EXTENSION );
45
46 $matches = explode( '.', $file );
47
48 if ( ! is_numeric( $matches[0] ) ) {
49 continue;
50 }
51
52 $file_name = self::get_file_name( $file, $folder );
53
54 $files[ $matches[0] ] = [ 'file' => $matches[1], 'name' => $file_name ];
55 }
56
57 return $files;
58 }
59
60 public static function get_file_name( $file, $folder ): string {
61
62 $file_path = self::get_folder_path( $folder ) . '/' . $file;
63 $file_data = get_file_data( $file_path, array( 'name' => 'Page Name' ) );
64
65 return $file_data['name'];
66
67 }
68
69 public static function get_folder_path( $folder ): string {
70 return WOWP_Plugin::dir() . 'admin/' . $folder;
71 }
72
73 public static function get_file( $current, $folder ) {
74 $files = scandir( self::get_folder_path( $folder ) );
75 foreach ( $files as $file ) {
76 $matches = explode( '.', $file );
77 if ( isset( $matches[1] ) && $matches[1] === $current ) {
78 return $file;
79 }
80 }
81
82 return false;
83 }
84
85 public static function search_value( $array, $value ): bool {
86
87 foreach ( $array as $item ) {
88 if ( is_array( $item ) ) {
89 if ( self::search_value( $item, $value ) ) {
90 return true;
91 }
92 } else {
93 if ( $item === $value ) {
94 return true;
95 }
96 }
97 }
98
99 return false;
100 }
101
102 }