예제 #1
0
 /**
  * Write a content into a file
  *
  * @param string $file
  * @param mixed $content
  * @return mixed
  * @since 1.0.0
  * @author Simone D'Amico <*****@*****.**>
  */
 function yit_file_put_contents($file, $content)
 {
     if (yit_is_writable(dirname($file))) {
         return file_put_contents($file, $content);
     } else {
         return false;
     }
 }
예제 #2
0
 /**
  * Add theme page function callback
  *
  * The function to be called to output the content for this page.
  *
  * @since 2.0.0
  * @author Simone D'Amico <*****@*****.**>
  * @return void
  */
 public function display_page()
 {
     if (!current_user_can('edit_theme_options')) {
         wp_die('<p>' . __('You do not have sufficient permissions to edit templates for this site.', 'yit') . '</p>');
     }
     $file = locate_template($this->filename);
     if (!file_exists($file) || !yit_is_writable($file)) {
         echo '<p>' . __('The file does not exist or you do not have sufficient permissions to edit this file.', 'yit') . '</p>';
         echo '<p>' . __(sprintf('Make sure the file <strong>%s</strong> exists within the root of your theme folder and the file is writable. In order to use this tool, you need to make this file writable before you can save your changes. See <a href="http://codex.wordpress.org/Changing_File_Permissions">the Codex</a> for more information.', $this->filename), 'yit') . '</p>';
         return;
     }
     $content = file_get_contents($file);
     yit_get_template('admin/editor/editor.php', array('filename' => $this->filename, 'file' => $file, 'content' => $content));
 }
예제 #3
0
 /**
  * Write a content into a file
  * 
  * @since 1.0.0
  */
 function yit_file_put_contents($file, $content)
 {
     if (yit_is_writable(dirname($file))) {
         return file_put_contents($file, $content);
     } else {
         return false;
     }
     /*
             global $wp_filesystem;
             
             if ( ! isset( $wp_filesystem ) ) {
                 require_once(ABSPATH . 'wp-admin/includes/admin.php');
             }            
             
             ob_start();
         	$url = wp_nonce_url('admin.php?page=yit_panel','yit-theme-options');
         	if ( false === ($credentials = request_filesystem_credentials($url)) ) {
         		$data = ob_get_contents();
         		ob_end_clean();
         		if ( ! empty($data) ){
         			include_once( ABSPATH . 'wp-admin/includes/screen.php');
         			include_once( ABSPATH . 'wp-admin/admin-header.php');
         			echo $data;
         			include( ABSPATH . 'wp-admin/admin-footer.php');
         			exit;
         		}
         		return;
         	}
         
         	if ( ! WP_Filesystem($credentials) ) {
         		request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
         		$data = ob_get_contents();
         		ob_end_clean();
         		if ( ! empty($data) ){                              
         			include_once( ABSPATH . 'wp-admin/includes/screen.php');
         			include_once( ABSPATH . 'wp-admin/admin-header.php');
         			echo $data;
         			include( ABSPATH . 'wp-admin/admin-footer.php');
         			exit;
         		}
         		return;
         	}
         	
         	$wp_filesystem->put_contents($file, $content, FS_CHMOD_FILE);
     */
 }
예제 #4
0
파일: Panel.php 프로젝트: zgomotos/Bazar
 /**
  * Check if the cache folder is writable
  * 
  * @since 1.0.0
  */
 public function is_cache_writable()
 {
     if (!yit_is_writable(YIT_CACHE_DIR)) {
         $message = "<strong>Cannot write cache folder</strong>. You may try setting the folder <strong>cache</strong> folder permission to <strong>755</strong> or <strong>777</strong> to solved this. <a href='" . admin_url('options.php?page=cache-permission-page') . "'>Learn how</a>.";
         yit_add_message($message, "error", "global");
     }
 }