| 1 |
<?php |
| 2 |
|
| 3 |
// Try to create the mu-plugins folder/file. |
| 4 |
// No need to do this if it already exists. |
| 5 |
if ( file_exists( WPMU_PLUGIN_DIR . '/patchstack.php' ) || file_exists( WPMU_PLUGIN_DIR . '/_patchstack.php' )) { |
| 6 |
update_option('patchstack_db_version', '3.0.3'); |
| 7 |
return; |
| 8 |
} |
| 9 |
|
| 10 |
// The mu-plugin does not exist, try to create it. |
| 11 |
@include_once ABSPATH . 'wp-admin/includes/file.php'; |
| 12 |
$wpfs = WP_Filesystem(); |
| 13 |
|
| 14 |
// Failed to initialize WP_Filesystem. |
| 15 |
if ( ! $wpfs ) { |
| 16 |
update_option('patchstack_db_version', '3.0.3'); |
| 17 |
return; |
| 18 |
} |
| 19 |
|
| 20 |
// Try to create the mu-plugins folder. |
| 21 |
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { |
| 22 |
wp_mkdir_p( WPMU_PLUGIN_DIR ); |
| 23 |
} |
| 24 |
|
| 25 |
// Failed to create the mu-plugin folder. |
| 26 |
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) { |
| 27 |
update_option('patchstack_db_version', '3.0.3'); |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
// Create the mu-plugin file in the folder. |
| 32 |
if ( is_writable( WPMU_PLUGIN_DIR ) ) { |
| 33 |
$php = file_get_contents( trailingslashit( plugin_dir_path( __FILE__ ) ) . '../mu-plugin.php' ); |
| 34 |
file_put_contents( trailingslashit( WPMU_PLUGIN_DIR ) . '_patchstack.php', $php ); |
| 35 |
} |
| 36 |
|
| 37 |
update_option('patchstack_db_version', '3.0.3'); |