From cea36b27ef5b4c515b41c193fed86d63c1903154 Mon Sep 17 00:00:00 2001 From: Iain Date: Sat, 16 Mar 2024 10:42:51 +0000 Subject: [PATCH] PHPCS fixes --- includes/abstracts/class-wpcm-widget.php | 93 +-- .../class-wpcm-admin-dashboard-widgets.php | 40 +- includes/admin/class-wpcm-admin-dashboard.php | 12 +- includes/admin/class-wpcm-admin-editor.php | 11 + .../admin/class-wpcm-admin-extensions.php | 4 +- includes/admin/class-wpcm-admin-help.php | 10 +- includes/admin/class-wpcm-admin-importers.php | 14 +- includes/admin/class-wpcm-admin-menus.php | 14 +- .../admin/class-wpcm-admin-meta-boxes.php | 31 +- includes/admin/class-wpcm-admin-notices.php | 28 +- .../class-wpcm-admin-permalink-settings.php | 11 +- .../admin/class-wpcm-admin-post-types.php | 477 +++++++----- includes/admin/class-wpcm-admin-profile.php | 14 +- includes/admin/class-wpcm-admin-settings.php | 374 ++++----- .../admin/class-wpcm-admin-setup-wizard.php | 137 ++-- .../admin/class-wpcm-admin-taxonomies.php | 242 +++--- includes/admin/class-wpcm-admin.php | 18 +- .../importers/class-wpcm-club-importer.php | 37 +- ...-importers.php => class-wpcm-importer.php} | 137 ++-- .../importers/class-wpcm-match-importer.php | 35 +- .../importers/class-wpcm-player-importer.php | 50 +- .../importers/class-wpcm-staff-importer.php | 34 +- .../class-wpcm-meta-box-club-details.php | 47 +- .../class-wpcm-meta-box-club-parent.php | 27 +- .../class-wpcm-meta-box-club-players.php | 17 +- .../class-wpcm-meta-box-club-staff.php | 17 +- .../class-wpcm-meta-box-club-table.php | 22 +- .../class-wpcm-meta-box-match-details.php | 102 ++- .../class-wpcm-meta-box-match-fixture.php | 46 +- .../class-wpcm-meta-box-match-players.php | 156 ++-- .../class-wpcm-meta-box-match-result.php | 645 ++++++++++------ .../class-wpcm-meta-box-match-video.php | 27 +- .../class-wpcm-meta-box-player-details.php | 76 +- .../class-wpcm-meta-box-player-display.php | 31 +- .../class-wpcm-meta-box-player-roster.php | 24 +- .../class-wpcm-meta-box-player-stats.php | 130 ++-- .../class-wpcm-meta-box-player-users.php | 43 +- .../class-wpcm-meta-box-roster-details.php | 42 +- .../class-wpcm-meta-box-roster-players.php | 33 +- .../class-wpcm-meta-box-roster-staff.php | 34 +- .../class-wpcm-meta-box-sponsor-url.php | 25 +- .../class-wpcm-meta-box-staff-details.php | 66 +- .../class-wpcm-meta-box-staff-roster.php | 26 +- .../class-wpcm-meta-box-table-details.php | 42 +- .../class-wpcm-meta-box-table-notes.php | 16 +- .../class-wpcm-meta-box-table-stats.php | 82 +- .../settings/class-wpcm-settings-clubs.php | 4 + .../settings/class-wpcm-settings-general.php | 12 +- .../settings/class-wpcm-settings-licenses.php | 3 + .../settings/class-wpcm-settings-matches.php | 3 + .../settings/class-wpcm-settings-page.php | 16 +- .../settings/class-wpcm-settings-players.php | 4 + .../settings/class-wpcm-settings-staff.php | 4 + .../class-wpcm-settings-standings.php | 5 +- .../admin/views/html-admin-page-dashboard.php | 190 ++--- .../admin/views/html-admin-page-status.php | 218 +++--- includes/admin/views/html-admin-settings.php | 14 +- includes/admin/views/html-admin-sidebar.php | 13 +- includes/admin/views/html-bulk-edit-match.php | 12 +- .../admin/views/html-notice-club-check.php | 6 +- .../admin/views/html-notice-cricket-addon.php | 8 +- includes/admin/views/html-notice-install.php | 15 +- .../views/html-notice-template-check.php | 6 +- .../admin/views/html-notice-theme-support.php | 10 +- includes/admin/views/html-notice-update.php | 6 +- .../views/html-notice-version-update.php | 36 +- .../admin/views/html-quick-edit-match.php | 40 +- .../admin/views/html-quick-edit-player.php | 14 +- .../admin/views/html-quick-edit-staff.php | 14 +- includes/admin/wpcm-admin-functions.php | 4 +- includes/admin/wpcm-meta-box-functions.php | 6 +- includes/class-wp-club-manager.php | 2 +- includes/class-wpcm-ajax.php | 727 ++++++++++-------- includes/class-wpcm-autoloader.php | 4 + includes/class-wpcm-cache-helper.php | 19 +- includes/class-wpcm-countries.php | 12 +- includes/class-wpcm-frontend-scripts.php | 12 +- includes/class-wpcm-geocoder.php | 25 +- includes/class-wpcm-install.php | 24 +- ...nse-handler.php => class-wpcm-license.php} | 50 +- includes/class-wpcm-post-types.php | 46 +- includes/class-wpcm-shortcodes.php | 20 +- includes/class-wpcm-sports.php | 14 + includes/class-wpcm-taxonomy-order.php | 19 +- includes/class-wpcm-template-loader.php | 3 + .../class-wpcm-shortcode-league-table.php | 4 +- .../class-wpcm-shortcode-map-venue.php | 2 +- .../class-wpcm-shortcode-match-list.php | 4 +- .../class-wpcm-shortcode-match-opponents.php | 67 +- .../class-wpcm-shortcode-player-gallery.php | 4 +- .../class-wpcm-shortcode-player-list.php | 4 +- .../class-wpcm-shortcode-staff-gallery.php | 31 +- .../class-wpcm-shortcode-staff-list.php | 4 +- .../legacy/class-wpcm-shortcode-matches.php | 61 +- .../legacy/class-wpcm-shortcode-players.php | 23 +- .../legacy/class-wpcm-shortcode-staff.php | 25 +- .../legacy/class-wpcm-shortcode-standings.php | 30 +- ...ys.php => class-wpcm-birthdays-widget.php} | 17 +- ...res.php => class-wpcm-fixtures-widget.php} | 35 +- ...yers.php => class-wpcm-players-widget.php} | 7 +- ...ults.php => class-wpcm-results-widget.php} | 29 +- ...ors.php => class-wpcm-sponsors-widget.php} | 14 +- ...gs.php => class-wpcm-standings-widget.php} | 7 +- includes/wpcm-club-functions.php | 25 +- includes/wpcm-conditional-functions.php | 2 +- includes/wpcm-core-functions.php | 57 +- includes/wpcm-deprecated-functions.php | 38 + includes/wpcm-formatting-functions.php | 90 ++- includes/wpcm-match-functions.php | 119 ++- includes/wpcm-player-functions.php | 37 +- includes/wpcm-preset-functions.php | 3 + includes/wpcm-standings-functions.php | 48 +- includes/wpcm-stats-functions.php | 239 +++--- includes/wpcm-template-functions.php | 10 +- includes/wpcm-user-functions.php | 4 +- includes/wpcm-widget-functions.php | 12 +- index.php | 4 +- phpcs.xml.dist | 3 + templates/content-single-club.php | 93 ++- templates/content-single-match.php | 21 +- templates/content-single-player.php | 6 +- templates/content-single-staff.php | 46 +- templates/content-widget-birthdays.php | 32 +- templates/content-widget-fixtures.php | 26 +- templates/content-widget-results.php | 26 +- templates/layout/wrapper-end.php | 1 + templates/shortcodes/league-table.php | 52 +- templates/shortcodes/map-venue.php | 28 +- templates/shortcodes/match-list.php | 32 +- templates/shortcodes/match-opponents.php | 34 +- templates/shortcodes/matches-2.php | 26 +- templates/shortcodes/matches.php | 42 +- templates/shortcodes/players-gallery.php | 24 +- templates/shortcodes/players.php | 18 +- templates/shortcodes/staff-gallery.php | 16 +- templates/shortcodes/staff.php | 24 +- templates/shortcodes/standings.php | 40 +- templates/single-match/attendance.php | 6 +- templates/single-match/away-badge.php | 4 +- templates/single-match/away-club.php | 4 +- templates/single-match/box-scores.php | 94 +-- templates/single-match/comp.php | 4 +- templates/single-match/date.php | 4 +- templates/single-match/home-badge.php | 4 +- templates/single-match/home-club.php | 4 +- templates/single-match/lineup-row.php | 34 +- templates/single-match/lineup.php | 54 +- templates/single-match/referee.php | 6 +- templates/single-match/report.php | 8 +- templates/single-match/score.php | 8 +- templates/single-match/status.php | 8 +- templates/single-match/team.php | 6 +- templates/single-match/venue-info.php | 14 +- templates/single-match/venue.php | 4 +- templates/single-match/video.php | 4 +- templates/single-player/meta.php | 54 +- templates/single-player/player-image.php | 6 +- templates/single-player/stats-table.php | 22 +- templates/single-player/stats.php | 70 +- wpclubmanager.php | 2 +- 160 files changed, 4309 insertions(+), 3000 deletions(-) rename includes/admin/importers/{class-wpcm-importers.php => class-wpcm-importer.php} (59%) rename includes/{class-wpcm-license-handler.php => class-wpcm-license.php} (84%) rename includes/widgets/{class-wpcm-widget-birthdays.php => class-wpcm-birthdays-widget.php} (90%) rename includes/widgets/{class-wpcm-widget-fixtures.php => class-wpcm-fixtures-widget.php} (89%) rename includes/widgets/{class-wpcm-widget-players.php => class-wpcm-players-widget.php} (97%) rename includes/widgets/{class-wpcm-widget-results.php => class-wpcm-results-widget.php} (89%) rename includes/widgets/{class-wpcm-widget-sponsors.php => class-wpcm-sponsors-widget.php} (90%) rename includes/widgets/{class-wpcm-widget-standings.php => class-wpcm-standings-widget.php} (96%) diff --git a/includes/abstracts/class-wpcm-widget.php b/includes/abstracts/class-wpcm-widget.php index 886ea76..c8334c5 100644 --- a/includes/abstracts/class-wpcm-widget.php +++ b/includes/abstracts/class-wpcm-widget.php @@ -71,7 +71,7 @@ public function get_cached_widget( $args ) { } if ( isset( $cache[ $args['widget_id'] ] ) ) { - echo $cache[ $args['widget_id'] ]; + echo $cache[ $args['widget_id'] ]; // phpcs:ignore return true; } @@ -97,7 +97,9 @@ public function cache_widget( $args, $content ) { * Flush the cache */ public function flush_widget_cache() { - wp_cache_delete( apply_filters( 'wpclubmanager_cached_widget_id', $this->widget_id ), 'widget' ); + if ( $this->widget_id ) { + wp_cache_delete( apply_filters( 'wpclubmanager_cached_widget_id', $this->widget_id ), 'widget' ); + } } /** @@ -107,12 +109,12 @@ public function flush_widget_cache() { * @param array $instance */ public function widget_start( $args, $instance ) { - echo $args['before_widget']; + echo $args['before_widget']; // phpcs:ignore $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); if ( $title ) { - echo $args['before_title'] . $title . $args['after_title']; + echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore } } @@ -122,7 +124,7 @@ public function widget_start( $args, $instance ) { * @param array $args */ public function widget_end( $args ) { - echo $args['after_widget']; + echo $args['after_widget']; // phpcs:ignore } /** @@ -168,6 +170,7 @@ public function update( $new_instance, $old_instance ): array { $new_instance[ $key ] = implode( ',', $new_instance[ $key ] ); } $instance[ $key ] = strip_tags( $new_instance[ $key ] ); + break; case 'standings_columns': if ( is_array( $new_instance[ $key ] ) ) { $new_instance[ $key ] = implode( ',', $new_instance[ $key ] ); @@ -212,27 +215,27 @@ public function form( $instance ) { case 'text': ?>

- + + name="get_field_name( $key ) ); ?>" type="text" + value=""/>

- - + +

- + /> - + name="get_field_name( $key ) ); ?>" type="checkbox" + value="1" /> +

+ for="get_field_id( $key ) ); ?>"> @@ -339,7 +342,7 @@ public function form( $instance ) { case 'player_stats': $stats_labels = wpcm_get_player_all_names(); - $stats = explode( ',', $value ); + $stats = explode( ',', $value ); ?>
@@ -347,7 +350,7 @@ public function form( $instance ) { $option_value ) { - ++ $count; + ++$count; if ( $count > 2 ) { $count = 1; echo ''; @@ -355,12 +358,12 @@ public function form( $instance ) { ?> @@ -375,13 +378,13 @@ public function form( $instance ) { ?>
+ for="get_field_id( $key ) ); ?>"> @@ -391,7 +394,7 @@ public function form( $instance ) { case 'standings_columns': $column_labels = wpcm_get_preset_labels( 'standings', 'label' ); - $columns = explode( ',', $value ); + $columns = explode( ',', $value ); ?>
@@ -399,7 +402,7 @@ public function form( $instance ) { $option_value ) { - ++ $count; + ++$count; if ( $count > 4 ) { $count = 1; echo ''; @@ -407,9 +410,9 @@ public function form( $instance ) { ?> @@ -434,12 +437,12 @@ public function form( $instance ) { } ?>
- +
@@ -448,7 +451,7 @@ public function form( $instance ) { case 'section_heading': ?> -

+

labels->singular_name, '%s ' . $post_type->labels->name, $num_posts->publish, 'wp-club-manager' ); + $text = _n( '%s ' . $post_type->labels->singular_name, '%s ' . $post_type->labels->name, $num_posts->publish, 'wp-club-manager' ); // phpcs:ignore $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); @@ -82,8 +84,8 @@ public function upcoming_matches_widget() { $club = get_default_club(); $format = get_match_title_format(); - $year = date( 'Y' ); - $week = date( 'W' ); + $year = gmdate( 'Y' ); + $week = gmdate( 'W' ); // get matches $query_args = array( @@ -116,7 +118,7 @@ public function upcoming_matches_widget() { $matches = get_posts( $query_args ); ?>
    - + ID, 'wpcm_comp_status', true ); $separator = get_option( 'wpcm_match_clubs_separator' ); - if ( $format == '%home% vs %away%' ) { + if ( '%home% vs %away%' === $format ) { $side1 = $home_club; $side2 = $away_club; } else { @@ -156,12 +158,12 @@ public function upcoming_matches_widget() {
  • - + - + - + - + - +
  • -
  • +
  • - + name; $team_slug = $term->slug; @@ -309,7 +309,7 @@ public static function output() { ); $clubs = get_posts( $args ); - $size = sizeof( $clubs ); + $size = count( $clubs ); foreach ( $clubs as $club ) { @@ -325,7 +325,7 @@ public static function output() { usort( $clubs, 'wpcm_sort_table_clubs' ); - if ( $order == 'ASC' ) { + if ( 'ASC' === $order ) { $clubs = array_reverse( $clubs ); } foreach ( $clubs as $key => $value ) { @@ -350,4 +350,4 @@ public static function output() {
    plugin_path() . '/assets/js/admin/editor-lang.php'; return $arr; diff --git a/includes/admin/class-wpcm-admin-extensions.php b/includes/admin/class-wpcm-admin-extensions.php index f907b9f..6047612 100644 --- a/includes/admin/class-wpcm-admin-extensions.php +++ b/includes/admin/class-wpcm-admin-extensions.php @@ -21,8 +21,8 @@ class WPCM_Admin_Extensions { * Handles output of the reports page in admin. */ public static function output() { - - if ( false === ( $extensions = get_transient( 'wpclubmanager_extensions_data' ) ) ) { + $extensions = get_transient( 'wpclubmanager_extensions_data' ); + if ( false === $extensions ) { $extensions_json = wp_remote_get( 'http://d3dglxqx43ixhm.cloudfront.net/wpclubmanager-extensions.json', array( 'user-agent' => 'WP Club Manager Extensions Page' ) ); if ( ! is_wp_error( $extensions_json ) ) { $extensions = json_decode( wp_remote_retrieve_body( $extensions_json ) ); diff --git a/includes/admin/class-wpcm-admin-help.php b/includes/admin/class-wpcm-admin-help.php index 0122bd4..d702033 100644 --- a/includes/admin/class-wpcm-admin-help.php +++ b/includes/admin/class-wpcm-admin-help.php @@ -42,17 +42,19 @@ public function add_tabs() { 'content' => '

    ' . __( 'Help & Support', 'wp-club-manager' ) . '

    ' . '

    ' . sprintf( + /* translators: 1: docs link 2: end anchor */ __( 'Should you need help understanding, using, or extending WP Club Manager, %1$splease read our documentation%2$s. You will find all kinds of resources including snippets, tutorials and much more.', 'wp-club-manager' ), '', '' ) . '

    ' . '

    ' . sprintf( + /* translators: 1: community forum link 2: end anchor */ __( 'For further assistance with WP Club Manager core you can use the %1$scommunity forum%2$s.', 'wp-club-manager' ), '', '' ) . '

    ' . '

    ' . __( 'Before asking for help we recommend checking the system status page to identify any problems with your configuration.', 'wp-club-manager' ) . '

    ' . - '

    ' . __( 'System Status', 'wp-club-manager' ) . ' ' . __( 'Community Forum', 'wp-club-manager' ) . '

    ', + '

    ' . __( 'System Status', 'wp-club-manager' ) . ' ' . __( 'Community Forum', 'wp-club-manager' ) . '

    ', ) ); $screen->add_help_tab( array( @@ -67,9 +69,9 @@ public function add_tabs() { $screen->set_help_sidebar( '

    ' . __( 'For more information:', 'wp-club-manager' ) . '

    ' . - '

    ' . __( 'WP Club Manager Homepage', 'wp-club-manager' ) . '

    ' . - '

    ' . __( 'WordPress.org Project', 'wp-club-manager' ) . '

    ' . - '

    ' . __( 'Official Themes', 'wp-club-manager' ) . '

    ' + '

    ' . __( 'WP Club Manager Homepage', 'wp-club-manager' ) . '

    ' . + '

    ' . __( 'WordPress.org Project', 'wp-club-manager' ) . '

    ' . + '

    ' . __( 'Official Themes', 'wp-club-manager' ) . '

    ' ); } } diff --git a/includes/admin/class-wpcm-admin-importers.php b/includes/admin/class-wpcm-admin-importers.php index c2387bc..46a8c28 100644 --- a/includes/admin/class-wpcm-admin-importers.php +++ b/includes/admin/class-wpcm-admin-importers.php @@ -50,6 +50,9 @@ public function player_importer() { $importer->dispatch(); } + /** + * @return void + */ public function staff_importer() { $this->includes(); @@ -61,6 +64,9 @@ public function staff_importer() { $importer->dispatch(); } + /** + * @return void + */ public function club_importer() { $this->includes(); @@ -72,6 +78,9 @@ public function club_importer() { $importer->dispatch(); } + /** + * @return void + */ public function match_importer() { $this->includes(); @@ -83,6 +92,9 @@ public function match_importer() { $importer->dispatch(); } + /** + * @return void + */ public static function includes() { // Load Importer API require_once ABSPATH . 'wp-admin/includes/import.php'; @@ -95,7 +107,7 @@ public static function includes() { } // includes - require 'importers/class-wpcm-importers.php'; + require 'importers/class-wpcm-importer.php'; } } diff --git a/includes/admin/class-wpcm-admin-menus.php b/includes/admin/class-wpcm-admin-menus.php index c36e8ce..f7feabd 100644 --- a/includes/admin/class-wpcm-admin-menus.php +++ b/includes/admin/class-wpcm-admin-menus.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Admin_Menus' ) ) : + /** + * WPCM_Admin_Menus + */ class WPCM_Admin_Menus { /** @@ -37,7 +40,7 @@ public function admin_menu() { global $menu; if ( current_user_can( 'manage_wpclubmanager' ) ) { - $menu[] = array( '', 'read', 'separator-wpclubmanager', '', 'wp-menu-separator wpclubmanager' ); + $menu[] = array( '', 'read', 'separator-wpclubmanager', '', 'wp-menu-separator wpclubmanager' ); // phpcs:ignore } $main_page = add_menu_page( __( 'Club Manager', 'wp-club-manager' ), __( 'Club Manager', 'wp-club-manager' ), 'manage_wpclubmanager', 'wpcm-dashboard', array( $this, 'dashboard_page' ), WPCM()->plugin_url() . '/assets/images/logo.png', '31' ); @@ -130,20 +133,19 @@ public function menu_highlight() { switch ( $post_type ) { case 'wpcm_roster': - // $parent_file = 'edit.php?post_type=wpcm_player'; - $parent_file = 'wpcm-dashboard'; + $parent_file = 'wpcm-dashboard'; // phpcs:ignore break; } switch ( $submenu_file ) { case 'edit-tags.php?taxonomy=wpcm_season&post_type=wpcm_club': - $parent_file = 'wpcm-dashboard'; + $parent_file = 'wpcm-dashboard'; // phpcs:ignore break; case 'edit-tags.php?taxonomy=wpcm_comp&post_type=wpcm_club': - $parent_file = 'wpcm-dashboard'; + $parent_file = 'wpcm-dashboard'; // phpcs:ignore break; case 'edit-tags.php?taxonomy=wpcm_team&post_type=wpcm_player': - $parent_file = 'wpcm-dashboard'; + $parent_file = 'wpcm-dashboard'; // phpcs:ignore break; } } diff --git a/includes/admin/class-wpcm-admin-meta-boxes.php b/includes/admin/class-wpcm-admin-meta-boxes.php index 97805e5..1b0a22c 100644 --- a/includes/admin/class-wpcm-admin-meta-boxes.php +++ b/includes/admin/class-wpcm-admin-meta-boxes.php @@ -14,8 +14,14 @@ exit; // Exit if accessed directly } +/** + * WPCM_Admin_Meta_Boxes + */ class WPCM_Admin_Meta_Boxes { + /** + * @var array + */ private static $meta_box_errors = array(); /** @@ -108,6 +114,9 @@ public function output_errors() { /** * Venue taxonomy meta box callback + * + * @param WP_Post $post + * @param array $box */ public function venue_meta_box_cb( $post, $box ) { @@ -132,7 +141,7 @@ public function add_meta_boxes() { 'tinymce' => array( 'resize' => false ), ) ); }, 'wpcm_club', 'normal', 'high' ); - if ( is_league_mode() && $post->post_status == 'publish' ) { + if ( is_league_mode() && 'publish' === $post->post_status ) { add_meta_box( 'wpclubmanager-club-players', __( 'Players', 'wp-club-manager' ), 'WPCM_Meta_Box_Club_Players::output', 'wpcm_club', 'normal', 'high' ); add_meta_box( 'wpclubmanager-club-staff', __( 'Staff', 'wp-club-manager' ), 'WPCM_Meta_Box_Club_Staff::output', 'wpcm_club', 'normal', 'high' ); } @@ -177,7 +186,7 @@ public function add_meta_boxes() { 'tinymce' => array( 'resize' => false ), ) ); }, 'wpcm_player', 'normal', 'high' ); - if ( $post->post_status == 'publish' ) { + if ( 'publish' === $post->post_status ) { add_meta_box( 'wpclubmanager-player-stats', __( 'Player Statistics', 'wp-club-manager' ), 'WPCM_Meta_Box_Player_Stats::output', 'wpcm_player', 'normal', 'high' ); add_meta_box( 'wpclubmanager-player-users', __( 'Link Player to User', 'wp-club-manager' ), 'WPCM_Meta_Box_Player_Users::output', 'wpcm_player', 'normal', 'high' ); } @@ -200,7 +209,7 @@ public function add_meta_boxes() { add_meta_box( 'wpclubmanager-staff-roster', __( 'Add to Staff Roster', 'wp-club-manager' ), 'WPCM_Meta_Box_Staff_Roster::output', 'wpcm_staff', 'side' ); } - if ( $post->post_status == 'publish' ) { + if ( 'publish' === $post->post_status ) { add_meta_box( 'wpclubmanager-table-stats', __( 'Manage League Table', 'wp-club-manager' ), 'WPCM_Meta_Box_Table_Stats::output', 'wpcm_table', 'normal', 'high' ); add_meta_box( 'wpclubmanager-table-notes', __( 'Notes', 'wp-club-manager' ), 'WPCM_Meta_Box_Table_Notes::output', 'wpcm_table', 'normal', 'low' ); add_meta_box( 'wpclubmanager-table-details', __( 'League Table Setup', 'wp-club-manager' ), 'WPCM_Meta_Box_Table_Details::output', 'wpcm_table', 'side' ); @@ -208,7 +217,7 @@ public function add_meta_boxes() { add_meta_box( 'wpclubmanager-table-details', __( 'League Table Setup', 'wp-club-manager' ), 'WPCM_Meta_Box_Table_Details::output', 'wpcm_table', 'normal', 'low' ); } - if ( $post->post_status == 'publish' ) { + if ( 'publish' === $post->post_status ) { add_meta_box( 'wpclubmanager-roster-players', __( 'Manage Players Roster', 'wp-club-manager' ), 'WPCM_Meta_Box_Roster_Players::output', 'wpcm_roster', 'normal', 'high' ); add_meta_box( 'wpclubmanager-roster-staff', __( 'Manage Staff Roster', 'wp-club-manager' ), 'WPCM_Meta_Box_Roster_Staff::output', 'wpcm_roster', 'normal', 'high' ); add_meta_box( 'wpclubmanager-roster-details', __( 'Roster Setup', 'wp-club-manager' ), 'WPCM_Meta_Box_Roster_Details::output', 'wpcm_roster', 'side' ); @@ -261,7 +270,8 @@ public function save_meta_boxes( $post_id, $post ) { if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { return; } - if ( empty( $_POST['wpclubmanager_meta_nonce'] ) || ! wp_verify_nonce( $_POST['wpclubmanager_meta_nonce'], 'wpclubmanager_save_data' ) ) { + $nonce = filter_input( INPUT_POST, 'wpclubmanager_meta_nonce', FILTER_UNSAFE_RAW ); + if ( empty( $nonce ) || ! wp_verify_nonce( sanitize_text_field( $nonce ), 'wpclubmanager_save_data' ) ) { return; } if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { @@ -270,7 +280,16 @@ public function save_meta_boxes( $post_id, $post ) { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } - if ( $post->post_type != 'wpcm_club' && $post->post_type != 'wpcm_player' && $post->post_type != 'wpcm_match' && $post->post_type != 'wpcm_staff' && $post->post_type != 'wpcm_sponsor' && $post->post_type != 'wpcm_table' && $post->post_type != 'wpcm_roster' ) { + + if ( ! in_array( $post->post_type, array( + 'wpcm_club', + 'wpcm_player', + 'wpcm_match', + 'wpcm_staff', + 'wpcm_sponsor', + 'wpcm_table', + 'wpcm_roster', + ) ) ) { return; } diff --git a/includes/admin/class-wpcm-admin-notices.php b/includes/admin/class-wpcm-admin-notices.php index e8e3d07..464f4c4 100644 --- a/includes/admin/class-wpcm-admin-notices.php +++ b/includes/admin/class-wpcm-admin-notices.php @@ -70,6 +70,8 @@ public function reset_admin_notices() { /** * Add notices + styles if needed. + * + * @param string $name */ public static function add_notice( $name ) { @@ -103,17 +105,19 @@ public static function has_notice( $name ) { * Hide a notice if the GET variable is set. */ public function hide_notices() { + $hide_notice = filter_input( INPUT_GET, 'wpcm-hide-notice', FILTER_UNSAFE_RAW ); + $nonce = filter_input( INPUT_GET, '_wpcm_notice_nonce', FILTER_UNSAFE_RAW ); - if ( isset( $_GET['wpcm-hide-notice'] ) && isset( $_GET['_wpcm_notice_nonce'] ) ) { - if ( ! wp_verify_nonce( $_GET['_wpcm_notice_nonce'], 'wpclubmanager_hide_notices_nonce' ) ) { - wp_die( __( 'Action failed. Please refresh the page and retry.', 'wp-club-manager' ) ); + if ( isset( $hide_notice ) && isset( $nonce ) ) { + if ( ! wp_verify_nonce( sanitize_text_field( $nonce ), 'wpclubmanager_hide_notices_nonce' ) ) { + wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wp-club-manager' ) ); } if ( ! current_user_can( 'manage_wpclubmanager' ) ) { - wp_die( __( 'Cheatin’ huh?', 'wp-club-manager' ) ); + wp_die( esc_html__( 'Cheatin’ huh?', 'wp-club-manager' ) ); } - $hide_notice = sanitize_text_field( $_GET['wpcm-hide-notice'] ); + $hide_notice = sanitize_text_field( $hide_notice ); self::remove_notice( $hide_notice ); do_action( 'wpclubmanager_hide_' . $hide_notice . '_notice' ); } @@ -258,14 +262,9 @@ public function template_file_check_notice() { } } - // public function club_check_notice() { - - // if( get_option( 'wpcm_default_club' ) == "" ) { - - // include( 'views/html-notice-club-check.php' ); - // } - // } - + /** + * @return void + */ public function cricket_addon_notice() { if ( get_option( 'wpcm_sport' ) == 'cricket' && ! in_array( 'wpcm-cricket/wpcm-cricket.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { @@ -276,6 +275,9 @@ public function cricket_addon_notice() { } } + /** + * @return void + */ public function version_update_notice() { if ( get_option( 'wpcm_version_upgraded_from' ) && version_compare( get_option( 'wpcm_version_upgraded_from' ), '2.0.0', '<' ) ) { diff --git a/includes/admin/class-wpcm-admin-permalink-settings.php b/includes/admin/class-wpcm-admin-permalink-settings.php index be811ea..1e3eea6 100644 --- a/includes/admin/class-wpcm-admin-permalink-settings.php +++ b/includes/admin/class-wpcm-admin-permalink-settings.php @@ -60,7 +60,7 @@ public function slug_input() { $slug = array_shift( $this->slugs ); $key = $slug[0]; $text = get_option( 'wpclubmanager_' . $key . '_slug', null ); - ?>
    + ?>
    not using "Plain" permalinks above.', 'wp-club-manager' ) ); + echo esc_html( wpautop( __( 'These settings control the permalinks used for WP Club Manager. These settings only apply when not using "Plain" permalinks above.', 'wp-club-manager' ) ) ); } /** @@ -95,14 +95,11 @@ public function settings_save() { foreach ( $this->slugs as $slug ) { $key = 'wpclubmanager_' . $slug[0] . '_slug'; - $value = null; - if ( isset( $_POST[ $key ] ) ) { - $value = sanitize_text_field( $_POST[ $key ] ); - } + $value = filter_input( INPUT_POST, $key, FILTER_UNSAFE_RAW ); if ( empty( $value ) ) { delete_option( $key ); } else { - update_option( $key, $value ); + update_option( $key, sanitize_text_field( $value ) ); } } diff --git a/includes/admin/class-wpcm-admin-post-types.php b/includes/admin/class-wpcm-admin-post-types.php index 92ad691..991c4b0 100644 --- a/includes/admin/class-wpcm-admin-post-types.php +++ b/includes/admin/class-wpcm-admin-post-types.php @@ -67,10 +67,6 @@ public function __construct() { // Disable post type view mode options add_filter( 'view_mode_post_types', array( $this, 'disable_view_mode_options' ) ); - // if( $typenow == 'wpcm_player' ) { - // add_filter('months_dropdown_results', '__return_empty_array'); - // } - include_once 'class-wpcm-admin-meta-boxes.php'; } @@ -85,58 +81,82 @@ public function post_updated_messages( $messages ) { $messages['wpcm_player'] = array( 0 => '', // Unused. Messages start at index 1. + /* translators: 1: preview url */ 1 => sprintf( __( 'Player updated. View Player', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 2 => __( 'Custom field updated.', 'wp-club-manager' ), 3 => __( 'Custom field deleted.', 'wp-club-manager' ), 4 => __( 'Player updated.', 'wp-club-manager' ), + /* translators: 1: revision title */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Player restored to revision from %s', 'wp-club-manager' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: 1: preview url */ 6 => sprintf( __( 'Player published. View Player', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 7 => __( 'Player saved.', 'wp-club-manager' ), + /* translators: 1: preview url */ 8 => sprintf( __( 'Player submitted. Preview Player', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + /* translators: 1: date 2: preview url */ 9 => sprintf( __( 'Player scheduled for: %1$s. Preview Player', 'wp-club-manager' ), date_i18n( __( 'M j, Y @ G:i', 'wp-club-manager' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), + /* translators: 1: preview url */ 10 => sprintf( __( 'Player draft updated. Preview Player', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), ); $messages['wpcm_staff'] = array( 0 => '', // Unused. Messages start at index 1. + /* translators: 1: preview url */ 1 => sprintf( __( 'Staff updated. View Staff', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 2 => __( 'Custom field updated.', 'wp-club-manager' ), 3 => __( 'Custom field deleted.', 'wp-club-manager' ), 4 => __( 'Staff updated.', 'wp-club-manager' ), + /* translators: 1: revision title */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Staff restored to revision from %s', 'wp-club-manager' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: 1: preview url */ 6 => sprintf( __( 'Staff published. View Staff', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 7 => __( 'Staff saved.', 'wp-club-manager' ), + /* translators: 1: preview url */ 8 => sprintf( __( 'Staff submitted. Preview Staff', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + /* translators: 1: date 2: preview url */ 9 => sprintf( __( 'Staff scheduled for: %1$s. Preview Staff', 'wp-club-manager' ), date_i18n( __( 'M j, Y @ G:i', 'wp-club-manager' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), + /* translators: 1: preview url */ 10 => sprintf( __( 'Staff draft updated. Preview Staff', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), ); $messages['wpcm_match'] = array( 0 => '', // Unused. Messages start at index 1. + /* translators: 1: preview url */ 1 => sprintf( __( 'Match updated. View Match', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 2 => __( 'Custom field updated.', 'wp-club-manager' ), 3 => __( 'Custom field deleted.', 'wp-club-manager' ), 4 => __( 'Match updated.', 'wp-club-manager' ), + /* translators: 1: revision title */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Match restored to revision from %s', 'wp-club-manager' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: 1: preview url */ 6 => sprintf( __( 'Match published. View Match', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 7 => __( 'Match saved.', 'wp-club-manager' ), + /* translators: 1: preview url */ 8 => sprintf( __( 'Match submitted. Preview Match', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + /* translators: 1: date 2: preview url */ 9 => sprintf( __( 'Match scheduled for: %1$s. Preview Match', 'wp-club-manager' ), date_i18n( __( 'M j, Y @ G:i', 'wp-club-manager' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), + /* translators: 1: preview url */ 10 => sprintf( __( 'Match draft updated. Preview Match', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), ); $messages['wpcm_club'] = array( 0 => '', // Unused. Messages start at index 1. + /* translators: 1: preview url */ 1 => sprintf( __( 'Club updated. View Club', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 2 => __( 'Custom field updated.', 'wp-club-manager' ), 3 => __( 'Custom field deleted.', 'wp-club-manager' ), 4 => __( 'Club updated.', 'wp-club-manager' ), + /* translators: 1: revision title */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Club restored to revision from %s', 'wp-club-manager' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: 1: preview url */ 6 => sprintf( __( 'Club published. View Club', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 7 => __( 'Club saved.', 'wp-club-manager' ), + /* translators: 1: preview url */ 8 => sprintf( __( 'Club submitted. Preview Club', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + /* translators: 1: date 2: preview url */ 9 => sprintf( __( 'Club scheduled for: %1$s. Preview Club', 'wp-club-manager' ), date_i18n( __( 'M j, Y @ G:i', 'wp-club-manager' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), + /* translators: 1: preview url */ 10 => sprintf( __( 'Club draft updated. Preview Club', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), ); $messages['wpcm_sponsor'] = array( @@ -145,77 +165,106 @@ public function post_updated_messages( $messages ) { 2 => __( 'Custom field updated.', 'wp-club-manager' ), 3 => __( 'Custom field deleted.', 'wp-club-manager' ), 4 => __( 'Sponsor updated.', 'wp-club-manager' ), + /* translators: 1: revision title */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Sponsor restored to revision from %s', 'wp-club-manager' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => __( 'Sponsor published.', 'wp-club-manager' ), 7 => __( 'Sponsor saved.', 'wp-club-manager' ), 8 => __( 'Sponsor submitted.', 'wp-club-manager' ), + /* translators: 1: preview url */ 9 => sprintf( __( 'Sponsor scheduled for: %1$s.', 'wp-club-manager' ), date_i18n( __( 'M j, Y @ G:i', 'wp-club-manager' ), strtotime( $post->post_date ) ) ), 10 => __( 'Sponsor draft updated.', 'wp-club-manager' ), ); $messages['wpcm_roster'] = array( 0 => '', // Unused. Messages start at index 1. + /* translators: 1: preview url */ 1 => sprintf( __( 'Roster updated. View Roster', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 2 => __( 'Custom field updated.', 'wp-club-manager' ), 3 => __( 'Custom field deleted.', 'wp-club-manager' ), 4 => __( 'Roster updated.', 'wp-club-manager' ), + /* translators: 1: revision title */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Roster restored to revision from %s', 'wp-club-manager' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: 1: preview url */ 6 => sprintf( __( 'Roster published. View Roster', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 7 => __( 'Roster saved.', 'wp-club-manager' ), + /* translators: 1: preview url */ 8 => sprintf( __( 'Roster submitted. Preview Roster', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + /* translators: 1: date 2: preview url */ 9 => sprintf( __( 'Roster scheduled for: %1$s. Preview Roster', 'wp-club-manager' ), date_i18n( __( 'M j, Y @ G:i', 'wp-club-manager' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), + /* translators: 1: preview url */ 10 => sprintf( __( 'Roster draft updated. Preview Roster', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), ); $messages['wpcm_table'] = array( 0 => '', // Unused. Messages start at index 1. + /* translators: 1: preview url */ 1 => sprintf( __( 'League Table updated. View League Table', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 2 => __( 'Custom field updated.', 'wp-club-manager' ), 3 => __( 'Custom field deleted.', 'wp-club-manager' ), 4 => __( 'League Table updated.', 'wp-club-manager' ), + /* translators: 1: revision title */ 5 => isset( $_GET['revision'] ) ? sprintf( __( 'League Table restored to revision from %s', 'wp-club-manager' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, + /* translators: 1: preview url */ 6 => sprintf( __( 'League Table published. View League Table', 'wp-club-manager' ), esc_url( get_permalink( $post_ID ) ) ), 7 => __( 'League Table saved.', 'wp-club-manager' ), + /* translators: 1: preview url */ 8 => sprintf( __( 'League Table submitted. Preview League Table', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), + /* translators: 1: date 2: preview url */ 9 => sprintf( __( 'League Table scheduled for: %1$s. Preview League Table', 'wp-club-manager' ), date_i18n( __( 'M j, Y @ G:i', 'wp-club-manager' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ) ), + /* translators: 1: preview url */ 10 => sprintf( __( 'League Table draft updated. Preview League Table', 'wp-club-manager' ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ), ); return $messages; } - // show future + /** + * Show future + * + * @param array $posts + * + * @return array + */ public function show_scheduled_matches( $posts ) { global $wp_query, $wpdb; - if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['wpcm_match'] ) ) { - $posts = $wpdb->get_results( $wp_query->request ); + if ( is_single() && 0 == $wp_query->post_count && isset( $wp_query->query_vars['wpcm_match'] ) ) { + $posts = $wpdb->get_results( $wp_query->request ); // phpcs:ignore } return $posts; } - // Insert post title data + /** + * Insert post title data + * + * @param array $data + * @param array $postarr + * + * @return array + */ public function wp_insert_post_data( $data, $postarr ) { - if ( $data['post_type'] == 'wpcm_match' ) : + if ( 'wpcm_match' == $data['post_type'] ) : $separator = get_option( 'wpcm_match_clubs_separator' ); - if ( $data['post_title'] == '' || $data['post_title'] == ' ' . $separator . ' ' || $data['post_name'] == 'importing' ) { + if ( '' == $data['post_title'] || ' ' . $separator . ' ' == $data['post_title'] || 'importing' == $data['post_name'] ) { // $default_club = get_default_club(); $title_format = get_match_title_format(); // $separator = get_option('wpcm_match_clubs_separator'); $home_id = ''; - if ( isset( $_POST['wpcm_home_club'] ) ) { - $home_id = $_POST['wpcm_home_club']; + $home_club = filter_input( INPUT_POST, 'wpcm_home_club', FILTER_VALIDATE_INT ); + if ( $home_club ) { + $home_id = $home_club; } $away_id = ''; - if ( isset( $_POST['wpcm_away_club'] ) ) { - $away_id = $_POST['wpcm_away_club']; + $away_club = filter_input( INPUT_POST, 'wpcm_away_club', FILTER_VALIDATE_INT ); + if ( $away_club ) { + $away_id = $away_club; } $home_club = get_post( $home_id ); $away_club = get_post( $away_id ); @@ -227,7 +276,7 @@ public function wp_insert_post_data( $data, $postarr ) { $home_club = $home_club->post_name; $away_club = $away_club->post_name; } - if ( $title_format == '%home% vs %away%' ) { + if ( '%home% vs %away%' == $title_format ) { $side1 = $home_club; $side2 = $away_club; } else { @@ -242,9 +291,11 @@ public function wp_insert_post_data( $data, $postarr ) { $data['post_name'] = $post_name; } - if ( isset( $_POST['wpcm_match_date'] ) && isset( $_POST['wpcm_match_kickoff'] ) ) { - $date = $_POST['wpcm_match_date']; - $kickoff = $_POST['wpcm_match_kickoff']; + $kickoff = filter_input( INPUT_POST, 'wpcm_match_kickoff', FILTER_UNSAFE_RAW ); + $date = filter_input( INPUT_POST, 'wpcm_match_date', FILTER_UNSAFE_RAW ); + if ( $kickoff && $date ) { + $date = sanitize_text_field( $date ); + $kickoff = sanitize_text_field( $kickoff ); $datetime = $date . ' ' . $kickoff . ':00'; $datetime_gmt = get_gmt_from_date( $datetime ); @@ -258,37 +309,41 @@ public function wp_insert_post_data( $data, $postarr ) { endif; - if ( $data['post_type'] == 'wpcm_player' ) : + if ( 'wpcm_player' == $data['post_type'] ) : - if ( isset( $_POST['_wpcm_firstname'] ) ) { - $firstname = $_POST['_wpcm_firstname']; + $firstname = filter_input( INPUT_POST, '_wpcm_firstname', FILTER_UNSAFE_RAW ); + if ( $firstname ) { + $first_name = sanitize_text_field( $firstname ); } else { - $firstname = ''; + $first_name = ''; } - if ( isset( $_POST['_wpcm_lastname'] ) ) { - $lastname = $_POST['_wpcm_lastname']; + $lastname = filter_input( INPUT_POST, '_wpcm_lastname', FILTER_UNSAFE_RAW ); + if ( $lastname ) { + $last_name = sanitize_text_field( $lastname ); } else { - $lastname = ''; + $last_name = ''; } - if ( isset( $_POST['_wpcm_firstname'] ) || isset( $_POST['_wpcm_lastname'] ) ) { - $title = sanitize_title_with_dashes( $firstname . '-' . $lastname ); + if ( $firstname || $lastname ) { + $title = sanitize_title_with_dashes( $first_name . '-' . $last_name ); - $data['post_title'] = $firstname . ' ' . $lastname; + $data['post_title'] = $first_name . ' ' . $last_name; $data['post_name'] = $title; } endif; - if ( $data['post_type'] == 'wpcm_staff' ) : + if ( 'wpcm_staff' == $data['post_type'] ) : $firstname = ''; - if ( isset( $_POST['_wpcm_firstname'] ) ) { - $firstname = $_POST['_wpcm_firstname']; + $first_name = filter_input( INPUT_POST, '_wpcm_firstname', FILTER_UNSAFE_RAW ); + if ( $first_name ) { + $firstname = sanitize_text_field( $first_name ); } $lastname = ''; - if ( isset( $_POST['_wpcm_lastname'] ) ) { - $lastname = $_POST['_wpcm_lastname']; + $last_name = filter_input( INPUT_POST, '_wpcm_lastname', FILTER_UNSAFE_RAW ); + if ( $last_name ) { + $lastname = sanitize_text_field( $last_name ); } $title = sanitize_title_with_dashes( $firstname . '-' . $lastname ); @@ -359,7 +414,8 @@ public function club_columns( $existing_columns ) { /** * Define custom columns for players. * - * @param array $existing_columns + * @param array $existing_columns + * * @return array */ public function player_columns( $existing_columns ) { @@ -394,7 +450,8 @@ public function player_columns( $existing_columns ) { /** * Define custom columns for players. * - * @param array $existing_columns + * @param array $existing_columns + * * @return array */ public function staff_columns( $existing_columns ) { @@ -432,7 +489,8 @@ public function staff_columns( $existing_columns ) { /** * Define custom columns for rosters. * - * @param array $existing_columns + * @param array $columns + * * @return array */ public function roster_columns( $columns ) { @@ -454,7 +512,8 @@ public function roster_columns( $columns ) { /** * Define custom columns for tables. * - * @param array $existing_columns + * @param array $columns + * * @return array */ public function table_columns( $columns ) { @@ -498,12 +557,12 @@ public function render_match_columns( $column ) { echo ''; if ( $post->post_parent > 0 ) { - echo '  ← ' . get_the_title( $post->post_parent ) . ''; + echo '  ← ' . esc_html( get_the_title( $post->post_parent ) ) . ''; } // Excerpt view if ( isset( $_GET['mode'] ) && 'excerpt' == $_GET['mode'] ) { - echo apply_filters( 'the_excerpt', $post->post_excerpt ); + echo esc_html( apply_filters( 'the_excerpt', $post->post_excerpt ) ); } // $this->_render_match_row_actions( $post, $title ); @@ -544,18 +603,18 @@ public function render_match_columns( $column ) { ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); /* Custom inline data for wpclubmanager. */ echo ' -
$field ) : @@ -77,7 +77,7 @@ public function add_user_meta_fields( $user ) { + $val ) : if ( get_option( 'wpcm_show_stats_' . $key ) == 'yes' ) : ?> - + - + $val ) : if ( get_option( 'wpcm_show_stats_' . $key ) == 'yes' ) : ?> - + - + $val ) : if ( get_option( 'wpcm_show_stats_' . $key ) == 'yes' ) : ?> - + prefix . 'usermeta'; $meta_key = $wpdb->prefix . 'capabilities'; - $query = "SELECT count(*) - FROM $table_name - WHERE user_id=$user_id AND meta_key='$meta_key' AND meta_value like '%administrator%'"; - $has_admin_role = $wpdb->get_var( $query ); + $has_admin_role = $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM {$wpdb->prefix}usermeta WHERE user_id=%d AND meta_key=%s AND meta_value like %s", $user_id, $meta_key, '%administrator%' ) ); if ( $has_admin_role > 0 ) { $result = true; } else { @@ -50,23 +46,25 @@ public static function has_administrator_role( $user_id ) { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { wp_nonce_field( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ); - if ( $post->post_status == 'publish' ) { + if ( 'publish' === $post->post_status ) { do_action( 'wpclubmanager_before_admin_player_user_meta', $post->ID ); $user = get_post_meta( $post->ID, '_wpcm_link_users', true ); $user_data = get_userdata( $user ); - $edit_link = ( isset( $user ) && ! empty( $user ) ? '' . __( 'Edit user', 'wp-club-manager' ) . '' : '' ); ?> + $edit_link = ( isset( $user ) && ! empty( $user ) ? '' . esc_html__( 'Edit user', 'wp-club-manager' ) . '' : '' ); ?> -

+

- + __( 'None', 'wp-club-manager' ), @@ -78,10 +76,10 @@ public static function output( $post ) { wp_dropdown_users( $args ); ?> - +

- -

+ +

- +

- + 'wpcm_season', @@ -53,7 +58,7 @@ public static function output( $post ) { ?>

- + 'wpcm_team', @@ -68,7 +73,7 @@ public static function output( $post ) { ?>

- + 'roster_players_import', @@ -82,7 +87,7 @@ public static function output( $post ) { ?>

- + 'roster_staff_import', @@ -102,19 +107,29 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['wpcm_roster_season'] ) ) { - wp_set_post_terms( $post_id, $_POST['wpcm_roster_season'], 'wpcm_season' ); + $season_id = filter_input( INPUT_POST, 'wpcm_roster_season', FILTER_VALIDATE_INT ); + if ( $season_id ) { + wp_set_post_terms( $post_id, $season_id, 'wpcm_season' ); } - if ( isset( $_POST['wpcm_roster_team'] ) ) { - wp_set_post_terms( $post_id, $_POST['wpcm_roster_team'], 'wpcm_team' ); + + $team_id = filter_input( INPUT_POST, 'wpcm_roster_team', FILTER_VALIDATE_INT ); + if ( $team_id ) { + wp_set_post_terms( $post_id, $team_id, 'wpcm_team' ); } - if ( isset( $_POST['roster_players_import'] ) ) { + $player_team_import_id = filter_input( INPUT_POST, 'roster_players_import', FILTER_VALIDATE_INT ); + if ( $player_team_import_id ) { - $players = (array) unserialize( get_post_meta( $_POST['roster_players_import'], '_wpcm_roster_players', true ) ); + $players = (array) unserialize( get_post_meta( $player_team_import_id, '_wpcm_roster_players', true ) ); update_post_meta( $post_id, '_wpcm_roster_players', serialize( $players ) ); @@ -131,9 +146,10 @@ public static function save( $post_id, $post ) { } } + $staff_team_import_id = filter_input( INPUT_POST, 'roster_staff_import', FILTER_VALIDATE_INT ); if ( isset( $_POST['roster_staff_import'] ) ) { - $employees = (array) unserialize( get_post_meta( $_POST['roster_staff_import'], '_wpcm_roster_staff', true ) ); + $employees = (array) unserialize( get_post_meta( $staff_team_import_id, '_wpcm_roster_staff', true ) ); update_post_meta( $post_id, '_wpcm_roster_staff', serialize( $employees ) ); @@ -152,4 +168,4 @@ public static function save( $post_id, $post ) { do_action( 'delete_plugin_transients' ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-players.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-players.php index 685a7c2..cbdec9d 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-players.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-players.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Roster_Players + */ class WPCM_Meta_Box_Roster_Players { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -68,12 +73,12 @@ public static function output( $post ) {

- ID, $key, true ) ); foreach ( $field['options'] as $option_key => $option_value ) : @@ -86,7 +86,7 @@ public function add_user_meta_fields( $user ) { - +
@@ -111,9 +111,9 @@ public function save_user_meta_fields( $user_id ) { foreach ( $save_fields as $fieldset ) { foreach ( $fieldset['fields'] as $key => $field ) { - - if ( isset( $_POST[ $key ] ) ) { - update_user_meta( $user_id, $key, wpcm_clean( $_POST[ $key ] ) ); + $field_value = filter_input( INPUT_POST, $key, FILTER_UNSAFE_RAW ); + if ( isset( $field_value ) ) { + update_user_meta( $user_id, $key, wpcm_clean( $field_value ) ); } } } @@ -122,4 +122,4 @@ public function save_user_meta_fields( $user_id ) { endif; -return new WPCM_Admin_Profile(); \ No newline at end of file +return new WPCM_Admin_Profile(); diff --git a/includes/admin/class-wpcm-admin-settings.php b/includes/admin/class-wpcm-admin-settings.php index abf3460..4fb4aae 100644 --- a/includes/admin/class-wpcm-admin-settings.php +++ b/includes/admin/class-wpcm-admin-settings.php @@ -14,10 +14,22 @@ if ( ! class_exists( 'WPCM_Admin_Settings' ) ) : + /** + * WPCM_Admin_Settings + */ class WPCM_Admin_Settings { + /** + * @var array + */ private static $settings = array(); + /** + * @var array + */ private static $errors = array(); + /** + * @var array + */ private static $messages = array(); /** @@ -51,8 +63,9 @@ public static function get_settings_pages() { public static function save() { global $current_section, $current_tab; - if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'wpclubmanager-settings' ) ) { - die( __( 'Action failed. Please refresh the page and retry.', 'wp-club-manager' ) ); + $nonce = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); + if ( empty( $nonce ) || ! wp_verify_nonce( sanitize_text_field( $nonce ), 'wpclubmanager-settings' ) ) { + die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wp-club-manager' ) ); } // Trigger actions @@ -87,11 +100,11 @@ public static function add_error( $text ) { * Output messages + errors */ public static function show_messages() { - if ( sizeof( self::$errors ) > 0 ) { + if ( count( self::$errors ) > 0 ) { foreach ( self::$errors as $error ) { echo '

' . esc_html( $error ) . '

'; } - } elseif ( sizeof( self::$messages ) > 0 ) { + } elseif ( count( self::$messages ) > 0 ) { foreach ( self::$messages as $message ) { echo '

' . esc_html( $message ) . '

'; } @@ -123,20 +136,23 @@ public static function output() { self::get_settings_pages(); // Get current tab - $current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_title( $_GET['tab'] ); + $tab = filter_input( INPUT_GET, 'tab', FILTER_UNSAFE_RAW ); + $current_tab = empty( $tab ) ? 'general' : sanitize_title( $tab ); // Save settings if data has been posted - if ( ! empty( $_POST ) ) { + if ( ! empty( $_POST ) ) { // phpcs:ignore self::save(); } // Add any posted messages - if ( ! empty( $_GET['wpcm_error'] ) ) { - self::add_error( stripslashes( $_GET['wpcm_error'] ) ); + $error = filter_input( INPUT_GET, 'wpcm_message', FILTER_UNSAFE_RAW ); + if ( $error ) { + self::add_error( wp_kses_post( stripslashes( $error ) ) ); } - if ( ! empty( $_GET['wpcm_message'] ) ) { - self::add_message( stripslashes( $_GET['wpcm_message'] ) ); + $message = filter_input( INPUT_GET, 'wpcm_message', FILTER_UNSAFE_RAW ); + if ( $message ) { + self::add_message( wp_kses_post( stripslashes( $message ) ) ); } self::show_messages(); @@ -150,7 +166,9 @@ public static function output() { /** * Get a setting from the settings API. * - * @param mixed $option + * @param string $option_name + * @param string $default + * * @return string */ public static function get_option( $option_name, $default = '' ) { @@ -184,11 +202,11 @@ public static function get_option( $option_name, $default = '' ) { $option_value = stripslashes( $option_value ); } - return $option_value === null ? $default : $option_value; + return null === $option_value ? $default : $option_value; } /** - * Output admin fields. + * Output admin fields * * Loops though the wpclubmanager options array and outputs each field. * @@ -258,7 +276,7 @@ public static function output_fields( $options ) { echo '

' . esc_html( $value['title'] ) . '

'; } if ( ! empty( $value['desc'] ) ) { - echo wpautop( wptexturize( wp_kses_post( $value['desc'] ) ) ); + echo wp_kses_post( wpautop( wptexturize( $value['desc'] ) ) ); } echo '' . "\n\n"; if ( ! empty( $value['id'] ) ) { @@ -290,9 +308,9 @@ public static function output_fields( $options ) { - " - @@ -341,29 +359,23 @@ class="" - - - " if ( ! isset( $value['show_if_checked'] ) ) { $value['show_if_checked'] = false; } - if ( $value['hide_if_checked'] == 'yes' || $value['show_if_checked'] == 'yes' ) { + if ( 'yes' == $value['hide_if_checked'] || 'yes' == $value['show_if_checked'] ) { $visbility_class[] = 'hidden_option'; } - if ( $value['hide_if_checked'] == 'option' ) { + if ( 'option' == $value['hide_if_checked'] ) { $visbility_class[] = 'hide_options_if_checked'; } - if ( $value['show_if_checked'] == 'option' ) { + if ( 'option' == $value['show_if_checked'] ) { $visbility_class[] = 'show_options_if_checked'; } @@ -447,46 +459,46 @@ class="" - + - " - $value['id'], @@ -526,13 +538,13 @@ class="" - $value['id'], @@ -553,13 +565,13 @@ class="" - countries->countries; @@ -575,12 +587,12 @@ class="" - - - + - $stats = wpcm_get_preset_labels( 'standings' ); $stats_names = wpcm_get_preset_labels( 'standings', 'name' ); ?> - + - - - - - + - - " - - - - + - - " - - - " - - - " * @return bool */ public static function save_fields( $options ) { - if ( empty( $_POST ) ) { + $nonce = filter_input( INPUT_POST, '_wpnonce', FILTER_UNSAFE_RAW ); + + if ( empty( $nonce ) ) { return false; } @@ -852,7 +866,8 @@ public static function save_fields( $options ) { // Standard types case 'checkbox': - if ( isset( $_POST[ $value['id'] ] ) ) { + $checkbox = filter_input( INPUT_POST, $value['id'], FILTER_UNSAFE_RAW ); + if ( $checkbox ) { $option_value = 'yes'; } else { $option_value = 'no'; @@ -861,8 +876,9 @@ public static function save_fields( $options ) { break; case 'textarea': - if ( isset( $_POST[ $value['id'] ] ) ) { - $option_value = wp_kses_post( trim( stripslashes( $_POST[ $value['id'] ] ) ) ); + $textarea = filter_input( INPUT_POST, $value['id'], FILTER_UNSAFE_RAW ); + if ( $textarea ) { + $option_value = wp_kses_post( trim( stripslashes( $textarea ) ) ); } else { $option_value = ''; } @@ -880,13 +896,14 @@ public static function save_fields( $options ) { case 'single_select_country': case 'radio': case 'license_key': - case 'osm_radio'; + case 'osm_radio': case 'osm_text': case 'gmap_radio': case 'gmap_text': case 'map_zoom': - if ( isset( $_POST[ $value['id'] ] ) ) { - $option_value = wpcm_clean( stripslashes( $_POST[ $value['id'] ] ) ); + $zoom = filter_input( INPUT_POST, $value['id'], FILTER_UNSAFE_RAW ); + if ( $zoom ) { + $option_value = wpcm_clean( stripslashes( sanitize_text_field( $zoom ) ) ); } else { $option_value = ''; } @@ -896,17 +913,20 @@ public static function save_fields( $options ) { // Special types case 'multiselect': case 'standings_columns': - $option_value = wpcm_clean( stripslashes( $_POST[ $value['id'] ] ) ); + $standings_columns = filter_input( INPUT_POST, $value['id'], FILTER_UNSAFE_RAW ); + $option_value = wpcm_clean( stripslashes( sanitize_text_field( $standings_columns ) ) ); break; case 'image_width': - if ( isset( $_POST[ $value['id'] ]['width'] ) ) { + $size = filter_input( INPUT_POST, $value['id'], FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); - $update_options[ $value['id'] ]['width'] = wpcm_clean( stripslashes( $_POST[ $value['id'] ]['width'] ) ); - $update_options[ $value['id'] ]['height'] = wpcm_clean( stripslashes( $_POST[ $value['id'] ]['height'] ) ); + if ( $size['width'] ) { - if ( isset( $_POST[ $value['id'] ]['crop'] ) ) { + $update_options[ $value['id'] ]['width'] = wpcm_clean( stripslashes( $size['width'] ) ); + $update_options[ $value['id'] ]['height'] = wpcm_clean( stripslashes( $size['height'] ) ); + + if ( isset( $size['crop'] ) ) { $update_options[ $value['id'] ]['crop'] = 1; } else { $update_options[ $value['id'] ]['crop'] = 0; @@ -972,6 +992,9 @@ public static function save_fields( $options ) { * Configure sport * * @access public + * + * @param array $sport + * * @return void */ public static function configure_sport( $sport ) { @@ -980,29 +1003,34 @@ public static function configure_sport( $sport ) { foreach ( $term_groups as $taxonomy => $terms ) : // Find empty terms and destroy - $allterms = get_terms( $taxonomy, 'hide_empty=0' ); + $allterms = get_terms( + array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + ) + ); foreach ( $allterms as $term ) : - if ( $term->count == 0 ) { + if ( 0 == $term->count ) { wp_delete_term( $term->term_id, $taxonomy ); } - endforeach; + endforeach; // Insert terms foreach ( $terms as $term ) : wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) ); + endforeach; endforeach; - endforeach; // Get array of taxonomies to insert $stats_labels = wpcm_array_value( $sport, 'stats_labels' ); foreach ( $stats_labels as $key => $value ) : update_option( 'wpcm_show_stats_' . $key, 'yes' ); - endforeach; + endforeach; update_option( 'wpcm_primary_result', 0 ); } } -endif; \ No newline at end of file +endif; diff --git a/includes/admin/class-wpcm-admin-setup-wizard.php b/includes/admin/class-wpcm-admin-setup-wizard.php index 8da383a..43cba76 100644 --- a/includes/admin/class-wpcm-admin-setup-wizard.php +++ b/includes/admin/class-wpcm-admin-setup-wizard.php @@ -9,6 +9,7 @@ * @package WPClubManager/Admin * @version 2.2.2 */ + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -85,7 +86,8 @@ public function setup_wizard() { wp_register_script( 'wpcm-setup-js', WPCM()->plugin_url() . '/assets/js/admin/wpcm-setup.min.js', array( 'jquery-locationpicker' ) ); - if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { + $step = filter_input( INPUT_POST, 'save_step', FILTER_UNSAFE_RAW ); + if ( $step && isset( $this->steps[ $this->step ]['handler'] ) ) { call_user_func( $this->steps[ $this->step ]['handler'] ); } @@ -97,6 +99,9 @@ public function setup_wizard() { exit; } + /** + * @return string + */ public function get_next_step_link() { $keys = array_keys( $this->steps ); return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] ); @@ -112,7 +117,7 @@ public function setup_wizard_header() { - <?php _e( 'WP Club Manager › Setup Wizard', 'wp-club-manager' ); ?> + <?php esc_html_e( 'WP Club Manager › Setup Wizard', 'wp-club-manager' ); ?> @@ -121,9 +126,9 @@ public function setup_wizard_header() {

- WP Club Manager -
-
+ WP Club Manager +
+

step ) : ?> - +
@@ -186,15 +191,15 @@ public function setup_wizard_content() { */ public function wpcm_setup_introduction() { ?> -

-

-

-

+

+

+

+

- - + + -

+

-

+

- +
- + @@ -237,7 +242,7 @@ public function wpcm_setup_general() { - + @@ -254,15 +259,17 @@ public function wpcm_setup_general_save() { // $plugin_mode = $_POST['plugin_mode']; // update_option( 'wpcm_mode', $plugin_mode ); // } - if ( isset( $_POST['club_location'] ) ) { - $club_location = sanitize_text_field( $_POST['club_location'] ); + $location = filter_input( INPUT_POST, 'club_location', FILTER_UNSAFE_RAW ); + if ( $location ) { + $club_location = sanitize_text_field( $location ); update_option( 'wpcm_default_country', $club_location ); } - if ( isset( $_POST['club_sport'] ) && ! empty( $_POST['club_sport'] ) ) { - $post = $_POST['club_sport']; + + $club_sport = filter_input( INPUT_POST, 'club_sport', FILTER_UNSAFE_RAW ); + if ( $club_sport ) { + $post = sanitize_text_field( $club_sport ); $sport = WPCM()->sports->$post; WPCM_Admin_Settings::configure_sport( $sport ); - $club_sport = sanitize_text_field( $_POST['club_sport'] ); update_option( 'wpcm_sport', $club_sport ); // Set table columns $cols = wpcm_get_preset_labels( 'standings' ); @@ -285,42 +292,42 @@ public function wpcm_setup_general_save() { */ public function wpcm_setup_club() { - $current = date( 'Y' ); - $next = date( 'y' ) + 1; + $current = gmdate( 'Y' ); + $next = gmdate( 'y' ) + 1; $season_input = _x( 'eg.', 'example', 'wp-club-manager' ) . ' ' . $current . '/' . $next; ?> -

+

-

+

- +
- +
- - + +
- +
- + @@ -335,20 +342,23 @@ public function wpcm_setup_club_save() { check_admin_referer( 'wpcm-setup' ); - if ( isset( $_POST['setup_season'] ) ) { - $season = sanitize_text_field( $_POST['setup_season'] ); + $setup_season = filter_input( INPUT_POST, 'setup_season', FILTER_UNSAFE_RAW ); + if ( $setup_season ) { + $season = sanitize_text_field( $setup_season ); $season_id = wp_insert_term( $season, 'wpcm_season' ); update_term_meta( $season_id, 'tax_position', 1 ); } - if ( isset( $_POST['setup_comp'] ) ) { - $comp = sanitize_text_field( $_POST['setup_comp'] ); + $setup_comp = filter_input( INPUT_POST, 'setup_comp', FILTER_UNSAFE_RAW ); + if ( $setup_comp ) { + $comp = sanitize_text_field( $setup_comp ); $comp_id = wp_insert_term( $comp, 'wpcm_comp' ); update_term_meta( $comp_id, 'tax_position', 1 ); } - if ( isset( $_POST['default_club'] ) && ! empty( $_POST['default_club'] ) && get_option( 'wpcm_default_club', null ) != $_POST['default_club'] ) { - $title = sanitize_text_field( $_POST['default_club'] ); + $default_club = filter_input( INPUT_POST, 'default_club', FILTER_UNSAFE_RAW ); + if ( $default_club && get_option( 'wpcm_default_club', null ) != sanitize_text_field( $default_club ) ) { + $title = sanitize_text_field( $default_club ); $post = array( 'post_title' => $title, 'post_type' => 'wpcm_club', @@ -363,8 +373,9 @@ public function wpcm_setup_club_save() { $team_id = wp_insert_term( $team, 'wpcm_team' ); update_term_meta( $team_id, 'tax_position', 1 ); - if ( isset( $_POST['setup_opponent'] ) ) { - $opponent = sanitize_text_field( $_POST['setup_opponent'] ); + $setup_opponent = filter_input( INPUT_POST, 'setup_opponent', FILTER_UNSAFE_RAW ); + if ( $setup_opponent ) { + $opponent = sanitize_text_field( $setup_opponent ); $args = array( 'post_title' => $opponent, 'post_type' => 'wpcm_club', @@ -418,21 +429,21 @@ public function wpcm_setup_club_save() { */ public function wpcm_setup_venue() { ?> -

+

-

+

- +
- +
@@ -444,7 +455,7 @@ public function wpcm_setup_venue() { - + @@ -459,19 +470,21 @@ public function wpcm_setup_venue_save() { check_admin_referer( 'wpcm-setup' ); - if ( isset( $_POST['setup_home'] ) && ! empty( $_POST['setup_home'] ) ) { - $home = sanitize_text_field( $_POST['setup_home'] ); + $setup_home = filter_input( INPUT_POST, 'setup_home', FILTER_UNSAFE_RAW ); + if ( $setup_home ) { + $home = sanitize_text_field( $setup_home ); $post_id = get_option( 'wpcm_default_club' ); $terms = wp_insert_term( $home, 'wpcm_venue' ); wp_set_object_terms( $post_id, $terms['term_id'], 'wpcm_venue' ); - if ( isset( $_POST['term_meta'] ) ) { + $term_meta_value = filter_input( INPUT_POST, 'term_meta', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $term_meta_value ) { $t_id = $terms['term_id']; $term_meta = get_option( "taxonomy_term_$t_id" ); - $cat_keys = array_keys( $_POST['term_meta'] ); + $cat_keys = array_keys( $term_meta_value ); foreach ( $cat_keys as $key ) { - if ( isset( $_POST['term_meta'][ $key ] ) ) { - $term_meta[ $key ] = $_POST['term_meta'][ $key ]; + if ( isset( $term_meta_value[ $key ] ) ) { + $term_meta[ $key ] = sanitize_text_field( $term_meta_value[ $key ] ); } } update_option( "taxonomy_term_$t_id", $term_meta ); @@ -489,33 +502,33 @@ public function wpcm_setup_ready() { ?> -

+

-

+

- +

- +

-

+

- +

- +

- - - + + +
diff --git a/includes/admin/class-wpcm-admin-taxonomies.php b/includes/admin/class-wpcm-admin-taxonomies.php index cab68ec..936d0a1 100644 --- a/includes/admin/class-wpcm-admin-taxonomies.php +++ b/includes/admin/class-wpcm-admin-taxonomies.php @@ -13,6 +13,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Admin_Taxonomies + */ class WPCM_Admin_Taxonomies { /** @@ -61,12 +64,15 @@ public function __construct() { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param int $term_id + * + * @return void */ public function save_season_tax_positions( $term_id ) { - $terms = get_terms( 'wpcm_season', array( + $terms = get_terms( array( + 'taxonomy' => 'wpcm_season', 'hide_empty' => false, 'exclude' => $term_id, ) ); @@ -82,12 +88,15 @@ public function save_season_tax_positions( $term_id ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param int $term_id + * + * @return void */ public function save_position_tax_positions( $term_id ) { - $terms = get_terms( 'wpcm_position', array( + $terms = get_terms( array( + 'taxonomy' => 'wpcm_position', 'hide_empty' => false, 'exclude' => $term_id, ) ); @@ -103,12 +112,15 @@ public function save_position_tax_positions( $term_id ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param int $term_id + * + * @return void */ public function save_jobs_tax_positions( $term_id ) { - $terms = get_terms( 'wpcm_jobs', array( + $terms = get_terms( array( + 'taxonomy' => 'wpcm_jobs', 'hide_empty' => false, 'exclude' => $term_id, ) ); @@ -124,16 +136,18 @@ public function save_jobs_tax_positions( $term_id ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $tag + * + * @return void */ public function team_add_new_extra_fields( $tag ) { ?>
- - -

+ + +

'wpcm_team', 'hide_empty' => false, 'exclude' => $term_id, ) ); @@ -199,7 +218,9 @@ public function save_team_extra_fields( $term_id ) { * Thumbnail column added to category admin. * * @access public + * * @param mixed $columns + * * @return array */ public function team_edit_columns( $columns ) { @@ -218,8 +239,12 @@ public function team_edit_columns( $columns ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $value + * @param string $column + * @param int $t_id + * + * @return void */ public function team_custom_columns( $value, $column, $t_id ) { @@ -232,7 +257,7 @@ public function team_custom_columns( $value, $column, $t_id ) { echo ''; break; case 'label': - echo $term_meta['wpcm_team_label']; + echo esc_html( $term_meta['wpcm_team_label'] ); break; } } @@ -241,17 +266,18 @@ public function team_custom_columns( $value, $column, $t_id ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $tag + * + * @return void */ public function comp_add_new_extra_fields( $tag ) { - ?>
- - -

+ + +

'wpcm_season', 'hide_empty' => false, 'exclude' => $term_id, ) ); @@ -336,8 +367,12 @@ public function comp_edit_columns( $columns ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $value + * @param string $column + * @param int $t_id + * + * @return void */ public function comp_custom_columns( $value, $column, $t_id ) { @@ -350,7 +385,7 @@ public function comp_custom_columns( $value, $column, $t_id ) { echo ''; break; case 'label': - echo $term_meta['wpcm_comp_label']; + echo esc_html( $term_meta['wpcm_comp_label'] ); break; } } @@ -377,8 +412,12 @@ public function season_edit_columns( $columns ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $value + * @param string $column + * @param int $t_id + * + * @return void */ public function season_custom_columns( $value, $column, $t_id ) { @@ -395,18 +434,21 @@ public function season_custom_columns( $value, $column, $t_id ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $tag + * + * @return void */ public function venue_add_new_extra_fields( $tag ) { $args = array( + 'taxonomy' => 'wpcm_venue', 'orderby' => 'id', 'order' => 'DESC', 'hide_empty' => false, ); // Get latitude and longitude from the last added venue - $terms = get_terms( 'wpcm_venue', $args ); + $terms = get_terms( $args ); if ( $terms ) { $term = reset( $terms ); $t_id = $term->term_id; @@ -423,27 +465,27 @@ public function venue_add_new_extra_fields( $tag ) { ?>
- +

- +

- +
- - + +
- + - + - name="term_meta[wpcm_latitude]" id="term_meta[wpcm_latitude]" value=""> + name="term_meta[wpcm_latitude]" id="term_meta[wpcm_latitude]" value=""> + + name="term_meta[wpcm_longitude]" id="term_meta[wpcm_longitude]" value=""> - name="term_meta[wpcm_longitude]" id="term_meta[wpcm_longitude]" value=""> - lat; $lng = $location->lng; - $term_meta['wpcm_address'] = $_POST['term_meta']['wpcm_address']; + $term_meta['wpcm_address'] = $term_meta_value['wpcm_address']; $term_meta['wpcm_latitude'] = $lat; $term_meta['wpcm_longitude'] = $lng; - $term_meta['wpcm_capacity'] = $_POST['term_meta']['wpcm_capacity']; + $term_meta['wpcm_capacity'] = $term_meta_value['wpcm_capacity']; update_option( 'taxonomy_term_' . $t_id, $term_meta ); } - } elseif ( isset( $_POST['term_meta'] ) ) { + } elseif ( $term_meta_value ) { $t_id = $term_id; $term_meta = get_option( "taxonomy_term_$t_id" ); - $cat_keys = array_keys( $_POST['term_meta'] ); + $cat_keys = array_keys( $term_meta_value ); foreach ( $cat_keys as $key ) { - if ( isset( $_POST['term_meta'][ $key ] ) ) { - $term_meta[ $key ] = $_POST['term_meta'][ $key ]; + if ( isset( $term_meta_value[ $key ] ) ) { + $term_meta[ $key ] = $term_meta_value[ $key ]; } } update_option( "taxonomy_term_$t_id", $term_meta ); @@ -574,8 +622,12 @@ public function venue_edit_columns( $columns ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $value + * @param string $column + * @param int $t_id + * + * @return void */ public function venue_custom_columns( $value, $column, $t_id ) { @@ -585,10 +637,10 @@ public function venue_custom_columns( $value, $column, $t_id ) { switch ( $column ) { case 'address': - echo ( isset( $term_meta['wpcm_address'] ) && ! empty( $term_meta['wpcm_address'] ) ) ? $term_meta['wpcm_address'] : ''; + echo ( isset( $term_meta['wpcm_address'] ) && ! empty( $term_meta['wpcm_address'] ) ) ? esc_html( $term_meta['wpcm_address'] ) : ''; break; case 'capacity': - echo ( isset( $term_meta['wpcm_capacity'] ) && ! empty( $term_meta['wpcm_capacity'] ) ) ? $term_meta['wpcm_capacity'] : ''; + echo ( isset( $term_meta['wpcm_capacity'] ) && ! empty( $term_meta['wpcm_capacity'] ) ) ? esc_html( $term_meta['wpcm_capacity'] ) : ''; break; } } @@ -616,8 +668,12 @@ public function position_edit_columns( $columns ) { * Thumbnail column added to category admin. * * @access public - * @param mixed $columns - * @return array + * + * @param mixed $value + * @param string $column + * @param string $t_id + * + * @return void */ public function position_custom_columns( $value, $column, $t_id ) { @@ -633,4 +689,4 @@ public function position_custom_columns( $value, $column, $t_id ) { } } -new WPCM_Admin_Taxonomies(); \ No newline at end of file +new WPCM_Admin_Taxonomies(); diff --git a/includes/admin/class-wpcm-admin.php b/includes/admin/class-wpcm-admin.php index 8a0d7ff..941d2c3 100644 --- a/includes/admin/class-wpcm-admin.php +++ b/includes/admin/class-wpcm-admin.php @@ -15,6 +15,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Admin + */ class WPCM_Admin { /** @@ -109,8 +112,9 @@ public function conditonal_includes() { public function admin_redirects() { // Nonced plugin install redirects (whitelisted) - if ( ! empty( $_GET['wpcm-install-plugin-redirect'] ) ) { - $plugin_slug = wpcm_clean( $_GET['wpcm-install-plugin-redirect'] ); + $redirect = filter_input( INPUT_GET, 'wpcm-install-plugin-redirect', FILTER_UNSAFE_RAW ); + if ( ! empty( $redirect ) ) { + $plugin_slug = wpcm_clean( $redirect ); $url = admin_url( 'plugin-install.php?tab=search&type=term&s=' . $plugin_slug ); wp_safe_redirect( $url ); exit; @@ -138,7 +142,7 @@ public function admin_redirects() { public function prevent_admin_access() { $prevent_access = false; - if ( 'yes' == get_option( 'wpclubmanager_lock_down_admin' ) && ! is_ajax() && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_wpclubmanager' ) ) && basename( $_SERVER['SCRIPT_FILENAME'] ) !== 'admin-post.php' ) { + if ( get_option( 'wpclubmanager_lock_down_admin' ) === 'yes' && ! is_ajax() && ! ( current_user_can( 'edit_posts' ) || current_user_can( 'manage_wpclubmanager' ) ) && ( isset( $_SERVER['SCRIPT_FILENAME'] ) && basename( $_SERVER['SCRIPT_FILENAME'] ) !== 'admin-post.php' ) ) { // phpcs:ignore $prevent_access = true; } @@ -182,7 +186,7 @@ public function wpclubmanager_print_js() { $wpclubmanager_queued_js = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", $wpclubmanager_queued_js ); $wpclubmanager_queued_js = str_replace( "\r", '', $wpclubmanager_queued_js ); - echo $wpclubmanager_queued_js . "});\n\n"; + echo $wpclubmanager_queued_js . "});\n\n"; // phpcs:ignore unset( $wpclubmanager_queued_js ); } @@ -208,6 +212,7 @@ public function wpclubmanager_admin_rate_us( $footer_text ) { if ( ! get_option( 'wpclubmanager_admin_footer_text_rated' ) ) { + /* translators: 1: review URL */ $footer_text = sprintf( __( 'If you like WP Club Manager please leave us a %1$s★★★★★%2$s rating. A huge thank you in advance!', 'wp-club-manager' ), '', '' ); $this->wpclubmanager_enqueue_js( " jQuery( 'a.wpcm-rating-link' ).click( function() { @@ -224,6 +229,11 @@ public function wpclubmanager_admin_rate_us( $footer_text ) { return $footer_text; } + /** + * @param string $classes + * + * @return string + */ public function wpclubmanager_admin_body_class( $classes ) { $sport = get_option( 'wpcm_sport' ); diff --git a/includes/admin/importers/class-wpcm-club-importer.php b/includes/admin/importers/class-wpcm-club-importer.php index a674670..3f20ae3 100644 --- a/includes/admin/importers/class-wpcm-club-importer.php +++ b/includes/admin/importers/class-wpcm-club-importer.php @@ -13,6 +13,10 @@ } if ( class_exists( 'WP_Importer' ) ) { + + /** + * WPCM_Club_Importer + */ class WPCM_Club_Importer extends WPCM_Importer { /** @@ -30,17 +34,19 @@ public function __construct() { /** * import function. * - * @param mixed $file + * @param array $array + * @param array $columns */ - function import( $array = array(), $columns = array( 'post_title' ) ) { - $this->imported = $this->skipped = 0; + public function import( $array = array(), $columns = array( 'post_title' ) ) { + $this->imported = 0; + $this->skipped = 0; - if ( ! is_array( $array ) || ! sizeof( $array ) ) : + if ( ! is_array( $array ) || ! count( $array ) ) : $this->footer(); die(); endif; - $rows = array_chunk( $array, sizeof( $columns ) ); + $rows = array_chunk( $array, count( $columns ) ); foreach ( $rows as $row ) : @@ -63,6 +69,11 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { continue; endif; + if ( post_exists( $name, '', '', 'wpcm_club' ) ) { + ++$this->skipped; + continue; + } + $args = array( 'post_type' => 'wpcm_club', 'post_status' => 'publish', @@ -83,9 +94,10 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { endforeach; // Show Result - echo '

- ' . sprintf( __( 'Import complete - imported %1$s clubs and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) . ' -

'; + echo '

' . + /* translators: 1: number of imported 2: number of skipped */ + wp_kses_post( sprintf( __( 'Import complete - imported %1$s clubs and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) ) + . '

'; $this->import_end(); } @@ -94,7 +106,7 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { * Performs post-import cleanup of files and the cache */ public function import_end() { - echo '

' . __( 'All done!', 'wp-club-manager' ) . ' ' . __( 'View Clubs', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'All done!', 'wp-club-manager' ) . ' ' . esc_html__( 'View Clubs', 'wp-club-manager' ) . '

'; do_action( 'import_end' ); } @@ -103,7 +115,7 @@ public function import_end() { * header function. */ public function header() { - echo '

' . __( 'Import Clubs', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'Import Clubs', 'wp-club-manager' ) . '

'; } /** @@ -111,8 +123,9 @@ public function header() { */ public function greet() { echo '
'; - echo '

' . __( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; - echo '

' . sprintf( __( 'Clubs need to be defined with columns in a specific order (2 columns). Click here to download a sample.', 'wp-club-manager' ), plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/club-sample.csv' ) . '

'; + echo '

' . esc_html__( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; + /* translators: 1: sample CSV link */ + echo '

' . sprintf( wp_kses_post( __( 'Clubs need to be defined with columns in a specific order (2 columns). Click here to download a sample.', 'wp-club-manager' ) ), esc_url( plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/club-sample.csv' ) ) . '

'; wp_import_upload_form( 'admin.php?import=wpclubmanager_club_csv&step=1' ); echo '
'; } diff --git a/includes/admin/importers/class-wpcm-importers.php b/includes/admin/importers/class-wpcm-importer.php similarity index 59% rename from includes/admin/importers/class-wpcm-importers.php rename to includes/admin/importers/class-wpcm-importer.php index 7a254e5..e3cee88 100644 --- a/includes/admin/importers/class-wpcm-importers.php +++ b/includes/admin/importers/class-wpcm-importer.php @@ -13,17 +13,56 @@ } if ( class_exists( 'WP_Importer' ) ) { + + /** + * WPCM_Importer + */ class WPCM_Importer extends WP_Importer { - var $id; - var $file_url; - var $import_page; - var $delimiter; - var $posts = array(); - var $imported; - var $skipped; - var $import_label; - var $columns = array(); + /** + * @var int + */ + public $id; + + /** + * @var string + */ + public $file_url; + + /** + * @var string + */ + public $import_page; + + /** + * @var string + */ + public $delimiter; + + /** + * @var array + */ + public $posts = array(); + + /** + * @var int + */ + public $imported; + + /** + * @var int + */ + public $skipped; + + /** + * @var string + */ + public $import_label; + + /** + * @var array + */ + public $columns = array(); /** * Registered callback function for the WordPress Importer @@ -33,8 +72,9 @@ class WPCM_Importer extends WP_Importer { public function dispatch() { $this->header(); - if ( ! empty( $_POST['delimiter'] ) ) { - $this->delimiter = stripslashes( trim( $_POST['delimiter'] ) ); + $delimiter = filter_input( INPUT_POST, 'delimiter', FILTER_UNSAFE_RAW ); + if ( $delimiter ) { + $this->delimiter = stripslashes( trim( $delimiter ) ); } if ( ! $this->delimiter ) { @@ -75,9 +115,13 @@ public function dispatch() { case 2: check_admin_referer( 'import-upload' ); - if ( isset( $_POST['wpcm_import'] ) ) : - $columns = array_filter( wpcm_array_value( $_POST, 'wpcm_columns', array( 'post_title' ) ) ); - $this->import( $_POST['wpcm_import'], array_values( $columns ) ); + $import = filter_input( INPUT_POST, 'wpcm_import', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $import ) : + $columns = filter_input( INPUT_POST, 'wpcm_columns', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( empty( $columns ) ) { + $columns = array( 'post_title' ); + } + $this->import( $import, array_values( $columns ) ); endif; break; @@ -91,15 +135,17 @@ public function dispatch() { * Adapted from https://wordpress.org/plugins/sportspress/ * * @access public - * @param mixed $file + * + * @param string $selected + * * @return void */ - function dropdown( $selected ) { + public function dropdown( $selected ) { ?> - + columns as $key => $label ) : ?> - + imported = $this->skipped = 0; + $this->imported = 0; + $this->skipped = 0; if ( ! is_file( $file ) ) : - echo '

' . __( 'Sorry, there has been an error.', 'wp-club-manager' ) . '
'; - echo __( 'The file does not exist, please try again.', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'Sorry, there has been an error.', 'wp-club-manager' ) . '
'; + esc_html_e( 'The file does not exist, please try again.', 'wp-club-manager' ) . '

'; $this->footer(); @@ -130,12 +177,12 @@ function import_table( $file ) { endif; ini_set( 'auto_detect_line_endings', '1' ); - - if ( ( $handle = fopen( $file, 'r' ) ) !== false ) : + $handle = fopen( $file, 'r' ); + if ( false !== $handle ) : $header = fgetcsv( $handle, 0, $this->delimiter ); - if ( sizeof( $header ) >= 1 ) : + if ( count( $header ) >= 1 ) : $action = 'admin.php?import=' . $this->import_page . '&step=2'; ?> @@ -159,7 +206,7 @@ function import_table( $file ) { $value = wpcm_array_value( $row, $index ); ?>
- + + - /> + + />
- + - + +
- + - + > $val ) { ?> - + > - +
- + +
- +
    - $val ) { - ?> + $val ) { + ?>
  • + + + />
  • - +
-
- - -
- × px + × px - +
- +
- +
+
- + +
- +
- + - - + + +
- + - -

+ +

- + - -

+ +

- +

- +

- + - +
- +

- imported + 1, $this->imported + 1 ); ?> + imported + 1 ), esc_html( $this->imported + 1 ) ); + ?>

@@ -189,8 +239,8 @@ function import_table( $file ) { ' . __( 'Sorry, there has been an error.', 'wp-club-manager' ) . '
'; - echo __( 'The CSV is invalid.', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'Sorry, there has been an error.', 'wp-club-manager' ) . '
'; + esc_html_e( 'The CSV is invalid.', 'wp-club-manager' ) . '

'; $this->footer(); die(); @@ -209,8 +259,8 @@ function import_table( $file ) { * @param string $enc * @return string */ - function format_data_from_csv( $data, $enc ) { - return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data ); + public function format_data_from_csv( $data, $enc ) { + return ( 'UTF-8' == $enc ) ? $data : utf8_encode( $data ); } /** @@ -219,27 +269,28 @@ function format_data_from_csv( $data, $enc ) { * * @return bool False if error uploading or invalid file, true otherwise */ - function handle_upload() { + public function handle_upload() { - if ( empty( $_POST['file_url'] ) ) { + $file_url = filter_input( INPUT_POST, 'file_url', FILTER_VALIDATE_URL ); + if ( empty( $file_url ) ) { $file = wp_import_handle_upload(); if ( isset( $file['error'] ) ) { - echo '

' . __( 'Sorry, there has been an error.', 'wp-club-manager' ) . '
'; + echo '

' . esc_html__( 'Sorry, there has been an error.', 'wp-club-manager' ) . '
'; echo esc_html( $file['error'] ) . '

'; return false; } $this->id = (int) $file['id']; - } elseif ( file_exists( ABSPATH . $_POST['file_url'] ) ) { + } elseif ( file_exists( ABSPATH . $file_url ) ) { - $this->file_url = esc_attr( $_POST['file_url'] ); + $this->file_url = esc_attr( $file_url ); } else { - echo '

' . __( 'Sorry, there has been an error.', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'Sorry, there has been an error.', 'wp-club-manager' ) . '

'; return false; } @@ -252,8 +303,8 @@ function handle_upload() { * @access public * @return void */ - function header() { - echo '

' . $this->import_label . '

'; + public function header() { + echo '

' . esc_html( $this->import_label ) . '

'; } /** @@ -262,8 +313,8 @@ function header() { * @access public * @return void */ - function footer() { - echo '
'; + public function footer() { + echo '
'; // phpcs:ignore } /** @@ -272,7 +323,7 @@ function footer() { * @param int $val * @return int 60 */ - function bump_request_timeout( $val ) { + public function bump_request_timeout( $val ) { return 60; } } diff --git a/includes/admin/importers/class-wpcm-match-importer.php b/includes/admin/importers/class-wpcm-match-importer.php index f2fe7e3..2777378 100644 --- a/includes/admin/importers/class-wpcm-match-importer.php +++ b/includes/admin/importers/class-wpcm-match-importer.php @@ -13,6 +13,10 @@ } if ( class_exists( 'WP_Importer' ) ) { + + /** + * WPCM_Match_Importer + */ class WPCM_Match_Importer extends WPCM_Importer { /** @@ -40,18 +44,19 @@ public function __construct() { /** * import function. * - * @param mixed $file + * @param array $array + * @param array $columns */ - function import( $array = array(), $columns = array( 'post_title' ) ) { - - $this->imported = $this->skipped = 0; + public function import( $array = array(), $columns = array( 'post_title' ) ) { + $this->imported = 0; + $this->skipped = 0; - if ( ! is_array( $array ) || ! sizeof( $array ) ) : + if ( ! is_array( $array ) || ! count( $array ) ) : $this->footer(); die(); endif; - $rows = array_chunk( $array, sizeof( $columns ) ); + $rows = array_chunk( $array, count( $columns ) ); $date_format = 'yyyy/mm/dd'; $wpcm_player_stats_labels = wpcm_get_preset_labels(); @@ -243,7 +248,7 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { $cards = wpcm_stats_cards(); foreach ( $cards as $card ) { - if ( array_key_exists( $card, $stats_combine ) && $stats_combine[ $card ] == '0' ) { + if ( array_key_exists( $card, $stats_combine ) && '0' == $stats_combine[ $card ] ) { unset( $stats_combine[ $card ] ); } } @@ -263,9 +268,10 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { endforeach; // Show import result - echo '

- ' . sprintf( __( 'Import complete - imported %1$s matches and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) . ' -

'; + echo '

'; + /* translators: 1: imported total 2: skipped total */ + echo wp_kses_post( sprintf( __( 'Import complete - imported %1$s matches and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) ); + echo '

'; $this->import_end(); } @@ -274,7 +280,7 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { * Performs post-import cleanup of files and the cache */ public function import_end() { - echo '

' . __( 'All done!', 'wp-club-manager' ) . ' ' . __( 'View Matches', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'All done!', 'wp-club-manager' ) . ' ' . esc_html__( 'View Matches', 'wp-club-manager' ) . '

'; do_action( 'import_end' ); } @@ -283,7 +289,7 @@ public function import_end() { * header function. */ public function header() { - echo '

' . __( 'Import Matches', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'Import Matches', 'wp-club-manager' ) . '

'; } /** @@ -291,8 +297,9 @@ public function header() { */ public function greet() { echo '
'; - echo '

' . __( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; - echo '

' . sprintf( __( 'Matches need to be defined with columns in a specific order (12 columns). Click here to download a sample.', 'wp-club-manager' ), plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/match-sample.csv' ) . '

'; + echo '

' . esc_html__( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; + /* translators: 1: match-sample.csv URL */ + echo '

' . wp_kses_post( sprintf( __( 'Matches need to be defined with columns in a specific order (12 columns). Click here to download a sample.', 'wp-club-manager' ), esc_url( plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/match-sample.csv' ) ) ) . '

'; wp_import_upload_form( 'admin.php?import=wpclubmanager_match_csv&step=1' ); echo '
'; } diff --git a/includes/admin/importers/class-wpcm-player-importer.php b/includes/admin/importers/class-wpcm-player-importer.php index 3e441c0..ad56fe2 100644 --- a/includes/admin/importers/class-wpcm-player-importer.php +++ b/includes/admin/importers/class-wpcm-player-importer.php @@ -13,6 +13,10 @@ } if ( class_exists( 'WP_Importer' ) ) { + + /** + * WPCM_Player_Importer + */ class WPCM_Player_Importer extends WPCM_Importer { /** @@ -38,17 +42,19 @@ public function __construct() { /** * import function. * - * @param mixed $file + * @param array $array + * @param array $columns */ - function import( $array = array(), $columns = array( 'post_title' ) ) { - $this->imported = $this->skipped = 0; + public function import( $array = array(), $columns = array( 'post_title' ) ) { + $this->imported = 0; + $this->skipped = 0; - if ( ! is_array( $array ) || ! sizeof( $array ) ) : + if ( ! is_array( $array ) || ! count( $array ) ) : $this->footer(); die(); endif; - $rows = array_chunk( $array, sizeof( $columns ) ); + $rows = array_chunk( $array, count( $columns ) ); foreach ( $rows as $row ) : @@ -64,8 +70,8 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { $meta[ $key ] = wpcm_array_value( $row, $index ); endforeach; - $first_name = wpcm_array_value( $meta, '_wpcm_firstname' ); - $last_name = wpcm_array_value( $meta, '_wpcm_lastname' ); + $first_name = sanitize_text_field( wpcm_array_value( $meta, '_wpcm_firstname' ) ); + $last_name = sanitize_text_field( wpcm_array_value( $meta, '_wpcm_lastname' ) ); $name = $first_name . ' ' . $last_name; $post_name = sanitize_title_with_dashes( $name ); @@ -104,35 +110,36 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { wp_set_object_terms( $id, $positions, 'wpcm_position', false ); // Update date of birth - update_post_meta( $id, 'wpcm_dob', wpcm_array_value( $meta, 'wpcm_dob' ) ); + update_post_meta( $id, 'wpcm_dob', sanitize_text_field( wpcm_array_value( $meta, 'wpcm_dob' ) ) ); // Update height - update_post_meta( $id, 'wpcm_height', wpcm_array_value( $meta, 'wpcm_height' ) ); + update_post_meta( $id, 'wpcm_height', sanitize_text_field( wpcm_array_value( $meta, 'wpcm_height' ) ) ); // Update weight - update_post_meta( $id, 'wpcm_weight', wpcm_array_value( $meta, 'wpcm_weight' ) ); + update_post_meta( $id, 'wpcm_weight', sanitize_text_field( wpcm_array_value( $meta, 'wpcm_weight' ) ) ); // Update hometown - update_post_meta( $id, 'wpcm_hometown', wpcm_array_value( $meta, 'wpcm_hometown' ) ); + update_post_meta( $id, 'wpcm_hometown', sanitize_text_field( wpcm_array_value( $meta, 'wpcm_hometown' ) ) ); // Update nationality $natl = trim( strtolower( wpcm_array_value( $meta, 'wpcm_natl' ) ) ); - if ( $natl == '*' ) { + if ( '*' === $natl ) { $natl = ''; } - update_post_meta( $id, 'wpcm_natl', $natl ); + update_post_meta( $id, 'wpcm_natl', sanitize_text_field( $natl ) ); // Update previous clubs - update_post_meta( $id, 'wpcm_prevclubs', wpcm_array_value( $meta, 'wpcm_prevclubs' ) ); + update_post_meta( $id, 'wpcm_prevclubs', sanitize_text_field( wpcm_array_value( $meta, 'wpcm_prevclubs' ) ) ); ++$this->imported; endforeach; // Show Result - echo '

- ' . sprintf( __( 'Import complete - imported %1$s players and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) . ' -

'; + echo '

'; + /* translators: 1: imported total 2: skipped total */ + echo wp_kses_post( sprintf( __( 'Import complete - imported %1$s players and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) ); + echo '

'; $this->import_end(); } @@ -141,7 +148,7 @@ function import( $array = array(), $columns = array( 'post_title' ) ) { * Performs post-import cleanup of files and the cache */ public function import_end() { - echo '

' . __( 'All done!', 'wp-club-manager' ) . ' ' . __( 'View Players', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'All done!', 'wp-club-manager' ) . ' ' . esc_html__( 'View Players', 'wp-club-manager' ) . '

'; do_action( 'import_end' ); } @@ -150,7 +157,7 @@ public function import_end() { * header function. */ public function header() { - echo '

' . __( 'Import Players', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'Import Players', 'wp-club-manager' ) . '

'; } /** @@ -158,8 +165,9 @@ public function header() { */ public function greet() { echo '
'; - echo '

' . __( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; - echo '

' . sprintf( __( 'Players need to be defined with columns in a specific order (10 columns). Click here to download a sample.', 'wp-club-manager' ), plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/player-sample.csv' ) . '

'; + echo '

' . esc_html__( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; + /* translators: 1: sample file URL */ + echo '

' . wp_kses_post( sprintf( __( 'Players need to be defined with columns in a specific order (10 columns). Click here to download a sample.', 'wp-club-manager' ), esc_url( plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/player-sample.csv' ) ) ) . '

'; wp_import_upload_form( 'admin.php?import=wpclubmanager_player_csv&step=1' ); echo '
'; } diff --git a/includes/admin/importers/class-wpcm-staff-importer.php b/includes/admin/importers/class-wpcm-staff-importer.php index cf46f16..4c3bffb 100644 --- a/includes/admin/importers/class-wpcm-staff-importer.php +++ b/includes/admin/importers/class-wpcm-staff-importer.php @@ -13,6 +13,10 @@ } if ( class_exists( 'WP_Importer' ) ) { + + /** + * WPCM_Staff_Importer + */ class WPCM_Staff_Importer extends WPCM_Importer { /** @@ -35,17 +39,19 @@ public function __construct() { /** * import function. * - * @param mixed $file + * @param array $array + * @param array $columns */ - function import( $array = array(), $columns = array() ) { - $this->imported = $this->skipped = 0; + public function import( $array = array(), $columns = array() ) { + $this->imported = 0; + $this->skipped = 0; - if ( ! is_array( $array ) || ! sizeof( $array ) ) : + if ( ! is_array( $array ) || ! count( $array ) ) : $this->footer(); die(); endif; - $rows = array_chunk( $array, sizeof( $columns ) ); + $rows = array_chunk( $array, count( $columns ) ); foreach ( $rows as $row ) : @@ -98,7 +104,7 @@ function import( $array = array(), $columns = array() ) { // Update nationality $natl = trim( strtolower( wpcm_array_value( $meta, 'wpcm_natl' ) ) ); - if ( $natl == '*' ) { + if ( '*' === $natl ) { $natl = ''; } update_post_meta( $id, 'wpcm_natl', $natl ); @@ -114,9 +120,10 @@ function import( $array = array(), $columns = array() ) { endforeach; // Show Result - echo '

- ' . sprintf( __( 'Import complete - imported %1$s staff and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) . ' -

'; + echo '

'; + /* translators: 1: imported total 2: skipped total */ + echo wp_kses_post( sprintf( __( 'Import complete - imported %1$s staff and skipped %2$s.', 'wp-club-manager' ), $this->imported, $this->skipped ) ); + echo '

'; $this->import_end(); } @@ -125,7 +132,7 @@ function import( $array = array(), $columns = array() ) { * Performs post-import cleanup of files and the cache */ public function import_end() { - echo '

' . __( 'All done!', 'wp-club-manager' ) . ' ' . __( 'View Staff', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'All done!', 'wp-club-manager' ) . ' ' . esc_html__( 'View Staff', 'wp-club-manager' ) . '

'; do_action( 'import_end' ); } @@ -134,7 +141,7 @@ public function import_end() { * header function. */ public function header() { - echo '

' . __( 'Import Staff', 'wp-club-manager' ) . '

'; + echo '

' . esc_html__( 'Import Staff', 'wp-club-manager' ) . '

'; } /** @@ -142,8 +149,9 @@ public function header() { */ public function greet() { echo '
'; - echo '

' . __( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; - echo '

' . sprintf( __( 'Staff need to be defined with columns in a specific order (7 columns). Click here to download a sample.', 'wp-club-manager' ), plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) . '

'; + echo '

' . esc_html__( 'Choose a .csv file to upload, then click "Upload file and import".', 'wp-club-manager' ) . '

'; + /* translators: 1: sample data URL */ + echo '

' . wp_kses_post( sprintf( __( 'Staff need to be defined with columns in a specific order (7 columns). Click here to download a sample.', 'wp-club-manager' ), esc_url( plugin_dir_url( WPCM_PLUGIN_FILE ) . 'dummy-data/staff-sample.csv' ) ) ) . '

'; wp_import_upload_form( 'admin.php?import=wpclubmanager_staff_csv&step=1' ); echo '
'; } diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-details.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-details.php index 06376af..88083ea 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-details.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-details.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Club_Details + */ class WPCM_Meta_Box_Club_Details { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -73,29 +78,45 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { - + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } // if( isset( $_POST['parent_id'] ) ) { // update_post_meta( $post_id, '_wpcm_club_parent', $_POST['parent_id'] ); // } - if ( isset( $_POST['_wpcm_club_abbr'] ) ) { - update_post_meta( $post_id, '_wpcm_club_abbr', $_POST['_wpcm_club_abbr'] ); + $club_abr = filter_input( INPUT_POST, '_wpcm_club_abbr', FILTER_UNSAFE_RAW ); + if ( $club_abr ) { + update_post_meta( $post_id, '_wpcm_club_abbr', sanitize_text_field( $club_abr ) ); } - if ( isset( $_POST['_wpcm_club_formed'] ) ) { - update_post_meta( $post_id, '_wpcm_club_formed', $_POST['_wpcm_club_formed'] ); + + $formed = filter_input( INPUT_POST, '_wpcm_club_formed', FILTER_UNSAFE_RAW ); + if ( $formed ) { + update_post_meta( $post_id, '_wpcm_club_formed', sanitize_text_field( $formed ) ); } - if ( isset( $_POST['_wpcm_club_primary_color'] ) ) { - update_post_meta( $post_id, '_wpcm_club_primary_color', $_POST['_wpcm_club_primary_color'] ); + + $primary = filter_input( INPUT_POST, '_wpcm_club_primary_color', FILTER_UNSAFE_RAW ); + if ( $primary ) { + update_post_meta( $post_id, '_wpcm_club_primary_color', sanitize_text_field( $primary ) ); } - if ( isset( $_POST['_wpcm_club_secondary_color'] ) ) { - update_post_meta( $post_id, '_wpcm_club_secondary_color', $_POST['_wpcm_club_secondary_color'] ); + + $secondary = filter_input( INPUT_POST, '_wpcm_club_secondary_color', FILTER_UNSAFE_RAW ); + if ( $secondary ) { + update_post_meta( $post_id, '_wpcm_club_secondary_color', sanitize_text_field( $secondary ) ); } - if ( isset( $_POST['_wpcm_club_website'] ) ) { - update_post_meta( $post_id, '_wpcm_club_website', $_POST['_wpcm_club_website'] ); + + $website = filter_input( INPUT_POST, '_wpcm_club_website', FILTER_UNSAFE_RAW ); + if ( $website ) { + update_post_meta( $post_id, '_wpcm_club_website', sanitize_text_field( $website ) ); } - if ( isset( $_POST['_wpcm_club_honours'] ) ) { - update_post_meta( $post_id, '_wpcm_club_honours', $_POST['_wpcm_club_honours'] ); + + $honours = filter_input( INPUT_POST, '_wpcm_club_honours', FILTER_UNSAFE_RAW ); + if ( $honours ) { + update_post_meta( $post_id, '_wpcm_club_honours', sanitize_text_field( $honours ) ); } do_action( 'delete_plugin_transients' ); diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-parent.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-parent.php index 7e7045c..15035f2 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-parent.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-parent.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Club_Parent + */ class WPCM_Meta_Box_Club_Parent { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -37,7 +42,7 @@ public static function output( $post ) { } ?>

- + 'parent_id', @@ -53,7 +58,7 @@ public static function output( $post ) { )); if ( $club ) { ?> - + @@ -63,14 +68,13 @@ public static function output( $post ) { if ( $children ) { ?> - 1 ? __( 'Child Clubs', 'wp-club-manager' ) : __( 'Child Club', 'wp-club-manager' ) ); ?> - +

    -
  • post_title; ?>
  • +
  • post_title ); ?>
  • @@ -81,11 +85,18 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['parent_id'] ) ) { - update_post_meta( $post_id, '_wpcm_club_parent', $_POST['parent_id'] ); + $parent = filter_input( INPUT_POST, 'parent_id', FILTER_VALIDATE_INT ); + if ( isset( $parent ) ) { + update_post_meta( $post_id, '_wpcm_club_parent', $parent ); } } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-players.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-players.php index 0c954c9..c196c67 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-players.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-club-players.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Club_Players + */ class WPCM_Meta_Box_Club_Players { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -38,11 +43,11 @@ public static function output( $post ) {
    - + @@ -55,13 +60,13 @@ public static function output( $post ) { foreach ( $players as $player ) { ?> - + @@ -73,4 +78,4 @@ public static function output( $post ) {
    - post_title; ?> + post_title ); ?> - +
    - + @@ -55,13 +60,13 @@ public static function output( $post ) { foreach ( $players as $player ) { ?> - + @@ -73,4 +78,4 @@ public static function output( $post ) {

    - + post_status == 'publish' || $post->post_status == 'future' ? get_the_time( 'H:i' ) : get_option( 'wpcm_match_time', '15:00' ) ); + $time = ( 'publish' === $post->post_status || 'future' === $post->post_status ? get_the_time( 'H:i' ) : get_option( 'wpcm_match_time', '15:00' ) ); $date = get_the_date( 'Y-m-d' ); @@ -86,7 +91,7 @@ public static function output( $post ) { ) ); ?>

    - + 'wpcm_comp', @@ -99,10 +104,10 @@ public static function output( $post ) { 'class' => 'chosen_select', )); ?> - +

    - + 'wpcm_season', @@ -120,7 +125,7 @@ public static function output( $post ) { if ( is_club_mode() && has_teams() ) { ?>

    - + 'wpcm_team', @@ -138,7 +143,7 @@ public static function output( $post ) { } ?>

    - + __( 'None' ), @@ -152,9 +157,9 @@ public static function output( $post ) { ?> -

    +

    - +

    - +

    $val ) { if ( get_option( 'wpcm_show_stats_' . $key ) == 'yes' ) : + $class = ''; + if ( in_array( $key, array( + 'greencards', + 'yellowcards', + 'blackcards', + 'redcards', + ) ) ) { + $class = 'th-checkbox'; + } + if ( 'mvp' == $key ) { + $class = 'th-radio'; + } ?> - + - + - + @@ -416,23 +431,22 @@ public static function wpcm_match_player_stats_table( $selected_players = array( ++$count; - if ( $show_shirt == 'yes' ) { + if ( 'yes' == $show_shirt ) { $shirt = ''; } else { $shirt = ''; } ?> - - ID, $selected_players, $type, $count, $played ); ?> - + + ID, $selected_players, $type, $count, $played ) ); ?> @@ -440,7 +454,7 @@ public static function wpcm_match_player_stats_table( $selected_players = array( do_action( 'wpclubmanager_admin_before_lineup_stats', $selected_players, $player->ID, ! $played ); - if ( $type !== 'subs_not_used' ) { + if ( 'subs_not_used' !== $type ) { foreach ( $wpcm_player_stats_labels as $key => $val ) : $keyarray = ( @@ -454,11 +468,11 @@ public static function wpcm_match_player_stats_table( $selected_players = array( if ( get_option( 'wpcm_show_stats_' . $key ) == 'yes' ) : - if ( $key == 'greencards' ) { + if ( 'greencards' == $key ) { ?> - - + - - + - - + - - + - - + +
    - post_title; ?> + post_title ); ?> - +
    - > + - @@ -180,9 +187,11 @@ public static function wpcm_player_subs_dropdown( $players = array(), $id = null * Match player minutes input. * * @access public - * @param array + * + * @param array $players * @param string $id - * @param bool $disabled = false + * @param bool $disabled + * * @return void */ public static function wpcm_player_subs_minutes( $players = array(), $id = null, $disabled = false ) { @@ -195,7 +204,7 @@ public static function wpcm_player_subs_minutes( $players = array(), $id = null, ?> - /> + />
      - >
    ' . $count . '
    - + + - + + - + + - + + - + - + - - + - ID ); ?> + ID ); ?> ID, ! $played ); @@ -576,11 +590,18 @@ public static function wpcm_match_player_stats_table( $selected_players = array( /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['wpcm_players'] ) ) { - $players = (array) $_POST['wpcm_players']; + $players_data = filter_input( INPUT_POST, 'wpcm_players', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $players_data ) { + $players = (array) $players_data; if ( is_array( $players ) ) { if ( array_key_exists( 'lineup', $players ) && is_array( $players['lineup'] ) ) { $players['lineup'] = array_filter( $players['lineup'], 'wpcm_array_filter_checked' ); @@ -596,12 +617,9 @@ public static function save( $post_id, $post ) { update_post_meta( $post_id, '_wpcm_match_subs_not_used', $players['subs_not_used'] ); } - if ( isset( $_POST['wpcm_match_captain'] ) ) { - update_post_meta( $post_id, '_wpcm_match_captain', $_POST['wpcm_match_captain'] ); - } - - if ( isset( $_POST['wpcm_match_subs_not_used'] ) ) { - update_post_meta( $post_id, '_wpcm_match_subs_not_used', $_POST['wpcm_match_subs_not_used'] ); + $match_captain = filter_input( INPUT_POST, 'wpcm_match_captain', FILTER_VALIDATE_INT ); + if ( $match_captain ) { + update_post_meta( $post_id, '_wpcm_match_captain', $match_captain ); } do_action( 'delete_plugin_transients' ); diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-result.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-result.php index 3c82669..e2204c1 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-result.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-result.php @@ -4,372 +4,530 @@ * * Displays the match result box. * - * @author ClubPress - * @category Admin - * @package WPClubManager/Admin/Meta Boxes - * @version 2.1.9 + * @author ClubPress + * @category Admin + * @package WPClubManager/Admin/Meta Boxes + * @version 2.1.9 */ -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +// phpcs:disable Generic.WhiteSpace.ScopeIndent.Incorrect +// phpcs:disable PEAR.Functions.FunctionCallSignature.Indent +// phpcs:disable NormalizedArrays.Arrays.CommaAfterLast.MissingMultiLine +// phpcs:disable Squiz.PHP.EmbeddedPhp.ContentBeforeEnd +// phpcs:disable WordPress.Arrays.ArrayDeclarationSpacing.AssociativeArrayFound +// phpcs:disable WordPress.Arrays.ArrayIndentation.ItemNotAligned +// phpcs:disable WordPress.Arrays.ArrayIndentation.MultiLineArrayItemNotAligned +// phpcs:disable Squiz.PHP.EmbeddedPhp.ContentAfterOpen +// phpcs:disable WordPress.Arrays.ArrayIndentation.CloseBraceNotAligned +// phpcs:disable WordPress.WhiteSpace.ControlStructureSpacing.NoSpaceBeforeCloseParenthesis + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} // Exit if accessed directly +/** + * WPCM_Meta_Box_Match_Result + */ class WPCM_Meta_Box_Match_Result { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { wp_nonce_field( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ); - $sport = get_option('wpcm_sport'); + $sport = get_option( 'wpcm_sport', '' ); - $played = get_post_meta( $post->ID, 'wpcm_played', true ); + $played = get_post_meta( $post->ID, 'wpcm_played', true ); $postponed = get_post_meta( $post->ID, '_wpcm_postponed', true ); - $walkover = get_post_meta( $post->ID, '_wpcm_walkover', true ); - - if( $sport == 'cricket' ){ - $wpcm_match_runs = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, '_wpcm_match_runs', true ) ) ); - $wpcm_match_extras = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, '_wpcm_match_extras', true ) ) ); - $wpcm_match_wickets = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, '_wpcm_match_wickets', true ) ) ); - $wpcm_match_overs = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, '_wpcm_match_overs', true ) ) ); + $walkover = get_post_meta( $post->ID, '_wpcm_walkover', true ); + + if ( 'cricket' == $sport ) { + $wpcm_match_runs = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, '_wpcm_match_runs', true ) ) ); + $wpcm_match_extras = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, '_wpcm_match_extras', true ) ) ); + $wpcm_match_wickets = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, '_wpcm_match_wickets', true ) ) ); + $wpcm_match_overs = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, '_wpcm_match_overs', true ) ) ); $wpcm_cricket_outcome = get_post_meta( $post->ID, '_wpcm_cricket_outcome', true ); - if( ! is_array($wpcm_cricket_outcome) ) { + if ( ! is_array( $wpcm_cricket_outcome ) ) { $wpcm_cricket_outcome = array( 0 => '', 1 => '', 2 => '' ); }; - }else{ - $goals = array_merge( array( 'total' => array( 'home' => '0', 'away' => '0' ) ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); + } else { + $goals = array_merge( array( + 'total' => array( + 'home' => '0', + 'away' => '0' + ) + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); } - if ( $sport !== 'volleyball' || $sport !== 'baseball' ) { + if ( ! in_array( $sport, array( 'volleyball', 'baseball' ) ) ) { $overtime = get_post_meta( $post->ID, 'wpcm_overtime', true ); } - if ( $sport == 'hockey' || $sport == 'handball' ) { + if ( in_array( $sport, array( 'hockey', 'handball' ) ) ) { $shootout = get_post_meta( $post->ID, 'wpcm_shootout', true ); } - if ( $sport == 'soccer' ) { - $shootout = get_post_meta( $post->ID, 'wpcm_shootout', true ); - $shootout_score = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_shootout_score', true ) ) ); + if ( 'soccer' == $sport ) { + $shootout = get_post_meta( $post->ID, 'wpcm_shootout', true ); + $shootout_score = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_shootout_score', true ) ) ); } - if( $sport == 'rugby' ){ - $bonus = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_bonus', true ) ) ); + if ( 'rugby' == $sport ) { + $bonus = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_bonus', true ) ) ); } - if( $sport == 'gaelic' ){ - $gaa_goals = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_gaa_goals', true ) ) ); - $gaa_points = array_merge( array( 'home' => '0', 'away' => '0' ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_gaa_points', true ) ) ); + if ( 'gaelic' === $sport) { + $gaa_goals = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_gaa_goals', true ) ) ); + $gaa_points = array_merge( array( + 'home' => '0', + 'away' => '0' + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_gaa_points', true ) ) ); } ?>

    - '_wpcm_walkover', 'value' => $walkover, 'class' => 'chosen_select', 'label' => '', 'wrapper_class' => 'wpcm-postponed-result', 'options' => array( - '' => __( 'To be rescheduled', 'wp-club-manager' ), - 'home_win' => __( 'Home win', 'wp-club-manager' ), - 'away_win' => __( 'Away win', 'wp-club-manager' ) - ) ) ); ?> + '_wpcm_walkover', + 'value' => $walkover, + 'class' => 'chosen_select', + 'label' => '', + 'wrapper_class' => 'wpcm-postponed-result', + 'options' => array( + '' => __( 'To be rescheduled', 'wp-club-manager' ), + 'home_win' => __( 'Home win', 'wp-club-manager' ), + 'away_win' => __( 'Away win', 'wp-club-manager' ) + ) + ) ); ?>
    - + - - +
    + - - + + - - + + array( 'home' => '0', 'away' => '0' ) ), array( 'q2' => array( 'home' => '0', 'away' => '0' ) ), array( 'q3' => array( 'home' => '0', 'away' => '0' ) ), array( 'q4' => array( 'home' => '0', 'away' => '0' ) ), array( 'q5' => array( 'home' => '0', 'away' => '0' ) ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); ?> + if ( 'volleyball' === $sport ) : + + $box_goals = array_merge( array( + 'q1' => array( + 'home' => '0', + 'away' => '0' + ) + ), array( 'q2' => array( 'home' => '0', 'away' => '0' ) ), array( + 'q3' => array( + 'home' => '0', + 'away' => '0' + ) + ), array( 'q4' => array( 'home' => '0', 'away' => '0' ) ), array( + 'q5' => array( + 'home' => '0', + 'away' => '0' + ) + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); ?> - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + array( 'home' => '0', 'away' => '0' ) ), array( 'q2' => array( 'home' => '0', 'away' => '0' ) ), array( 'q3' => array( 'home' => '0', 'away' => '0' ) ), array( 'q4' => array( 'home' => '0', 'away' => '0' ) ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); ?> + elseif ( in_array( $sport, array( 'basketball', 'football', 'footy' ) ) ) : + + $box_goals = array_merge( array( + 'q1' => array( + 'home' => '0', + 'away' => '0' + ) + ), array( 'q2' => array( 'home' => '0', 'away' => '0' ) ), array( + 'q3' => array( + 'home' => '0', + 'away' => '0' + ) + ), array( + 'q4' => array( + 'home' => '0', + 'away' => '0' + ) + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); ?> - - - + + + - - - + + + - - - + + + - - - + + + array( 'home' => '0', 'away' => '0' ) ), array( 'q2' => array( 'home' => '0', 'away' => '0' ) ), array( 'q3' => array( 'home' => '0', 'away' => '0' ) ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); ?> + elseif ( in_array( $sport, array( 'hockey', 'floorball' ) ) ) : + + $box_goals = array_merge( array( + 'q1' => array( + 'home' => '0', + 'away' => '0' + ), + ), array( + 'q2' => array( + 'home' => '0', + 'away' => '0', + ), + ), array( + 'q3' => array( + 'home' => '0', + 'away' => '0', + ), + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); + ?> - - - + + + - - - + + + - - - + + + - array( 'home' => '0', 'away' => '0' ) ), (array)unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); ?> + $box_goals = array_merge( array( + 'q1' => array( + 'home' => '0', + 'away' => '0', + ), + ), (array) unserialize( get_post_meta( $post->ID, 'wpcm_goals', true ) ) ); + ?> - - - + + + - + - -
     
    +
    - + + if ( get_option( 'wpcm_match_box_scores' ) != 'yes' ) { + ?> - - - - - + + + + + - + if ( 'cricket' === $sport ) { + ?> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - ID ); ?> - - - - - + ID ); ?> + + + + +
     
     
    - +

    - +

    'cricket_outcome_0', - 'value' => $wpcm_cricket_outcome[0], - 'class' => 'chosen_select_outcome', - 'label' => '', + 'id' => 'cricket_outcome_0', + 'value' => $wpcm_cricket_outcome[0], + 'class' => 'chosen_select_outcome', + 'label' => '', 'wrapper_class' => 'wpcm_cricket_outcome', - 'options' => array( - '' => '', - 'won_by' => __( 'Won by', 'wp-club-manager' ), + 'options' => array( + '' => '', + 'won_by' => __( 'Won by', 'wp-club-manager' ), 'lost_by' => __( 'Lost by', 'wp-club-manager' ), - 'drawn' => __( 'Draw', 'wp-club-manager' ) - ) - )); + 'drawn' => __( 'Draw', 'wp-club-manager' ), + ), + ) ); ?> - + 'cricket_outcome_2', - 'value' => $wpcm_cricket_outcome[2], - 'class' => 'chosen_select_outcome', - 'label' => '', + 'id' => 'cricket_outcome_2', + 'value' => $wpcm_cricket_outcome[2], + 'class' => 'chosen_select_outcome', + 'label' => '', 'wrapper_class' => 'wpcm_cricket_outcome', - 'options' => array( - '' => '', - 'runs' => __( 'runs', 'wp-club-manager' ), + 'options' => array( + '' => '', + 'runs' => __( 'runs', 'wp-club-manager' ), 'wickets' => __( 'wickets', 'wp-club-manager' ), - 'innings' => __( 'innings', 'wp-club-manager' ) - ) - )); + 'innings' => __( 'innings', 'wp-club-manager' ), + ), + ) ); ?>
    - + - - - - - + + + + +
    - + - - - - - - - - - - + + + + + + + + + +
    - +

    - +

    - +

    - - - - - + + + + +
    @@ -377,91 +535,114 @@ public static function output( $post ) {
    - ID ); - + ID ); } /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - $sport = get_option('wpcm_sport'); + $sport = get_option( 'wpcm_sport', '' ); - if( ! empty( $_POST['wpcm_played'] ) ) { - update_post_meta( $post_id, 'wpcm_played', $_POST['wpcm_played'] ); + $played = filter_input( INPUT_POST, 'wpcm_played', FILTER_UNSAFE_RAW ); + if ( $played ) { + update_post_meta( $post_id, 'wpcm_played', sanitize_text_field( $played ) ); } else { update_post_meta( $post_id, 'wpcm_played', '' ); } - if( ! empty( $_POST['_wpcm_postponed'] ) ) { - update_post_meta( $post_id, '_wpcm_postponed', $_POST['_wpcm_postponed'] ); + + $postponed = filter_input( INPUT_POST, '_wpcm_postponed', FILTER_UNSAFE_RAW ); + if ( $postponed ) { + update_post_meta( $post_id, '_wpcm_postponed', sanitize_text_field( $postponed ) ); } else { update_post_meta( $post_id, '_wpcm_postponed', '' ); } - if( isset( $_POST['_wpcm_walkover'] ) ) { - update_post_meta( $post_id, '_wpcm_walkover', $_POST['_wpcm_walkover'] ); + + $walkover = filter_input( INPUT_POST, '_wpcm_walkover', FILTER_UNSAFE_RAW ); + if ( $walkover ) { + update_post_meta( $post_id, '_wpcm_walkover', $walkover ); } - if ( $sport == 'cricket' ) { - if( isset( $_POST['wpcm_match_runs'] ) ) { - $wpcm_match_runs = $_POST['wpcm_match_runs']; + + if ( 'cricket' == $sport ) { + + $wpcm_match_runs = filter_input( INPUT_POST, 'wpcm_match_runs', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $wpcm_match_runs ) { update_post_meta( $post_id, '_wpcm_match_runs', serialize( $wpcm_match_runs ) ); } - if( isset( $_POST['wpcm_match_extras'] ) ) { - $wpcm_match_extras = $_POST['wpcm_match_extras']; + $wpcm_match_extras = filter_input( INPUT_POST, 'wpcm_match_extras', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( isset( $_POST['wpcm_match_extras'] ) ) { update_post_meta( $post_id, '_wpcm_match_extras', serialize( $wpcm_match_extras ) ); } - if( isset( $_POST['wpcm_match_wickets'] ) ) { - $wpcm_match_wickets = $_POST['wpcm_match_wickets']; + $wpcm_match_wickets = filter_input( INPUT_POST, 'wpcm_match_wickets', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( isset( $_POST['wpcm_match_wickets'] ) ) { update_post_meta( $post_id, '_wpcm_match_wickets', serialize( $wpcm_match_wickets ) ); } - if( isset( $_POST['wpcm_match_overs'] ) ) { - $wpcm_match_overs = $_POST['wpcm_match_overs']; + $wpcm_match_overs = filter_input( INPUT_POST, 'wpcm_match_overs', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( isset( $_POST['wpcm_match_overs'] ) ) { update_post_meta( $post_id, '_wpcm_match_overs', serialize( $wpcm_match_overs ) ); } - if( $_POST['cricket_outcome_0'] != '' ) { - $outcome_0 = $_POST['cricket_outcome_0']; - $outcome_1 = $_POST['cricket_outcome_1']; - $outcome_2 = $_POST['cricket_outcome_2']; + + $cricket_outcome = filter_input( INPUT_POST, 'cricket_outcome_0', FILTER_UNSAFE_RAW ); + if ( $cricket_outcome && '' != $cricket_outcome ) { + $outcome_0 = sanitize_text_field( $cricket_outcome ); + $cricket_outcome_1 = filter_input( INPUT_POST, 'cricket_outcome_1', FILTER_UNSAFE_RAW ); + $cricket_outcome_2 = filter_input( INPUT_POST, 'cricket_outcome_2', FILTER_UNSAFE_RAW ); + $outcome_1 = sanitize_text_field( $cricket_outcome_1 ); + $outcome_2 = sanitize_text_field( $cricket_outcome_2 ); $cricket_outcome = array( $outcome_0, $outcome_1, $outcome_2 ); update_post_meta( $post_id, '_wpcm_cricket_outcome', $cricket_outcome ); } } else { - if( isset( $_POST['wpcm_goals'] ) ) { - $goals = $_POST['wpcm_goals']; + $goals = filter_input( INPUT_POST, 'wpcm_goals', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $goals ) { update_post_meta( $post_id, 'wpcm_goals', serialize( $goals ) ); update_post_meta( $post_id, 'wpcm_home_goals', $goals['total']['home'] ); update_post_meta( $post_id, 'wpcm_away_goals', $goals['total']['away'] ); } } - if ( $sport == 'rugby' && isset( $_POST['wpcm_bonus'] ) ) { - $bonus = $_POST['wpcm_bonus']; + $bonus = filter_input( INPUT_POST, 'wpcm_bonus', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( 'rugby' == $sport && $bonus ) { update_post_meta( $post_id, 'wpcm_bonus', serialize( $bonus ) ); update_post_meta( $post_id, 'wpcm_home_bonus', $bonus['home'] ); update_post_meta( $post_id, 'wpcm_away_bonus', $bonus['away'] ); } - if ( $sport !== 'volleyball' && isset( $_POST['wpcm_overtime'] ) || $sport !== 'baseball' && isset( $_POST['wpcm_overtime'] ) ) { - update_post_meta( $post_id, 'wpcm_overtime', $_POST['wpcm_overtime'] ); + + $overtime = filter_input( INPUT_POST, 'wpcm_overtime', FILTER_UNSAFE_RAW ); + if ( $overtime && ! in_array( $sport, array( 'volleyball', 'baseball' ) ) ) { + update_post_meta( $post_id, 'wpcm_overtime', sanitize_text_field( $overtime ) ); } - if ( $sport == 'hockey' && isset( $_POST['wpcm_shootout'] ) || $sport == 'handball' && isset( $_POST['wpcm_shootout'] ) ) { - update_post_meta( $post_id, 'wpcm_shootout', $_POST['wpcm_shootout'] ); + + $shootout = filter_input( INPUT_POST, 'wpcm_shootout', FILTER_UNSAFE_RAW ); + if ( $shootout && in_array( $sport, array( 'hockey', 'handball' ) ) ) { + update_post_meta( $post_id, 'wpcm_shootout', sanitize_text_field( $shootout ) ); } - if ( $sport == 'soccer' && isset( $_POST['wpcm_shootout'] ) ) { - update_post_meta( $post_id, 'wpcm_shootout', $_POST['wpcm_shootout'] ); - $shootout_score = $_POST['wpcm_shootout_score']; + + if ( 'soccer' === $sport && $shootout ) { + update_post_meta( $post_id, 'wpcm_shootout', sanitize_text_field( $shootout ) ); + $shootout_score = filter_input( INPUT_POST, 'wpcm_shootout_score', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); update_post_meta( $post_id, '_wpcm_shootout_score', serialize( $shootout_score ) ); update_post_meta( $post_id, '_wpcm_home_shootout_goals', $shootout_score['home'] ); update_post_meta( $post_id, '_wpcm_away_shootout_goals', $shootout_score['away'] ); } - if ( $sport == 'gaelic' ) { - if( isset( $_POST['wpcm_gaa_goals'] ) ) { - $gaa_goals = $_POST['wpcm_gaa_goals']; + + if ( 'gaelic' === $sport ) { + $gaa_goals = filter_input( INPUT_POST, 'wpcm_gaa_goals', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $gaa_goals ) { update_post_meta( $post_id, 'wpcm_gaa_goals', serialize( $gaa_goals ) ); update_post_meta( $post_id, 'wpcm_home_gaa_goals', $gaa_goals['home'] ); update_post_meta( $post_id, 'wpcm_away_gaa_goals', $gaa_goals['away'] ); } - if( isset( $_POST['wpcm_gaa_points'] ) ) { - $gaa_points = $_POST['wpcm_gaa_points']; + $gaa_points = filter_input( INPUT_POST, 'wpcm_gaa_points', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $gaa_points ) { update_post_meta( $post_id, 'wpcm_gaa_points', serialize( $gaa_points ) ); update_post_meta( $post_id, 'wpcm_home_gaa_points', $gaa_points['home'] ); update_post_meta( $post_id, 'wpcm_away_gaa_points', $gaa_points['away'] ); @@ -470,4 +651,4 @@ public static function save( $post_id, $post ) { do_action( 'delete_plugin_transients' ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-video.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-video.php index d78790a..07cdec7 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-video.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-match-video.php @@ -19,6 +19,8 @@ class WPCM_Meta_Box_Match_Video { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -28,32 +30,39 @@ public static function output( $post ) { if ( $video ) : ?>
    - -

    + +

    -

    +

    - + '_wpcm_player_club', @@ -75,14 +80,14 @@ public static function output( $post ) { // if ( get_option( 'wpcm_player_profile_show_position' ) == 'yes') { ?>

    - + 'wpcm_position', 'name' => 'tax_input[wpcm_position][]', 'selected' => $position_ids, 'values' => 'term_id', - 'placeholder' => sprintf( __( 'Choose %s', 'wp-club-manager' ), __( 'positions', 'wp-club-manager' ) ), + 'placeholder' => __( 'Choose positions', 'wp-club-manager' ), 'class' => 'regular-text', 'attribute' => 'multiple', 'chosen' => true, @@ -151,42 +156,43 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { - - if ( isset( $_POST['_wpcm_player_club'] ) ) { - update_post_meta( $post_id, '_wpcm_player_club', $_POST['_wpcm_player_club'] ); - } - if ( isset( $_POST['wpcm_dob'] ) ) { - update_post_meta( $post_id, 'wpcm_dob', $_POST['wpcm_dob'] ); - } - if ( isset( $_POST['_wpcm_firstname'] ) ) { - update_post_meta( $post_id, '_wpcm_firstname', $_POST['_wpcm_firstname'] ); - } - if ( isset( $_POST['_wpcm_lastname'] ) ) { - update_post_meta( $post_id, '_wpcm_lastname', $_POST['_wpcm_lastname'] ); - } - if ( isset( $_POST['wpcm_number'] ) ) { - update_post_meta( $post_id, 'wpcm_number', $_POST['wpcm_number'] ); - } - if ( isset( $_POST['wpcm_height'] ) ) { - update_post_meta( $post_id, 'wpcm_height', $_POST['wpcm_height'] ); - } - if ( isset( $_POST['wpcm_weight'] ) ) { - update_post_meta( $post_id, 'wpcm_weight', $_POST['wpcm_weight'] ); - } - if ( isset( $_POST['wpcm_natl'] ) ) { - update_post_meta( $post_id, 'wpcm_natl', $_POST['wpcm_natl'] ); - } - if ( isset( $_POST['wpcm_hometown'] ) ) { - update_post_meta( $post_id, 'wpcm_hometown', $_POST['wpcm_hometown'] ); - } - if ( isset( $_POST['wpcm_prevclubs'] ) ) { - update_post_meta( $post_id, 'wpcm_prevclubs', $_POST['wpcm_prevclubs'] ); + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; } + self::update_meta( $post_id, '_wpcm_player_club' ); + self::update_meta( $post_id, 'wpcm_dob' ); + self::update_meta( $post_id, '_wpcm_firstname' ); + self::update_meta( $post_id, '_wpcm_lastname' ); + self::update_meta( $post_id, 'wpcm_number' ); + self::update_meta( $post_id, 'wpcm_height' ); + self::update_meta( $post_id, 'wpcm_weight' ); + self::update_meta( $post_id, 'wpcm_natl' ); + self::update_meta( $post_id, 'wpcm_hometown' ); + self::update_meta( $post_id, 'wpcm_prevclubs' ); + do_action( 'wpclubmanager_after_admin_player_save', $post_id ); do_action( 'delete_plugin_transients' ); } -} \ No newline at end of file + + /** + * Update post meta + * + * @param int $post_id + * @param string $key + * + * @return void + */ + protected static function update_meta( $post_id, $key ) { + $value = filter_input( INPUT_POST, $key, FILTER_UNSAFE_RAW ); + if ( $value ) { + update_post_meta( $post_id, $key, sanitize_text_field( $value ) ); + } + } +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-display.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-display.php index 0ef12db..c15c759 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-display.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-display.php @@ -9,15 +9,20 @@ * @package WPClubManager/Admin/Meta Boxes * @version 2.0.0 */ + if ( ! defined( 'ABSPATH' ) ) { exit; } - +/** + * WPCM_Meta_Box_Player_Display + */ class WPCM_Meta_Box_Player_Display { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -29,14 +34,14 @@ public static function output( $post ) {

    $val ) : - if ( get_option( 'wpcm_show_stats_' . $key ) == 'yes' ) : + if ( 'yes' === get_option( 'wpcm_show_stats_' . $key ) ) : ?> - + - + $value ) { + $player_stats[ sanitize_text_field( $key ) ] = ''; + } update_post_meta( $post_id, '_wpcm_custom_player_stats', $player_stats ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-roster.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-roster.php index daf864a..cb7e6b7 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-roster.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-roster.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Player_Roster + */ class WPCM_Meta_Box_Player_Roster { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -44,25 +49,32 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['add_to_roster'] ) && $_POST['add_to_roster'] != null ) { + $player_id = filter_input( INPUT_POST, 'add_to_roster', FILTER_VALIDATE_INT ); + if ( $player_id ) { - $players = (array) unserialize( get_post_meta( $_POST['add_to_roster'], '_wpcm_roster_players', true ) ); + $players = (array) unserialize( get_post_meta( $player_id, '_wpcm_roster_players', true ) ); if ( ! in_array( $post_id, $players ) ) { array_push( $players, intval( $post_id ) ); - update_post_meta( $_POST['add_to_roster'], '_wpcm_roster_players', serialize( $players ) ); + update_post_meta( $player_id, '_wpcm_roster_players', serialize( $players ) ); - $seasons = wp_get_post_terms( $_POST['add_to_roster'], 'wpcm_season' ); + $seasons = wp_get_post_terms( $player_id, 'wpcm_season' ); $season = $seasons[0]->term_id; wp_set_post_terms( $post_id, $season, 'wpcm_season', true ); - $teams = wp_get_post_terms( $_POST['add_to_roster'], 'wpcm_team' ); + $teams = wp_get_post_terms( $player_id, 'wpcm_team' ); $team = $teams[0]->term_id; wp_set_post_terms( $post_id, $team, 'wpcm_team', true ); } } } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-stats.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-stats.php index 7553498..9514edb 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-stats.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-player-stats.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Player_Stats + */ class WPCM_Meta_Box_Player_Stats { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -35,7 +40,7 @@ public static function output( $post ) { ?>
    - — +
/> />
- + @@ -86,17 +91,17 @@ public static function output( $post ) { foreach ( $players as $player ) { ?> - + @@ -119,10 +124,10 @@ public static function output( $post ) { )); ?> - + - + @@ -131,11 +136,17 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['wpcm_roster_players'] ) ) { - $players = $_POST['wpcm_roster_players']; + $players = filter_input( INPUT_POST, 'wpcm_roster_players', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $players ) { if ( is_array( $players ) ) { $teams = wp_get_post_terms( $post_id, 'wpcm_team' ); $team = $teams[0]->term_id; @@ -152,4 +163,4 @@ public static function save( $post_id, $post ) { do_action( 'delete_plugin_transients' ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-staff.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-staff.php index 1db1bf0..4a4221b 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-staff.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-roster-staff.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Roster_Staff + */ class WPCM_Meta_Box_Roster_Staff { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -70,12 +75,12 @@ public static function output( $post ) {
- - post_title; ?> + + post_title ); ?> - +
- + @@ -88,17 +93,17 @@ public static function output( $post ) { foreach ( $staff as $employee ) { ?> - + @@ -121,9 +126,9 @@ public static function output( $post ) { )); ?> - + - + @@ -132,11 +137,18 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['wpcm_roster_staff'] ) ) { - $staff = $_POST['wpcm_roster_staff']; + $staff_data = filter_input( INPUT_POST, 'wpcm_roster_staff', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); + if ( $staff_data ) { + $staff = $staff_data; } else { $staff = array(); } @@ -149,4 +161,4 @@ public static function save( $post_id, $post ) { do_action( 'delete_plugin_transients' ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-sponsor-url.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-sponsor-url.php index 9030511..e2fd410 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-sponsor-url.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-sponsor-url.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Sponsor_Url + */ class WPCM_Meta_Box_Sponsor_Url { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -34,7 +39,7 @@ public static function output( $post ) { ) ); ?> @@ -44,16 +49,24 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['wpcm_link_nw'] ) ) { - update_post_meta( $post_id, 'wpcm_link_nw', $_POST['wpcm_link_nw'] ); + $link_nw = filter_input( INPUT_POST, 'wpcm_link_nw', FILTER_UNSAFE_RAW ); + if ( isset( $link_nw ) ) { + update_post_meta( $post_id, 'wpcm_link_nw', sanitize_text_field( $link_nw ) ); } - if ( isset( $_POST['wpcm_link_url'] ) ) { - update_post_meta( $post_id, 'wpcm_link_url', $_POST['wpcm_link_url'] ); + $link_url = filter_input( INPUT_POST, 'wpcm_link_url', FILTER_UNSAFE_RAW ); + if ( isset( $link_url ) ) { + update_post_meta( $post_id, 'wpcm_link_url', sanitize_text_field( $link_url ) ); } do_action( 'wpclubmanager_after_admin_sponsors_save', $post_id ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-details.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-details.php index 681da47..3319143 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-details.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-details.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Staff_Details + */ class WPCM_Meta_Box_Staff_Details { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -50,7 +55,7 @@ public static function output( $post ) { if ( is_league_mode() ) { ?>

- + '_wpcm_staff_club', @@ -69,14 +74,14 @@ public static function output( $post ) { // if ( get_option( 'wpcm_staff_profile_show_jobs' ) == 'yes') { ?>

- + 'wpcm_jobs', 'name' => 'tax_input[wpcm_jobs][]', 'selected' => $job_ids, 'values' => 'term_id', - 'placeholder' => sprintf( __( 'Choose %s', 'wp-club-manager' ), __( 'jobs', 'wp-club-manager' ) ), + 'placeholder' => __( 'Choose jobs', 'wp-club-manager' ), 'class' => '', 'attribute' => 'multiple', 'chosen' => true, @@ -135,36 +140,57 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['_wpcm_staff_club'] ) ) { - update_post_meta( $post_id, '_wpcm_staff_club', $_POST['_wpcm_staff_club'] ); + $club = filter_input( INPUT_POST, '_wpcm_staff_club', FILTER_UNSAFE_RAW ); + if ( $club ) { + update_post_meta( $post_id, '_wpcm_staff_club', sanitize_text_field( $club ) ); } - if ( isset( $_POST['wpcm_dob'] ) ) { - update_post_meta( $post_id, 'wpcm_dob', $_POST['wpcm_dob'] ); + + $dob = filter_input( INPUT_POST, 'wpcm_dob', FILTER_UNSAFE_RAW ); + if ( $dob ) { + update_post_meta( $post_id, 'wpcm_dob', sanitize_text_field( $dob ) ); } - if ( isset( $_POST['_wpcm_firstname'] ) ) { - update_post_meta( $post_id, '_wpcm_firstname', $_POST['_wpcm_firstname'] ); + + $firstname = filter_input( INPUT_POST, '_wpcm_firstname', FILTER_UNSAFE_RAW ); + if ( $firstname ) { + update_post_meta( $post_id, '_wpcm_firstname', sanitize_text_field( $firstname ) ); } - if ( isset( $_POST['_wpcm_lastname'] ) ) { - update_post_meta( $post_id, '_wpcm_lastname', $_POST['_wpcm_lastname'] ); + + $lastname = filter_input( INPUT_POST, '_wpcm_lastname', FILTER_UNSAFE_RAW ); + if ( $lastname ) { + update_post_meta( $post_id, '_wpcm_lastname', sanitize_text_field( $lastname ) ); } - if ( isset( $_POST['_wpcm_staff_email'] ) ) { - update_post_meta( $post_id, '_wpcm_staff_email', $_POST['_wpcm_staff_email'] ); + + $email = filter_input( INPUT_POST, '_wpcm_staff_email', FILTER_UNSAFE_RAW ); + if ( $email ) { + update_post_meta( $post_id, '_wpcm_staff_email', sanitize_text_field( $email ) ); } - if ( isset( $_POST['_wpcm_staff_phone'] ) ) { - update_post_meta( $post_id, '_wpcm_staff_phone', $_POST['_wpcm_staff_phone'] ); + + $phone = filter_input( INPUT_POST, '_wpcm_staff_phone', FILTER_UNSAFE_RAW ); + if ( $phone ) { + update_post_meta( $post_id, '_wpcm_staff_phone', sanitize_text_field( $phone ) ); } - if ( isset( $_POST['_wpcm_staff_hometown'] ) ) { - update_post_meta( $post_id, '_wpcm_staff_hometown', $_POST['_wpcm_staff_hometown'] ); + + $hometown = filter_input( INPUT_POST, '_wpcm_staff_hometown', FILTER_UNSAFE_RAW ); + if ( $hometown ) { + update_post_meta( $post_id, '_wpcm_staff_hometown', sanitize_text_field( $hometown ) ); } - if ( isset( $_POST['wpcm_natl'] ) ) { - update_post_meta( $post_id, 'wpcm_natl', $_POST['wpcm_natl'] ); + + $natl = filter_input( INPUT_POST, 'wpcm_natl', FILTER_UNSAFE_RAW ); + if ( $natl ) { + update_post_meta( $post_id, 'wpcm_natl', sanitize_text_field( $natl ) ); } do_action( 'wpclubmanager_after_admin_staff_save', $post_id ); do_action( 'delete_plugin_transients' ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-roster.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-roster.php index d59a29e..2157ea0 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-roster.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-staff-roster.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Staff_Roster + */ class WPCM_Meta_Box_Staff_Roster { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -38,31 +43,38 @@ public static function output( $post ) { )); ?>

- + term_id; wp_set_post_terms( $post_id, $season, 'wpcm_season', true ); - $teams = wp_get_post_terms( $_POST['add_to_roster'], 'wpcm_team' ); + $teams = wp_get_post_terms( $staff_id, 'wpcm_team' ); $team = $teams[0]->term_id; wp_set_post_terms( $post_id, $team, 'wpcm_team', true ); } } } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-details.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-details.php index ddd39c2..0686e95 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-details.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-details.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Table_Details + */ class WPCM_Meta_Box_Table_Details { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -40,7 +45,7 @@ public static function output( $post ) { } $default_club = get_default_club(); - if ( $default_club !== null && has_teams() ) { + if ( null !== $default_club && has_teams() ) { $teams = get_the_terms( $post->ID, 'wpcm_team' ); if ( is_array( $teams ) ) { $team = $teams[0]->term_id; @@ -48,9 +53,9 @@ public static function output( $post ) { $team = 0; } } ?> - +

- + 'wpcm_comp', @@ -65,7 +70,7 @@ public static function output( $post ) { ?>

- + 'wpcm_season', @@ -80,10 +85,10 @@ public static function output( $post ) { ?>

- + 'wpcm_team', @@ -107,19 +112,30 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['wpcm_table_comp'] ) ) { - wp_set_post_terms( $post_id, $_POST['wpcm_table_comp'], 'wpcm_comp' ); + $table_id = filter_input( INPUT_POST, 'wpcm_table_comp', FILTER_VALIDATE_INT ); + if ( $table_id ) { + wp_set_post_terms( $post_id, $table_id, 'wpcm_comp' ); } - if ( isset( $_POST['wpcm_table_season'] ) ) { - wp_set_post_terms( $post_id, $_POST['wpcm_table_season'], 'wpcm_season' ); + + $season_id = filter_input( INPUT_POST, 'wpcm_table_season', FILTER_VALIDATE_INT ); + if ( $season_id ) { + wp_set_post_terms( $post_id, $season_id, 'wpcm_season' ); } - if ( isset( $_POST['wpcm_table_team'] ) ) { - wp_set_post_terms( $post_id, $_POST['wpcm_table_team'], 'wpcm_team' ); + + $team_id = filter_input( INPUT_POST, 'wpcm_table_team', FILTER_VALIDATE_INT ); + if ( $team_id ) { + wp_set_post_terms( $post_id, $team_id, 'wpcm_team' ); } do_action( 'delete_plugin_transients' ); } -} \ No newline at end of file +} diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-notes.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-notes.php index f44c0be..b085270 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-notes.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-notes.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Table_Notes + */ class WPCM_Meta_Box_Table_Notes { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -32,11 +37,18 @@ public static function output( $post ) { /** * Save meta box data + * + * @param int $post_id + * @param WP_Post $post */ public static function save( $post_id, $post ) { + if ( ! check_admin_referer( 'wpclubmanager_save_data', 'wpclubmanager_meta_nonce' ) ) { + return; + } - if ( isset( $_POST['_wpcm_table_notes'] ) ) { - update_post_meta( $post_id, '_wpcm_table_notes', $_POST['_wpcm_table_notes'] ); + $notes = filter_input( INPUT_POST, '_wpcm_table_notes', FILTER_UNSAFE_RAW ); + if ( isset( $notes ) ) { + update_post_meta( $post_id, '_wpcm_table_notes', sanitize_text_field( $notes ) ); } } } diff --git a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-stats.php b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-stats.php index b2b432c..e621c6c 100644 --- a/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-stats.php +++ b/includes/admin/post-types/meta-boxes/class-wpcm-meta-box-table-stats.php @@ -14,10 +14,15 @@ exit; // Exit if accessed directly } +/** + * WPCM_Meta_Box_Table_Stats + */ class WPCM_Meta_Box_Table_Stats { /** * Output the metabox + * + * @param WP_Post $post */ public static function output( $post ) { @@ -69,7 +74,7 @@ public static function output( $post ) { $clubs = get_posts( $args ); if ( empty( $clubs ) ) { - if ( $default_club != false ) { + if ( false != $default_club ) { $selected_clubs = array( $default_club ); } else { $selected_clubs = null; @@ -113,10 +118,9 @@ public static function output( $post ) { } } - // $clubs = wpcm_club_standings_sort_by( $orderby, $clubs ); usort( $clubs, 'wpcm_sort_table_clubs' ); - if ( $order == 'ASC' ) { + if ( 'ASC' === $order ) { $clubs = array_reverse( $clubs ); } foreach ( $clubs as $key => $value ) { @@ -125,25 +129,25 @@ public static function output( $post ) {

- - post_title; ?> + + post_title ); ?> - +
- + - + - - - + + + - + - + wpcm_stats; ?> - + - - + + - - + + - + - - + + - + - + - - + + - + @@ -233,11 +237,11 @@ public static function output( $post ) { )); ?> - + - - + + __( 'Club Badge Sizes', 'wp-club-manager' ), 'type' => 'title', + /* translators: 1: regenerate thumbnails URLS. */ 'desc' => sprintf( __( 'These settings affect the actual dimensions of images in club profiles - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to regenerate your thumbnails.', 'wp-club-manager' ), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ), 'id' => 'image_options', ), diff --git a/includes/admin/settings/class-wpcm-settings-general.php b/includes/admin/settings/class-wpcm-settings-general.php index bd86331..c85257e 100644 --- a/includes/admin/settings/class-wpcm-settings-general.php +++ b/includes/admin/settings/class-wpcm-settings-general.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Settings_General' ) ) : + /** + * WPCM_Settings_General + */ class WPCM_Settings_General extends WPCM_Settings_Page { /** @@ -145,6 +148,7 @@ public function get_settings() { 'css' => 'width: 100%;max-width:350px;', 'default' => '', 'type' => 'text', + /* translators: 1: API url */ 'desc' => sprintf( __( 'Get API Key', 'wp-club-manager' ), 'https://account.mapbox.com/auth/signup/' ), ); @@ -166,6 +170,7 @@ public function get_settings() { 'css' => 'width: 100%;max-width:350px;', 'default' => '', 'type' => 'text', + /* translators: 1: API url */ 'desc' => sprintf( __( 'Get API Key', 'wp-club-manager' ), 'https://developers.google.com/maps/documentation/javascript/get-api-key' ), ); @@ -206,9 +211,10 @@ public function get_settings() { * Save settings */ public function save() { - if ( isset( $_POST['wpcm_sport'] ) && ! empty( $_POST['wpcm_sport'] ) && get_option( 'wpcm_sport' ) != $_POST['wpcm_sport'] ) { - $post = $_POST['wpcm_sport']; - $sport = WPCM()->sports->$post; + $post = filter_input( INPUT_POST, 'wpcm_sport', FILTER_UNSAFE_RAW ); + $post = sanitize_text_field( $post ); + if ( isset( $post ) && ! empty( $post ) && get_option( 'wpcm_sport' ) !== $post ) { + $sport = WPCM()->sports->{$post}; WPCM_Admin_Settings::configure_sport( $sport ); } diff --git a/includes/admin/settings/class-wpcm-settings-licenses.php b/includes/admin/settings/class-wpcm-settings-licenses.php index 5d09aa5..cc16a4c 100644 --- a/includes/admin/settings/class-wpcm-settings-licenses.php +++ b/includes/admin/settings/class-wpcm-settings-licenses.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Settings_Licenses' ) ) : + /** + * WPCM_Settings_Licenses + */ class WPCM_Settings_Licenses extends WPCM_Settings_Page { /** diff --git a/includes/admin/settings/class-wpcm-settings-matches.php b/includes/admin/settings/class-wpcm-settings-matches.php index bf9e48d..6a91f57 100644 --- a/includes/admin/settings/class-wpcm-settings-matches.php +++ b/includes/admin/settings/class-wpcm-settings-matches.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Settings_Matches' ) ) : + /** + * WPCM_Settings_Matches + */ class WPCM_Settings_Matches extends WPCM_Settings_Page { /** diff --git a/includes/admin/settings/class-wpcm-settings-page.php b/includes/admin/settings/class-wpcm-settings-page.php index beca92b..0555adc 100644 --- a/includes/admin/settings/class-wpcm-settings-page.php +++ b/includes/admin/settings/class-wpcm-settings-page.php @@ -14,13 +14,27 @@ if ( ! class_exists( 'WPCM_Settings_Page' ) ) : + /** + * WPCM_Settings_Page + */ class WPCM_Settings_Page { - protected $id = ''; + /** + * @var string + */ + protected $id = ''; + + /** + * @var string + */ protected $label = ''; /** * Add this page to settings + * + * @param array $pages + * + * @return mixed */ public function add_settings_page( $pages ) { $pages[ $this->id ] = $this->label; diff --git a/includes/admin/settings/class-wpcm-settings-players.php b/includes/admin/settings/class-wpcm-settings-players.php index fadbf9f..3b5bbc0 100644 --- a/includes/admin/settings/class-wpcm-settings-players.php +++ b/includes/admin/settings/class-wpcm-settings-players.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Settings_Players' ) ) : + /** + * WPCM_Settings_Players + */ class WPCM_Settings_Players extends WPCM_Settings_Page { /** @@ -199,6 +202,7 @@ public function get_settings() { $settings[] = array( 'title' => __( 'Player Image Sizes', 'wp-club-manager' ), 'type' => 'title', + /* translators: 1: regenerate thumbnails URLS. */ 'desc' => sprintf( __( '

These settings affect the actual dimensions of images in player and staff profiles - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to regenerate your thumbnails.

', 'wp-club-manager' ), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ), 'id' => 'image_options', ); diff --git a/includes/admin/settings/class-wpcm-settings-staff.php b/includes/admin/settings/class-wpcm-settings-staff.php index 930c09d..d747e1c 100644 --- a/includes/admin/settings/class-wpcm-settings-staff.php +++ b/includes/admin/settings/class-wpcm-settings-staff.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Settings_Staff' ) ) : + /** + * WPCM_Settings_Staff + */ class WPCM_Settings_Staff extends WPCM_Settings_Page { /** @@ -144,6 +147,7 @@ public function get_settings() { $settings[] = array( 'title' => __( 'Staff Image Sizes', 'wp-club-manager' ), 'type' => 'title', + /* translators: 1: regenerate thumbnails URLS. */ 'desc' => sprintf( __( 'These settings affect the actual dimensions of images in player and staff profiles - the display on the front-end will still be affected by CSS styles. After changing these settings you may need to regenerate your thumbnails.', 'wp-club-manager' ), 'http://wordpress.org/extend/plugins/regenerate-thumbnails/' ), 'id' => 'image_options', ); diff --git a/includes/admin/settings/class-wpcm-settings-standings.php b/includes/admin/settings/class-wpcm-settings-standings.php index 77a4dfe..c96db79 100644 --- a/includes/admin/settings/class-wpcm-settings-standings.php +++ b/includes/admin/settings/class-wpcm-settings-standings.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Settings_Standings' ) ) : + /** + * WPCM_Settings_Standings + */ class WPCM_Settings_Standings extends WPCM_Settings_Page { /** @@ -70,7 +73,7 @@ public function get_settings() { ); $sport = get_option( 'wpcm_sport' ); - if ( $sport == 'hockey' || $sport == 'basketball' ) { + if ( in_array( $sport, array( 'hockey', 'basketball' ) ) ) { $settings[] = array( 'title' => __( 'Points for overtime win', 'wp-club-manager' ), diff --git a/includes/admin/views/html-admin-page-dashboard.php b/includes/admin/views/html-admin-page-dashboard.php index a9ca970..1020f2b 100644 --- a/includes/admin/views/html-admin-page-dashboard.php +++ b/includes/admin/views/html-admin-page-dashboard.php @@ -1,11 +1,17 @@ +

'ui image' ) ); ?>
- -
name; ?>
+ +
name ); ?>

@@ -15,7 +21,7 @@
- +
@@ -52,43 +58,43 @@
- +
-
+
- +
- +
- +
- +
- +
- +
- +
- +
- +
@@ -103,12 +109,12 @@
- +
-
+
@@ -117,7 +123,7 @@ ?>
- + ID ); $opponent = wpcm_get_match_opponents( $played_match->ID, false ); $class = wpcm_get_match_outcome( $played_match->ID ); - if ( $class == 'win' ) { + if ( 'win' == $class ) { $class = 'green'; - } elseif ( $class == 'loss' ) { + } elseif ( 'loss' == $class ) { $class = 'red'; - } elseif ( $class == 'draw' ) { + } elseif ( 'draw' == $class ) { $class = 'yellow'; } ?> @@ -142,29 +148,29 @@
-
+
-
+
- - + +
- +
- +
- + - +
-

+

- + @@ -182,17 +188,17 @@
- - + +
- +
-
+
@@ -218,17 +224,17 @@
-
+
- - + +
- +
- +
@@ -238,15 +244,15 @@ ?>
- +
-

+

- + @@ -254,8 +260,8 @@
- - + +
@@ -263,10 +269,10 @@
-
+
- + @@ -274,8 +280,8 @@
- place; ?> + place ); ?> ID ) { if ( $team_label ) { - echo $team_label; + echo esc_html( $team_label ); } else { - echo $club->post_title; + echo esc_html( $club->post_title ); } } else { - echo $club->post_title; + echo esc_html( $club->post_title ); } ?> />/>
- - + + @@ -283,21 +289,21 @@ - - + + - +
ID, 'full' ); ?>ID, 'full' ) ); ?>
- +
- +
@@ -306,13 +312,13 @@ ?>
-

+

- +
- +
@@ -331,32 +337,32 @@
-
+
- +
- name; ?> + name ); ?>
- - + + - - - + + + - + ID == $default_club ? 'class="positive"' : '' ); ?>> - + - - + + - + - +
place; ?>place ); ?> ID ) { if ( $team_label ) { - echo $team_label; + echo esc_html( $team_label ); } else { - echo $club->post_title; + echo esc_html( $club->post_title ); } } else { - echo $club->post_title; + echo esc_html( $club->post_title ); } ?>
- +
@@ -407,12 +413,12 @@ ?>
-

+

- +
@@ -424,10 +430,10 @@
-
+
- + @@ -435,10 +441,10 @@ - - - - + + + + @@ -446,22 +452,22 @@ - - - - + + + + - +
ID, 'wpcm_number', true ); ?>ID, 'full' ); ?>ID ); ?>ID, 'wpcm_number', true ) ); ?>ID, 'full' ) ); ?>ID ) ); ?>
- +
@@ -470,13 +476,13 @@ ?>
-

+

- +
-
\ No newline at end of file +
diff --git a/includes/admin/views/html-admin-page-status.php b/includes/admin/views/html-admin-page-status.php index 3ef52e0..de2f8cd 100644 --- a/includes/admin/views/html-admin-page-status.php +++ b/includes/admin/views/html-admin-page-status.php @@ -11,16 +11,16 @@

- +

-

-

+

+

-

+

@@ -33,83 +33,84 @@ - + - - + + - - + + - + - - + + - + - + - + - - + +
::
::
:: version ); ?>
::
:: ' . '✓' . ''; + echo ''; } else { - echo '' . '✗' . ''; + echo ''; } ?>
:: ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: Increasing memory allocated to PHP', 'wp-club-manager' ), size_format( $memory ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . ''; + /* translators: 1: memory limit 2: URL to learn how to increase memory limit */ + echo '' . wp_kses_post( sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: Increasing memory allocated to PHP', 'wp-club-manager' ), esc_html( size_format( $memory ) ), 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) ) . ''; } else { - echo '' . size_format( $memory ) . ''; + echo '' . esc_html( size_format( $memory ) ) . ''; } ?>
:: ' . '✓' . ''; + echo ''; } else { - echo '' . '✗' . ''; + echo ''; } ?>
::
- + - - + + - + - - + + - - + + - - + + - + - - + + - + @@ -173,7 +176,7 @@
::
:: ' . sprintf( __( '%1$s - We recommend a minimum PHP version of 5.4. See: How to update your PHP version', 'wp-club-manager' ), esc_html( $php_version ), 'http://docs.woothemes.com/document/how-to-update-your-php-version/' ) . ''; + /* translators: 1: php version 2: link to update php */ + echo '' . wp_kses_post( sprintf( __( '%1$s - We recommend a minimum PHP version of 5.4. See: How to update your PHP version', 'wp-club-manager' ), esc_html( $php_version ), 'http://docs.woothemes.com/document/how-to-update-your-php-version/' ) ) . ''; } else { echo '' . esc_html( $php_version ) . ''; } } else { - _e( "Couldn't determine PHP version because phpversion() doesn't exist.", 'wp-club-manager' ); + esc_html_e( "Couldn't determine PHP version because phpversion() doesn't exist.", 'wp-club-manager' ); } ?>
::
::
::
:: db_version(); + echo esc_html( $wpdb->db_version() ); ?>
::
:: ' . '✕ ' . sprintf( __( 'Default timezone is %s - it should be UTC', 'wp-club-manager' ), $default_timezone ) . ''; + /* translators: 1: timezone */ + echo '✕ ' . sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'wp-club-manager' ), esc_html( $default_timezone ) ) . ''; } else { - echo '' . '✓' . ''; + echo ''; } ?>
- + @@ -184,10 +187,10 @@ $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); } - foreach ( $active_plugins as $plugin ) { + foreach ( $active_plugins as $active_plugin ) { - $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); - $dirname = dirname( $plugin ); + $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $active_plugin ); + $dirname = dirname( $active_plugin ); $version_string = ''; $network_string = ''; @@ -201,9 +204,14 @@ } ?> - + - + - + - + - + - +
() ()
  + +
:: - 0 ) ); - foreach ( $terms as $term ) { - $display_terms[] = strtolower( $term->name ) . ' (' . $term->slug . ')'; - } + $all_terms = get_terms( + array( + 'taxonomy' => 'wpcm_team', + 'hide_empty' => false, + ) + ); + foreach ( $all_terms as $all_term ) { + $display_terms[] = strtolower( $all_term->name ) . ' (' . $all_term->slug . ')'; + } echo implode( ', ', array_map( 'esc_html', $display_terms ) ); - ?> + ?>
:: - 0 ) ); - foreach ( $terms as $term ) { - $display_terms[] = strtolower( $term->name ) . ' (' . $term->slug . ')'; - } + $terms = get_terms( + array( + 'taxonomy' => 'wpcm_season', + 'hide_empty' => false, + ) + ); + foreach ( $terms as $all_term ) { + $display_terms[] = strtolower( $all_term->name ) . ' (' . $all_term->slug . ')'; + } echo implode( ', ', array_map( 'esc_html', $display_terms ) ); - ?> + ?>
:: 0 ) ); - foreach ( $terms as $term ) { - $display_terms[] = strtolower( $term->name ) . ' (' . $term->slug . ')'; + $display_terms = array(); + $all_terms = get_terms( + array( + 'taxonomy' => 'wpcm_comp', + 'hide_empty' => false, + ) + ); + foreach ( $all_terms as $all_term ) { + $display_terms[] = strtolower( $all_term->name ) . ' (' . $all_term->slug . ')'; } echo implode( ', ', array_map( 'esc_html', $display_terms ) ); ?> @@ -262,56 +285,56 @@ - + - - + + - - + + - - + + - + Template ); + $parent_theme = wp_get_theme( $active_theme->Template ) // phpcs:ignore; ?> - - + + - - + + - - + + - + @@ -321,7 +344,7 @@
:Name; ?>:Name ); // phpcs:ignore ?>
:Version; ?>:Version); // phpcs:ignore ?>
:{'Author URI'}; ?>:{'Author URI'} ); ?>
:: ' . '✓' . '' : '' . '✗' . ''; + echo is_child_theme() ? '' : ''; ?>
:Name; ?>:Name ); // phpcs:ignore ?>
:Version; ?>:Version ); // phpcs:ignore ?>
:{'Author URI'}; ?>:{'Author URI'} ); ?>
:: template, wpcm_get_core_supported_themes() ) ) { - echo '' . __( 'Not Declared', 'wp-club-manager' ) . ''; + echo '' . esc_html__( 'Not Declared', 'wp-club-manager' ) . ''; } else { - echo '' . '✓' . ''; + echo ''; } ?>
- + @@ -330,19 +353,19 @@ $sport = get_option( 'wpcm_sport' ); ?> - - + + - - + +
::
::
- + @@ -379,6 +402,7 @@ if ( ! $outdated_templates ) { $outdated_templates = true; } + /* translators: 1: theme url 2: theme version 3: core plugin version */ $found_files[ $plugin_name ][] = sprintf( __( '%1$s version %2$s is out of date. The core version is %3$s', 'wp-club-manager' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version ); } else { $found_files[ $plugin_name ][] = sprintf( '%s', str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ) ); @@ -391,15 +415,15 @@ foreach ( $found_files as $plugin_name => $found_plugin_files ) { ?> - - + + - + \ No newline at end of file + diff --git a/includes/admin/views/html-admin-settings.php b/includes/admin/views/html-admin-settings.php index f0a697a..b1384e1 100644 --- a/includes/admin/views/html-admin-settings.php +++ b/includes/admin/views/html-admin-settings.php @@ -1,10 +1,16 @@ +
-

+

- \ No newline at end of file + diff --git a/includes/admin/views/html-admin-sidebar.php b/includes/admin/views/html-admin-sidebar.php index c30c5c1..8ae39ba 100644 --- a/includes/admin/views/html-admin-sidebar.php +++ b/includes/admin/views/html-admin-sidebar.php @@ -1,10 +1,15 @@ -
+ +?> +
+

Victory Theme

- plugin_url() . '/assets/images/admin/wpcm-victory-preview.jpg" style="max-width:100%" />'; ?> + plugin_url() ) . '/assets/images/admin/wpcm-victory-preview.jpg" style="max-width:100%" />'; ?>

A clean, versatile theme, Victory integrates seamlessly with WP Club Manager to give your sports club website a fresh new look.

Check it out!

Get 25% off with this code:
25PERCENT

@@ -24,4 +29,4 @@
-
\ No newline at end of file +
diff --git a/includes/admin/views/html-bulk-edit-match.php b/includes/admin/views/html-bulk-edit-match.php index df27770..5a6cb74 100644 --- a/includes/admin/views/html-bulk-edit-match.php +++ b/includes/admin/views/html-bulk-edit-match.php @@ -12,18 +12,18 @@
-

+

-
\ No newline at end of file + diff --git a/includes/admin/views/html-notice-club-check.php b/includes/admin/views/html-notice-club-check.php index 96397ed..6459077 100644 --- a/includes/admin/views/html-notice-club-check.php +++ b/includes/admin/views/html-notice-club-check.php @@ -10,8 +10,8 @@ ?>
-

You have not set a Default Club! Some features of WP Club Manager will not work without a default club set, please choose your default club now.', 'wp-club-manager' ); ?>

+

You have not set a Default Club! Some features of WP Club Manager will not work without a default club set, please choose your default club now.', 'wp-club-manager' ); ?>

- +

-
\ No newline at end of file + diff --git a/includes/admin/views/html-notice-cricket-addon.php b/includes/admin/views/html-notice-cricket-addon.php index 9a69154..748d5a1 100644 --- a/includes/admin/views/html-notice-cricket-addon.php +++ b/includes/admin/views/html-notice-cricket-addon.php @@ -8,9 +8,9 @@ } ?>
-

-

+

+

- +

-
\ No newline at end of file + diff --git a/includes/admin/views/html-notice-install.php b/includes/admin/views/html-notice-install.php index 118895a..97cab32 100644 --- a/includes/admin/views/html-notice-install.php +++ b/includes/admin/views/html-notice-install.php @@ -11,16 +11,21 @@

- + + +

- +

- +

- +

-
\ No newline at end of file + diff --git a/includes/admin/views/html-notice-template-check.php b/includes/admin/views/html-notice-template-check.php index 446a5a1..000f2db 100644 --- a/includes/admin/views/html-notice-template-check.php +++ b/includes/admin/views/html-notice-template-check.php @@ -10,7 +10,7 @@ ?>
-

-

learn more about WP Club Manager Template Structure here.', 'wp-club-manager' ); ?>

-

+

+

learn more about WP Club Manager Template Structure here.', 'wp-club-manager' ); ?>

+

diff --git a/includes/admin/views/html-notice-theme-support.php b/includes/admin/views/html-notice-theme-support.php index 71ccda7..9973f8b 100644 --- a/includes/admin/views/html-notice-theme-support.php +++ b/includes/admin/views/html-notice-theme-support.php @@ -11,12 +11,12 @@

-
- +
+

- - - + + +

diff --git a/includes/admin/views/html-notice-update.php b/includes/admin/views/html-notice-update.php index 3489823..d3305c6 100644 --- a/includes/admin/views/html-notice-update.php +++ b/includes/admin/views/html-notice-update.php @@ -10,12 +10,12 @@ ?>
-

WP Club Manager Data Update Required – We just need to update your install to the latest version', 'wp-club-manager' ); ?>

-

+

WP Club Manager Data Update Required – We just need to update your install to the latest version', 'wp-club-manager' ); ?>

+

diff --git a/includes/admin/views/html-notice-version-update.php b/includes/admin/views/html-notice-version-update.php index 89d33ba..3bc5f58 100644 --- a/includes/admin/views/html-notice-version-update.php +++ b/includes/admin/views/html-notice-version-update.php @@ -11,20 +11,25 @@

- + + +

- +

    -
  • -
  • -
  • +
  • +
  • +
-
- +
+

', '' ); ?> @@ -43,9 +49,10 @@ if ( in_array( 'wpcm-players-gallery/wpcm-player-gallery.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { ?>

- + ', '' ); ?> @@ -56,9 +63,10 @@ if ( in_array( 'wp-club-manager-score-summary/wpcm-score-summary.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { ?>

- + ', '' ); ?> @@ -68,6 +76,6 @@ ?>

- +

-
\ No newline at end of file + diff --git a/includes/admin/views/html-quick-edit-match.php b/includes/admin/views/html-quick-edit-match.php index 229a09b..2c16efb 100644 --- a/includes/admin/views/html-quick-edit-match.php +++ b/includes/admin/views/html-quick-edit-match.php @@ -11,8 +11,8 @@
- - + +
@@ -21,12 +21,12 @@
@@ -117,21 +117,21 @@
- +
():', $found_plugin_files ); ?> ():', $found_plugin_files ) ); ?>
::
- - + + - + @@ -143,6 +143,6 @@ - + diff --git a/includes/admin/views/html-quick-edit-player.php b/includes/admin/views/html-quick-edit-player.php index a84d15e..ce031f5 100644 --- a/includes/admin/views/html-quick-edit-player.php +++ b/includes/admin/views/html-quick-edit-player.php @@ -11,8 +11,8 @@
- - + +
@@ -20,14 +20,14 @@
diff --git a/includes/admin/views/html-quick-edit-staff.php b/includes/admin/views/html-quick-edit-staff.php index 624cc37..d30f2e9 100644 --- a/includes/admin/views/html-quick-edit-staff.php +++ b/includes/admin/views/html-quick-edit-staff.php @@ -11,8 +11,8 @@
- - + +
@@ -20,14 +20,14 @@
diff --git a/includes/admin/wpcm-admin-functions.php b/includes/admin/wpcm-admin-functions.php index 5c5520f..95479c3 100644 --- a/includes/admin/wpcm-admin-functions.php +++ b/includes/admin/wpcm-admin-functions.php @@ -83,7 +83,9 @@ function wpclubmanager_update_options( $options ) { /** * Get a setting from the settings API. * - * @param mixed $option + * @param string $option_name + * @param string $default + * * @return string */ function wpclubmanager_settings_get_option( $option_name, $default = '' ) { diff --git a/includes/admin/wpcm-meta-box-functions.php b/includes/admin/wpcm-meta-box-functions.php index ad896fb..50cfd70 100644 --- a/includes/admin/wpcm-meta-box-functions.php +++ b/includes/admin/wpcm-meta-box-functions.php @@ -32,7 +32,9 @@ function wpclubmanager_wp_text_input( $field ) { $field['maxlength'] = isset( $field['maxlength'] ) ? $field['maxlength'] : ''; ( ! empty( $field['maxlength'] ) ? $maxlength = 'maxlength="' . esc_attr( $field['maxlength'] ) . '"' : $maxlength = '' ); - echo '

'; + echo '

'; + echo ''; + echo ' '; if ( ! empty( $field['description'] ) ) { @@ -244,7 +246,7 @@ function wpclubmanager_wp_country_select( $field ) { echo '

'; - echo ''; WPCM()->countries->country_dropdown_options( $country ); diff --git a/includes/class-wp-club-manager.php b/includes/class-wp-club-manager.php index 9e9742f..bccb504 100644 --- a/includes/class-wp-club-manager.php +++ b/includes/class-wp-club-manager.php @@ -210,7 +210,7 @@ private function includes() { require_once WPCM_PATH . 'includes/class-wpcm-post-types.php'; require_once WPCM_PATH . 'includes/class-wpcm-countries.php'; require_once WPCM_PATH . 'includes/class-wpcm-geocoder.php'; - require_once WPCM_PATH . 'includes/class-wpcm-license-handler.php'; + require_once WPCM_PATH . 'includes/class-wpcm-license.php'; require_once WPCM_PATH . 'includes/libraries/tgm-plugin-activation/class-tgm-plugin-activation.php'; } diff --git a/includes/class-wpcm-ajax.php b/includes/class-wpcm-ajax.php index c82f00c..682973c 100644 --- a/includes/class-wpcm-ajax.php +++ b/includes/class-wpcm-ajax.php @@ -15,6 +15,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_AJAX + */ class WPCM_AJAX { /** @@ -46,52 +49,52 @@ public function __construct() { } /** - * match_list_shortcode_ajax function. + * Match_list_shortcode_ajax function. */ public function match_opponents_shortcode() { ?>

- - + +

- +

- + 'id', 'id' => 'id', 'post_type' => 'wpcm_club', - 'limit' => -1, + 'limit' => - 1, 'class' => 'chosen_select', - )); + ) ); ?>

- - + +

- + 'wpcm_comp', - 'show_option_none' => __( 'All', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'All', 'wp-club-manager' ), 'option_none_value' => '', 'hide_empty' => false, 'meta_key' => 'tax_position', @@ -105,11 +108,11 @@ public function match_opponents_shortcode() { ?>

- + 'wpcm_season', - 'show_option_none' => __( 'All', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'All', 'wp-club-manager' ), 'option_none_value' => '', 'hide_empty' => false, 'meta_key' => 'tax_position', @@ -123,11 +126,11 @@ public function match_opponents_shortcode() { ?>

- + 'wpcm_team', - 'show_option_none' => __( 'All', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'All', 'wp-club-manager' ), 'option_none_value' => '', 'hide_empty' => false, 'meta_key' => 'tax_position', @@ -157,33 +160,33 @@ public function match_opponents_shortcode() { '12' => __( 'December', 'wp-club-manager' ), ); ?> - +

- +

- +

- + __( 'Abbreviation', 'wp-club-manager' ), @@ -197,22 +200,23 @@ public function match_opponents_shortcode() { foreach ( $columns as $key => $value ) { ?> -

- - + +

- + __( 'None', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'None', 'wp-club-manager' ), 'name' => 'linkpage', 'id' => 'linkpage', ) ); @@ -221,8 +225,11 @@ public function match_opponents_shortcode() {

- - + +

@@ -232,7 +239,7 @@ public function match_opponents_shortcode() { } /** - * match_list_shortcode_ajax function. + * Match_list_shortcode_ajax function. */ public function match_list_shortcode() { @@ -240,27 +247,27 @@ public function match_list_shortcode() {

- - + +

- +

- - + +

- + 'wpcm_comp', - 'show_option_none' => __( 'All', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'All', 'wp-club-manager' ), 'option_none_value' => '', 'hide_empty' => false, 'meta_key' => 'tax_position', @@ -274,11 +281,11 @@ public function match_list_shortcode() { ?>

- + 'wpcm_season', - 'show_option_none' => __( 'All', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'All', 'wp-club-manager' ), 'option_none_value' => '', 'hide_empty' => false, 'meta_key' => 'tax_position', @@ -295,11 +302,11 @@ public function match_list_shortcode() { if ( is_club_mode() ) { ?>

- + 'wpcm_team', - 'show_option_none' => __( 'All', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'All', 'wp-club-manager' ), 'option_none_value' => '', 'hide_empty' => false, 'meta_key' => 'tax_position', @@ -332,13 +339,13 @@ public function match_list_shortcode() { '12' => __( 'December', 'wp-club-manager' ), ); ?> - +

@@ -346,25 +353,25 @@ public function match_list_shortcode() { if ( is_club_mode() ) { ?>

- +

- +

- + __( 'Abbreviation', 'wp-club-manager' ), @@ -377,22 +384,23 @@ public function match_list_shortcode() { $columns['show_venue'] = __( 'Venue', 'wp-club-manager' ); foreach ( $columns as $key => $value ) { ?> -

- - + +

- + __( 'None', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'None', 'wp-club-manager' ), 'name' => 'linkpage', 'id' => 'linkpage', ) ); @@ -401,8 +409,11 @@ public function match_list_shortcode() {

- - + +

@@ -420,52 +431,52 @@ public function player_list_shortcode() { $stats = wpcm_get_player_all_names(); $defaults = array( 'number', 'name', 'thumb', 'position' ) ?> - +

- - + +

- + 'id', 'id' => 'id', 'post_type' => 'wpcm_roster', - 'limit' => -1, + 'limit' => - 1, 'class' => 'chosen_select', - )); + ) ); ?>

- + 'id', 'id' => 'id', 'post_type' => 'wpcm_club', - 'limit' => -1, + 'limit' => - 1, 'class' => 'chosen_select', 'show_option_none' => __( 'All', 'wp-club-manager' ), 'option_none_value' => '', - )); + ) ); ?>

- - + +

- +

- + 'wpcm_position', @@ -483,58 +494,59 @@ public function player_list_shortcode() { ?>

- +

- +

- +

- +
$value ) { ?> -

- - + +

- + __( 'None', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'None', 'wp-club-manager' ), 'name' => 'linkpage', 'id' => 'linkpage', ) ); @@ -543,10 +555,13 @@ public function player_list_shortcode() {

- - + +

- +
- +

- - + +

- + 'id', 'id' => 'id', 'post_type' => 'wpcm_roster', - 'limit' => -1, + 'limit' => - 1, 'class' => 'chosen_select', - )); + ) ); ?>

- + 'id', 'id' => 'id', 'post_type' => 'wpcm_club', - 'limit' => -1, + 'limit' => - 1, 'class' => 'chosen_select', - )); + ) ); ?>

- - + +

- +

- + 'wpcm_jobs', - 'show_option_none' => __( 'All', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'All', 'wp-club-manager' ), 'option_none_value' => '', 'hide_empty' => false, 'meta_key' => 'tax_position', @@ -752,48 +770,49 @@ public function staff_list_shortcode() { ?>

- +

- +

- +

- +
$value ) { ?> -

- - + +

- + __( 'None', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'None', 'wp-club-manager' ), 'name' => 'linkpage', 'id' => 'linkpage', ) ); @@ -802,10 +821,13 @@ public function staff_list_shortcode() {

- - + +

- + - +

- - + +

- + 'id', 'id' => 'id', 'post_type' => 'wpcm_table', - 'limit' => -1, + 'limit' => - 1, 'class' => 'chosen_select', - )); + ) ); ?>

- +

- +

- - + +

- - + +

- - + +

- - + +

- + $value ) { ?>

- - + +

- + __( 'None', 'wp-club-manager' ), + 'show_option_none' => esc_html__( 'None', 'wp-club-manager' ), 'name' => 'linkpage', 'id' => 'linkpage', ) ); @@ -1018,8 +1044,11 @@ public function league_table_shortcode() {

- - + +

@@ -1034,14 +1063,14 @@ public function league_table_shortcode() { public function map_venue_shortcode() { ?> - +

- - + +

- + 'wpcm_venue', @@ -1054,18 +1083,21 @@ public function map_venue_shortcode() { ?>

- - + +

- - + +

- - + +

@@ -1074,6 +1106,11 @@ public function map_venue_shortcode() { die(); } + /** + * Scripts + * + * @return void + */ public function scripts() { ?> @@ -1081,118 +1118,126 @@ public function scripts() { - + ' . ( $escape ? esc_js( $value ) : $value ) . ''; + echo ' value="' . esc_attr( $key ) . '">' . ( $escape ? esc_js( $value ) : $value ) . ''; // phpcs:ignore endforeach; } } diff --git a/includes/class-wpcm-frontend-scripts.php b/includes/class-wpcm-frontend-scripts.php index 68f3abc..47b3bf5 100644 --- a/includes/class-wpcm-frontend-scripts.php +++ b/includes/class-wpcm-frontend-scripts.php @@ -7,10 +7,14 @@ * @package WPClubManager/Admin * @version 2.2.0 */ + if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } +/** + * WPCM_Frontend_Scripts + */ class WPCM_Frontend_Scripts { /** @@ -60,9 +64,9 @@ public function load_scripts() { $frontend_script_path = $assets_path . 'js/frontend/'; $map_service = get_option( 'wpcm_map_select', 'google' ); - if ( $map_service == 'google' ) { + if ( 'google' === $map_service ) { wp_register_script( 'google-maps-api', '//maps.google.com/maps/api/js?sensor=false' ); - } elseif ( $map_service == 'osm' ) { + } elseif ( 'osm' === $map_service ) { wp_enqueue_script( 'leaflet-maps', $assets_path . 'js/leaflet/leaflet.js' ); } @@ -89,11 +93,11 @@ public function load_scripts() { /** * Loads the JSON-LD structured data. * + * @return void * @since 2.2.0 * @access public - * @return void */ - public function load_json_ld( $post ) { + public function load_json_ld() { global $post; diff --git a/includes/class-wpcm-geocoder.php b/includes/class-wpcm-geocoder.php index 8054364..20d3c71 100644 --- a/includes/class-wpcm-geocoder.php +++ b/includes/class-wpcm-geocoder.php @@ -14,7 +14,11 @@ exit; // Exit if accessed directly } +/** + * WPCM_Geocoder + */ class WPCM_Geocoder { + /** * Geocoder should return this on error/not found * @@ -38,12 +42,11 @@ class WPCM_Geocoder { public $lng = 0; /** - * new Geocoder from address + * New Geocoder from address * - * handles url encoding and caching + * Handles url encoding and caching * * @param string $address the requested address to look up - * @return NOTHING */ public function __construct( $address ) { @@ -69,10 +72,10 @@ public function __construct( $address ) { /** * Used by geocoders to make requests via curl or file_get_contents * - * includes a try/catch + * @param string $url * - * @param string $url the urlencoded request url - * @return varies object from API or null (failed) + * @return bool|string + * @throws Exception */ private function get_url( $url ) { $referer = get_site_url(); @@ -106,14 +109,16 @@ private function get_url( $url ) { } $error_msg = 'Could not get url: ' . $url; - throw new Exception( $error_msg ); + throw new Exception( esc_html( $error_msg ) ); } /** * Google geocoder (https://developers.google.com/maps/documentation/geocoding/start) * - * @param string $address the urlencoded address to look up - * @return varies object from API or null (failed) + * @param string $address + * + * @return object + * @throws Exception */ private function google_geocode( $address ) { @@ -126,7 +131,7 @@ private function google_geocode( $address ) { $json = json_decode( $json ); /* found location */ - if ( $json->status == 'OK' ) { + if ( 'OK' === $json->status ) { $location = $json->results[0]->geometry->location; diff --git a/includes/class-wpcm-install.php b/includes/class-wpcm-install.php index 3d2680b..c8fb26d 100644 --- a/includes/class-wpcm-install.php +++ b/includes/class-wpcm-install.php @@ -14,6 +14,9 @@ if ( ! class_exists( 'WPCM_Install' ) ) : + /** + * WPCM_Install + */ class WPCM_Install { /** @@ -68,6 +71,9 @@ public function install_actions() { } } + /** + * @return bool + */ private function is_new_install() { return is_null( get_option( 'wpclubmanager_version', null ) ); } @@ -128,6 +134,8 @@ public function install() { /** * Handle updates + * + * @param string|null $version */ public function updates( $version = null ) { @@ -163,7 +171,7 @@ public function updates( $version = null ) { * * @access public */ - function create_options() { + public function create_options() { // Include settings so that we can run through defaults include_once 'admin/class-wpcm-admin-settings.php'; @@ -201,7 +209,7 @@ public function create_roles() { } if ( ! isset( $wp_roles ) ) { - $wp_roles = new WP_Roles(); + $wp_roles = new WP_Roles(); // phpcs:ignore } // Player role @@ -317,7 +325,7 @@ public function remove_roles() { if ( class_exists( 'WP_Roles' ) ) { if ( ! isset( $wp_roles ) ) { - $wp_roles = new WP_Roles(); + $wp_roles = new WP_Roles(); // phpcs:ignore } } @@ -343,7 +351,7 @@ public function remove_roles() { * @param string $new_value * @return string */ - function pre_update_option_active_plugins( $new_value ) { + public function pre_update_option_active_plugins( $new_value ) { $old_value = (array) get_option( 'active_plugins' ); if ( $new_value !== $old_value && in_array( W3TC_FILE, (array) $new_value ) && in_array( W3TC_FILE, (array) $old_value ) ) { @@ -351,6 +359,8 @@ function pre_update_option_active_plugins( $new_value ) { try { $this->_config->save(); } catch ( Exception $ex ) { + // not handled + $test = 1; } } @@ -362,7 +372,7 @@ function pre_update_option_active_plugins( $new_value ) { * * @return void */ - function in_plugin_update_message() { + public function in_plugin_update_message() { $response = wp_remote_get( 'https://plugins.svn.wordpress.org/wp-club-manager/trunk/readme.txt' ); if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) { @@ -394,7 +404,7 @@ function in_plugin_update_message() { if ( preg_match( $regexp, $response['body'], $matches ) ) { $changelog = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) ); - _e( 'What\'s new:', 'wp-club-manager' ) . '
'; + esc_html_e( 'What\'s new:', 'wp-club-manager' ) . '
'; $ul = false; @@ -407,7 +417,7 @@ function in_plugin_update_message() { $line = preg_replace( '~^\s*\*\s*~', '', htmlspecialchars( $line ) ); - echo '
  • ' . esc_html( $line ) . '
  • '; + echo '
  • ' . esc_html( $line ) . '
  • '; } else { $version = trim( current( explode( '-', str_replace( '=', '', $line ) ) ) ); diff --git a/includes/class-wpcm-license-handler.php b/includes/class-wpcm-license.php similarity index 84% rename from includes/class-wpcm-license-handler.php rename to includes/class-wpcm-license.php index 90dd1e9..2514959 100644 --- a/includes/class-wpcm-license-handler.php +++ b/includes/class-wpcm-license.php @@ -18,12 +18,40 @@ * WPCM_License Class */ class WPCM_License { + + /** + * @var string + */ private $file; + + /** + * @var string + */ private $license; + + /** + * @var string + */ private $item_name; + + /** + * @var string + */ private $item_shortname; + + /** + * @var string + */ private $version; + + /** + * @var string + */ private $author; + + /** + * @var string + */ private $api_url = 'https://wpclubmanager.com'; /** @@ -36,7 +64,7 @@ class WPCM_License { * @param string $_optname * @param string $_api_url */ - function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) { + public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) { $this->file = $_file; $this->item_name = $_item_name; @@ -128,6 +156,7 @@ public function settings( $settings ) { $wpcm_license_settings = array( array( 'id' => $this->item_shortname . '_license_key', + /* translators: 1: item name. */ 'name' => sprintf( __( '%1$s License Key', 'wp-club-manager' ), $this->item_name ), 'desc' => '', 'type' => 'license_key', @@ -151,16 +180,17 @@ public function activate_license() { return; } - foreach ( $_POST as $key => $value ) { + foreach ( $_POST as $key => $value ) { // phpcs:ignore if ( false !== strpos( $key, 'license_key_deactivate' ) ) { // Don't activate a key when deactivating a different key return; } } - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { + $nonce = filter_input( INPUT_REQUEST, $this->item_shortname . '_license_key-nonce', FILTER_UNSAFE_RAW ); + if ( ! wp_verify_nonce( sanitize_text_field( $nonce ), $this->item_shortname . '_license_key-nonce' ) ) { - wp_die( __( 'Nonce verification failed', 'wp-club-manager' ), __( 'Error', 'wp-club-manager' ), array( 'response' => 403 ) ); + wp_die( esc_html__( 'Nonce verification failed', 'wp-club-manager' ), esc_html__( 'Error', 'wp-club-manager' ), array( 'response' => 403 ) ); } @@ -168,7 +198,7 @@ public function activate_license() { return; } - $license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] ); + $license = filter_input( INPUT_POST, $this->item_shortname . '_license_key', FILTER_UNSAFE_RAW ); if ( empty( $license ) ) { return; @@ -177,7 +207,7 @@ public function activate_license() { // Data to send to the API $api_params = array( 'edd_action' => 'activate_license', - 'license' => $license, + 'license' => sanitize_text_field( $license ), 'item_name' => urlencode( $this->item_name ), ); @@ -224,9 +254,10 @@ public function deactivate_license() { return; } - if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) { + $nonce = filter_input( INPUT_REQUEST, $this->item_shortname . '_license_key-nonce', FILTER_UNSAFE_RAW ); + if ( ! wp_verify_nonce( sanitize_text_field( $nonce ), $this->item_shortname . '_license_key-nonce' ) ) { - wp_die( __( 'Nonce verification failed', 'wp-club-manager' ), __( 'Error', 'wp-club-manager' ), array( 'response' => 403 ) ); + wp_die( esc_html__( 'Nonce verification failed', 'wp-club-manager' ), esc_html__( 'Error', 'wp-club-manager' ), array( 'response' => 403 ) ); } @@ -307,6 +338,7 @@ public function notices() { break; default: + /* translators: 1: error code. */ $message = sprintf( __( 'There was a problem activating your license key, please try again or contact support. Error code: %s', 'wp-club-manager' ), $license_error->error ); break; @@ -316,7 +348,7 @@ public function notices() { if ( ! empty( $message ) ) { echo '
    '; - echo '

    ' . $message . '

    '; + echo '

    ' . esc_html( $message ) . '

    '; echo '
    '; } diff --git a/includes/class-wpcm-post-types.php b/includes/class-wpcm-post-types.php index a2087b3..0464671 100644 --- a/includes/class-wpcm-post-types.php +++ b/includes/class-wpcm-post-types.php @@ -15,6 +15,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Post_Types + */ class WPCM_Post_Types { /** @@ -27,8 +30,6 @@ public function __construct() { add_action( 'init', array( __CLASS__, 'support_jetpack_omnisearch' ) ); add_filter( 'the_posts', array( __CLASS__, 'show_future_matches' ) ); add_filter( 'rest_api_allowed_post_types', array( __CLASS__, 'rest_api_allowed_post_types' ) ); - // add_filter( 'post_type_link', array( __CLASS__, 'remove_custom_service_slug' ), 10, 2 ); - // add_action( 'pre_get_posts', array( __CLASS__, 'add_cpt_post_names_to_main_query' ) ); } /** @@ -526,8 +527,8 @@ public static function register_post_types() { */ public static function show_future_matches( $posts ) { global $wp_query, $wpdb; - if ( is_single() && $wp_query->post_count == 0 && isset( $wp_query->query_vars['wpcm_match'] ) ) { - $posts = $wpdb->get_results( $wp_query->request ); + if ( is_single() && 0 === $wp_query->post_count && isset( $wp_query->query_vars['wpcm_match'] ) ) { + $posts = $wpdb->get_results( $wp_query->request ); // phpcs:ignore } return $posts; } @@ -557,43 +558,6 @@ public static function rest_api_allowed_post_types( $post_types ) { return $post_types; } - - public static function remove_custom_service_slug( $post_link, $post ) { - if ( 'wpcm_club' === $post->post_type && 'publish' === $post->post_status ) { - if ( $post->post_parent ) { - $parent = get_post( $post->post_parent ); - $post_link = str_replace( '/' . $post->post_type . '/' . $parent->post_name . '/', '/', $post_link ); - } else { - $post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link ); - } - } - return $post_link; - } - - /** - * Have WordPress match postname to any of our public post types (post, page, race). - * All of our public post types can have /post-name/ as the slug, so they need to be unique across all posts. - * By default, WordPress only accounts for posts and pages where the slug is /post-name/. - * - * @param $query The current query. - */ - public static function add_cpt_post_names_to_main_query( $query ) { - - // Bail if this is not the main query. - if ( ! $query->is_main_query() ) { - return; - } - // Bail if this query doesn't match our very specific rewrite rule. - if ( ! isset( $query->query['page'] ) || 2 !== count( $query->query ) ) { - return; - } - // Bail if we're not querying based on the post name. - if ( empty( $query->query['name'] ) ) { - return; - } - // Add CPT to the list of post types WP will include when it queries based on the post name. - $query->set( 'post_type', array( 'post', 'page', 'wpcm_club' ) ); - } } new WPCM_Post_Types(); diff --git a/includes/class-wpcm-shortcodes.php b/includes/class-wpcm-shortcodes.php index b0f96a8..c28baee 100644 --- a/includes/class-wpcm-shortcodes.php +++ b/includes/class-wpcm-shortcodes.php @@ -13,8 +13,14 @@ exit; // Exit if accessed directly } +/** + * WPCM_Shortcodes + */ class WPCM_Shortcodes { + /** + * Construct + */ public function __construct() { add_action( 'wp_head', array( $this, 'wpcm_map_css' ) ); @@ -57,6 +63,8 @@ public static function init() { * * @param mixed $function * @param array $atts (default: array()) + * @param array $wrapper + * * @return string */ public static function shortcode_wrapper( @@ -76,9 +84,9 @@ public static function shortcode_wrapper( $before = empty( $wrapper['before'] ) ? '
    ' : $wrapper['before']; $after = empty( $wrapper['after'] ) ? '
    ' : $wrapper['after']; - echo $before; + echo esc_html( $before ); call_user_func( $function, $atts ); - echo $after; + echo esc_html( $after ); return ob_get_clean(); } @@ -291,18 +299,18 @@ public static function map( $atts ) { } ob_start(); - if ( $latitude != null && $longitude != null ) : + if ( null != $latitude && null != $longitude ) : ?> data = wpcm_get_sport_presets(); } + /** + * @param string $key + * + * @return mixed|null + */ public function __get( $key ) { return ( array_key_exists( $key, $this->data ) ? $this->data[ $key ] : null ); } + /** + * @param string $key + * @param mixed $value + * + * @return void + */ public function __set( $key, $value ) { $this->data[ $key ] = $value; } diff --git a/includes/class-wpcm-taxonomy-order.php b/includes/class-wpcm-taxonomy-order.php index df9e527..b53e548 100644 --- a/includes/class-wpcm-taxonomy-order.php +++ b/includes/class-wpcm-taxonomy-order.php @@ -30,6 +30,8 @@ public function __construct() { /** * Order the terms on the admin side. + * + * @param WP_Screen $screen */ public function admin_order_terms( WP_Screen $screen ) { // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Form data is not being used. @@ -89,7 +91,10 @@ public function enqueue() { * @param string $tax_slug The taxonomy's slug. */ public function default_term_order( $tax_slug ) { - $terms = get_terms( $tax_slug, array( 'hide_empty' => false ) ); + $terms = get_terms( array( + 'taxonomy' => $tax_slug, + 'hide_empty' => false, + ) ); // $order = 1; $order = $this->get_max_taxonomy_order( $tax_slug ); foreach ( $terms as $term ) { @@ -102,6 +107,10 @@ public function default_term_order( $tax_slug ) { /** * Get the maximum tax_position for this taxonomy. This will be applied to terms that don't have a tax position. + * + * @param string $tax_slug + * + * @return int */ private function get_max_taxonomy_order( $tax_slug ) { global $wpdb; @@ -109,13 +118,13 @@ private function get_max_taxonomy_order( $tax_slug ) { $wpdb->prepare( "SELECT MAX( CAST( tm.meta_value AS UNSIGNED ) ) FROM $wpdb->terms t - JOIN $wpdb->term_taxonomy tt ON t.term_id = tt.term_id AND tt.taxonomy = '%s' + JOIN $wpdb->term_taxonomy tt ON t.term_id = tt.term_id AND tt.taxonomy = %s JOIN $wpdb->termmeta tm ON tm.term_id = t.term_id WHERE tm.meta_key = 'tax_position'", $tax_slug ) ); $max_term_order = is_array( $max_term_order ) ? current( $max_term_order ) : 0; - return (int) $max_term_order === 0 || empty( $max_term_order ) ? 1 : (int) $max_term_order + 1; + return 0 === (int) $max_term_order || empty( $max_term_order ) ? 1 : (int) $max_term_order + 1; } /** @@ -161,8 +170,8 @@ public function update_taxonomy_order() { wp_send_json_error(); } - $taxonomy_ordering_data = filter_var_array( wp_unslash( $_POST['taxonomy_ordering_data'] ), FILTER_SANITIZE_NUMBER_INT ); - $base_index = filter_var( wp_unslash( $_POST['base_index'] ), FILTER_SANITIZE_NUMBER_INT ); + $taxonomy_ordering_data = filter_var_array( wp_unslash( $_POST['taxonomy_ordering_data'] ), FILTER_SANITIZE_NUMBER_INT ); // phpcs:ignore + $base_index = filter_input( INPUT_POST, 'base_index', FILTER_SANITIZE_NUMBER_INT ); foreach ( $taxonomy_ordering_data as $order_data ) { // Due to the way WordPress shows parent categories on multiple pages, we need to check if the parent category's position should be updated. diff --git a/includes/class-wpcm-template-loader.php b/includes/class-wpcm-template-loader.php index b4c82ed..d11465f 100644 --- a/includes/class-wpcm-template-loader.php +++ b/includes/class-wpcm-template-loader.php @@ -13,6 +13,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Template_Loader + */ class WPCM_Template_Loader { /** diff --git a/includes/shortcodes/class-wpcm-shortcode-league-table.php b/includes/shortcodes/class-wpcm-shortcode-league-table.php index 8f9c418..89ed22f 100644 --- a/includes/shortcodes/class-wpcm-shortcode-league-table.php +++ b/includes/shortcodes/class-wpcm-shortcode-league-table.php @@ -24,7 +24,7 @@ class WPCM_Shortcode_League_Table { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $id = ( isset( $atts['id'] ) ? $atts['id'] : null ); $title = ( isset( $atts['title'] ) ? $atts['title'] : '' ); @@ -189,6 +189,6 @@ public static function output( $atts ) { } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/class-wpcm-shortcode-map-venue.php b/includes/shortcodes/class-wpcm-shortcode-map-venue.php index b36e1f9..616bed0 100644 --- a/includes/shortcodes/class-wpcm-shortcode-map-venue.php +++ b/includes/shortcodes/class-wpcm-shortcode-map-venue.php @@ -24,7 +24,7 @@ class WPCM_Shortcode_Map_Venue { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $id = ( isset( $atts['id'] ) ? $atts['id'] : -1 ); $title = ( isset( $atts['title'] ) ? $atts['title'] : '' ); diff --git a/includes/shortcodes/class-wpcm-shortcode-match-list.php b/includes/shortcodes/class-wpcm-shortcode-match-list.php index a785220..983026d 100644 --- a/includes/shortcodes/class-wpcm-shortcode-match-list.php +++ b/includes/shortcodes/class-wpcm-shortcode-match-list.php @@ -24,7 +24,7 @@ class WPCM_Shortcode_Match_List { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $title = ( isset( $atts['title'] ) ? $atts['title'] : '' ); $format = ( isset( $atts['format'] ) ? $atts['format'] : '' ); @@ -227,6 +227,6 @@ public static function output( $atts ) { } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/class-wpcm-shortcode-match-opponents.php b/includes/shortcodes/class-wpcm-shortcode-match-opponents.php index ea0991b..3ded88f 100644 --- a/includes/shortcodes/class-wpcm-shortcode-match-opponents.php +++ b/includes/shortcodes/class-wpcm-shortcode-match-opponents.php @@ -12,6 +12,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Shortcode_Match_Opponents + */ class WPCM_Shortcode_Match_Opponents { /** @@ -21,7 +24,7 @@ class WPCM_Shortcode_Match_Opponents { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $title = ( isset( $atts['title'] ) ? $atts['title'] : '' ); $format = ( isset( $atts['format'] ) ? $atts['format'] : '' ); @@ -40,74 +43,73 @@ public static function output( $atts ) { $show_venue = ( isset( $atts['show_venue'] ) ? $atts['show_venue'] : 1 ); $linktext = ( isset( $atts['linktext'] ) ? $atts['linktext'] : '' ); $linkpage = ( isset( $atts['linkpage'] ) ? $atts['linkpage'] : '' ); - // $link_club = ( get_option( 'wpcm_match_list_link_club', 'yes' ) == 'yes' ? true : false ); - if ( $limit == '' ) { + if ( '' === $limit ) { $limit = -1; } - if ( $comp == '' ) { + if ( '' === $comp ) { $comp = null; } - if ( $season == '' ) { + if ( '' === $season ) { $season = null; } - if ( $team == '' ) { + if ( '' === $team ) { $team = null; } - if ( $venue == '' ) { + if ( '' === $venue ) { $venue = null; } - if ( $date_range == '' ) { + if ( '' === $date_range ) { $date_range = null; } - if ( $order == '' ) { + if ( '' === $order ) { $order = 'ASC'; } - if ( $show_abbr == '' ) { + if ( '' === $show_abbr ) { $show_abbr = 0; } - if ( $show_thumb == '' ) { + if ( '' === $show_thumb ) { $show_thumb = 0; } - if ( $show_team == '' ) { + if ( '' === $show_team ) { $show_team = 0; } - if ( $show_comp == '' ) { + if ( '' === $show_comp ) { $show_comp = 1; } - if ( $show_venue == '' ) { + if ( '' === $show_venue ) { $show_venue = 0; } - if ( $linkpage == '' ) { + if ( '' === $linkpage ) { $linkpage = null; } $disable_cache = get_option( 'wpcm_disable_cache' ); - if ( $disable_cache === 'no' || $date_range === 'last_week' || $date_range === 'next_week' ) { + if ( 'no' === $disable_cache || 'last_week' === $date_range || 'next_week' === $date_range ) { $transient_name = WPCM_Cache_Helper::create_plugin_transient_name( $atts, 'match_opponents' ); $output = get_transient( $transient_name ); } else { $output = false; } - if ( $output === false ) { + if ( false === $output ) { if ( is_club_mode() ) { $club = get_default_club(); } else { $club = $id; } - if ( $format == '' ) { + if ( '' === $format ) { $format = array( 'publish', 'future' ); - } elseif ( $format == 'fixtures' ) { + } elseif ( 'fixtures' === $format ) { $format = 'future'; - } elseif ( $format == 'results' ) { + } elseif ( 'results' === $format ) { $format = 'publish'; } // get matches $query_args = array( - 'tax_query' => array(), + 'tax_query' => array(), // phpcs:ignore 'numberposts' => $limit, 'order' => $order, 'orderby' => 'post_date', @@ -116,8 +118,8 @@ public static function output( $atts ) { 'posts_per_page' => $limit, ); - if ( $format == 'results' ) { - $query_args['meta_query'] = array( + if ( 'results' === $format ) { + $query_args['meta_query'] = array( // phpcs:ignore array( 'key' => 'wpcm_played', 'value' => false, @@ -125,22 +127,22 @@ public static function output( $atts ) { ); } - if ( isset( $venue ) && $venue == 'home' ) { - $query_args['meta_query'] = array( + if ( isset( $venue ) && 'home' === $venue ) { + $query_args['meta_query'] = array( // phpcs:ignore array( 'key' => 'wpcm_home_club', 'value' => $club, ), ); - } elseif ( isset( $venue ) && $venue == 'away' ) { - $query_args['meta_query'] = array( + } elseif ( isset( $venue ) && 'away' === $venue ) { + $query_args['meta_query'] = array( // phpcs:ignore array( 'key' => 'wpcm_away_club', 'value' => $club, ), ); } else { - $query_args['meta_query'] = array( + $query_args['meta_query'] = array( // phpcs:ignore 'relation' => 'OR', array( 'key' => 'wpcm_home_club', @@ -175,7 +177,7 @@ public static function output( $atts ) { ); } if ( isset( $date_range ) ) { - if ( $date_range == 'last_week' ) { + if ( 'last_week' === $date_range ) { $today = getdate(); $query_args['date_query'] = array( 'column' => 'post_date', @@ -186,7 +188,7 @@ public static function output( $atts ) { ), 'after' => '- 7 days', ); - } elseif ( $date_range == 'next_week' ) { + } elseif ( 'next_week' === $date_range ) { $today = getdate(); $query_args['date_query'] = array( 'column' => 'post_date', @@ -211,7 +213,6 @@ public static function output( $atts ) { wpclubmanager_get_template( 'shortcodes/match-opponents.php', array( 'title' => $title, 'club' => $club, - // 'link_club' => $link_club, 'show_abbr' => $show_abbr, 'show_thumb' => $show_thumb, 'show_team' => $show_team, @@ -224,13 +225,13 @@ public static function output( $atts ) { $output = ob_get_clean(); wp_reset_postdata(); - if ( $disable_cache === 'no' || $date_range === 'last_week' || $date_range === 'next_week' ) { + if ( 'no' === $disable_cache || 'last_week' === $date_range || 'next_week' === $date_range ) { set_transient( $transient_name, $output, 4 * WEEK_IN_SECONDS ); do_action( 'update_plugin_transient_keys', $transient_name ); } } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/class-wpcm-shortcode-player-gallery.php b/includes/shortcodes/class-wpcm-shortcode-player-gallery.php index 3ac136f..7de47c6 100644 --- a/includes/shortcodes/class-wpcm-shortcode-player-gallery.php +++ b/includes/shortcodes/class-wpcm-shortcode-player-gallery.php @@ -35,7 +35,7 @@ public static function get( $atts ) { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $id = ( isset( $atts['id'] ) ? $atts['id'] : null ); $title = ( isset( $atts['title'] ) ? $atts['title'] : __( 'Players Gallery', 'wp-club-manager' ) ); @@ -184,6 +184,6 @@ public static function output( $atts ) { } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/class-wpcm-shortcode-player-list.php b/includes/shortcodes/class-wpcm-shortcode-player-list.php index 8f97589..d02db5f 100644 --- a/includes/shortcodes/class-wpcm-shortcode-player-list.php +++ b/includes/shortcodes/class-wpcm-shortcode-player-list.php @@ -34,7 +34,7 @@ public static function get( $atts ) { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $id = ( isset( $atts['id'] ) ? $atts['id'] : '' ); $limit = ( isset( $atts['limit'] ) ? $atts['limit'] : '' ); @@ -283,6 +283,6 @@ public static function output( $atts ) { } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/class-wpcm-shortcode-staff-gallery.php b/includes/shortcodes/class-wpcm-shortcode-staff-gallery.php index 5b00327..a9c1e43 100644 --- a/includes/shortcodes/class-wpcm-shortcode-staff-gallery.php +++ b/includes/shortcodes/class-wpcm-shortcode-staff-gallery.php @@ -12,6 +12,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Shortcode_Staff_Gallery + */ class WPCM_Shortcode_Staff_Gallery { /** @@ -31,7 +34,7 @@ public static function get( $atts ) { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $id = ( isset( $atts['id'] ) ? $atts['id'] : null ); $title = ( isset( $atts['title'] ) ? $atts['title'] : __( 'Staff Gallery', 'wp-club-manager' ) ); @@ -45,37 +48,37 @@ public static function output( $atts ) { $name_format = ( isset( $atts['name_format'] ) ? $atts['name_format'] : 'full' ); $type = ( isset( $atts['type'] ) ? $atts['type'] : '' ); - if ( $limit == '' ) { + if ( '' === $limit ) { $limit = -1; } - if ( $position == '' ) { + if ( '' === $position ) { $position = null; } - if ( $orderby == '' ) { + if ( '' === $orderby ) { $orderby = 'number'; } - if ( $order == '' ) { + if ( '' === $order ) { $order = 'ASC'; } - if ( $columns == '' ) { + if ( '' === $columns ) { $columns = '3'; } - if ( $name_format == '' ) { + if ( '' === $name_format ) { $name_format = 'full'; } - if ( $linkpage == '' ) { + if ( '' === $linkpage ) { $linkpage = null; } $disable_cache = get_option( 'wpcm_disable_cache' ); - if ( $disable_cache === 'no' && $type !== 'widget' ) { + if ( 'no' === $disable_cache && 'widget' !== $type ) { $transient_name = WPCM_Cache_Helper::create_plugin_transient_name( $atts, 'staff_gallery' ); $output = get_transient( $transient_name ); } else { $output = false; } - if ( $output === false ) { + if ( false === $output ) { $selected_staff = (array) unserialize( get_post_meta( $id, '_wpcm_roster_staff', true ) ); $seasons = get_the_terms( $id, 'wpcm_season' ); @@ -88,7 +91,7 @@ public static function output( $atts ) { $query_args = array( 'post_type' => 'wpcm_staff', - 'tax_query' => array(), + 'tax_query' => array(), // phpcs:ignore 'numposts' => $limit, 'posts_per_page' => -1, 'orderby' => $orderby, @@ -117,7 +120,7 @@ public static function output( $atts ) { if ( has_post_thumbnail( $employee->ID ) ) { $thumb = get_the_post_thumbnail( $employee->ID, 'player-medium' ); } else { - $thumb = wpcm_placeholder_img( $size = 'full' ); + $thumb = wpcm_placeholder_img( 'full' ); } $employee_details[ $employee->ID ]['image'] = '' . $thumb . ''; @@ -141,13 +144,13 @@ public static function output( $atts ) { $output = ob_get_clean(); wp_reset_postdata(); - if ( $disable_cache === 'no' ) { + if ( 'no' === $disable_cache ) { set_transient( $transient_name, $output, 4 * WEEK_IN_SECONDS ); do_action( 'update_plugin_transient_keys', $transient_name ); } } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/class-wpcm-shortcode-staff-list.php b/includes/shortcodes/class-wpcm-shortcode-staff-list.php index f07967e..78d71b5 100644 --- a/includes/shortcodes/class-wpcm-shortcode-staff-list.php +++ b/includes/shortcodes/class-wpcm-shortcode-staff-list.php @@ -24,7 +24,7 @@ class WPCM_Shortcode_Staff_List { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $id = ( isset( $atts['id'] ) ? $atts['id'] : null ); $limit = ( isset( $atts['limit'] ) ? $atts['limit'] : -1 ); @@ -187,6 +187,6 @@ public static function output( $atts ) { } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/legacy/class-wpcm-shortcode-matches.php b/includes/shortcodes/legacy/class-wpcm-shortcode-matches.php index 33c8fe3..700203b 100644 --- a/includes/shortcodes/legacy/class-wpcm-shortcode-matches.php +++ b/includes/shortcodes/legacy/class-wpcm-shortcode-matches.php @@ -12,18 +12,11 @@ exit; // Exit if accessed directly } +/** + * WPCM_Shortcode_Matches + */ class WPCM_Shortcode_Matches { - /** - * Get the shortcode content. - * - * @param array $atts - * @return string - */ - // public static function get( $atts ) { - // return WPCM_Shortcodes::shortcode_wrapper( array( __CLASS__, 'output' ), $atts ); - // } - /** * Output the standings shortcode. * @@ -31,7 +24,7 @@ class WPCM_Shortcode_Matches { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $type = ( isset( $atts['type'] ) ? $atts['type'] : '1' ); $format = ( isset( $atts['format'] ) ? $atts['format'] : '1' ); @@ -49,40 +42,40 @@ public static function output( $atts ) { $linktext = ( isset( $atts['linktext'] ) ? $atts['linktext'] : __( 'View all results', 'wp-club-manager' ) ); $linkpage = ( isset( $atts['linkpage'] ) ? $atts['linkpage'] : null ); - if ( $limit == '' ) { + if ( '' === $limit ) { $limit = -1; } - if ( $comp == -1 ) { + if ( -1 === $comp ) { $comp = null; } - if ( $season == -1 ) { + if ( -1 === $season ) { $season = null; } - if ( $team == -1 ) { + if ( -1 === $team ) { $team = null; } - if ( $month == -1 ) { + if ( -1 === $month ) { $month = null; } $disable_cache = get_option( 'wpcm_disable_cache' ); - if ( $disable_cache === 'no' ) { + if ( 'no' === $disable_cache ) { $transient_name = WPCM_Cache_Helper::create_plugin_transient_name( $atts, 'matches' ); $output = get_transient( $transient_name ); } else { $output = false; } - if ( $output === false ) { + if ( false === $output ) { $club = get_default_club(); - if ( $format == '1' ) { + if ( '1' === $format ) { $format = array( 'publish', 'future' ); $order = 'ASC'; - } elseif ( $format == '2' ) { + } elseif ( '2' === $format ) { $format = 'future'; $order = 'ASC'; - } elseif ( $format == '3' ) { + } elseif ( '3' === $format ) { $format = 'publish'; $order = 'DESC'; } @@ -98,7 +91,7 @@ public static function output( $atts ) { 'posts_per_page' => $limit, ); - if ( $format == '2' ) { + if ( '2' === $format ) { $query_args['meta_query'] = array( array( 'key' => 'wpcm_played', @@ -107,14 +100,14 @@ public static function output( $atts ) { ); } - if ( isset( $venue ) && $venue == 'home' ) { + if ( isset( $venue ) && 'home' === $venue ) { $query_args['meta_query'] = array( array( 'key' => 'wpcm_home_club', 'value' => $club, ), ); - } elseif ( isset( $venue ) && $venue == 'away' ) { + } elseif ( isset( $venue ) && 'away' === $venue ) { $query_args['meta_query'] = array( array( 'key' => 'wpcm_away_club', @@ -156,13 +149,7 @@ public static function output( $atts ) { 'field' => 'term_id', ); } - // if ( isset( $venue ) ) { - // $query_args['tax_query'][] = array( - // 'taxonomy' => 'wpcm_venue', - // 'terms' => $venue, - // 'field' => 'term_id' - // ); - // } + if ( isset( $month ) ) { $query_args['date_query'] = array( 'month' => $month, @@ -172,7 +159,7 @@ public static function output( $atts ) { $matches = get_posts( $query_args ); if ( $matches ) { - if ( $type == '2' ) { + if ( '2' === $type ) { ob_start(); wpclubmanager_get_template( 'shortcodes/matches-2.php', array( 'title' => $title, @@ -199,17 +186,17 @@ public static function output( $atts ) { } wp_reset_postdata(); - if ( $disable_cache === 'no' ) { + if ( 'no' === $disable_cache ) { set_transient( $transient_name, $output, 4 * WEEK_IN_SECONDS ); do_action( 'update_plugin_transient_keys', $transient_name ); } } else { ?> - -

    + +

    0, ); - if ( $orderby == 'name' ) { + if ( 'name' === $orderby ) { $args['orderby'] = 'name'; } - if ( $orderby == 'menu_order' ) { + if ( 'menu_order' === $orderby ) { $args['orderby'] = 'menu_order'; } @@ -127,7 +130,7 @@ public static function output( $atts ) { $player_details = array(); $count = 0; - if ( sizeof( $players ) > 0 ) { + if ( count( $players ) > 0 ) { foreach ( $players as $player ) { @@ -202,7 +205,7 @@ public static function output( $atts ) { } if ( array_key_exists( $orderby, $player_stats_labels ) ) { $player_details = subval_sort( $player_details, $orderby ); - if ( $order == 'DESC' ) { + if ( 'DESC' === $order ) { $player_details = array_reverse( $player_details ); } } @@ -221,13 +224,13 @@ public static function output( $atts ) { $output = ob_get_clean(); wp_reset_postdata(); - if ( $disable_cache === 'no' && $type !== 'widget' ) { + if ( 'no' === $disable_cache && 'widget' !== $type ) { set_transient( $transient_name, $output, 4 * WEEK_IN_SECONDS ); do_action( 'update_plugin_transient_keys', $transient_name ); } } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/shortcodes/legacy/class-wpcm-shortcode-staff.php b/includes/shortcodes/legacy/class-wpcm-shortcode-staff.php index 7a8789c..7beb913 100644 --- a/includes/shortcodes/legacy/class-wpcm-shortcode-staff.php +++ b/includes/shortcodes/legacy/class-wpcm-shortcode-staff.php @@ -12,6 +12,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Shortcode_Staff + */ class WPCM_Shortcode_Staff { /** @@ -21,7 +24,7 @@ class WPCM_Shortcode_Staff { */ public static function output( $atts ) { - extract( shortcode_atts( array(), $atts ) ); + extract( shortcode_atts( array(), $atts ) ); // phpcs:ignore $limit = ( isset( $atts['limit'] ) ? $atts['limit'] : -1 ); $title = ( isset( $atts['title'] ) ? $atts['title'] : __( 'Staff', 'wp-club-manager' ) ); @@ -35,18 +38,18 @@ public static function output( $atts ) { $linkpage = ( isset( $atts['linkpage'] ) ? $atts['linkpage'] : null ); $disable_cache = get_option( 'wpcm_disable_cache' ); - if ( $disable_cache === 'no' ) { + if ( 'no' === $disable_cache ) { $transient_name = WPCM_Cache_Helper::create_plugin_transient_name( $atts, 'staff' ); $output = get_transient( $transient_name ); } else { $output = false; } - if ( $output === false ) { + if ( false === $output ) { $stats_labels = wpcm_staff_labels(); - if ( $limit == 0 ) { + if ( 0 === $limit ) { $limit = -1; } if ( $team <= 0 ) { @@ -143,13 +146,13 @@ public static function output( $atts ) { if ( array_key_exists( $orderby, $atts ) ) { $staff_details = subval_sort( $staff_details, $orderby ); - if ( $order == 'DESC' ) { + if ( 'DESC' === $order ) { $staff_details = array_reverse( $staff_details ); } } $count = 0; - if ( sizeof( $employees ) > 0 ) { + if ( count( $employees ) > 0 ) { ob_start(); wpclubmanager_get_template( 'shortcodes/staff.php', array( @@ -165,20 +168,20 @@ public static function output( $atts ) { $output = ob_get_clean(); if ( isset( $linkpage ) ) { ?> - - + + ID, $comp, $season ); $club->wpcm_stats = $club_stats; - if ( $thumb == 1 ) { + if ( 1 == $thumb ) { if ( has_post_thumbnail( $club->ID ) ) { $club->thumb = get_the_post_thumbnail( $club->ID, 'crest-small' ); } else { @@ -108,14 +111,14 @@ public static function output( $atts ) { } } // sort clubs - if ( $orderby == 'pts' ) { + if ( 'pts' === $orderby ) { usort( $clubs, 'wpcm_club_standings_sort' ); - } elseif ( $orderby == 'pct' ) { + } elseif ( 'pct' === $orderby ) { usort( $clubs, 'wpcm_club_standings_pct_sort' ); } else { $clubs = wpcm_club_standings_sort_by( $orderby, $clubs ); } - if ( $order == 'ASC' ) { + if ( 'ASC' === $order ) { $clubs = array_reverse( $clubs ); } // add places to clubs @@ -163,7 +166,6 @@ public static function output( $atts ) { 'stats' => $stats, 'stats_labels' => $stats_labels, 'center' => $center, - 'type' => $type, 'link_club' => $link_club, 'linkpage' => $linkpage, 'linktext' => $linktext, @@ -171,12 +173,12 @@ public static function output( $atts ) { $output = ob_get_clean(); wp_reset_postdata(); - if ( $disable_cache === 'no' && $type !== 'widget' ) { + if ( 'no' === $disable_cache && 'widget' !== $type ) { set_transient( $transient_name, $output, 4 * WEEK_IN_SECONDS ); do_action( 'update_plugin_transient_keys', $transient_name ); } } - echo $output; + echo esc_html( $output ); } } diff --git a/includes/widgets/class-wpcm-widget-birthdays.php b/includes/widgets/class-wpcm-birthdays-widget.php similarity index 90% rename from includes/widgets/class-wpcm-widget-birthdays.php rename to includes/widgets/class-wpcm-birthdays-widget.php index ec09918..bd6b34f 100644 --- a/includes/widgets/class-wpcm-widget-birthdays.php +++ b/includes/widgets/class-wpcm-birthdays-widget.php @@ -13,6 +13,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Birthdays_Widget + */ class WPCM_Birthdays_Widget extends WPCM_Widget { /** @@ -108,8 +111,8 @@ public function get_birthdays( $args, $instance ) { foreach ( $players as $player ) : $dob = get_post_meta( $player->ID, 'wpcm_dob', true ); - list( $Y, $m, $d ) = explode( '-', $dob ); - $month_day = date( 'Y-' . $m . '-' . $d ); + list( $y, $m, $d ) = explode( '-', $dob ); + $month_day = gmdate( 'Y-' . $m . '-' . $d ); $posts[ $player->ID ] = $month_day; endforeach; @@ -120,10 +123,10 @@ public function get_birthdays( $args, $instance ) { foreach ( $posts as $post => $value ) { - list( $Y, $m, $d ) = explode( '-', $value ); - $month_day = date( $m . '-' . $d ); - $timespan = date( 'm-d', strtotime( $date ) ); - if ( $month_day <= $timespan && $month_day >= date( 'm-d' ) ) { + list( $y, $m, $d ) = explode( '-', $value ); + $month_day = gmdate( $m . '-' . $d ); + $timespan = gmdate( 'm-d', strtotime( $date ) ); + if ( $month_day <= $timespan && $month_day >= gmdate( 'm-d' ) ) { $new_posts[ $post ] = $month_day; } @@ -170,6 +173,6 @@ public function widget( $args, $instance ) { $this->widget_end( $args ); - echo $this->cache_widget( $args, ob_get_clean() ); + echo wp_kses_post( $this->cache_widget( $args, ob_get_clean() ) ); } } diff --git a/includes/widgets/class-wpcm-widget-fixtures.php b/includes/widgets/class-wpcm-fixtures-widget.php similarity index 89% rename from includes/widgets/class-wpcm-widget-fixtures.php rename to includes/widgets/class-wpcm-fixtures-widget.php index 124613a..28795b9 100644 --- a/includes/widgets/class-wpcm-widget-fixtures.php +++ b/includes/widgets/class-wpcm-fixtures-widget.php @@ -13,6 +13,9 @@ exit; } // Exit if accessed directly +/** + * WPCM_Fixtures_Widget + */ class WPCM_Fixtures_Widget extends WPCM_Widget { @@ -129,8 +132,9 @@ public function __construct() { /** * Query the fixtures and return them. * - * @param array $args - * @param array $instance + * @param array $args + * @param array $instance + * * @return WP_Query */ public function get_fixtures( $args, $instance ) { @@ -140,7 +144,7 @@ public function get_fixtures( $args, $instance ) { $team = isset( $instance['team'] ) ? $instance['team'] : null; $club = get_option( 'wpcm_default_club' ); $venue = isset( $instance['venue'] ) ? $instance['venue'] : 'all'; - if ( $limit == 0 ) { + if ( 0 == $limit ) { $limit = -1; } if ( $comp <= 0 ) { @@ -168,14 +172,14 @@ public function get_fixtures( $args, $instance ) { 'posts_per_page' => $limit, ); - if ( isset( $venue ) && $venue == 'home' ) { + if ( isset( $venue ) && 'home' === $venue ) { $query_args['meta_query'] = array( array( 'key' => 'wpcm_home_club', 'value' => $club, ), ); - } elseif ( isset( $venue ) && $venue == 'away' ) { + } elseif ( isset( $venue ) && 'away' === $venue ) { $query_args['meta_query'] = array( array( 'key' => 'wpcm_away_club', @@ -226,11 +230,12 @@ public function get_fixtures( $args, $instance ) { /** * widget function. * - * @see WP_Widget - * @access public * @param array $args * @param array $instance + * * @return void + * @see WP_Widget + * @access public */ public function widget( $args, $instance ) { if ( $this->get_cached_widget( $args ) ) { @@ -240,9 +245,9 @@ public function widget( $args, $instance ) { ob_start(); $this->widget_start( $args, $instance ); - - if ( ( $fixtures = $this->get_fixtures( $args, $instance ) ) && $fixtures->have_posts() ) { - echo apply_filters( 'wpclubmanager_before_widget_fixtures', '
      ' ); + $fixtures = $this->get_fixtures( $args, $instance ); + if ( $fixtures && $fixtures->have_posts() ) { + echo wp_kses_post( apply_filters( 'wpclubmanager_before_widget_fixtures', '
        ' ) ); while ( $fixtures->have_posts() ) : $fixtures->the_post(); @@ -256,7 +261,7 @@ public function widget( $args, $instance ) { $show_time = ! empty( $instance['show_time'] ); $show_comp = ! empty( $instance['show_comp'] ); $show_team = ! empty( $instance['show_team'] ); - if ( $show_abbr == 1 ) { + if ( 1 == $show_abbr ) { $sides = wpcm_get_match_clubs( $post, true ); } else { $sides = wpcm_get_match_clubs( $post ); @@ -281,9 +286,9 @@ public function widget( $args, $instance ) { endwhile; - echo apply_filters( 'wpclubmanager_after_widget_fixtures', '
      ' ); + echo wp_kses_post( apply_filters( 'wpclubmanager_after_widget_fixtures', '
    ' ) ); } else { - echo '

    ' . __( 'No more matches scheduled.', 'wp-club-manager' ) . '

    '; + echo '

    ' . esc_html__( 'No more matches scheduled.', 'wp-club-manager' ) . '

    '; } wp_reset_postdata(); @@ -295,11 +300,11 @@ public function widget( $args, $instance ) { } if ( isset( $linkpage ) ) { - echo '' . $linktext . ''; + echo '' . esc_html( $linktext ) . ''; } $this->widget_end( $args ); - echo $this->cache_widget( $args, ob_get_clean() ); + echo wp_kses_post( $this->cache_widget( $args, ob_get_clean() ) ); } } diff --git a/includes/widgets/class-wpcm-widget-players.php b/includes/widgets/class-wpcm-players-widget.php similarity index 97% rename from includes/widgets/class-wpcm-widget-players.php rename to includes/widgets/class-wpcm-players-widget.php index b657698..6398e5d 100644 --- a/includes/widgets/class-wpcm-widget-players.php +++ b/includes/widgets/class-wpcm-players-widget.php @@ -13,6 +13,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Players_Widget + */ class WPCM_Players_Widget extends WPCM_Widget { /** @@ -124,11 +127,11 @@ public function __construct() { * @param array $instance * @return void */ - function widget( $args, $instance ) { + public function widget( $args, $instance ) { $options_string = ''; foreach ( $instance as $key => $value ) { - if ( $value != -1 ) { + if ( -1 != $value ) { $options_string .= ' ' . $key . '="' . $value . '"'; } } diff --git a/includes/widgets/class-wpcm-widget-results.php b/includes/widgets/class-wpcm-results-widget.php similarity index 89% rename from includes/widgets/class-wpcm-widget-results.php rename to includes/widgets/class-wpcm-results-widget.php index 5e25955..9f2cd37 100644 --- a/includes/widgets/class-wpcm-widget-results.php +++ b/includes/widgets/class-wpcm-results-widget.php @@ -13,6 +13,9 @@ exit; } // Exit if accessed directly +/** + * WPCM_Results_Widget + */ class WPCM_Results_Widget extends WPCM_Widget { @@ -129,8 +132,9 @@ public function __construct() { /** * Query the results and return them. * - * @param array $args - * @param array $instance + * @param array $args + * @param array $instance + * * @return WP_Query */ public function get_results( $args, $instance ) { @@ -140,7 +144,7 @@ public function get_results( $args, $instance ) { $team = isset( $instance['team'] ) ? $instance['team'] : null; $club = get_option( 'wpcm_default_club' ); $venue = isset( $instance['venue'] ) ? $instance['venue'] : 'all'; - if ( $limit == 0 ) { + if ( 0 == $limit ) { $limit = -1; } if ( $comp <= 0 ) { @@ -167,14 +171,14 @@ public function get_results( $args, $instance ) { 'posts_per_page' => $limit, ); - if ( isset( $venue ) && $venue == 'home' ) { + if ( isset( $venue ) && 'home' === $venue ) { $query_args['meta_query'] = array( array( 'key' => 'wpcm_home_club', 'value' => $club, ), ); - } elseif ( isset( $venue ) && $venue == 'away' ) { + } elseif ( isset( $venue ) && 'away' === $venue ) { $query_args['meta_query'] = array( array( 'key' => 'wpcm_away_club', @@ -247,8 +251,9 @@ public function widget( $args, $instance ) { $this->widget_start( $args, $instance ); - if ( ( $results = $this->get_results( $args, $instance ) ) && $results->have_posts() ) { - echo apply_filters( 'wpclubmanager_before_widget_results', '
      ' ); + $results = $this->get_results( $args, $instance ); + if ( $results && $results->have_posts() ) { + echo wp_kses_post( apply_filters( 'wpclubmanager_before_widget_results', '
        ' ) ); while ( $results->have_posts() ) : $results->the_post(); @@ -265,7 +270,7 @@ public function widget( $args, $instance ) { $show_score = ! empty( $instance['show_score'] ); $show_comp = ! empty( $instance['show_comp'] ); $show_team = ! empty( $instance['show_team'] ); - if ( $show_abbr == 1 ) { + if ( 1 == $show_abbr ) { $sides = wpcm_get_match_clubs( $post, true ); } else { $sides = wpcm_get_match_clubs( $post ); @@ -288,9 +293,9 @@ public function widget( $args, $instance ) { endwhile; - echo apply_filters( 'wpclubmanager_after_widget_results', '
      ' ); + echo wp_kses_post( apply_filters( 'wpclubmanager_after_widget_results', '
    ' ) ); } else { - echo '

    ' . __( 'No more matches scheduled.', 'wp-club-manager' ) . '

    '; + echo '

    ' . esc_html__( 'No more matches scheduled.', 'wp-club-manager' ) . '

    '; } wp_reset_postdata(); @@ -302,11 +307,11 @@ public function widget( $args, $instance ) { } if ( isset( $linkpage ) ) { - echo '' . $linktext . ''; + echo '' . esc_html( $linktext ) . ''; } $this->widget_end( $args ); - echo $this->cache_widget( $args, ob_get_clean() ); + echo wp_kses_post( $this->cache_widget( $args, ob_get_clean() ) ); } } diff --git a/includes/widgets/class-wpcm-widget-sponsors.php b/includes/widgets/class-wpcm-sponsors-widget.php similarity index 90% rename from includes/widgets/class-wpcm-widget-sponsors.php rename to includes/widgets/class-wpcm-sponsors-widget.php index 4e1f020..94647a6 100644 --- a/includes/widgets/class-wpcm-widget-sponsors.php +++ b/includes/widgets/class-wpcm-sponsors-widget.php @@ -13,6 +13,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Sponsors_Widget + */ class WPCM_Sponsors_Widget extends WPCM_Widget { /** @@ -51,13 +54,14 @@ public function __construct() { /** * widget function. * - * @see WP_Widget - * @access public * @param array $args * @param array $instance + * * @return void + * @see WP_Widget + * @access public */ - function widget( $args, $instance ) { + public function widget( $args, $instance ) { $this->widget_start( $args, $instance ); @@ -65,11 +69,11 @@ function widget( $args, $instance ) { $link_new_window = get_post_meta( $instance['id'], 'wpcm_link_nw', true ); $nw = ( $link_new_window ) ? ' target="_blank"' : ''; ?> - > + > widget_end( $args ); } -} \ No newline at end of file +} diff --git a/includes/widgets/class-wpcm-widget-standings.php b/includes/widgets/class-wpcm-standings-widget.php similarity index 96% rename from includes/widgets/class-wpcm-widget-standings.php rename to includes/widgets/class-wpcm-standings-widget.php index 79a0bee..49caaa5 100644 --- a/includes/widgets/class-wpcm-widget-standings.php +++ b/includes/widgets/class-wpcm-standings-widget.php @@ -13,6 +13,9 @@ exit; // Exit if accessed directly } +/** + * WPCM_Standings_Widget + */ class WPCM_Standings_Widget extends WPCM_Widget { /** @@ -114,11 +117,11 @@ public function __construct() { * @param array $instance * @return void */ - function widget( $args, $instance ) { + public function widget( $args, $instance ) { $options_string = ''; foreach ( $instance as $key => $value ) { - if ( $value != -1 ) { + if ( -1 != $value ) { $options_string .= ' ' . $key . '="' . $value . '"'; } } diff --git a/includes/wpcm-club-functions.php b/includes/wpcm-club-functions.php index e86d52e..91bd85e 100644 --- a/includes/wpcm-club-functions.php +++ b/includes/wpcm-club-functions.php @@ -144,9 +144,12 @@ function get_club_venue( $post ) { * Get club details. * * @access public - * @param array $post + * + * @param array $post + * @param string $size + * * @return array $details - * @since 2.1.0 + * @since 2.1.0 */ function get_club_details( $post, $size = 'crest-small' ) { @@ -160,28 +163,28 @@ function get_club_details( $post, $size = 'crest-small' ) { $details['badge'] = get_the_post_thumbnail( $post->ID, $size ); if ( $post->post_parent > 0 ) { - if ( $details['abbr'] == '' ) { + if ( '' === $details['abbr'] ) { $details['abbr'] = get_post_meta( $post->post_parent, '_wpcm_club_abbr', true ); } - if ( $details['formed'] == '' ) { + if ( '' === $details['formed'] ) { $details['formed'] = get_post_meta( $post->post_parent, '_wpcm_club_formed', true ); } - if ( $details['primary_color'] == '' ) { + if ( '' === $details['primary_color'] ) { $details['primary_color'] = get_post_meta( $post->post_parent, '_wpcm_club_primary_color', true ); } - if ( $details['secondary_color'] == '' ) { + if ( '' === $details['secondary_color'] ) { $details['secondary_color'] = get_post_meta( $post->post_parent, '_wpcm_club_secondary_color', true ); } - if ( $details['website'] == '' ) { + if ( '' === $details['website'] ) { $details['website'] = get_post_meta( $post->post_parent, '_wpcm_club_website', true ); } - if ( $details['honours'] == '' ) { + if ( '' === $details['honours'] ) { $details['honours'] = get_post_meta( $post->post_parent, '_wpcm_club_honours', true ); } - if ( $details['venue'] == false ) { + if ( ! $details['venue'] ) { $details['venue'] = get_club_venue( $post->post_parent ); } - if ( $details['badge'] == '' ) { + if ( '' === $details['badge'] ) { $details['badge'] = get_the_post_thumbnail( $post->post_parent, $size ); } } @@ -201,7 +204,7 @@ function get_club_abbreviation( $post_id ) { $abbr = get_post_meta( $post_id, '_wpcm_club_abbr', true ); - if ( $abbr == '' ) { + if ( '' === $abbr ) { $title = get_the_title( $post_id, true ); $title = str_replace( ' ', '', $title ); $abbr = substr( $title, 0, 3 ); diff --git a/includes/wpcm-conditional-functions.php b/includes/wpcm-conditional-functions.php index 71d3151..b654e67 100644 --- a/includes/wpcm-conditional-functions.php +++ b/includes/wpcm-conditional-functions.php @@ -102,7 +102,7 @@ function is_ajax() { return true; } - return ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) ? true : false; + return ( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) == 'xmlhttprequest' ) ? true : false; // phpcs:ignore } } diff --git a/includes/wpcm-core-functions.php b/includes/wpcm-core-functions.php index 5218288..1124dec 100644 --- a/includes/wpcm-core-functions.php +++ b/includes/wpcm-core-functions.php @@ -75,13 +75,13 @@ function wpclubmanager_get_template_part( $slug, $name = '' ) { function wpclubmanager_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { if ( $args && is_array( $args ) ) { - extract( $args ); + extract( $args ); // phpcs:ignore } $located = wpclubmanager_locate_template( $template_name, $template_path, $default_path ); if ( ! file_exists( $located ) ) { - _doing_it_wrong( __FUNCTION__, sprintf( '%s does not exist.', $located ), '1.3' ); + _doing_it_wrong( __FUNCTION__, esc_html( sprintf( '%s does not exist.', $located ) ), '1.3' ); return; } @@ -98,8 +98,14 @@ function wpclubmanager_get_template( $template_name, $args = array(), $template_ /** * Like wpcm_get_template, but returns the HTML instead of outputting. * - * @see wpcm_get_template + * @param string $template_name + * @param array $args + * @param string $template_path + * @param string $default_path + * + * @return false|string * @since 1.4.0 + * @see wpcm_get_template */ function wpcm_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { @@ -212,6 +218,10 @@ function wpcm_nonce() { /** * Get information about available image sizes + * + * @param string $size + * + * @return array|false|mixed */ function wpcm_get_image_sizes( $size = '' ) { @@ -261,6 +271,9 @@ function wpcm_placeholder_img_src() { * Get the placeholder image * * @access public + * + * @param string $size + * * @return string */ function wpcm_placeholder_img( $size = 'player_thumbnail' ) { @@ -285,6 +298,9 @@ function wpcm_crest_placeholder_img_src() { * Get the crest placeholder image * * @access public + * + * @param string $size + * * @return string */ function wpcm_crest_placeholder_img( $size = 'crest-small' ) { @@ -383,6 +399,12 @@ function wpcm_get_core_supported_themes() { * @return mixed */ if ( ! function_exists( 'wpcm_get_team_name' ) ) { + /** + * @param WP_Post $post + * @param int $id + * + * @return mixed|string + */ function wpcm_get_team_name( $post, $id ) { $club = get_default_club(); @@ -461,8 +483,10 @@ function has_teams() { /** * Get array of teams. * - * @since 2.0.0 + * @param int|WP_Post $post + * * @return array + * @since 2.0.0 */ function get_the_teams( $post ) { @@ -481,8 +505,10 @@ function get_the_teams( $post ) { /** * Get array of seasons. * - * @since 2.0.0 + * @param int|WP_Post $post + * * @return array + * @since 2.0.0 */ function get_the_seasons( $post ) { @@ -524,8 +550,11 @@ function get_current_season() { /** * Sort biggest score. * - * @since 2.0.0 + * @param array $a + * @param array $b + * * @return int + * @since 2.0.0 */ function sort_biggest_score( $a, $b ) { @@ -543,7 +572,6 @@ function sort_biggest_score( $a, $b ) { * Rewrite hierachical club URLs. * * @since 2.0.0 - * @return string */ function wpcm_club_rewrites() { $permalink = get_option( 'wpclubmanager_club_slug' ); @@ -555,8 +583,12 @@ function wpcm_club_rewrites() { /** * Fix club permalinks. * - * @since 2.0.0 + * @param string $post_link + * @param WP_Post $post + * @param bool $leavename + * * @return string + * @since 2.0.0 */ function wpcm_club_permalinks( $post_link, $post, $leavename ) { if ( isset( $post->post_type ) && 'wpcm_club' == $post->post_type ) { @@ -574,8 +606,15 @@ function wpcm_club_permalinks( $post_link, $post, $leavename ) { /** * Prevent slug duplicates in Clubs. * - * @since 2.0.0 + * @param string $slug + * @param int $post_ID + * @param string $post_status + * @param string $post_type + * @param string $post_parent + * @param string $original_slug + * * @return string + * @since 2.0.0 */ function wpcm_prevent_slug_duplicates( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ) { $check_post_types = array( diff --git a/includes/wpcm-deprecated-functions.php b/includes/wpcm-deprecated-functions.php index b84213c..3cc3329 100644 --- a/includes/wpcm-deprecated-functions.php +++ b/includes/wpcm-deprecated-functions.php @@ -14,19 +14,43 @@ exit; // Exit if accessed directly } +/** + * @param mixed $code + * + * @return void + */ function wpcm_enqueue_js( $code ) { _deprecated_function( 'wpcm_enqueue_js', '1.0.3', '' ); } + +/** + * @return void + */ function wpcm_print_js() { _deprecated_function( 'wpcm_print_js', '1.0.3', '' ); } + +/** + * @return void + */ function check_jquery() { _deprecated_function( 'check_jquery', '1.1.0', '' ); } + +/** + * @return void + */ function is_sponsors() { _deprecated_function( 'is_sponsors', '1.1.1', '' ); } +/** + * @param string $key + * @param mixed $value + * @param int $count + * + * @return null + */ function wpcm_match_player_row( $key, $value, $count = 0 ) { _deprecated_function( 'wpcm_match_player_row', '1.4.0', '' ); return wpclubmanager_get_template( 'single-match/lineup-row.php', array( @@ -35,6 +59,14 @@ function wpcm_match_player_row( $key, $value, $count = 0 ) { 'count' => $count, ) ); } + +/** + * @param array $stats + * @param int $team + * @param int $season + * + * @return null + */ function wpcm_profile_stats_table( $stats = array(), $team = 0, $season = 0 ) { _deprecated_function( 'wpcm_profile_stats_table', '1.4.0', '' ); return wpclubmanager_get_template( 'single-player/stats-table.php', array( @@ -43,6 +75,12 @@ function wpcm_profile_stats_table( $stats = array(), $team = 0, $season = 0 ) { 'season' => $season, ) ); } + +/** + * @param WP_Post|int|null $post + * + * @return array + */ function get_wpcm_player_stats_from_post( $post = null ) { _deprecated_function( 'get_wpcm_player_stats_from_post', '1.4.0', '' ); return get_wpcm_player_stats( $post ); diff --git a/includes/wpcm-formatting-functions.php b/includes/wpcm-formatting-functions.php index 8cda0cb..11f535a 100644 --- a/includes/wpcm-formatting-functions.php +++ b/includes/wpcm-formatting-functions.php @@ -88,8 +88,10 @@ function wpcm_clean( $var ) { * Subvalue sorting. * * @access public - * @param array + * + * @param array $a * @param string $subkey + * * @return array */ function subval_sort( $a, $subkey ) { @@ -99,7 +101,7 @@ function subval_sort( $a, $subkey ) { $b[ $k ] = strtolower( $v[ $subkey ] ?? '' ); } - if ( $b != null ) { + if ( null != $b ) { asort( $b ); @@ -114,6 +116,13 @@ function subval_sort( $a, $subkey ) { return array(); } +/** + * @param array $arr + * @param mixed $key + * @param mixed $default + * + * @return mixed|null + */ function wpcm_array_value( $arr = array(), $key = 0, $default = null ) { return ( isset( $arr[ $key ] ) ? $arr[ $key ] : $default ); } @@ -138,6 +147,12 @@ function wpcm_array_value( $arr = array(), $key = 0, $default = null ) { * @return void */ if ( ! function_exists( 'wpcm_array_values_to_int' ) ) { + /** + * @param mixed $value + * @param string $key + * + * @return void + */ function wpcm_array_values_to_int( &$value, $key ) { $value = (int) $value; @@ -152,6 +167,11 @@ function wpcm_array_values_to_int( &$value, $key ) { * @return mixed */ if ( ! function_exists( 'wpcm_array_filter_checked' ) ) { + /** + * @param array $value + * + * @return bool + */ function wpcm_array_filter_checked( $value ) { return ( array_key_exists( 'checked', $value ) ); @@ -185,7 +205,8 @@ function wpcm_array_filter_checked( $value ) { * * This function transforms the php.ini notation for numbers (like '2M') to an integer. * - * @param $size + * @param mixed $size + * * @return int */ function wpcm_let_to_num( $size ) { @@ -194,14 +215,19 @@ function wpcm_let_to_num( $size ) { switch ( strtoupper( $l ) ) { case 'P': $ret *= 1024; + break; case 'T': $ret *= 1024; + break; case 'G': $ret *= 1024; + break; case 'M': $ret *= 1024; + break; case 'K': $ret *= 1024; + break; } return $ret; } @@ -210,7 +236,9 @@ function wpcm_let_to_num( $size ) { * Dropdown posts function. * * @access public - * @param array + * + * @param array $args + * * @return void */ function wpcm_dropdown_posts( $args = array() ) { @@ -233,11 +261,11 @@ function wpcm_dropdown_posts( $args = array() ) { $args['id'] = $args['name']; } - echo ''; unset( $args['name'] ); if ( $args['show_option_none'] ) { - echo ''; + echo ''; } $posts = get_posts( $args ); @@ -246,14 +274,14 @@ function wpcm_dropdown_posts( $args = array() ) { $name = get_the_title( $post->ID ); - if ( isset( $args['post_type'] ) && $args['post_type'] == 'wpcm_match' ) { + if ( isset( $args['post_type'] ) && 'wpcm_match' === $args['post_type'] ) { $timestamp = strtotime( $post->post_date ); $date_format = get_option( 'date_format' ); $name = date_i18n( $date_format, $timestamp ) . ' - ' . $name; } - echo ''; + echo ''; } echo ''; @@ -263,8 +291,10 @@ function wpcm_dropdown_posts( $args = array() ) { * Dropdown taxonomies function. * * @access public - * @param array - * @return void + * + * @param array $args + * + * @return bool */ function wpcm_dropdown_taxonomies( $args = array() ) { @@ -295,7 +325,7 @@ function wpcm_dropdown_taxonomies( $args = array() ) { $get_terms_args = $args; unset( $get_terms_args['name'] ); - $terms = get_terms( $args['taxonomy'], $get_terms_args ); + $terms = get_terms( $get_terms_args ); $name = ( $args['name'] ) ? $args['name'] : $args['taxonomy']; $id = ( $args['id'] ) ? $args['id'] : $name; @@ -317,30 +347,30 @@ function wpcm_dropdown_taxonomies( $args = array() ) { $chosen = $args['chosen']; unset( $args['chosen'] ); - printf( '', $args['taxonomy'] ); + sprintf( '', esc_attr( $args['taxonomy'] ) ); if ( $terms ) : - printf( '', esc_attr( $name ), esc_attr( $class . ( $chosen ? ' chosen_select' : '' ) ), ( null !== $placeholder ? 'data-placeholder="' . esc_html( $placeholder ) . '" ' : '' ) . esc_html( $attribute ) ); if ( strpos( $attribute, 'multiple' ) === false ) : if ( $args['show_option_all'] ) : - printf( '', $args['show_option_all'] ); + printf( '', esc_html( $args['show_option_all'] ) ); endif; if ( $args['show_option_none'] ) : - printf( '', $args['show_option_none'] ); + printf( '', esc_html( $args['show_option_none'] ) ); endif; endif; foreach ( $terms as $term ) : - if ( $args['values'] == 'term_id' ) : + if ( 'term_id' === $args['values'] ) : $this_value = $term->term_id; else : $this_value = $term->slug; @@ -350,7 +380,7 @@ function wpcm_dropdown_taxonomies( $args = array() ) { else : $selected_attribute = selected( $this_value, $selected, false ); endif; - printf( '', $this_value, $selected_attribute, $term->name ); + echo sprintf( '', esc_attr( $this_value ), $selected_attribute, esc_html( $term->name ) ); // phpcs:ignore endforeach; print( '' ); return true; @@ -364,10 +394,12 @@ function wpcm_dropdown_taxonomies( $args = array() ) { * Match player subs dropdown. * * @access public + * * @param string $name - * @param array + * @param array $arr * @param string $selected * @param string $atts + * * @return mixed $output */ function wpcm_form_dropdown( $name, $arr = array(), $selected = null, $atts = null ) { @@ -398,21 +430,26 @@ function wpcm_form_dropdown( $name, $arr = array(), $selected = null, $atts = nu * Calculate age from birth date. * * @access public - * @param string $p_strDate + * + * @param string $p_str_date + * * @return mixed */ -function get_age( $p_strDate ) { +function get_age( $p_str_date ) { - list($Y, $m, $d) = explode( '-', $p_strDate ); + list($y, $m, $d) = explode( '-', $p_str_date ); - return( date( 'md' ) < $m . $d ? date( 'Y' ) - $Y - 1 : date( 'Y' ) - $Y ); + return( gmdate( 'md' ) < $m . $d ? gmdate( 'Y' ) - $y - 1 : gmdate( 'Y' ) - $y ); } /** * Calculate age from birth date. * * @access public - * @param string $p_strDate + * + * @param mixed $a + * @param mixed $b + * * @return mixed */ function compare_dates( $a, $b ) { @@ -428,11 +465,14 @@ function compare_dates( $a, $b ) { * Calculate division. * * @access public - * @param string $p_strDate + * + * @param mixed $a + * @param mixed $b + * * @return mixed */ function wpcm_divide( $a, $b ) { - if ( $b != 0 ) { + if ( 0 != $b ) { $result = $a / $b; } else { $result = 0; diff --git a/includes/wpcm-match-functions.php b/includes/wpcm-match-functions.php index 9de422b..9c3bb31 100644 --- a/includes/wpcm-match-functions.php +++ b/includes/wpcm-match-functions.php @@ -14,7 +14,15 @@ exit; // Exit if accessed directly } -// generate title + +/** + * Generate title + * + * @param string $title + * @param int $id + * + * @return mixed|string + */ function match_title( $title, $id = null ) { if ( get_post_type( $id ) == 'wpcm_match' ) { @@ -25,7 +33,7 @@ function match_title( $title, $id = null ) { $away_id = (int) get_post_meta( $id, 'wpcm_away_club', true ); $home_club = get_post( $home_id ); $away_club = get_post( $away_id ); - if ( $title_format == '%home% vs %away%' ) { + if ( '%home% vs %away%' === $title_format ) { $side1 = $home_club->post_title; $side2 = $away_club->post_title; } else { @@ -39,7 +47,13 @@ function match_title( $title, $id = null ) { } add_filter( 'the_title', 'match_title', 10, 2 ); -// // generate title +/** + * Generate match title + * + * @param string $title + * + * @return mixed|string + */ function match_wp_title( $title ) { if ( get_post_type() == 'wpcm_match' ) { @@ -60,9 +74,12 @@ function wpcm_match_players_item_order() { global $wpdb; - $order = explode( ',', $_POST['order'] ); + $order = explode( ',', $_POST['order'] ); // phpcs:ignore $counter = 0; foreach ( $order as $item_id ) { + if ( ! is_int( $item_id ) ) { + continue; + } $wpdb->update( $wpdb->posts, array( 'menu_order' => $counter ), array( 'ID' => $item_id ) ); ++$counter; } @@ -100,16 +117,16 @@ function wpcm_get_match_outcome( $post ) { $away_goals = $runs['away'] + $extras['away']; } if ( $postponed ) { - if ( $walkover !== '' ) { + if ( '' != $walkover ) { if ( $club == $home_club ) { - if ( $walkover == 'home_win' ) { + if ( 'home_win' === $walkover ) { $outcome = 'win'; - } elseif ( $walkover == 'away_win' ) { + } elseif ( 'away_win' === $walkover ) { $outcome = 'loss'; } - } elseif ( $walkover == 'home_win' ) { + } elseif ( 'home_win' === $walkover ) { $outcome = 'loss'; - } elseif ( $walkover == 'away_win' ) { + } elseif ( 'away_win' === $walkover ) { $outcome = 'win'; } } else { @@ -144,9 +161,11 @@ function wpcm_get_match_outcome( $post ) { * Get match result. * * @access public + * * @param int $post + * * @return string $result - * @since 1.4.6 + * @since 1.4.6 */ function wpcm_get_match_result( $post ) { @@ -159,30 +178,30 @@ function wpcm_get_match_result( $post ) { $walkover = get_post_meta( $post, '_wpcm_walkover', true ); $home_goals = get_post_meta( $post, 'wpcm_home_goals', true ); $away_goals = get_post_meta( $post, 'wpcm_away_goals', true ); - if ( $sport == 'gaelic' ) { + if ( 'gaelic' === $sport ) { $home_gaa_goals = get_post_meta( $post, 'wpcm_home_gaa_goals', true ); $home_gaa_points = get_post_meta( $post, 'wpcm_home_gaa_points', true ); $away_gaa_goals = get_post_meta( $post, 'wpcm_away_gaa_goals', true ); $away_gaa_points = get_post_meta( $post, 'wpcm_away_gaa_points', true ); } - if ( $sport == 'cricket' ) { + if ( 'cricket' === $sport ) { $runs = unserialize( get_post_meta( $post, '_wpcm_match_runs', true ) ); $extras = unserialize( get_post_meta( $post, '_wpcm_match_extras', true ) ); $wickets = unserialize( get_post_meta( $post, '_wpcm_match_wickets', true ) ); $cricket_outcome = get_post_meta( $post, '_wpcm_cricket_outcome', true ); if ( is_array( $cricket_outcome ) ) { - if ( $cricket_outcome[0] == 'won_by' ) { + if ( 'won_by' === $cricket_outcome[0] ) { $outcome1 = __( 'Won by', 'wp-club-manager' ); - } elseif ( $cricket_outcome[0] == 'lost_by' ) { + } elseif ( 'lost_by' === $cricket_outcome[0] ) { $outcome1 = __( 'Lost by', 'wp-club-manager' ); - } elseif ( $cricket_outcome[0] == 'drawn' ) { + } elseif ( 'drawn' === $cricket_outcome[0] ) { $outcome1 = __( 'Match Drawn', 'wp-club-manager' ); } - if ( $cricket_outcome[2] == 'runs' ) { + if ( 'runs' === $cricket_outcome[2] ) { $outcome2 = __( 'runs', 'wp-club-manager' ); - } elseif ( $cricket_outcome[2] == 'wickets' ) { + } elseif ( 'wickets' === $cricket_outcome[2] ) { $outcome2 = __( 'wickets', 'wp-club-manager' ); - } elseif ( $cricket_outcome[2] == 'innings' ) { + } elseif ( 'innings' === $cricket_outcome[2] ) { $outcome2 = __( 'innings', 'wp-club-manager' ); } $outcome = $outcome1 . ' ' . $cricket_outcome[1] . ' ' . $outcome2; @@ -192,11 +211,11 @@ function wpcm_get_match_result( $post ) { } if ( $postponed ) { - if ( $walkover == 'home_win' ) { + if ( 'home_win' === $walkover ) { $result = _x( 'H', 'HW - home walkover', 'wp-club-manager' ) . ' ' . $delimiter . ' ' . _x( 'W', 'HW - home walkover', 'wp-club-manager' ); $side1 = _x( 'H', 'HW - home walkover', 'wp-club-manager' ); $side2 = _x( 'W', 'HW - home walkover', 'wp-club-manager' ); - } elseif ( $walkover == 'away_win' ) { + } elseif ( 'away_win' === $walkover ) { $result = _x( 'A', 'AW - away walkover', 'wp-club-manager' ) . ' ' . $delimiter . ' ' . _x( 'W', 'AW - away walkover', 'wp-club-manager' ); $side1 = _x( 'A', 'AW - away walkover', 'wp-club-manager' ); $side2 = _x( 'W', 'AW - away walkover', 'wp-club-manager' ); @@ -205,22 +224,22 @@ function wpcm_get_match_result( $post ) { $side1 = _x( 'P', 'Postponed', 'wp-club-manager' ); $side2 = _x( 'P', 'Postponed', 'wp-club-manager' ); } - } elseif ( $hide == 'yes' && ! is_user_logged_in() ) { + } elseif ( 'yes' === $hide && ! is_user_logged_in() ) { $result = ( $played ? __( 'x', 'wp-club-manager' ) . ' ' . $delimiter . ' ' . __( 'x', 'wp-club-manager' ) : '' ); $side1 = __( 'x', 'wp-club-manager' ); $side2 = __( 'x', 'wp-club-manager' ); - } elseif ( $format == '%home% vs %away%' ) { - if ( $sport == 'gaelic' ) { + } elseif ( '%home% vs %away%' === $format ) { + if ( 'gaelic' === $sport ) { $result = ( $played ? $home_gaa_goals . '-' . $home_gaa_points . ' ' . $delimiter . ' ' . $away_gaa_goals . '-' . $away_gaa_points : '' ); $side1 = ( $played ? $home_gaa_goals . '-' . $home_gaa_points : '-' ); $side2 = ( $played ? $away_gaa_goals . '-' . $away_gaa_points : '-' ); - } elseif ( $sport == 'cricket' ) { + } elseif ( 'cricket' === $sport ) { $home_score = $runs['home'] + $extras['home']; $away_score = $runs['away'] + $extras['away']; - $home_wickets = ( $wickets['home'] == '10' ? '' : '/' . $wickets['home'] ); - $away_wickets = ( $wickets['away'] == '10' ? '' : '/' . $wickets['away'] ); + $home_wickets = ( '10' == $wickets['home'] ? '' : '/' . $wickets['home'] ); + $away_wickets = ( '10' == $wickets['away'] ? '' : '/' . $wickets['away'] ); // $result = ( $played ? $home_score . $home_wickets . ' ' . $delimiter . ' ' . $away_score . $away_wickets : '' ); $result = $outcome; @@ -234,18 +253,18 @@ function wpcm_get_match_result( $post ) { $side2 = ( $played ? $away_goals : '' ); } - } elseif ( $sport == 'gaelic' ) { + } elseif ( 'gaelic' === $sport ) { $result = ( $played ? $away_gaa_goals . '-' . $away_gaa_points . ' ' . $delimiter . ' ' . $home_gaa_goals . '-' . $home_gaa_points : '' ); $side1 = ( $played ? $away_gaa_goals . '-' . $away_gaa_points : '-' ); $side2 = ( $played ? $home_gaa_goals . '-' . $home_gaa_points : '-' ); - } elseif ( $sport == 'cricket' ) { + } elseif ( 'cricket' === $sport ) { $home_score = $runs['home'] + $extras['home']; $away_score = $runs['away'] + $extras['away']; - $home_wickets = ( $wickets['home'] == '10' ? '' : '/' . $wickets['home'] ); - $away_wickets = ( $wickets['away'] == '10' ? '' : '/' . $wickets['away'] ); + $home_wickets = ( '10' == $wickets['home'] ? '' : '/' . $wickets['home'] ); + $away_wickets = ( '10' == $wickets['away'] ? '' : '/' . $wickets['away'] ); // $result = ( $played ? $away_score . $away_wickets . ' ' . $delimiter . ' ' . $home_score . $home_wickets : '' ); $result = $outcome; @@ -299,9 +318,11 @@ function wpcm_get_match_comp( $post ) { * Get match team. * * @access public + * * @param int $post + * * @return array - * @since 1.4.0 + * @since 1.4.0 */ function wpcm_get_match_team( $post ) { @@ -331,9 +352,12 @@ function wpcm_get_match_team( $post ) { * Get match team names. * * @access public - * @param int $post + * + * @param int $post + * @param bool $abbr + * * @return array $side1 $side2 - * @since 2.1.0 + * @since 2.1.0 */ function wpcm_get_match_clubs( $post, $abbr = false ) { @@ -341,15 +365,15 @@ function wpcm_get_match_clubs( $post, $abbr = false ) { $home_club = get_post_meta( $post, 'wpcm_home_club', true ); $away_club = get_post_meta( $post, 'wpcm_away_club', true ); - if ( $abbr == false ) { - if ( $format == '%home% vs %away%' ) { + if ( false == $abbr ) { + if ( '%home% vs %away%' === $format ) { $side1 = wpcm_get_team_name( $home_club, $post ); $side2 = wpcm_get_team_name( $away_club, $post ); } else { $side1 = wpcm_get_team_name( $away_club, $post ); $side2 = wpcm_get_team_name( $home_club, $post ); } - } elseif ( $format == '%home% vs %away%' ) { + } elseif ( '%home% vs %away%' === $format ) { $side1 = get_club_abbreviation( $home_club ); $side2 = get_club_abbreviation( $away_club ); } else { @@ -364,10 +388,12 @@ function wpcm_get_match_clubs( $post, $abbr = false ) { * Get match opponents. * * @access public + * * @param int $post - * @param bool $link_club + * @param bool $abbr + * * @return string $opponent - * @since 2.1.0 + * @since 2.1.0 */ function wpcm_get_match_opponents( $post, $abbr = false ) { @@ -375,7 +401,7 @@ function wpcm_get_match_opponents( $post, $abbr = false ) { $home_club = get_post_meta( $post, 'wpcm_home_club', true ); $away_club = get_post_meta( $post, 'wpcm_away_club', true ); $opponent = ''; - if ( $abbr == false ) { + if ( false == $abbr ) { if ( $club == $home_club ) { $opponent = get_the_title( $away_club, true ); } elseif ( $club == $away_club ) { @@ -394,9 +420,13 @@ function wpcm_get_match_opponents( $post, $abbr = false ) { * Get match club badges. * * @access public - * @param int $post + * + * @param int $post + * @param null|string $size + * @param null|array $args + * * @return array $home_badge $away_badge - * @since 1.4.0 + * @since 1.4.0 */ function wpcm_get_match_badges( $post, $size = null, $args = null ) { @@ -404,7 +434,7 @@ function wpcm_get_match_badges( $post, $size = null, $args = null ) { $home_club = get_post_meta( $post, 'wpcm_home_club', true ); $away_club = get_post_meta( $post, 'wpcm_away_club', true ); - if ( $format == '%home% vs %away%' ) { + if ( '%home% vs %away%' === $format ) { if ( has_post_thumbnail( $home_club ) ) { $badge1 = get_the_post_thumbnail( $home_club, $size, $args ); } else { @@ -483,6 +513,11 @@ function wpcm_get_match_venue( $post ) { * @return mixed $players */ if ( ! function_exists( 'get_wpcm_match_player_stats' ) ) { + /** + * @param int|null $post_id + * + * @return mixed + */ function get_wpcm_match_player_stats( $post_id = null ) { if ( ! $post_id ) { diff --git a/includes/wpcm-player-functions.php b/includes/wpcm-player-functions.php index c87ec00..c8dc9c2 100644 --- a/includes/wpcm-player-functions.php +++ b/includes/wpcm-player-functions.php @@ -17,6 +17,9 @@ /** * Get player titles. * + * @param int $post + * @param string $format + * * @return string * @since 2.0.0 */ @@ -35,13 +38,13 @@ function get_player_title( $post, $format = 'full' ) { $start = strrpos( $name, ' ' ) + 1; $last = substr( $name, $start ); - if ( $format == 'full' ) { + if ( 'full' === $format ) { $name = ( $firstname ? '' . $firstname . '' : '' . $first . '' ) . ' ' . ( $lastname ? '' . $lastname . '' : '' . $last . '' ); - } elseif ( $format == 'first' ) { + } elseif ( 'first' === $format ) { $name = ( $firstname ? '' . $firstname . '' : '' . $first . '' ); - } elseif ( $format == 'last' ) { + } elseif ( 'last' === $format ) { $name = ( $lastname ? '' . $lastname . '' : '' . $last . '' ); - } elseif ( $format == 'initial' ) { + } elseif ( 'initial' === $format ) { $name = ( $firstname ? '' . substr( $firstname, 0, 1 ) . '. ' : '' . substr( $first, 0, 1 ) . '.' ) . ( $lastname ? '' . $lastname . '' : '' . $last . '' ); } else { $name = ( $firstname ? '' . $firstname . '' : '' . $first . '' ) . ' ' . ( $lastname ? '' . $lastname . '' : '' . $last . '' ); @@ -127,7 +130,7 @@ function wpcm_get_appearance_and_subs_labels() { $apps = wpcm_get_appearance_labels(); $subs = array( - 'subs' => __( 'SUBS', 'Substitute Appearances', 'wp-club-manager' ), + 'subs' => _x( 'SUBS', 'Substitute Appearances', 'wp-club-manager' ), ); $appearances = array_merge( $apps, $subs ); @@ -383,9 +386,13 @@ function wpcm_get_player_seasons( $post ) { * Get player thumbnail. * * @access public - * @param int $post + * + * @param int $post + * @param string|null $size + * @param array|null $args + * * @return mixed $thumb - * @since 1.4.0 + * @since 1.4.0 */ function wpcm_get_player_thumbnail( $post, $size = null, $args = null ) { @@ -447,16 +454,18 @@ function wpcm_get_player_appearances( $player_detail ) { * Get player stat - used in templates/shortcodes/players.php. * * @access public + * * @param array $player_detail * @param string $stat + * * @return string $stat - * @since 1.4.0 + * @since 1.4.0 */ function wpcm_get_player_stat( $player_detail, $stat ) { - if ( $stat == 'rating' ) { + if ( 'rating' === $stat ) { $stat = wpcm_get_player_average_rating( $player_detail['rating'], $player_detail['appearances'] ); - } elseif ( $stat == 'appearances' ) { + } elseif ( 'appearances' === $stat ) { $stat = wpcm_get_player_appearances( $player_detail ); } else { $stat = $player_detail[ $stat ] ?? null; @@ -469,14 +478,16 @@ function wpcm_get_player_stat( $player_detail, $stat ) { * Get player stat value from presets - used in templates/shortcodes/players.php * * @access public - * @param array $player_details + * * @param int $post - * @param array $player_stats * @param string $stat + * @param array $player_details + * @param array $player_stats * @param int $team * @param int $season + * * @return array $player_details - * @since 1.4.0 + * @since 1.4.0 */ function wpcm_get_player_preset_stat( $post, $stat, $player_details = array(), $player_stats = array(), $team = 0, $season = 0 ) { diff --git a/includes/wpcm-preset-functions.php b/includes/wpcm-preset-functions.php index c106252..860a308 100644 --- a/includes/wpcm-preset-functions.php +++ b/includes/wpcm-preset-functions.php @@ -1893,6 +1893,9 @@ function wpcm_get_sport_presets() { )); } +/** + * @return array + */ function wpcm_get_sport_options() { $sports = wpcm_get_sport_presets(); $options = array(); diff --git a/includes/wpcm-standings-functions.php b/includes/wpcm-standings-functions.php index 109c0ad..e0f7d90 100644 --- a/includes/wpcm-standings-functions.php +++ b/includes/wpcm-standings-functions.php @@ -23,6 +23,12 @@ * @return int */ if ( ! function_exists( 'wpcm_club_standings_sort' ) ) { + /** + * @param mixed $a + * @param mixed $b + * + * @return int + */ function wpcm_club_standings_sort( $a, $b ) { $priority_1 = get_option( 'wpcm_standings_orderby' ); @@ -73,6 +79,12 @@ function wpcm_club_standings_sort( $a, $b ) { * @return int */ if ( ! function_exists( 'wpcm_club_standings_pct_sort' ) ) { + /** + * @param mixed $a + * @param mixed $b + * + * @return int + */ function wpcm_club_standings_pct_sort( $a, $b ) { if ( $a->wpcm_stats['pct'] > $b->wpcm_stats['pct'] ) { @@ -119,6 +131,12 @@ function wpcm_club_standings_pct_sort( $a, $b ) { * @return array */ if ( ! function_exists( 'wpcm_club_standings_sort_by' ) ) { + /** + * @param string $subkey + * @param array $a + * + * @return array + */ function wpcm_club_standings_sort_by( $subkey, $a ) { foreach ( $a as $k => $v ) { @@ -126,7 +144,7 @@ function wpcm_club_standings_sort_by( $subkey, $a ) { $b[ $k ] = (float) $v->wpcm_stats[ $subkey ]; } - if ( $b != null ) { + if ( null != $b ) { arsort( $b ); foreach ( $b as $key => $val ) { @@ -151,6 +169,15 @@ function wpcm_club_standings_sort_by( $subkey, $a ) { * @return mixed $output */ if ( ! function_exists( 'get_wpcm_table_total_stats' ) ) { + /** + * @param int $post_id + * @param int $comp + * @param int $season + * @param array $manualstats + * @param int $team + * + * @return array + */ function get_wpcm_table_total_stats( $post_id = null, $comp = null, $season = null, $manualstats = null, $team = null ) { $sport = get_option( 'wpcm_sport' ); @@ -159,7 +186,7 @@ function get_wpcm_table_total_stats( $post_id = null, $comp = null, $season = nu foreach ( $output as $key => $val ) { - if ( $key == 'pct' ) { + if ( 'pct' === $key ) { $combined_win = $autostats['w'] + $manualstats['w']; $combined_played = $autostats['p'] + $manualstats['p']; @@ -171,7 +198,7 @@ function get_wpcm_table_total_stats( $post_id = null, $comp = null, $season = nu $output[ $key ] = round( $wpct, 3 ); - } elseif ( $sport == 'footy' && $key == 'gd' ) { + } elseif ( 'footy' === $sport && 'gd' === $key ) { $combined_for = $autostats['f'] + $manualstats['f']; $combined_against = $autostats['a'] + $manualstats['a']; @@ -197,6 +224,9 @@ function get_wpcm_table_total_stats( $post_id = null, $comp = null, $season = nu } if ( ! function_exists( 'wpcm_table_priorities' ) ) { + /** + * @return array + */ function wpcm_table_priorities() { $priorities = array( @@ -218,6 +248,12 @@ function wpcm_table_priorities() { } if ( ! function_exists( 'wpcm_sort_table_clubs' ) ) { + /** + * @param array $a + * @param array $b + * + * @return int + */ function wpcm_sort_table_clubs( $a, $b ) { $priorities = wpcm_table_priorities(); @@ -225,15 +261,13 @@ function wpcm_sort_table_clubs( $a, $b ) { // Loop through priorities foreach ( $priorities as $priority ) { - if ( $priority['column'] == 'compare' ) { - - } elseif ( wpcm_array_value( $a->wpcm_stats, $priority['column'], 0 ) != wpcm_array_value( $b->wpcm_stats, $priority['column'], 0 ) ) { + if ( wpcm_array_value( $a->wpcm_stats, $priority['column'], 0 ) != wpcm_array_value( $b->wpcm_stats, $priority['column'], 0 ) ) { // Compare column values $output = wpcm_array_value( $a->wpcm_stats, $priority['column'], 0 ) - wpcm_array_value( $b->wpcm_stats, $priority['column'], 0 ); // Flip value if descending order - if ( $priority['order'] == 'DESC' ) { + if ( 'DESC' === $priority['order'] ) { $output = 0 - $output; } diff --git a/includes/wpcm-stats-functions.php b/includes/wpcm-stats-functions.php index 5bd9f3b..222eee2 100644 --- a/includes/wpcm-stats-functions.php +++ b/includes/wpcm-stats-functions.php @@ -26,9 +26,9 @@ function wpcm_get_preset_labels( $type = 'players', $format = 'label' ) { $sport = get_option( 'wpcm_sport' ); $data = wpcm_get_sport_presets(); - if ( $type == 'standings' ) { + if ( 'standings' == $type ) { $stats = $data[ $sport ]['standings_columns']; - } elseif ( $type == 'players' ) { + } elseif ( 'players' == $type ) { $stats = $data[ $sport ]['stats_labels']; } @@ -43,8 +43,8 @@ function wpcm_get_preset_labels( $type = 'players', $format = 'label' ) { /** * Get preset stats and standings. * - * @param string $type - * @param string $format + * @param string $section + * * @return array */ function wpcm_get_section_stats( $section = 'batting' ) { @@ -63,13 +63,13 @@ function wpcm_get_section_stats( $section = 'batting' ) { return $output; } -/** - * Get empty player stats row. - * - * @access public - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_player_stats_empty_row' ) ) { + /** + * Get empty player stats row. + * + * @access public + * @return mixed $output + */ function get_wpcm_player_stats_empty_row() { $player_stats_labels = wpcm_get_preset_labels(); @@ -84,13 +84,13 @@ function get_wpcm_player_stats_empty_row() { } } -/** - * Get empty club stats row. - * - * @access public - * @return array - */ if ( ! function_exists( 'get_wpcm_club_stats_empty_row' ) ) { + /** + * Get empty club stats row. + * + * @access public + * @return array + */ function get_wpcm_club_stats_empty_row() { $standings_stats_labels = wpcm_get_preset_labels( 'standings', 'label' ); @@ -105,16 +105,18 @@ function get_wpcm_club_stats_empty_row() { } } -/** - * Get total player stats. - * - * @access public - * @param string $post_id - * @param string $team - * @param string $season - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_player_total_stats' ) ) { + /** + * Get total player stats. + * + * @access public + * + * @param string $post_id + * @param string $team + * @param string $season + * + * @return mixed $output + */ function get_wpcm_player_total_stats( $post_id = null, $team = null, $season = null ) { $output = get_wpcm_player_stats_empty_row(); @@ -129,16 +131,18 @@ function get_wpcm_player_total_stats( $post_id = null, $team = null, $season = n } } -/** - * Get total club stats. - * - * @access public - * @param string $post_id - * @param string $comp - * @param string $season - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_club_total_stats' ) ) { + /** + * Get total club stats. + * + * @access public + * + * @param string $post_id + * @param string $comp + * @param string $season + * + * @return mixed $output + */ function get_wpcm_club_total_stats( $post_id = null, $comp = null, $season = null ) { $output = get_wpcm_club_stats_empty_row(); @@ -147,7 +151,7 @@ function get_wpcm_club_total_stats( $post_id = null, $comp = null, $season = nul foreach ( $output as $key => $val ) { - if ( $key == 'pct' ) { + if ( 'pct' == $key ) { $combined_win = $autostats['w'] + $manualstats['w']; $combined_played = $autostats['p'] + $manualstats['p']; @@ -172,16 +176,18 @@ function get_wpcm_club_total_stats( $post_id = null, $comp = null, $season = nul } } -/** - * Get manual player stats. - * - * @access public - * @param string $post_id - * @param string $team - * @param string $season - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_player_manual_stats' ) ) { + /** + * Get manual player stats. + * + * @access public + * + * @param string $post_id + * @param string $team + * @param string $season + * + * @return mixed $output + */ function get_wpcm_player_manual_stats( $post_id = null, $team = null, $season = null ) { $output = get_wpcm_player_stats_empty_row(); @@ -207,16 +213,18 @@ function get_wpcm_player_manual_stats( $post_id = null, $team = null, $season = } } -/** - * Get manual club stats. - * - * @access public - * @param string $post_id - * @param string $comp - * @param string $season - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_club_manual_stats' ) ) { + /** + * Get manual club stats. + * + * @access public + * + * @param string $post_id + * @param string $comp + * @param string $season + * + * @return mixed $output + */ function get_wpcm_club_manual_stats( $post_id = null, $comp = null, $season = null ) { $output = get_wpcm_club_stats_empty_row(); @@ -242,16 +250,18 @@ function get_wpcm_club_manual_stats( $post_id = null, $comp = null, $season = nu } } -/** - * Get auto player stats. - * - * @access public - * @param string $post_id - * @param string $team_id - * @param string $season_id - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_player_auto_stats' ) ) { + /** + * Get auto player stats. + * + * @access public + * + * @param string $post_id + * @param string $team + * @param string $season_id + * + * @return mixed $output + */ function get_wpcm_player_auto_stats( $post_id = null, $team = null, $season_id = null ) { // if ( !$post_id ) global $post_id; @@ -342,6 +352,14 @@ function get_wpcm_player_auto_stats( $post_id = null, $team = null, $season_id = * @return mixed $output */ if ( ! function_exists( 'get_wpcm_club_auto_stats' ) ) { + /** + * @param int $post_id + * @param int $comp + * @param int $season + * @param int $team + * + * @return array + */ function get_wpcm_club_auto_stats( $post_id = null, $comp = null, $season = null, $team = null ) { if ( ! $post_id ) { @@ -405,11 +423,11 @@ function get_wpcm_club_auto_stats( $post_id = null, $comp = null, $season = null $a = get_post_meta( $match->ID, 'wpcm_away_goals', true ); } $hb = get_post_meta( $match->ID, 'wpcm_home_bonus', true ); - $won = $overtime == 0 && (int) ( $f > $a ); + $won = 0 == $overtime && (int) ( $f > $a ); $draw = (int) ( $f == $a ); - $lost = $overtime == 0 && (int) ( $f < $a ); - $otw = $overtime == 1 && (int) ( $f > $a ); - $otl = $overtime == 1 && (int) ( $f < $a ); + $lost = 0 == $overtime && (int) ( $f < $a ); + $otw = 1 == $overtime && (int) ( $f > $a ); + $otl = 1 == $overtime && (int) ( $f < $a ); ++$output['p']; $output['w'] += $won; if ( array_key_exists( 'd', $output ) ) { @@ -436,11 +454,11 @@ function get_wpcm_club_auto_stats( $post_id = null, $comp = null, $season = null } $output['pts'] += $won * get_option( 'wpcm_standings_win_points' ) + $lost * get_option( 'wpcm_standings_loss_points' ); } - if ( $postponed && $walkover == 'home_win' ) { + if ( $postponed && 'home_win' == $walkover ) { ++$output['p']; $output['w'] += 1; $output['pts'] += get_option( 'wpcm_standings_win_points' ); - } elseif ( $postponed && $walkover == 'away_win' ) { + } elseif ( $postponed && 'away_win' == $walkover ) { ++$output['p']; $output['l'] += 1; $output['pts'] += get_option( 'wpcm_standings_loss_points' ); @@ -471,11 +489,11 @@ function get_wpcm_club_auto_stats( $post_id = null, $comp = null, $season = null $a = get_post_meta( $match->ID, 'wpcm_home_goals', true ); } $ab = get_post_meta( $match->ID, 'wpcm_away_bonus', true ); - $won = $overtime == 0 && (int) ( $f > $a ); + $won = 0 == $overtime && (int) ( $f > $a ); $draw = (int) ( $f == $a ); - $lost = $overtime == 0 && (int) ( $f < $a ); - $otw = $overtime == 1 && (int) ( $f > $a ); - $otl = $overtime == 1 && (int) ( $f < $a ); + $lost = 0 == $overtime && (int) ( $f < $a ); + $otw = 1 == $overtime && (int) ( $f > $a ); + $otl = 1 == $overtime && (int) ( $f < $a ); ++$output['p']; $output['w'] += $won; if ( array_key_exists( 'd', $output ) ) { @@ -502,11 +520,11 @@ function get_wpcm_club_auto_stats( $post_id = null, $comp = null, $season = null } $output['pts'] += $won * get_option( 'wpcm_standings_win_points' ) + $lost * get_option( 'wpcm_standings_loss_points' ); } - if ( $postponed && $walkover == 'away_win' ) { + if ( $postponed && 'away_win' == $walkover ) { ++$output['p']; $output['w'] += 1; $output['pts'] += get_option( 'wpcm_standings_win_points' ); - } elseif ( $postponed && $walkover == 'home_win' ) { + } elseif ( $postponed && 'home_win' === $walkover ) { ++$output['p']; $output['l'] += 1; $output['pts'] += get_option( 'wpcm_standings_loss_points' ); @@ -517,14 +535,15 @@ function get_wpcm_club_auto_stats( $post_id = null, $comp = null, $season = null } } -/** - * Get total player stats. - * - * @access public - * @param string $post_id - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_player_stats' ) ) { + + /** + * Get total player stats. + * + * @param WP_Post $post + * + * @return array + */ function get_wpcm_player_stats( $post = null ) { if ( ! $post ) { @@ -617,14 +636,14 @@ function get_wpcm_player_stats( $post = null ) { } -/** - * Get club stats. - * - * @access public - * @param string $post - * @return mixed $output - */ if ( ! function_exists( 'get_wpcm_club_stats' ) ) { + /** + * Get club stats. + * + * @param WP_Post $post + * + * @return array + */ function get_wpcm_club_stats( $post = null ) { if ( ! $post ) { @@ -718,9 +737,11 @@ function get_wpcm_club_stats( $post = null ) { * Get player subtitute appearances. * * @access public - * @param int $post + * + * @param int $id * @param int $season * @param int $team + * * @return int $total_subs */ function get_player_subs_total( $id = null, $season = null, $team = null ) { @@ -773,7 +794,7 @@ function get_player_subs_total( $id = null, $season = null, $team = null ) { $matches = get_posts( $query_args ); - $size = sizeof( $matches ); + $size = count( $matches ); $total_subs = '0'; @@ -796,16 +817,16 @@ function get_player_subs_total( $id = null, $season = null, $team = null ) { return $total_subs; } -/** - * Match player subs dropdown. - * - * @access public - * @param array - * @param string $type ('manual') - * @param string $index ('goals') - * @return int - */ if ( ! function_exists( 'get_wpcm_stats_value' ) ) { + /** + * Match player subs dropdown. + * + * @param array $stats + * @param string $type + * @param string $index + * + * @return float|int + */ function get_wpcm_stats_value( $stats = array(), $type = 'manual', $index = 'goals' ) { if ( is_array( $stats ) ) { @@ -823,18 +844,18 @@ function get_wpcm_stats_value( $stats = array(), $type = 'manual', $index = 'goa } } -/** - * Get the value of the stats. - * - * @access public - * @param string $stats - * @param string $type - * @param string $index - * @return void - */ if ( ! function_exists( 'wpcm_stats_value' ) ) { + /** + * Get the value of the stats. + * + * @param array $stats + * @param string $type + * @param string $index + * + * @return void + */ function wpcm_stats_value( $stats, $type, $index ) { - echo get_wpcm_stats_value( $stats, $type, $index ); + echo esc_html( get_wpcm_stats_value( $stats, $type, $index ) ); } } diff --git a/includes/wpcm-template-functions.php b/includes/wpcm-template-functions.php index fc23a83..bf605e7 100644 --- a/includes/wpcm-template-functions.php +++ b/includes/wpcm-template-functions.php @@ -324,12 +324,12 @@ function wpclubmanager_template_single_player_dropdown() { $custom = get_post_custom( $player_post->ID ); - $players[ get_permalink( $player_post->ID ) ] = ( $custom['wpcm_number'][0] == null ? '' : $custom['wpcm_number'][0] . '. ' ) . get_the_title( $player_post->ID ); + $players[ get_permalink( $player_post->ID ) ] = ( null == $custom['wpcm_number'][0] ? '' : $custom['wpcm_number'][0] . '. ' ) . get_the_title( $player_post->ID ); endforeach; $custom = get_post_custom(); - if ( $custom['wpcm_number'][0] == null ) { + if ( null == $custom['wpcm_number'][0] ) { $number = '-'; $name = get_the_title( $post->ID ); } else { @@ -337,7 +337,7 @@ function wpclubmanager_template_single_player_dropdown() { $name = $number . '. ' . get_the_title( $post->ID ); } - echo wpcm_form_dropdown( 'switch-player-profile', $players, get_permalink(), array( 'onchange' => 'window.location = this.value;' ) ); + echo wp_kses_post( wpcm_form_dropdown( 'switch-player-profile', $players, get_permalink(), array( 'onchange' => 'window.location = this.value;' ) ) ); } } @@ -393,7 +393,7 @@ function wpclubmanager_template_single_staff_dropdown() { $players[ get_permalink( $player_post->ID ) ] = get_the_title( $player_post->ID ); endforeach; - echo wpcm_form_dropdown( 'switch-player-profile', $players, get_permalink(), array( 'onchange' => 'window.location = this.value;' ) ); + echo wp_kses_post( wpcm_form_dropdown( 'switch-player-profile', $players, get_permalink(), array( 'onchange' => 'window.location = this.value;' ) ) ); } } @@ -524,7 +524,7 @@ function wpclubmanager_template_single_match_status() { $sport = get_option( 'wpcm_sport' ); - if ( $sport == 'soccer' ) { + if ( 'soccer' === $sport ) { wpclubmanager_get_template( 'single-match/status.php' ); } } diff --git a/includes/wpcm-user-functions.php b/includes/wpcm-user-functions.php index 738c7c6..c86634c 100644 --- a/includes/wpcm-user-functions.php +++ b/includes/wpcm-user-functions.php @@ -107,7 +107,7 @@ function wpcm_create_new_user( $email, $username = '', $password = '' ) { * @return array */ function wpcm_modify_editable_roles( $roles ) { - if ( ! current_user_can( 'administrator' ) ) { + if ( ! current_user_can( 'manage_options' ) ) { unset( $roles['administrator'] ); } return $roles; @@ -133,7 +133,7 @@ function wpcm_modify_map_meta_cap( $caps, $cap, $user_id, $args ) { case 'delete_user': if ( ! isset( $args[0] ) || $args[0] === $user_id ) { break; - } elseif ( user_can( $args[0], 'administrator' ) && ! current_user_can( 'administrator' ) ) { + } elseif ( user_can( $args[0], 'manage_options' ) && ! current_user_can( 'manage_options' ) ) { $caps[] = 'do_not_allow'; } break; diff --git a/includes/wpcm-widget-functions.php b/includes/wpcm-widget-functions.php index 20c3c98..962c5a5 100644 --- a/includes/wpcm-widget-functions.php +++ b/includes/wpcm-widget-functions.php @@ -16,12 +16,12 @@ // Include widget classes require_once 'abstracts/class-wpcm-widget.php'; -require_once 'widgets/class-wpcm-widget-fixtures.php'; -require_once 'widgets/class-wpcm-widget-results.php'; -require_once 'widgets/class-wpcm-widget-standings.php'; -require_once 'widgets/class-wpcm-widget-sponsors.php'; -require_once 'widgets/class-wpcm-widget-players.php'; -require_once 'widgets/class-wpcm-widget-birthdays.php'; +require_once 'widgets/class-wpcm-fixtures-widget.php'; +require_once 'widgets/class-wpcm-results-widget.php'; +require_once 'widgets/class-wpcm-standings-widget.php'; +require_once 'widgets/class-wpcm-sponsors-widget.php'; +require_once 'widgets/class-wpcm-players-widget.php'; +require_once 'widgets/class-wpcm-birthdays-widget.php'; /** * Register Widgets diff --git a/index.php b/index.php index 6220032..e1b76cc 100644 --- a/index.php +++ b/index.php @@ -1,2 +1,4 @@ + + + diff --git a/templates/content-single-club.php b/templates/content-single-club.php index a9d6f95..7636495 100644 --- a/templates/content-single-club.php +++ b/templates/content-single-club.php @@ -13,8 +13,6 @@ exit; // Exit if accessed directly } -// global $post; - $details = get_club_details( $post ); $primary_color_bg = ( $details['primary_color'] ) ? ' style="background-color:' . $details['primary_color'] . ';color:#fff;text-shadow: 0 0 3px #000;"' : ''; @@ -41,21 +39,21 @@
    - - + + - - + + - - + + - - + + - - + + - - + + - + @@ -107,7 +105,7 @@ - +
    @@ -120,41 +118,40 @@ if ( is_club_mode() ) { - if ( get_option( 'wpcm_club_settings_h2h' ) == 'yes' || get_option( 'wpcm_club_settings_matches' ) == 'yes' ) { + if ( 'yes' === get_option( 'wpcm_club_settings_h2h' ) || 'yes' === get_option( 'wpcm_club_settings_matches' ) ) { $matches = wpcm_head_to_heads( $post->ID ); ?> -

    post_title ); ?>

    +

    post_title ) ); ?>

    ID ); $outcome = wpcm_head_to_head_count( $matches ); ?>
      -
    • > - +
    • > +
    • -
    • > - +
    • > +
    • -
    • > - +
    • > +
    • -
    • > - +
    • > +
    - + -

    +

      @@ -224,24 +221,24 @@ $result = wpcm_get_match_result( $match->ID ); ?> -
    • - +
    • + - + - + - - + + - + - +
    • @@ -260,4 +257,4 @@ - \ No newline at end of file + diff --git a/templates/content-single-match.php b/templates/content-single-match.php index 345ef4b..2b79023 100644 --- a/templates/content-single-match.php +++ b/templates/content-single-match.php @@ -15,9 +15,12 @@ global $post; -( get_post_meta( $post->ID, 'wpcm_played', true ) ? $type = 'result' : $type = 'fixture' ); ?> +$match_type = 'fixture'; +if ( get_post_meta( $post->ID, 'wpcm_played', true ) ) { + $match_type = 'result'; +} ?> -
      > +
      > @@ -25,7 +28,7 @@ -
      \ No newline at end of file +
      diff --git a/templates/content-single-player.php b/templates/content-single-player.php index e9aecf0..54c725c 100644 --- a/templates/content-single-player.php +++ b/templates/content-single-player.php @@ -22,7 +22,7 @@ - \ No newline at end of file + diff --git a/templates/content-single-staff.php b/templates/content-single-staff.php index 631cd55..5a7344c 100644 --- a/templates/content-single-staff.php +++ b/templates/content-single-staff.php @@ -19,8 +19,8 @@
      - - ID, 'staff_single' ); ?> + + ID, 'staff_single' ) ); ?>
      @@ -29,7 +29,7 @@

     
    - + - +
    - + - ID, 'wpcm_dob', true ) ) ); ?> + ID, 'wpcm_dob', true ) ) ) ); ?>
    - + - ID, 'wpcm_dob', true ) ); ?> + ID, 'wpcm_dob', true ) ) ); ?>
    - + - +
    - + - +
    - + - +
    - + - +
    - + - +
    - + - ID, 'wpcm_hometown', true ) : '' ); ?> ID, 'wpcm_natl', true ) . '.png" />' : '' ); ?> + ID, 'wpcm_hometown', true ) : '' ) ); ?> ID, 'wpcm_natl', true ) ) . '.png' ) . '" />' : '' ); ?>
    - + - post_date ) ); ?> + post_date ) ) ); ?>
    @@ -227,4 +227,4 @@ - \ No newline at end of file + diff --git a/templates/content-widget-birthdays.php b/templates/content-widget-birthdays.php index 5c34038..8b1c42a 100644 --- a/templates/content-widget-birthdays.php +++ b/templates/content-widget-birthdays.php @@ -14,31 +14,31 @@
      $value ) { + foreach ( $posts as $this_post_id => $value ) { - $dob = get_post_meta( $post, 'wpcm_dob', true ); - $date = date( 'F j', strtotime( $dob ) ); + $dob = get_post_meta( $this_post_id, 'wpcm_dob', true ); + $date = gmdate( 'F j', strtotime( $dob ) ); $age = ''; if ( $show_age ) { $age = get_age( $dob ); - if ( date( 'm-d' ) !== $value ) { + if ( gmdate( 'm-d' ) !== $value ) { $age = get_age( $dob ) + 1; } } // Today - if ( date( 'm-d' ) == $value ) { + if ( gmdate( 'm-d' ) == $value ) { ?>
    • -

      +

      - - + +
      -

      -

      +

      +

    • @@ -50,12 +50,12 @@
    • - - + +
      -

      -

      +

      +

    • @@ -64,5 +64,5 @@ } } ?> - -
    \ No newline at end of file + + diff --git a/templates/content-widget-fixtures.php b/templates/content-widget-fixtures.php index 04b78a7..86745f7 100644 --- a/templates/content-widget-fixtures.php +++ b/templates/content-widget-fixtures.php @@ -18,41 +18,41 @@
    - +
    -   +  
    - +

    - - + +

    - - + +

    -
    +
    - +
    - \ No newline at end of file + diff --git a/templates/content-widget-results.php b/templates/content-widget-results.php index 52a3bfc..06ac847 100644 --- a/templates/content-widget-results.php +++ b/templates/content-widget-results.php @@ -18,38 +18,38 @@
    - +
    -   +  
    - +

    - - -
    + + +

    - - -
    + + +

    -
    +
    - \ No newline at end of file + diff --git a/templates/layout/wrapper-end.php b/templates/layout/wrapper-end.php index 4009570..2c3b3ac 100644 --- a/templates/layout/wrapper-end.php +++ b/templates/layout/wrapper-end.php @@ -36,6 +36,7 @@ echo ''; get_sidebar(); echo ''; + break; case 'twentynineteen': echo ''; echo ' - ' . $title . '' : '' ); ?> - + ' . esc_html( $title ) . '' : '' ); ?> + @@ -23,55 +23,55 @@ - - - + + + - + - + wpcm_stats; ?> - + - - + + @@ -82,8 +82,8 @@
    - place; ?> + place ); ?> thumb; + echo esc_html( $club->thumb ); if ( $default_club == $club->ID ) { - if ( $abbr == 1 ) { + if ( 1 === $abbr ) { $club_abbr = get_club_abbreviation( $club->ID ); - echo $club_abbr; + echo esc_html( $club_abbr ); } elseif ( $team_label ) { - echo $team_label; + echo esc_html( $team_label ); } else { - echo $club->post_title; + echo esc_html( $club->post_title ); } - } elseif ( $abbr == 1 ) { - echo ( $link_club == 1 ? '' : '' ); + } elseif ( 1 === $abbr ) { + echo ( 1 === $link_club ? '' : '' ); $club_abbr = get_club_abbreviation( $club->ID ); - echo $club_abbr; - echo ( $link_club == 1 ? '' : '' ); + echo esc_html( $club_abbr ); + echo ( 1 === $link_club ? '' : '' ); } else { - echo ( $link_club == 1 ? '' : '' ); - echo $club->post_title; - echo ( $link_club == 1 ? '' : '' ); + echo ( 1 === $link_club ? '' : '' ); + echo esc_html( $club->post_title ); + echo ( 1 === $link_club ? '' : '' ); } ?>
    - - + + - \ No newline at end of file + diff --git a/templates/shortcodes/map-venue.php b/templates/shortcodes/map-venue.php index 9d5461e..bed548d 100644 --- a/templates/shortcodes/map-venue.php +++ b/templates/shortcodes/map-venue.php @@ -15,35 +15,35 @@
    ' . $title . '' : '' ); + echo ( $title ? '

    ' . esc_html( $title ) . '

    ' : '' ); - if ( $service == 'osm' ) { + if ( 'osm' === $service ) { ?> - -
    + +