Extract CampTix Admin Setup and Tools into dedicated classes#1645
Extract CampTix Admin Setup and Tools into dedicated classes#1645dd32 wants to merge 3 commits intoproductionfrom
Conversation
…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>
There was a problem hiding this comment.
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_Setupto own Setup-page settings registration, validation, and UI. - Added
CampTix_Admin_Toolsto own Tools-page tab UIs (Summarize/Revenue/Export/Notify/Refund) and related request handlers. - Updated
camptix.phpto 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.
| $errors[] = __( 'At least one segment condition must be defined.', 'wordcamporg' ); | ||
|
|
||
| if ( empty( $_POST['tix-notify-segment-match'] ) ) | ||
| $error[] = __( 'Please select a segment match mode' ); | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
| $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' ); | |
| if ( count( $recipients ) < 1 ) { | ||
| $errors[] = __( 'The selected segment does not match any recipients. Please try a again.', 'wordcamporg' ); | ||
| } |
There was a problem hiding this comment.
Typo in the error message: “Please try a again.” should be “Please try again.”
There was a problem hiding this comment.
| 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' ); | |
| } |
| 'paged' => $paged++, | ||
| 'orderby' => 'ID', | ||
| 'fields' => 'ids', | ||
| 'order' => 'ASC', | ||
| 'cache_results' => 'false', | ||
| ) ) ) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
| 'paged' => $paged++, | |
| 'orderby' => 'ID', | |
| 'fields' => 'ids', | |
| 'order' => 'ASC', | |
| 'cache_results' => 'false', | |
| ) ) ) { | |
| 'paged' => $paged++, | |
| 'orderby' => 'ID', | |
| 'fields' => 'ids', | |
| 'order' => 'ASC', | |
| 'cache_results' => false, | |
| ) ) ) { |
| 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 ) ) | ||
| ) ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
| 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 ) ) | |
| ) ); |
| require( dirname( __FILE__ ) . '/inc/class-camptix-admin-setup.php' ); | ||
| require( dirname( __FILE__ ) . '/inc/class-camptix-admin-tools.php' ); |
There was a problem hiding this comment.
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.
| function field_checkbox( $args ) { | ||
| $args = array_merge( | ||
| array( | ||
| 'id' => '', | ||
| 'name' => '', | ||
| 'class' => '', | ||
| 'value' => '' | ||
| ), | ||
| $args | ||
| ) | ||
|
|
There was a problem hiding this comment.
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 ;.
There was a problem hiding this comment.
Note: Existing bug.
| 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 | |
| ); | |
Summary
CampTix_PluginintoCampTix_Admin_Setup(inc/class-camptix-admin-setup.php)CampTix_Admin_Tools(inc/class-camptix-admin-tools.php)get_summary,generate_revenue_report_data,get_segment, etc.) remain inCampTix_Pluginget_options,get_default_options,get_currencies) remain inCampTix_PluginCampTix_Pluginreference and delegate to itcamptix.phpreduced from ~8,867 to ~7,587 lines (-1,280 lines)Test plan