public function filterGetAvatar($avatar, $idOrEmail, $size, $default, $alt) { if (is_numeric($idOrEmail) && \WPMinecraftJP\Configure::read('avatar_enable')) { $username = get_user_meta($idOrEmail, 'minecraftjp_username', true); if ($username) { $url = 'https://avatar.minecraft.jp/' . $username . '/minecraft/' . $size . '.png'; $avatar = sprintf('<img alt="%s" src="%s" class="avatar avatar-%d photo" height="%d" width="%d" />', esc_attr($alt), $url, $size, $size, $size); } } return $avatar; }
public function settings() { if (!empty($_POST['updateSettings'])) { if (!wp_verify_nonce(isset($_POST['token']) ? $_POST['token'] : '', 'minecraftjp_settings')) { $this->setFlash(__('Bad request.', App::NAME), 'default', array('class' => 'error')); wp_safe_redirect(admin_url('?page=minecraftjp')); exit; } $fields = array('client_id', 'client_secret', 'username_suffix'); foreach ($fields as $field) { if (isset($_POST[$field])) { Configure::write($field, $_POST[$field]); } } Configure::write('avatar_enable', isset($_POST['avatar_enable']) && $_POST['avatar_enable'] == '1' ? 1 : 0); Configure::write('force_users_can_register', isset($_POST['force_users_can_register']) && $_POST['force_users_can_register'] == '1' ? 1 : 0); header('Location: ' . admin_url('?page=minecraftjp&success=' . urlencode(__('Settings saved.')))); exit; } $this->set('group', $this->group); $this->render('admin_settings'); }
</table> <h3 class="clear"><?php echo __('User Settings', WPMinecraftJP\App::NAME); ?> </h3> <table class="form-table"> <tbody> <tr> <th scope="row"><?php echo __('Membership'); ?> </th> <td><input type="checkbox" id="avatarEnable" name="force_users_can_register" value="1" <?php echo \WPMinecraftJP\Configure::read('avatar_enable') == 1 ? ' checked="checked"' : ''; ?> /><label for="avatarEnable"><?php echo __('Force users can register', \WPMinecraftJP\App::NAME); ?> </label></td> </tr> <tr> <th scope="row"><?php echo __('Username Suffix', WPMinecraftJP\App::NAME); ?> </th> <td> <input name="username_suffix" type="text" value="<?php WPMinecraftJP\Configure::out('username_suffix'); ?>
private function getMinecraftJP() { $clientId = Configure::read('client_id'); $clientSecret = Configure::read('client_secret'); if (empty($clientId) || empty($clientSecret)) { echo 'Not configured.'; exit; } return new \MinecraftJP(array('clientId' => $clientId, 'clientSecret' => $clientSecret)); }
<?php if (!defined('WP_UNINSTALL_PLUGIN')) { die; } require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'autoload.php'; // Delete options \WPMinecraftJP\Configure::deleteAll();