Esempio n. 1
0
 protected function prepare()
 {
     // MEMO need for diagnosis
     define('WP_INSTALLING', true);
     //        define('WP_REPAIRING', true);
     require_once wordpress_path('wp-load.php');
 }
 protected function download(Request $request, $prefix, $attachment = false)
 {
     $path = $request->path();
     // trim prefix
     if (starts_with($path, $prefix)) {
         $path = substr($path, strlen($prefix));
     }
     debug_log('File Download[File Path]', $path);
     // make absolute file path
     $path = wordpress_path($path);
     // ERROR: file not found
     if (!is_file($path)) {
         debug_log('File Download: [Abort]: not found');
         abort(404);
     }
     $extension = pathinfo($path, PATHINFO_EXTENSION);
     // ERROR: file extension is .php
     if ($extension == 'php') {
         debug_log('File Download: [Abort]: .php');
         abort(404);
     }
     debug_log('File Download[Content Type]', $this->getMimeType($path, $extension));
     $headers = ['Content-Type' => $this->getMimeType($path, $extension)];
     if ($attachment === false) {
         return response()->make(file_get_contents($path), 200, $headers);
     }
     return response()->download($path, 200, $headers);
 }
 protected function outputThemeInfo($theme)
 {
     $theme_path = wordpress_path('wp-content/themes/') . $theme;
     // check
     if (!file_exists($theme_path)) {
         throw new \InvalidArgumentException("Theme '{$theme}' is not found.");
     }
     $theme_object = new \WP_Theme($theme, dirname($theme_path));
     //        // MEMO: template_dir と同じ
     //        $this->line("<info>[path]</info> '{$theme_path}'");
     $properties_wordpress = ['name', 'title', 'version', 'parent_theme', 'template_dir', 'stylesheet_dir', 'template', 'stylesheet', 'screenshot', 'description', 'author', 'tags', 'theme_root', 'theme_root_uri'];
     foreach ($properties_wordpress as $property) {
         $value = $theme_object->{$property};
         if (is_array($value)) {
             $value = '[' . implode(', ', $value) . ']';
         }
         $this->line("<info>[{$property}]</info> {$value}");
     }
     $properties_extra = ['php_namespace' => 'PHP Namespace'];
     foreach ($properties_extra as $property => $field) {
         $value = $theme_object->get($field);
         if (is_array($value)) {
             $value = '[' . implode(', ', $value) . ']';
         }
         $this->line("<info>[{$property}]</info> {$value}");
     }
 }
 protected function bootstrapForMultisiteSetup()
 {
     define('WP_INSTALLING', true);
     define('WP_REPAIRING', true);
     global $wpdb;
     require_once wordpress_path('wp-config.php');
 }
Esempio n. 5
0
 public static function themePath($theme)
 {
     $path = wordpress_path('wp-content/themes/') . $theme;
     if (!is_dir($path)) {
         return false;
     }
     return $path;
 }
Esempio n. 6
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     // 5分ごとに wp-cron.php を実行する
     $schedule->call(function () {
         info('Schedule run: wp-cron.php');
         require wordpress_path('wp-cron.php');
     })->everyFiveMinutes();
 }
 public function xmlrpc()
 {
     // これを定義しないと以下のエラーが出る
     // XMLRPC -32601: requested method jetpack.verifyRegistration does not exist
     define('XMLRPC_REQUEST', true);
     // MEMO PHP7で、apply_filters() がないと言われる対策。
     require_once wordpress_path('wp-config.php');
     //		info (function_exists('apply_filters'));
     // TODO xmlrpc.phpは書き直した方がいい
     require wordpress_path('xmlrpc.php');
 }
 protected function download(Request $request, $prefix)
 {
     $path = $request->path();
     // trim prefix
     if (starts_with($path, $prefix)) {
         $path = substr($path, strlen($prefix));
     }
     info('Download: ' . $path);
     // make absolute file path
     $path = wordpress_path($path);
     // ERROR: file not found
     if (!is_file($path)) {
         abort(404);
     }
     $extension = pathinfo($path, PATHINFO_EXTENSION);
     // ERROR: file extension is .php
     if ($extension == 'php') {
         abort(404);
     }
     info('Content-Type: ' . $this->getMimeType($extension));
     return response()->download($path, null, ['Content-Type' => $this->getMimeType($extension)]);
 }
 public function provide()
 {
     $this->setupLaravelEnvironment();
     /*
      * Tells WordPress to load the WordPress theme and output it.
      *
      * @var bool
      */
     define('WP_USE_THEMES', true);
     // Process
     wp();
     // remove admin redirect action
     remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);
     if (config('wordpress.themes.blade.precompile')) {
         // Compile blade files
         $this->prepareTemplates(true);
         add_filter('template_include', [$this, 'renderPhpTemplate']);
     } else {
         $this->prepareTemplates(false);
         add_filter('template_include', [$this, 'evaluateTemplate']);
     }
     /* Loads the WordPress Template */
     require wordpress_path('wp-includes/template-loader.php');
 }
 public function runPhpScript()
 {
     $path = app('request')->path();
     $prefix = config('wordpress.url.backend_prefix');
     // trim prefix
     if (starts_with($path, $prefix)) {
         $path = substr($path, strlen($prefix));
     }
     $path = wordpress_path($path);
     // ERROR: file not found
     if (!is_file($path)) {
         abort(404);
     }
     require $path;
 }
Esempio n. 11
0
 protected function process(array $config)
 {
     global $wpdb;
     // We need to create references to ms global tables to enable Network.
     foreach ($this->singlesiteTables() as $table => $prefixed_table) {
         $wpdb->{$table} = $prefixed_table;
     }
     require_once wordpress_path('wp-admin/includes/upgrade.php');
     $result = wp_install($config['site_title'], $config['admin_username'], $config['admin_email'], $config['site_public'], '', wp_slash($config['admin_password']), $config['language']);
     //        var_dump($result);
     update_option('siteurl', $config['backend_url']);
     update_option('home', $config['site_url']);
     update_option('blogdescription', $config['site_description']);
     if ($config['language'] == 'ja') {
         // 週の初めは '日曜日'
         update_option('start_of_week', '0');
         // 日付フォーマットは 'Y年n月j日'
         update_option('date_format', 'Y年n月j日');
         // 時刻フォーマットは 'H:i'
         update_option('time_format', 'H:i');
     }
 }
 protected function runScript($path, array $globals = [])
 {
     // add script specified global variables
     $globals = array_merge($globals, WordPress::globals($path) ?: []);
     foreach ($globals as $global) {
         global ${$global};
     }
     if (env('APP_ENV') == 'testing1') {
         ob_start();
         // We'll evaluate the contents of the view inside a try/catch block so we can
         // flush out any stray output that might get out before an error occurs or
         // an exception is thrown. This prevents any partial views from leaking.
         try {
             require wordpress_path($path);
         } catch (Exception $e) {
             ob_end_clean();
         }
         return ltrim(ob_get_clean());
     } else {
         require wordpress_path($path);
     }
 }
 protected function createMultisiteTables()
 {
     global $wpdb;
     // We need to create references to ms global tables to enable Network.
     foreach ($this->multisiteTables() as $table => $prefixed_table) {
         $wpdb->{$table} = $prefixed_table;
     }
     // Create network tables.
     require_once wordpress_path('wp-admin/includes/upgrade.php');
     install_network();
 }
 protected function runScript($path, array $globals = [])
 {
     // add script specified global variables
     $globals = array_merge($globals, WordPress::globals($path) ?: []);
     foreach ($globals as $global) {
         global ${$global};
     }
     require wordpress_path($path);
 }