-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand-ide-admin.php
More file actions
57 lines (50 loc) · 2.07 KB
/
rand-ide-admin.php
File metadata and controls
57 lines (50 loc) · 2.07 KB
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
<?php
add_action('admin_enqueue_scripts', 'rand_admin_scripts', 11);
function rand_admin_scripts() {
wp_register_script('rand-ide', plugins_url('js/rand-ide.js', __FILE__));
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-ui-core', '//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css');
wp_enqueue_script( 'rand-ide');
}
add_action('admin_menu', 'rand_add_menus', 12);
function rand_add_menus() {
$member_credits = add_submenu_page('idc', __('Rand IDE Settings', 'randide'), __('Rand IDE Settings', 'randide'), 'manage_options', 'rand_settings', 'rand_settings');
}
function rand_settings() {
$member = new ID_Member();
if (isset($_POST['rand_submit'])) {
// Getting all the allowed users whose credits could be added
$users = get_users(array('fields' => array('ID')));
//$users = array_reverse($member->get_allowed_users());
// Looping the users and updating their credits
foreach ($users as $user) {
$match = $member->match_user($user->ID);
if (empty($match)) {
$user_args = array(
'user_id' => $user->ID,
'level' => array(),
'data' => array()
);
$new_user = ID_Member::add_user($user_args);
}
ID_Member::add_credits($user->ID, absint($_POST['user_credits']));
}
$message = absint($_POST['user_credits']).' '._n('credit', 'credits', absint($_POST['user_credits']), 'randide').' '.__('added to all users', 'randide');
}
// Getting the option if stored before
$default_proj_end_date = get_option( "ign_default_project_end_date" );
if (isset($_POST['rand_proj_date_submit'])) {
// Saving the field in options
update_option( "ign_default_project_end_date", $_POST['default_project_end_date'] );
$default_proj_end_date = $_POST['default_project_end_date'];
// Updating all the projects ending dates
$projects = ID_Project::get_project_posts();
// Looping those posts and updating their end date in post meta
foreach ($projects as $project) {
update_post_meta($project->ID, 'ign_fund_end', $default_proj_end_date);
}
}
include_once 'templates/admin/_randSettings.php';
}
?>