Skip to content

Instantly share code, notes, and snippets.

@mstyne
Created April 26, 2016 20:34
Show Gist options
  • Save mstyne/ff31952bb6751f1d95454ef2c907a075 to your computer and use it in GitHub Desktop.
Save mstyne/ff31952bb6751f1d95454ef2c907a075 to your computer and use it in GitHub Desktop.
/**
* @param string $url
*/
protected static function getFileSystem( $url = '' ) {
if ( empty( $url ) ) {
$url = wp_nonce_url( 'admin.php?page=vc-general', 'wpb_js_settings_save_action' );
}
if ( false === ( $creds = request_filesystem_credentials( $url, '', false, false, null ) ) ) {
_e( 'This is required to enable file writing for js_composer', 'js_composer' );
exit(); // stop processing here
}
$upload_dir = wp_upload_dir();
if ( ! WP_Filesystem( $creds, $upload_dir['basedir'] ) ) {
request_filesystem_credentials( $url, '', true, false, null );
_e( 'This is required to enable file writing for js_composer', 'js_composer' );
exit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment