Ejemplo n.º 1
0
 /**
  * @action load-theme-editor.php
  */
 public static function get_edition_data()
 {
     if ('POST' !== $_SERVER['REQUEST_METHOD']) {
         return;
     }
     if ('update' !== wp_stream_filter_input(INPUT_POST, 'action')) {
         return;
     }
     $theme_slug = wp_stream_filter_input(INPUT_POST, 'theme') ? wp_stream_filter_input(INPUT_POST, 'theme') : get_stylesheet();
     $theme = wp_get_theme($theme_slug);
     if (!$theme->exists() || $theme->errors() && 'theme_no_stylesheet' === $theme->errors()->get_error_code()) {
         return;
     }
     $allowed_files = $theme->get_files('php', 1);
     $style_files = $theme->get_files('css');
     $allowed_files['style.css'] = $style_files['style.css'];
     $file = wp_stream_filter_input(INPUT_POST, 'file');
     if (empty($file)) {
         $file_name = 'style.css';
         $file_path = $allowed_files['style.css'];
     } else {
         $file_name = $file;
         $file_path = sprintf('%s/%s', $theme->get_stylesheet_directory(), $file_name);
     }
     $file_contents_before = file_get_contents($file_path);
     self::$edited_file = compact('file_name', 'file_path', 'file_contents_before', 'theme');
 }
 /**
  * Retrieves data submitted on the screen, and prepares it for the appropriate context type
  *
  * @action load-theme-editor.php
  * @action load-plugin-editor.php
  * @return void
  */
 public static function get_edition_data()
 {
     if ('POST' !== $_SERVER['REQUEST_METHOD'] || 'update' !== wp_stream_filter_input(INPUT_POST, 'action')) {
         return;
     }
     if ($slug = wp_stream_filter_input(INPUT_POST, 'theme')) {
         self::$edited_file = self::get_theme_data($slug);
     }
     if ($slug = wp_stream_filter_input(INPUT_POST, 'plugin')) {
         self::$edited_file = self::get_plugin_data($slug);
     }
 }