@@ -14,17 +14,17 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function bootstrap() { |
16 | 16 | // Add all your plugin hooks here. |
17 | - add_action( 'cmb2_init', __NAMESPACE__ . '\\Game\\fields' ); |
|
18 | - add_action( 'init', __NAMESPACE__ . '\\Game\\register_cpt' ); |
|
19 | - add_action( 'init', __NAMESPACE__ . '\\Attributes\\register_taxonomy' ); |
|
20 | - add_action( 'admin_init', __NAMESPACE__ . '\\Attributes\\create_default_attributes' ); |
|
21 | - add_action( 'add_meta_boxes', __NAMESPACE__ . '\\Attributes\\metabox' ); |
|
22 | - add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\Attributes\\enqueue_scripts' ); |
|
23 | - add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\Display\\enqueue_scripts' ); |
|
24 | - add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_all_games_shortcode' ); |
|
25 | - add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_individual_games_shortcode' ); |
|
26 | - add_filter( 'rest_prepare_gc_game', __NAMESPACE__ . '\\Api\\filter_games_json', 10, 2 ); |
|
27 | - add_shortcode( 'games-collector', __NAMESPACE__ . '\\Shortcode\\shortcode' ); |
|
17 | + add_action( 'cmb2_init', __NAMESPACE__ . '\\Game\\fields' ); |
|
18 | + add_action( 'init', __NAMESPACE__ . '\\Game\\register_cpt' ); |
|
19 | + add_action( 'init', __NAMESPACE__ . '\\Attributes\\register_taxonomy' ); |
|
20 | + add_action( 'admin_init', __NAMESPACE__ . '\\Attributes\\create_default_attributes' ); |
|
21 | + add_action( 'add_meta_boxes', __NAMESPACE__ . '\\Attributes\\metabox' ); |
|
22 | + add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\Attributes\\enqueue_scripts' ); |
|
23 | + add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\Display\\enqueue_scripts' ); |
|
24 | + add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_all_games_shortcode' ); |
|
25 | + add_action( 'register_shortcode_ui', __NAMESPACE__ . '\\Shortcode\\register_individual_games_shortcode' ); |
|
26 | + add_filter( 'rest_prepare_gc_game', __NAMESPACE__ . '\\Api\\filter_games_json', 10, 2 ); |
|
27 | + add_shortcode( 'games-collector', __NAMESPACE__ . '\\Shortcode\\shortcode' ); |
|
28 | 28 | add_shortcode( 'games-collector-list', __NAMESPACE__ . '\\Shortcode\\shortcode' ); |
29 | 29 | } |
30 | 30 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | */ |
36 | 36 | function activate() { |
37 | 37 | if ( ! get_page_by_title( esc_html__( 'Games', 'games-collector' ) ) ) { |
38 | - wp_insert_post([ |
|
38 | + wp_insert_post( [ |
|
39 | 39 | 'post_type' => 'page', |
40 | 40 | 'post_title' => esc_html__( 'Games', 'games-collector' ), |
41 | 41 | 'post_content' => '[games-collector]', |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | * @return string Displays a list of all games. |
22 | 22 | */ |
23 | 23 | function shortcode( $atts ) { |
24 | - $atts = shortcode_atts([ |
|
24 | + $atts = shortcode_atts( [ |
|
25 | 25 | 'gc_game' => '', |
26 | 26 | ], $atts ); |
27 | 27 | |
28 | 28 | // Get the ID from the atts, if one was set, so we can get a single game (or all games). |
29 | - $post_ids = []; |
|
30 | - if ( '' === $atts['gc_game'] ) { |
|
29 | + $post_ids = [ ]; |
|
30 | + if ( '' === $atts[ 'gc_game' ] ) { |
|
31 | 31 | $post_ids = $post_ids; |
32 | - } elseif ( is_array( $atts['gc_game'] ) ) { |
|
33 | - $post_ids = $atts['gc_game']; |
|
34 | - } elseif ( false !== strpos( (string) $atts['gc_game'], ',' ) ) { |
|
35 | - $post_ids = explode( ',', $atts['gc_game'] ); |
|
36 | - } elseif ( ! is_array( $atts['gc_game'] ) ) { |
|
37 | - $post_ids = [ $atts['gc_game'] ]; |
|
32 | + } elseif ( is_array( $atts[ 'gc_game' ] ) ) { |
|
33 | + $post_ids = $atts[ 'gc_game' ]; |
|
34 | + } elseif ( false !== strpos( (string) $atts[ 'gc_game' ], ',' ) ) { |
|
35 | + $post_ids = explode( ',', $atts[ 'gc_game' ] ); |
|
36 | + } elseif ( ! is_array( $atts[ 'gc_game' ] ) ) { |
|
37 | + $post_ids = [ $atts[ 'gc_game' ] ]; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $games = get_games( $post_ids ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | <div <?php post_class( Game\get_game_classes( 'game-single', $game->ID ), $game->ID ); ?> id="game-<?php echo absint( $game->ID ); ?>"> |
53 | 53 | |
54 | 54 | <?php |
55 | - echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized. |
|
55 | + echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized. |
|
56 | 56 | echo Display\get_game_info( $game->ID ); // WPCS: XSS ok, already sanitized. |
57 | 57 | ?> |
58 | 58 | |
@@ -71,31 +71,31 @@ discard block |
||
71 | 71 | * @param array $post_ids An array of game post IDs. |
72 | 72 | * @return array An array of Game WP_Post objects. |
73 | 73 | */ |
74 | -function get_games( $post_ids = [] ) { |
|
74 | +function get_games( $post_ids = [ ] ) { |
|
75 | 75 | if ( empty( $post_ids ) ) { |
76 | 76 | $post_ids = false; |
77 | 77 | } |
78 | 78 | |
79 | 79 | if ( $post_ids ) { |
80 | 80 | // If we're only displaying select games, don't show the filters. |
81 | - add_filter( 'gc_filter_buttons', '__return_null' ); |
|
81 | + add_filter( 'gc_filter_buttons', '__return_null' ); |
|
82 | 82 | add_filter( 'gc_filter_game_filters', '__return_null' ); |
83 | 83 | |
84 | - return get_posts([ |
|
84 | + return get_posts( [ |
|
85 | 85 | 'posts_per_page' => count( $post_ids ), |
86 | 86 | 'post_type' => 'gc_game', |
87 | 87 | 'post__in' => $post_ids, |
88 | 88 | 'orderby' => 'title', |
89 | 89 | 'order' => 'ASC', |
90 | - ]); |
|
90 | + ] ); |
|
91 | 91 | } |
92 | 92 | |
93 | - return get_posts([ |
|
93 | + return get_posts( [ |
|
94 | 94 | 'posts_per_page' => -1, |
95 | 95 | 'post_type' => 'gc_game', |
96 | 96 | 'orderby' => 'title', |
97 | 97 | 'order' => 'ASC', |
98 | - ]); |
|
98 | + ] ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |