From e817be4c50b1b84face22b6d13abe7fb60fb6647 Mon Sep 17 00:00:00 2001 From: Brian Hogg Date: Thu, 12 Dec 2024 09:36:52 -0500 Subject: [PATCH] Moving setting of titles and descriptions to init (#59) * Avoids translation warning/error --- .changelogs/fix_translation-error.yml | 5 ++ .github/workflows/coding-standards.yml | 60 --------------------- inc/labs/class.llms.lab.action.manager.php | 23 ++++---- inc/labs/class.llms.lab.beaver.builder.php | 31 ++++------- inc/labs/class.llms.lab.lifti.php | 29 ++++------ inc/labs/class.llms.lab.simple.branding.php | 25 ++++----- inc/labs/class.llms.lab.super.sidebars.php | 21 ++++---- 7 files changed, 62 insertions(+), 132 deletions(-) create mode 100644 .changelogs/fix_translation-error.yml delete mode 100644 .github/workflows/coding-standards.yml diff --git a/.changelogs/fix_translation-error.yml b/.changelogs/fix_translation-error.yml new file mode 100644 index 0000000..c8c2fe4 --- /dev/null +++ b/.changelogs/fix_translation-error.yml @@ -0,0 +1,5 @@ +significance: patch +type: fixed +links: + - "#58" +entry: Fixing translation warnings, which break translations. diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml deleted file mode 100644 index de324ad..0000000 --- a/.github/workflows/coding-standards.yml +++ /dev/null @@ -1,60 +0,0 @@ -### -# -# This workflow file is deployed into this repository via the "Sync Organization Files" workflow -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/coding-standards.yml} -# -### -name: Coding Standards - -on: - workflow_dispatch: - pull_request: - # Once daily at 00:00 UTC. - # schedule: - # - cron: '0 0 * * *' - -concurrency: - group: ${{ github.workflow }}-${{ 'pull_request' == github.event_name && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - phpcs: - name: Check Coding Standards - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - coverage: none - tools: composer, cs2pr - - # Composer Install. - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - name: Install Composer dependencies - run: composer update - - # Check Coding Standards. - - name: Run PHPCS - run: composer run check-cs-errors -- --report-full --report-checkstyle=./phpcs-report.xml - - - name: Show PHPCS results in PR - run: cs2pr ./phpcs-report.xml diff --git a/inc/labs/class.llms.lab.action.manager.php b/inc/labs/class.llms.lab.action.manager.php index 23a3db4..7bfd39d 100644 --- a/inc/labs/class.llms.lab.action.manager.php +++ b/inc/labs/class.llms.lab.action.manager.php @@ -37,15 +37,7 @@ class LLMS_Lab_Action_Manager extends LLMS_Lab { */ protected function configure() { - $this->id = 'action-manager'; // Leave this so we don't have to rewrite db options. - $this->title = esc_html__( 'Action Manager', 'lifterlms-labs' ); - $this->description = sprintf( - // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. - esc_html__( 'Quickly remove specific elements like course author, syllabus, and more without having to write any code. Click %1$shere%2$s for more information.', 'lifterlms-labs' ), - '', - '' - ); - + $this->id = 'action-manager'; // Leave this so we don't have to rewrite db options. } /** @@ -60,7 +52,17 @@ protected function init() { add_action( 'init', array( $this, 'setup_hooks' ), 11 ); add_action( 'init', array( $this, 'remove_actions' ), 11 ); + add_action( 'init', array( $this, 'set_title_and_description' ) ); + } + public function set_title_and_description() { + $this->title = esc_html__( 'Action Manager', 'lifterlms-labs' ); + $this->description = sprintf( + // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. + esc_html__( 'Quickly remove specific elements like course author, syllabus, and more without having to write any code. Click %1$shere%2$s for more information.', 'lifterlms-labs' ), + '', + '' + ); } /** @@ -86,7 +88,6 @@ public function remove_actions() { } } } - } /** @@ -249,7 +250,7 @@ public function setup_hooks() { 'priority' => 10, 'title' => esc_html__( 'Back to Course Link', 'lifterlms-labs' ), ), - 'llms_template_favorite' => array( + 'llms_template_favorite' => array( 'action' => 'lifterlms_single_lesson_before_summary', 'priority' => 10, 'title' => esc_html__( 'Mark Favorite / Unfavorite Lesson button', 'lifterlms-labs' ), diff --git a/inc/labs/class.llms.lab.beaver.builder.php b/inc/labs/class.llms.lab.beaver.builder.php index f585a64..89381d4 100644 --- a/inc/labs/class.llms.lab.beaver.builder.php +++ b/inc/labs/class.llms.lab.beaver.builder.php @@ -36,15 +36,7 @@ protected function configure() { define( 'LLMS_LABS_BB_MODULES_DIR', plugin_dir_path( __FILE__ ) . 'inc/beaver-builder/modules/' ); define( 'LLMS_LABS_BB_MODULES_URL', plugins_url( '/', __FILE__ ) . 'inc/beaver-builder/modules/' ); - $this->id = 'beaver-builder'; - $this->title = esc_html__( 'Beaver Builder', 'lifterlms-labs' ); - $this->description = sprintf( - // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. - esc_html__( 'Adds LifterLMS elements as pagebuilder modules and enables row and module visibility settings based on student enrollment in courses and memberships. For help and more information click %1$shere%2$s.', 'lifterlms-labs' ), - '', - '' - ); - + $this->id = 'beaver-builder'; } /** @@ -73,6 +65,7 @@ protected function init() { add_action( 'init', array( $this, 'load_modules' ) ); add_action( 'init', array( $this, 'load_templates' ) ); + add_action( 'init', array( $this, 'set_title_and_description' ) ); add_filter( 'llms_page_restricted', array( $this, 'mod_page_restrictions' ), 999, 2 ); @@ -89,7 +82,16 @@ protected function init() { // LifterLMS Private Areas. add_action( 'llms_pa_before_do_area_content', array( $this, 'llms_pa_before_content' ) ); add_action( 'llms_pa_after_do_area_content', array( $this, 'llms_pa_after_content' ) ); + } + public function set_title_and_description() { + $this->title = esc_html__( 'Beaver Builder', 'lifterlms-labs' ); + $this->description = sprintf( + // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. + esc_html__( 'Adds LifterLMS elements as pagebuilder modules and enables row and module visibility settings based on student enrollment in courses and memberships. For help and more information click %1$shere%2$s.', 'lifterlms-labs' ), + '', + '' + ); } /** @@ -107,7 +109,6 @@ public function on_enable() { $existing = get_option( '_fl_builder_post_types', array( 'page' ) ); $types = array_unique( array_merge( $existing, array( 'course', 'lesson', 'llms_membership' ) ) ); update_option( '_fl_builder_post_types', $types ); - } /** @@ -226,7 +227,6 @@ public function add_visibility_settings( $form, $id ) { } return $form; - } /** @@ -252,7 +252,6 @@ private function get_related_posts_from_settings( $settings ) { } return $post_ids; - } /** @@ -374,7 +373,6 @@ private function is_student_enrolled_in_one_thing( $uid ) { } return false; - } /** @@ -414,7 +412,6 @@ public function load_modules() { require_once $file; } } - } /** @@ -427,7 +424,6 @@ public function load_modules() { public function load_templates() { FLBuilderModel::register_templates( LLMS_LABS_PLUGIN_DIR . 'inc/labs/inc/' . $this->get_id() . '/templates/course-template.dat' ); - } /** @@ -453,7 +449,6 @@ public function mod_metabox_fields( $fields ) { } return $fields; - } /** @@ -480,7 +475,6 @@ public function mod_page_restrictions( $results, $post_id ) { } return $results; - } /** @@ -498,7 +492,6 @@ public function remove_uneditable_post_types( $post_types ) { unset( $post_types['llms_question'] ); return $post_types; - } /** @@ -512,8 +505,6 @@ public function remove_uneditable_post_types( $post_types ) { public function upgrade_url( $url ) { return 'https://www.wpbeaverbuilder.com/?fla=968'; } - - } return new LLMS_Lab_Beaver_Builder(); diff --git a/inc/labs/class.llms.lab.lifti.php b/inc/labs/class.llms.lab.lifti.php index 7d12cf8..fe56097 100644 --- a/inc/labs/class.llms.lab.lifti.php +++ b/inc/labs/class.llms.lab.lifti.php @@ -44,15 +44,7 @@ class LLMS_Lab_Lifti extends LLMS_Lab { */ protected function configure() { - $this->id = 'divi-friends'; // Leave this so we don't have to rewrite db options. - $this->title = esc_html__( 'Lifti: Divi Theme Compatibility', 'lifterlms-labs' ); - $this->description = sprintf( - // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. - esc_html__( 'Enable LifterLMS compatibility with the Divi Theme and Page Builder. For more information click %1$shere%2$s.', 'lifterlms-labs' ), - '', - '' - ); - + $this->id = 'divi-friends'; // Leave this so we don't have to rewrite db options. } /** @@ -80,6 +72,7 @@ protected function init() { add_action( 'lifterlms_after_main_content', array( $this, 'output_content_wrapper_end' ), 10 ); add_action( 'init', array( $this, 'remove_llms_sidebars' ), 15 ); + add_action( 'init', array( $this, 'set_title_and_description' ) ); add_action( 'admin_init', array( $this, 'include_template_functions' ) ); add_filter( 'body_class', array( $this, 'body_class' ), 777 ); @@ -96,7 +89,16 @@ protected function init() { add_action( 'add_meta_boxes', array( $this, 'add_page_settings' ) ); add_filter( 'llms_builder_register_custom_fields', array( $this, 'add_builder_quiz_settings' ) ); + } + public function set_title_and_description() { + $this->title = esc_html__( 'Lifti: Divi Theme Compatibility', 'lifterlms-labs' ); + $this->description = sprintf( + // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. + esc_html__( 'Enable LifterLMS compatibility with the Divi Theme and Page Builder. For more information click %1$shere%2$s.', 'lifterlms-labs' ), + '', + '' + ); } /** @@ -130,7 +132,6 @@ public function add_page_settings() { ); } - } /** @@ -152,7 +153,6 @@ public function admin_enqueue() { wp_enqueue_style( 'editor-buttons' ); } - } /** @@ -257,7 +257,6 @@ public function body_class( $classes ) { } return $classes; - } /** @@ -317,7 +316,6 @@ public function handle_content( $content ) { } return wpautop( $content ); - } /** @@ -338,7 +336,6 @@ public function handle_excerpt( $excerpt ) { } return $this->handle_content( $post->post_content ); - } /** @@ -360,7 +357,6 @@ private function get_builder_sections( $content ) { } return false; - } /** @@ -398,7 +394,6 @@ public function is_builder_enabled( $post_or_post_type ) { $enabled = in_array( $post_type, $this->builder_cpts_enabled, true ); return ( $enabled && $meta ); - } /** @@ -413,7 +408,6 @@ private function is_divi_enabled() { $theme = wp_get_theme(); return ( 'divi' === strtolower( $theme->get_template() ) ); - } /** @@ -560,7 +554,6 @@ public function settings() { return $settings; } - } return new LLMS_Lab_Lifti(); diff --git a/inc/labs/class.llms.lab.simple.branding.php b/inc/labs/class.llms.lab.simple.branding.php index d2dc5a9..f2a6efe 100644 --- a/inc/labs/class.llms.lab.simple.branding.php +++ b/inc/labs/class.llms.lab.simple.branding.php @@ -29,14 +29,7 @@ class LLMS_Lab_Simple_Branding extends LLMS_Lab { * @return void */ protected function configure() { - $this->id = 'simple-branding'; - $this->title = esc_html__( 'Simple Branding', 'lifterlms-labs' ); - $this->description = sprintf( - // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. - esc_html__( 'Customize the default colors of various LifterLMS elements. For help and more information click %1$shere%2$s.', 'lifterlms-labs' ), - '', - '' - ); + $this->id = 'simple-branding'; } /** @@ -54,7 +47,17 @@ protected function init() { add_action( 'wp_head', array( $this, 'output_css' ), 777 ); add_action( 'llms_lab_' . $this->id . '_settings_saved', array( $this, 'generate_css' ) ); add_filter( 'llms_email_css', array( $this, 'email_css' ), 777, 1 ); + add_action( 'init', array( $this, 'set_title_and_description' ) ); + } + public function set_title_and_description() { + $this->title = esc_html__( 'Simple Branding', 'lifterlms-labs' ); + $this->description = sprintf( + // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. + esc_html__( 'Customize the default colors of various LifterLMS elements. For help and more information click %1$shere%2$s.', 'lifterlms-labs' ), + '', + '' + ); } /** @@ -150,7 +153,6 @@ private function adjust_hex( $hex, $percent ) { } return $new_hex; - } /** @@ -177,7 +179,6 @@ public function email_css( $css ) { $css['main-color'] = $primary; return $css; - } /** @@ -382,7 +383,6 @@ private function get_luminance( $hex ) { } return ( 0.2126 * $rgb[0] ) + ( 0.7152 * $rgb[1] ) + ( 0.0722 * $rgb[2] ); - } /** @@ -422,7 +422,6 @@ private function hex_to_rgb_array( $hex ) { ); return $rgb; - } /** @@ -449,7 +448,6 @@ public function on_enable() { } $this->generate_css(); - } /** @@ -521,7 +519,6 @@ protected function settings() { ), ); } - } return new LLMS_Lab_Simple_Branding(); diff --git a/inc/labs/class.llms.lab.super.sidebars.php b/inc/labs/class.llms.lab.super.sidebars.php index e58838b..9d94c13 100644 --- a/inc/labs/class.llms.lab.super.sidebars.php +++ b/inc/labs/class.llms.lab.super.sidebars.php @@ -28,14 +28,7 @@ class LLMS_Lab_Super_Sidebars extends LLMS_Lab { * @return void */ protected function configure() { - $this->id = 'super-sidebars'; - $this->title = esc_html__( 'Super Sidebars', 'lifterlms-labs' ); - $this->description = sprintf( - // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. - esc_html__( 'Very quickly configure LifterLMS sidebars to work with your theme. For help and more information click %1$shere%2$s.', 'lifterlms-labs' ), - '', - '' - ); + $this->id = 'super-sidebars'; } /** @@ -48,6 +41,17 @@ protected function configure() { protected function init() { // Replace the default sidebar with user selected sidebar. add_filter( 'llms_get_theme_default_sidebar', array( $this, 'replace_sidebar' ) ); + add_action( 'init', array( $this, 'set_title_and_description' ) ); + } + + public function set_title_and_description() { + $this->title = esc_html__( 'Super Sidebars', 'lifterlms-labs' ); + $this->description = sprintf( + // Translators: %1$s = Opening anchor tag; %2$s = Closing anchor tag. + esc_html__( 'Very quickly configure LifterLMS sidebars to work with your theme. For help and more information click %1$shere%2$s.', 'lifterlms-labs' ), + '', + '' + ); } /** @@ -100,7 +104,6 @@ protected function settings() { ), ); } - } return new LLMS_Lab_Super_Sidebars();