Dynamic path to settings.xml/settings.php when running embedded
-
Hello!
We run Types embedded in some of our themes because of a multi user-setup.
This is because the sites use the same theme, but with separate uploads-folders and databases.To do this, we follow the instructions of copying the embedded-folder into the theme.
But as we keep our plugins automatically updated with composer in the plugins directory we would like to include the embedded-folder directly instead of “detaching” the embedded files.
By “detaching” i mean that we move the emdedded folder out of the plugins-folder that is automatically updated from the WordPress-repository.
As far as i can see this in itself is not a problem, but we would like to keep the settings.php and settings.xml-files in a separate versioned folder. For example these files could be kept in a folder in the theme.
Basically there should be an option to specify where the config-files are located when embedding Types.
The lines that are affected:
embedded/functions.php:125
embedded/functions.php:136
embedded/functions.php:144A proposal would be to do like this:
Create a extra constant that falls back to “WPCF_EMBEDDED_ABSPATH”.
if ( file_exists( WPCF_EMBEDDED_ABSPATH . '/settings.php' ) ) { if(!defined('WPCF_EMBEDDED_CONFIG_ABSPATH')) { define('WPCF_EMBEDDED_CONFIG_ABSPATH', WPCF_EMBEDDED_ABSPATH); } require_once WPCF_EMBEDDED_ABSPATH . '/admin.php'; require_once WPCF_EMBEDDED_CONFIG_ABSPATH . '/settings.php'; $dismissed = get_option( 'wpcf_dismissed_messages', array() ); if ( in_array( $timestamp, $dismissed ) ) { return false; } if ( $timestamp > get_option( 'wpcf-types-embedded-import', 0 ) ) { if ( isset( $_GET['types-embedded-import'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'embedded-import') ) { if ( file_exists( WPCF_EMBEDDED_CONFIG_ABSPATH . '/settings.xml' ) ) { $_POST['overwrite-groups'] = 1; $_POST['overwrite-fields'] = 1; $_POST['overwrite-types'] = 1; $_POST['overwrite-tax'] = 1; $_POST['post_relationship'] = 1; require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php'; require_once WPCF_EMBEDDED_INC_ABSPATH . '/import-export.php'; $data = @file_get_contents( WPCF_EMBEDDED_CONFIG_ABSPATH . '/settings.xml' ); wpcf_admin_import_data( $data, false, 'types-auto-import' ); update_option( 'wpcf-types-embedded-import', $timestamp ); wp_safe_redirect( esc_url_raw(admin_url() )); } else { $code = __( 'settings.xml file missing', 'wpcf' ); wpcf_admin_message( $code, 'error' ); } }
This would be great as the developer could specify the placement of the config-files himself, but by default it looks for the config-files in embedded folder.
Hope to hear from you, all feedback is appreciated ??
Creds to you for a very nice plugin and WP Toolset!
Best regards, Robert Sather.
https://www.ads-software.com/plugins/types/
- The topic ‘Dynamic path to settings.xml/settings.php when running embedded’ is closed to new replies.