@@ -20,23 +20,23 @@ discard block |
||
| 20 | 20 | * @param array $atts Array of shortcode attributes. |
| 21 | 21 | * @return string Displays a list of all games. |
| 22 | 22 | */ |
| 23 | -function shortcode( $atts ) { |
|
| 23 | +function shortcode($atts) { |
|
| 24 | 24 | $atts = shortcode_atts([ |
| 25 | 25 | 'gc_game' => '', |
| 26 | - ], $atts ); |
|
| 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 | - if ( '' === $atts['gc_game'] ) { |
|
| 30 | - $post_ids = []; |
|
| 31 | - } elseif ( is_array( $atts['gc_game'] ) ) { |
|
| 32 | - $post_ids = $atts['gc_game']; |
|
| 33 | - } elseif ( false !== strpos( (string) $atts['gc_game'], ',' ) ) { |
|
| 34 | - $post_ids = explode( ',', $atts['gc_game'] ); |
|
| 35 | - } elseif ( ! is_array( $atts['gc_game'] ) ) { |
|
| 36 | - $post_ids = [ $atts['gc_game'] ]; |
|
| 29 | + if ('' === $atts[ 'gc_game' ]) { |
|
| 30 | + $post_ids = [ ]; |
|
| 31 | + } elseif (is_array($atts[ 'gc_game' ])) { |
|
| 32 | + $post_ids = $atts[ 'gc_game' ]; |
|
| 33 | + } elseif (false !== strpos((string) $atts[ 'gc_game' ], ',')) { |
|
| 34 | + $post_ids = explode(',', $atts[ 'gc_game' ]); |
|
| 35 | + } elseif ( ! is_array($atts[ 'gc_game' ])) { |
|
| 36 | + $post_ids = [ $atts[ 'gc_game' ] ]; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $games = get_games( $post_ids ); |
|
| 39 | + $games = get_games($post_ids); |
|
| 40 | 40 | ob_start(); ?> |
| 41 | 41 | |
| 42 | 42 | <div class="games-filter-group"> |
@@ -47,12 +47,12 @@ discard block |
||
| 47 | 47 | </div> |
| 48 | 48 | |
| 49 | 49 | <div class="games-collector-list"> |
| 50 | - <?php foreach ( $games as $game ) { ?> |
|
| 51 | - <div <?php post_class( Game\get_game_classes( 'game-single', $game->ID ), $game->ID ); ?> id="game-<?php echo absint( $game->ID ); ?>"> |
|
| 50 | + <?php foreach ($games as $game) { ?> |
|
| 51 | + <div <?php post_class(Game\get_game_classes('game-single', $game->ID), $game->ID); ?> id="game-<?php echo absint($game->ID); ?>"> |
|
| 52 | 52 | |
| 53 | 53 | <?php |
| 54 | - echo Display\get_game_title( $game ); // WPCS: XSS ok, already sanitized. |
|
| 55 | - echo Display\get_game_info( $game->ID ); // WPCS: XSS ok, already sanitized. |
|
| 54 | + echo Display\get_game_title($game); // WPCS: XSS ok, already sanitized. |
|
| 55 | + echo Display\get_game_info($game->ID); // WPCS: XSS ok, already sanitized. |
|
| 56 | 56 | ?> |
| 57 | 57 | |
| 58 | 58 | </div> |
@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | * @param array $post_ids An array of game post IDs. |
| 71 | 71 | * @return array An array of Game WP_Post objects. |
| 72 | 72 | */ |
| 73 | -function get_games( $post_ids = [] ) { |
|
| 74 | - if ( empty( $post_ids ) ) { |
|
| 73 | +function get_games($post_ids = [ ]) { |
|
| 74 | + if (empty($post_ids)) { |
|
| 75 | 75 | $post_ids = false; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( $post_ids ) { |
|
| 78 | + if ($post_ids) { |
|
| 79 | 79 | // If we're only displaying select games, don't show the filters. |
| 80 | - add_filter( 'gc_filter_buttons', '__return_null' ); |
|
| 81 | - add_filter( 'gc_filter_game_filters', '__return_null' ); |
|
| 80 | + add_filter('gc_filter_buttons', '__return_null'); |
|
| 81 | + add_filter('gc_filter_game_filters', '__return_null'); |
|
| 82 | 82 | |
| 83 | 83 | return get_posts([ |
| 84 | - 'posts_per_page' => count( $post_ids ), |
|
| 84 | + 'posts_per_page' => count($post_ids), |
|
| 85 | 85 | 'post_type' => 'gc_game', |
| 86 | 86 | 'post__in' => $post_ids, |
| 87 | 87 | 'orderby' => 'title', |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | shortcode_ui_register_for_shortcode( |
| 107 | 107 | 'games-collector', |
| 108 | 108 | [ |
| 109 | - 'label' => esc_html__( 'All Games List', 'games-collector' ), |
|
| 110 | - 'listItemImage' => '<img src="' . Display\get_svg( 'dice-alt' ) . '" />', |
|
| 109 | + 'label' => esc_html__('All Games List', 'games-collector'), |
|
| 110 | + 'listItemImage' => '<img src="' . Display\get_svg('dice-alt') . '" />', |
|
| 111 | 111 | ] |
| 112 | 112 | ); |
| 113 | 113 | } |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | shortcode_ui_register_for_shortcode( |
| 122 | 122 | 'games-collector-list', |
| 123 | 123 | [ |
| 124 | - 'label' => esc_html__( 'Individual Games', 'games-collector' ), |
|
| 125 | - 'listItemImage' => '<img src="' . Display\get_svg( 'dice-alt' ) . '" />', |
|
| 124 | + 'label' => esc_html__('Individual Games', 'games-collector'), |
|
| 125 | + 'listItemImage' => '<img src="' . Display\get_svg('dice-alt') . '" />', |
|
| 126 | 126 | 'attrs' => [ |
| 127 | 127 | [ |
| 128 | - 'label' => esc_html__( 'Select Game(s)', 'games-collector' ), |
|
| 128 | + 'label' => esc_html__('Select Game(s)', 'games-collector'), |
|
| 129 | 129 | 'type' => 'post_select', |
| 130 | 130 | 'attr' => 'gc_game', |
| 131 | 131 | 'query' => [ 'post_type' => 'gc_game' ], |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | * @since 0.1 |
| 16 | 16 | */ |
| 17 | 17 | function register_taxonomy() { |
| 18 | - register_extended_taxonomy( 'gc_attribute', 'gc_game', [ |
|
| 19 | - 'dashboard_glance' => true, // Show this taxonomy in the 'At a Glance' widget. |
|
| 18 | + register_extended_taxonomy('gc_attribute', 'gc_game', [ |
|
| 19 | + 'dashboard_glance' => true, // Show this taxonomy in the 'At a Glance' widget. |
|
| 20 | 20 | 'hierarchical' => false, |
| 21 | 21 | 'show_in_rest' => true, |
| 22 | 22 | 'rest_base' => 'attributes', |
| 23 | 23 | ], [ |
| 24 | - 'singular' => __( 'Game Attribute', 'games-collector' ), |
|
| 25 | - 'plural' => __( 'Game Attributes', 'games-collector' ), |
|
| 24 | + 'singular' => __('Game Attribute', 'games-collector'), |
|
| 25 | + 'plural' => __('Game Attributes', 'games-collector'), |
|
| 26 | 26 | 'slug' => 'attribute', |
| 27 | 27 | ] |
| 28 | 28 | ); |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | * @since 0.1 |
| 35 | 35 | */ |
| 36 | 36 | function metabox() { |
| 37 | - remove_meta_box( 'tagsdiv-gc_attribute', 'gc_game', 'side' ); |
|
| 38 | - add_meta_box( 'game-attributes-chosen', __( 'Game Attributes', 'games-collector' ), __NAMESPACE__ . '\\meta_box_display', 'gc_game', 'side', 'default' ); |
|
| 37 | + remove_meta_box('tagsdiv-gc_attribute', 'gc_game', 'side'); |
|
| 38 | + add_meta_box('game-attributes-chosen', __('Game Attributes', 'games-collector'), __NAMESPACE__ . '\\meta_box_display', 'gc_game', 'side', 'default'); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | function enqueue_scripts() { |
| 47 | 47 | $screen = get_current_screen(); |
| 48 | 48 | |
| 49 | - if ( 'post' !== $screen->base || 'gc_game' !== $screen->post_type ) { |
|
| 49 | + if ('post' !== $screen->base || 'gc_game' !== $screen->post_type) { |
|
| 50 | 50 | return; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - wp_enqueue_script( 'chosen', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'vendor/chosen-js/chosen.jquery.js', [ 'jquery' ], '1.6.2', true ); |
|
| 54 | - wp_enqueue_style( 'chosen', plugin_dir_url( dirname( dirname( __FILE__ ) ) ) . 'vendor/chosen-js/chosen.css', [], '1.6.2' ); |
|
| 53 | + wp_enqueue_script('chosen', plugin_dir_url(dirname(dirname(__FILE__))) . 'vendor/chosen-js/chosen.jquery.js', [ 'jquery' ], '1.6.2', true); |
|
| 54 | + wp_enqueue_style('chosen', plugin_dir_url(dirname(dirname(__FILE__))) . 'vendor/chosen-js/chosen.css', [ ], '1.6.2'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @link https://gist.github.com/helen/1573966#file-wp-chosen-tax-metabox-php |
| 63 | 63 | */ |
| 64 | 64 | function meta_box_display() { |
| 65 | - wp_nonce_field( 'chosen-save-tax-terms', 'chosen_taxonomy_meta_box_nonce' ); |
|
| 65 | + wp_nonce_field('chosen-save-tax-terms', 'chosen_taxonomy_meta_box_nonce'); |
|
| 66 | 66 | $tax = 'gc_attribute'; |
| 67 | 67 | ?> |
| 68 | 68 | <script type="text/javascript"> |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | }); |
| 72 | 72 | </script> |
| 73 | 73 | <?php |
| 74 | - if ( current_user_can( 'edit_posts' ) ) { |
|
| 75 | - $taxonomy = get_taxonomy( $tax ); |
|
| 76 | - $label = apply_filters( 'ctm_tax_label' , $taxonomy->labels->name, $tax, 'gc_game' ); |
|
| 74 | + if (current_user_can('edit_posts')) { |
|
| 75 | + $taxonomy = get_taxonomy($tax); |
|
| 76 | + $label = apply_filters('ctm_tax_label', $taxonomy->labels->name, $tax, 'gc_game'); |
|
| 77 | 77 | |
| 78 | - $terms = get_terms( $tax, [ 'hide_empty' => 0 ] ); |
|
| 79 | - $current_terms = wp_get_post_terms( get_the_ID(), $tax, [ 'fields' => 'ids' ] ); |
|
| 78 | + $terms = get_terms($tax, [ 'hide_empty' => 0 ]); |
|
| 79 | + $current_terms = wp_get_post_terms(get_the_ID(), $tax, [ 'fields' => 'ids' ]); |
|
| 80 | 80 | $name = "tax_input[$tax]"; |
| 81 | 81 | ?> |
| 82 | - <p><select name="<?php echo esc_html( $name ); ?>[]" class="chzn-select widefat" data-placeholder="<?php esc_html_e( 'Select one or more attributes', 'games-collector' ); ?>" multiple="multiple"> |
|
| 82 | + <p><select name="<?php echo esc_html($name); ?>[]" class="chzn-select widefat" data-placeholder="<?php esc_html_e('Select one or more attributes', 'games-collector'); ?>" multiple="multiple"> |
|
| 83 | 83 | <?php |
| 84 | - foreach ( $terms as $term ) { |
|
| 84 | + foreach ($terms as $term) { |
|
| 85 | 85 | $value = $term->slug; |
| 86 | 86 | ?> |
| 87 | - <option value="<?php echo esc_html( $value ); ?>"<?php selected( in_array( $term->term_id, $current_terms ) ); ?>><?php echo esc_html( $term->name ); ?></option> |
|
| 87 | + <option value="<?php echo esc_html($value); ?>"<?php selected(in_array($term->term_id, $current_terms)); ?>><?php echo esc_html($term->name); ?></option> |
|
| 88 | 88 | <?php } ?> |
| 89 | 89 | </select> |
| 90 | 90 | </p> |
@@ -98,80 +98,80 @@ discard block |
||
| 98 | 98 | * @since 0.1 |
| 99 | 99 | */ |
| 100 | 100 | function create_default_attributes() { |
| 101 | - if ( ! term_exists( 'Solo Play', 'gc_attribute' ) ) { |
|
| 102 | - wp_insert_term( 'Solo Play', 'gc_attribute', [ 'slug' => 'solo' ] ); |
|
| 101 | + if ( ! term_exists('Solo Play', 'gc_attribute')) { |
|
| 102 | + wp_insert_term('Solo Play', 'gc_attribute', [ 'slug' => 'solo' ]); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - if ( ! term_exists( 'Cooperative', 'gc_attribute' ) ) { |
|
| 106 | - wp_insert_term( 'Cooperative', 'gc_attribute', [ 'slug' => 'coop' ] ); |
|
| 105 | + if ( ! term_exists('Cooperative', 'gc_attribute')) { |
|
| 106 | + wp_insert_term('Cooperative', 'gc_attribute', [ 'slug' => 'coop' ]); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ( ! term_exists( 'Party Game', 'gc_attribute' ) ) { |
|
| 110 | - wp_insert_term( 'Party Game', 'gc_attribute', [ 'slug' => 'party' ] ); |
|
| 109 | + if ( ! term_exists('Party Game', 'gc_attribute')) { |
|
| 110 | + wp_insert_term('Party Game', 'gc_attribute', [ 'slug' => 'party' ]); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - if ( ! term_exists( 'Easy-to-learn', 'gc_attribute' ) ) { |
|
| 114 | - wp_insert_term( 'Easy-to-learn', 'gc_attribute', [ 'slug' => 'easy-to-learn' ] ); |
|
| 113 | + if ( ! term_exists('Easy-to-learn', 'gc_attribute')) { |
|
| 114 | + wp_insert_term('Easy-to-learn', 'gc_attribute', [ 'slug' => 'easy-to-learn' ]); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - if ( ! term_exists( 'Heavy Strategy', 'gc_attribute' ) ) { |
|
| 118 | - wp_insert_term( 'Heavy Strategy', 'gc_attribute', [ 'slug' => 'strategy' ] ); |
|
| 117 | + if ( ! term_exists('Heavy Strategy', 'gc_attribute')) { |
|
| 118 | + wp_insert_term('Heavy Strategy', 'gc_attribute', [ 'slug' => 'strategy' ]); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( ! term_exists( 'Expansion', 'gc_attribute' ) ) { |
|
| 122 | - wp_insert_term( 'Expansion', 'gc_attribute', [ 'slug' => 'expansion' ] ); |
|
| 121 | + if ( ! term_exists('Expansion', 'gc_attribute')) { |
|
| 122 | + wp_insert_term('Expansion', 'gc_attribute', [ 'slug' => 'expansion' ]); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - if ( ! term_exists( 'City/Empire Building', 'gc_attribute' ) ) { |
|
| 126 | - wp_insert_term( 'City/Empire Building', 'gc_attribute', [ 'slug' => 'city-building' ] ); |
|
| 125 | + if ( ! term_exists('City/Empire Building', 'gc_attribute')) { |
|
| 126 | + wp_insert_term('City/Empire Building', 'gc_attribute', [ 'slug' => 'city-building' ]); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - if ( ! term_exists( 'Fast-paced', 'gc_attribute' ) ) { |
|
| 130 | - wp_insert_term( 'Fast-paced', 'gc_attribute', [ 'slug' => 'fast-paced' ] ); |
|
| 129 | + if ( ! term_exists('Fast-paced', 'gc_attribute')) { |
|
| 130 | + wp_insert_term('Fast-paced', 'gc_attribute', [ 'slug' => 'fast-paced' ]); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - if ( ! term_exists( 'Card Game', 'gc_attribute' ) ) { |
|
| 134 | - wp_insert_term( 'Card Game', 'gc_attribute', [ 'slug' => 'card' ] ); |
|
| 133 | + if ( ! term_exists('Card Game', 'gc_attribute')) { |
|
| 134 | + wp_insert_term('Card Game', 'gc_attribute', [ 'slug' => 'card' ]); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if ( ! term_exists( 'Deck Building', 'gc_attribute' ) ) { |
|
| 138 | - wp_insert_term( 'Deck Building', 'gc_attribute', [ 'slug' => 'deck-building' ] ); |
|
| 137 | + if ( ! term_exists('Deck Building', 'gc_attribute')) { |
|
| 138 | + wp_insert_term('Deck Building', 'gc_attribute', [ 'slug' => 'deck-building' ]); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( ! term_exists( 'Dice Game', 'gc_attribute' ) ) { |
|
| 142 | - wp_insert_term( 'Dice Game', 'gc_attribute', [ 'slug' => 'dice' ] ); |
|
| 141 | + if ( ! term_exists('Dice Game', 'gc_attribute')) { |
|
| 142 | + wp_insert_term('Dice Game', 'gc_attribute', [ 'slug' => 'dice' ]); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - if ( ! term_exists( 'Role-Playing Game', 'gc_attribute' ) ) { |
|
| 146 | - wp_insert_term( 'Role-Playing Game', 'gc_attribute', [ 'slug' => 'rpg' ] ); |
|
| 145 | + if ( ! term_exists('Role-Playing Game', 'gc_attribute')) { |
|
| 146 | + wp_insert_term('Role-Playing Game', 'gc_attribute', [ 'slug' => 'rpg' ]); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( ! term_exists( 'Sci-Fi', 'gc_attribute' ) || ! term_exists( 'Science Fiction', 'gc_attribute' ) ) { |
|
| 150 | - wp_insert_term( 'Sci-Fi', 'gc_attribute', [ 'slug' => 'sci-fi' ] ); |
|
| 149 | + if ( ! term_exists('Sci-Fi', 'gc_attribute') || ! term_exists('Science Fiction', 'gc_attribute')) { |
|
| 150 | + wp_insert_term('Sci-Fi', 'gc_attribute', [ 'slug' => 'sci-fi' ]); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - if ( ! term_exists( 'Horror', 'gc_attribute' ) ) { |
|
| 154 | - wp_insert_term( 'Horror', 'gc_attribute', [ 'slug' => 'horror' ] ); |
|
| 153 | + if ( ! term_exists('Horror', 'gc_attribute')) { |
|
| 154 | + wp_insert_term('Horror', 'gc_attribute', [ 'slug' => 'horror' ]); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( ! term_exists( 'Fantasy', 'gc_attribute' ) ) { |
|
| 158 | - wp_insert_term( 'Fantasy', 'gc_attribute', [ 'slug' => 'fantasy' ] ); |
|
| 157 | + if ( ! term_exists('Fantasy', 'gc_attribute')) { |
|
| 158 | + wp_insert_term('Fantasy', 'gc_attribute', [ 'slug' => 'fantasy' ]); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if ( ! term_exists( 'Based on a Film/TV Show', 'gc_attribute' ) ) { |
|
| 162 | - wp_insert_term( 'Based on a Film/TV Show', 'gc_attribute', [ 'slug' => 'based-on-film-tv' ] ); |
|
| 161 | + if ( ! term_exists('Based on a Film/TV Show', 'gc_attribute')) { |
|
| 162 | + wp_insert_term('Based on a Film/TV Show', 'gc_attribute', [ 'slug' => 'based-on-film-tv' ]); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( ! term_exists( 'Mystery', 'gc_attribute' ) ) { |
|
| 166 | - wp_insert_term( 'Mystery', 'gc_attribute', [ 'slug' => 'mystery' ] ); |
|
| 165 | + if ( ! term_exists('Mystery', 'gc_attribute')) { |
|
| 166 | + wp_insert_term('Mystery', 'gc_attribute', [ 'slug' => 'mystery' ]); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if ( ! term_exists( 'Historical', 'gc_attribute' ) ) { |
|
| 170 | - wp_insert_term( 'Historical', 'gc_attribute', [ 'slug' => 'historical' ] ); |
|
| 169 | + if ( ! term_exists('Historical', 'gc_attribute')) { |
|
| 170 | + wp_insert_term('Historical', 'gc_attribute', [ 'slug' => 'historical' ]); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - if ( ! term_exists( 'Legacy', 'gc_attribute' ) ) { |
|
| 174 | - wp_insert_term( 'Legacy', 'gc_attribute', [ 'slug' => 'legacy' ] ); |
|
| 173 | + if ( ! term_exists('Legacy', 'gc_attribute')) { |
|
| 174 | + wp_insert_term('Legacy', 'gc_attribute', [ 'slug' => 'legacy' ]); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
@@ -183,23 +183,23 @@ discard block |
||
| 183 | 183 | * @link https://helen.wordpress.com/2012/01/08/using-chosen-for-a-replacement-taxonomy-metabox/ |
| 184 | 184 | * @link https://gist.github.com/helen/1573966#file-wp-chosen-tax-metabox-php |
| 185 | 185 | */ |
| 186 | -function save_post( $post_id ) { |
|
| 186 | +function save_post($post_id) { |
|
| 187 | 187 | // verify nonce |
| 188 | - if ( ! isset( $_POST['chosen_taxonomy_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['chosen_taxonomy_meta_box_nonce'], 'chosen-save-tax-terms' ) ) { |
|
| 188 | + if ( ! isset($_POST[ 'chosen_taxonomy_meta_box_nonce' ]) || ! wp_verify_nonce($_POST[ 'chosen_taxonomy_meta_box_nonce' ], 'chosen-save-tax-terms')) { |
|
| 189 | 189 | return; |
| 190 | 190 | } |
| 191 | 191 | // check autosave |
| 192 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 192 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 193 | 193 | return; |
| 194 | 194 | } |
| 195 | - $post_type = get_post_type( $post_id ); |
|
| 195 | + $post_type = get_post_type($post_id); |
|
| 196 | 196 | |
| 197 | - $input = isset( $_POST['tax_input']['gc_attribute'] ) ? $_POST['tax_input']['gc_attribute'] : ''; |
|
| 197 | + $input = isset($_POST[ 'tax_input' ][ 'gc_attribute' ]) ? $_POST[ 'tax_input' ][ 'gc_attribute' ] : ''; |
|
| 198 | 198 | |
| 199 | - if ( empty( $input ) ) { |
|
| 200 | - $taxonomy = get_taxonomy( 'gc_attribute' ); |
|
| 201 | - if ( $taxonomy && current_user_can( $taxonomy->cap->assign_terms ) ) { |
|
| 202 | - wp_set_object_terms( $post_id, '', 'gc_attribute' ); |
|
| 199 | + if (empty($input)) { |
|
| 200 | + $taxonomy = get_taxonomy('gc_attribute'); |
|
| 201 | + if ($taxonomy && current_user_can($taxonomy->cap->assign_terms)) { |
|
| 202 | + wp_set_object_terms($post_id, '', 'gc_attribute'); |
|
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | } |
@@ -214,32 +214,32 @@ discard block |
||
| 214 | 214 | * @param string $after Anything after the list of attributes. |
| 215 | 215 | * @return string The sanitized list of attributes. |
| 216 | 216 | */ |
| 217 | -function get_the_attribute_list( $post_id = 0, $before = '', $seperator = ', ', $after = '' ) { |
|
| 218 | - if ( 0 === $post_id ) { |
|
| 217 | +function get_the_attribute_list($post_id = 0, $before = '', $seperator = ', ', $after = '') { |
|
| 218 | + if (0 === $post_id) { |
|
| 219 | 219 | global $post; |
| 220 | - if ( isset( $post->ID ) ) { |
|
| 220 | + if (isset($post->ID)) { |
|
| 221 | 221 | $post_id = $post->ID; |
| 222 | 222 | } else { |
| 223 | - return new WP_Error( 'cannot_get_attribute', esc_html__( 'No post ID given for game. Cannot get attributes.', 'games-collector' ) ); |
|
| 223 | + return new WP_Error('cannot_get_attribute', esc_html__('No post ID given for game. Cannot get attributes.', 'games-collector')); |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | $terms = ''; |
| 228 | - $attributes = get_the_terms( $post_id, 'gc_attribute' ); |
|
| 229 | - if ( ! is_wp_error( $attributes ) ) { |
|
| 230 | - $count = count( $attributes ); |
|
| 228 | + $attributes = get_the_terms($post_id, 'gc_attribute'); |
|
| 229 | + if ( ! is_wp_error($attributes)) { |
|
| 230 | + $count = count($attributes); |
|
| 231 | 231 | $iterator = 1; |
| 232 | - foreach ( $attributes as $term ) { |
|
| 233 | - $seperator = ( $iterator < $count ) ? $seperator : ''; |
|
| 232 | + foreach ($attributes as $term) { |
|
| 233 | + $seperator = ($iterator < $count) ? $seperator : ''; |
|
| 234 | 234 | $terms .= '<span class="gc-attribute attribute-' . $term->slug . '">' . $term->name . '</span>' . $seperator; |
| 235 | 235 | $iterator++; |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Allow the terms to be filtered. |
| 240 | - $terms = apply_filters( 'gc_filter_the_terms', $terms ); |
|
| 240 | + $terms = apply_filters('gc_filter_the_terms', $terms); |
|
| 241 | 241 | |
| 242 | - return apply_filters( 'gc_filter_the_attribute_list', gc_kses( $before ) . $terms . gc_kses( $after ) ); |
|
| 242 | + return apply_filters('gc_filter_the_attribute_list', gc_kses($before) . $terms . gc_kses($after)); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -249,24 +249,24 @@ discard block |
||
| 249 | 249 | * @param string $string The string to be sanitized. |
| 250 | 250 | * @return string The sanitized string. |
| 251 | 251 | */ |
| 252 | -function gc_kses( $string = '' ) { |
|
| 253 | - $allowed_html = array_merge( wp_kses_allowed_html( 'post' ), [ |
|
| 252 | +function gc_kses($string = '') { |
|
| 253 | + $allowed_html = array_merge(wp_kses_allowed_html('post'), [ |
|
| 254 | 254 | 'svg' => [ |
| 255 | - 'class' => [], |
|
| 256 | - 'aria-labelledby' => [], |
|
| 257 | - 'role' => [], |
|
| 258 | - 'version' => [], |
|
| 259 | - 'xmlns' => [], |
|
| 260 | - 'xmlns:xlink' => [], |
|
| 261 | - 'height' => [], |
|
| 262 | - 'width' => [], |
|
| 263 | - 'viewbox' => [], |
|
| 255 | + 'class' => [ ], |
|
| 256 | + 'aria-labelledby' => [ ], |
|
| 257 | + 'role' => [ ], |
|
| 258 | + 'version' => [ ], |
|
| 259 | + 'xmlns' => [ ], |
|
| 260 | + 'xmlns:xlink' => [ ], |
|
| 261 | + 'height' => [ ], |
|
| 262 | + 'width' => [ ], |
|
| 263 | + 'viewbox' => [ ], |
|
| 264 | 264 | ], |
| 265 | - 'title' => [], |
|
| 265 | + 'title' => [ ], |
|
| 266 | 266 | 'path' => [ |
| 267 | - 'd' => [], |
|
| 267 | + 'd' => [ ], |
|
| 268 | 268 | ], |
| 269 | - ] ); |
|
| 269 | + ]); |
|
| 270 | 270 | |
| 271 | - return wp_kses( $string, $allowed_html ); |
|
| 271 | + return wp_kses($string, $allowed_html); |
|
| 272 | 272 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * @param integer $post_id The ID for the game to get the difficulty for. |
| 20 | 20 | * @return string The human-readable difficulty level (not the meta value saved). |
| 21 | 21 | */ |
| 22 | -function gc_get_difficulty( $post_id = 0 ) { |
|
| 23 | - return Game\get_difficulty( $post_id ); |
|
| 22 | +function gc_get_difficulty($post_id = 0) { |
|
| 23 | + return Game\get_difficulty($post_id); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @since 0.2 |
| 30 | 30 | */ |
| 31 | 31 | function gc_the_difficulty() { |
| 32 | - echo esc_html( Game\get_difficulty() ); |
|
| 32 | + echo esc_html(Game\get_difficulty()); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | * @param int $post_id The Post ID to retrieve the minimum age for. |
| 40 | 40 | * @return string The age range for the game. |
| 41 | 41 | */ |
| 42 | -function gc_get_age( $post_id = 0 ) { |
|
| 43 | - return Game\get_age( $post_id ); |
|
| 42 | +function gc_get_age($post_id = 0) { |
|
| 43 | + return Game\get_age($post_id); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @since 0.2 |
| 50 | 50 | */ |
| 51 | 51 | function gc_the_age() { |
| 52 | - echo esc_html( Game\get_age() ); |
|
| 52 | + echo esc_html(Game\get_age()); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | * @param int $post_id The Post ID to retrieve the number of players for. |
| 60 | 60 | * @return string The number of players for the game. |
| 61 | 61 | */ |
| 62 | -function gc_get_number_of_players( $post_id = 0 ) { |
|
| 63 | - return Game\get_number_of_players( $post_id ); |
|
| 62 | +function gc_get_number_of_players($post_id = 0) { |
|
| 63 | + return Game\get_number_of_players($post_id); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @since 0.2 |
| 70 | 70 | */ |
| 71 | 71 | function gc_the_number_of_players() { |
| 72 | - echo esc_html( Game\get_number_of_players() ); |
|
| 72 | + echo esc_html(Game\get_number_of_players()); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | * @param integer $post_id The ID of the game to get the number of players from. |
| 80 | 80 | * @return array An array containing the minimum and maximum number of players for the game. |
| 81 | 81 | */ |
| 82 | -function gc_get_players_min_max( $post_id = 0 ) { |
|
| 83 | - return Game\get_players_min_max( $post_id ); |
|
| 82 | +function gc_get_players_min_max($post_id = 0) { |
|
| 83 | + return Game\get_players_min_max($post_id); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @return string All the games in formatted HTML. |
| 91 | 91 | */ |
| 92 | 92 | function gc_get_games() { |
| 93 | - return Shortcode\shortcode( [] ); |
|
| 93 | + return Shortcode\shortcode([ ]); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @since 0.2 |
| 100 | 100 | */ |
| 101 | 101 | function gc_the_games() { |
| 102 | - echo Shortcode\shortcode( [] ); // WPCS: XSS ok. Already sanitized. |
|
| 102 | + echo Shortcode\shortcode([ ]); // WPCS: XSS ok. Already sanitized. |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -109,29 +109,29 @@ discard block |
||
| 109 | 109 | * @param mixed $post_ids Can be a valid game post ID, an array of games, or a comma-separated list of games. |
| 110 | 110 | * @return string The requested games in formatted HTML. |
| 111 | 111 | */ |
| 112 | -function gc_get_game( $post_ids = '' ) { |
|
| 112 | +function gc_get_game($post_ids = '') { |
|
| 113 | 113 | // If nothing was passed, just use gc_get_games. |
| 114 | - if ( '' === $post_ids ) { |
|
| 114 | + if ('' === $post_ids) { |
|
| 115 | 115 | return gc_get_games(); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | // If an array was passed, implode the array and pass a comma-separated list of IDs to the shortcode. |
| 119 | - if ( is_array( $post_ids ) ) { |
|
| 120 | - return Shortcode\shortcode( [ 'gc_game' => $post_ids ] ); |
|
| 119 | + if (is_array($post_ids)) { |
|
| 120 | + return Shortcode\shortcode([ 'gc_game' => $post_ids ]); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | // If there's a comma, we'll assume comma-separated values, so deal with normally. |
| 124 | - if ( false !== strpos( (string) $post_ids, ',' ) ) { |
|
| 125 | - return Shortcode\shortcode( [ 'gc_game' => $post_ids ] ); |
|
| 124 | + if (false !== strpos((string) $post_ids, ',')) { |
|
| 125 | + return Shortcode\shortcode([ 'gc_game' => $post_ids ]); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // If an integer was passed, and it's a valid, non-zero integer, pass that to the shortcode atts. |
| 129 | - if ( 0 !== absint( $post_ids ) && is_int( absint( $post_ids ) ) ) { |
|
| 130 | - return Shortcode\shortcode( [ 'gc_game' => $post_ids ] ); |
|
| 129 | + if (0 !== absint($post_ids) && is_int(absint($post_ids))) { |
|
| 130 | + return Shortcode\shortcode([ 'gc_game' => $post_ids ]); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // For all other cases, handle normally. We'll catch the issues later. |
| 134 | - return Shortcode\shortcode( [ 'gc_game' => $post_ids ] ); |
|
| 134 | + return Shortcode\shortcode([ 'gc_game' => $post_ids ]); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | * @since 1.1.0 |
| 141 | 141 | * @param mixed $post_ids Can be a valid game post ID, an array of games, or a comma-separated list of games. |
| 142 | 142 | */ |
| 143 | -function gc_the_game( $post_ids = '' ) { |
|
| 144 | - echo gc_get_game( $post_ids ); // WPCS: XSS ok, already sanitized. |
|
| 143 | +function gc_the_game($post_ids = '') { |
|
| 144 | + echo gc_get_game($post_ids); // WPCS: XSS ok, already sanitized. |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -154,6 +154,6 @@ discard block |
||
| 154 | 154 | * @param string $after Anything after the list of attributes. |
| 155 | 155 | * @return string The sanitized list of attributes. |
| 156 | 156 | */ |
| 157 | -function gc_get_the_attribute_list( $post_id = 0, $before = '', $seperator = ', ', $after = '' ) { |
|
| 158 | - return Attributes\get_the_attribute_list( $post_id, $before, $seperator, $after ); |
|
| 157 | +function gc_get_the_attribute_list($post_id = 0, $before = '', $seperator = ', ', $after = '') { |
|
| 158 | + return Attributes\get_the_attribute_list($post_id, $before, $seperator, $after); |
|
| 159 | 159 | } |
@@ -14,18 +14,18 @@ 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' ); |
|
| 28 | - add_shortcode( 'games-collector-list', __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 | + add_shortcode('games-collector-list', __NAMESPACE__ . '\\Shortcode\\shortcode'); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | * @return int Post ID of new Games page. |
| 36 | 36 | */ |
| 37 | 37 | function activate() { |
| 38 | - if ( ! get_page_by_title( esc_html__( 'Games', 'games-collector' ) ) ) { |
|
| 38 | + if ( ! get_page_by_title(esc_html__('Games', 'games-collector'))) { |
|
| 39 | 39 | $post_id = wp_insert_post([ |
| 40 | 40 | 'post_type' => 'page', |
| 41 | - 'post_title' => esc_html__( 'Games', 'games-collector' ), |
|
| 41 | + 'post_title' => esc_html__('Games', 'games-collector'), |
|
| 42 | 42 | 'post_content' => '[games-collector]', |
| 43 | 43 | 'post_status' => 'publish', |
| 44 | - ] ); |
|
| 44 | + ]); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return $post_id; |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | * @since 0.1 |
| 16 | 16 | */ |
| 17 | 17 | function register_cpt() { |
| 18 | - register_extended_post_type( 'gc_game', [ |
|
| 18 | + register_extended_post_type('gc_game', [ |
|
| 19 | 19 | 'supports' => [ 'title' ], |
| 20 | - 'menu_icon' => Display\get_svg( 'dice' ), |
|
| 20 | + 'menu_icon' => Display\get_svg('dice'), |
|
| 21 | 21 | 'exclude_from_search' => true, |
| 22 | 22 | 'publicly_queryable' => false, |
| 23 | 23 | 'show_in_nav_menus' => false, |
@@ -26,33 +26,33 @@ discard block |
||
| 26 | 26 | // Custom columns. |
| 27 | 27 | 'admin_cols' => [ |
| 28 | 28 | 'players' => [ |
| 29 | - 'title' => __( '# of Players', 'games-collector' ), |
|
| 29 | + 'title' => __('# of Players', 'games-collector'), |
|
| 30 | 30 | 'function' => __NAMESPACE__ . '\\the_number_of_players', |
| 31 | 31 | ], |
| 32 | 32 | 'time' => [ |
| 33 | - 'title' => __( 'Playing Time', 'games-collector' ), |
|
| 33 | + 'title' => __('Playing Time', 'games-collector'), |
|
| 34 | 34 | 'meta_key' => '_gc_time', |
| 35 | 35 | ], |
| 36 | 36 | 'age' => [ |
| 37 | - 'title' => __( 'Age', 'games-collector' ), |
|
| 37 | + 'title' => __('Age', 'games-collector'), |
|
| 38 | 38 | 'function' => __NAMESPACE__ . '\\the_age', |
| 39 | 39 | ], |
| 40 | 40 | 'difficulty' => [ |
| 41 | - 'title' => __( 'Difficulty', 'games-collector' ), |
|
| 41 | + 'title' => __('Difficulty', 'games-collector'), |
|
| 42 | 42 | 'function' => __NAMESPACE__ . '\\the_difficulty', |
| 43 | 43 | ], |
| 44 | 44 | 'attributes' => [ |
| 45 | 45 | 'taxonomy' => 'gc_attribute', |
| 46 | 46 | ], |
| 47 | 47 | 'date' => [ |
| 48 | - 'title' => __( 'Date added', 'games-collector' ), |
|
| 48 | + 'title' => __('Date added', 'games-collector'), |
|
| 49 | 49 | ], |
| 50 | 50 | ], |
| 51 | 51 | // Dropdown filters. |
| 52 | - 'admin_filters' => [], |
|
| 52 | + 'admin_filters' => [ ], |
|
| 53 | 53 | ], [ |
| 54 | - 'singular' => __( 'Game', 'games-collector' ), |
|
| 55 | - 'plural' => __( 'Games', 'games-collector' ), |
|
| 54 | + 'singular' => __('Game', 'games-collector'), |
|
| 55 | + 'plural' => __('Games', 'games-collector'), |
|
| 56 | 56 | 'slug' => 'game', |
| 57 | 57 | ] |
| 58 | 58 | ); |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | function fields() { |
| 67 | 67 | $prefix = '_gc_'; |
| 68 | 68 | |
| 69 | - $cmb = new_cmb2_box( [ |
|
| 69 | + $cmb = new_cmb2_box([ |
|
| 70 | 70 | 'id' => $prefix . 'metabox', |
| 71 | - 'title' => __( 'Game Details', 'games-collector' ), |
|
| 71 | + 'title' => __('Game Details', 'games-collector'), |
|
| 72 | 72 | 'object_types' => [ 'gc_game' ], |
| 73 | 73 | ]); |
| 74 | 74 | |
| 75 | 75 | $cmb->add_field([ |
| 76 | - 'name' => __( 'Minimum Number of Players', 'games-collector' ), |
|
| 76 | + 'name' => __('Minimum Number of Players', 'games-collector'), |
|
| 77 | 77 | 'id' => $prefix . 'min_players', |
| 78 | 78 | 'type' => 'text_small', |
| 79 | 79 | 'attributes' => [ |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | ]); |
| 84 | 84 | |
| 85 | 85 | $cmb->add_field([ |
| 86 | - 'name' => __( 'Maximum Number of Players', 'games-collector' ), |
|
| 86 | + 'name' => __('Maximum Number of Players', 'games-collector'), |
|
| 87 | 87 | 'id' => $prefix . 'max_players', |
| 88 | 88 | 'type' => 'text_small', |
| 89 | 89 | 'attributes' => [ |
@@ -93,20 +93,20 @@ discard block |
||
| 93 | 93 | ]); |
| 94 | 94 | |
| 95 | 95 | $cmb->add_field([ |
| 96 | - 'name' => __( 'Playing Time', 'games-collector' ), |
|
| 96 | + 'name' => __('Playing Time', 'games-collector'), |
|
| 97 | 97 | 'id' => $prefix . 'time', |
| 98 | 98 | 'type' => 'text_small', |
| 99 | - 'desc' => __( 'Average time range, in minutes (e.g. 45-90).', 'games-collector' ), |
|
| 99 | + 'desc' => __('Average time range, in minutes (e.g. 45-90).', 'games-collector'), |
|
| 100 | 100 | 'attributes' => [ |
| 101 | 101 | 'placeholder' => '20-30', |
| 102 | 102 | ], |
| 103 | 103 | ]); |
| 104 | 104 | |
| 105 | 105 | $cmb->add_field([ |
| 106 | - 'name' => __( 'Ages', 'games-collector' ), |
|
| 106 | + 'name' => __('Ages', 'games-collector'), |
|
| 107 | 107 | 'id' => $prefix . 'age', |
| 108 | 108 | 'type' => 'text_small', |
| 109 | - 'desc' => __( 'Recommended minimum age (e.g. 10 would mean the game is best for ages 10+).', 'games-collector' ), |
|
| 109 | + 'desc' => __('Recommended minimum age (e.g. 10 would mean the game is best for ages 10+).', 'games-collector'), |
|
| 110 | 110 | 'attributes' => [ |
| 111 | 111 | 'type' => 'number', |
| 112 | 112 | 'placeholder' => '10', |
@@ -114,23 +114,23 @@ discard block |
||
| 114 | 114 | ]); |
| 115 | 115 | |
| 116 | 116 | $cmb->add_field([ |
| 117 | - 'name' => __( 'Difficulty Level', 'games-collector' ), |
|
| 117 | + 'name' => __('Difficulty Level', 'games-collector'), |
|
| 118 | 118 | 'id' => $prefix . 'difficulty', |
| 119 | 119 | 'type' => 'radio', |
| 120 | - 'desc' => __( 'How difficult or complex is this game?', 'games-collector' ), |
|
| 120 | + 'desc' => __('How difficult or complex is this game?', 'games-collector'), |
|
| 121 | 121 | 'options' => get_difficulties(), |
| 122 | 122 | 'default' => 'easy', |
| 123 | 123 | ]); |
| 124 | 124 | |
| 125 | - $cmb->add_field( array( |
|
| 126 | - 'name' => __( 'More Info Link', 'games-collector' ), |
|
| 125 | + $cmb->add_field(array( |
|
| 126 | + 'name' => __('More Info Link', 'games-collector'), |
|
| 127 | 127 | 'id' => $prefix . 'link', |
| 128 | 128 | 'type' => 'text_url', |
| 129 | - 'desc' => __( 'Link to more information for the game (e.g. Amazon, Wikipedia or Board Game Geek link).', 'games-collector' ), |
|
| 129 | + 'desc' => __('Link to more information for the game (e.g. Amazon, Wikipedia or Board Game Geek link).', 'games-collector'), |
|
| 130 | 130 | 'attributes' => [ |
| 131 | 131 | 'placeholder' => 'https://boardgamegeek.com/boardgame/random', |
| 132 | 132 | ], |
| 133 | - ) ); |
|
| 133 | + )); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -140,16 +140,16 @@ discard block |
||
| 140 | 140 | * @param int $post_id The Post ID to retrieve the number of players for. |
| 141 | 141 | * @return string The number of players for the game. |
| 142 | 142 | */ |
| 143 | -function get_number_of_players( $post_id = 0 ) { |
|
| 144 | - if ( 0 === $post_id ) { |
|
| 143 | +function get_number_of_players($post_id = 0) { |
|
| 144 | + if (0 === $post_id) { |
|
| 145 | 145 | global $post; |
| 146 | 146 | $post_id = $post->ID; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - $players_min_max = get_players_min_max( $post_id ); |
|
| 149 | + $players_min_max = get_players_min_max($post_id); |
|
| 150 | 150 | |
| 151 | - if ( isset( $players_min_max['min'] ) && isset( $players_min_max['max'] ) ) { |
|
| 152 | - return sprintf( '%1$s - %2$s', $players_min_max['min'], $players_min_max['max'] ); |
|
| 151 | + if (isset($players_min_max[ 'min' ]) && isset($players_min_max[ 'max' ])) { |
|
| 152 | + return sprintf('%1$s - %2$s', $players_min_max[ 'min' ], $players_min_max[ 'max' ]); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | return; |
@@ -162,18 +162,18 @@ discard block |
||
| 162 | 162 | * @param integer $post_id The ID of the game to get the number of players from. |
| 163 | 163 | * @return array An array containing the minimum and maximum number of players for the game. |
| 164 | 164 | */ |
| 165 | -function get_players_min_max( $post_id = 0 ) { |
|
| 166 | - if ( 0 === $post_id ) { |
|
| 165 | +function get_players_min_max($post_id = 0) { |
|
| 166 | + if (0 === $post_id) { |
|
| 167 | 167 | global $post; |
| 168 | 168 | $post_id = $post->ID; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $min = get_post_meta( $post_id, '_gc_min_players', true ); |
|
| 172 | - $max = get_post_meta( $post_id, '_gc_max_players', true ); |
|
| 171 | + $min = get_post_meta($post_id, '_gc_min_players', true); |
|
| 172 | + $max = get_post_meta($post_id, '_gc_max_players', true); |
|
| 173 | 173 | |
| 174 | 174 | return [ |
| 175 | - 'min' => ( 0 !== $min ) ? $min : '', |
|
| 176 | - 'max' => ( 0 !== $max ) ? $max : '', |
|
| 175 | + 'min' => (0 !== $min) ? $min : '', |
|
| 176 | + 'max' => (0 !== $max) ? $max : '', |
|
| 177 | 177 | ]; |
| 178 | 178 | } |
| 179 | 179 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | function the_number_of_players() { |
| 186 | 186 | global $post; |
| 187 | - echo esc_html( get_number_of_players( $post->ID ) ); |
|
| 187 | + echo esc_html(get_number_of_players($post->ID)); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -194,16 +194,16 @@ discard block |
||
| 194 | 194 | * @param int $post_id The Post ID to retrieve the minimum age for. |
| 195 | 195 | * @return string The age range for the game. |
| 196 | 196 | */ |
| 197 | -function get_age( $post_id = 0 ) { |
|
| 198 | - if ( 0 === $post_id ) { |
|
| 197 | +function get_age($post_id = 0) { |
|
| 198 | + if (0 === $post_id) { |
|
| 199 | 199 | global $post; |
| 200 | 200 | $post_id = $post->ID; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - $age = get_post_meta( $post_id, '_gc_age', true ); |
|
| 203 | + $age = get_post_meta($post_id, '_gc_age', true); |
|
| 204 | 204 | |
| 205 | - if ( $age ) { |
|
| 206 | - return sprintf( '%s+', $age ); |
|
| 205 | + if ($age) { |
|
| 206 | + return sprintf('%s+', $age); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | return; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | function the_age() { |
| 218 | 218 | global $post; |
| 219 | - echo esc_html( get_age( $post->ID ) ); |
|
| 219 | + echo esc_html(get_age($post->ID)); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | /** |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | * @param integer $post_id The ID for the game to get the difficulty for. |
| 227 | 227 | * @return string The human-readable difficulty level (not the meta value saved). |
| 228 | 228 | */ |
| 229 | -function get_difficulty( $post_id = 0 ) { |
|
| 230 | - if ( 0 === $post_id ) { |
|
| 229 | +function get_difficulty($post_id = 0) { |
|
| 230 | + if (0 === $post_id) { |
|
| 231 | 231 | global $post; |
| 232 | 232 | $post_id = $post->ID; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - $difficulty = get_post_meta( $post_id, '_gc_difficulty', true ); |
|
| 236 | - return get_difficulties( $difficulty ); |
|
| 235 | + $difficulty = get_post_meta($post_id, '_gc_difficulty', true); |
|
| 236 | + return get_difficulties($difficulty); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | function the_difficulty() { |
| 245 | 245 | global $post; |
| 246 | - echo esc_html( get_difficulty( $post->ID ) ); |
|
| 246 | + echo esc_html(get_difficulty($post->ID)); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
@@ -253,23 +253,23 @@ discard block |
||
| 253 | 253 | * @param string $difficulty A valid difficulty to match. If none is passed, will return all the difficulties. |
| 254 | 254 | * @return array The array of game difficulties. |
| 255 | 255 | */ |
| 256 | -function get_difficulties( $difficulty = '' ) { |
|
| 256 | +function get_difficulties($difficulty = '') { |
|
| 257 | 257 | $difficulties = [ |
| 258 | - 'easy' => __( 'Easy', 'games-collector' ), |
|
| 259 | - 'moderate' => __( 'Moderate', 'games-collector' ), |
|
| 260 | - 'difficult' => __( 'Difficult', 'games-collector' ), |
|
| 261 | - 'hardcore' => __( 'Hard Core (experienced gamers only!)', 'games-collector' ), |
|
| 258 | + 'easy' => __('Easy', 'games-collector'), |
|
| 259 | + 'moderate' => __('Moderate', 'games-collector'), |
|
| 260 | + 'difficult' => __('Difficult', 'games-collector'), |
|
| 261 | + 'hardcore' => __('Hard Core (experienced gamers only!)', 'games-collector'), |
|
| 262 | 262 | ]; |
| 263 | 263 | |
| 264 | - if ( '' === $difficulty ) { |
|
| 265 | - return apply_filters( 'gc_filter_all_game_difficulties', $difficulties ); |
|
| 264 | + if ('' === $difficulty) { |
|
| 265 | + return apply_filters('gc_filter_all_game_difficulties', $difficulties); |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - if ( isset( $difficulties[ $difficulty ] ) ) { |
|
| 269 | - return apply_filters( "gc_filter_$difficulty", $difficulties[ $difficulty ] ); |
|
| 268 | + if (isset($difficulties[ $difficulty ])) { |
|
| 269 | + return apply_filters("gc_filter_$difficulty", $difficulties[ $difficulty ]); |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - return __( 'Invalid difficulty given.', 'games-collector' ); |
|
| 272 | + return __('Invalid difficulty given.', 'games-collector'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,48 +280,48 @@ discard block |
||
| 280 | 280 | * @param integer $post_id The post ID of the game. |
| 281 | 281 | * @return string The classes for this game. |
| 282 | 282 | */ |
| 283 | -function get_game_classes( $classes = '', $post_id = 0 ) { |
|
| 284 | - if ( 0 === $post_id ) { |
|
| 283 | +function get_game_classes($classes = '', $post_id = 0) { |
|
| 284 | + if (0 === $post_id) { |
|
| 285 | 285 | global $post; |
| 286 | 286 | $post_id = $post->ID; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - $players = get_players_min_max( $post_id ); |
|
| 290 | - $age = get_post_meta( $post_id, '_gc_age', true ); |
|
| 291 | - $difficulty = get_post_meta( $post_id, '_gc_difficulty', true ); |
|
| 292 | - $length = get_game_length( $post_id ); |
|
| 289 | + $players = get_players_min_max($post_id); |
|
| 290 | + $age = get_post_meta($post_id, '_gc_age', true); |
|
| 291 | + $difficulty = get_post_meta($post_id, '_gc_difficulty', true); |
|
| 292 | + $length = get_game_length($post_id); |
|
| 293 | 293 | |
| 294 | - if ( isset( $players['min'] ) ) { |
|
| 295 | - $classes .= ' min-' . $players['min'] . '-players'; |
|
| 294 | + if (isset($players[ 'min' ])) { |
|
| 295 | + $classes .= ' min-' . $players[ 'min' ] . '-players'; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - if ( isset( $players['max'] ) ) { |
|
| 299 | - if ( absint( $players['max'] ) >= 8 ) { |
|
| 298 | + if (isset($players[ 'max' ])) { |
|
| 299 | + if (absint($players[ 'max' ]) >= 8) { |
|
| 300 | 300 | $classes .= ' 8-or-more-players'; |
| 301 | 301 | } else { |
| 302 | - $classes .= ' max-' . $players['max'] . '-players'; |
|
| 302 | + $classes .= ' max-' . $players[ 'max' ] . '-players'; |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | - if ( isset( $players['min'] ) && ! isset( $players['max'] ) ) { |
|
| 307 | - $classes .= ' ' . $players['min'] . '-players'; |
|
| 306 | + if (isset($players[ 'min' ]) && ! isset($players[ 'max' ])) { |
|
| 307 | + $classes .= ' ' . $players[ 'min' ] . '-players'; |
|
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - if ( $age ) { |
|
| 311 | - if ( absint( $age ) >= 13 ) { |
|
| 310 | + if ($age) { |
|
| 311 | + if (absint($age) >= 13) { |
|
| 312 | 312 | $classes .= ' mature'; |
| 313 | 313 | } else { |
| 314 | 314 | $classes .= " $age-and-up"; |
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | - if ( $difficulty ) { |
|
| 318 | + if ($difficulty) { |
|
| 319 | 319 | $classes .= " $difficulty"; |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - $classes .= ( '' !== $length ) ? ' ' . $length : ''; |
|
| 322 | + $classes .= ('' !== $length) ? ' ' . $length : ''; |
|
| 323 | 323 | |
| 324 | - return apply_filters( 'gc_filter_game_classes', $classes ); |
|
| 324 | + return apply_filters('gc_filter_game_classes', $classes); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -330,25 +330,25 @@ discard block |
||
| 330 | 330 | * @param integer $post_id The post ID of the game. |
| 331 | 331 | * @return string The length of the game (if it's short or long). |
| 332 | 332 | */ |
| 333 | -function get_game_length( $post_id = 0 ) { |
|
| 334 | - if ( 0 === $post_id ) { |
|
| 333 | +function get_game_length($post_id = 0) { |
|
| 334 | + if (0 === $post_id) { |
|
| 335 | 335 | global $post; |
| 336 | 336 | $post_id = $post->ID; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | $classes = ''; |
| 340 | 340 | |
| 341 | - $game_time = str_replace( ' ', '', get_post_meta( $post_id, '_gc_time', true ) ); |
|
| 342 | - $time = explode( '-', $game_time ); |
|
| 343 | - $time = isset( $time[1] ) ? $time[1] : $time[0]; |
|
| 341 | + $game_time = str_replace(' ', '', get_post_meta($post_id, '_gc_time', true)); |
|
| 342 | + $time = explode('-', $game_time); |
|
| 343 | + $time = isset($time[ 1 ]) ? $time[ 1 ] : $time[ 0 ]; |
|
| 344 | 344 | |
| 345 | - if ( $game_time ) { |
|
| 346 | - switch ( $time ) { |
|
| 347 | - case ( absint( $time ) <= 20 ) : |
|
| 345 | + if ($game_time) { |
|
| 346 | + switch ($time) { |
|
| 347 | + case (absint($time) <= 20) : |
|
| 348 | 348 | $classes .= 'short'; |
| 349 | 349 | break; |
| 350 | 350 | |
| 351 | - case ( absint( $time ) > 60 ) : |
|
| 351 | + case (absint($time) > 60) : |
|
| 352 | 352 | $classes .= 'long'; |
| 353 | 353 | break; |
| 354 | 354 | |
@@ -357,5 +357,5 @@ discard block |
||
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - return apply_filters( 'gc_filter_game_length', $classes ); |
|
| 360 | + return apply_filters('gc_filter_game_length', $classes); |
|
| 361 | 361 | } |
@@ -19,36 +19,36 @@ |
||
| 19 | 19 | * @return object The filtered data object. |
| 20 | 20 | * @link http://wordpress.stackexchange.com/a/227517 |
| 21 | 21 | */ |
| 22 | -function filter_games_json( $data, $post ) { |
|
| 23 | - $min_players = get_post_meta( $post->ID, '_gc_min_players' ); |
|
| 24 | - $max_players = get_post_meta( $post->ID, '_gc_max_players' ); |
|
| 25 | - $time = get_post_meta( $post->ID, '_gc_time' ); |
|
| 26 | - $age = get_post_meta( $post->ID, '_gc_age' ); |
|
| 27 | - $difficulty = get_post_meta( $post->ID, '_gc_difficulty' ); |
|
| 28 | - $link = get_post_meta( $post->ID, '_gc_link' ); |
|
| 29 | - |
|
| 30 | - if ( $min_players ) { |
|
| 31 | - $data->data['min_players'] = $min_players; |
|
| 22 | +function filter_games_json($data, $post) { |
|
| 23 | + $min_players = get_post_meta($post->ID, '_gc_min_players'); |
|
| 24 | + $max_players = get_post_meta($post->ID, '_gc_max_players'); |
|
| 25 | + $time = get_post_meta($post->ID, '_gc_time'); |
|
| 26 | + $age = get_post_meta($post->ID, '_gc_age'); |
|
| 27 | + $difficulty = get_post_meta($post->ID, '_gc_difficulty'); |
|
| 28 | + $link = get_post_meta($post->ID, '_gc_link'); |
|
| 29 | + |
|
| 30 | + if ($min_players) { |
|
| 31 | + $data->data[ 'min_players' ] = $min_players; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if ( $max_players ) { |
|
| 35 | - $data->data['max_players'] = $max_players; |
|
| 34 | + if ($max_players) { |
|
| 35 | + $data->data[ 'max_players' ] = $max_players; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - if ( $time ) { |
|
| 39 | - $data->data['time'] = $time; |
|
| 38 | + if ($time) { |
|
| 39 | + $data->data[ 'time' ] = $time; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if ( $age ) { |
|
| 43 | - $data->data['age'] = $age; |
|
| 42 | + if ($age) { |
|
| 43 | + $data->data[ 'age' ] = $age; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if ( $difficulty ) { |
|
| 47 | - $data->data['difficulty'] = $difficulty; |
|
| 46 | + if ($difficulty) { |
|
| 47 | + $data->data[ 'difficulty' ] = $difficulty; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ( $link ) { |
|
| 51 | - $data->data['url'] = $link; |
|
| 50 | + if ($link) { |
|
| 51 | + $data->data[ 'url' ] = $link; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | return $data; |
@@ -19,22 +19,22 @@ discard block |
||
| 19 | 19 | * @param object $game The game WP_Post object. |
| 20 | 20 | * @return string The HTML markup for the game title. |
| 21 | 21 | */ |
| 22 | -function get_game_title( $game ) { |
|
| 22 | +function get_game_title($game) { |
|
| 23 | 23 | $before = ''; |
| 24 | 24 | $after = ''; |
| 25 | 25 | |
| 26 | 26 | // Output a link if one was saved. |
| 27 | - if ( $link = get_post_meta( $game->ID, '_gc_link', true ) ) { |
|
| 28 | - $before = '<a href="' . esc_url( $link ) . '">'; |
|
| 27 | + if ($link = get_post_meta($game->ID, '_gc_link', true)) { |
|
| 28 | + $before = '<a href="' . esc_url($link) . '">'; |
|
| 29 | 29 | $after = '</a>'; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $title = '<span class="game-title" id="game-' . absint( $game->ID ) . '-title">' . wp_kses_post( $game->post_title ) . '</span>'; |
|
| 32 | + $title = '<span class="game-title" id="game-' . absint($game->ID) . '-title">' . wp_kses_post($game->post_title) . '</span>'; |
|
| 33 | 33 | |
| 34 | 34 | // 1: Game ID, 2: Game title, 3: Link <a> tag, 4: Closing </a>. |
| 35 | - $output = sprintf( '%3$s<span class="game-title" id="game-%1$d-title">%2$s</span>%4$s', |
|
| 36 | - absint( $game->ID ), |
|
| 37 | - wp_kses_post( $game->post_title ), |
|
| 35 | + $output = sprintf('%3$s<span class="game-title" id="game-%1$d-title">%2$s</span>%4$s', |
|
| 36 | + absint($game->ID), |
|
| 37 | + wp_kses_post($game->post_title), |
|
| 38 | 38 | $before, |
| 39 | 39 | $after |
| 40 | 40 | ); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param string $output The HTML markup for the game title. |
| 47 | 47 | * @param int $game_id The game's post ID. |
| 48 | 48 | */ |
| 49 | - return apply_filters( 'gc_filter_game_title', $output, $game->ID ); |
|
| 49 | + return apply_filters('gc_filter_game_title', $output, $game->ID); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | * @param int $game_id The game's post ID. |
| 57 | 57 | * @return string The HTML markup for the game information. |
| 58 | 58 | */ |
| 59 | -function get_game_info( $game_id ) { |
|
| 59 | +function get_game_info($game_id) { |
|
| 60 | 60 | ob_start(); ?> |
| 61 | 61 | |
| 62 | - <div class="game-info" id="game-<?php echo absint( $game_id ); ?>-info"> |
|
| 62 | + <div class="game-info" id="game-<?php echo absint($game_id); ?>-info"> |
|
| 63 | 63 | <?php |
| 64 | - echo get_players( $game_id ); // WPCS: XSS ok, already sanitized. |
|
| 65 | - echo get_playing_time( $game_id ); // WPCS: XSS ok, already sanitized. |
|
| 66 | - echo get_age( $game_id ); // WPCS: XSS ok, already sanitized. |
|
| 67 | - echo get_difficulty( $game_id ); // WPCS: XSS ok, already sanitized. |
|
| 68 | - echo get_attributes( $game_id ); // WPCS: XSS ok, already sanitized. |
|
| 64 | + echo get_players($game_id); // WPCS: XSS ok, already sanitized. |
|
| 65 | + echo get_playing_time($game_id); // WPCS: XSS ok, already sanitized. |
|
| 66 | + echo get_age($game_id); // WPCS: XSS ok, already sanitized. |
|
| 67 | + echo get_difficulty($game_id); // WPCS: XSS ok, already sanitized. |
|
| 68 | + echo get_attributes($game_id); // WPCS: XSS ok, already sanitized. |
|
| 69 | 69 | ?> |
| 70 | 70 | </div> |
| 71 | 71 | |
@@ -79,18 +79,18 @@ discard block |
||
| 79 | 79 | * @return string The markup for the buttons. |
| 80 | 80 | */ |
| 81 | 81 | function get_buttons() { |
| 82 | - $terms = get_terms( 'gc_attribute' ); |
|
| 82 | + $terms = get_terms('gc_attribute'); |
|
| 83 | 83 | |
| 84 | - $show_all = '<button data-filter="*">' . esc_html__( 'Show All', 'games-collector' ) . '</button>'; |
|
| 85 | - $short_games = '<button data-filter=".short">' . esc_html__( 'Short Games', 'games-collector' ) . '</button>'; |
|
| 86 | - $long_games = '<button data-filter = ".long">' . esc_html__( 'Long Games', 'games-collector' ) . '</button>'; |
|
| 87 | - $kids_games = '<button data-filter = ".4-and-up,.5-and-up,.6-and-up,.7-and-up,.8-and-up,.9-and-up">' . esc_html__( 'Good for Kids', 'games-collector' ) . '</button>'; |
|
| 88 | - $adult_games = '<button data-filter=".mature">' . esc_html__( 'Adult Games', 'games-collector' ) . '</button>'; |
|
| 84 | + $show_all = '<button data-filter="*">' . esc_html__('Show All', 'games-collector') . '</button>'; |
|
| 85 | + $short_games = '<button data-filter=".short">' . esc_html__('Short Games', 'games-collector') . '</button>'; |
|
| 86 | + $long_games = '<button data-filter = ".long">' . esc_html__('Long Games', 'games-collector') . '</button>'; |
|
| 87 | + $kids_games = '<button data-filter = ".4-and-up,.5-and-up,.6-and-up,.7-and-up,.8-and-up,.9-and-up">' . esc_html__('Good for Kids', 'games-collector') . '</button>'; |
|
| 88 | + $adult_games = '<button data-filter=".mature">' . esc_html__('Adult Games', 'games-collector') . '</button>'; |
|
| 89 | 89 | |
| 90 | 90 | // Loop through terms to generate all those buttons. These won't be filterable. |
| 91 | 91 | $terms_buttons = ''; |
| 92 | - foreach ( $terms as $term ) { |
|
| 93 | - $terms_buttons .= '<button data-filter=".gc_attribute-' . esc_attr( $term->slug ) . '">' . esc_attr( $term->name ) . '</button>'; |
|
| 92 | + foreach ($terms as $term) { |
|
| 93 | + $terms_buttons .= '<button data-filter=".gc_attribute-' . esc_attr($term->slug) . '">' . esc_attr($term->name) . '</button>'; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @since 1.1.0 |
| 100 | 100 | * @var string HTML markup for Show All button. |
| 101 | 101 | */ |
| 102 | - $show_all = apply_filters( 'gc_filter_button_show_all', $show_all ); |
|
| 102 | + $show_all = apply_filters('gc_filter_button_show_all', $show_all); |
|
| 103 | 103 | |
| 104 | 104 | /** |
| 105 | 105 | * Allow the attribute term buttons to be filtered. This will filter _all_ the term buttons. Can be hooked to __return_null to disable term buttons. |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @since 1.1.0 |
| 108 | 108 | * @var string HTML markup for all attribute term buttons. |
| 109 | 109 | */ |
| 110 | - $terms_buttons = apply_filters( 'gc_filter_term_buttons', $terms_buttons ); |
|
| 110 | + $terms_buttons = apply_filters('gc_filter_term_buttons', $terms_buttons); |
|
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * Allow Short Games button to be filtered. Can be hooked to __return_null to disable. |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @since 1.1.0 |
| 116 | 116 | * @var string HTML markup for Short Games button. |
| 117 | 117 | */ |
| 118 | - $short_games = apply_filters( 'gc_filter_button_short_games', $short_games ); |
|
| 118 | + $short_games = apply_filters('gc_filter_button_short_games', $short_games); |
|
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Allow Long Games button to be filtered. Can be hooked to __return_null to disable. |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * @since 1.1.0 |
| 124 | 124 | * @var string HTML markup for Long Games button. |
| 125 | 125 | */ |
| 126 | - $long_games = apply_filters( 'gc_filter_button_long_games', $long_games ); |
|
| 126 | + $long_games = apply_filters('gc_filter_button_long_games', $long_games); |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * Allow Kids Games button to be filtered. Can be hooked to __return_null to disable. |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @since 1.1.0 |
| 132 | 132 | * @var string HTML markup for Kids Games button. |
| 133 | 133 | */ |
| 134 | - $kids_games = apply_filters( 'gc_filter_button_kids_games', $kids_games ); |
|
| 134 | + $kids_games = apply_filters('gc_filter_button_kids_games', $kids_games); |
|
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Allow Adults Games button to be filtered. Can be hooked to __return_null to disable. |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @since 1.1.0 |
| 140 | 140 | * @var string HTML markup for Adults Games button. |
| 141 | 141 | */ |
| 142 | - $adult_games = apply_filters( 'gc_filter_button_adult_games', $adult_games ); |
|
| 142 | + $adult_games = apply_filters('gc_filter_button_adult_games', $adult_games); |
|
| 143 | 143 | |
| 144 | 144 | $output = $show_all . $terms_buttons . $short_games . $long_games . $kids_games . $adult_games; |
| 145 | 145 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @since 1.0.0 |
| 150 | 150 | * @var string HTML markup for buttons. |
| 151 | 151 | */ |
| 152 | - return apply_filters( 'gc_filter_buttons', $output ); |
|
| 152 | + return apply_filters('gc_filter_buttons', $output); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -159,21 +159,21 @@ discard block |
||
| 159 | 159 | * @return string Select markup for filters. |
| 160 | 160 | */ |
| 161 | 161 | function get_filters() { |
| 162 | - $player_filter = '<div class="player-filter"><label for="players-filter-select">' . esc_html__( 'How many players?', 'games-collector' ) . ':</label> |
|
| 162 | + $player_filter = '<div class="player-filter"><label for="players-filter-select">' . esc_html__('How many players?', 'games-collector') . ':</label> |
|
| 163 | 163 | <select class="players-filter-select"> |
| 164 | - <option selected>- ' . esc_html__( 'Select one', 'games-collector' ) . ' -</option> |
|
| 165 | - <option value=".2-players,.min-2-players,.max-2-players,.max-3-players,.max-4-players,.max-5-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__( '2+ players', 'games-collector' ) . '</option> |
|
| 166 | - <option value=".4-players,.min-4-players,.max-4-players,.max-5-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__( '4+ players', 'games-collector' ) . '</option> |
|
| 167 | - <option value=".5-players,.min-5-players,.max-5-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__( '5+ players', 'games-collector' ) . '</option> |
|
| 168 | - <option value=".6-players,.min-6-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__( '6+ players', 'games-collector' ) . '</option> |
|
| 169 | - <option value=".8-players,.min-8-players,.8-or-more-players">' . esc_html__( '8+ players', 'games-collector' ) . '</option> |
|
| 164 | + <option selected>- ' . esc_html__('Select one', 'games-collector') . ' -</option> |
|
| 165 | + <option value=".2-players,.min-2-players,.max-2-players,.max-3-players,.max-4-players,.max-5-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__('2+ players', 'games-collector') . '</option> |
|
| 166 | + <option value=".4-players,.min-4-players,.max-4-players,.max-5-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__('4+ players', 'games-collector') . '</option> |
|
| 167 | + <option value=".5-players,.min-5-players,.max-5-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__('5+ players', 'games-collector') . '</option> |
|
| 168 | + <option value=".6-players,.min-6-players,.max-6-players,.max-7-players,.8-or-more-players">' . esc_html__('6+ players', 'games-collector') . '</option> |
|
| 169 | + <option value=".8-players,.min-8-players,.8-or-more-players">' . esc_html__('8+ players', 'games-collector') . '</option> |
|
| 170 | 170 | </select> |
| 171 | 171 | </div>'; |
| 172 | 172 | |
| 173 | 173 | $game_difficulties = ''; |
| 174 | 174 | |
| 175 | - foreach ( Game\get_difficulties() as $key => $value ) { |
|
| 176 | - $game_difficulties = '<option value=".' . esc_html( $key ) . '">' . esc_html( $value ) . '</option>'; |
|
| 175 | + foreach (Game\get_difficulties() as $key => $value) { |
|
| 176 | + $game_difficulties = '<option value=".' . esc_html($key) . '">' . esc_html($value) . '</option>'; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | * @since 1.1.0 |
| 183 | 183 | * @var string HTML markup of <option> tags for difficulties select input. |
| 184 | 184 | */ |
| 185 | - $game_difficulties = apply_filters( 'gc_filter_options_difficulties', $game_difficulties ); |
|
| 185 | + $game_difficulties = apply_filters('gc_filter_options_difficulties', $game_difficulties); |
|
| 186 | 186 | |
| 187 | - $difficulty_filter = '<div class="difficulty-filter"><label for="difficulty-filter-select">' . esc_html__( 'Difficulty', 'games-collector' ) . ':</label> |
|
| 187 | + $difficulty_filter = '<div class="difficulty-filter"><label for="difficulty-filter-select">' . esc_html__('Difficulty', 'games-collector') . ':</label> |
|
| 188 | 188 | <select class="difficulty-filter-select"> |
| 189 | - <option selected>- ' . esc_html__( 'Select one', 'games-collector' ) . ' -</option>' . $game_difficulties . ' |
|
| 189 | + <option selected>- ' . esc_html__('Select one', 'games-collector') . ' -</option>' . $game_difficulties . ' |
|
| 190 | 190 | </select> |
| 191 | 191 | </div>'; |
| 192 | 192 | |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @since 1.1.0 |
| 197 | 197 | * @var string HTML markup for player filter. |
| 198 | 198 | */ |
| 199 | - $player_filter = apply_filters( 'gc_filter_player_filter', $player_filter ); |
|
| 199 | + $player_filter = apply_filters('gc_filter_player_filter', $player_filter); |
|
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | 202 | * Allow the difficulty filter to be filtered. Can be disabled entirely by hooking to __return_null. |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | * @since 1.1.0 |
| 205 | 205 | * @var string HTML markup for difficulty filter. |
| 206 | 206 | */ |
| 207 | - $difficulty_filter = apply_filters( 'gc_filter_difficulty_filter', $difficulty_filter ); |
|
| 207 | + $difficulty_filter = apply_filters('gc_filter_difficulty_filter', $difficulty_filter); |
|
| 208 | 208 | |
| 209 | 209 | $output = $player_filter . $difficulty_filter; |
| 210 | 210 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @since 1.0.0 |
| 215 | 215 | * @var string HTML markup for the filters. |
| 216 | 216 | */ |
| 217 | - return apply_filters( 'gc_filter_game_filters', $output ); |
|
| 217 | + return apply_filters('gc_filter_game_filters', $output); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -225,11 +225,11 @@ discard block |
||
| 225 | 225 | * @return string The HTML markup for the game attributes. |
| 226 | 226 | * @uses Attributes\get_the_attribute_list |
| 227 | 227 | */ |
| 228 | -function get_attributes( $game_id ) { |
|
| 228 | +function get_attributes($game_id) { |
|
| 229 | 229 | $attribute_list = Attributes\get_the_attribute_list( |
| 230 | 230 | $game_id, |
| 231 | - '<div class="game-attributes"><span class="gc-icon icon-game-attributes">' . get_svg( 'tags', false ) . '</span><span class="game-attributes" id="game-' . absint( $game_id ) . '-attributes">', // Before. |
|
| 232 | - ', ', // Seperator. |
|
| 231 | + '<div class="game-attributes"><span class="gc-icon icon-game-attributes">' . get_svg('tags', false) . '</span><span class="game-attributes" id="game-' . absint($game_id) . '-attributes">', // Before. |
|
| 232 | + ', ', // Seperator. |
|
| 233 | 233 | '</span></div>' // After. |
| 234 | 234 | ); |
| 235 | 235 | |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @var string The HTML markup for the attribute list. |
| 241 | 241 | * @uses Attributes\get_the_attribute_list |
| 242 | 242 | */ |
| 243 | - return apply_filters( 'gc_filter_attribute_list', $attribute_list ); |
|
| 243 | + return apply_filters('gc_filter_attribute_list', $attribute_list); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | /** |
@@ -251,18 +251,18 @@ discard block |
||
| 251 | 251 | * @return mixed The HTML markup for number of players or false if not set. |
| 252 | 252 | * @uses Game\get_players_min_max |
| 253 | 253 | */ |
| 254 | -function get_players( $game_id ) { |
|
| 255 | - $players_min_max = Game\get_players_min_max( $game_id ); |
|
| 254 | +function get_players($game_id) { |
|
| 255 | + $players_min_max = Game\get_players_min_max($game_id); |
|
| 256 | 256 | |
| 257 | - if ( isset( $players_min_max['min'] ) ) { |
|
| 257 | + if (isset($players_min_max[ 'min' ])) { |
|
| 258 | 258 | ob_start(); ?> |
| 259 | 259 | |
| 260 | - <span class="gc-icon icon-game-players"><?php the_svg( 'players', false ); ?></span><span class="game-num-players" id="game-<?php echo absint( $game_id ); ?>-num-players"><?php echo esc_attr( sprintf( |
|
| 260 | + <span class="gc-icon icon-game-players"><?php the_svg('players', false); ?></span><span class="game-num-players" id="game-<?php echo absint($game_id); ?>-num-players"><?php echo esc_attr(sprintf( |
|
| 261 | 261 | // Translators: 1: Minimum number of players, 2: Maximum number of players. |
| 262 | - __( '%1$d %2$s players', 'games-collector' ), |
|
| 263 | - absint( $players_min_max['min'] ), |
|
| 264 | - isset( $players_min_max['max'] ) ? sprintf( '- %d', absint( $players_min_max['max'] ) ) : '+' |
|
| 265 | - ) ); ?></span><?php |
|
| 262 | + __('%1$d %2$s players', 'games-collector'), |
|
| 263 | + absint($players_min_max[ 'min' ]), |
|
| 264 | + isset($players_min_max[ 'max' ]) ? sprintf('- %d', absint($players_min_max[ 'max' ])) : '+' |
|
| 265 | + )); ?></span><?php |
|
| 266 | 266 | |
| 267 | 267 | $output = ob_get_clean(); |
| 268 | 268 | |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @var string The HTML markup for # of players. |
| 274 | 274 | * @uses Game\get_players_min_max |
| 275 | 275 | */ |
| 276 | - return apply_filters( 'gc_filter_players', $output ); |
|
| 276 | + return apply_filters('gc_filter_players', $output); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | return false; |
@@ -287,10 +287,10 @@ discard block |
||
| 287 | 287 | * @return mixed The HTML markup for difficulty or false if not set. |
| 288 | 288 | * @uses Game\get_difficulties |
| 289 | 289 | */ |
| 290 | -function get_difficulty( $game_id ) { |
|
| 291 | - if ( $difficulty = get_post_meta( $game_id, '_gc_difficulty', true ) ) { |
|
| 290 | +function get_difficulty($game_id) { |
|
| 291 | + if ($difficulty = get_post_meta($game_id, '_gc_difficulty', true)) { |
|
| 292 | 292 | ob_start(); ?> |
| 293 | - <span class="gc-icon icon-game-difficulty"><?php the_svg( 'difficulty', false ); ?></span><span class="game-difficulty" id="game-<?php echo absint( $game_id ); ?>-difficulty"><?php echo esc_html( Game\get_difficulties( $difficulty ) ); ?></span> |
|
| 293 | + <span class="gc-icon icon-game-difficulty"><?php the_svg('difficulty', false); ?></span><span class="game-difficulty" id="game-<?php echo absint($game_id); ?>-difficulty"><?php echo esc_html(Game\get_difficulties($difficulty)); ?></span> |
|
| 294 | 294 | |
| 295 | 295 | <?php $output = ob_get_clean(); |
| 296 | 296 | |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @var string The HTML markup for difficulty. |
| 302 | 302 | * @uses Game\get_difficulties |
| 303 | 303 | */ |
| 304 | - return apply_filters( 'gc_filter_difficulty', $output ); |
|
| 304 | + return apply_filters('gc_filter_difficulty', $output); |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | return false; |
@@ -314,10 +314,10 @@ discard block |
||
| 314 | 314 | * @param int $game_id The game's post ID. |
| 315 | 315 | * @return mixed The HTML markup for playing time or false if not set. |
| 316 | 316 | */ |
| 317 | -function get_playing_time( $game_id ) { |
|
| 318 | - if ( $playing_time = get_post_meta( $game_id, '_gc_time', true ) ) { |
|
| 317 | +function get_playing_time($game_id) { |
|
| 318 | + if ($playing_time = get_post_meta($game_id, '_gc_time', true)) { |
|
| 319 | 319 | ob_start(); ?> |
| 320 | - <span class="gc-icon icon-game-time"><?php the_svg( 'time', false ); ?></span><span class="game-playing-time" id="game-<?php echo absint( $game_id ); ?>-playing-time"><?php echo esc_html( sprintf( __( '%s minutes', 'games-collector' ), $playing_time ) ); ?></span> |
|
| 320 | + <span class="gc-icon icon-game-time"><?php the_svg('time', false); ?></span><span class="game-playing-time" id="game-<?php echo absint($game_id); ?>-playing-time"><?php echo esc_html(sprintf(__('%s minutes', 'games-collector'), $playing_time)); ?></span> |
|
| 321 | 321 | |
| 322 | 322 | <?php $output = ob_get_clean(); |
| 323 | 323 | |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * @since 1.0.0 |
| 328 | 328 | * @var string The HTML markup for playing time. |
| 329 | 329 | */ |
| 330 | - return apply_filters( 'gc_filter_playing_time', $output ); |
|
| 330 | + return apply_filters('gc_filter_playing_time', $output); |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | return false; |
@@ -340,10 +340,10 @@ discard block |
||
| 340 | 340 | * @param int $game_id The game's post ID. |
| 341 | 341 | * @return mixed The HTML markup for age or false if not set. |
| 342 | 342 | */ |
| 343 | -function get_age( $game_id ) { |
|
| 344 | - if ( $age = get_post_meta( $game_id, '_gc_age', true ) ) { |
|
| 343 | +function get_age($game_id) { |
|
| 344 | + if ($age = get_post_meta($game_id, '_gc_age', true)) { |
|
| 345 | 345 | ob_start(); ?> |
| 346 | - <span class="gc-icon icon-game-age"><?php the_svg( 'age', false ); ?></span><span class="game-age" id="game-<?php echo absint( $game_id ); ?>-age"><?php echo esc_html( sprintf( '%d+', $age ) ); ?></span> |
|
| 346 | + <span class="gc-icon icon-game-age"><?php the_svg('age', false); ?></span><span class="game-age" id="game-<?php echo absint($game_id); ?>-age"><?php echo esc_html(sprintf('%d+', $age)); ?></span> |
|
| 347 | 347 | |
| 348 | 348 | <?php $output = ob_get_clean(); |
| 349 | 349 | |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | * @since 1.0.0 |
| 354 | 354 | * @var string The HTML markup for age. |
| 355 | 355 | */ |
| 356 | - return apply_filters( 'gc_filter_age', $output ); |
|
| 356 | + return apply_filters('gc_filter_age', $output); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | return false; |
@@ -366,13 +366,13 @@ discard block |
||
| 366 | 366 | */ |
| 367 | 367 | function enqueue_scripts() { |
| 368 | 368 | // Don't load in the admin. |
| 369 | - if ( is_admin() ) { |
|
| 369 | + if (is_admin()) { |
|
| 370 | 370 | return; |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - wp_enqueue_style( 'games-collector', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/assets/css/games-collector.css', [], '1.1.0-r2' ); |
|
| 374 | - wp_enqueue_script( 'isotope', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/assets/js/isotope.pkgd.min.js', [ 'jquery' ], '3.0.1', true ); |
|
| 375 | - wp_enqueue_script( 'games-collector', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/assets/js/games-collector.js', [ 'jquery', 'isotope' ], '0.2' ); |
|
| 373 | + wp_enqueue_style('games-collector', dirname(dirname(plugin_dir_url(__FILE__))) . '/assets/css/games-collector.css', [ ], '1.1.0-r2'); |
|
| 374 | + wp_enqueue_script('isotope', dirname(dirname(plugin_dir_url(__FILE__))) . '/assets/js/isotope.pkgd.min.js', [ 'jquery' ], '3.0.1', true); |
|
| 375 | + wp_enqueue_script('games-collector', dirname(dirname(plugin_dir_url(__FILE__))) . '/assets/js/games-collector.js', [ 'jquery', 'isotope' ], '0.2'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | /** |
@@ -383,13 +383,13 @@ discard block |
||
| 383 | 383 | * @param bool $encoded Whether to return the svg as a base64 encoded image (for background images) or the raw SVG XML. |
| 384 | 384 | * @return string The svg. |
| 385 | 385 | */ |
| 386 | -function get_svg( $name = '', $encoded = true ) { |
|
| 386 | +function get_svg($name = '', $encoded = true) { |
|
| 387 | 387 | // Bail if nothing was passed. |
| 388 | - if ( '' === $name ) { |
|
| 388 | + if ('' === $name) { |
|
| 389 | 389 | return; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | - if ( $encoded ) { |
|
| 392 | + if ($encoded) { |
|
| 393 | 393 | $icons = [ |
| 394 | 394 | 'dice' => 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0ZWQgYnkgSWNvTW9vbi5pbyAtLT4KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkIj4KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgdmlld0JveD0iMCAwIDMyIDMyIj4KPHBhdGggZmlsbD0iI2EwYTVhYSIgZD0iTTI3IDZoLTE2Yy0yLjc1IDAtNSAyLjI1LTUgNXYxNmMwIDIuNzUgMi4yNSA1IDUgNWgxNmMyLjc1IDAgNS0yLjI1IDUtNXYtMTZjMC0yLjc1LTIuMjUtNS01LTV6TTEzIDI4Yy0xLjY1NyAwLTMtMS4zNDMtMy0zczEuMzQzLTMgMy0zIDMgMS4zNDMgMyAzLTEuMzQzIDMtMyAzek0xMyAxNmMtMS42NTcgMC0zLTEuMzQzLTMtM3MxLjM0My0zIDMtMyAzIDEuMzQzIDMgMy0xLjM0MyAzLTMgM3pNMTkgMjJjLTEuNjU3IDAtMy0xLjM0My0zLTNzMS4zNDMtMyAzLTMgMyAxLjM0MyAzIDMtMS4zNDMgMy0zIDN6TTI1IDI4Yy0xLjY1NyAwLTMtMS4zNDMtMy0zczEuMzQzLTMgMy0zIDMgMS4zNDMgMyAzLTEuMzQzIDMtMyAzek0yNSAxNmMtMS42NTcgMC0zLTEuMzQzLTMtM3MxLjM0My0zIDMtMyAzIDEuMzQzIDMgMy0xLjM0MyAzLTMgM3pNMjUuODk5IDRjLTAuNDY3LTIuMjc1LTIuNDkxLTQtNC44OTktNGgtMTZjLTIuNzUgMC01IDIuMjUtNSA1djE2YzAgMi40MDggMS43MjUgNC40MzIgNCA0Ljg5OXYtMTkuODk5YzAtMS4xIDAuOS0yIDItMmgxOS44OTl6Ij48L3BhdGg+Cjwvc3ZnPgo=', |
| 395 | 395 | 'dice-alt' => 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTAyNCIgaGVpZ2h0PSIxMDI0IiB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0Ij48ZyBpZD0iaWNvbW9vbi1pZ25vcmUiPjwvZz48cGF0aCBkPSJNNjg4IDM1MmgtMjU2Yy00NCAwLTgwIDM2LTgwIDgwdjI1NmMwIDQ0IDM2IDgwIDgwIDgwaDI1NmM0NCAwIDgwLTM2IDgwLTgwdi0yNTZjMC00NC0zNi04MC04MC04MHpNNDY0IDcwNGMtMjYuNTA4IDAtNDgtMjEuNDkyLTQ4LTQ4czIxLjQ5Mi00OCA0OC00OCA0OCAyMS40OTIgNDggNDgtMjEuNDkyIDQ4LTQ4IDQ4ek00NjQgNTEyYy0yNi41MDggMC00OC0yMS40OTItNDgtNDhzMjEuNDkyLTQ4IDQ4LTQ4IDQ4IDIxLjQ5MiA0OCA0OC0yMS40OTIgNDgtNDggNDh6TTU2MCA2MDhjLTI2LjUwOCAwLTQ4LTIxLjQ5Mi00OC00OHMyMS40OTItNDggNDgtNDggNDggMjEuNDkyIDQ4IDQ4LTIxLjQ5MiA0OC00OCA0OHpNNjU2IDcwNGMtMjYuNTA4IDAtNDgtMjEuNDkyLTQ4LTQ4czIxLjQ5Mi00OCA0OC00OCA0OCAyMS40OTIgNDggNDgtMjEuNDkyIDQ4LTQ4IDQ4ek02NTYgNTEyYy0yNi41MDggMC00OC0yMS40OTItNDgtNDhzMjEuNDkyLTQ4IDQ4LTQ4IDQ4IDIxLjQ5MiA0OCA0OC0yMS40OTIgNDgtNDggNDh6TTY3MC4zNzUgMzIwYy03LjQ2NS0zNi40MDQtMzkuODU0LTY0LTc4LjM3NS02NGgtMjU2Yy00NCAwLTgwIDM2LTgwIDgwdjI1NmMwIDM4LjUxOSAyNy41OTYgNzAuOTE4IDY0IDc4LjM3NXYtMzE4LjM3NWMwLTE3LjYgMTQuNC0zMiAzMi0zMmgzMTguMzc1eiI+PC9wYXRoPjwvc3ZnPg==', |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * |
| 406 | 406 | * @var array |
| 407 | 407 | */ |
| 408 | - $icons = apply_filters( 'gc_filter_svg_base64', $icons ); |
|
| 408 | + $icons = apply_filters('gc_filter_svg_base64', $icons); |
|
| 409 | 409 | } else { |
| 410 | 410 | $icons = [ |
| 411 | 411 | 'dice' => '<svg class="gc-icon svg gc-icon-dice" aria-labelledby="title-ID" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32"> |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | * |
| 446 | 446 | * @var array |
| 447 | 447 | */ |
| 448 | - $icons = apply_filters( 'gc_filter_svg_xml', Attributes\gc_kses( $icons ) ); |
|
| 448 | + $icons = apply_filters('gc_filter_svg_xml', Attributes\gc_kses($icons)); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | return $icons[ $name ]; |
@@ -458,6 +458,6 @@ discard block |
||
| 458 | 458 | * @param string $name An icon name. |
| 459 | 459 | * @param bool $encoded Whether to return the svg as a base64 encoded image (for background images) or the raw SVG XML. |
| 460 | 460 | */ |
| 461 | -function the_svg( $name = '', $encoded = true ) { |
|
| 462 | - echo get_svg( $name, $encoded ); // WPCS: XSS ok. |
|
| 461 | +function the_svg($name = '', $encoded = true) { |
|
| 462 | + echo get_svg($name, $encoded); // WPCS: XSS ok. |
|
| 463 | 463 | } |
@@ -45,22 +45,22 @@ discard block |
||
| 45 | 45 | function autoload_init() { |
| 46 | 46 | // Add in some specific includes and vendor libraries. |
| 47 | 47 | $files = [ |
| 48 | - dirname( __FILE__ ) . '/vendor/extended-cpts/extended-cpts.php', |
|
| 49 | - dirname( __FILE__ ) . '/vendor/extended-taxos/extended-taxos.php', |
|
| 50 | - dirname( __FILE__ ) . '/vendor/cmb2/init.php', |
|
| 51 | - dirname( __FILE__ ) . '/inc/namespace.php', |
|
| 52 | - dirname( __FILE__ ) . '/inc/functions.php', |
|
| 48 | + dirname(__FILE__) . '/vendor/extended-cpts/extended-cpts.php', |
|
| 49 | + dirname(__FILE__) . '/vendor/extended-taxos/extended-taxos.php', |
|
| 50 | + dirname(__FILE__) . '/vendor/cmb2/init.php', |
|
| 51 | + dirname(__FILE__) . '/inc/namespace.php', |
|
| 52 | + dirname(__FILE__) . '/inc/functions.php', |
|
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | 55 | // Autoload the namespaces. |
| 56 | - $namespaces = array_filter( glob( dirname( __FILE__ ) . '/inc/*' ), 'is_dir' ); |
|
| 57 | - foreach ( $namespaces as $namespace ) { |
|
| 58 | - $files[] = $namespace . '/namespace.php'; |
|
| 56 | + $namespaces = array_filter(glob(dirname(__FILE__) . '/inc/*'), 'is_dir'); |
|
| 57 | + foreach ($namespaces as $namespace) { |
|
| 58 | + $files[ ] = $namespace . '/namespace.php'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Loop through and load all the things! |
| 62 | - foreach ( $files as $file ) { |
|
| 63 | - require_once( $file ); |
|
| 62 | + foreach ($files as $file) { |
|
| 63 | + require_once($file); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | autoload_init(); |
| 75 | 75 | |
| 76 | 76 | // Register activation hook. |
| 77 | - register_activation_hook( __FILE__, __NAMESPACE__ . '\\activate' ); |
|
| 77 | + register_activation_hook(__FILE__, __NAMESPACE__ . '\\activate'); |
|
| 78 | 78 | |
| 79 | 79 | // Kick it off. |
| 80 | - add_action( 'plugins_loaded', __NAMESPACE__ . '\\bootstrap' ); |
|
| 80 | + add_action('plugins_loaded', __NAMESPACE__ . '\\bootstrap'); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // Kick it off! |