Skip to content

Commit

Permalink
Moving setting of titles and descriptions to init (#59)
Browse files Browse the repository at this point in the history
* Avoids translation warning/error
  • Loading branch information
brianhogg authored Dec 12, 2024
1 parent 666a15e commit e817be4
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 132 deletions.
5 changes: 5 additions & 0 deletions .changelogs/fix_translation-error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
significance: patch
type: fixed
links:
- "#58"
entry: Fixing translation warnings, which break translations.
60 changes: 0 additions & 60 deletions .github/workflows/coding-standards.yml

This file was deleted.

23 changes: 12 additions & 11 deletions inc/labs/class.llms.lab.action.manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
'<a href="https://lifterlms.com/docs/lab-action-manager/?utm_source=settings&utm_medium=product&utm_campaign=lifterlmslabsplugin&utm_content=actionmanager">',
'</a>'
);

$this->id = 'action-manager'; // Leave this so we don't have to rewrite db options.
}

/**
Expand All @@ -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' ),
'<a href="https://lifterlms.com/docs/lab-action-manager/?utm_source=settings&utm_medium=product&utm_campaign=lifterlmslabsplugin&utm_content=actionmanager">',
'</a>'
);
}

/**
Expand All @@ -86,7 +88,6 @@ public function remove_actions() {
}
}
}

}

/**
Expand Down Expand Up @@ -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' ),
Expand Down
31 changes: 11 additions & 20 deletions inc/labs/class.llms.lab.beaver.builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
'<a href="https://lifterlms.com/docs/lab-beaver-builder?utm_source=settings&utm_campaign=lifterlmslabsplugin&utm_medium=product&utm_content=beaverbuilder" target="blank">',
'</a>'
);

$this->id = 'beaver-builder';
}

/**
Expand Down Expand Up @@ -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 );

Expand All @@ -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' ),
'<a href="https://lifterlms.com/docs/lab-beaver-builder?utm_source=settings&utm_campaign=lifterlmslabsplugin&utm_medium=product&utm_content=beaverbuilder" target="blank">',
'</a>'
);
}

/**
Expand All @@ -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 );

}

/**
Expand Down Expand Up @@ -226,7 +227,6 @@ public function add_visibility_settings( $form, $id ) {
}

return $form;

}

/**
Expand All @@ -252,7 +252,6 @@ private function get_related_posts_from_settings( $settings ) {
}

return $post_ids;

}

/**
Expand Down Expand Up @@ -374,7 +373,6 @@ private function is_student_enrolled_in_one_thing( $uid ) {
}

return false;

}

/**
Expand Down Expand Up @@ -414,7 +412,6 @@ public function load_modules() {
require_once $file;
}
}

}

/**
Expand All @@ -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' );

}

/**
Expand All @@ -453,7 +449,6 @@ public function mod_metabox_fields( $fields ) {
}

return $fields;

}

/**
Expand All @@ -480,7 +475,6 @@ public function mod_page_restrictions( $results, $post_id ) {
}

return $results;

}

/**
Expand All @@ -498,7 +492,6 @@ public function remove_uneditable_post_types( $post_types ) {
unset( $post_types['llms_question'] );

return $post_types;

}

/**
Expand All @@ -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();
29 changes: 11 additions & 18 deletions inc/labs/class.llms.lab.lifti.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
'<a href="https://lifterlms.com/docs/lab-lifti/?utm_source=settings&utm_medium=product&utm_campaign=lifterlmslabsplugin&utm_content=lifti">',
'</a>'
);

$this->id = 'divi-friends'; // Leave this so we don't have to rewrite db options.
}

/**
Expand Down Expand Up @@ -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 );
Expand All @@ -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' ),
'<a href="https://lifterlms.com/docs/lab-lifti/?utm_source=settings&utm_medium=product&utm_campaign=lifterlmslabsplugin&utm_content=lifti">',
'</a>'
);
}

/**
Expand Down Expand Up @@ -130,7 +132,6 @@ public function add_page_settings() {
);

}

}

/**
Expand All @@ -152,7 +153,6 @@ public function admin_enqueue() {
wp_enqueue_style( 'editor-buttons' );

}

}

/**
Expand Down Expand Up @@ -257,7 +257,6 @@ public function body_class( $classes ) {
}

return $classes;

}

/**
Expand Down Expand Up @@ -317,7 +316,6 @@ public function handle_content( $content ) {
}

return wpautop( $content );

}

/**
Expand All @@ -338,7 +336,6 @@ public function handle_excerpt( $excerpt ) {
}

return $this->handle_content( $post->post_content );

}

/**
Expand All @@ -360,7 +357,6 @@ private function get_builder_sections( $content ) {
}

return false;

}

/**
Expand Down Expand Up @@ -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 );

}

/**
Expand All @@ -413,7 +408,6 @@ private function is_divi_enabled() {

$theme = wp_get_theme();
return ( 'divi' === strtolower( $theme->get_template() ) );

}

/**
Expand Down Expand Up @@ -560,7 +554,6 @@ public function settings() {

return $settings;
}

}

return new LLMS_Lab_Lifti();
Loading

0 comments on commit e817be4

Please sign in to comment.