elementor / elementor/wp2static
Bedrock Support / Filtering SiteInfo Class
- Dominant language
- PHP
- Stars
- 1.5k
- Forks
- 294
- PR merge metrics
- No merged PRs in 30d
Description
There is a problem with WP2Static and Bedrock. Bedrock has a bit different folder structure (https://roots.io/docs/bedrock/master/folder-structure/) and the ABSPATH is pointing a bit wrong (it's pointing the `wp` folder when it should point to the `web` folder).
Apart from Bedrock probably this could also cause problems where home_url and site_url are different (although I'm guessing here).
So I think that we should make all the properties filterable - something like:
```php
$info = [
// Core
'site_path' => ABSPATH,
'site_url' => $site_url,
/*
Note: 'home_path' => get_home_path(),
// errors trying to find it in WP2Static\get_home_path()...
*/
'home_url' => trailingslashit( get_home_url() ),
'includes_path' => trailingslashit( ABSPATH . WPINC ),
'includes_url' => includes_url(),
/*
TODO: Q on subdir:
Does it matter?
'subdirectory' => $this->isSiteInstalledInSubDirectory(),
A: It shouldn't, but current mechanism for rewriting URLs
has some cases that require knowledge of it...
*/
// Content
'content_path' => trailingslashit( WP_CONTENT_DIR ),
'content_url' => trailingslashit( content_url() ),
'uploads_path' =>
trailingslashit( $upload_path_and_url['basedir'] ),
'uploads_url' => trailingslashit( $upload_path_and_url['baseurl'] ),
// Plugins
'plugins_path' => trailingslashit( WP_PLUGIN_DIR ),
'plugins_url' => trailingslashit( plugins_url() ),
// Themes
'themes_root_path' => trailingslashit( get_theme_root() ),
'themes_root_url' => trailingslashit( get_theme_root_uri() ),
'parent_theme_path' => trailingslashit( get_template_directory() ),
'parent_theme_url' =>
trailingslashit( get_template_directory_uri() ),
'child_theme_path' => trailingslashit( get_stylesheet_directory() ),
'child_theme_url' =>
trailingslashit( get_stylesheet_directory_uri() ),
];
self::$info = apply_filters( 'wp2static_modify_siteinfo', $info );
```
and than we could create a mu-plugin for Bedrock that would use the correct `site_path` based on:
```php
/**
* Directory containing all of the site's files
*
* @var string
*/
$root_dir = dirname(__DIR__);
/**
* Document Root
*
* @var string
*/
$webroot_dir = $root_dir . '/web';
// OTHER CODE
Config::define('CONTENT_DIR', '/app');
Config::define('WP_CONTENT_DIR', $webroot_dir . Config::get('CONTENT_DIR'));
```
If you're OK with this I will gladly create a PR for this.
Contributor guide
Assessment
This issue has not been assessed yet.