Skip to content

Commit 4577180

Browse files
committed
Renameed shortcode 'object' attribute to 'path'
1 parent 402bd65 commit 4577180

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This is a WordPress plugin that allows you to serve your WordPress Media Library
2929

3030
- Limit offloading by MIME types
3131
- Option to remove files from origin server
32-
- [Shortcode](https://github.com/cloudverve/wordpress-cloud-media-offloader-plugin/wiki/Shortcodes) to create hyperlinks
32+
- [Shortcode](https://github.com/cloudverve/wordpress-cloud-media-offloader-plugin/wiki/Shortcodes) to create hyperlinks and output image tags
3333
- :new: CloudFlare support ([more info](https://www.backblaze.com/blog/backblaze-and-cloudflare-partner-to-provide-free-data-transfer/))
3434

3535
### Contributing

app/Shortcodes/B2_Object_Shortcode.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function __construct() {
1111

1212
if( !self::$client ) self::$client = B2::auth();
1313

14-
// Usage example: [b2_object bucket="my-bucket" object="wp-conteent/uploads/example.pdf"]Example File[/b2_object]
14+
// Usage example: [b2_object bucket="my-bucket" path="wp-conteent/uploads/example.pdf"]Example File[/b2_object]
1515
if ( ! shortcode_exists( 'b2_object' ) ) {
1616
add_shortcode( 'b2_object', array( $this, 'b2_object_shortcode' ) );
1717
}
@@ -28,7 +28,7 @@ public function __construct() {
2828
public function b2_object_shortcode( $atts, $content = null ) {
2929
$atts = shortcode_atts( [
3030
'bucket' => null,
31-
'object' => null,
31+
'path' => null,
3232
'silent' => false,
3333
'output' => null, // image, link, url
3434
'title' => null
@@ -44,21 +44,21 @@ public function b2_object_shortcode( $atts, $content = null ) {
4444

4545
// Get bucket object
4646
$bucket = $atts['bucket'] ? B2::get_bucket_by_name( $atts['bucket'] ) : B2::get_bucket_by_id( $this->get_carbon_plugin_option( 'bucket_id' ) );
47-
if( empty( $atts['object'] ) || !$bucket ) return $atts['silent'] ? '' : __( 'Invalid bucket', self::$textdomain );
47+
if( empty( $atts['path'] ) || !$bucket ) return $atts['silent'] ? '' : __( 'Invalid bucket', self::$textdomain );
4848

4949
// Get file object
5050
try {
51-
$file_object = self::$client->getFile( [ 'BucketName' => $bucket['name'], 'FileName' => $atts['object'] ] );
51+
$file_object = self::$client->getFile( [ 'BucketName' => $bucket['name'], 'FileName' => $atts['path'] ] );
5252
} catch ( \ChrisWhite\B2\Exceptions\NotFoundException $e ) {
5353
return $atts['silent'] ? '' : __( 'Object not found', self::$textdomain );
5454
}
5555

5656
// Get object URL
5757
$custom_url = rtrim( trim( $this->get_carbon_plugin_option( 'custom_url' ) ), '/' );
5858
if( $this->get_carbon_plugin_option( 'enable_custom_url' ) && trim( $custom_url ) ) {
59-
$url = sprintf( '%s/file/%s/%s', $custom_url, $bucket['name'], $atts['object'] );
59+
$url = sprintf( '%s/file/%s/%s', $custom_url, $bucket['name'], $atts['path'] );
6060
} else {
61-
$url = self::$client->getDownloadUrl( [ 'BucketName' => $bucket['name'], 'FileName' => $atts['object'] ] );
61+
$url = self::$client->getDownloadUrl( [ 'BucketName' => $bucket['name'], 'FileName' => $atts['path'] ] );
6262
}
6363

6464
// Create hyperlink

0 commit comments

Comments
 (0)