PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.3.2
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.3.2
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / functions / filesystem.php

filesystem.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.3.2, at src/functions/filesystem.php

67 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Global functions related to the filesystem.
4 *
5 * @since 0.1.0
6 *
7 * @package SolidWP\Performance
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 /**
15 * Provides an instance of WordPress' native direct filesystem.
16 *
17 * @since 0.1.0
18 *
19 * @return WP_Filesystem_Direct
20 */
21 function swpsp_direct_filesystem() {
22 if ( ! class_exists( 'WP_Filesystem_Direct' ) ) {
23 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
24 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
25 }
26
27 if ( ! defined( 'FS_CHMOD_FILE' ) ) {
28 define( 'FS_CHMOD_FILE', swpsp_get_file_mode() );
29 }
30
31 if ( ! defined( 'FS_CHMOD_DIR' ) ) {
32 define( 'FS_CHMOD_DIR', swpsp_get_dir_mode() );
33 }
34
35 return new WP_Filesystem_Direct( [] );
36 }
37
38 /**
39 * Gets the default file mode as an octal integer.
40 *
41 * @since 0.1.0
42 *
43 * @return int
44 */
45 function swpsp_get_file_mode() {
46 if ( defined( 'FS_CHMOD_FILE' ) ) {
47 return FS_CHMOD_FILE;
48 }
49
50 return ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
51 }
52
53 /**
54 * Gets the default file mode as an octal integer.
55 *
56 * @since 0.1.0
57 *
58 * @return int
59 */
60 function swpsp_get_dir_mode() {
61 if ( defined( 'FS_CHMOD_DIR' ) ) {
62 return FS_CHMOD_DIR;
63 }
64
65 return ( fileperms( ABSPATH ) & 0777 | 0755 );
66 }
67