close
Skip to content

Extract CampTix Admin Setup and Tools into dedicated classes#1645

Open
dd32 wants to merge 3 commits intoproductionfrom
add/claude/camptix-admin-setup-extraction
Open

Extract CampTix Admin Setup and Tools into dedicated classes#1645
dd32 wants to merge 3 commits intoproductionfrom
add/claude/camptix-admin-setup-extraction

Conversation

@dd32
Copy link
Member

@dd32 dd32 commented Mar 10, 2026

Summary

  • Extracts the Tickets > Setup page methods from CampTix_Plugin into CampTix_Admin_Setup (inc/class-camptix-admin-setup.php)
  • Extracts the Tickets > Tools page UI methods (Summarize, Revenue, Export, Notify, Refund tabs) into CampTix_Admin_Tools (inc/class-camptix-admin-tools.php)
  • Data/utility methods (get_summary, generate_revenue_report_data, get_segment, etc.) remain in CampTix_Plugin
  • Settings getters (get_options, get_default_options, get_currencies) remain in CampTix_Plugin
  • Both new classes use composition: they hold a CampTix_Plugin reference and delegate to it
  • camptix.php reduced from ~8,867 to ~7,587 lines (-1,280 lines)

Test plan

  • All 63 existing CampTix integration tests pass locally
  • CI PHP tests pass on 8.1, 8.4, 8.5
  • CI lint checks pass

dd32 and others added 3 commits March 10, 2026 16:36
…etup

Move the Tickets > Setup page rendering, settings registration, field
renderers, options validation, and related admin UI methods into a
dedicated CampTix_Admin_Setup class at inc/class-camptix-admin-setup.php.

Settings getters (get_options, get_default_options, get_currencies,
get_beta_features) remain in CampTix_Plugin. A validate_options proxy
is kept on CampTix_Plugin for backwards compatibility.

This reduces camptix.php by ~420 lines and is the first step toward
splitting the monolithic class into focused admin modules.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The code in class-camptix-admin-setup.php was moved verbatim from
camptix.php which also uses phpcs:ignoreFile. Fixing 95 legacy lint
errors in moved code is a separate refactoring task.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the Tickets > Tools page UI methods (Summarize, Revenue, Export,
Notify, Refund tabs) into a dedicated inc/class-camptix-admin-tools.php
file. Data/utility methods (get_summary, generate_revenue_report_data,
get_segment, etc.) remain in CampTix_Plugin.

camptix.php: 8,445 -> 7,587 lines (-858)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dd32 dd32 changed the title Extract Admin Settings/Setup from CampTix_Plugin into dedicated class Extract CampTix Admin Setup and Tools into dedicated classes Mar 10, 2026
@dd32 dd32 requested a review from Copilot March 10, 2026 07:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors CampTix’s wp-admin UI by extracting the Tickets → Setup and Tickets → Tools screens out of the monolithic CampTix_Plugin class into dedicated admin classes, while keeping data/utility methods in the main plugin.

Changes:

  • Added CampTix_Admin_Setup to own Setup-page settings registration, validation, and UI.
  • Added CampTix_Admin_Tools to own Tools-page tab UIs (Summarize/Revenue/Export/Notify/Refund) and related request handlers.
  • Updated camptix.php to instantiate the new classes and route admin hooks/menu callbacks through them.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
public_html/wp-content/plugins/camptix/inc/class-camptix-admin-tools.php New class that renders the Tools admin page and handles export/notify/refund flows.
public_html/wp-content/plugins/camptix/inc/class-camptix-admin-setup.php New class that registers Setup settings/sections/fields, validates options, and renders Setup UI.
public_html/wp-content/plugins/camptix/camptix.php Wires the new admin classes into plugin init and admin menu/hook registration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +343 to +347
$errors[] = __( 'At least one segment condition must be defined.', 'wordcamporg' );

