@@ -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