/**
  * Write a string to a file
  *
  * @access public
  *
  * @param string $file     Remote path to the file where to write the data.
  * @param string $contents The data to write.
  * @param int    $mode     Optional. The file permissions as octal number, usually 0644.
  *                         Default false.
  * @return bool False upon failure, true otherwise.
  */
 public function put_contents($file, $contents, $mode = false)
 {
     if ($this->authorized()) {
         return parent::put_contents($file, $contents, $mode);
     } else {
         return false;
     }
 }
Exemple #2
0
/**
 * File creation based on WordPress Filesystem
 *
 * @since 1.3.5
 *
 * @param string $file 	  The path of file will be created
 * @param string $content The content that will be printed in advanced-cache.php
 * @return bool
 */
function rocket_put_content($file, $content)
{
    require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
    require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
    $direct_filesystem = new WP_Filesystem_Direct(new StdClass());
    $chmod = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : 0644;
    return $direct_filesystem->put_contents($file, $content, $chmod);
}