Skip to content

Commit

Permalink
Merge pull request #268 from 10up/develop
Browse files Browse the repository at this point in the history
Release 2.6.0
  • Loading branch information
oscarssanchez authored Apr 19, 2022
2 parents cf06bc3 + a4bf628 commit 438274b
Show file tree
Hide file tree
Showing 19 changed files with 566 additions and 412 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PHP Compatibility

env:
COMPOSER_VERSION: "1"
COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache"

on:
push:
branches:
- develop
- master
pull_request:
branches:
- develop

jobs:
php_compatibility:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set standard 10up cache directories
run: |
composer config -g cache-dir "${{ env.COMPOSER_CACHE }}"
- name: Prepare composer cache
uses: actions/cache@v2
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: prestissimo, composer:v1

- name: Install dependencies
run: composer install

- name: Check PHP Compatibility
run: ./vendor/bin/phpcs -p brightcove-video-connect.php includes --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion ${{ matrix.php }}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file, per [the Ke

## [Unreleased] - TBD

## [2.6.0] - 2022-04-19

### Added
- Support custom fields with multilingual metadata. Props [@oscarssanchez](https://github.com/oscarssanchez), and [@felipeelia](https://github.com/felipeelia), via [#266](https://github.com/10up/brightcove-video-connect/pull/266).

## [2.5.2] - 2022-03-17

### Added
Expand Down Expand Up @@ -362,6 +367,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.6.0]: https://github.com/10up/brightcove-video-connect/compare/2.5.2...2.6.0
[2.5.2]: https://github.com/10up/brightcove-video-connect/compare/2.5.1...2.5.2
[2.5.1]: https://github.com/10up/brightcove-video-connect/compare/2.5.0...2.5.1
[2.5.0]: https://github.com/10up/brightcove-video-connect/compare/2.4.0...2.5.0
Expand Down
66 changes: 46 additions & 20 deletions assets/js/brightcove-admin.js

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

2 changes: 1 addition & 1 deletion assets/js/brightcove-admin.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/brightcove-admin.min.js

Large diffs are not rendered by default.

66 changes: 46 additions & 20 deletions assets/js/src/views/video-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var VideoEditView = BrightcoveView.extend({
if (valueSelected === 'none') {
template = wp.template('brightcove-video-edit');
$('.brightcove-variant-details').replaceWith(template(options));
this.setCustomFields(options.custom_fields);
} else {
let variantIndex = options.variants
.map(function (variant) {
Expand All @@ -39,10 +40,12 @@ var VideoEditView = BrightcoveView.extend({
let variant = options.variants[variantIndex];
variant.variantList = options.variants;
variant.valueSelected = valueSelected;
template = wp.template('brightcove-variants');

template = wp.template('brightcove-variants');
this.setCustomFields(variant.custom_fields);
$('.brightcove-variant-details').replaceWith(template(variant));
}
this.renderCustomFields();
},

back: function (event) {
Expand Down Expand Up @@ -525,6 +528,47 @@ var VideoEditView = BrightcoveView.extend({
wpbc.broadcast.trigger('start:gridview');
},

/**
* Renders the "Custom fields" from a video/variant.
*/
renderCustomFields: function () {
var customContainer = this.$el.find('#brightcove-custom-fields'),
stringTmp = wp.template('brightcove-video-edit-custom-string'),
enumTmp = wp.template('brightcove-video-edit-custom-enum');
_.each(this.model.get('custom'), function (custom) {
if (custom.id === '_change_history') {
return;
}
switch (custom.type) {
case 'string':
customContainer.append(stringTmp(custom));
break;
case 'enum':
customContainer.append(enumTmp(custom));
break;
}
});
},

/**
* In order to switch models accordingly to render a video/variant, we update the current model custom fields.
* @param {array} custom_fields
*/
setCustomFields: function (custom_fields) {
let custom = this.model.get('custom');

custom.forEach((customField) => {
let CustomFieldsKeys = Object.keys(custom_fields);
CustomFieldsKeys.forEach((index) => {
if (customField.id === index) {
customField.value = custom_fields[index];
}
});
});

this.model.set('custom', custom);
},

/**
* Render the actual view for the Video Edit screen.
*
Expand All @@ -544,25 +588,7 @@ var VideoEditView = BrightcoveView.extend({

this.$('.brightcove-datetime').datepicker();

// Render custom fields into the template
var customContainer = this.$el.find('#brightcove-custom-fields'),
stringTmp = wp.template('brightcove-video-edit-custom-string'),
enumTmp = wp.template('brightcove-video-edit-custom-enum');

_.each(this.model.get('custom'), function (custom) {
if (custom.id === '_change_history') {
return;
}

switch (custom.type) {
case 'string':
customContainer.append(stringTmp(custom));
break;
case 'enum':
customContainer.append(enumTmp(custom));
break;
}
});
this.renderCustomFields();

// Render the change history
var history = this.model.get('history');
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.5.2
* Version: 2.6.0
* Author: 10up
* Author URI: http://10up.com
* License: GPLv2+
Expand All @@ -29,7 +29,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 021.0.2301 USA
*/

define( 'BRIGHTCOVE_VERSION', '2.5.2' );
define( 'BRIGHTCOVE_VERSION', '2.6.0' );
define( 'BRIGHTCOVE_URL', plugin_dir_url( __FILE__ ) );
define( 'BRIGHTCOVE_PATH', dirname( __FILE__ ) . '/' );
define( 'BRIGHTCOVE_BASENAME', plugin_basename( __FILE__ ) );
Expand Down
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@
"composer/installers": "~1.0"
},
"require-dev": {
"10up/phpcs-composer": "dev-master"
"10up/phpcs-composer": "dev-master",
"phpcompatibility/phpcompatibility-wp": "*"
},
"scripts": {
"lint": "phpcs .",
"lint-fix": "phpcbf ."
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"composer/installers": true
}
}
}
Loading

0 comments on commit 438274b

Please sign in to comment.