From a4d34f1c3fd221215438bfafee9980090be34b9b Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 21 Jun 2022 17:54:16 -0400 Subject: [PATCH 1/6] :bug: fixes #126 by changing the native label to the message that we want displayed on the block editor. The block editor is hard to customize at the moment, and it is easier to change the label in the taxonomy editor page. --- src/customize_tax_label.js | 20 ++++++++++++++++++++ src/customize_tax_panel.js | 29 ----------------------------- src/learning-module-cpt.php | 26 +++++++++++++++++++------- 3 files changed, 39 insertions(+), 36 deletions(-) create mode 100644 src/customize_tax_label.js delete mode 100644 src/customize_tax_panel.js diff --git a/src/customize_tax_label.js b/src/customize_tax_label.js new file mode 100644 index 0000000..5090be5 --- /dev/null +++ b/src/customize_tax_label.js @@ -0,0 +1,20 @@ +/** + * Customizes the taxonomy editor, to set the new Lesson label. + * + * This used to be customized in the block editor, but that became unstable. It is easier to + * set the default label to what we want in the block editor, then customize the taxonomy admin page. + * Relies on the markup of the taxonomy editor page. + */ +document.addEventListener('DOMContentLoaded', function () { + // The block editor uses the native "new tag" label, so we reset it here to a more general meaning. + var labelText = 'Create Lesson'; + + // Rename the form label. + var taxForm = document.querySelector("#addtag"); + var labelElement = taxForm.parentElement.getElementsByTagName('h2')[0]; + labelElement.innerHTML = labelText; + + // Rename the submit button. + document.querySelector("#addtag #submit").value = labelText; + +}, false); diff --git a/src/customize_tax_panel.js b/src/customize_tax_panel.js deleted file mode 100644 index af384fa..0000000 --- a/src/customize_tax_panel.js +++ /dev/null @@ -1,29 +0,0 @@ -var el = wp.element.createElement; - -/** - * Customizes the label within the taxonomy editor component. - * - * @since 0.0.7 - * - * @param {Component} OriginalComponent Post taxonomy editor component. - * - * @returns {Component} The customized editor component. - */ -function customizeLessonSelector( OriginalComponent ) { - return function( props ) { - if ( props.slug === 'bulb-courses' ) { - // Customize the label for the custom taxonomy. - props.taxonomy.labels.add_new_item = 'Include in Lesson (start typing name of Lesson)'; - } - return el( - OriginalComponent, - props - ); - }; -} - -wp.hooks.addFilter( - 'editor.PostTaxonomyType', - 'bu-learning-blocks', - customizeLessonSelector -); diff --git a/src/learning-module-cpt.php b/src/learning-module-cpt.php index c3afa2b..0239300 100644 --- a/src/learning-module-cpt.php +++ b/src/learning-module-cpt.php @@ -24,7 +24,7 @@ function register_course_tax() { 'parent_item' => __( 'Parent Lesson', 'bu-learning-blocks' ), 'parent_item_colon' => __( 'Parent Lesson:', 'bu-learning-blocks' ), 'new_item_name' => __( 'New Lesson Name', 'bu-learning-blocks' ), - 'add_new_item' => __( 'Create Lesson', 'bu-learning-blocks' ), + 'add_new_item' => __( 'Include in Lesson (start typing name of Lesson)', 'bu-learning-blocks' ), 'edit_item' => __( 'Edit Lesson', 'bu-learning-blocks' ), 'update_item' => __( 'Update Lesson', 'bu-learning-blocks' ), 'separate_items_with_commas' => __( 'Separate lessons with commas', 'bu-learning-blocks' ), @@ -228,17 +228,29 @@ function remove_bulb_attributes_panel() { } /** - * Load script to customize the taxonomy menu in the lesson page editor. + * Loads a script to customize the bu-courses taxonomy label. + * + * This used to modify the label of the taxonomy panel in the block editor. Changes in the block editor made this + * much more difficult, so now the default label is the string that is used in the block editor. This script + * customizes the taxonomy page instead, to what the default label used to be. + * + * Activated by the 'bulb-courses_add_form_fields' action, which is fired when the bu-courses taxonomy form is loaded. * * @since 0.0.7 */ -function bulb_add_admin_scripts() { +function bulb_add_admin_scripts( $hook_suffix ) { + // Double check that we're on the bulb taxonomy page, and bail if not. + if ( 'bulb-courses' !== $hook_suffix ) { + return; + } + + // If we are on the bulb taxonomy page, enqueue the script to customize the label. wp_enqueue_script( - 'customize_tax_panel', - BULB_PLUGIN_URL . 'src/customize_tax_panel.js', + 'customize_tax_label', + BULB_PLUGIN_URL . 'src/customize_tax_label.js', array(), - filemtime( plugin_dir_path( __DIR__ ) . 'src/customize_tax_panel.js' ), // Gets file modification time for cache busting. + filemtime( plugin_dir_path( __DIR__ ) . 'src/customize_tax_label.js' ), // Gets file modification time for cache busting. true // Enqueue the script in the footer. ); } -add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\bulb_add_admin_scripts' ); +add_action( 'bulb-courses_add_form_fields', __NAMESPACE__ . '\bulb_add_admin_scripts' ); From 4141f9fe2ce4f427e25af596b2b8bc07842bbc2f Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 5 Jul 2022 14:54:49 -0400 Subject: [PATCH 2/6] address deprecated filter name Adds a WP version check, to adjust the block category filter name to work on either side of the 5.8 name change. Addresses #128 --- src/init.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/init.php b/src/init.php index f51965f..03e8423 100644 --- a/src/init.php +++ b/src/init.php @@ -26,11 +26,12 @@ require_once BULB_PLUGIN_DIR_PATH . 'src/blocks/bulb-fitb/index.php'; require_once BULB_PLUGIN_DIR_PATH . 'src/blocks/bulb-mat/index.php'; - +// To support versions before and after 5.8, check the WordPress version and use the newer 'block_categories_all' tag if it's 5.8 or newer. +$block_category_filter = ( version_compare( get_bloginfo( 'version' ), '5.8', '>=' ) ) ? 'block_categories_all' : 'block_categories'; // Add BULB custom block category. add_filter( - 'block_categories', + $block_category_filter, function( $categories, $post ) { return array_merge( $categories, From dd961cd98f0d7eec95585df5fa45992f7ddf35a5 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Tue, 5 Jul 2022 15:57:09 -0400 Subject: [PATCH 3/6] :pencil: adjust doc block --- src/learning-module-cpt.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/learning-module-cpt.php b/src/learning-module-cpt.php index 0239300..32c358d 100644 --- a/src/learning-module-cpt.php +++ b/src/learning-module-cpt.php @@ -237,6 +237,8 @@ function remove_bulb_attributes_panel() { * Activated by the 'bulb-courses_add_form_fields' action, which is fired when the bu-courses taxonomy form is loaded. * * @since 0.0.7 + * + * @param string $hook_suffix The name of the hook that was activated. */ function bulb_add_admin_scripts( $hook_suffix ) { // Double check that we're on the bulb taxonomy page, and bail if not. From 958a2a1317ce631a3d170af8cf9c492c966e276e Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Mon, 18 Jul 2022 17:19:49 -0400 Subject: [PATCH 4/6] :bookmark: version bump --- bu-learning-blocks.php | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bu-learning-blocks.php b/bu-learning-blocks.php index 33ae199..36040d3 100644 --- a/bu-learning-blocks.php +++ b/bu-learning-blocks.php @@ -9,7 +9,7 @@ * Author URI: http://www.bu.edu/ * Text Domain: bu-learning-blocks * Domain Path: /languages - * Version: 1.1.3 + * Version: 1.1.4 * License: GPL2+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * diff --git a/package.json b/package.json index eef0b9e..a3206b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bu-learning-blocks", - "version": "1.1.3", + "version": "1.1.4", "private": true, "scripts": { "start": "wp-scripts start", From 939dc18ab02151f3ca62dca33dcd7b77087254bd Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Mon, 18 Jul 2022 17:21:37 -0400 Subject: [PATCH 5/6] :globe_with_meridians: update pot file --- languages/bu-learning-blocks.pot | 121 +++++++++++++++---------------- 1 file changed, 59 insertions(+), 62 deletions(-) diff --git a/languages/bu-learning-blocks.pot b/languages/bu-learning-blocks.pot index 1d3b169..fe4cb7a 100644 --- a/languages/bu-learning-blocks.pot +++ b/languages/bu-learning-blocks.pot @@ -1,17 +1,17 @@ -# Copyright (C) 2021 Boston University: Web Applications -# This file is distributed under the same license as the BU Learning Blocks plugin. +# Copyright (C) 2022 Boston University: Web Applications +# This file is distributed under the GPL2+. msgid "" msgstr "" -"Project-Id-Version: BU Learning Blocks v1.1.3\n" +"Project-Id-Version: BU Learning Blocks 1.1.4\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/bu-learning-blocks\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2021-03-09T22:14:20+00:00\n" +"POT-Creation-Date: 2022-07-18T17:16:56-04:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.4.0\n" +"X-Generator: WP-CLI 2.6.0\n" "X-Domain: bu-learning-blocks\n" #. Plugin Name of the plugin @@ -34,15 +34,15 @@ msgstr "" msgid "http://www.bu.edu/" msgstr "" -#: bu-learning-blocks.php:39 +#: bu-learning-blocks.php:41 msgid "BULB Error: BU Learning Blocks requires either WordPress 5.0.0, or the Gutenberg plugin to be installed and activated on any version previous to 5.0.0." msgstr "" -#: bu-learning-blocks.php:42 +#: bu-learning-blocks.php:44 msgid "Please install and activate the Gutenberg plugin to use BU Learning Blocks." msgstr "" -#: src/init.php:38 +#: src/init.php:41 #: src/blocks/bulb-cn/index.js:22 #: src/blocks/bulb-fitb/index.js:22 #: src/blocks/bulb-ma/index.js:20 @@ -52,169 +52,154 @@ msgstr "" msgid "BULB" msgstr "" -#: src/init.php:101 +#: src/init.php:104 msgid "Welcome to BU Learning Blocks" msgstr "" -#: src/init.php:109 +#: src/init.php:112 msgid "Install Blocks and Pages" msgstr "" -#: src/init.php:115 +#: src/init.php:118 msgid "Install Blocks Only" msgstr "" -#: src/learning-module-cpt.php:17 +#: src/learning-module-cpt.php:19 msgctxt "Taxonomy General Name" msgid "Lessons" msgstr "" -#: src/learning-module-cpt.php:18 +#: src/learning-module-cpt.php:20 msgctxt "Taxonomy Singular Name" msgid "Lesson" msgstr "" -#: src/learning-module-cpt.php:19 +#: src/learning-module-cpt.php:21 msgid "Lessons" msgstr "" -#: src/learning-module-cpt.php:20 +#: src/learning-module-cpt.php:22 msgid "All Lessons" msgstr "" -#: src/learning-module-cpt.php:21 +#: src/learning-module-cpt.php:23 msgid "View Lesson" msgstr "" -#: src/learning-module-cpt.php:22 +#: src/learning-module-cpt.php:24 msgid "Parent Lesson" msgstr "" -#: src/learning-module-cpt.php:23 +#: src/learning-module-cpt.php:25 msgid "Parent Lesson:" msgstr "" -#: src/learning-module-cpt.php:24 +#: src/learning-module-cpt.php:26 msgid "New Lesson Name" msgstr "" -#: src/learning-module-cpt.php:25 -msgid "Create Lesson" +#: src/learning-module-cpt.php:27 +msgid "Include in Lesson (start typing name of Lesson)" msgstr "" -#: src/learning-module-cpt.php:26 +#: src/learning-module-cpt.php:28 msgid "Edit Lesson" msgstr "" -#: src/learning-module-cpt.php:27 +#: src/learning-module-cpt.php:29 msgid "Update Lesson" msgstr "" -#: src/learning-module-cpt.php:28 +#: src/learning-module-cpt.php:30 msgid "Separate lessons with commas" msgstr "" -#: src/learning-module-cpt.php:29 +#: src/learning-module-cpt.php:31 msgid "Search Lessons" msgstr "" -#: src/learning-module-cpt.php:30 +#: src/learning-module-cpt.php:32 msgid "Add or remove lessons" msgstr "" -#: src/learning-module-cpt.php:31 +#: src/learning-module-cpt.php:33 msgid "Choose from the most used lessons" msgstr "" -#: src/learning-module-cpt.php:32 +#: src/learning-module-cpt.php:34 msgid "Not Found" msgstr "" -#: src/learning-module-cpt.php:62 +#: src/learning-module-cpt.php:64 msgid "Lesson Pages" msgstr "" -#: src/learning-module-cpt.php:63 +#: src/learning-module-cpt.php:65 msgid "Lesson Page" msgstr "" -#: src/learning-module-cpt.php:64 +#: src/learning-module-cpt.php:66 msgid "BULB Lessons" msgstr "" -#: src/learning-module-cpt.php:65 -#: src/learning-module-cpt.php:66 -#: src/learning-module-cpt.php:69 +#: src/learning-module-cpt.php:67 +#: src/learning-module-cpt.php:68 +#: src/learning-module-cpt.php:71 msgid "New Lesson Page" msgstr "" -#: src/learning-module-cpt.php:67 +#: src/learning-module-cpt.php:69 msgid "Edit Lesson Page" msgstr "" -#: src/learning-module-cpt.php:68 +#: src/learning-module-cpt.php:70 msgid "Update Lesson Page" msgstr "" -#: src/learning-module-cpt.php:70 +#: src/learning-module-cpt.php:72 msgid "All Lesson Pages" msgstr "" -#: src/learning-module-cpt.php:71 +#: src/learning-module-cpt.php:73 msgid "View Lesson Page" msgstr "" -#: src/learning-module-cpt.php:72 +#: src/learning-module-cpt.php:74 msgid "View Lesson Pages" msgstr "" -#: src/learning-module-cpt.php:73 +#: src/learning-module-cpt.php:75 msgid "Lesson Page Attributes" msgstr "" -#: src/learning-module-cpt.php:74 +#: src/learning-module-cpt.php:76 msgid "Search Lesson Pages" msgstr "" -#: src/learning-module-cpt.php:75 +#: src/learning-module-cpt.php:77 msgid "No Lesson Pages found" msgstr "" -#: src/learning-module-cpt.php:76 +#: src/learning-module-cpt.php:78 msgid "No Lessons Pages found in Trash" msgstr "" -#: src/learning-module-cpt.php:77 +#: src/learning-module-cpt.php:79 msgid "Lesson Page Archives" msgstr "" -#: src/learning-module-cpt.php:78 +#: src/learning-module-cpt.php:80 msgid "Parent Lesson Page:" msgstr "" -#: src/learning-module-cpt.php:87 +#: src/learning-module-cpt.php:89 msgid "lesson" msgstr "" -#: src/learning-module-cpt.php:89 +#: src/learning-module-cpt.php:91 msgid "Holds our Lessons" msgstr "" -#: build/blocks/blocks.build.js:1 -#: src/components/QuestionHeader.js:7 -msgid "Question" -msgstr "" - -#: build/blocks/blocks.build.js:1 -#: src/components/QuestionHeader.js:8 -msgid "Question Header" -msgstr "" - -#: build/blocks/blocks.build.js:1 -#: src/components/QuestionHeader.js:11 -msgid "Enter Question Header" -msgstr "" - #: src/blocks/bulb-cn/index.js:16 msgid "BULB - Calculated Numeric" msgstr "" @@ -330,3 +315,15 @@ msgstr "" #: src/components/QuestionFeedback.js:44 msgid "Enter Incorrect Feedback" msgstr "" + +#: src/components/QuestionHeader.js:7 +msgid "Question" +msgstr "" + +#: src/components/QuestionHeader.js:8 +msgid "Question Header" +msgstr "" + +#: src/components/QuestionHeader.js:11 +msgid "Enter Question Header" +msgstr "" From 87f43b34a3164962507b78e67b377d1189e509bd Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Mon, 18 Jul 2022 17:30:16 -0400 Subject: [PATCH 6/6] :bookmark: update changelog --- readme.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index e23ad1d..9db4a50 100644 --- a/readme.txt +++ b/readme.txt @@ -2,8 +2,8 @@ Contributors: carlosesilva, dannycrews, jdub233 Tags: learning, teaching, education, online courses, boston university, bu Requires at least: 5.3.2 -Tested up to: 5.7 -Stable tag: 1.1.3 +Tested up to: 6.0 +Stable tag: 1.1.4 Requires PHP: 7.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -39,6 +39,9 @@ Development takes place at https://github.com/bu-ist/bu-learning-blocks/ == Changelog == += 1.1.4 = +* Patch issues with 5.8 and 5.9 compatibility + = 1.1.3 = * Add Github publish action