diff --git a/includes/class-solrpower-api.php b/includes/class-solrpower-api.php index c029c6c9..632b3d4b 100644 --- a/includes/class-solrpower-api.php +++ b/includes/class-solrpower-api.php @@ -106,16 +106,25 @@ function submit_schema() { /* * Solarium does not currently support submitting schemas to the server. * So we'll do it ourselves. - * Let's check for a custom Schema.xml. It MUST be located in - * wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml. + * Let's check for a custom Schema.xml. It defaults to + * wp-content/uploads/solr-for-wordpress-on-pantheon/schema.xml + * and can be overridden with the filter 'solr_power_customer_schema_file_path'. */ $schema = SOLR_POWER_PATH . '/schema.xml'; $upload_dir = wp_upload_dir(); - $custom_schema_file = path_join( $upload_dir['basedir'], 'solr-for-wordpress-on-pantheon/schema.xml' ); - if ( file_exists( $custom_schema_file ) ) { + $custom_schema_file_path = path_join( $upload_dir['basedir'], 'solr-for-wordpress-on-pantheon/schema.xml' ); + + /** + * Filter the custom schema file path + * + * @param string $custom_schema_file_path The default message. + */ + $custom_schema_file_path = apply_filters( 'solr_power_customer_schema_file_path', $custom_schema_file_path ); + + if ( file_exists( $custom_schema_file_path ) ) { error_log( 'Solr Power: Uploading Schema from custom location' ); - $schema = $custom_schema_file; + $schema = $custom_schema_file_path; } $path = $this->compute_path(); @@ -162,7 +171,7 @@ function submit_schema() { if ( 200 === (int) $curl_opts['http_code'] ) { // Schema Upload Success. $return_value = 'Schema Upload Success: ' . $curl_opts['http_code']; - if ( $schema == $custom_schema_file ) { + if ( $schema == $custom_schema_file_path ) { $return_value = 'Custom ' . $return_value; } return $return_value;