Skip to content

Commit

Permalink
Merge pull request #361 from 10up/develop
Browse files Browse the repository at this point in the history
[Release] 2.8.4 - Develop to Master
  • Loading branch information
felipeelia authored Nov 30, 2023
2 parents b52c928 + ff1c36a commit 3806fa2
Show file tree
Hide file tree
Showing 20 changed files with 296 additions and 732 deletions.
28 changes: 27 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,32 @@ All notable changes to this project will be documented in this file, per [the Ke

## [Unreleased] - TBD

## [2.8.3] - 2022-08-03
<!--
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
-->

## [2.8.4] - 2023-11-30

### Added
- Brightcove version to user agent string. Props [@felipeelia](https://github.com/felipeelia) via [#341](https://github.com/10up/brightcove-video-connect/pull/341).

### Changed
- Use `wp.blockEditor.BlockControls` if available. Props [@felipeelia](https://github.com/felipeelia), [@JakePT](https://github.com/JakePT), and [@oscarssanchez](https://github.com/oscarssanchez) via [#342](https://github.com/10up/brightcove-video-connect/pull/342).

### Fixed
- Empty "Created At:" and "Updated At:" in playlists. Props [@burhandodhy](https://github.com/burhandodhy) and [@MARQAS](https://github.com/MARQAS) via [#349](https://github.com/10up/brightcove-video-connect/pull/349).
- Help notices being displayed more than once. Props [@burhandodhy](https://github.com/burhandodhy) and [@MARQAS](https://github.com/MARQAS) via [#350](https://github.com/10up/brightcove-video-connect/pull/350).
- Caption upload. Props [@burhandodhy](https://github.com/burhandodhy) and [@MARQAS](https://github.com/MARQAS) via [#351](https://github.com/10up/brightcove-video-connect/pull/351).

### Security
- Bumped `@babel/traverse` from 7.22.8 to 7.23.2. Props [@dependabot](https://github.com/dependabot) via [#343](https://github.com/10up/brightcove-video-connect/pull/343).

## [2.8.3] - 2023-08-03

### Fixed
- Playlist experience not rendering correctly in frontend
Expand Down Expand Up @@ -418,6 +443,7 @@ All notable changes to this project will be documented in this file, per [the Ke
- First release

[Unreleased]: https://github.com/10up/brightcove-video-connect/compare/master...develop
[2.8.4]: https://github.com/10up/brightcove-video-connect/compare/2.8.3...2.8.4
[2.8.3]: https://github.com/10up/brightcove-video-connect/compare/2.8.2...2.8.3
[2.8.2]: https://github.com/10up/brightcove-video-connect/compare/2.8.1...2.8.2
[2.8.1]: https://github.com/10up/brightcove-video-connect/compare/2.8.0...2.8.1
Expand Down
26 changes: 16 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ For more on how 10up writes and manages code, check out our [10up Engineering Be
The `develop` branch is the development branch which means it contains the next version to be released. `master` contains the corresponding stable development version. Always branch off the `develop` branch and open up PRs against `develop`.

## Release instructions
1. Create a new branch following the format `release/x.y.z`
2. Changelog: Add/update the changelog in `CHANGELOG.md` and `readme.txt`, ensuring to link the [X.Y.Z] release reference in the footer of `CHANGELOG.md` (e.g., https://github.com/10up/brightcove-video-connect/compare/X.Y.Z-1...X.Y.Z)
3. Update the plugin version in `readme.txt`, `package.json`, `brightcove-video-connect.php` in plugin version and `BRIGHTCOVE_VERSION` constant
4. If applicable, bump the `tested up to` field in `readme.txt`
5. Run `npm run build` to generate updated translation files
6. Commit your changes and open a PR to `develop`
7. Once changes are merged, open a PR from `develop` to `master`
8. Once changes are merged, draft a new release https://github.com/10up/brightcove-video-connect/releases/new selecting as target `master`
9. Check the deploy to WordPres.org GitHub action ran correctly https://github.com/10up/brightcove-video-connect/actions
10. Verify the WordPress.org repository is updated. This may take a few minutes

1. Branch: Starting from `develop`, create a new branch following the format `release/X.Y.Z`.
1. Version bump: Update the plugin version in `readme.txt`, `package.json`, `package-lock.json`, `brightcove-video-connect.php` in plugin version and `BRIGHTCOVE_VERSION` constant.
1. Changelog: Add/update the changelog in `CHANGELOG.md` and `readme.txt`, ensuring to link the [X.Y.Z] release reference in the footer of `CHANGELOG.md` (e.g., https://github.com/10up/brightcove-video-connect/compare/X.Y.Z-1...X.Y.Z).
1. New files: Check to be sure any new files/paths that are unnecessary in the production version are included in `.gitattributes`.
1. If applicable, bump the `Tested up to` field in `readme.txt`.
1. Release date: Double check the release date in both changelog files.
1. Run `npm run build` to generate updated translation files.
1. Commit your changes and open a PR to `develop`.
1. Once changes are merged, open a PR from `develop` to `master`.
1. Test: Once changes are merged, checkout the `master` branch locally and test for functionality.
1. Release: Once merged, draft a [new release](https://github.com/10up/brightcove-video-connect/releases/new) naming the release with the new version number, creating a new label `X.Y.Z`, and selecting as target `master`. Paste the release changelog from `CHANGELOG.md` into the body of the release and include a link to the closed issues on the [milestone](https://github.com/10up/brightcove-video-connect/#?closed=1).
1. SVN: Wait for the [GitHub Action](https://github.com/10up/brightcove-video-connect/actions/workflows/push-deploy.yml) to finish deploying to the WordPress.org repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes.
1. Check WordPress.org: Ensure that the changes are live on https://wordpress.org/plugins/brightcove-video-connect/. This may take a few minutes.
1. Close milestone: Edit the [milestone](https://github.com/10up/brightcove-video-connect/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close the milestone.
1. Punt incomplete items: If any open issues or PRs which were milestoned for `X.Y.Z` do not make it into the release, update their milestone to `X.Y.Z+1`, `X.Y+1.0`, `X+1.0.0` or `Future Release`.
2 changes: 1 addition & 1 deletion assets/css/brightcove_video_connect.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/css/jquery-ui-datepicker.min.css

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions assets/js/brightcove-admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/js/brightcove-admin.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/js/brightcove-admin.min.js

Large diffs are not rendered by default.

67 changes: 46 additions & 21 deletions assets/js/src/block.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/* global wp, bctiny, bcBlock */
(function (blocks, element, components, editor) {
(function (blocks, element, components) {
const { __, sprintf } = wp.i18n;

const { BlockControls } = wp.blockEditor;
const { Button, Dashicon, ToolbarGroup, ToolbarButton } = components;

var el = element.createElement,
registerBlockType = blocks.registerBlockType,
Placeholder = components.Placeholder,
BlockControls = editor.BlockControls,
IconButton = components.IconButton,
userPermission = !!bcBlock.userPermission,
InspectorControls = wp.blockEditor.InspectorControls,
TextControl = components.TextControl;
Expand Down Expand Up @@ -248,23 +249,47 @@
jQuery(document).on('change', '#' + target, onSelectVideo);

// Set up our controls
var controls = el(
BlockControls,
{ key: 'controls' },
el(
'div',
{ className: 'components-toolbar' },
el(IconButton, {
className:
'brightcove-add-media components-icon-button components-toolbar__control',
label: videoId.playlist_id
? __('Change Playlist', 'brightcove')
: __('Change Video', 'brightcove'),
icon: 'edit',
'data-target': '#' + target,
}),
),
);
if (typeof ToolbarGroup === 'function') {
var controls = el(
BlockControls,
{},
el(
ToolbarGroup,
{},
el(ToolbarButton, {
className:
'brightcove-add-media components-icon-button components-toolbar__control',
label: videoId.playlist_id
? __('Change Playlist', 'brightcove')
: __('Change Video', 'brightcove'),
icon: 'edit',
'data-target': '#' + target,
}),
),
);
} else {
var controls = el(
BlockControls,
{ key: 'controls' },
el(
'div',
{ className: 'components-toolbar' },
el(
Button,
{
className:
'brightcove-add-media components-icon-button components-toolbar__control',
label: videoId.playlist_id
? __('Change Playlist', 'brightcove')
: __('Change Video', 'brightcove'),

'data-target': '#' + target,
},
el(Dashicon, { icon: 'edit' }),
),
),
);
}

// If no video has been selected yet, show the selection view
if (
Expand Down Expand Up @@ -654,4 +679,4 @@
return null;
},
});
})(window.wp.blocks, window.wp.element, window.wp.components, window.wp.editor);
})(window.wp.blocks, window.wp.element, window.wp.components);
4 changes: 2 additions & 2 deletions assets/js/src/views/media-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ var MediaDetailsView = BrightcoveView.extend({
options = _.extend({}, options, this.model.toJSON());
// options.duration = this.model.getReadableDuration();
options.duration = '0:05';
options.updated_at_readable = this.model.getReadableDate('updatedAt');
options.created_at_readable = this.model.getReadableDate('createdAt');
options.updated_at_readable = this.model.getReadableDate('updated_at');
options.created_at_readable = this.model.getReadableDate('created_at');
options.account_name = this.model.getAccountName();

this.template = wp.template('brightcove-media-item-details-' + this.mediaType);
Expand Down
3 changes: 3 additions & 0 deletions assets/js/src/views/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ var ToolbarView = BrightcoveView.extend({
toggleToolbar: function () {
var template = wp.template('brightcove-tooltip-notice');

// Remove any existing tooltip notice
$('#js-tooltip-notice').remove();

// Throw a notice to the user that the file is not the correct format
$('.brightcove.media-frame-router').before(template);
// Allow the user to dismiss the notice
Expand Down
4 changes: 2 additions & 2 deletions brightcove-video-connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Brightcove Video Connect
* Plugin URI: https://wordpress.org/plugins/brightcove-video-connect/
* Description: A Brightcove™ Connector for WordPress that leverages enhanced APIs and Brightcove™ Capabilities
* Version: 2.8.3
* Version: 2.8.4
* Author: 10up
* Author URI: http://10up.com
* License: GPLv2+
Expand Down Expand Up @@ -31,7 +31,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 021.0.2301 USA
*/

define( 'BRIGHTCOVE_VERSION', '2.8.3' );
define( 'BRIGHTCOVE_VERSION', '2.8.4' );
define( 'BRIGHTCOVE_URL', plugin_dir_url( __FILE__ ) );
define( 'BRIGHTCOVE_PATH', dirname( __FILE__ ) . '/' );
define( 'BRIGHTCOVE_BASENAME', plugin_basename( __FILE__ ) );
Expand Down
8 changes: 6 additions & 2 deletions includes/admin/api/class-bc-admin-media-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ public function ajax_caption_upload( $account_hash, $video_id, $raw_captions ) {
$default = ( isset( $caption['default'] ) && 'checked' === $caption['default'] );

$source = wp_parse_url( $caption['source'] );
if ( 0 === strpos( $source['host'], 'brightcove' ) ) {
if ( 0 === strpos( $source['host'], 'brightcove' ) && false === strpos( $source['host'], '.test' ) ) {
// If the hostname starts with "brightcove," assume this media has already been ingested and add to old captions.
$old_captions[] = new BC_Text_Track( $url, $lang, 'captions', $label, $default );
continue;
Expand All @@ -957,10 +957,14 @@ public function ajax_caption_upload( $account_hash, $video_id, $raw_captions ) {
}

// Push the new captions to Brightcove
$this->cms_api->text_track_upload( $video_id, $new_captions );
$has_caption_uploaded = $this->cms_api->text_track_upload( $video_id, $new_captions );

// Restore our global, default account
$bc_accounts->restore_default_account();

if ( false === $has_caption_uploaded ) {
wp_send_json_error( esc_html__( 'Failed to upload caption.', 'brightcove' ) );
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion includes/api/class-bc-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ protected function send_request( $url, $method = 'GET', $data = array(), $force_
}

$args = array(
'headers' => $headers,
'is_brightcove_request' => true,
'headers' => $headers,
);

switch ( $method ) {
Expand Down
3 changes: 2 additions & 1 deletion includes/api/class-bc-oauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public function set_account_credentials( $client_id, $client_secret ) {
$this->client_id = $client_id;
$this->client_secret = $client_secret;
$this->http_headers = array(
'headers' => array(
'is_brightcove_request' => true,
'headers' => array(
'Content-type' => 'application/json',
'Authorization' => sprintf( 'Basic %s', base64_encode( $this->client_id . ':' . $this->client_secret ) ), // phpcs:ignore
),
Expand Down
16 changes: 8 additions & 8 deletions includes/api/class-bc-text-track.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BC_Text_Track {
*
* @var string
*/
protected $src_lang;
protected $srclang;

/**
* How the VTT file is meant to be used
Expand Down Expand Up @@ -61,8 +61,8 @@ class BC_Text_Track {
* @param bool $default Set the default language for captions/subtitles
*/
public function __construct( $url, $language = 'en-US', $kind = 'captions', $label = '', $default = false ) {
$this->url = esc_url_raw( $url );
$this->src_lang = sanitize_text_field( $language );
$this->url = esc_url_raw( $url );
$this->srclang = sanitize_text_field( $language );
if ( ! in_array( $kind, array( 'captions', 'subtitles', 'descriptions', 'chapters', 'metadata' ), true ) ) {
$this->kind = 'captions';
} else {
Expand All @@ -79,10 +79,10 @@ public function __construct( $url, $language = 'en-US', $kind = 'captions', $lab
*/
public function to_array() {
$data = array(
'url' => $this->url,
'src_lang' => $this->src_lang,
'kind' => $this->kind,
'default' => $this->default,
'url' => $this->url,
'srclang' => $this->srclang,
'kind' => $this->kind,
'default' => $this->default,
);

if ( ! empty( $this->label ) ) {
Expand All @@ -100,7 +100,7 @@ public function to_array() {
public function to_array_patch() {
$data = array(
'src' => $this->url,
'src_lang' => $this->src_lang,
'srclang' => $this->srclang,
'kind' => $this->kind,
'default' => $this->default,
'mime_type' => $this->mime_type,
Expand Down
23 changes: 23 additions & 0 deletions includes/class-bc-setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public static function action_init() {
add_filter( 'upload_mimes', array( 'BC_Setup', 'mime_types' ) );
add_action( 'media_buttons', array( 'BC_Setup', 'add_brightcove_media_button' ) );
add_action( 'admin_footer', array( 'BC_Setup', 'add_brightcove_media_modal_container' ) );
add_filter( 'http_request_args', array( 'BC_Setup', 'maybe_add_brightcove_version_to_user_agent' ) );

// Show admin notice only if there are not sources.
add_action( 'admin_notices', array( 'BC_Setup', 'bc_admin_notices' ) );
Expand Down Expand Up @@ -568,4 +569,26 @@ public static function redirect( $query ) {
// Kill the response immediately
die;
}

/**
* Conditionally add the Brightcove Video Connect version to the User Agent string.
*
* @since 2.8.4
* @param string $args Original request arguments.
* @return string
*/
public static function maybe_add_brightcove_version_to_user_agent( $args ) {
if ( empty( $args['is_brightcove_request'] ) || empty( $args['user-agent'] ) ) {
return $args;
}

$end_part = '; ' . get_bloginfo( 'url' );
$args['user-agent'] = str_replace(
$end_part,
' (BrightcoveVideoConnect/' . BRIGHTCOVE_VERSION . ')' . $end_part,
$args['user-agent']
);

return $args;
}
}
Loading

0 comments on commit 3806fa2

Please sign in to comment.