Skip to content

Commit

Permalink
Merge pull request #47 from threadi/fix/setCapatibilitiesForPlayground
Browse files Browse the repository at this point in the history
Fix/set capatibilities for playground
  • Loading branch information
threadi authored Nov 11, 2024
2 parents 3738f79 + 7b5a07a commit 810892f
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/ExternalFiles/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public function add_url( string $url, bool $add_to_queue = false ): bool {
// bail if file is given, but has an error.
if ( ! empty( $file_data['tmp-file'] ) && is_wp_error( $file_data['tmp-file'] ) ) {
/* translators: %1$s will be replaced by an error-code. */
$log->create( sprintf( __( 'Given URL results in error during request: <pre>%1$s</pre>', 'external-files-in-media-library' ), wp_json_encode( $file_data['tmp-file'] ) ), esc_url( $url ), 'error', 0 );
$log->create( sprintf( __( 'Given URL results in error during request: %1$s', 'external-files-in-media-library' ), '<code>' . wp_json_encode( $file_data['tmp-file'] ) . '</code>' ), esc_url( $url ), 'error', 0 );

// show progress.
$progress ? $progress->tick() : '';
Expand Down
2 changes: 1 addition & 1 deletion app/ExternalFiles/Forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ private function get_fields( bool $single = false ): array {
}

// add credentials fields.
$fields[] = '<details><summary>' . __( 'Add credentials to access this URL', 'external-files-in-media-library' ) . '</summary><div><label for="eml_login">' . __( 'Login', 'external-files-in-media-library' ) . ':</label><input type="text" id="eml_login" name="text" value="" autocomplete="off"></div><div><label for="eml_password">' . __( 'Password', 'external-files-in-media-library' ) . ':</label><input type="password" id="eml_password" name="text" value="" autocomplete="off"></div><p><strong>' . __( 'Hint:', 'external-files-in-media-library' ) . '</strong> ' . __( 'files with credentials will be saved locally.', 'external-files-in-media-library' ) . '</p></details>';
$fields[] = '<details><summary>' . __( 'Add credentials to access this URL', 'external-files-in-media-library' ) . '</summary><div><label for="eml_login">' . __( 'Login', 'external-files-in-media-library' ) . ':</label><input type="text" id="eml_login" name="text" value="" autocomplete="off"></div><div><label for="eml_password">' . __( 'Password', 'external-files-in-media-library' ) . ':</label><input type="password" id="eml_password" name="text" value="" autocomplete="off"></div><p><strong>' . __( 'Hint:', 'external-files-in-media-library' ) . '</strong> ' . __( 'Files with credentials will be saved locally.', 'external-files-in-media-library' ) . '</p></details>';

/**
* Filter the fields for the dialog.
Expand Down
2 changes: 1 addition & 1 deletion app/ExternalFiles/Protocols/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function check_url( string $url ): bool {
if ( false === filter_var( $url, FILTER_VALIDATE_URL ) ) {
// log event.
/* translators: %1$s will be replaced by the file-URL */
Log::get_instance()->create( sprintf( __( 'Given string %1$s is not a valid url.', 'external-files-in-media-library' ), esc_html( $url ) ), esc_html( $url ), 'error', 0 );
Log::get_instance()->create( sprintf( __( 'Given string %1$s is not a valid URL.', 'external-files-in-media-library' ), esc_html( $url ) ), esc_html( $url ), 'error', 0 );

// return that given string is not a valid URL.
return false;
Expand Down
2 changes: 1 addition & 1 deletion app/ExternalFiles/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function run( string $template ): string {
if ( false === $external_file_obj || ( $external_file_obj && false === $external_file_obj->is_valid() ) ) {
// log this event.
/* translators: %1$s will be replaced by the detected filename. */
Log::get_instance()->create( sprintf( __( 'Proxy could not load load the filename %1$s as external file.', 'external-files-in-media-library' ), '<code>' . $title . '</code>' ), '', 'info', 2 );
Log::get_instance()->create( sprintf( __( 'Proxy could not load the filename %1$s as external file.', 'external-files-in-media-library' ), '<code>' . $title . '</code>' ), '', 'info', 2 );

// fallback to 404.
return $template;
Expand Down
4 changes: 2 additions & 2 deletions app/ExternalFiles/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function process_queue(): void {

// log event.
/* translators: %1$d will be replaced by a number. */
Log::get_instance()->create( sprintf( _n( 'Processing the import of %1$d URL from queue ended.', 'Processing the import of %1$d URLs from queue.', count( $urls_to_import ), 'external-files-in-media-library' ), count( $urls_to_import ) ), '', 'info', 2 );
Log::get_instance()->create( sprintf( _n( 'Processing the import of %1$d URL from queue ended.', 'Processing the import of %1$d URLs from queue ended.', count( $urls_to_import ), 'external-files-in-media-library' ), count( $urls_to_import ) ), '', 'info', 2 );
}

/**
Expand Down Expand Up @@ -627,7 +627,7 @@ private function db_error_handling( \mysqli_result|bool|int|null $result, string

// log this event.
/* translators: %1$s is replaced by an error-code. */
Log::get_instance()->create( sprintf( __( 'Database-Error: %1$s', 'external-files-in-media-library' ), wp_json_encode( $wpdb->last_error ) ), $url, 'error', 0 );
Log::get_instance()->create( sprintf( __( 'Database-Error: %1$s', 'external-files-in-media-library' ), '<code>' . wp_json_encode( $wpdb->last_error ) . '</code>' ), $url, 'error', 0 );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Plugin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function add_settings(): void {
$setting->set_field(
array(
'type' => 'Checkbox',
'title' => __( 'Switch external files to local hosting during uninstallation', 'external-files-in-media-library' ),
'title' => __( 'Switch external files to local hosting during uninstallation', 'external-files-in-media-library' ),
'description' => __( 'If this option is enabled all external files will be saved local during uninstallation of this plugin.', 'external-files-in-media-library' ),
)
);
Expand Down
1 change: 1 addition & 0 deletions app/Plugin/Uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function run(): void {
'eml_import_title',
'eml_import_errors',
'eml_transients',
'efmlVersion',
);
foreach ( $options as $option ) {
delete_option( $option );
Expand Down
12 changes: 1 addition & 11 deletions app/Plugin/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,7 @@ public static function get_instance(): Update {
* @return void
*/
public function init(): void {
add_action( 'plugins_loaded', array( $this, 'run' ) );
}

/**
* Wrapper to run all version-specific updates, which are in this class.
*
* @return void
*/
public static function run_all_updates(): void {
$obj = self::get_instance();
$obj->version200();
add_action( 'init', array( $this, 'run' ) );
}

/**
Expand Down
4 changes: 4 additions & 0 deletions assets/blueprints/blueprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"activate": true
}
},
{
"step": "runPHP",
"code": "<?php\nrequire '/wordpress/wp-load.php';\n\nupdate_option( 'eml_allowed_roles', array( 'administrator' ) );\\ExternalFilesInMediaLibrary\\Plugin\\Helper::set_capabilities(get_option( 'eml_allowed_roles' ));"
},
{
"step": "login",
"username": "admin",
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tested up to: 6.7
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Stable tag: 2.0.0
Stable tag: 2.0.1

Add external files to your media library to link or embed them in your website. They will be integrated as if they were locally available.

Expand Down Expand Up @@ -192,3 +192,8 @@ Yes, there are many options on WP CLI, see [our documentation](https://github.co
* Move support for already supported plugins in new wrapper
* Fixed some typos
* Fixed error with import of multiple files via WP CLI

= 2.0.1 =
* Small optimizations on texts for better translations
* Fixed update handler for WordPress 6.7
* Fixed setting of capabilities for Playground

0 comments on commit 810892f

Please sign in to comment.