if ( empty( $_POST['tix-notify-segment-match'] ) )
$error[] = __( 'Please select a segment match mode' );

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In menu_tools_notify(), errors are collected in $errors, but this branch appends to $error (undefined) and the string is missing the text domain. This prevents the validation error from being surfaced. Use $errors[] = __( ... , 'wordcamporg' ) here.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Existing bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$errors[] = __( 'At least one segment condition must be defined.', 'wordcamporg' );
if ( empty( $_POST['tix-notify-segment-match'] ) )
$error[] = __( 'Please select a segment match mode' );
$errors[] = __( 'At least one segment condition must be defined.', 'wordcamporg' );
if ( empty( $_POST['tix-notify-segment-match'] ) )
$errors[] = __( 'Please select a segment match mode' );

Comment on lines +354 to +356
if ( count( $recipients ) < 1 ) {
$errors[] = __( 'The selected segment does not match any recipients. Please try a again.', 'wordcamporg' );
}
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the error message: “Please try a again.” should be “Please try again.”

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Existing bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( count( $recipients ) < 1 ) {
$errors[] = __( 'The selected segment does not match any recipients. Please try a again.', 'wordcamporg' );
}
if ( count( $recipients ) < 1 ) {
$errors[] = __( 'The selected segment does not match any recipients. Please try again.', 'wordcamporg' );
}

Comment on lines +812 to +817
'paged' => $paged++,
'orderby' => 'ID',
'fields' => 'ids',
'order' => 'ASC',
'cache_results' => 'false',
) ) ) {
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_posts() is passed 'cache_results' => 'false' as a string. In WordPress query args this should be a boolean false; the non-empty string may be treated as truthy and enable caching unintentionally.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Existing bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'paged' => $paged++,
'orderby' => 'ID',
'fields' => 'ids',
'order' => 'ASC',
'cache_results' => 'false',
) ) ) {
'paged' => $paged++,
'orderby' => 'ID',
'fields' => 'ids',
'order' => 'ASC',
'cache_results' => false,
) ) ) {

Comment on lines +279 to +283
echo wpautop( sprintf(
__( 'The <a href="%1$s">currently selected currency</a> is not supported by any of the <a href="%2$s">enabled payment methods</a>.' ),
esc_url( add_query_arg( 'tix_section', 'general', $base_url ) ),
esc_url( add_query_arg( 'tix_section', 'payment', $base_url ) )
) );
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The translation call in this admin notice omits the text domain. Elsewhere in CampTix admin strings use the wordcamporg domain; please pass it here as well so the string can be translated consistently.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: existing bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo wpautop( sprintf(
__( 'The <a href="%1$s">currently selected currency</a> is not supported by any of the <a href="%2$s">enabled payment methods</a>.' ),
esc_url( add_query_arg( 'tix_section', 'general', $base_url ) ),
esc_url( add_query_arg( 'tix_section', 'payment', $base_url ) )
) );
echo wpautop( sprintf(
__( 'The <a href="%1$s">currently selected currency</a> is not supported by any of the <a href="%2$s">enabled payment methods</a>.', 'wordcamporg' ),
esc_url( add_query_arg( 'tix_section', 'general', $base_url ) ),
esc_url( add_query_arg( 'tix_section', 'payment', $base_url ) )
) );

Comment on lines +81 to +82
require( dirname( __FILE__ ) . '/inc/class-camptix-admin-setup.php' );
require( dirname( __FILE__ ) . '/inc/class-camptix-admin-tools.php' );
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new require() line is mis-indented compared to the surrounding requires, which makes this block harder to scan. Please align the indentation with the other require(...) statements.

Copilot uses AI. Check for mistakes.
Comment on lines +309 to +319
function field_checkbox( $args ) {
$args = array_merge(
array(
'id' => '',
'name' => '',
'class' => '',
'value' => ''
),
$args
)

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

field_checkbox() is missing a semicolon after the array_merge(...) call (and the statement isn’t terminated), which will cause a PHP parse error and break the plugin. Please close the array_merge expression properly and end it with ;.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: existing bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Existing bug.

Suggested change
function field_checkbox( $args ) {
$args = array_merge(
array(
'id' => '',
'name' => '',
'class' => '',
'value' => ''
),
$args
)
function field_checkbox( $args ) {
$args = array_merge(
array(
'id' => '',
'name' => '',
'class' => '',
'value' => ''
),
$args
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants