1
difenduandada
2024-10-15 7fd2948ee35c8e147ed35ce6d8502f94a98ddd22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
 
function list_categories(){
    $categories = fetch_all_categories();
    echo '<ul class="links list-categories">';
    foreach ($categories as $item) {
        echo '<a href="'. get_permalink('category', $item->slug) .'"><li>'. esc_string($item->name) .'</li></a>';
    }
    echo '</ul>';
}
function list_games($type, $amount, $count = false){
    echo '<div class="row">';
    $data = fetch_games_by_type($type, $amount, 0, $count);
    $games = $data['results'];
    foreach ( $games as $game ) { ?>
    <div class="col-4 list-tile">
        <a href="<?php echo get_permalink('game', $game->slug) ?>">
            <div class="list-game">
                <div class="list-thumbnail"><img src="<?php echo get_small_thumb($game) ?>" class="small-thumb" alt="<?php echo esc_string($game->title) ?>"></div>
            </div>
        </a>
    </div>
    <?php }
    echo '</div>';
}
function list_games_by_category($cat, $amount){
    // Deprecated, not used anymore
    echo '<div class="grid-layout grid-wrapper">';
    $data = get_game_list_category($cat, $amount);
    $games = $data['results'];
    foreach ( $games as $game ) { ?>
        <?php include  TEMPLATE_PATH . "/includes/grid.php" ?>
    <?php }
    echo '</div>';
}
function list_games_by_categories($cat, $amount){
    // Deprecated, not used anymore
    echo '<div class="grid-layout grid-wrapper">';
    $data = get_game_list_categories($cat, $amount);
    $games = $data['results'];
    foreach ( $games as $game ) { ?>
        <?php include  TEMPLATE_PATH . "/includes/grid.php" ?>
    <?php }
    echo '</div>';
}
 
function show_user_profile_header(){
 
    global $login_user;
 
    if($login_user){
    ?>
    <div class="user-avatar">
        <img src="<?php echo get_user_avatar() ?>">
    </div>
    <ul class="user-links hidden">
        <li>
            <strong>
                <?php echo $login_user->username ?>
            </strong>
            <div class="label-xp"><?php echo $login_user->xp ?>xp</div>
        </li>
        <hr>
        <a href="<?php echo get_permalink('user', $login_user->username) ?>">
            <li><?php _e('My Profile') ?></li>
        </a>
        <a href="<?php echo get_permalink('user', $login_user->username, array('edit' => 'edit')) ?>">
            <li><?php _e('Edit Profile') ?></li>
        </a>
        <hr>
        <a href="<?php echo DOMAIN ?>admin.php?action=logout">
            <li class="text-danger"><?php _e('Log Out') ?></li>
        </a>
    </ul>
    <?php
    }
}
 
register_sidebar(array(
    'name' => 'Head',
    'id' => 'head',
    'description' => 'HTML element before &#x3C;/head&#x3E;',
));
 
register_sidebar(array(
    'name' => 'Sidebar 1',
    'id' => 'sidebar-1',
    'description' => 'Right sidebar',
));
 
register_sidebar(array(
    'name' => 'Footer 1',
    'id' => 'footer-1',
    'description' => 'Footer 1',
));
 
register_sidebar(array(
    'name' => 'Footer 2',
    'id' => 'footer-2',
    'description' => 'Footer 2',
));
 
register_sidebar(array(
    'name' => 'Footer 3',
    'id' => 'footer-3',
    'description' => 'Footer 3',
));
 
register_sidebar(array(
    'name' => 'Top Content',
    'id' => 'top-content',
    'description' => 'Above main content element. Recommended for Ad banner placement.',
));
 
register_sidebar(array(
    'name' => 'Bottom Content',
    'id' => 'bottom-content',
    'description' => 'Under main content element. Recommended for Ad banner placement.',
));
 
register_sidebar(array(
    'name' => 'Homepage Bottom',
    'id' => 'homepage-bottom',
    'description' => 'Bottom content on homepage. Can be used to show site description or explaining about your site.',
));
 
register_sidebar(array(
    'name' => 'Footer Copyright',
    'id' => 'footer-copyright',
    'description' => 'Copyright section.',
));
 
class widget_game_list extends Widget {
    function __construct() {
         $this->name = 'Game List';
         $this->id_base = 'game-list';
         $this->description = 'Show game list ( Grid ). Is recommedned to put this on sidebar.';
    }
    public function widget( $instance, $args = array() ){
        $label = isset($instance['label']) ? $instance['label'] : '';
        $class = isset($instance['class']) ? $instance['class'] : 'widget';
        $type = isset($instance['type']) ? $instance['type'] : 'new';
        $amount = isset($instance['amount']) ? $instance['amount'] : 9;
 
        echo '<div class="'.$class.'">';
 
        if($label != ''){
            $icon = 'fa-plus';
            if($type != 'new'){
                $icon = 'fa-gamepad';
            }
            echo '<h4 class="widget-title"><i class="fa '.$icon.'" aria-hidden="true"></i>'.$label.'</h4>';
        }
 
        list_games($type, (int)$amount);
        echo '</div>';
    }
 
    public function form( $instance = array() ){
 
        if(!isset( $instance['label'] )){
            $instance['label'] = '';
        }
        if(!isset( $instance['type'] )){
            $instance['type'] = 'new';
        }
        if(!isset( $instance['amount'] )){
            $instance['amount'] = 9;
        }
        if(!isset( $instance['class'] )){
            $instance['class'] = 'widget';
        }
        ?>
        <div class="form-group">
            <label><?php _e('Widget label/title (optional)') ?>:</label>
            <input type="text" class="form-control" name="label" placeholder="NEW GAMES" value="<?php echo $instance['label'] ?>">
        </div>
        <div class="form-group">
            <label><?php _e('Sort game list by') ?>:</label>
            <select class="form-control" name="type">
                <?php
 
                $opts = array(
                    'new' => 'New',
                    'popular' => 'Popular',
                    'random' => 'Random',
                    'likes' => 'Likes',
                    'trending' => 'Trending'
                );
 
                foreach ($opts as $key => $value) {
                    $selected = '';
                    if($key == $instance['type']){
                        $selected = 'selected';
                    }
                    echo '<option value="'.$key.'" '.$selected.'>'.$value.'</option>';
                }
                ?>
            </select>
        </div>
        <div class="form-group">
            <label><?php _e('Amount') ?>:</label>
            <input type="number" class="form-control" name="amount" placeholder="9" min="1" value="<?php echo $instance['amount'] ?>">
        </div>
        <div class="form-group">
            <label><?php _e('Div class (Optional)') ?>:</label>
            <input type="text" class="form-control" name="class" placeholder="widget" value="<?php echo $instance['class'] ?>">
        </div>
        <?php
    }
}
 
register_widget( 'widget_game_list' );
 
if(file_exists(ABSPATH . TEMPLATE_PATH . '/includes/custom.php')){
    include(ABSPATH . TEMPLATE_PATH . '/includes/custom.php');
}
 
?>