Skip to content

Commit

Permalink
Merge pull request #3487 from the-events-calendar/fix/resolving-trans…
Browse files Browse the repository at this point in the history
…lation-issues

[ET-2284] Fixing Translation Issues in ET: Part One
  • Loading branch information
codingmusician authored Jan 24, 2025
2 parents 79a9529 + ed905f7 commit 7e92a6b
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 13 deletions.
8 changes: 7 additions & 1 deletion src/Tickets/Commerce/Gateways/PayPal/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ public function register() {
*/
protected function register_assets() {
$assets = new Assets( $this->container );
$assets->register();

// Register assets only after `init` hook has fired.
if ( did_action( 'init' ) || doing_action( 'init' ) ) {
$assets->register();
} else {
add_action( 'init', [ $assets, 'register' ] );
}

$this->container->singleton( Assets::class, $assets );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ class Order_Modifier_Fee_Metabox extends Controller_Contract {
*/
protected Order_Modifier_Relationship $order_modifiers_relationship_repository;

/**
* The order modifiers controller.
*
* @since TBD
* @var Controller
*/
protected Controller $controller;

/**
* Constructor to initialize dependencies and set up the modifier strategy and manager.
*
Expand All @@ -98,11 +106,22 @@ public function __construct(
) {
parent::__construct( $container );
// Set up the modifier strategy and manager for handling fees.
$this->modifier_strategy = $controller->get_modifier( $this->modifier_type );
$this->controller = $controller;
$this->manager = $manager;

// Set up the order modifiers repository for accessing fee data.
$this->order_modifiers_relationship_repository = $order_modifier_relationship;

add_action( 'init', [ $this, 'set_modifier_strategy' ] );
}

/**
* Sets the modifier strategy for applying fees.
*
* @since TBD
*/
public function set_modifier_strategy() {
$this->modifier_strategy = $this->controller->get_modifier( $this->modifier_type );
}

/**
Expand Down
21 changes: 20 additions & 1 deletion src/Tickets/Commerce/Order_Modifiers/Checkout/Abstract_Fees.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ abstract class Abstract_Fees extends Controller_Contract {
*/
protected static bool $fees_appended = false;

/**
* The order modifiers controller.
*
* @since TBD
* @var Controller
*/
protected Controller $controller;

/**
* Constructor
*
Expand All @@ -124,10 +132,21 @@ public function __construct(
Modifier_Manager $manager
) {
parent::__construct( $container );
$this->modifier_strategy = $controller->get_modifier( $this->modifier_type );
$this->controller = $controller;
$this->manager = $manager;
$this->order_modifiers_repository = $fee_repository;
$this->order_modifiers_relationship_repository = $order_modifier_relationship;

add_action( 'init', [ $this, 'set_modifier_strategy' ] );
}

/**
* Sets the modifier strategy for applying fees.
*
* @since TBD
*/
public function set_modifier_strategy() {
$this->modifier_strategy = $this->controller->get_modifier( $this->modifier_type );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Tickets/Seating/Health.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class Health extends Controller_Contract {
*/
public function __construct( Container $container ) {
parent::__construct( $container );

$this->define_tests();
}

/**
Expand All @@ -68,7 +66,7 @@ public function __construct( Container $container ) {
*
* @return void
*/
protected function define_tests() {
public function define_tests() {
$set_license_url = tribe( Settings::class )->get_url( [ 'tab' => 'licenses' ] );

$this->tests = [
Expand Down Expand Up @@ -174,6 +172,7 @@ public function get_tests(): array {
* @return void
*/
public function unregister(): void {
remove_action( 'init', [ $this, 'define_tests' ] );
remove_filter( 'site_status_tests', [ $this, 'add_site_status_tests' ] );

foreach ( $this->get_tests() as $callback => $test ) {
Expand All @@ -189,6 +188,7 @@ public function unregister(): void {
* @return void
*/
protected function do_register(): void {
add_action( 'init', [ $this, 'define_tests' ] );
add_filter( 'site_status_tests', [ $this, 'add_site_status_tests' ] );

foreach ( $this->get_tests() as $callback => $test ) {
Expand Down
12 changes: 11 additions & 1 deletion src/Tickets/Seating/Uplink.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class Uplink extends Controller_Contract {
public function __construct( Container $container ) {
parent::__construct( $container );
$this->et_main = Main::instance();
$this->et_slr_plugin_name = _x( 'Seating', 'Header of the connection controls', 'event-tickets' );
}

/**
Expand All @@ -67,6 +66,7 @@ public function __construct( Container $container ) {
* @since 5.16.0
*/
public function do_register(): void {
add_action( 'init', [ $this, 'set_slr_plugin_name' ], 9 );
add_action( 'init', [ $this, 'register_plugin' ] );
add_filter(
'stellarwp/uplink/tec/tec-seating/view/authorize_button/link_text',
Expand All @@ -78,6 +78,15 @@ public function do_register(): void {
add_action( 'stellarwp/uplink/tec/tec-seating/connected', [ $this, 'reset_data_on_new_connection' ] );
}

/**
* Set the SLR plugin name.
*
* @since TBD
*/
public function set_slr_plugin_name(): void {
$this->et_slr_plugin_name = _x( 'Seating', 'Header of the connection controls', 'event-tickets' );
}

/**
* Unregister the controller.
*
Expand All @@ -86,6 +95,7 @@ public function do_register(): void {
* @return void
*/
public function unregister(): void {
remove_action( 'init', [ $this, 'set_slr_plugin_name' ], 9 );
remove_action( 'init', [ $this, 'register_plugin' ] );
remove_filter(
'stellarwp/uplink/tec/tec-seating/view/authorize_button/link_text',
Expand Down
6 changes: 5 additions & 1 deletion src/Tribe/Commerce/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class Tribe__Tickets__Commerce__Currency {
* @since 4.7
*/
public function __construct() {
$this->generate_default_currency_map();
if ( did_action( 'init' ) || doing_action( 'init' ) ) {
$this->generate_default_currency_map();
} else {
add_action( 'init', [ $this, 'generate_default_currency_map' ], 1 );
}
}

/**
Expand Down
11 changes: 10 additions & 1 deletion src/Tribe/Commerce/PayPal/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ public function __construct() {
$main = Tribe__Tickets__Main::instance();

/* Set up some parent's vars */
$this->plugin_name = esc_html_x( 'Tribe Commerce', 'ticket provider', 'event-tickets' );
$this->plugin_path = $main->plugin_path;
$this->plugin_url = $main->plugin_url;

Expand Down Expand Up @@ -299,6 +298,7 @@ public function bind_implementations() {
* @since 4.7
*/
public function hooks() {
add_action( 'init', [ $this, 'set_plugin_name' ], 9 );
// if the hooks have already been bound, don't do it again
if ( $this->is_loaded ) {
return false;
Expand Down Expand Up @@ -373,6 +373,15 @@ public function hooks() {
add_filter( 'tec_cache_listener_save_post_types', [ $this, 'filter_cache_listener_save_post_types' ] );
}

/**
* Sets the RSVPs plugin name.
*
* @since TBD
*/
public function set_plugin_name() {
$this->plugin_name = esc_html_x( 'Tribe Commerce', 'ticket provider', 'event-tickets' );
}

/**
* Hooked to the init action
*
Expand Down
12 changes: 11 additions & 1 deletion src/Tribe/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public static function instance() {
*/
protected function __construct() {
// Set up some of the plugin's properties.
$this->plugin_name = esc_html_x( 'Tickets', 'provider_plugin_name', 'event-tickets' );
$this->plugin_slug = 'tickets';
$this->plugin_path = trailingslashit( EVENT_TICKETS_DIR );
$this->plugin_dir = trailingslashit( basename( $this->plugin_path ) );
Expand All @@ -187,14 +186,25 @@ protected function __construct() {
$this->plugin_url = trailingslashit( plugins_url( $dir_prefix . $this->plugin_dir ) );
}

/**
* Set the plugin name.
*
* @since TBD
*/
public function set_plugin_name() {
$this->plugin_name = esc_html_x( 'Tickets', 'provider_plugin_name', 'event-tickets' );
}

/**
* Attach our initial hooks and filters
*
* @since 5.18.0
* @since TBD Called `set_plugin_name` on `init` hook.
*
* @return void
*/
public function do_hooks() {
add_action( 'init', [ $this, 'set_plugin_name' ] );
add_filter( 'tribe_events_integrations_should_load_freemius', '__return_false' );

$this->maybe_set_common_lib_info();
Expand Down
11 changes: 11 additions & 0 deletions src/Tribe/REST/V1/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ class Tribe__Tickets__REST__V1__Messages implements Tribe__REST__Messages_Interf
*
*/
public function __construct() {
add_action( 'init', [ $this, 'set_messages' ] );
}

/**
* Sets the messages handled by the class.
*
* @since TBD
*
* @return void
*/
public function set_messages() {
$this->messages = [
'missing-attendee-id' => __( 'The attendee ID is missing from the request', 'event-tickets' ),
'attendee-not-found' => __( 'The requested post ID does not exist or is not an attendee', 'event-tickets' ),
Expand Down
12 changes: 11 additions & 1 deletion src/Tribe/RSVP.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ public function __construct() {
$main = Tribe__Tickets__Main::instance();
$this->tickets_view = Tribe__Tickets__Tickets_View::instance();
/* Set up parent vars */
$this->plugin_name = $this->pluginName = esc_html( tribe_get_rsvp_label_plural( 'provider_plugin_name' ) );
$this->plugin_path = $this->pluginPath = $main->plugin_path;
$this->plugin_url = $this->pluginUrl = $main->plugin_url;

Expand All @@ -228,6 +227,7 @@ public function __construct() {
* Registers all actions/filters
*/
public function hooks() {
add_action( 'init', [ $this, 'set_plugin_name' ], 9 );
add_action( 'wp_enqueue_scripts', [ $this, 'register_resources' ], 5 );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_resources' ], 11 );
add_action( 'trashed_post', [ $this, 'maybe_redirect_to_attendees_report' ] );
Expand Down Expand Up @@ -258,6 +258,16 @@ public function hooks() {
add_filter( 'tec_cache_listener_save_post_types', [ $this, 'filter_cache_listener_save_post_types' ] );
}

/**
* Sets the RSVPs plugin name.
*
* @since TBD
*/
public function set_plugin_name() {
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase, Squiz.PHP.DisallowMultipleAssignments.Found
$this->plugin_name = $this->pluginName = esc_html( tribe_get_rsvp_label_plural( 'provider_plugin_name' ) );
}

/**
* Handle RSVP processing for the RSVP forms.
*
Expand Down
13 changes: 11 additions & 2 deletions src/Tribe/Tickets_Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,29 @@ class Tribe__Tickets__Tickets_Handler {
* Class constructor.
*/
public function __construct() {
$this->unlimited_term = __( 'Unlimited', 'event-tickets' );

$this->add_hooks();

$this->path = trailingslashit( dirname( dirname( dirname( __FILE__ ) ) ) );
}

/**
* Set the unlimited term name
*
* @since TBD
*/
public function set_unlimited_term_name() {
$this->unlimited_term = __( 'Unlimited', 'event-tickets' );
}

/**
* Add hooks for saving/meta.
*
* @since 4.11.4
* @since TBD Added the `set_unlimited_term_name` method to set the unlimited term name.
*/
public function add_hooks() {
$main = Tribe__Tickets__Main::instance();
add_action( 'init', [ $this, 'set_unlimited_term_name' ] );

foreach ( $main->post_types() as $post_type ) {
add_action( 'save_post_' . $post_type, [ $this, 'save_post' ] );
Expand Down
6 changes: 6 additions & 0 deletions tests/slr_integration/Health_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Health_Test extends Controller_Test_Case {
public function it_should_add_slr_tests() {
$controller = $this->make_controller();
$controller->register();
$controller->define_tests();

$tests = $controller->get_tests();

Expand Down Expand Up @@ -56,6 +57,7 @@ public function it_should_fail_when_no_nonce() {

$controller = $this->make_controller();
$controller->register();
$controller->define_tests();

$this->expectException( \Exception::class );
// Fail because no nonce.
Expand All @@ -71,6 +73,7 @@ public function it_should_check_slr_valid_license_with_invalid_license() {

$controller = $this->make_controller();
$controller->register();
$controller->define_tests();

$wp_send_json_error = $this->mock_wp_send_json_error();
$wp_send_json_success = $this->mock_wp_send_json_success();
Expand All @@ -95,6 +98,7 @@ public function it_should_check_slr_valid_license() {

$controller = $this->make_controller();
$controller->register();
$controller->define_tests();

$_REQUEST['_ajax_nonce'] = wp_create_nonce( self::NONCE_ACTION );

Expand All @@ -120,6 +124,7 @@ public function it_should_check_slr_can_see_sass_when_sass_unavailable() {

$controller = $this->make_controller();
$controller->register();
$controller->define_tests();

$wp_send_json_error = $this->mock_wp_send_json_error();
$wp_send_json_success = $this->mock_wp_send_json_success();
Expand All @@ -145,6 +150,7 @@ public function it_should_check_slr_can_see_sass_when_sass_available() {

$controller = $this->make_controller();
$controller->register();
$controller->define_tests();

$wp_send_json_error = $this->mock_wp_send_json_error();
$wp_send_json_success = $this->mock_wp_send_json_success();
Expand Down

0 comments on commit 7e92a6b

Please sign in to comment.