mc-multiserver-gallery/includes/class-mc-gallery-helpers.php gelöscht
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class MC_Gallery_Helpers {
|
||||
|
||||
public static function get_tokens() {
|
||||
$arr = get_option(MCGALLERY_OPTION_KEY, []);
|
||||
return is_array($arr) ? $arr : [];
|
||||
}
|
||||
|
||||
public static function save_tokens($arr) {
|
||||
update_option(MCGALLERY_OPTION_KEY, $arr);
|
||||
}
|
||||
|
||||
public static function generate_token($length = 40) {
|
||||
if ($length % 2 !== 0) $length++;
|
||||
return bin2hex(random_bytes($length/2));
|
||||
}
|
||||
|
||||
public static function find_or_create_gallery_post($player, $server_id) {
|
||||
$args = [
|
||||
'post_type' => 'mc_gallery',
|
||||
'posts_per_page' => 1,
|
||||
'meta_query' => [
|
||||
['key' => 'mc_player', 'value' => $player],
|
||||
['key' => 'mc_server', 'value' => $server_id]
|
||||
]
|
||||
];
|
||||
$q = get_posts($args);
|
||||
if (!empty($q)) return $q[0];
|
||||
|
||||
$id = wp_insert_post([
|
||||
'post_type' => 'mc_gallery',
|
||||
'post_title' => "Galerie $player (Server $server_id)",
|
||||
'post_status' => 'publish',
|
||||
'meta_input' => [
|
||||
'mc_player' => $player,
|
||||
'mc_server' => $server_id
|
||||
]
|
||||
]);
|
||||
return get_post($id);
|
||||
}
|
||||
|
||||
public static function error_log($msg) {
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) error_log("[mc-gallery-pro] " . $msg);
|
||||
}
|
||||
|
||||
public static function rest_response_success($data = []) {
|
||||
return new WP_REST_Response(['success' => true, 'data' => $data], 200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user