PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 6.0.5
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v6.0.5
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / classes / Dashboard / DashboardHelper.php

DashboardHelper.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 6.0.5, at classes/Dashboard/DashboardHelper.php

85 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 namespace FloatingButton\Dashboard;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use FloatingButton\WOW_Plugin;
8
9 class DashboardHelper {
10
11 public static function first_file( $folder ) {
12
13 $files = self::get_files( $folder );
14
15 return reset( $files )['file'];
16 }
17
18 public static function get_files( $folder ): array {
19 $scan_files = scandir( self::get_folder_path( $folder ) );
20 $files = [];
21 foreach ( $scan_files as $file ) {
22 if ( $file === '.' || $file === '..' || $file === 'index.php' ) {
23 continue;
24 }
25 $extension = pathinfo( $file, PATHINFO_EXTENSION );
26
27 if ( $extension !== 'php' ) {
28 continue;
29 }
30 $matches = explode( '.', $file );
31 if ( ! is_numeric( $matches[0] ) ) {
32 continue;
33 }
34
35 $file_name = self::get_file_name( $file, $folder );
36
37 $files[ $matches[0] ] = [ 'file' => $matches[1], 'name' => $file_name ];
38 }
39
40 return $files;
41 }
42
43 public static function get_file_name( $file, $folder ): string {
44
45 $file_path = self::get_folder_path( $folder ) . '/' . $file;
46 $file_data = get_file_data( $file_path, array( 'name' => 'Page Name' ) );
47
48 return $file_data['name'];
49
50 }
51
52 public static function get_folder_path( $folder ): string {
53 return WOW_Plugin::dir() . 'includes/' . $folder;
54 }
55
56 public static function get_file( $current, $folder ) {
57 $files = scandir( self::get_folder_path( $folder ) );
58 foreach ( $files as $file ) {
59 $matches = explode( '.', $file );
60 if ( isset( $matches[1] ) && $matches[1] === $current ) {
61 return $file;
62 }
63 }
64
65 return false;
66 }
67
68 public static function search_value( $array, $value ): bool {
69
70 foreach ( $array as $item ) {
71 if ( is_array( $item ) ) {
72 if ( self::search_value( $item, $value ) ) {
73 return true;
74 }
75 } else {
76 if ( $item === $value ) {
77 return true;
78 }
79 }
80 }
81
82 return false;
83 }
84
85 }