From ab35c671c4aa1cd877bec5236a8f87a691a6f8f6 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Fri, 22 Nov 2024 08:24:16 +0000 Subject: [PATCH 01/15] Start refactoring --- .../wp-content/plugins/camptix/camptix.php | 469 +---------------- .../camptix/inc/class-camptix-admin.php | 480 ++++++++++++++++++ 2 files changed, 484 insertions(+), 465 deletions(-) create mode 100644 public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php diff --git a/public_html/wp-content/plugins/camptix/camptix.php b/public_html/wp-content/plugins/camptix/camptix.php index 4182556df5..ba55fd45b8 100644 --- a/public_html/wp-content/plugins/camptix/camptix.php +++ b/public_html/wp-content/plugins/camptix/camptix.php @@ -67,6 +67,7 @@ function __construct() { require( dirname( __FILE__ ) . '/inc/class-camptix-addon.php' ); require( dirname( __FILE__ ) . '/inc/class-camptix-payment-method.php' ); + require( dirname( __FILE__ ) . '/inc/class-camptix-admin.php' ); if ( defined( 'WP_CLI' ) && WP_CLI ) { require_once( dirname( __FILE__ ) . '/inc/class-wp-cli-commands.php' ); @@ -121,9 +122,6 @@ function init() { // Stuff that might need to redirect, thus not in [camptix] shortcode. add_action( 'template_redirect', array( $this, 'template_redirect' ), 9 ); // earlier than the others. - add_action( 'admin_init', array( $this, 'admin_init' ) ); - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); - add_action( 'admin_head', array( $this, 'admin_menu_fix' ) ); add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); // Handle meta for our post types. @@ -150,7 +148,6 @@ function init() { $this->add_resend_notices(); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); // Sort of admin_init but on the Tickets > Tools page only. add_action( 'load-tix_ticket_page_camptix_tools', array( $this, 'summarize_extra_fields' ) ); @@ -448,7 +445,7 @@ function notify_shortcode_ticket_url( $atts ) { * grabs all the available tickets questions and adds them to Summarize. */ function summarize_extra_fields() { - if ( 'summarize' != $this->get_tools_section() ) + if ( 'summarize' != Camptix_Admin::get_tools_section() ) return; // Adds all questions to Summarize and register the callback that counts all the things. @@ -510,59 +507,6 @@ function enqueue_scripts() { ) ); } - function admin_enqueue_scripts() { - global $wp_query; - - if ( ! $wp_query->query_vars ) { // only on singular admin pages - if ( 'tix_ticket' == get_post_type() || 'tix_coupon' == get_post_type() ) { - } - } - - // Let's see whether to include admin.css and admin.js - if ( is_admin() ) { - $screen = get_current_screen(); - $post_types = array( 'tix_ticket', 'tix_coupon', 'tix_email', 'tix_attendee' ); - $pages = array( 'camptix_options', 'camptix_tools' ); - $screen_ids = array( 'dashboard' ); - if ( - ( in_array( get_post_type(), $post_types ) ) || - ( in_array( $screen->id, $screen_ids ) ) || - ( isset( $_REQUEST['post_type'] ) && in_array( $_REQUEST['post_type'], $post_types ) ) || - ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $pages ) ) - ) { - wp_enqueue_script( 'jquery-ui-datepicker' ); - wp_enqueue_style( - 'jquery-ui', - plugins_url( '/external/jquery-ui.css', __FILE__ ), - array(), - filemtime( __DIR__ . '/external/jquery-ui.css' ) - ); - - wp_enqueue_style( - 'camptix-admin', - plugins_url( '/admin.css', __FILE__ ), - array(), - filemtime( __DIR__ . '/admin.css' ) - ); - - wp_enqueue_script( - 'camptix-admin', - plugins_url( '/admin.js', __FILE__ ), - array( 'jquery', 'jquery-ui-datepicker', 'backbone' ), - filemtime( __DIR__ . '/admin.js' ) - ); - - wp_dequeue_script( 'autosave' ); - } - } - - $screen = get_current_screen(); - if ( 'tix_ticket_page_camptix_options' == $screen->id ) { - wp_enqueue_script( 'jquery-ui-datepicker' ); - wp_enqueue_style( 'jquery-ui', plugins_url( '/external/jquery-ui.css', __FILE__ ), array(), $this->version ); - } - } - /** * Filters column fields for our new post types, adds extra columns * and registers callback actions to render column callback. @@ -1555,121 +1499,7 @@ protected function run_upgrade_parts( $from ) { return $this->version; } - /** - * Runs during admin_init, mainly for Settings API things. - */ - function admin_init() { - register_setting( 'camptix_options', 'camptix_options', array( $this, 'validate_options' ) ); - - // Add settings fields - $this->menu_setup_controls(); - - // Let's add some help tabs. - require_once dirname( __FILE__ ) . '/help.php'; - } - - function menu_setup_controls() { - wp_enqueue_script( 'jquery-ui' ); - $section = $this->get_setup_section(); - - add_action( 'admin_notices', array( $this, 'admin_notice_supported_currencies' ) ); - - switch ( $section ) { - case 'general': - add_settings_section( 'general', __( 'General Configuration', 'wordcamporg' ), array( $this, 'menu_setup_section_general' ), 'camptix_options' ); - $this->add_settings_field_helper( 'event_name', __( 'Event Name', 'wordcamporg' ), 'field_text' ); - $this->add_settings_field_helper( 'currency', __( 'Currency', 'wordcamporg' ), 'field_currency' ); - - $this->add_settings_field_helper( 'refunds_enabled', __( 'Enable Refunds', 'wordcamporg' ), 'field_enable_refunds', false, - __( "This will allows your customers to refund their tickets purchase by filling out a simple refund form.", 'wordcamporg' ) - ); - - break; - case 'payment': - foreach ( $this->get_available_payment_methods() as $key => $payment_method ) { - $payment_method_obj = $this->get_payment_method_by_id( $key ); - - add_settings_section( 'payment_' . $key, $payment_method_obj->name, array( $payment_method_obj, '_camptix_settings_section_callback' ), 'camptix_options' ); - add_settings_field( 'payment_method_' . $key . '_enabled', __( 'Enabled', 'wordcamporg' ), array( $payment_method_obj, '_camptix_settings_enabled_callback' ), 'camptix_options', 'payment_' . $key, array( - 'name' => "camptix_options[payment_methods][{$key}]", - 'value' => isset( $this->options['payment_methods'][$key] ) ? (bool) $this->options['payment_methods'][ $key ] : false, - ) ); - - $payment_method_obj->payment_settings_fields(); - } - break; - case 'email-templates': - add_settings_section( 'general', __( 'E-mail Templates', 'wordcamporg' ), array( $this, 'menu_setup_section_email_templates' ), 'camptix_options' ); - $this->add_settings_field_helper( 'email_template_single_purchase', __( 'Single purchase', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_multiple_purchase', __( 'Multiple purchase', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_multiple_purchase_receipt', __( 'Multiple purchase (receipt)', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_pending_succeeded', __( 'Pending Payment Succeeded', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_pending_failed', __( 'Pending Payment Failed', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_single_refund', __( 'Single Refund', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_multiple_refund', __( 'Multiple Refund', 'wordcamporg' ), 'field_textarea' ); - - foreach ( apply_filters( 'camptix_custom_email_templates', array() ) as $key => $template ) { - $this->add_settings_field_helper( $key, $template['title'], $template['callback_method'] ); - } - - // Add a reset templates button - add_action( 'camptix_setup_buttons', array( $this, 'setup_buttons_reset_templates' ) ); - break; - case 'beta': - - if ( ! $this->beta_features_enabled ) - break; - - add_settings_section( 'general', __( 'Beta Features', 'wordcamporg' ), array( $this, 'menu_setup_section_beta' ), 'camptix_options' ); - - $this->add_settings_field_helper( 'reservations_enabled', __( 'Enable Reservations', 'wordcamporg' ), 'field_yesno', false, - __( "Reservations is a way to make sure that a certain group of people, can always purchase their tickets, even if you sell out fast.", 'wordcamporg' ) - ); - - if ( current_user_can( $this->caps['refund_all'] ) ) { - $this->add_settings_field_helper( 'refund_all_enabled', __( 'Enable Refund All', 'wordcamporg' ), 'field_yesno', false, - __( "Allows to refund all purchased tickets by an admin via the Tools menu.", 'wordcamporg' ) - ); - } - - $this->add_settings_field_helper( 'archived', __( 'Archived Event', 'wordcamporg' ), 'field_yesno', false, - __( "Archived events are read-only.", 'wordcamporg' ) - ); - break; - default: - do_action( 'camptix_menu_setup_controls', $section ); - break; - } - } - - function menu_setup_section_beta() { - echo '

' . __( 'Beta features are things that are being worked on in CampTix, but are not quite finished yet. You can try them out, but we do not recommend doing that in a live environment on a real event. If you have any kind of feedback on any of the beta features, please let us know.', 'wordcamporg' ) . '

'; - } - function menu_setup_section_email_templates() { - ?> - -

- -

- -

- - -

- -

- - - ' . __( 'General configuration.', 'wordcamporg' ) . '

'; - } /** * I don't like repeating code, so here's a helper for simple fields. @@ -2026,254 +1856,6 @@ function format_name_string( $name_string, $given_name, $surname ) { return $name_string; } - /** - * Oh the holy admin menu! - */ - function admin_menu() { - add_submenu_page( 'edit.php?post_type=tix_ticket', __( 'Tools', 'wordcamporg' ), __( 'Tools', 'wordcamporg' ), $this->caps['manage_tools'], 'camptix_tools', array( $this, 'menu_tools' ) ); - add_submenu_page( 'edit.php?post_type=tix_ticket', __( 'Setup', 'wordcamporg' ), __( 'Setup', 'wordcamporg' ), $this->caps['manage_options'], 'camptix_options', array( $this, 'menu_setup' ) ); - remove_submenu_page( 'edit.php?post_type=tix_ticket', 'post-new.php?post_type=tix_ticket' ); - } - - /** - * When squeezing several custom post types under one top-level menu item, WordPress - * tends to get confused which menu item is currently active, especially around post-new.php. - * This function runs during admin_head and hacks into some of the global variables that are - * used to construct the menu. - */ - function admin_menu_fix() { - global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; - - // Make sure Coupons is selected when adding a new coupon - if ( 'post-new.php' == $pagenow && 'tix_coupon' == $typenow ) - $submenu_file = 'edit.php?post_type=tix_coupon'; - - // Make sure Attendees is selected when adding a new attendee - if ( 'post-new.php' == $pagenow && 'tix_attendee' == $typenow ) - $submenu_file = 'edit.php?post_type=tix_attendee'; - - // Make sure Tickets is selected when creating a new ticket - if ( 'post-new.php' == $pagenow && 'tix_ticket' == $typenow ) - $submenu_file = 'edit.php?post_type=tix_ticket'; - } - - /** - * The Tickets > Setup screen, uses the Settings API. - */ - function menu_setup() { - ?> -
-

- - -
- -

- - -

-
-
- Tools? This tells - * us which tab is currently active. - */ - function get_setup_section() { - if ( isset( $_REQUEST['tix_section'] ) ) - return strtolower( $_REQUEST['tix_section'] ); - - return 'general'; - } - - /** - * Tabs for Tickets > Tools, outputs the markup. - */ - function menu_setup_tabs() { - $current_section = $this->get_setup_section(); - $sections = array( - 'general' => __( 'General', 'wordcamporg' ), - 'payment' => __( 'Payment', 'wordcamporg' ), - 'email-templates' => __( 'E-mail Templates', 'wordcamporg' ), - ); - - if ( $this->beta_features_enabled ) - $sections['beta'] = __( 'Beta', 'wordcamporg' ); - - $sections = apply_filters( 'camptix_setup_sections', $sections ); - - foreach ( $sections as $section_key => $section_caption ) { - $active = $current_section === $section_key ? 'nav-tab-active' : ''; - $url = add_query_arg( 'tix_section', $section_key ); - echo '' . esc_html( $section_caption ) . ''; - } - } - - /** - * The Tickets > Tools screen, doesn't use the settings API, but does use tabs. - */ - function menu_tools() { - ?> -
-

- - - get_tools_section(); - if ( $section == 'summarize' ) - $this->menu_tools_summarize(); - elseif ( $section == 'revenue' ) - $this->menu_tools_revenue(); - elseif ( $section == 'export' ) - $this->menu_tools_export(); - elseif ( $section == 'notify' ) - $this->menu_tools_notify(); - elseif ( $section == 'refund' && ! $this->options['archived'] ) - $this->menu_tools_refund(); - else - do_action( 'camptix_menu_tools_' . $section ); - ?> -
- Tools? This tells - * us which tab is currently active. - */ - function get_tools_section() { - if ( isset( $_REQUEST['tix_section'] ) ) - return strtolower( $_REQUEST['tix_section'] ); - - return 'summarize'; - } - - /** - * Tabs for Tickets > Tools, outputs the markup. - */ - function menu_tools_tabs() { - $current_section = $this->get_tools_section(); - $sections = apply_filters( 'camptix_menu_tools_tabs', array( - 'summarize' => __( 'Summarize', 'wordcamporg' ), - 'revenue' => __( 'Revenue', 'wordcamporg' ), - 'export' => __( 'Export', 'wordcamporg' ), - 'notify' => __( 'Notify', 'wordcamporg' ), - ) ); - - if ( current_user_can( $this->caps['refund_all'] ) && ! $this->options['archived'] && $this->options['refund_all_enabled'] ) - $sections['refund'] = __( 'Refund', 'wordcamporg' ); - - foreach ( $sections as $section_key => $section_caption ) { - $active = $current_section === $section_key ? 'nav-tab-active' : ''; - $url = add_query_arg( 'tix_section', $section_key ); - echo '' . esc_html( $section_caption ) . ''; - } - } - - /** - * Tools > Summarize, the screen that outputs the summary tables, - * provides an export option, powered by the summarize_admin_init method, - * hooked (almost) at admin_init, because of additional headers. Doesn't use - * the Settings API so check for nonces/referrers and caps. - * @see summarize_admin_init() - */ - function menu_tools_summarize() { - $summarize_by = isset( $_POST['tix_summarize_by'] ) ? $_POST['tix_summarize_by'] : 'ticket'; - ?> -
- - - - - - - -
- -
-

- - - - -

-
- - get_available_summary_fields() ) ) : ?> - get_available_summary_fields(); - $summary = $this->get_summary( $summarize_by ); - $summary_title = $fields[ $summarize_by ]; - $alt = ''; - - $rows = array(); - foreach ( $summary as $entry ) - $rows[] = array( - esc_html( $summary_title ) => esc_html( $entry['label'] ), - __( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ) - ); - - // Render the widefat table. - $this->table( $rows, 'widefat tix-summarize' ); - ?> - - - caps['manage_tools'] ) || 'summarize' != $this->get_tools_section() ) - return; - - if ( isset( $_POST['tix_export_summary'], $_POST['tix_summarize_by'] ) && check_admin_referer( 'tix_summarize' ) ) { - $summarize_by = $_POST['tix_summarize_by']; - if ( ! array_key_exists( $summarize_by, $this->get_available_summary_fields() ) ) - return; - - $fields = $this->get_available_summary_fields(); - $summary = $this->get_summary( $summarize_by ); - $summary_title = $fields[ $summarize_by ]; - $filename = sprintf( 'camptix-summary-%s-%s.csv', sanitize_title_with_dashes( $summary_title ), date( 'Y-m-d' ) ); - - header( 'Content-Type: text/csv' ); - header( 'Content-Disposition: attachment; filename="' . $filename . '"' ); - header( "Cache-control: private" ); - header( 'Pragma: private' ); - header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); - - $stream = fopen( "php://output", 'w' ); - - $headers = array( $summary_title, __( 'Count', 'wordcamporg' ) ); - fputcsv( $stream, self::esc_csv( $headers ) ); - foreach ( $summary as $entry ) { - fputcsv( $stream, self::esc_csv( $entry ), ',', '"' ); - } - - fclose( $stream ); - die(); - } - } - /** * Returns a summary of all attendees. A lot of @magic here and * watch out for actions and filters. @@ -2765,7 +2347,7 @@ function menu_tools_export() { function export_admin_init() { global $post; - if ( ! current_user_can( $this->caps['manage_tools'] ) || 'export' != $this->get_tools_section() ) + if ( ! current_user_can( $this->caps['manage_tools'] ) || 'export' != Camptix_Admin::get_tools_section() ) return; if ( isset( $_POST['tix_export_submit'], $_POST['tix_export_to'] ) && check_admin_referer( 'tix_export' ) ) { @@ -3661,7 +3243,7 @@ function menu_tools_refund() { * Runs before the page markup is printed so can add settings errors. */ function menu_tools_refund_admin_init() { - if ( ! current_user_can( $this->caps['refund_all'] ) || 'refund' != $this->get_tools_section() ) + if ( ! current_user_can( $this->caps['refund_all'] ) || 'refund' != Camptix_Admin::get_tools_section() ) return; // Display results of completed refund-all job @@ -8213,49 +7795,6 @@ function shutdown() { $this->flush_tickets_page_seriously(); } - /** - * Helper function to create admin tables, give me a - * $rows array and I'll do the rest. - */ - function table( $rows, $classes='widefat' ) { - - if ( ! is_array( $rows ) || ! isset( $rows[0] ) ) - return; - - $alt = ''; - ?> - - - - - - - - - - - - - - - - $value ) : ?> - - - - - -
- -
- -
- caps['manage_tools'], 'camptix_tools', array( $this, 'menu_tools' ) ); + add_submenu_page( 'edit.php?post_type=tix_ticket', __( 'Setup', 'wordcamporg' ), __( 'Setup', 'wordcamporg' ), $this->caps['manage_options'], 'camptix_options', array( $this, 'menu_setup' ) ); + add_submenu_page( 'edit.php?post_type=tix_ticket', __( 'Badges', 'wordcamporg' ), __( 'Badges', 'wordcamporg' ), $this->caps['manage_options'], 'camptix_badges', array( $this, 'menu_badges' ) ); + + remove_submenu_page( 'edit.php?post_type=tix_ticket', 'post-new.php?post_type=tix_ticket' ); + } + + /** + * When squeezing several custom post types under one top-level menu item, WordPress + * tends to get confused which menu item is currently active, especially around post-new.php. + * This function runs during admin_head and hacks into some of the global variables that are + * used to construct the menu. + */ + function admin_menu_fix() { + global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; + + // Make sure Coupons is selected when adding a new coupon + if ( 'post-new.php' == $pagenow && 'tix_coupon' == $typenow ) + $submenu_file = 'edit.php?post_type=tix_coupon'; + + // Make sure Attendees is selected when adding a new attendee + if ( 'post-new.php' == $pagenow && 'tix_attendee' == $typenow ) + $submenu_file = 'edit.php?post_type=tix_attendee'; + + // Make sure Tickets is selected when creating a new ticket + if ( 'post-new.php' == $pagenow && 'tix_ticket' == $typenow ) + $submenu_file = 'edit.php?post_type=tix_ticket'; + } + + /** + * The Tickets > Setup screen, uses the Settings API. + */ + function menu_setup() { + ?> +
+

+ + +
+ +

+ + +

+
+
+ Tools, outputs the markup. + */ + function menu_setup_tabs() { + $current_section = $this->get_setup_section(); + $sections = array( + 'general' => __( 'General', 'wordcamporg' ), + 'payment' => __( 'Payment', 'wordcamporg' ), + 'email-templates' => __( 'E-mail Templates', 'wordcamporg' ), + ); + + if ( $this->beta_features_enabled ) + $sections['beta'] = __( 'Beta', 'wordcamporg' ); + + $sections = apply_filters( 'camptix_setup_sections', $sections ); + + foreach ( $sections as $section_key => $section_caption ) { + $active = $current_section === $section_key ? 'nav-tab-active' : ''; + $url = add_query_arg( 'tix_section', $section_key ); + echo '' . esc_html( $section_caption ) . ''; + } + } + + /** + * The Tickets > Tools screen, doesn't use the settings API, but does use tabs. + */ + function menu_tools() { + ?> +
+

+ + + get_tools_section(); + if ( $section == 'summarize' ) + $this->menu_tools_summarize(); + elseif ( $section == 'revenue' ) + $this->menu_tools_revenue(); + elseif ( $section == 'export' ) + $this->menu_tools_export(); + elseif ( $section == 'notify' ) + $this->menu_tools_notify(); + elseif ( $section == 'refund' && ! $this->options['archived'] ) + $this->menu_tools_refund(); + else + do_action( 'camptix_menu_tools_' . $section ); + ?> +
+ Tools? This tells + * us which tab is currently active. + */ + function get_setup_section() { + if ( isset( $_REQUEST['tix_section'] ) ) + return strtolower( $_REQUEST['tix_section'] ); + + return 'general'; + } + + /** + * Remember the tabs in Tickets > Tools? This tells + * us which tab is currently active. + */ + function get_tools_section() { + if ( isset( $_REQUEST['tix_section'] ) ) + return strtolower( $_REQUEST['tix_section'] ); + + return 'summarize'; + } + + /** + * Tabs for Tickets > Tools, outputs the markup. + */ + function menu_tools_tabs() { + $current_section = $this->get_tools_section(); + $sections = apply_filters( 'camptix_menu_tools_tabs', array( + 'summarize' => __( 'Summarize', 'wordcamporg' ), + 'revenue' => __( 'Revenue', 'wordcamporg' ), + 'export' => __( 'Export', 'wordcamporg' ), + 'notify' => __( 'Notify', 'wordcamporg' ), + ) ); + + if ( current_user_can( $this->caps['refund_all'] ) && ! $this->options['archived'] && $this->options['refund_all_enabled'] ) + $sections['refund'] = __( 'Refund', 'wordcamporg' ); + + foreach ( $sections as $section_key => $section_caption ) { + $active = $current_section === $section_key ? 'nav-tab-active' : ''; + $url = add_query_arg( 'tix_section', $section_key ); + echo '' . esc_html( $section_caption ) . ''; + } + } + + /** + * Tools > Summarize, the screen that outputs the summary tables, + * provides an export option, powered by the summarize_admin_init method, + * hooked (almost) at admin_init, because of additional headers. Doesn't use + * the Settings API so check for nonces/referrers and caps. + * @see summarize_admin_init() + */ + function menu_tools_summarize() { + $summarize_by = isset( $_POST['tix_summarize_by'] ) ? $_POST['tix_summarize_by'] : 'ticket'; + ?> +
+ + + + + + + +
+ +
+

+ + + + +

+
+ + get_available_summary_fields() ) ) : ?> + get_available_summary_fields(); + $summary = $this->get_summary( $summarize_by ); + $summary_title = $fields[ $summarize_by ]; + $alt = ''; + + $rows = array(); + foreach ( $summary as $entry ) + $rows[] = array( + esc_html( $summary_title ) => esc_html( $entry['label'] ), + __( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ) + ); + + // Render the widefat table. + $this->table( $rows, 'widefat tix-summarize' ); + ?> + + + caps['manage_tools'] ) || 'summarize' != $this->get_tools_section() ) + return; + + if ( isset( $_POST['tix_export_summary'], $_POST['tix_summarize_by'] ) && check_admin_referer( 'tix_summarize' ) ) { + $summarize_by = $_POST['tix_summarize_by']; + if ( ! array_key_exists( $summarize_by, $this->get_available_summary_fields() ) ) + return; + + $fields = $this->get_available_summary_fields(); + $summary = $this->get_summary( $summarize_by ); + $summary_title = $fields[ $summarize_by ]; + $filename = sprintf( 'camptix-summary-%s-%s.csv', sanitize_title_with_dashes( $summary_title ), date( 'Y-m-d' ) ); + + header( 'Content-Type: text/csv' ); + header( 'Content-Disposition: attachment; filename="' . $filename . '"' ); + header( "Cache-control: private" ); + header( 'Pragma: private' ); + header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); + + $stream = fopen( "php://output", 'w' ); + + $headers = array( $summary_title, __( 'Count', 'wordcamporg' ) ); + fputcsv( $stream, self::esc_csv( $headers ) ); + foreach ( $summary as $entry ) { + fputcsv( $stream, self::esc_csv( $entry ), ',', '"' ); + } + + fclose( $stream ); + die(); + } + } + + /** + * Helper function to create admin tables, give me a + * $rows array and I'll do the rest. + */ + function table( $rows, $classes='widefat' ) { + + if ( ! is_array( $rows ) || ! isset( $rows[0] ) ) + return; + + $alt = ''; + ?> + + + + + + + + + + + + + + + + $value ) : ?> + + + + + +
+ +
+ +
+ query_vars ) { // only on singular admin pages + if ( 'tix_ticket' == get_post_type() || 'tix_coupon' == get_post_type() ) { + } + } + + // Let's see whether to include admin.css and admin.js + if ( is_admin() ) { + $screen = get_current_screen(); + $post_types = array( 'tix_ticket', 'tix_coupon', 'tix_email', 'tix_attendee' ); + $pages = array( 'camptix_options', 'camptix_tools' ); + $screen_ids = array( 'dashboard' ); + if ( + ( in_array( get_post_type(), $post_types ) ) || + ( in_array( $screen->id, $screen_ids ) ) || + ( isset( $_REQUEST['post_type'] ) && in_array( $_REQUEST['post_type'], $post_types ) ) || + ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $pages ) ) + ) { + wp_enqueue_script( 'jquery-ui-datepicker' ); + wp_enqueue_style( + 'jquery-ui', + plugins_url( '/external/jquery-ui.css', __FILE__ ), + array(), + filemtime( __DIR__ . '/external/jquery-ui.css' ) + ); + + wp_enqueue_style( + 'camptix-admin', + plugins_url( '/admin.css', __FILE__ ), + array(), + filemtime( __DIR__ . '/admin.css' ) + ); + + wp_enqueue_script( + 'camptix-admin', + plugins_url( '/admin.js', __FILE__ ), + array( 'jquery', 'jquery-ui-datepicker', 'backbone' ), + filemtime( __DIR__ . '/admin.js' ) + ); + + wp_dequeue_script( 'autosave' ); + } + } + + $screen = get_current_screen(); + if ( 'tix_ticket_page_camptix_options' == $screen->id ) { + wp_enqueue_script( 'jquery-ui-datepicker' ); + wp_enqueue_style( 'jquery-ui', plugins_url( '/external/jquery-ui.css', __FILE__ ), array(), $this->version ); + } + } + + /** + * Runs during admin_init, mainly for Settings API things. + */ + function admin_init() { + register_setting( 'camptix_options', 'camptix_options', array( $this, 'validate_options' ) ); + + // Add settings fields + $this->menu_setup_controls(); + + // Let's add some help tabs. + require_once dirname( __FILE__ ) . '/help.php'; + } + + function menu_setup_controls() { + wp_enqueue_script( 'jquery-ui' ); + $section = $this->get_setup_section(); + + add_action( 'admin_notices', array( $this, 'admin_notice_supported_currencies' ) ); + + switch ( $section ) { + case 'general': + add_settings_section( 'general', __( 'General Configuration', 'wordcamporg' ), array( $this, 'menu_setup_section_general' ), 'camptix_options' ); + $this->add_settings_field_helper( 'event_name', __( 'Event Name', 'wordcamporg' ), 'field_text' ); + $this->add_settings_field_helper( 'currency', __( 'Currency', 'wordcamporg' ), 'field_currency' ); + + $this->add_settings_field_helper( 'refunds_enabled', __( 'Enable Refunds', 'wordcamporg' ), 'field_enable_refunds', false, + __( "This will allows your customers to refund their tickets purchase by filling out a simple refund form.", 'wordcamporg' ) + ); + + break; + case 'payment': + foreach ( $this->get_available_payment_methods() as $key => $payment_method ) { + $payment_method_obj = $this->get_payment_method_by_id( $key ); + + add_settings_section( 'payment_' . $key, $payment_method_obj->name, array( $payment_method_obj, '_camptix_settings_section_callback' ), 'camptix_options' ); + add_settings_field( 'payment_method_' . $key . '_enabled', __( 'Enabled', 'wordcamporg' ), array( $payment_method_obj, '_camptix_settings_enabled_callback' ), 'camptix_options', 'payment_' . $key, array( + 'name' => "camptix_options[payment_methods][{$key}]", + 'value' => isset( $this->options['payment_methods'][$key] ) ? (bool) $this->options['payment_methods'][ $key ] : false, + ) ); + + $payment_method_obj->payment_settings_fields(); + } + break; + case 'email-templates': + add_settings_section( 'general', __( 'E-mail Templates', 'wordcamporg' ), array( $this, 'menu_setup_section_email_templates' ), 'camptix_options' ); + $this->add_settings_field_helper( 'email_template_single_purchase', __( 'Single purchase', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_multiple_purchase', __( 'Multiple purchase', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_multiple_purchase_receipt', __( 'Multiple purchase (receipt)', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_pending_succeeded', __( 'Pending Payment Succeeded', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_pending_failed', __( 'Pending Payment Failed', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_single_refund', __( 'Single Refund', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_multiple_refund', __( 'Multiple Refund', 'wordcamporg' ), 'field_textarea' ); + + foreach ( apply_filters( 'camptix_custom_email_templates', array() ) as $key => $template ) { + $this->add_settings_field_helper( $key, $template['title'], $template['callback_method'] ); + } + + // Add a reset templates button + add_action( 'camptix_setup_buttons', array( $this, 'setup_buttons_reset_templates' ) ); + break; + case 'beta': + + if ( ! $this->beta_features_enabled ) + break; + + add_settings_section( 'general', __( 'Beta Features', 'wordcamporg' ), array( $this, 'menu_setup_section_beta' ), 'camptix_options' ); + + $this->add_settings_field_helper( 'reservations_enabled', __( 'Enable Reservations', 'wordcamporg' ), 'field_yesno', false, + __( "Reservations is a way to make sure that a certain group of people, can always purchase their tickets, even if you sell out fast.", 'wordcamporg' ) + ); + + if ( current_user_can( $this->caps['refund_all'] ) ) { + $this->add_settings_field_helper( 'refund_all_enabled', __( 'Enable Refund All', 'wordcamporg' ), 'field_yesno', false, + __( "Allows to refund all purchased tickets by an admin via the Tools menu.", 'wordcamporg' ) + ); + } + + $this->add_settings_field_helper( 'archived', __( 'Archived Event', 'wordcamporg' ), 'field_yesno', false, + __( "Archived events are read-only.", 'wordcamporg' ) + ); + break; + default: + do_action( 'camptix_menu_setup_controls', $section ); + break; + } + } + + function menu_setup_section_beta() { + echo '

' . __( 'Beta features are things that are being worked on in CampTix, but are not quite finished yet. You can try them out, but we do not recommend doing that in a live environment on a real event. If you have any kind of feedback on any of the beta features, please let us know.', 'wordcamporg' ) . '

'; + } + + function menu_setup_section_email_templates() { + ?> + +

+ +

+ +

+ + +

+ +

+ + + ' . __( 'General configuration.', 'wordcamporg' ) . '

'; + } +} + +new Camptix_Admin; \ No newline at end of file From 807733d84dfdd785f4cda1ab66468937fe81d3f6 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 12:13:16 +0000 Subject: [PATCH 02/15] phpcs --- .../camptix/inc/class-camptix-admin.php | 86 +++++++++++-------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 7c3287470e..ab38f12130 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -2,22 +2,28 @@ class Camptix_Admin extends CampTix_Plugin { + /** + * Fired as soon as this file is loaded, don't do anything + * but filters and actions here. + */ public function __construct() { add_action( 'init', array( $this, 'init' ) ); } + /** + * runs on init action. + */ public function init() { add_action( 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'admin_head', array( $this, 'admin_menu_fix' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); - } /** * Oh the holy admin menu! */ - function admin_menu() { + public function admin_menu() { add_submenu_page( 'edit.php?post_type=tix_ticket', __( 'Tools', 'wordcamporg' ), __( 'Tools', 'wordcamporg' ), $this->caps['manage_tools'], 'camptix_tools', array( $this, 'menu_tools' ) ); add_submenu_page( 'edit.php?post_type=tix_ticket', __( 'Setup', 'wordcamporg' ), __( 'Setup', 'wordcamporg' ), $this->caps['manage_options'], 'camptix_options', array( $this, 'menu_setup' ) ); add_submenu_page( 'edit.php?post_type=tix_ticket', __( 'Badges', 'wordcamporg' ), __( 'Badges', 'wordcamporg' ), $this->caps['manage_options'], 'camptix_badges', array( $this, 'menu_badges' ) ); @@ -31,26 +37,29 @@ function admin_menu() { * This function runs during admin_head and hacks into some of the global variables that are * used to construct the menu. */ - function admin_menu_fix() { + public function admin_menu_fix() { global $self, $parent_file, $submenu_file, $plugin_page, $pagenow, $typenow; - // Make sure Coupons is selected when adding a new coupon - if ( 'post-new.php' == $pagenow && 'tix_coupon' == $typenow ) + // Make sure Coupons is selected when adding a new coupon. + if ( 'post-new.php' == $pagenow && 'tix_coupon' == $typenow ) { $submenu_file = 'edit.php?post_type=tix_coupon'; + } - // Make sure Attendees is selected when adding a new attendee - if ( 'post-new.php' == $pagenow && 'tix_attendee' == $typenow ) + // Make sure Attendees is selected when adding a new attendee. + if ( 'post-new.php' == $pagenow && 'tix_attendee' == $typenow ) { $submenu_file = 'edit.php?post_type=tix_attendee'; + } - // Make sure Tickets is selected when creating a new ticket - if ( 'post-new.php' == $pagenow && 'tix_ticket' == $typenow ) + // Make sure Tickets is selected when creating a new ticket. + if ( 'post-new.php' == $pagenow && 'tix_ticket' == $typenow ) { $submenu_file = 'edit.php?post_type=tix_ticket'; + } } /** * The Tickets > Setup screen, uses the Settings API. */ - function menu_setup() { + public function menu_setup() { ?>

@@ -73,7 +82,7 @@ function menu_setup() { /** * Tabs for Tickets > Tools, outputs the markup. */ - function menu_setup_tabs() { + public function menu_setup_tabs() { $current_section = $this->get_setup_section(); $sections = array( 'general' => __( 'General', 'wordcamporg' ), @@ -81,8 +90,9 @@ function menu_setup_tabs() { 'email-templates' => __( 'E-mail Templates', 'wordcamporg' ), ); - if ( $this->beta_features_enabled ) + if ( $this->beta_features_enabled ) { $sections['beta'] = __( 'Beta', 'wordcamporg' ); + } $sections = apply_filters( 'camptix_setup_sections', $sections ); @@ -96,7 +106,7 @@ function menu_setup_tabs() { /** * The Tickets > Tools screen, doesn't use the settings API, but does use tabs. */ - function menu_tools() { + public function menu_tools() { ?>

@@ -125,9 +135,10 @@ function menu_tools() { * Remember the tabs in Tickets > Tools? This tells * us which tab is currently active. */ - function get_setup_section() { - if ( isset( $_REQUEST['tix_section'] ) ) + public function get_setup_section() { + if ( isset( $_REQUEST['tix_section'] ) ) { return strtolower( $_REQUEST['tix_section'] ); + } return 'general'; } @@ -136,9 +147,10 @@ function get_setup_section() { * Remember the tabs in Tickets > Tools? This tells * us which tab is currently active. */ - function get_tools_section() { - if ( isset( $_REQUEST['tix_section'] ) ) + public function get_tools_section() { + if ( isset( $_REQUEST['tix_section'] ) ) { return strtolower( $_REQUEST['tix_section'] ); + } return 'summarize'; } @@ -146,7 +158,7 @@ function get_tools_section() { /** * Tabs for Tickets > Tools, outputs the markup. */ - function menu_tools_tabs() { + public function menu_tools_tabs() { $current_section = $this->get_tools_section(); $sections = apply_filters( 'camptix_menu_tools_tabs', array( 'summarize' => __( 'Summarize', 'wordcamporg' ), @@ -155,8 +167,9 @@ function menu_tools_tabs() { 'notify' => __( 'Notify', 'wordcamporg' ), ) ); - if ( current_user_can( $this->caps['refund_all'] ) && ! $this->options['archived'] && $this->options['refund_all_enabled'] ) + if ( current_user_can( $this->caps['refund_all'] ) && ! $this->options['archived'] && $this->options['refund_all_enabled'] ) { $sections['refund'] = __( 'Refund', 'wordcamporg' ); + } foreach ( $sections as $section_key => $section_caption ) { $active = $current_section === $section_key ? 'nav-tab-active' : ''; @@ -172,7 +185,7 @@ function menu_tools_tabs() { * the Settings API so check for nonces/referrers and caps. * @see summarize_admin_init() */ - function menu_tools_summarize() { + public function menu_tools_summarize() { $summarize_by = isset( $_POST['tix_summarize_by'] ) ? $_POST['tix_summarize_by'] : 'ticket'; ?>
@@ -212,12 +225,12 @@ function menu_tools_summarize() { $alt = ''; $rows = array(); - foreach ( $summary as $entry ) + foreach ( $summary as $entry ) { $rows[] = array( - esc_html( $summary_title ) => esc_html( $entry['label'] ), + esc_html( $summary_title ) => esc_html( $entry['label'] ), __( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ) ); - + } // Render the widefat table. $this->table( $rows, 'widefat tix-summarize' ); ?> @@ -231,9 +244,10 @@ function menu_tools_summarize() { * Summarize export. Serves the download file. * @see menu_tools_summarize() */ - function summarize_admin_init() { - if ( ! current_user_can( $this->caps['manage_tools'] ) || 'summarize' != $this->get_tools_section() ) + public function summarize_admin_init() { + if ( ! current_user_can( $this->caps['manage_tools'] ) || 'summarize' != $this->get_tools_section() ) { return; + } if ( isset( $_POST['tix_export_summary'], $_POST['tix_summarize_by'] ) && check_admin_referer( 'tix_summarize' ) ) { $summarize_by = $_POST['tix_summarize_by']; @@ -268,10 +282,11 @@ function summarize_admin_init() { * Helper function to create admin tables, give me a * $rows array and I'll do the rest. */ - function table( $rows, $classes='widefat' ) { + public function table( $rows, $classes='widefat' ) { - if ( ! is_array( $rows ) || ! isset( $rows[0] ) ) + if ( ! is_array( $rows ) || ! isset( $rows[0] ) ) { return; + } $alt = ''; ?> @@ -307,7 +322,7 @@ function table( $rows, $classes='widefat' ) { query_vars ) { // only on singular admin pages @@ -363,7 +378,7 @@ function admin_enqueue_scripts() { /** * Runs during admin_init, mainly for Settings API things. */ - function admin_init() { + public function admin_init() { register_setting( 'camptix_options', 'camptix_options', array( $this, 'validate_options' ) ); // Add settings fields @@ -373,7 +388,7 @@ function admin_init() { require_once dirname( __FILE__ ) . '/help.php'; } - function menu_setup_controls() { + public function menu_setup_controls() { wp_enqueue_script( 'jquery-ui' ); $section = $this->get_setup_section(); @@ -422,9 +437,10 @@ function menu_setup_controls() { break; case 'beta': - if ( ! $this->beta_features_enabled ) + if ( ! $this->beta_features_enabled ) { break; - + } + add_settings_section( 'general', __( 'Beta Features', 'wordcamporg' ), array( $this, 'menu_setup_section_beta' ), 'camptix_options' ); $this->add_settings_field_helper( 'reservations_enabled', __( 'Enable Reservations', 'wordcamporg' ), 'field_yesno', false, @@ -447,11 +463,11 @@ function menu_setup_controls() { } } - function menu_setup_section_beta() { + public function menu_setup_section_beta() { echo '

' . __( 'Beta features are things that are being worked on in CampTix, but are not quite finished yet. You can try them out, but we do not recommend doing that in a live environment on a real event. If you have any kind of feedback on any of the beta features, please let us know.', 'wordcamporg' ) . '

'; } - function menu_setup_section_email_templates() { + public function menu_setup_section_email_templates() { ?>

@@ -472,7 +488,7 @@ function menu_setup_section_email_templates() { ' . __( 'General configuration.', 'wordcamporg' ) . '

'; } } From 1724ff7d3758bf6db33a64aa57baafd1c2e4eac7 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 12:18:20 +0000 Subject: [PATCH 03/15] phpcs --- .../plugins/camptix/inc/class-camptix-admin.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index ab38f12130..122391af6a 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -114,18 +114,19 @@ public function menu_tools() { get_tools_section(); - if ( $section == 'summarize' ) + if ( 'summarize' == $section ) { $this->menu_tools_summarize(); - elseif ( $section == 'revenue' ) + } elseif ( 'revenue' == $section ) { $this->menu_tools_revenue(); - elseif ( $section == 'export' ) + } elseif ( 'export' == $section ) { $this->menu_tools_export(); - elseif ( $section == 'notify' ) + } elseif ( 'notify' == $section ) { $this->menu_tools_notify(); - elseif ( $section == 'refund' && ! $this->options['archived'] ) + } elseif ( 'refund' == $section && ! $this->options['archived'] ) { $this->menu_tools_refund(); - else + } else { do_action( 'camptix_menu_tools_' . $section ); + } ?>
beta_features_enabled ) { break; } - + add_settings_section( 'general', __( 'Beta Features', 'wordcamporg' ), array( $this, 'menu_setup_section_beta' ), 'camptix_options' ); $this->add_settings_field_helper( 'reservations_enabled', __( 'Enable Reservations', 'wordcamporg' ), 'field_yesno', false, From 5c4639a28f25862672b707c55b79fd1e553cf178 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 14:11:13 +0000 Subject: [PATCH 04/15] more phpcs --- .../camptix/inc/class-camptix-admin.php | 90 ++++++++++++------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 122391af6a..11522e2f6d 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -169,7 +169,7 @@ public function menu_tools_tabs() { ) ); if ( current_user_can( $this->caps['refund_all'] ) && ! $this->options['archived'] && $this->options['refund_all_enabled'] ) { - $sections['refund'] = __( 'Refund', 'wordcamporg' ); + $sections['refund'] = esc_html__( 'Refund', 'wordcamporg' ); } foreach ( $sections as $section_key => $section_caption ) { @@ -229,7 +229,7 @@ public function menu_tools_summarize() { foreach ( $summary as $entry ) { $rows[] = array( esc_html( $summary_title ) => esc_html( $entry['label'] ), - __( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ) + esc_html__( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ) ); } // Render the widefat table. @@ -323,15 +323,18 @@ public function table( $rows, $classes='widefat' ) { query_vars ) { // only on singular admin pages + if ( ! $wp_query->query_vars ) { // only on singular admin pages. if ( 'tix_ticket' == get_post_type() || 'tix_coupon' == get_post_type() ) { } } - // Let's see whether to include admin.css and admin.js + // Let's see whether to include admin.css and admin.js. if ( is_admin() ) { $screen = get_current_screen(); $post_types = array( 'tix_ticket', 'tix_coupon', 'tix_email', 'tix_attendee' ); @@ -382,13 +385,16 @@ public function admin_enqueue_scripts() { public function admin_init() { register_setting( 'camptix_options', 'camptix_options', array( $this, 'validate_options' ) ); - // Add settings fields + // Add settings fields. $this->menu_setup_controls(); // Let's add some help tabs. require_once dirname( __FILE__ ) . '/help.php'; } + /** + * Menu Setup general section. + */ public function menu_setup_controls() { wp_enqueue_script( 'jquery-ui' ); $section = $this->get_setup_section(); @@ -402,7 +408,7 @@ public function menu_setup_controls() { $this->add_settings_field_helper( 'currency', __( 'Currency', 'wordcamporg' ), 'field_currency' ); $this->add_settings_field_helper( 'refunds_enabled', __( 'Enable Refunds', 'wordcamporg' ), 'field_enable_refunds', false, - __( "This will allows your customers to refund their tickets purchase by filling out a simple refund form.", 'wordcamporg' ) + esc_html__( "This will allows your customers to refund their tickets purchase by filling out a simple refund form.", 'wordcamporg' ) ); break; @@ -411,51 +417,66 @@ public function menu_setup_controls() { $payment_method_obj = $this->get_payment_method_by_id( $key ); add_settings_section( 'payment_' . $key, $payment_method_obj->name, array( $payment_method_obj, '_camptix_settings_section_callback' ), 'camptix_options' ); - add_settings_field( 'payment_method_' . $key . '_enabled', __( 'Enabled', 'wordcamporg' ), array( $payment_method_obj, '_camptix_settings_enabled_callback' ), 'camptix_options', 'payment_' . $key, array( - 'name' => "camptix_options[payment_methods][{$key}]", - 'value' => isset( $this->options['payment_methods'][$key] ) ? (bool) $this->options['payment_methods'][ $key ] : false, - ) ); + add_settings_field( + 'payment_method_' . $key . '_enabled', + __( 'Enabled', 'wordcamporg' ), + array( $payment_method_obj, '_camptix_settings_enabled_callback' ), + 'camptix_options', 'payment_' . $key, array( + 'name' => "camptix_options[payment_methods][{$key}]", + 'value' => isset( $this->options[ 'payment_methods' ][$key] ) ? (bool) $this->options[ 'payment_methods' ][ $key ] : false, + ) + ); $payment_method_obj->payment_settings_fields(); } break; case 'email-templates': add_settings_section( 'general', __( 'E-mail Templates', 'wordcamporg' ), array( $this, 'menu_setup_section_email_templates' ), 'camptix_options' ); - $this->add_settings_field_helper( 'email_template_single_purchase', __( 'Single purchase', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_multiple_purchase', __( 'Multiple purchase', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_multiple_purchase_receipt', __( 'Multiple purchase (receipt)', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_pending_succeeded', __( 'Pending Payment Succeeded', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_pending_failed', __( 'Pending Payment Failed', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_single_refund', __( 'Single Refund', 'wordcamporg' ), 'field_textarea' ); - $this->add_settings_field_helper( 'email_template_multiple_refund', __( 'Multiple Refund', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_single_purchase', esc_html__( 'Single purchase', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_multiple_purchase', esc_html__( 'Multiple purchase', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_multiple_purchase_receipt', esc_html__( 'Multiple purchase (receipt)', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_pending_succeeded', esc_html__( 'Pending Payment Succeeded', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_pending_failed', esc_html__( 'Pending Payment Failed', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_single_refund', esc_html__( 'Single Refund', 'wordcamporg' ), 'field_textarea' ); + $this->add_settings_field_helper( 'email_template_multiple_refund', esc_html__( 'Multiple Refund', 'wordcamporg' ), 'field_textarea' ); foreach ( apply_filters( 'camptix_custom_email_templates', array() ) as $key => $template ) { $this->add_settings_field_helper( $key, $template['title'], $template['callback_method'] ); } - // Add a reset templates button + // Add a reset templates button. add_action( 'camptix_setup_buttons', array( $this, 'setup_buttons_reset_templates' ) ); break; case 'beta': - if ( ! $this->beta_features_enabled ) { break; } - add_settings_section( 'general', __( 'Beta Features', 'wordcamporg' ), array( $this, 'menu_setup_section_beta' ), 'camptix_options' ); + add_settings_section( 'general', esc_html__( 'Beta Features', 'wordcamporg' ), array( $this, 'menu_setup_section_beta' ), 'camptix_options' ); - $this->add_settings_field_helper( 'reservations_enabled', __( 'Enable Reservations', 'wordcamporg' ), 'field_yesno', false, - __( "Reservations is a way to make sure that a certain group of people, can always purchase their tickets, even if you sell out fast.", 'wordcamporg' ) + $this->add_settings_field_helper( + 'reservations_enabled', + esc_html__( 'Enable Reservations', 'wordcamporg' ), + 'field_yesno', + false, + esc_html__( 'Reservations is a way to make sure that a certain group of people, can always purchase their tickets, even if you sell out fast.', 'wordcamporg' ) ); if ( current_user_can( $this->caps['refund_all'] ) ) { - $this->add_settings_field_helper( 'refund_all_enabled', __( 'Enable Refund All', 'wordcamporg' ), 'field_yesno', false, - __( "Allows to refund all purchased tickets by an admin via the Tools menu.", 'wordcamporg' ) + $this->add_settings_field_helper( + 'refund_all_enabled', + esc_html__( 'Enable Refund All', 'wordcamporg' ), + 'field_yesno', false, + esc_html__( 'Allows to refund all purchased tickets by an admin via the Tools menu.', 'wordcamporg' ) ); } - $this->add_settings_field_helper( 'archived', __( 'Archived Event', 'wordcamporg' ), 'field_yesno', false, - __( "Archived events are read-only.", 'wordcamporg' ) + $this->add_settings_field_helper( + 'archived', + esc_html__( 'Archived Event', 'wordcamporg' ), + 'field_yesno', + false, + esc_html__( 'Archived events are read-only.', 'wordcamporg' ) ); break; default: @@ -464,17 +485,23 @@ public function menu_setup_controls() { } } + /** + * Menu Setup Beta section. + */ public function menu_setup_section_beta() { - echo '

' . __( 'Beta features are things that are being worked on in CampTix, but are not quite finished yet. You can try them out, but we do not recommend doing that in a live environment on a real event. If you have any kind of feedback on any of the beta features, please let us know.', 'wordcamporg' ) . '

'; + echo '

' . esc_html__( 'Beta features are things that are being worked on in CampTix, but are not quite finished yet. You can try them out, but we do not recommend doing that in a live environment on a real event. If you have any kind of feedback on any of the beta features, please let us know.', 'wordcamporg' ) . '

'; } + /** + * Menu Setup Email template section. + */ public function menu_setup_section_email_templates() { ?>

- +

@@ -489,9 +516,12 @@ public function menu_setup_section_email_templates() { ' . __( 'General configuration.', 'wordcamporg' ) . '

'; + echo '

' . esc_html__( 'General configuration.', 'wordcamporg' ) . '

'; } } -new Camptix_Admin; \ No newline at end of file +new Camptix_Admin(); \ No newline at end of file From c717403c9b508964da41c0b5779aeb7d8607a2ee Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 14:25:58 +0000 Subject: [PATCH 05/15] phpcs --- .../plugins/camptix/inc/class-camptix-admin.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 11522e2f6d..28e97d42a0 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -11,7 +11,7 @@ public function __construct() { } /** - * runs on init action. + * Runs on init action. */ public function init() { add_action( 'admin_menu', array( $this, 'admin_menu' ) ); @@ -42,17 +42,17 @@ public function admin_menu_fix() { // Make sure Coupons is selected when adding a new coupon. if ( 'post-new.php' == $pagenow && 'tix_coupon' == $typenow ) { - $submenu_file = 'edit.php?post_type=tix_coupon'; + add_filter( 'submenu_file', function () { return 'edit.php?post_type=tix_coupon'; } ); } // Make sure Attendees is selected when adding a new attendee. if ( 'post-new.php' == $pagenow && 'tix_attendee' == $typenow ) { - $submenu_file = 'edit.php?post_type=tix_attendee'; + add_filter( 'submenu_file', function () { return 'edit.php?post_type=tix_attendee'; } ); } // Make sure Tickets is selected when creating a new ticket. if ( 'post-new.php' == $pagenow && 'tix_ticket' == $typenow ) { - $submenu_file = 'edit.php?post_type=tix_ticket'; + add_filter( 'submenu_file', function () { return 'edit.php?post_type=tix_ticket'; } ); } } @@ -262,11 +262,11 @@ public function summarize_admin_init() { header( 'Content-Type: text/csv' ); header( 'Content-Disposition: attachment; filename="' . $filename . '"' ); - header( "Cache-control: private" ); + header( 'Cache-control: private' ); header( 'Pragma: private' ); - header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); + header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); - $stream = fopen( "php://output", 'w' ); + $stream = fopen( 'php://output', 'w' ); $headers = array( $summary_title, __( 'Count', 'wordcamporg' ) ); fputcsv( $stream, self::esc_csv( $headers ) ); @@ -283,7 +283,7 @@ public function summarize_admin_init() { * Helper function to create admin tables, give me a * $rows array and I'll do the rest. */ - public function table( $rows, $classes='widefat' ) { + public function table( $rows, $classes = 'widefat' ) { if ( ! is_array( $rows ) || ! isset( $rows[0] ) ) { return; From beb4a18bf102ace78704adf090ff72535944e112 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 14:49:32 +0000 Subject: [PATCH 06/15] phpcs --- .../camptix/inc/class-camptix-admin.php | 68 ++++++++++++------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 28e97d42a0..c800709053 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -42,17 +42,23 @@ public function admin_menu_fix() { // Make sure Coupons is selected when adding a new coupon. if ( 'post-new.php' == $pagenow && 'tix_coupon' == $typenow ) { - add_filter( 'submenu_file', function () { return 'edit.php?post_type=tix_coupon'; } ); + add_filter( 'submenu_file', function () { + return 'edit.php?post_type=tix_coupon'; + } ); } // Make sure Attendees is selected when adding a new attendee. if ( 'post-new.php' == $pagenow && 'tix_attendee' == $typenow ) { - add_filter( 'submenu_file', function () { return 'edit.php?post_type=tix_attendee'; } ); + add_filter( 'submenu_file', function () { + return 'edit.php?post_type=tix_attendee'; + } ); } // Make sure Tickets is selected when creating a new ticket. if ( 'post-new.php' == $pagenow && 'tix_ticket' == $typenow ) { - add_filter( 'submenu_file', function () { return 'edit.php?post_type=tix_ticket'; } ); + add_filter( 'submenu_file', function () { + return 'edit.php?post_type=tix_ticket'; + } ); } } @@ -62,7 +68,7 @@ public function admin_menu_fix() { public function menu_setup() { ?>
-

+

@@ -109,7 +115,7 @@ public function menu_setup_tabs() { public function menu_tools() { ?>
-

+

menu_tools_summarize(); } elseif ( 'revenue' == $section ) { $this->menu_tools_revenue(); - } elseif ( 'export' == $section ) { + } elseif ( 'export' == $section ) { $this->menu_tools_export(); - } elseif ( 'notify' == $section ) { + } elseif ( 'notify' == $section ) { $this->menu_tools_notify(); } elseif ( 'refund' == $section && ! $this->options['archived'] ) { $this->menu_tools_refund(); @@ -161,12 +167,14 @@ public function get_tools_section() { */ public function menu_tools_tabs() { $current_section = $this->get_tools_section(); - $sections = apply_filters( 'camptix_menu_tools_tabs', array( - 'summarize' => __( 'Summarize', 'wordcamporg' ), - 'revenue' => __( 'Revenue', 'wordcamporg' ), - 'export' => __( 'Export', 'wordcamporg' ), - 'notify' => __( 'Notify', 'wordcamporg' ), - ) ); + $sections = apply_filters( 'camptix_menu_tools_tabs', + array( + 'summarize' => __( 'Summarize', 'wordcamporg' ), + 'revenue' => __( 'Revenue', 'wordcamporg' ), + 'export' => __( 'Export', 'wordcamporg' ), + 'notify' => __( 'Notify', 'wordcamporg' ), + ) + ); if ( current_user_can( $this->caps['refund_all'] ) && ! $this->options['archived'] && $this->options['refund_all_enabled'] ) { $sections['refund'] = esc_html__( 'Refund', 'wordcamporg' ); @@ -184,6 +192,7 @@ public function menu_tools_tabs() { * provides an export option, powered by the summarize_admin_init method, * hooked (almost) at admin_init, because of additional headers. Doesn't use * the Settings API so check for nonces/referrers and caps. + * * @see summarize_admin_init() */ public function menu_tools_summarize() { @@ -193,15 +202,16 @@ public function menu_tools_summarize() { - + - + $value ) : ?>
@@ -339,11 +343,6 @@ public function table( $rows, $classes = 'widefat' ) { public function admin_enqueue_scripts() { global $wp_query; - if ( ! $wp_query->query_vars ) { // only on singular admin pages. - if ( 'tix_ticket' == get_post_type() || 'tix_coupon' == get_post_type() ) { - } - } - // Let's see whether to include admin.css and admin.js. if ( is_admin() ) { $screen = get_current_screen(); @@ -399,7 +398,7 @@ public function admin_init() { $this->menu_setup_controls(); // Let's add some help tabs. - require_once dirname( __FILE__ ) . '/help.php'; + require_once __DIR__ . '/help.php'; } /** @@ -430,7 +429,7 @@ public function menu_setup_controls() { __( 'Enable Refunds', 'wordcamporg' ), 'field_enable_refunds', false, - esc_html__( "This will allows your customers to refund their tickets purchase by filling out a simple refund form.", 'wordcamporg' ) + esc_html__( 'This will allows your customers to refund their tickets purchase by filling out a simple refund form.', 'wordcamporg' ) ); break; @@ -443,9 +442,10 @@ public function menu_setup_controls() { 'payment_method_' . $key . '_enabled', __( 'Enabled', 'wordcamporg' ), array( $payment_method_obj, '_camptix_settings_enabled_callback' ), - 'camptix_options', 'payment_' . $key, array( + 'camptix_options', 'payment_' . $key, + array( 'name' => "camptix_options[payment_methods][{$key}]", - 'value' => isset( $this->options[ 'payment_methods' ][$key] ) ? (bool) $this->options[ 'payment_methods' ][ $key ] : false, + 'value' => isset( $this->options['payment_methods'][$key] ) ? (bool) $this->options['payment_methods'][ $key ] : false, ) ); @@ -477,18 +477,19 @@ public function menu_setup_controls() { add_settings_section( 'general', esc_html__( 'Beta Features', 'wordcamporg' ), array( $this, 'menu_setup_section_beta' ), 'camptix_options' ); $this->add_settings_field_helper( - 'reservations_enabled', - esc_html__( 'Enable Reservations', 'wordcamporg' ), - 'field_yesno', - false, - esc_html__( 'Reservations is a way to make sure that a certain group of people, can always purchase their tickets, even if you sell out fast.', 'wordcamporg' ) + 'reservations_enabled', + esc_html__( 'Enable Reservations', 'wordcamporg' ), + 'field_yesno', + false, + esc_html__( 'Reservations is a way to make sure that a certain group of people, can always purchase their tickets, even if you sell out fast.', 'wordcamporg' ) ); if ( current_user_can( $this->caps['refund_all'] ) ) { $this->add_settings_field_helper( 'refund_all_enabled', esc_html__( 'Enable Refund All', 'wordcamporg' ), - 'field_yesno', false, + 'field_yesno', + false, esc_html__( 'Allows to refund all purchased tickets by an admin via the Tools menu.', 'wordcamporg' ) ); } From 3c757df5ccd9d4dcf74ace68e236238e8992f7a2 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 15:20:11 +0000 Subject: [PATCH 08/15] phpcs --- .../camptix/inc/class-camptix-admin.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 52aca8251c..917eb178c6 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -42,16 +42,20 @@ public function admin_menu_fix() { // Make sure Coupons is selected when adding a new coupon. if ( 'post-new.php' == $pagenow && 'tix_coupon' == $typenow ) { - add_filter( 'submenu_file', function () { - return 'edit.php?post_type=tix_coupon'; - } ); + add_filter( 'submenu_file', + function () { + return 'edit.php?post_type=tix_coupon'; + } + ); } // Make sure Attendees is selected when adding a new attendee. if ( 'post-new.php' == $pagenow && 'tix_attendee' == $typenow ) { - add_filter( 'submenu_file', function () { - return 'edit.php?post_type=tix_attendee'; - } ); + add_filter( 'submenu_file', + function () { + return 'edit.php?post_type=tix_attendee'; + } + ); } // Make sure Tickets is selected when creating a new ticket. @@ -441,11 +445,12 @@ public function menu_setup_controls() { add_settings_field( 'payment_method_' . $key . '_enabled', __( 'Enabled', 'wordcamporg' ), - array( $payment_method_obj, '_camptix_settings_enabled_callback' ), + array( $payment_method_obj, + '_camptix_settings_enabled_callback' ), 'camptix_options', 'payment_' . $key, array( 'name' => "camptix_options[payment_methods][{$key}]", - 'value' => isset( $this->options['payment_methods'][$key] ) ? (bool) $this->options['payment_methods'][ $key ] : false, + 'value' => isset( $this->options['payment_methods'][ $key ] ) ? (bool) $this->options['payment_methods'][ $key ] : false, ) ); From b63e933cfd4cbfe0ee7b60ab97be54bafcdc25a9 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 15:43:58 +0000 Subject: [PATCH 09/15] phpcs --- .../plugins/camptix/inc/class-camptix-admin.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 917eb178c6..f21ca10a21 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -445,9 +445,12 @@ public function menu_setup_controls() { add_settings_field( 'payment_method_' . $key . '_enabled', __( 'Enabled', 'wordcamporg' ), - array( $payment_method_obj, - '_camptix_settings_enabled_callback' ), - 'camptix_options', 'payment_' . $key, + array( + $payment_method_obj, + '_camptix_settings_enabled_callback', + ), + 'camptix_options', + 'payment_' . $key, array( 'name' => "camptix_options[payment_methods][{$key}]", 'value' => isset( $this->options['payment_methods'][ $key ] ) ? (bool) $this->options['payment_methods'][ $key ] : false, From 2997c2df3c97f12da3f905a48fda70ef47d53ec0 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 15:51:15 +0000 Subject: [PATCH 10/15] switch to use wp_verify_nonce --- .../wp-content/plugins/camptix/inc/class-camptix-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index f21ca10a21..0055bc36c2 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -234,7 +234,7 @@ public function menu_tools_summarize() {

- get_available_summary_fields() ) ) : ?> + get_available_summary_fields() ) ) : ?> get_available_summary_fields(); $summary = $this->get_summary( $summarize_by ); From 6fa76e61a94a5ea475e2a7d978f4c2f8df109d08 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 15:55:07 +0000 Subject: [PATCH 11/15] switch order for phpcs --- .../camptix/inc/class-camptix-admin.php | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 0055bc36c2..d2823d9d75 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -203,6 +203,21 @@ public function menu_tools_tabs() { */ public function menu_tools_summarize() { $summarize_by = isset( $_POST['tix_summarize_by'] ) ? $_POST['tix_summarize_by'] : 'ticket'; + if ( isset( $_POST['tix_summarize_submit'] ) && wp_verify_nonce( $_POST['_wp_nonce'], 'tix_summarize' ) && array_key_exists( $summarize_by, $this->get_available_summary_fields() ) ) : + $fields = $this->get_available_summary_fields(); + $summary = $this->get_summary( $summarize_by ); + $summary_title = $fields[ $summarize_by ]; + $alt = ''; + + $rows = array(); + foreach ( $summary as $entry ) { + $rows[] = array( + esc_html( $summary_title ) => esc_html( $entry['label'] ), + esc_html__( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ), + ); + } + // Render the widefat table. + $this->table( $rows, 'widefat tix-summarize' ); ?>
@@ -233,26 +248,6 @@ public function menu_tools_summarize() {

- - get_available_summary_fields() ) ) : ?> - get_available_summary_fields(); - $summary = $this->get_summary( $summarize_by ); - $summary_title = $fields[ $summarize_by ]; - $alt = ''; - - $rows = array(); - foreach ( $summary as $entry ) { - $rows[] = array( - esc_html( $summary_title ) => esc_html( $entry['label'] ), - esc_html__( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ), - ); - } - // Render the widefat table. - $this->table( $rows, 'widefat tix-summarize' ); - ?> - - Date: Wed, 18 Dec 2024 17:03:56 +0000 Subject: [PATCH 12/15] fix error --- .../wp-content/plugins/camptix/inc/class-camptix-admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index d2823d9d75..97d4e64a9f 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -218,6 +218,7 @@ public function menu_tools_summarize() { } // Render the widefat table. $this->table( $rows, 'widefat tix-summarize' ); + endif; ?>
From aa8a4b322088728c7d2a3d3e81f04947c833f4df Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 17:08:32 +0000 Subject: [PATCH 13/15] move nonce check --- .../wp-content/plugins/camptix/inc/class-camptix-admin.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 97d4e64a9f..b65a8563e9 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -202,8 +202,11 @@ public function menu_tools_tabs() { * @see summarize_admin_init() */ public function menu_tools_summarize() { - $summarize_by = isset( $_POST['tix_summarize_by'] ) ? $_POST['tix_summarize_by'] : 'ticket'; - if ( isset( $_POST['tix_summarize_submit'] ) && wp_verify_nonce( $_POST['_wp_nonce'], 'tix_summarize' ) && array_key_exists( $summarize_by, $this->get_available_summary_fields() ) ) : + if ( isset( $_POST['tix_summarize_submit'] ) && wp_verify_nonce( $_POST['_wp_nonce'], 'tix_summarize' ) ) { + $summarize_by = isset( $_POST['tix_summarize_by'] ) ? $_POST['tix_summarize_by'] : 'ticket'; + if ( ! array_key_exists( $summarize_by, $this->get_available_summary_fields() ) ) { + return; + } $fields = $this->get_available_summary_fields(); $summary = $this->get_summary( $summarize_by ); $summary_title = $fields[ $summarize_by ]; From 48f2ac4f330be80ded62b64d0e05031c0d3e31bf Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Wed, 18 Dec 2024 17:12:40 +0000 Subject: [PATCH 14/15] fix --- .../plugins/camptix/inc/class-camptix-admin.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index b65a8563e9..3f4e16f82a 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -207,21 +207,21 @@ public function menu_tools_summarize() { if ( ! array_key_exists( $summarize_by, $this->get_available_summary_fields() ) ) { return; } - $fields = $this->get_available_summary_fields(); - $summary = $this->get_summary( $summarize_by ); + $fields = $this->get_available_summary_fields(); + $summary = $this->get_summary( $summarize_by ); $summary_title = $fields[ $summarize_by ]; - $alt = ''; + $alt = ''; $rows = array(); foreach ( $summary as $entry ) { $rows[] = array( - esc_html( $summary_title ) => esc_html( $entry['label'] ), + esc_html( $summary_title ) => esc_html( $entry['label'] ), esc_html__( 'Count', 'wordcamporg' ) => esc_html( $entry['count'] ), ); } // Render the widefat table. $this->table( $rows, 'widefat tix-summarize' ); - endif; + } ?>
From 3c7c5826cf1c7e8aa140e2519ace12bb12d9b0b8 Mon Sep 17 00:00:00 2001 From: Paul Kevan Date: Thu, 19 Dec 2024 09:26:49 +0000 Subject: [PATCH 15/15] add missing admin_init call --- .../wp-content/plugins/camptix/inc/class-camptix-admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php index 3f4e16f82a..26b8896142 100644 --- a/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php +++ b/public_html/wp-content/plugins/camptix/inc/class-camptix-admin.php @@ -14,6 +14,7 @@ public function __construct() { * Runs on init action. */ public function init() { + add_action( 'admin_init', array( $this, 'admin_init' ) ); add_action( 'admin_menu', array( $this, 'admin_menu' ) ); add_action( 'admin_head', array( $this, 'admin_menu_fix' ) );