Skip to content

Instantly share code, notes, and snippets.

@ClaraLeigh
Created January 9, 2019 05:52
Show Gist options
  • Save ClaraLeigh/12f44103145f43b777cfa9cfced86ed1 to your computer and use it in GitHub Desktop.
Save ClaraLeigh/12f44103145f43b777cfa9cfced86ed1 to your computer and use it in GitHub Desktop.
add_action( 'init', function() {
if ( isset( $_GET['do_write_test'] ) && $_GET['do_write_test'] == '1') {
// Login
wp_set_current_user(1);
wp_set_auth_cookie(1, false, true);
// Include Filesystem
require_once(ABSPATH . 'wp-admin/includes/file.php');
\WP_Filesystem();
global $wp_filesystem;
//// Attempt to Write to akismet.txt
echo 'Attempt to Write to akismet.txt<br>';
$attempt1 = $wp_filesystem->put_contents('akismet.txt', "Test23", 0644);
var_dump($attempt1);
echo "<br><br>";
//// Attempt to Write to akismet.txt
echo 'Attempt to Write to akismet.php<br>';
$attempt2 = $wp_filesystem->put_contents('akismet.php', "Test23", 0644);
var_dump($attempt2);
echo "<br><br>";
echo 'Test Complete';
exit;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment