<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function get_calender_events() { $params = array(); /*Get current date*/ $current_date = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key = "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...
<?php
/*
Plugin Name: Custom Profile
Plugin URI:
Description: This plugin provides custom login and managing people and private profiles
Version: 1.0
Author:
Author URI:
*/
global $table_name, $private_table, $user_tracking, $wpdb, $current_user;
$table_name = $wpdb->prefix . "tmp_users";
$private_table = $wpdb->prefix . "private_group";
$user_tracking = $wpdb->prefix . "user_tracking";
define('CP_PLUGIN_URL', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)));
require_once( ABSPATH . 'wp-includes/class-phpass.php');
/* * **********************************************************************************
* Hooks to fire when plugin is activated
* ************************************************************************************ */
register_activation_hook(__FILE__, 'ez_private_group');
register_activation_hook(__FILE__, 'ez_user_tracking');
/* * **********************************************************************************
* function for add private group table in database
* ************************************************************************************ */
function ez_private_group() {
global $wpdb, $private_table;
if ($wpdb->get_var("SHOW TABLES LIKE '$private_table'") != $private_table) {
$sql = "CREATE TABLE $private_table (
`ID` int NOT NULL AUTO_INCREMENT,
`user_id` int(40) NOT NULL,
`group_name` varchar(65) NOT NULL default '',
`group_creator` varchar(65) NOT NULL default '',
`Access_code` varchar(60) NOT NULL default '',
`group_members` varchar(1000) NOT NULL default '',
PRIMARY KEY (ID));";
//reference to upgrade.php file
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql);
}
}
/* * **********************************************************************************
* function for add user tracking group table in database
* ************************************************************************************ */
function ez_user_tracking() {
global $wpdb, $user_tracking;
if ($wpdb->get_var("SHOW TABLES LIKE '$user_tracking'") != $user_tracking) {
$sql = "CREATE TABLE $user_tracking (
`ID` int NOT NULL AUTO_INCREMENT,
`user_id` int(40) NOT NULL,
`post_id` varchar(3000) NOT NULL default '',
'timing` varchar(1000) NOT NULL default '',
'Evaluation_answers` varchar(2000) NOT NULL default '',
PRIMARY KEY (ID));";
//reference to upgrade.php file
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql);
}
}
/* * **********************************************************************************
* shortcode for sign in a user
* ************************************************************************************ */
add_shortcode('sign_in_user', 'signing1_user');
function signing1_user() {
ob_start();
wp_login_form();
$string = ob_get_contents();
ob_end_clean();
return $string;
}
add_shortcode('create_group', 'ez_create_group');
/* * **********************************************************************************
* function for creating private group
* ************************************************************************************ */
function ez_create_group() {
global $wpdb, $private_table, $current_user;
ob_start();
if (is_user_logged_in()) {
if (isset($_POST['ez-create-members'])) {
$group_name = strip_tags(trim($_POST['ez-group-name']));
$access_code = strip_tags(trim($_POST['ez-access-code']));
$members = $_POST['ez-members'];
$group_message = '';
if ($group_name && $access_code) {
$query = "SELECT COUNT(*) FROM `{$private_table}` WHERE `Access_code`= '{$access_code}'";
$customized_query = $wpdb->get_var($query);
if ($customized_query && intval($customized_query) == 1) {
echo "<div class='error'>This access code already exists.</div>";
} else {
$required_members = array();
if($members){
if (!(is_array($required_members))) {
$required_members = array();
}
$members = explode(",", $members);
foreach ($members as $mem) {
$members_query = $wpdb->get_var("SELECT COUNT(*)`user_email` FROM `{$wpdb->users}` WHERE `user_email`='$mem'");
if ($members_query && intval($members_query) == 1) {
$required_members[] = $mem;
}
}
}
if($_FILES['ez-custom-logo'] && !($_FILES["ez-custom-logo"]["error"] > 0)){
$custom_logo_name = $_FILES['ez-custom-logo']['name'];
$custom_logo_temp = $_FILES['ez-custom-logo']['tmp_name'];
move_uploaded_file($custom_logo_temp, get_template_directory().'/images/'.$custom_logo_name);
}
else{
$custom_logo_name = '';
}
$required_members[]= $current_user->user_email;
$members_insert = array_unique($required_members);
if($members){
$insert_members = implode(',', $members_insert);
$trim_insert_members = trim($insert_members,',');
$deselected_email = array_diff($members, $members_insert);
$converted_email_to_string = implode(',',$deselected_email);
$trim_it = trim($converted_email_to_string,',');
}
else{
$insert_members = implode(' ',$members_insert);
$trim_insert_members = trim($insert_members,',');
$trim_it = '';
}
$result = $wpdb->query($wpdb->prepare("INSERT INTO $private_table(user_id,group_name,group_creator, Access_code, group_members,Custom_logo)VALUES(%d,%s,%s,%s,%s,%s)", $current_user->ID, $group_name, $current_user->user_login, $access_code, $trim_insert_members,$custom_logo_name));
if ($result) {
if($trim_it){
$success_message = "<div class='success'><p>Your group with access code successfully created.
These members->".$trim_it." not included because they are not registered with us</p></div>";
}
else{
$success_message = "<div class='success'><p>Your group with access code successfully created.</p></div>";
}
}
}
} else {
$error_message = "Group name and Access code are required fields";
}
}
if($success_message){
$my_custom_query = $wpdb->get_row("SELECT * FROM `{$private_table}` WHERE `Access_code`= '{$access_code}'");
$remaining_emails = $my_custom_query->group_members;
$explode_it = explode(',',$remaining_emails);
$g_creator = $my_custom_query->group_creator;
$acc_code = $my_custom_query->Access_code;
$message = $g_creator ." has invited you to join a private group on Blaze Seminary.\n";
$message .= "Your access code is ".$acc_code."\n";
foreach($explode_it as $explode){
wp_mail($explode,'Private Group', $message);
}
}
if($error_message){
?>
<div class="error"><?php echo $error_message; ?></div>
<?php
}
if($success_message) { ?>
<?php echo $success_message; ?>
<?php } if (!($success_message)) {
?>
<h1 class="inner_title"> <?php _e("Create Private Group"); ?></h1>
<div class="create_group" class="wp-core-ui">
<form action="<?php echo $_SERVER['REDIRECT_URL']; ?>" method="POST" name="priv-grp" enctype="multipart/form-data">
<p>
<label for="ez-group-name"><?php _e("Group Name"); ?></label>
<input size="70px" type="text" name="ez-group-name" class="ez-group-name" value="<?php echo stripslashes($_POST['ez-group-name']); ?>" />
<span class="ez-gn-subs"><?php _e("(Keep group names simple)"); ?></span>
</p>
<p>
<label for="ez-access-code"><?php _e("Access Code"); ?></label>
<input size="70px" type="text" name="ez-access-code" class="ez-access-code" value="<?php echo $_POST['ez-access-code']; ?>" />
<span class="ez-gn-subs"><?php _e("(use numbers and/or letters)"); ?></span>
</p>
<p>
<label for="ez-members"><?php _e("Members"); ?></label>
<textarea size="50%" name="ez-members" rows="5" ><?php echo $_POST['ez-members']; ?></textarea>
<span class="ez-gn-subs"><?php _e("(Write comma separated list of Registered emails to add into group)"); ?></span>
</p>
<p>
<label for="ez-custom-logo"><?php _e("Custom Logo"); ?></label>
<input size="70px" type="file" name="ez-custom-logo" class="ez-custom-logo" value="" />
<span class="ez-gn-subs"><?php _e("(Dimension of logo should be 204x79)"); ?></span>
</p>
<p>
<input type="submit" name="ez-create-members" value="Create" />
</p>
</form>
</div>
<?php
}
} else {
echo "<div class='ez-logged-in'>You have to be logged in to view this page</div>";
}
$string = ob_get_contents();
ob_end_clean();
return $string;
}
/* * **********************************************************************************
* function for creating menu and submenu pages
* ************************************************************************************ */
function ez_custom_settings() {
add_menu_page(
'Home page', 'Home page', 'manage_options', 'home_page', 'home_page_options_display', '', '59.2'
);
add_submenu_page(
'home_page', 'Logo', 'Logo', 'manage_options', 'home_page', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Banner', 'Banner', 'manage_options', 'home_page_banner_display', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Top Headline', 'Top Headline', 'manage_options', 'home_page_headline_display', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Background Text ', 'Background Text', 'manage_options', 'home_page_background_text', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Follow us', 'Follow us', 'manage_options', 'home_page_follow_us', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Footer Options', 'Footer Options', 'manage_options', 'home_page_footer_options', 'home_page_options_display'
);
add_menu_page(
'Manage Users', 'Manage Users', 'manage_options', 'user_management', 'user_management_options_display', '', '59.3'
);
add_submenu_page(
'user_management', 'Tracking Progress', 'Tracking Progress', 'manage_options', 'user_management', 'user_management_options_display'
);
add_submenu_page(
'user_management', 'Head Badges', 'Head Badges', 'manage_options', 'user_management_head_badges', 'user_management_options_display'
);
add_submenu_page(
'user_management', 'Tracking Evaluation', 'Tracking Evaluation', 'manage_options', 'user_management_tracking_evaluation', 'user_management_options_display'
);
add_submenu_page(
'user_management', 'Purge Users', 'Purge Users', 'manage_options', 'user_management_purge_users', 'user_management_options_display'
);
add_menu_page(
'Discuss forum', 'Discuss forum', 'manage_options', 'discuss_forum', 'discuss_forum_options_display', '', '59.4'
);
}
add_action('admin_menu', 'ez_custom_settings');
/* * **********************************************************************************
* Callback function for home page
* ************************************************************************************ */
function home_page_options_display() {
?>
<div class="wrap">
<h2 class="standard-title">Home page Options</h2><br>
<?php $active_tab = isset($_GET['page']) ? $_GET['page'] : 'home_page'; ?>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php echo $active_tab == 'home_page' ? 'nav-tab-active' : ''; ?>" href="?page=home_page">Logo</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_banner_display' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_banner_display">Banner</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_headline_display' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_headline_display">Top Headline</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_background_text' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_background_text">Background Text</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_follow_us' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_follow_us">Follow Us</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_footer_options' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_footer_options">Footer Options</a>
</h2>
<div id="message-container"><?php settings_errors(); ?></div>
<?php
if ('home_page' == $active_tab) {
ez_logo_options();
} else if ('home_page_banner_display' == $active_tab) {
ez_banner_display();
} else if ('home_page_headline_display' == $active_tab) {
ez_top_headline();
} else if ('home_page_background_text' == $active_tab) {
ez_background_text();
} else if ('home_page_follow_us' == $active_tab) {
ez_follow_us();
} else if ('home_page_footer_options' == $active_tab) {
ez_footer_options();
}
?>
</div>
<?php
}
/* * **********************************************************************************
* Callback function for User Management
* ************************************************************************************ */
function user_management_options_display() {
?>
<div class="wrap">
<h2 class="standard-title">User Management</h2><br>
<?php $active_tab = isset($_GET['page']) ? $_GET['page'] : 'user_management'; ?>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php echo $active_tab == 'user_management' ? 'nav-tab-active' : ''; ?>" href="?page=user_management">Tracking Progress</a>
<a class="nav-tab <?php echo $active_tab == 'user_management_head_badges' ? 'nav-tab-active' : ''; ?>" href="?page=user_management_head_badges">Head Badges</a>
<a class="nav-tab <?php echo $active_tab == 'user_management_tracking_evaluation' ? 'nav-tab-active' : ''; ?>" href="?page=user_management_tracking_evaluation">Tracking Evaluation</a>
<a class="nav-tab <?php echo $active_tab == 'user_management_purge_users' ? 'nav-tab-active' : ''; ?>" href="?page=user_management_purge_users">Purge Users</a>
</h2>
<div id="message-container"><?php settings_errors(); ?></div>
<?php
if ('user_management' == $active_tab) {
ez_tracking_progress();
} else if ('user_management_head_badges' == $active_tab) {
ez_head_badges();
}
else if ('user_management_tracking_evaluation' == $active_tab) {
ez_tracking_evaluation();
}
else if ('user_management_purge_users' == $active_tab) {
ez_purge_users();
}
?>
</div>
<?php
}
/* * **********************************************************************************
* Callback function for Discussion forum
* ************************************************************************************ */
function discuss_forum_options_display() {
?>
<div class="wrap">
<h2 class="standard-title">Discussion Forum</h2><br>
<?php $active_tab = isset($_GET['page']) ? $_GET['page'] : 'discuss_forum'; ?>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php echo $active_tab == 'discuss_forum' ? 'nav-tab-active' : ''; ?>" href="?page=discuss_forum">Private Groups</a>
</h2>
<div id="message-container"><?php settings_errors(); ?></div>
<?php
if ('discuss_forum' == $active_tab) {
ez_private_group_members();
}
?>
</div>
<?php
}
/* * **********************************************************************************
* Callback for site logo
* ************************************************************************************ */
function ez_logo_options() {
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('ez_home_logo', $_POST['ez_home_logo']);
update_option('ez-logo-url', $_POST['ez-logo-url']);
update_option('ez-link-title', $_POST['ez-link-title']);
update_option('ez-target-link', $_POST['ez-target-link']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$ez_home_logo = get_option('ez_home_logo');
$ez_logo_url = get_option('ez-logo-url');
$ez_link_title = get_option('ez-link-title');
$target_link = get_option('ez-target-link');
?>
<div id="ez_header_menu_settings"><br><br>
<form action="" method="POST" >
<div id="ez-header-menu">
<table class="ez-logo">
<tr>
<th><label for="ez_home_logo">Image</label></th>
<td><input size="70px" type="text" name="ez_home_logo" class="ez_home_logo" id="image_src" value="<?php echo $ez_home_logo ?>"/>
<input type="submit" class="button upload_image" name="upload_button" id="logo_uploader_button" value="<?php _e('Select an Image', 'image_widget'); ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<?php
if (!empty($ez_home_logo)) {
echo '<img src="' . $ez_home_logo . '" />';
}
?>
</td>
</tr>
<tr>
<th><label for="ez-logo-url">href:</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_logo_url; ?>" name="ez-logo-url" id="ez-logo-url"/></td>
</tr>
<tr>
<th><label for="ez-link-title">Title :</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_link_title; ?>" name="ez-link-title" id="ez-link-title"/></td>
</tr>
<tr>
<th><label for="ez-target-link">Link Target :</label></th>
<td>
<select name="ez-target-link" id="ez-target-link">
<option value="_new_window" <?php selected($target_link, ' _new_window'); ?>>Open In New Window</option>
<option value="_same_window" <?php selected($target_link, '_same_window'); ?>>Stay In Same Window </option>
</select>
</td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
/* * **********************************************************************************
* Callback for Advertising banners in home page
* ************************************************************************************ */
function ez_banner_display() {
$action = isset($_POST['submit']) ? $_POST['submit'] : '';
$saved = false;
$options = '_banner';
if ($action) {
update_option($options, $_POST[$options]);
$saved = true;
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$$options = get_option($options);
if (!is_array($$options)) {
$$options = array();
}
?>
<form method="post" action="">
<br><br>
<div id="tabs" style="width:95%" >
<ul>
<li><a href="#tab-1">Banner 1</a></li>
<li><a href="#tab-2">Banner 2</a></li>
</ul>
<?php
for ($i = 1; $i <= 2; $i++) {
echo '<div id="tab-' . $i . '" >
<table class="ez-banner-content" >
<tr class="ez_image_src">
<th><label for="ez-image-src' . $i . '"> Image SRC :</label></th>
<td><input size="70px" type="text" name="_banner[ez-image-src' . $i . ']" id="image_src" value="' . $_banner['ez-image-src' . $i . ''] . '" class="ez-image-src' . $i . '" />
<input type="submit" class="button upload_image" name="upload_button" id="uploader_button" value="Select an Image" />
</td>
</tr>
<tr>
<td></td>
<td>
<img src="' . $_banner['ez-image-src' . $i . ''] . '" />
</td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-alt"> Alt Text :</label></th>
<td><input size="70px" type="text" value="' . $_banner['ez-image-src' . $i . '-alt'] . '" name="_banner[ez-image-src' . $i . '-alt]" id="ez-image-src' . $i . '-alt"/></td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-url"> Text URL :</label></th>
<td><input size="70px" type="text" value="' . $_banner['ez-image-src' . $i . '-url'] . '" name="_banner[ez-image-src' . $i . '-url]" id="ez-image-src' . $i . '-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-title-link"> Link Title :</label></th>
<td><input size="70px" type="text" value="' . $_banner['ez-image-src' . $i . '-title-link'] . '" name="_banner[ez-image-src' . $i . '-title-link]" id="ez-image-src' . $i . '-title-link"/></td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-link-target"> Link Target:</label></th>
<td>
<select name="_banner[ez-image-src' . $i . '-link-target]" id="ez-image-src' . $i . '-link-target">
<option value="_new_window" ' . selected($_banner['ez-image-src' . $i . '-link-target'], '_new_window', false) . '>Open In New Window</option>
<option value="_same_window" ' . selected($_banner['ez-image-src' . $i . '-link-target'], '_same_window', false) . '>Stay In Same Window</option>
</select>
</td>
</tr>
</table>
</div>
';
}
?>
</div>
<br/>
<br/>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
<?php
}
/* * *********************************************************************************
callback for headline
* ******************************************************************************** */
function ez_top_headline() {
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('ez_top_headline', $_POST['ez_top_headline']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$ez_top_headline = get_option('ez_top_headline');
?>
<div id="ez_headline">
<br>
<br>
<form action="" method="POST" >
<div id="ez-headline-settings">
<table>
<tr>
<th><label for="ez_top_headline">Headline Text :</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_top_headline; ?>" name="ez_top_headline" id="ez_top_headline"/></td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
/* * *********************************************************************************
* callback for background text
* ********************************************************************************** */
function ez_background_text() {
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('ez_back_text1', $_POST['ez_back_text1']);
update_option('ez_back_text2', $_POST['ez_back_text2']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$ez_back_text1 = get_option('ez_back_text1');
$ez_back_text2 = get_option('ez_back_text2');
?>
<div id="ez_headline">
<br>
<br>
<form action="" method="POST" >
<div id="ez-headline-settings">
<table>
<tr>
<th><label for="ez_back_text1">Background Text 1:</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_back_text1; ?>" name="ez_back_text1" id="ez_back_text1"/></td>
</tr>
<tr>
<th><label for="ez_back_text2">Background Text 2:</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_back_text2; ?>" name="ez_back_text2" id="ez_back_text2"/></td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
/* * ***********************************************************************************
callback for follow us
* *************************************************************************************** */
function ez_follow_us() {
$action = isset($_POST['submit']) ? $_POST['submit'] : '';
$saved = false;
$options = '_follow_us';
if ($action) {
update_option($options, $_POST[$options]);
$saved = true;
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$$options = get_option($options);
if (!is_array($$options)) {
$$options = array();
}
?>
<form method="post" action="">
<br><br>
<?php
echo '<div id="social-links" >
<table class="ez-social-links" >
<tr>
<th><label for="ez-image-src1-url"> Google plus URL </label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src1-url'] . '" name="_follow_us[ez-image-src1-url]" id="ez-image-src1-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src2-url"> Facebook URL</label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src2-url'] . '" name="_follow_us[ez-image-src2-url]" id="ez-image-src2-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src3-url"> Twitter URL</label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src3-url'] . '" name="_follow_us[ez-image-src3-url]" id="ez-image-src3-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src4-url"> RSS URL</label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src4-url'] . '" name="_follow_us[ez-image-src4-url]" id="ez-image-src4-url"/></td>
</tr>
</table>
</div>
';
?>
<br/>
<br/>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
<?php
}
/* * ***********************************************************************************
callback for choosing head badges
* *********************************************************************************** */
function ez_head_badges() {
$action = isset($_POST['submit']) ? $_POST['submit'] : '';
$saved = false;
$options = '_head_badges';
$options2 = '_head_badges_title';
$options3 = '_head_badges_link';
if ($action) {
update_option($options, $_POST[$options]);
update_option($options2, $_POST[$options2]);
update_option($options3, $_POST[$options3]);
$saved = true;
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$$options = get_option($options);
$$options2 = get_option($options2);
$$options3 = get_option($options3);
if (!is_array($$options)) {
$$options = array();
}
if (!is_array($$options2)) {
$$options2 = array();
}
if (!is_array($$options3)) {
$$options3 = array();
}
?>
<form method="post" action="" class="badge_form">
<?php
wp_reset_query();
$args = array(
'post_type' => 'classes',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'Class-type',
'field' => 'slug',
'terms' => 'sample',
'operator' => 'NOT IN'
)
)
);
$count = 1;
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
global $post;
$post_id = get_the_ID();
?>
<table class="classes_badge">
<tr>
<th width="200px"><label for="<?php echo $post_id; ?>" ><?php the_title(); ?></label></th>
<td>
<input type="text" size="60px" name="_head_badges[<?php echo $post_id; ?>]" class="<?php echo $post_id; ?>" id="image_src" value="<?php echo $_head_badges[$post_id]; ?>"/>
<input type="button" class="button upload_image" name="upload_button" id="uploader_button" value="<?php _e('Select an Image', 'image_widget'); ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<img src="<?php echo $_head_badges[$post_id]; ?>" />
</td>
</tr>
<tr>
<th width="200px"><label for="<?php echo $post_id; ?>" >Badge title</label></th>
<td>
<input type="text" size="60px" name="_head_badges_title[<?php echo $post_id; ?>]" class="_head_badges_link" value="<?php echo $_head_badges_title[$post_id]; ?>"/>
</td>
</tr>
<tr>
<th width="200px"><label for="<?php echo $post_id; ?>" >Badge URL</label></th>
<td>
<input type="text" size="60px" name="_head_badges_link[<?php echo $post_id; ?>]" class="_head_badges_link" value="<?php echo $_head_badges_link[$post_id]; ?>"/>
</td>
</tr>
</table>
<?php
}
}
?>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
<?php
}
/* * **********************************************************************************
* action for registering metaboxes
* *********************************************************************************** */
add_action('add_meta_boxes', 'ez_custom_profile_metaboxes');
/* * **********************************************************************************
* function for adding metabox
* ************************************************************************************ */
function ez_custom_profile_metaboxes() {
global $post;
$page_template = get_post_meta($post->ID, '_wp_page_template', true);
add_meta_box('ez_lesson_metaboxes', 'Custom fields', 'ez_lesson_metaboxes', 'classes', 'normal', 'high');
add_meta_box('ez_classes_dropdown', 'Custom fields', 'ez_classes_dropdown', 'lessons', 'normal', 'high');
if ($page_template == 'page-templates/about.php') {
add_meta_box('ez_about_banner', 'About', 'ez_about_banner', 'page', 'normal', 'high');
}
if($page_template == 'page-templates/template-classes.php'){
add_meta_box('ez_custom_title', 'Custom title', 'ez_custom_title', 'page', 'normal', 'high');
}
}
/* * **********************************************************************************
* function for adding metabox in classes post type
* ************************************************************************************ */
function ez_lesson_metaboxes() {
global $post, $wpdb;
$count = $count2 = $count3 = 1;
$lesson_checkbox = $mentor_checkbox = $headline_checkbox = array();
$lesson_checkbox = get_post_meta($post->ID, 'lesson_checkbox', true);
$mentor_checkbox = get_post_meta($post->ID, 'mentor_checkbox', true);
$headline_checkbox = get_post_meta($post->ID, 'headline_checkbox', true);
$sample_vimeo = get_post_meta($post->ID, 'sample_vimeo', true);
if (!(is_array($lesson_checkbox))) {
$lesson_checkbox = array();
}
if (!(is_array($mentor_checkbox))) {
$mentor_checkbox = array();
}
if (!(is_array($headline_checkbox))) {
$headline_checkbox = array();
}
wp_nonce_field(basename(__FILE__), 'ez_checkbox_noncename_lesson_metaboxes');
$custom_query = $wpdb->get_results("SELECT `ID`,`user_login` FROM `{$wpdb->users}`");
$args = array('post_type' => 'lessons', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC');
$args2 = array('post_type' => 'headline', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC');
$query = new WP_Query($args);
$query2 = new WP_Query($args2);
?>
<table class="widefat">
<tr>
<th><label for="sample_vimeo" >Sample Class Vimeo Link</label></th>
<td>
<input type="text" size="40px" name="sample_vimeo" class="sample_vimeo" value="<?php echo $sample_vimeo; ?>"/>
</td>
</tr>
<tr><td colspan="2">(If you are making a sample class you don't have to fill below fields. )</td></tr>
<tr>
<th class="associate-lessons">Select lessons</th>
</tr>
<tr>
<td class="lesson-td-left">
<div class="lesson_check" style="overflow:auto; width: 330px; height: 205px;margin-top: 20px;">
<?php
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
if (in_array(get_the_ID(), $lesson_checkbox)) {
$checked = 'checked';
} else {
$checked = '';
}
?>
<span class="lesson-details" style="float:left; width:100%" >
<input type="checkbox" id="lessons_checkbox_<?php echo $count; ?>" name="lesson_checkbox[]" <?php echo $checked; ?> value="<?php the_id(); ?>"/>
<label for="lessons_checkbox_<?php echo $count; ?>"><?php the_title(); ?></label><br>
</span>
<?php
$count++;
}
}
?>
</div>
</td>
</tr>
<tr>
<th class="associate-headline">Select sparks</th>
</tr>
<tr>
<td class="headline-td-left">
<div class="headline_check" style="overflow:auto; width: 330px; height: 205px;margin-top: 20px;">
<?php
if ($query2->have_posts()) {
while ($query2->have_posts()) {
$query2->the_post();
if (in_array(get_the_ID(), $headline_checkbox)) {
$checked = 'checked';
} else {
$checked = '';
}
?>
<span class="headline-details" style="float:left; width:100%" >
<input type="checkbox" id="headline_checkbox_<?php echo $count3; ?>" name="headline_checkbox[]" <?php echo $checked; ?> value="<?php the_id(); ?>"/>
<label for="headline_checkbox_<?php echo $count3; ?>"><?php the_title(); ?></label><br>
</span>
<?php
$count3++;
}
}
?>
</div>
</td>
</tr>
<tr>
<th class="associate-mentors">Select Mentors</th>
</tr>
<tr>
<td class="mentor-td-left">
<div class="mentor_check" style="overflow:auto; width: 330px; height: 205px;margin-top: 20px;">
<?php
foreach ($custom_query as $custom_q) {
if (in_array($custom_q->ID, $mentor_checkbox)) {
$checked = 'checked';
} else {
$checked = '';
}
?>
<span class="mentor-details" style="float:left; width:100%" >
<input type="checkbox" id="mentors_checkbox_<?php echo $count2; ?>" name="mentor_checkbox[]" <?php echo $checked; ?> value="<?php echo $custom_q->ID; ?>"/>
<label for="mentors_checkbox_<?php echo $count2; ?>"><?php echo $custom_q->user_login; ?></label><br>
</span>
<?php
$count2++;
}
?>
</div>
</td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_lesson_metaboxes', 1, 1);
function ez_save_lesson_metaboxes($post_id) {
if (!wp_verify_nonce(@$_POST['ez_checkbox_noncename_lesson_metaboxes'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, 'lesson_checkbox', $_POST['lesson_checkbox']);
update_post_meta($post_id, 'mentor_checkbox', $_POST['mentor_checkbox']);
update_post_meta($post_id, 'sample_vimeo', $_POST['sample_vimeo']);
update_post_meta($post_id, 'headline_checkbox', $_POST['headline_checkbox']);
}
/* * **********************************************************************************
* function for adding metabox in class template page
* ************************************************************************************ */
function ez_custom_title() {
global $post;
$_sample_course_title = $_course_title = '';
$_sample_course_title = get_post_meta($post->ID, '_sample_course_title', true);
$_course_title = get_post_meta($post->ID, '_course_title', true);
wp_nonce_field(basename(__FILE__), 'ez_noncename_custom_title');
?>
<table class="widefat">
<tr>
<th><label for="_sample_course_title" >Sample Course title(for non-logged in user)</label></th>
<td>
<input type="text" size="56px" name="_sample_course_title" class="_sample_course_title" id="_sample_course_title" value="<?php echo $_sample_course_title; ?>"/>
</td>
</tr>
<tr>
<th><label for="_course_title" >Course title(for logged in user)</label></th>
<td>
<input type="text" size="56px" name="_course_title" class="_course_title" id="_course_title" value="<?php echo $_course_title; ?>"/>
</td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_custom_title', 1, 1);
/* * **********************************************************************************
* function for saving data in classes post type
* ************************************************************************************ */
function ez_save_custom_title($post_id) {
if (!wp_verify_nonce(@$_POST['ez_noncename_custom_title'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, '_sample_course_title', $_POST['_sample_course_title']);
update_post_meta($post_id, '_course_title', $_POST['_course_title']);
}
/* * **********************************************************************************
* function for adding metabox in about page
* ************************************************************************************ */
function ez_about_banner() {
global $post;
$about_banner = $banner_url = '';
$about_banner = get_post_meta($post->ID, '_about_banner', true);
$about_banner_url = get_post_meta($post->ID, '_about_banner_url', true);
wp_nonce_field(basename(__FILE__), 'ez_checkbox_noncename_about_banner');
?>
<table class="widefat">
<tr>
<th><label for="_about_banner" >Banner img</label></th>
<td>
<input type="text" size="56px" name="_about_banner" class="_about_banner" id="image_src" value="<?php echo $about_banner; ?>"/>
<input type="button" class="button upload_image" name="upload_button" id="uploader_button" value="<?php _e('Select an Image', 'image_widget'); ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<?php if (!empty($about_banner)) {
?>
<img width="266px" height="184px" src="<?php echo $about_banner; ?>" />
<?php } ?>
</td>
</tr>
<tr>
<th><label for="_about_banner_url" >Banner URL</label></th>
<td>
<input type="text" size="56px" name="_about_banner_url" class="_about_banner_url" id="_about_banner_url" value="<?php echo $about_banner_url; ?>"/>
</td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_about_banner', 1, 1);
/* * **********************************************************************************
* function for saving data in classes post type
* ************************************************************************************ */
function ez_save_about_banner($post_id) {
if (!wp_verify_nonce(@$_POST['ez_checkbox_noncename_about_banner'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, '_about_banner', $_POST['_about_banner']);
update_post_meta($post_id, '_about_banner_url', $_POST['_about_banner_url']);
}
/* * **********************************************************************************
* function for adding metabox in lesson post type
* ************************************************************************************ */
function ez_classes_dropdown() {
global $post, $wpdb;
$count = 1;
$pdf_guide = $written_transcript = $pdf_content = $subtitle = '';
$pdf_guide = get_post_meta($post->ID, '_pdf_guide', true);
$pdf_content = get_post_meta($post->ID, '_pdf_content', true);
$written_transcript = get_post_meta($post->ID, '_written_transcript', true);
$subtitle = get_post_meta($post->ID, '_sub_title', true);
wp_nonce_field(basename(__FILE__), 'ez_classes_noncename_assigned_classes');
?>
<table class="widefat">
<tr>
<th><label for="_pdf_guide">pdf study guide</label></th>
<td><input size="70px" type="text" value="<?php echo $pdf_guide; ?>" name="_pdf_guide" id="_pdf_guide"/></td>
</tr>
<tr>
<th><label for="_pdf_content">pdf content</label></th>
<td> <?php wp_editor(stripslashes($pdf_content), '_pdf_content', array('textarea_name' => '_pdf_content', 'textarea_rows' => 4, 'textarea_columns' => 10)); ?></td>
</tr>
<tr>
<th><label for="_written_transcript">Written Transcript</label></th>
<td> <?php wp_editor(stripslashes($written_transcript), '_written_transcript', array('textarea_name' => '_written_transcript', 'textarea_rows' => 4, 'textarea_columns' => 10)); ?></td>
</tr>
<tr>
<th><label for="_sub_title">Subtitle</label></th>
<td><input size="70px" type="text" value="<?php echo $subtitle; ?>" name="_sub_title" id="_sub_title"/></td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_classes_dropdown', 1, 1);
/* * **********************************************************************************
* function for save metabox in lesson post type
* ************************************************************************************ */
function ez_save_classes_dropdown($post_id) {
if (!wp_verify_nonce(@$_POST['ez_classes_noncename_assigned_classes'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, '_pdf_guide', $_POST['_pdf_guide']);
update_post_meta($post_id, '_pdf_content', $_POST['_pdf_content']);
update_post_meta($post_id, '_written_transcript', $_POST['_written_transcript']);
update_post_meta($post_id, '_sub_title', $_POST['_sub_title']);
}
/* * **********************************************************************************
* Shortcode for private group
* ************************************************************************************ */
add_shortcode('private_group', 'custom_manage_group');
/* * **********************************************************************************
* function for add shortcode
* ************************************************************************************ */
function custom_manage_group() {
global $wpdb, $current_user,$private_table;
ob_start();
if(!($_SESSION['access_code'] == '')){
$query = $wpdb->get_row("SELECT * FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
}
if(isset($_POST['ez-manage-members'])){
$email_to_join = $_POST['ez-email-addresses'];
$query_email = explode(",",$query->group_members);
$address = array();
$address = $_POST['email_address'];
if($_FILES['ez-custom-logo'] && !($_FILES["ez-custom-logo"]["error"] > 0)){
$custom_logo_name = $_FILES['ez-custom-logo']['name'];
$custom_logo_temp = $_FILES['ez-custom-logo']['tmp_name'];
move_uploaded_file($custom_logo_temp, get_template_directory().'/images/'.$custom_logo_name);
}
else{
$custom_logo_name = '';
}
if($custom_logo_name != ''){
$logoquery = $wpdb->query("UPDATE `{$private_table}` SET `Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
if($address){
$unique = array_diff($query_email, $address);
$join_array = implode(',',$unique);
if($custom_logo_name != ''){
$query_row = $wpdb->query("UPDATE `{$private_table}` SET `group_members`='{$join_array}',`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$query_row = $wpdb->query("UPDATE `{$private_table}` SET `group_members`='{$join_array}' WHERE `Access_code`='{$query->Access_code}'");
}
}
if($email_to_join){
$members = explode(",", $email_to_join);
$required_members = array();
if (!(is_array($required_members))) {
$required_members = array();
}
if((count($members)) == 1){
$members_query = $wpdb->get_var("SELECT COUNT(*)`user_email` FROM `{$wpdb->users}` WHERE `user_email`='$members[0]'");
if ($members_query && (intval($members_query) == 1)) {
$required_members[] = $members[0];
}
}
else{
foreach ($members as $mem) {
$members_query = $wpdb->get_var("SELECT COUNT(*)`user_email` FROM `{$wpdb->users}` WHERE `user_email`='$mem'");
if ($members_query && (intval($members_query) == 1)) {
$required_members[] = $mem;
}
}
}
$members_insert = array_unique($required_members);
$deselected_members = array_diff($members,$members_insert);
$convert_to_string = implode(',',$deselected_members);
$trim_that_str = trim($convert_to_string,',');
if($trim_that_str){
echo "<div class='success'>Your changes saved successfully.These members->".$trim_that_str." are not added because they are not registered with us</div>";
}
else{
echo "<div class='success'>Your changes saved successfully.</div>";
}
$insert_members = implode(',', $members_insert);
$query_to_check = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$query->Access_code}'");
$mquery = $query_to_check->group_members;
$vquery = explode(",",$mquery);
if($vquery[0] == ''){
if($custom_logo_name != ''){
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$insert_members}',`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$insert_members}' WHERE `Access_code`='{$query->Access_code}'");
}
}
else{
if($custom_logo_name != ''){
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= CONCAT(`group_members`,',{$insert_members}'),`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= CONCAT(`group_members`,',{$insert_members}') WHERE `Access_code`='{$query->Access_code}'");
}
}
if($i_query){
$customized_query = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$query->Access_code}'");
if($customized_query){
$var_query = $customized_query->group_members;
$custom_var_query = explode(",",$var_query);
if($custom_var_query[0] == ''){
if($custom_logo_name != ''){
$wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$custom_var_query[1]}',`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$custom_var_query[1]}' WHERE `Access_code`='{$query->Access_code}'");
}
}
}
}
}
}
$update_query = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
$gm = $update_query->group_members;
$exploding = explode(',', $gm);
$uniqueness = array_unique($exploding);
$ready_to_join = implode(',', $uniqueness);
$remove_comma = trim($ready_to_join, ",");
if($ready_to_join){
$wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$remove_comma}' WHERE `Access_code`='{$query->Access_code}'");
}
$post_query = $wpdb->get_row("SELECT * FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
if($query && $post_query){
if($_POST){
$early_members = explode(',', $query->group_members);
$added_members = explode(',', $post_query->group_members);
$unified = array_diff($added_members,$early_members);
$g_creator = $post_query->group_creator;
$acc_code = $post_query->Access_code;
$message = $g_creator ." has invited you to join a private group on Blaze Seminary.\n";
$message .= "Your access code is ".$acc_code."\n";
foreach($unified as $uni){
wp_mail($uni,'Private Group', $message);
}
}
}
$custom_logo = '';
$custom_logo_query = $wpdb->get_row("SELECT `Custom_logo` FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
if($custom_logo_query->Custom_logo != ''){
$custom_logo = $custom_logo_query->Custom_logo;
}
else{
$custom_logo = '';
}
if (is_user_logged_in() && $query->group_creator == $current_user->user_login && !isset($_POST)) {
?>
<h1 class="inner_title"><?php _e('Manage Private Group'); ?></h1>
<div class="manage-priv-group" class="wp-core-ui">
<form action="<?php echo $_SERVER['REDIRECT_URL']; ?>" method="POST" name="priv-grp" enctype="multipart/form-data">
<table class="widefat">
<tr>
<th width="200px" ><?php _e('Group Name'); ?></th>
<td><?php echo $query->group_name; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Access Code'); ?></th>
<td><?php echo $query->Access_code; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Check the Members you want to delete from this group'); ?></th>
<td>
<?php
$email_address = explode(",",$query->group_members);
if($email_address[0] != ''){
foreach($email_address as $email){
?>
<input type="checkbox" name="email_address[]" <?php checked($address, $email ); ?> value="<?php echo $email; ?>"/> <?php echo $email; ?><br><br>
<?php
}
}
?>
</tr>
<tr>
<th width="200px"><?php _e("Enter email addresses separated by commas <br>to add new members to the group"); ?></th>
<td><textarea rows="10" name="ez-email-addresses"></textarea></td>
</tr>
<tr>
<th width="200px" ><?php _e('Custom Logo'); ?></th>
<td><input size="70px" type="file" name="ez-custom-logo" class="ez-custom-logo" value="" />
<span class="ez-gn-subs"><?php _e("(Dimension of logo should be 204x79)"); ?></span></td>
</tr>
<tr>
<th width="200px" ><?php _e('Logo Image'); ?></th>
<?php if($custom_logo == '') {?>
<td><img src="<?php echo get_bloginfo('stylesheet_directory').'/images/logo.gif'; ?>"</td>
<?php } else{ ?>
<td><img src="<?php echo get_bloginfo('stylesheet_directory').'/images/'.$custom_logo; ?>"</td>
<?php } ?>
</tr>
</table>
<p>
<input type="submit" name="ez-manage-members" value="Save Changes" />
</p>
</form>
</div>
<?php
}
elseif(isset($_POST)){
?>
<h1 class="inner_title"><?php _e('Manage Private Group'); ?></h1>
<div class="manage-priv-group" class="wp-core-ui">
<form action="<?php echo $_SERVER['REDIRECT_URL']; ?>" method="POST" name="priv-grp" enctype="multipart/form-data">
<table class="widefat">
<tr>
<th width="200px" ><?php _e('Group Name'); ?></th>
<td><?php echo $query->group_name; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Access Code'); ?></th>
<td><?php echo $query->Access_code; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Check the Members you want to delete from this group'); ?></th>
<td>
<?php
$email_address = explode(",",$post_query->group_members);
if($email_address[0] != ''){
foreach($email_address as $email){
?>
<input type="checkbox" name="email_address[]" <?php checked($address, $email ); ?> value="<?php echo $email; ?>"/> <?php echo $email; ?><br><br>
<?php
}
}
?>
</tr>
<tr>
<th width="200px"><?php _e("Enter email addresses separated by commas <br>to add new members to the group"); ?></th>
<td><textarea rows="10" name="ez-email-addresses"></textarea></td>
</tr>
<tr>
<th width="200px" ><?php _e('Custom Logo'); ?></th>
<td><input size="70px" type="file" name="ez-custom-logo" class="ez-custom-logo" value="" />
<span class="ez-gn-subs"><?php _e("(Dimension of logo should be 204x79)"); ?></span></td>
</tr>
<tr>
<th width="200px" ><?php _e('Logo Image'); ?></th>
<?php if($custom_logo == '') {?>
<td><img width="204" height="79" src="<?php echo get_bloginfo('stylesheet_directory').'/images/logo.gif'; ?>"</td>
<?php } else{ ?>
<td><img width="204" height="79" src="<?php echo get_bloginfo('stylesheet_directory').'/images/'.$custom_logo; ?>"</td>
<?php } ?>
</tr>
</table>
<p>
<input type="submit" name="ez-manage-members" value="Save Changes" />
</p>
</form>
</div>
<?php
}
else {
echo "<div class='inner_title'><h1>Only Group Creator Can view this page</h1>";
}
$string = ob_get_contents();
ob_end_clean();
return $string;
}
/* * *********************************************************************************
callback for tracking progress
* ******************************************************************************** */
function ez_tracking_progress() {
global $wpdb, $user_tracking;
$page = isset( $_GET['tpage'] ) ? abs( (int) $_GET['tpage'] ) : 1;
$items_per_page = 20;
$offset = ( $page * $items_per_page ) - $items_per_page;
$total = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->users}` WHERE `user_login`!='admin' ");
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin' LIMIT $offset, $items_per_page");
if($user_query){
$meta_value = get_option('_head_badges');
}
if($_GET['tpage'] > 1){
$count = (($_GET['tpage'] - 1)* $items_per_page) + 1;
}
else{
$count = 1;
}
?>
<br><br>
<form method="post" action="">
Search Username: <input type="text" id="custom_user" name="custom_user" value="<?php echo $cus_user; ?>"/>
<input type="submit" name="all_users" value="All Users" class="button button-primary" style="float:right">
</form>
<table class="tracking_prog" border="1" cellspacing="5">
<br><br>
<thead>
<tr>
<th width="10%" height="40px">S No.</th>
<th width="30%" style="text-align:center">User Name</th>
<th style="text-align:center">Completed</th>
</tr>
</thead>
<?php
if ($user_query) {
foreach ($user_query as $user_q) {
$custom_query = $wpdb->get_results("SELECT `post_id` FROM `{$user_tracking}` WHERE `user_id`= $user_q->ID ORDER BY `post_id` ASC");
?>
<tr>
<td width="10%" style="text-align:center"><?php echo $count . ')'; ?></td>
<td width="30%" style="text-align:center" ><?php echo $user_q->user_login; ?></td>
<td><?php
foreach($meta_value as $key => $value){
foreach($custom_query as $cus_q){
if($key == $cus_q->post_id){
$title = get_the_title($cus_q->post_id);
echo "<div class='badges_images' style='float:left;'><h4>$title</h4><span class='class-img'><img src=".$value."></span></div>";
}
}
}
?>
</td>
<?php
$count++;
?>
</tr>
<?php
}
}
?>
</table>
<div class="admin_pagination">
<?php
echo paginate_links( array(
'base' => add_query_arg( 'tpage', '%#%' ),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => ceil($total / $items_per_page),
'current' => $page
));
?>
</div>
<?php
}
/* * *********************************************************************************
callback for private group
* ******************************************************************************** */
function ez_private_group_members() {
global $wpdb, $private_table;
if(isset($_POST['submit'])){
$sorted_group = $_POST['sorted_group'];
$sort_submit = $_POST['sort_submit'];
if($sorted_group && $sort_submit){
$group_query = $wpdb->get_results("SELECT * FROM `{$private_table}` ORDER BY `$sorted_group` $sort_submit");
}
else{
$group_query = $wpdb->get_results("SELECT * FROM `{$private_table}`");
}
}
else{
$group_query = $wpdb->get_results("SELECT * FROM `{$private_table}`");
}
$count = 1;
?>
<br><br>
<form method="post" action="">
SORT <select name="sorted_group">
<option value="">Select</option>
<option value="group_creator" <?php if($sorted_group == 'group_creator'){ echo 'selected=selected';}?>>Group Creator</option>
<option value="group_name" <?php if($sorted_group == 'group_name'){ echo 'selected=selected';}?>>Group Name</option>
</select>
ORDER BY <select name="sort_submit">
<option value="">Select</option>
<option value="ASC" <?php if($sort_submit == 'ASC'){ echo 'selected=selected';}?>>ASC</option>
<option value="DESC" <?php if($sort_submit == 'DESC'){ echo 'selected=selected';}?>>DESC</option>
</select>
<input type="submit" value="Search" class="button button-primary" id="submit" name="submit">
</form>
<table class="priv_grp_mem" border="1" cellspacing="5">
<thead>
<tr>
<th width="5%" height="46px">S No.</th>
<th width="10%" style="text-align:center" >Group Creator</th>
<th width="20%" style="text-align:center">Group Name</th>
<th width="20%" style="text-align:center">Access code</th>
<th width="30%" style="text-align:center">Members</th>
<th width="10%" style="text-align:center">Add/delete</th>
</tr>
</thead>
<?php
if ($group_query) {
foreach ($group_query as $group_q) {
?>
<tr class="custom-<?php echo $count; ?>">
<td style="text-align:center"><?php echo $count . ')'; ?></td>
<td style="text-align:center"><?php echo $group_q->group_creator; ?></td>
<td width="20%" style="text-align:center" ><?php echo $group_q->group_name; ?></td>
<td width="20%" style="text-align:center" ><?php echo $group_q->Access_code; ?></td>
<td width="30%" style="text-align:center;">
<textarea id="group_members" readonly><?php echo $group_q->group_members; ?></textarea>
</td>
<td width="10%" style="text-align:center"><a class="edit_group_mem">Edit|</a><a rel="<?php echo $count; ?>" class="delete_group">delete</a><a class="submit_group" style="display:none" >Save</a></td>
</tr>
<?php
$count++;
}
}
?>
</table>
<?php
}
add_shortcode("signed_home", "signed_in_sidebar");
function signed_in_sidebar(){
ob_start();
global $current_user,$wpdb,$private_table;
if($_SESSION['access_code']){
$query = $wpdb->get_row("SELECT `group_creator` FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
if($query && $current_user->user_login == $query->group_creator){ ?>
<div class="ez-register-link">
<a class="create_grp" href="<?php echo home_url().'/manage-group/';?>"><?php _e("Manage Private Study Group"); ?></a>
</div>
<?php
}
else{
?>
<div class="ez-register-link">
<a class="create_grp" href="<?php echo home_url().'/group/';?>"><?php _e("Create Private Study Group"); ?></a>
</div>
<?php
}
}
else{
?>
<div class="ez-register-link">
<a class="create_grp" href="<?php echo home_url().'/group/';?>" ><?php _e("Create Private Study Group"); ?></a>
</div>
<?php
}
$string = ob_get_contents();
ob_end_clean();
return $string;
}
add_shortcode("custom_user", "custom_dynamic_classes");
function custom_dynamic_classes(){
global $current_user,$wpdb,$user_tracking,$post;
ob_start();
?>
<span>Welcome <?php echo $current_user->user_login; ?></span>
<div class="class_badges">
<div class="image_container">
<?php $query = $wpdb->get_results("SELECT `post_id` FROM `{$user_tracking}` WHERE `user_id`= $current_user->ID ORDER BY `post_id` ASC");
if($query){
$meta_value = get_option('_head_badges');
$_head_badges_title = get_option('_head_badges_title');
$_head_badges_link = get_option('_head_badges_link');
foreach($query as $que){
foreach($_head_badges_title as $head => $tit){
if($head == $que->post_id){
$head_title = $tit;
}
}
foreach($_head_badges_link as $he => $bad){
if($he == $que->post_id){
$head_bd_link = $bad;
}
}
foreach($meta_value as $key => $value){
if($key == $que->post_id){
$title = get_the_title( $que->post_id);
?>
<div class="badges_images" style="float:left;"><h4><?php echo $title; ?></h4><span class="class-img" ><a href="<?php echo $head_bd_link; ?>" target="_blank" title="<?php echo $head_title; ?>" ><img src="<?php echo $value; ?>"/></a></span></div>
<?php
}
}
}
}
?>
</div>
</div>
<?php
$string = ob_get_contents();
ob_end_clean();
return $string;
}
add_shortcode("custom_register", 'register_extra');
function register_extra(){
ob_start();
wp_register();
$string = ob_get_contents();
ob_end_clean();
return $string;
}
function ez_tracking_evaluation(){
global $wpdb, $user_tracking;
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
$items_per_page = 20;
$offset = ( $page * $items_per_page ) - $items_per_page;
$new_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin' LIMIT $offset, $items_per_page");
$total = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
?>
<br><br>
<form method="post" action="">
Search Username: <input type="text" name="custom_user" value="<?php echo $cus_user; ?>"/>
<input type="submit" value="All Users" class="button button-primary" id="submit" name="tracking_evaluation" style="float:right">
</form>
<br><br>
<div class="accordion_outer">
<div class="accordion">
<?php
foreach ($new_query as $user_q){
?>
<h3><?php echo $user_q->user_login; ?></h3>
<?php
$customization_query = $wpdb->get_results("SELECT `post_id` FROM `{$user_tracking}` WHERE `user_id`= $user_q->ID ORDER BY `post_id` ASC");
?>
<div>
<p>
<?php if(!$customization_query){?>
<div class="no-class">
<?php _e("This User not Evaluated any Class");?>
</div>
<?php } ?>
<div class="accordion">
<?php
foreach ($customization_query as $custom_q) {
$evaluation_content = $wpdb->get_row("SELECT `Evaluation_answers` FROM `{$user_tracking}` WHERE `user_id`= $user_q->ID AND `post_id`= $custom_q->post_id");
$evaluaton_con = explode('||',$evaluation_content->Evaluation_answers);
?>
<h3><?php echo get_the_title($custom_q->post_id);?></h3>
<div>
<ul>
<li>1) What was the general themes of this course?</li>
<span> Ans: <?php echo $evaluaton_con[0]; ?></span>
<li>2) What were the major thought or conscience difficulties that the Holy Spirit brought to your attention through this course?</li>
<span>Ans: <?php echo $evaluaton_con[1]; ?></span>
<li>3) How can what you learned through this course be useful for today’s Kingdom work?</li>
<span>Ans: <?php echo $evaluaton_con[2]; ?></span>
</ul>
</div>
<?php
}
$eval_learned = get_user_meta($user_q->ID, 'eval_learned',true);
$util_learned = get_user_meta($user_q->ID, 'util_learned', true);
if($eval_learned && $util_learned ){
?>
<h3><?php _e('Graduation Evaluation');?></h3>
<div>
<ul>
<li>1. What have you learned?</li>
<span> Ans: <?php echo $eval_learned; ?></span>
<li>2. How will you use what you have learned?</li>
<span>Ans: <?php echo $util_learned; ?></span>
</ul>
</div>
<?php
}
?>
</div>
</p>
</div>
<?php
}
?>
</div>
</div>
<div class="admin_pagination">
<?php
echo paginate_links( array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => ceil($total / $items_per_page),
'current' => $page
));
?>
</div>
<?php
}
function ez_purge_users(){
global $wpdb,$private_table;
$count = 1;
if(isset($_POST['submit'])){
$sorted_group = $_POST['sorted_group'];
$sort_submit = $_POST['sort_submit'];
if($sorted_group == 'last_login' && $sort_submit){
$user_query = $wpdb->get_results("SELECT *
FROM `{$wpdb->users}` AS U, `{$wpdb->usermeta}` AS M
WHERE M.META_KEY = '_LAST_LOGIN'
AND U.user_login!='admin' AND M.USER_ID = U.ID
ORDER BY M.META_VALUE $sort_submit");
}
else if($sorted_group == 'to_be_deleted' && $sort_submit){
$user_query = $wpdb->get_results("SELECT *
FROM `{$wpdb->users}` AS U, `{$wpdb->usermeta}` AS M
WHERE M.META_KEY = 'deleted_date'
AND U.user_login!='admin' AND M.USER_ID = U.ID
ORDER BY M.META_VALUE $sort_submit");
}
else{
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
}
}
else{
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
}
?>
<br><br>
<form method="post" action="">
SORT <select name="sorted_group">
<option value="">Select</option>
<option value="last_login" <?php if($sorted_group == 'last_login'){ echo 'selected=selected';}?>>Last Login</option>
<option value="to_be_deleted" <?php if($sorted_group == 'to_be_deleted'){ echo 'selected=selected';}?>>To-be-deleted</option>
</select>
ORDER BY <select name="sort_submit">
<option value="">Select</option>
<option value="ASC" <?php if($sort_submit == 'ASC'){ echo 'selected=selected';}?>>ASC</option>
<option value="DESC" <?php if($sort_submit == 'DESC'){ echo 'selected=selected';}?>>DESC</option>
</select>
<input type="submit" value="Search" class="button button-primary" id="submit" name="submit">
</form>
<table class="ez_purge_users" border="1" cellspacing="5">
<thead>
<tr>
<th width="5%" height="46px">S.No.</th>
<th width="10%" style="text-align:center">Username</th>
<th width="20%" style="text-align:center">Email Address</th>
<th width="20%" style="text-align:center">Private Groups</th>
<th width="15%" style="text-align:center">Last Login</th>
<th width="15%" style="text-align:center">To-be-deleted</th>
</tr>
</thead>
<?php
if ($user_query) {
foreach ($user_query as $user_q) {
$last_login = get_user_meta($user_q->ID, '_last_login', true);
$t = '-';
$no_days = '-';
$deleted_date = '-';
if($last_login){
$t = gmdate("m-d-y",(int)$last_login);
$now = time();
$your_date = $last_login;
if($your_date){
$datediff = $now - $your_date;
$no_days = floor($datediff/(60*60*24));
if($no_days >= 90){
$find_date = strtotime("+104 day", $your_date);
$deleted_date = gmdate("m-d-y", (int)$find_date);
$save_deleted_date = update_user_meta($user_q->ID, 'deleted_date',$deleted_date);
}
}
}
$get_group = $wpdb->get_results("SELECT `group_name` FROM `{$private_table}` WHERE `group_members` LIKE '%$user_q->user_email%'",ARRAY_A);
?>
<tr class="custom-<?php echo $count; ?>">
<td style="text-align:center"><?php echo $count . ')'; ?></td>
<td style="text-align:center"><?php echo $user_q->user_login; ?></td>
<td width="20%" style="text-align:center" ><?php echo $user_q->user_email; ?></td>
<td width="20%" style="text-align:center" >
<?php
if($get_group){
$c_grp = count($get_group);
foreach ($get_group as $ggrp){
if($c_grp > 1){
echo $ggrp['group_name'].',';
}
else{
echo $ggrp['group_name'];
}
$c_grp--;
}
}
else{
echo '-';
}?>
</td>
<td width="15%" style="text-align:center" ><?php echo $t; ?></td>
<td width="15%" style="text-align:center"><?php echo $deleted_date; ?></td>
</tr>
<?php
$count++;
}
}
?>
</table>
<?php
}
function ez_footer_options(){
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('_footer_email', $_POST['_footer_email']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$email = get_option('_footer_email');
?>
<div id="footer_options">
<br>
<br>
<form action="" method="POST" >
<div id="footer_options">
<table>
<tr>
<th><label for="_footer_email">Email:</label></th>
<td><input size="70px" type="text" value="<?php echo $email; ?>" name="_footer_email" id="_footer_email"/></td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
/*
Plugin Name: Custom Profile
Plugin URI:
Description: This plugin provides custom login and managing people and private profiles
Version: 1.0
Author:
Author URI:
*/
global $table_name, $private_table, $user_tracking, $wpdb, $current_user;
$table_name = $wpdb->prefix . "tmp_users";
$private_table = $wpdb->prefix . "private_group";
$user_tracking = $wpdb->prefix . "user_tracking";
define('CP_PLUGIN_URL', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)));
require_once( ABSPATH . 'wp-includes/class-phpass.php');
/* * **********************************************************************************
* Hooks to fire when plugin is activated
* ************************************************************************************ */
register_activation_hook(__FILE__, 'ez_private_group');
register_activation_hook(__FILE__, 'ez_user_tracking');
/* * **********************************************************************************
* function for add private group table in database
* ************************************************************************************ */
function ez_private_group() {
global $wpdb, $private_table;
if ($wpdb->get_var("SHOW TABLES LIKE '$private_table'") != $private_table) {
$sql = "CREATE TABLE $private_table (
`ID` int NOT NULL AUTO_INCREMENT,
`user_id` int(40) NOT NULL,
`group_name` varchar(65) NOT NULL default '',
`group_creator` varchar(65) NOT NULL default '',
`Access_code` varchar(60) NOT NULL default '',
`group_members` varchar(1000) NOT NULL default '',
PRIMARY KEY (ID));";
//reference to upgrade.php file
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql);
}
}
/* * **********************************************************************************
* function for add user tracking group table in database
* ************************************************************************************ */
function ez_user_tracking() {
global $wpdb, $user_tracking;
if ($wpdb->get_var("SHOW TABLES LIKE '$user_tracking'") != $user_tracking) {
$sql = "CREATE TABLE $user_tracking (
`ID` int NOT NULL AUTO_INCREMENT,
`user_id` int(40) NOT NULL,
`post_id` varchar(3000) NOT NULL default '',
'timing` varchar(1000) NOT NULL default '',
'Evaluation_answers` varchar(2000) NOT NULL default '',
PRIMARY KEY (ID));";
//reference to upgrade.php file
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($sql);
}
}
/* * **********************************************************************************
* shortcode for sign in a user
* ************************************************************************************ */
add_shortcode('sign_in_user', 'signing1_user');
function signing1_user() {
ob_start();
wp_login_form();
$string = ob_get_contents();
ob_end_clean();
return $string;
}
add_shortcode('create_group', 'ez_create_group');
/* * **********************************************************************************
* function for creating private group
* ************************************************************************************ */
function ez_create_group() {
global $wpdb, $private_table, $current_user;
ob_start();
if (is_user_logged_in()) {
if (isset($_POST['ez-create-members'])) {
$group_name = strip_tags(trim($_POST['ez-group-name']));
$access_code = strip_tags(trim($_POST['ez-access-code']));
$members = $_POST['ez-members'];
$group_message = '';
if ($group_name && $access_code) {
$query = "SELECT COUNT(*) FROM `{$private_table}` WHERE `Access_code`= '{$access_code}'";
$customized_query = $wpdb->get_var($query);
if ($customized_query && intval($customized_query) == 1) {
echo "<div class='error'>This access code already exists.</div>";
} else {
$required_members = array();
if($members){
if (!(is_array($required_members))) {
$required_members = array();
}
$members = explode(",", $members);
foreach ($members as $mem) {
$members_query = $wpdb->get_var("SELECT COUNT(*)`user_email` FROM `{$wpdb->users}` WHERE `user_email`='$mem'");
if ($members_query && intval($members_query) == 1) {
$required_members[] = $mem;
}
}
}
if($_FILES['ez-custom-logo'] && !($_FILES["ez-custom-logo"]["error"] > 0)){
$custom_logo_name = $_FILES['ez-custom-logo']['name'];
$custom_logo_temp = $_FILES['ez-custom-logo']['tmp_name'];
move_uploaded_file($custom_logo_temp, get_template_directory().'/images/'.$custom_logo_name);
}
else{
$custom_logo_name = '';
}
$required_members[]= $current_user->user_email;
$members_insert = array_unique($required_members);
if($members){
$insert_members = implode(',', $members_insert);
$trim_insert_members = trim($insert_members,',');
$deselected_email = array_diff($members, $members_insert);
$converted_email_to_string = implode(',',$deselected_email);
$trim_it = trim($converted_email_to_string,',');
}
else{
$insert_members = implode(' ',$members_insert);
$trim_insert_members = trim($insert_members,',');
$trim_it = '';
}
$result = $wpdb->query($wpdb->prepare("INSERT INTO $private_table(user_id,group_name,group_creator, Access_code, group_members,Custom_logo)VALUES(%d,%s,%s,%s,%s,%s)", $current_user->ID, $group_name, $current_user->user_login, $access_code, $trim_insert_members,$custom_logo_name));
if ($result) {
if($trim_it){
$success_message = "<div class='success'><p>Your group with access code successfully created.
These members->".$trim_it." not included because they are not registered with us</p></div>";
}
else{
$success_message = "<div class='success'><p>Your group with access code successfully created.</p></div>";
}
}
}
} else {
$error_message = "Group name and Access code are required fields";
}
}
if($success_message){
$my_custom_query = $wpdb->get_row("SELECT * FROM `{$private_table}` WHERE `Access_code`= '{$access_code}'");
$remaining_emails = $my_custom_query->group_members;
$explode_it = explode(',',$remaining_emails);
$g_creator = $my_custom_query->group_creator;
$acc_code = $my_custom_query->Access_code;
$message = $g_creator ." has invited you to join a private group on Blaze Seminary.\n";
$message .= "Your access code is ".$acc_code."\n";
foreach($explode_it as $explode){
wp_mail($explode,'Private Group', $message);
}
}
if($error_message){
?>
<div class="error"><?php echo $error_message; ?></div>
<?php
}
if($success_message) { ?>
<?php echo $success_message; ?>
<?php } if (!($success_message)) {
?>
<h1 class="inner_title"> <?php _e("Create Private Group"); ?></h1>
<div class="create_group" class="wp-core-ui">
<form action="<?php echo $_SERVER['REDIRECT_URL']; ?>" method="POST" name="priv-grp" enctype="multipart/form-data">
<p>
<label for="ez-group-name"><?php _e("Group Name"); ?></label>
<input size="70px" type="text" name="ez-group-name" class="ez-group-name" value="<?php echo stripslashes($_POST['ez-group-name']); ?>" />
<span class="ez-gn-subs"><?php _e("(Keep group names simple)"); ?></span>
</p>
<p>
<label for="ez-access-code"><?php _e("Access Code"); ?></label>
<input size="70px" type="text" name="ez-access-code" class="ez-access-code" value="<?php echo $_POST['ez-access-code']; ?>" />
<span class="ez-gn-subs"><?php _e("(use numbers and/or letters)"); ?></span>
</p>
<p>
<label for="ez-members"><?php _e("Members"); ?></label>
<textarea size="50%" name="ez-members" rows="5" ><?php echo $_POST['ez-members']; ?></textarea>
<span class="ez-gn-subs"><?php _e("(Write comma separated list of Registered emails to add into group)"); ?></span>
</p>
<p>
<label for="ez-custom-logo"><?php _e("Custom Logo"); ?></label>
<input size="70px" type="file" name="ez-custom-logo" class="ez-custom-logo" value="" />
<span class="ez-gn-subs"><?php _e("(Dimension of logo should be 204x79)"); ?></span>
</p>
<p>
<input type="submit" name="ez-create-members" value="Create" />
</p>
</form>
</div>
<?php
}
} else {
echo "<div class='ez-logged-in'>You have to be logged in to view this page</div>";
}
$string = ob_get_contents();
ob_end_clean();
return $string;
}
/* * **********************************************************************************
* function for creating menu and submenu pages
* ************************************************************************************ */
function ez_custom_settings() {
add_menu_page(
'Home page', 'Home page', 'manage_options', 'home_page', 'home_page_options_display', '', '59.2'
);
add_submenu_page(
'home_page', 'Logo', 'Logo', 'manage_options', 'home_page', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Banner', 'Banner', 'manage_options', 'home_page_banner_display', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Top Headline', 'Top Headline', 'manage_options', 'home_page_headline_display', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Background Text ', 'Background Text', 'manage_options', 'home_page_background_text', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Follow us', 'Follow us', 'manage_options', 'home_page_follow_us', 'home_page_options_display'
);
add_submenu_page(
'home_page', 'Footer Options', 'Footer Options', 'manage_options', 'home_page_footer_options', 'home_page_options_display'
);
add_menu_page(
'Manage Users', 'Manage Users', 'manage_options', 'user_management', 'user_management_options_display', '', '59.3'
);
add_submenu_page(
'user_management', 'Tracking Progress', 'Tracking Progress', 'manage_options', 'user_management', 'user_management_options_display'
);
add_submenu_page(
'user_management', 'Head Badges', 'Head Badges', 'manage_options', 'user_management_head_badges', 'user_management_options_display'
);
add_submenu_page(
'user_management', 'Tracking Evaluation', 'Tracking Evaluation', 'manage_options', 'user_management_tracking_evaluation', 'user_management_options_display'
);
add_submenu_page(
'user_management', 'Purge Users', 'Purge Users', 'manage_options', 'user_management_purge_users', 'user_management_options_display'
);
add_menu_page(
'Discuss forum', 'Discuss forum', 'manage_options', 'discuss_forum', 'discuss_forum_options_display', '', '59.4'
);
}
add_action('admin_menu', 'ez_custom_settings');
/* * **********************************************************************************
* Callback function for home page
* ************************************************************************************ */
function home_page_options_display() {
?>
<div class="wrap">
<h2 class="standard-title">Home page Options</h2><br>
<?php $active_tab = isset($_GET['page']) ? $_GET['page'] : 'home_page'; ?>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php echo $active_tab == 'home_page' ? 'nav-tab-active' : ''; ?>" href="?page=home_page">Logo</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_banner_display' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_banner_display">Banner</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_headline_display' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_headline_display">Top Headline</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_background_text' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_background_text">Background Text</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_follow_us' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_follow_us">Follow Us</a>
<a class="nav-tab <?php echo $active_tab == 'home_page_footer_options' ? 'nav-tab-active' : ''; ?>" href="?page=home_page_footer_options">Footer Options</a>
</h2>
<div id="message-container"><?php settings_errors(); ?></div>
<?php
if ('home_page' == $active_tab) {
ez_logo_options();
} else if ('home_page_banner_display' == $active_tab) {
ez_banner_display();
} else if ('home_page_headline_display' == $active_tab) {
ez_top_headline();
} else if ('home_page_background_text' == $active_tab) {
ez_background_text();
} else if ('home_page_follow_us' == $active_tab) {
ez_follow_us();
} else if ('home_page_footer_options' == $active_tab) {
ez_footer_options();
}
?>
</div>
<?php
}
/* * **********************************************************************************
* Callback function for User Management
* ************************************************************************************ */
function user_management_options_display() {
?>
<div class="wrap">
<h2 class="standard-title">User Management</h2><br>
<?php $active_tab = isset($_GET['page']) ? $_GET['page'] : 'user_management'; ?>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php echo $active_tab == 'user_management' ? 'nav-tab-active' : ''; ?>" href="?page=user_management">Tracking Progress</a>
<a class="nav-tab <?php echo $active_tab == 'user_management_head_badges' ? 'nav-tab-active' : ''; ?>" href="?page=user_management_head_badges">Head Badges</a>
<a class="nav-tab <?php echo $active_tab == 'user_management_tracking_evaluation' ? 'nav-tab-active' : ''; ?>" href="?page=user_management_tracking_evaluation">Tracking Evaluation</a>
<a class="nav-tab <?php echo $active_tab == 'user_management_purge_users' ? 'nav-tab-active' : ''; ?>" href="?page=user_management_purge_users">Purge Users</a>
</h2>
<div id="message-container"><?php settings_errors(); ?></div>
<?php
if ('user_management' == $active_tab) {
ez_tracking_progress();
} else if ('user_management_head_badges' == $active_tab) {
ez_head_badges();
}
else if ('user_management_tracking_evaluation' == $active_tab) {
ez_tracking_evaluation();
}
else if ('user_management_purge_users' == $active_tab) {
ez_purge_users();
}
?>
</div>
<?php
}
/* * **********************************************************************************
* Callback function for Discussion forum
* ************************************************************************************ */
function discuss_forum_options_display() {
?>
<div class="wrap">
<h2 class="standard-title">Discussion Forum</h2><br>
<?php $active_tab = isset($_GET['page']) ? $_GET['page'] : 'discuss_forum'; ?>
<h2 class="nav-tab-wrapper">
<a class="nav-tab <?php echo $active_tab == 'discuss_forum' ? 'nav-tab-active' : ''; ?>" href="?page=discuss_forum">Private Groups</a>
</h2>
<div id="message-container"><?php settings_errors(); ?></div>
<?php
if ('discuss_forum' == $active_tab) {
ez_private_group_members();
}
?>
</div>
<?php
}
/* * **********************************************************************************
* Callback for site logo
* ************************************************************************************ */
function ez_logo_options() {
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('ez_home_logo', $_POST['ez_home_logo']);
update_option('ez-logo-url', $_POST['ez-logo-url']);
update_option('ez-link-title', $_POST['ez-link-title']);
update_option('ez-target-link', $_POST['ez-target-link']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$ez_home_logo = get_option('ez_home_logo');
$ez_logo_url = get_option('ez-logo-url');
$ez_link_title = get_option('ez-link-title');
$target_link = get_option('ez-target-link');
?>
<div id="ez_header_menu_settings"><br><br>
<form action="" method="POST" >
<div id="ez-header-menu">
<table class="ez-logo">
<tr>
<th><label for="ez_home_logo">Image</label></th>
<td><input size="70px" type="text" name="ez_home_logo" class="ez_home_logo" id="image_src" value="<?php echo $ez_home_logo ?>"/>
<input type="submit" class="button upload_image" name="upload_button" id="logo_uploader_button" value="<?php _e('Select an Image', 'image_widget'); ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<?php
if (!empty($ez_home_logo)) {
echo '<img src="' . $ez_home_logo . '" />';
}
?>
</td>
</tr>
<tr>
<th><label for="ez-logo-url">href:</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_logo_url; ?>" name="ez-logo-url" id="ez-logo-url"/></td>
</tr>
<tr>
<th><label for="ez-link-title">Title :</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_link_title; ?>" name="ez-link-title" id="ez-link-title"/></td>
</tr>
<tr>
<th><label for="ez-target-link">Link Target :</label></th>
<td>
<select name="ez-target-link" id="ez-target-link">
<option value="_new_window" <?php selected($target_link, ' _new_window'); ?>>Open In New Window</option>
<option value="_same_window" <?php selected($target_link, '_same_window'); ?>>Stay In Same Window </option>
</select>
</td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
/* * **********************************************************************************
* Callback for Advertising banners in home page
* ************************************************************************************ */
function ez_banner_display() {
$action = isset($_POST['submit']) ? $_POST['submit'] : '';
$saved = false;
$options = '_banner';
if ($action) {
update_option($options, $_POST[$options]);
$saved = true;
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$$options = get_option($options);
if (!is_array($$options)) {
$$options = array();
}
?>
<form method="post" action="">
<br><br>
<div id="tabs" style="width:95%" >
<ul>
<li><a href="#tab-1">Banner 1</a></li>
<li><a href="#tab-2">Banner 2</a></li>
</ul>
<?php
for ($i = 1; $i <= 2; $i++) {
echo '<div id="tab-' . $i . '" >
<table class="ez-banner-content" >
<tr class="ez_image_src">
<th><label for="ez-image-src' . $i . '"> Image SRC :</label></th>
<td><input size="70px" type="text" name="_banner[ez-image-src' . $i . ']" id="image_src" value="' . $_banner['ez-image-src' . $i . ''] . '" class="ez-image-src' . $i . '" />
<input type="submit" class="button upload_image" name="upload_button" id="uploader_button" value="Select an Image" />
</td>
</tr>
<tr>
<td></td>
<td>
<img src="' . $_banner['ez-image-src' . $i . ''] . '" />
</td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-alt"> Alt Text :</label></th>
<td><input size="70px" type="text" value="' . $_banner['ez-image-src' . $i . '-alt'] . '" name="_banner[ez-image-src' . $i . '-alt]" id="ez-image-src' . $i . '-alt"/></td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-url"> Text URL :</label></th>
<td><input size="70px" type="text" value="' . $_banner['ez-image-src' . $i . '-url'] . '" name="_banner[ez-image-src' . $i . '-url]" id="ez-image-src' . $i . '-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-title-link"> Link Title :</label></th>
<td><input size="70px" type="text" value="' . $_banner['ez-image-src' . $i . '-title-link'] . '" name="_banner[ez-image-src' . $i . '-title-link]" id="ez-image-src' . $i . '-title-link"/></td>
</tr>
<tr>
<th><label for="ez-image-src' . $i . '-link-target"> Link Target:</label></th>
<td>
<select name="_banner[ez-image-src' . $i . '-link-target]" id="ez-image-src' . $i . '-link-target">
<option value="_new_window" ' . selected($_banner['ez-image-src' . $i . '-link-target'], '_new_window', false) . '>Open In New Window</option>
<option value="_same_window" ' . selected($_banner['ez-image-src' . $i . '-link-target'], '_same_window', false) . '>Stay In Same Window</option>
</select>
</td>
</tr>
</table>
</div>
';
}
?>
</div>
<br/>
<br/>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
<?php
}
/* * *********************************************************************************
callback for headline
* ******************************************************************************** */
function ez_top_headline() {
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('ez_top_headline', $_POST['ez_top_headline']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$ez_top_headline = get_option('ez_top_headline');
?>
<div id="ez_headline">
<br>
<br>
<form action="" method="POST" >
<div id="ez-headline-settings">
<table>
<tr>
<th><label for="ez_top_headline">Headline Text :</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_top_headline; ?>" name="ez_top_headline" id="ez_top_headline"/></td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
/* * *********************************************************************************
* callback for background text
* ********************************************************************************** */
function ez_background_text() {
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('ez_back_text1', $_POST['ez_back_text1']);
update_option('ez_back_text2', $_POST['ez_back_text2']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$ez_back_text1 = get_option('ez_back_text1');
$ez_back_text2 = get_option('ez_back_text2');
?>
<div id="ez_headline">
<br>
<br>
<form action="" method="POST" >
<div id="ez-headline-settings">
<table>
<tr>
<th><label for="ez_back_text1">Background Text 1:</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_back_text1; ?>" name="ez_back_text1" id="ez_back_text1"/></td>
</tr>
<tr>
<th><label for="ez_back_text2">Background Text 2:</label></th>
<td><input size="70px" type="text" value="<?php echo $ez_back_text2; ?>" name="ez_back_text2" id="ez_back_text2"/></td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
/* * ***********************************************************************************
callback for follow us
* *************************************************************************************** */
function ez_follow_us() {
$action = isset($_POST['submit']) ? $_POST['submit'] : '';
$saved = false;
$options = '_follow_us';
if ($action) {
update_option($options, $_POST[$options]);
$saved = true;
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$$options = get_option($options);
if (!is_array($$options)) {
$$options = array();
}
?>
<form method="post" action="">
<br><br>
<?php
echo '<div id="social-links" >
<table class="ez-social-links" >
<tr>
<th><label for="ez-image-src1-url"> Google plus URL </label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src1-url'] . '" name="_follow_us[ez-image-src1-url]" id="ez-image-src1-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src2-url"> Facebook URL</label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src2-url'] . '" name="_follow_us[ez-image-src2-url]" id="ez-image-src2-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src3-url"> Twitter URL</label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src3-url'] . '" name="_follow_us[ez-image-src3-url]" id="ez-image-src3-url"/></td>
</tr>
<tr>
<th><label for="ez-image-src4-url"> RSS URL</label></th>
<td><input size="60px" type="text" value="' . $_follow_us['ez-image-src4-url'] . '" name="_follow_us[ez-image-src4-url]" id="ez-image-src4-url"/></td>
</tr>
</table>
</div>
';
?>
<br/>
<br/>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
<?php
}
/* * ***********************************************************************************
callback for choosing head badges
* *********************************************************************************** */
function ez_head_badges() {
$action = isset($_POST['submit']) ? $_POST['submit'] : '';
$saved = false;
$options = '_head_badges';
$options2 = '_head_badges_title';
$options3 = '_head_badges_link';
if ($action) {
update_option($options, $_POST[$options]);
update_option($options2, $_POST[$options2]);
update_option($options3, $_POST[$options3]);
$saved = true;
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$$options = get_option($options);
$$options2 = get_option($options2);
$$options3 = get_option($options3);
if (!is_array($$options)) {
$$options = array();
}
if (!is_array($$options2)) {
$$options2 = array();
}
if (!is_array($$options3)) {
$$options3 = array();
}
?>
<form method="post" action="" class="badge_form">
<?php
wp_reset_query();
$args = array(
'post_type' => 'classes',
'posts_per_page' => -1,
'post_status' => 'publish',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'Class-type',
'field' => 'slug',
'terms' => 'sample',
'operator' => 'NOT IN'
)
)
);
$count = 1;
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
global $post;
$post_id = get_the_ID();
?>
<table class="classes_badge">
<tr>
<th width="200px"><label for="<?php echo $post_id; ?>" ><?php the_title(); ?></label></th>
<td>
<input type="text" size="60px" name="_head_badges[<?php echo $post_id; ?>]" class="<?php echo $post_id; ?>" id="image_src" value="<?php echo $_head_badges[$post_id]; ?>"/>
<input type="button" class="button upload_image" name="upload_button" id="uploader_button" value="<?php _e('Select an Image', 'image_widget'); ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<img src="<?php echo $_head_badges[$post_id]; ?>" />
</td>
</tr>
<tr>
<th width="200px"><label for="<?php echo $post_id; ?>" >Badge title</label></th>
<td>
<input type="text" size="60px" name="_head_badges_title[<?php echo $post_id; ?>]" class="_head_badges_link" value="<?php echo $_head_badges_title[$post_id]; ?>"/>
</td>
</tr>
<tr>
<th width="200px"><label for="<?php echo $post_id; ?>" >Badge URL</label></th>
<td>
<input type="text" size="60px" name="_head_badges_link[<?php echo $post_id; ?>]" class="_head_badges_link" value="<?php echo $_head_badges_link[$post_id]; ?>"/>
</td>
</tr>
</table>
<?php
}
}
?>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
<?php
}
/* * **********************************************************************************
* action for registering metaboxes
* *********************************************************************************** */
add_action('add_meta_boxes', 'ez_custom_profile_metaboxes');
/* * **********************************************************************************
* function for adding metabox
* ************************************************************************************ */
function ez_custom_profile_metaboxes() {
global $post;
$page_template = get_post_meta($post->ID, '_wp_page_template', true);
add_meta_box('ez_lesson_metaboxes', 'Custom fields', 'ez_lesson_metaboxes', 'classes', 'normal', 'high');
add_meta_box('ez_classes_dropdown', 'Custom fields', 'ez_classes_dropdown', 'lessons', 'normal', 'high');
if ($page_template == 'page-templates/about.php') {
add_meta_box('ez_about_banner', 'About', 'ez_about_banner', 'page', 'normal', 'high');
}
if($page_template == 'page-templates/template-classes.php'){
add_meta_box('ez_custom_title', 'Custom title', 'ez_custom_title', 'page', 'normal', 'high');
}
}
/* * **********************************************************************************
* function for adding metabox in classes post type
* ************************************************************************************ */
function ez_lesson_metaboxes() {
global $post, $wpdb;
$count = $count2 = $count3 = 1;
$lesson_checkbox = $mentor_checkbox = $headline_checkbox = array();
$lesson_checkbox = get_post_meta($post->ID, 'lesson_checkbox', true);
$mentor_checkbox = get_post_meta($post->ID, 'mentor_checkbox', true);
$headline_checkbox = get_post_meta($post->ID, 'headline_checkbox', true);
$sample_vimeo = get_post_meta($post->ID, 'sample_vimeo', true);
if (!(is_array($lesson_checkbox))) {
$lesson_checkbox = array();
}
if (!(is_array($mentor_checkbox))) {
$mentor_checkbox = array();
}
if (!(is_array($headline_checkbox))) {
$headline_checkbox = array();
}
wp_nonce_field(basename(__FILE__), 'ez_checkbox_noncename_lesson_metaboxes');
$custom_query = $wpdb->get_results("SELECT `ID`,`user_login` FROM `{$wpdb->users}`");
$args = array('post_type' => 'lessons', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC');
$args2 = array('post_type' => 'headline', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC');
$query = new WP_Query($args);
$query2 = new WP_Query($args2);
?>
<table class="widefat">
<tr>
<th><label for="sample_vimeo" >Sample Class Vimeo Link</label></th>
<td>
<input type="text" size="40px" name="sample_vimeo" class="sample_vimeo" value="<?php echo $sample_vimeo; ?>"/>
</td>
</tr>
<tr><td colspan="2">(If you are making a sample class you don't have to fill below fields. )</td></tr>
<tr>
<th class="associate-lessons">Select lessons</th>
</tr>
<tr>
<td class="lesson-td-left">
<div class="lesson_check" style="overflow:auto; width: 330px; height: 205px;margin-top: 20px;">
<?php
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
if (in_array(get_the_ID(), $lesson_checkbox)) {
$checked = 'checked';
} else {
$checked = '';
}
?>
<span class="lesson-details" style="float:left; width:100%" >
<input type="checkbox" id="lessons_checkbox_<?php echo $count; ?>" name="lesson_checkbox[]" <?php echo $checked; ?> value="<?php the_id(); ?>"/>
<label for="lessons_checkbox_<?php echo $count; ?>"><?php the_title(); ?></label><br>
</span>
<?php
$count++;
}
}
?>
</div>
</td>
</tr>
<tr>
<th class="associate-headline">Select sparks</th>
</tr>
<tr>
<td class="headline-td-left">
<div class="headline_check" style="overflow:auto; width: 330px; height: 205px;margin-top: 20px;">
<?php
if ($query2->have_posts()) {
while ($query2->have_posts()) {
$query2->the_post();
if (in_array(get_the_ID(), $headline_checkbox)) {
$checked = 'checked';
} else {
$checked = '';
}
?>
<span class="headline-details" style="float:left; width:100%" >
<input type="checkbox" id="headline_checkbox_<?php echo $count3; ?>" name="headline_checkbox[]" <?php echo $checked; ?> value="<?php the_id(); ?>"/>
<label for="headline_checkbox_<?php echo $count3; ?>"><?php the_title(); ?></label><br>
</span>
<?php
$count3++;
}
}
?>
</div>
</td>
</tr>
<tr>
<th class="associate-mentors">Select Mentors</th>
</tr>
<tr>
<td class="mentor-td-left">
<div class="mentor_check" style="overflow:auto; width: 330px; height: 205px;margin-top: 20px;">
<?php
foreach ($custom_query as $custom_q) {
if (in_array($custom_q->ID, $mentor_checkbox)) {
$checked = 'checked';
} else {
$checked = '';
}
?>
<span class="mentor-details" style="float:left; width:100%" >
<input type="checkbox" id="mentors_checkbox_<?php echo $count2; ?>" name="mentor_checkbox[]" <?php echo $checked; ?> value="<?php echo $custom_q->ID; ?>"/>
<label for="mentors_checkbox_<?php echo $count2; ?>"><?php echo $custom_q->user_login; ?></label><br>
</span>
<?php
$count2++;
}
?>
</div>
</td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_lesson_metaboxes', 1, 1);
function ez_save_lesson_metaboxes($post_id) {
if (!wp_verify_nonce(@$_POST['ez_checkbox_noncename_lesson_metaboxes'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, 'lesson_checkbox', $_POST['lesson_checkbox']);
update_post_meta($post_id, 'mentor_checkbox', $_POST['mentor_checkbox']);
update_post_meta($post_id, 'sample_vimeo', $_POST['sample_vimeo']);
update_post_meta($post_id, 'headline_checkbox', $_POST['headline_checkbox']);
}
/* * **********************************************************************************
* function for adding metabox in class template page
* ************************************************************************************ */
function ez_custom_title() {
global $post;
$_sample_course_title = $_course_title = '';
$_sample_course_title = get_post_meta($post->ID, '_sample_course_title', true);
$_course_title = get_post_meta($post->ID, '_course_title', true);
wp_nonce_field(basename(__FILE__), 'ez_noncename_custom_title');
?>
<table class="widefat">
<tr>
<th><label for="_sample_course_title" >Sample Course title(for non-logged in user)</label></th>
<td>
<input type="text" size="56px" name="_sample_course_title" class="_sample_course_title" id="_sample_course_title" value="<?php echo $_sample_course_title; ?>"/>
</td>
</tr>
<tr>
<th><label for="_course_title" >Course title(for logged in user)</label></th>
<td>
<input type="text" size="56px" name="_course_title" class="_course_title" id="_course_title" value="<?php echo $_course_title; ?>"/>
</td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_custom_title', 1, 1);
/* * **********************************************************************************
* function for saving data in classes post type
* ************************************************************************************ */
function ez_save_custom_title($post_id) {
if (!wp_verify_nonce(@$_POST['ez_noncename_custom_title'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, '_sample_course_title', $_POST['_sample_course_title']);
update_post_meta($post_id, '_course_title', $_POST['_course_title']);
}
/* * **********************************************************************************
* function for adding metabox in about page
* ************************************************************************************ */
function ez_about_banner() {
global $post;
$about_banner = $banner_url = '';
$about_banner = get_post_meta($post->ID, '_about_banner', true);
$about_banner_url = get_post_meta($post->ID, '_about_banner_url', true);
wp_nonce_field(basename(__FILE__), 'ez_checkbox_noncename_about_banner');
?>
<table class="widefat">
<tr>
<th><label for="_about_banner" >Banner img</label></th>
<td>
<input type="text" size="56px" name="_about_banner" class="_about_banner" id="image_src" value="<?php echo $about_banner; ?>"/>
<input type="button" class="button upload_image" name="upload_button" id="uploader_button" value="<?php _e('Select an Image', 'image_widget'); ?>" />
</td>
</tr>
<tr>
<td></td>
<td>
<?php if (!empty($about_banner)) {
?>
<img width="266px" height="184px" src="<?php echo $about_banner; ?>" />
<?php } ?>
</td>
</tr>
<tr>
<th><label for="_about_banner_url" >Banner URL</label></th>
<td>
<input type="text" size="56px" name="_about_banner_url" class="_about_banner_url" id="_about_banner_url" value="<?php echo $about_banner_url; ?>"/>
</td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_about_banner', 1, 1);
/* * **********************************************************************************
* function for saving data in classes post type
* ************************************************************************************ */
function ez_save_about_banner($post_id) {
if (!wp_verify_nonce(@$_POST['ez_checkbox_noncename_about_banner'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, '_about_banner', $_POST['_about_banner']);
update_post_meta($post_id, '_about_banner_url', $_POST['_about_banner_url']);
}
/* * **********************************************************************************
* function for adding metabox in lesson post type
* ************************************************************************************ */
function ez_classes_dropdown() {
global $post, $wpdb;
$count = 1;
$pdf_guide = $written_transcript = $pdf_content = $subtitle = '';
$pdf_guide = get_post_meta($post->ID, '_pdf_guide', true);
$pdf_content = get_post_meta($post->ID, '_pdf_content', true);
$written_transcript = get_post_meta($post->ID, '_written_transcript', true);
$subtitle = get_post_meta($post->ID, '_sub_title', true);
wp_nonce_field(basename(__FILE__), 'ez_classes_noncename_assigned_classes');
?>
<table class="widefat">
<tr>
<th><label for="_pdf_guide">pdf study guide</label></th>
<td><input size="70px" type="text" value="<?php echo $pdf_guide; ?>" name="_pdf_guide" id="_pdf_guide"/></td>
</tr>
<tr>
<th><label for="_pdf_content">pdf content</label></th>
<td> <?php wp_editor(stripslashes($pdf_content), '_pdf_content', array('textarea_name' => '_pdf_content', 'textarea_rows' => 4, 'textarea_columns' => 10)); ?></td>
</tr>
<tr>
<th><label for="_written_transcript">Written Transcript</label></th>
<td> <?php wp_editor(stripslashes($written_transcript), '_written_transcript', array('textarea_name' => '_written_transcript', 'textarea_rows' => 4, 'textarea_columns' => 10)); ?></td>
</tr>
<tr>
<th><label for="_sub_title">Subtitle</label></th>
<td><input size="70px" type="text" value="<?php echo $subtitle; ?>" name="_sub_title" id="_sub_title"/></td>
</tr>
</table>
<?php
}
add_action('save_post', 'ez_save_classes_dropdown', 1, 1);
/* * **********************************************************************************
* function for save metabox in lesson post type
* ************************************************************************************ */
function ez_save_classes_dropdown($post_id) {
if (!wp_verify_nonce(@$_POST['ez_classes_noncename_assigned_classes'], basename(__FILE__)))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
update_post_meta($post_id, '_pdf_guide', $_POST['_pdf_guide']);
update_post_meta($post_id, '_pdf_content', $_POST['_pdf_content']);
update_post_meta($post_id, '_written_transcript', $_POST['_written_transcript']);
update_post_meta($post_id, '_sub_title', $_POST['_sub_title']);
}
/* * **********************************************************************************
* Shortcode for private group
* ************************************************************************************ */
add_shortcode('private_group', 'custom_manage_group');
/* * **********************************************************************************
* function for add shortcode
* ************************************************************************************ */
function custom_manage_group() {
global $wpdb, $current_user,$private_table;
ob_start();
if(!($_SESSION['access_code'] == '')){
$query = $wpdb->get_row("SELECT * FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
}
if(isset($_POST['ez-manage-members'])){
$email_to_join = $_POST['ez-email-addresses'];
$query_email = explode(",",$query->group_members);
$address = array();
$address = $_POST['email_address'];
if($_FILES['ez-custom-logo'] && !($_FILES["ez-custom-logo"]["error"] > 0)){
$custom_logo_name = $_FILES['ez-custom-logo']['name'];
$custom_logo_temp = $_FILES['ez-custom-logo']['tmp_name'];
move_uploaded_file($custom_logo_temp, get_template_directory().'/images/'.$custom_logo_name);
}
else{
$custom_logo_name = '';
}
if($custom_logo_name != ''){
$logoquery = $wpdb->query("UPDATE `{$private_table}` SET `Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
if($address){
$unique = array_diff($query_email, $address);
$join_array = implode(',',$unique);
if($custom_logo_name != ''){
$query_row = $wpdb->query("UPDATE `{$private_table}` SET `group_members`='{$join_array}',`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$query_row = $wpdb->query("UPDATE `{$private_table}` SET `group_members`='{$join_array}' WHERE `Access_code`='{$query->Access_code}'");
}
}
if($email_to_join){
$members = explode(",", $email_to_join);
$required_members = array();
if (!(is_array($required_members))) {
$required_members = array();
}
if((count($members)) == 1){
$members_query = $wpdb->get_var("SELECT COUNT(*)`user_email` FROM `{$wpdb->users}` WHERE `user_email`='$members[0]'");
if ($members_query && (intval($members_query) == 1)) {
$required_members[] = $members[0];
}
}
else{
foreach ($members as $mem) {
$members_query = $wpdb->get_var("SELECT COUNT(*)`user_email` FROM `{$wpdb->users}` WHERE `user_email`='$mem'");
if ($members_query && (intval($members_query) == 1)) {
$required_members[] = $mem;
}
}
}
$members_insert = array_unique($required_members);
$deselected_members = array_diff($members,$members_insert);
$convert_to_string = implode(',',$deselected_members);
$trim_that_str = trim($convert_to_string,',');
if($trim_that_str){
echo "<div class='success'>Your changes saved successfully.These members->".$trim_that_str." are not added because they are not registered with us</div>";
}
else{
echo "<div class='success'>Your changes saved successfully.</div>";
}
$insert_members = implode(',', $members_insert);
$query_to_check = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$query->Access_code}'");
$mquery = $query_to_check->group_members;
$vquery = explode(",",$mquery);
if($vquery[0] == ''){
if($custom_logo_name != ''){
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$insert_members}',`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$insert_members}' WHERE `Access_code`='{$query->Access_code}'");
}
}
else{
if($custom_logo_name != ''){
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= CONCAT(`group_members`,',{$insert_members}'),`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$i_query = $wpdb->query("UPDATE `{$private_table}` SET `group_members`= CONCAT(`group_members`,',{$insert_members}') WHERE `Access_code`='{$query->Access_code}'");
}
}
if($i_query){
$customized_query = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$query->Access_code}'");
if($customized_query){
$var_query = $customized_query->group_members;
$custom_var_query = explode(",",$var_query);
if($custom_var_query[0] == ''){
if($custom_logo_name != ''){
$wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$custom_var_query[1]}',`Custom_logo`='$custom_logo_name' WHERE `Access_code`='{$query->Access_code}'");
}
else{
$wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$custom_var_query[1]}' WHERE `Access_code`='{$query->Access_code}'");
}
}
}
}
}
}
$update_query = $wpdb->get_row("SELECT `group_members` FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
$gm = $update_query->group_members;
$exploding = explode(',', $gm);
$uniqueness = array_unique($exploding);
$ready_to_join = implode(',', $uniqueness);
$remove_comma = trim($ready_to_join, ",");
if($ready_to_join){
$wpdb->query("UPDATE `{$private_table}` SET `group_members`= '{$remove_comma}' WHERE `Access_code`='{$query->Access_code}'");
}
$post_query = $wpdb->get_row("SELECT * FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
if($query && $post_query){
if($_POST){
$early_members = explode(',', $query->group_members);
$added_members = explode(',', $post_query->group_members);
$unified = array_diff($added_members,$early_members);
$g_creator = $post_query->group_creator;
$acc_code = $post_query->Access_code;
$message = $g_creator ." has invited you to join a private group on Blaze Seminary.\n";
$message .= "Your access code is ".$acc_code."\n";
foreach($unified as $uni){
wp_mail($uni,'Private Group', $message);
}
}
}
$custom_logo = '';
$custom_logo_query = $wpdb->get_row("SELECT `Custom_logo` FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
if($custom_logo_query->Custom_logo != ''){
$custom_logo = $custom_logo_query->Custom_logo;
}
else{
$custom_logo = '';
}
if (is_user_logged_in() && $query->group_creator == $current_user->user_login && !isset($_POST)) {
?>
<h1 class="inner_title"><?php _e('Manage Private Group'); ?></h1>
<div class="manage-priv-group" class="wp-core-ui">
<form action="<?php echo $_SERVER['REDIRECT_URL']; ?>" method="POST" name="priv-grp" enctype="multipart/form-data">
<table class="widefat">
<tr>
<th width="200px" ><?php _e('Group Name'); ?></th>
<td><?php echo $query->group_name; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Access Code'); ?></th>
<td><?php echo $query->Access_code; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Check the Members you want to delete from this group'); ?></th>
<td>
<?php
$email_address = explode(",",$query->group_members);
if($email_address[0] != ''){
foreach($email_address as $email){
?>
<input type="checkbox" name="email_address[]" <?php checked($address, $email ); ?> value="<?php echo $email; ?>"/> <?php echo $email; ?><br><br>
<?php
}
}
?>
</tr>
<tr>
<th width="200px"><?php _e("Enter email addresses separated by commas <br>to add new members to the group"); ?></th>
<td><textarea rows="10" name="ez-email-addresses"></textarea></td>
</tr>
<tr>
<th width="200px" ><?php _e('Custom Logo'); ?></th>
<td><input size="70px" type="file" name="ez-custom-logo" class="ez-custom-logo" value="" />
<span class="ez-gn-subs"><?php _e("(Dimension of logo should be 204x79)"); ?></span></td>
</tr>
<tr>
<th width="200px" ><?php _e('Logo Image'); ?></th>
<?php if($custom_logo == '') {?>
<td><img src="<?php echo get_bloginfo('stylesheet_directory').'/images/logo.gif'; ?>"</td>
<?php } else{ ?>
<td><img src="<?php echo get_bloginfo('stylesheet_directory').'/images/'.$custom_logo; ?>"</td>
<?php } ?>
</tr>
</table>
<p>
<input type="submit" name="ez-manage-members" value="Save Changes" />
</p>
</form>
</div>
<?php
}
elseif(isset($_POST)){
?>
<h1 class="inner_title"><?php _e('Manage Private Group'); ?></h1>
<div class="manage-priv-group" class="wp-core-ui">
<form action="<?php echo $_SERVER['REDIRECT_URL']; ?>" method="POST" name="priv-grp" enctype="multipart/form-data">
<table class="widefat">
<tr>
<th width="200px" ><?php _e('Group Name'); ?></th>
<td><?php echo $query->group_name; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Access Code'); ?></th>
<td><?php echo $query->Access_code; ?></td>
</tr>
<tr>
<th width="200px" ><?php _e('Check the Members you want to delete from this group'); ?></th>
<td>
<?php
$email_address = explode(",",$post_query->group_members);
if($email_address[0] != ''){
foreach($email_address as $email){
?>
<input type="checkbox" name="email_address[]" <?php checked($address, $email ); ?> value="<?php echo $email; ?>"/> <?php echo $email; ?><br><br>
<?php
}
}
?>
</tr>
<tr>
<th width="200px"><?php _e("Enter email addresses separated by commas <br>to add new members to the group"); ?></th>
<td><textarea rows="10" name="ez-email-addresses"></textarea></td>
</tr>
<tr>
<th width="200px" ><?php _e('Custom Logo'); ?></th>
<td><input size="70px" type="file" name="ez-custom-logo" class="ez-custom-logo" value="" />
<span class="ez-gn-subs"><?php _e("(Dimension of logo should be 204x79)"); ?></span></td>
</tr>
<tr>
<th width="200px" ><?php _e('Logo Image'); ?></th>
<?php if($custom_logo == '') {?>
<td><img width="204" height="79" src="<?php echo get_bloginfo('stylesheet_directory').'/images/logo.gif'; ?>"</td>
<?php } else{ ?>
<td><img width="204" height="79" src="<?php echo get_bloginfo('stylesheet_directory').'/images/'.$custom_logo; ?>"</td>
<?php } ?>
</tr>
</table>
<p>
<input type="submit" name="ez-manage-members" value="Save Changes" />
</p>
</form>
</div>
<?php
}
else {
echo "<div class='inner_title'><h1>Only Group Creator Can view this page</h1>";
}
$string = ob_get_contents();
ob_end_clean();
return $string;
}
/* * *********************************************************************************
callback for tracking progress
* ******************************************************************************** */
function ez_tracking_progress() {
global $wpdb, $user_tracking;
$page = isset( $_GET['tpage'] ) ? abs( (int) $_GET['tpage'] ) : 1;
$items_per_page = 20;
$offset = ( $page * $items_per_page ) - $items_per_page;
$total = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->users}` WHERE `user_login`!='admin' ");
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin' LIMIT $offset, $items_per_page");
if($user_query){
$meta_value = get_option('_head_badges');
}
if($_GET['tpage'] > 1){
$count = (($_GET['tpage'] - 1)* $items_per_page) + 1;
}
else{
$count = 1;
}
?>
<br><br>
<form method="post" action="">
Search Username: <input type="text" id="custom_user" name="custom_user" value="<?php echo $cus_user; ?>"/>
<input type="submit" name="all_users" value="All Users" class="button button-primary" style="float:right">
</form>
<table class="tracking_prog" border="1" cellspacing="5">
<br><br>
<thead>
<tr>
<th width="10%" height="40px">S No.</th>
<th width="30%" style="text-align:center">User Name</th>
<th style="text-align:center">Completed</th>
</tr>
</thead>
<?php
if ($user_query) {
foreach ($user_query as $user_q) {
$custom_query = $wpdb->get_results("SELECT `post_id` FROM `{$user_tracking}` WHERE `user_id`= $user_q->ID ORDER BY `post_id` ASC");
?>
<tr>
<td width="10%" style="text-align:center"><?php echo $count . ')'; ?></td>
<td width="30%" style="text-align:center" ><?php echo $user_q->user_login; ?></td>
<td><?php
foreach($meta_value as $key => $value){
foreach($custom_query as $cus_q){
if($key == $cus_q->post_id){
$title = get_the_title($cus_q->post_id);
echo "<div class='badges_images' style='float:left;'><h4>$title</h4><span class='class-img'><img src=".$value."></span></div>";
}
}
}
?>
</td>
<?php
$count++;
?>
</tr>
<?php
}
}
?>
</table>
<div class="admin_pagination">
<?php
echo paginate_links( array(
'base' => add_query_arg( 'tpage', '%#%' ),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => ceil($total / $items_per_page),
'current' => $page
));
?>
</div>
<?php
}
/* * *********************************************************************************
callback for private group
* ******************************************************************************** */
function ez_private_group_members() {
global $wpdb, $private_table;
if(isset($_POST['submit'])){
$sorted_group = $_POST['sorted_group'];
$sort_submit = $_POST['sort_submit'];
if($sorted_group && $sort_submit){
$group_query = $wpdb->get_results("SELECT * FROM `{$private_table}` ORDER BY `$sorted_group` $sort_submit");
}
else{
$group_query = $wpdb->get_results("SELECT * FROM `{$private_table}`");
}
}
else{
$group_query = $wpdb->get_results("SELECT * FROM `{$private_table}`");
}
$count = 1;
?>
<br><br>
<form method="post" action="">
SORT <select name="sorted_group">
<option value="">Select</option>
<option value="group_creator" <?php if($sorted_group == 'group_creator'){ echo 'selected=selected';}?>>Group Creator</option>
<option value="group_name" <?php if($sorted_group == 'group_name'){ echo 'selected=selected';}?>>Group Name</option>
</select>
ORDER BY <select name="sort_submit">
<option value="">Select</option>
<option value="ASC" <?php if($sort_submit == 'ASC'){ echo 'selected=selected';}?>>ASC</option>
<option value="DESC" <?php if($sort_submit == 'DESC'){ echo 'selected=selected';}?>>DESC</option>
</select>
<input type="submit" value="Search" class="button button-primary" id="submit" name="submit">
</form>
<table class="priv_grp_mem" border="1" cellspacing="5">
<thead>
<tr>
<th width="5%" height="46px">S No.</th>
<th width="10%" style="text-align:center" >Group Creator</th>
<th width="20%" style="text-align:center">Group Name</th>
<th width="20%" style="text-align:center">Access code</th>
<th width="30%" style="text-align:center">Members</th>
<th width="10%" style="text-align:center">Add/delete</th>
</tr>
</thead>
<?php
if ($group_query) {
foreach ($group_query as $group_q) {
?>
<tr class="custom-<?php echo $count; ?>">
<td style="text-align:center"><?php echo $count . ')'; ?></td>
<td style="text-align:center"><?php echo $group_q->group_creator; ?></td>
<td width="20%" style="text-align:center" ><?php echo $group_q->group_name; ?></td>
<td width="20%" style="text-align:center" ><?php echo $group_q->Access_code; ?></td>
<td width="30%" style="text-align:center;">
<textarea id="group_members" readonly><?php echo $group_q->group_members; ?></textarea>
</td>
<td width="10%" style="text-align:center"><a class="edit_group_mem">Edit|</a><a rel="<?php echo $count; ?>" class="delete_group">delete</a><a class="submit_group" style="display:none" >Save</a></td>
</tr>
<?php
$count++;
}
}
?>
</table>
<?php
}
add_shortcode("signed_home", "signed_in_sidebar");
function signed_in_sidebar(){
ob_start();
global $current_user,$wpdb,$private_table;
if($_SESSION['access_code']){
$query = $wpdb->get_row("SELECT `group_creator` FROM `{$private_table}` WHERE `Access_code`='{$_SESSION['access_code']}'");
if($query && $current_user->user_login == $query->group_creator){ ?>
<div class="ez-register-link">
<a class="create_grp" href="<?php echo home_url().'/manage-group/';?>"><?php _e("Manage Private Study Group"); ?></a>
</div>
<?php
}
else{
?>
<div class="ez-register-link">
<a class="create_grp" href="<?php echo home_url().'/group/';?>"><?php _e("Create Private Study Group"); ?></a>
</div>
<?php
}
}
else{
?>
<div class="ez-register-link">
<a class="create_grp" href="<?php echo home_url().'/group/';?>" ><?php _e("Create Private Study Group"); ?></a>
</div>
<?php
}
$string = ob_get_contents();
ob_end_clean();
return $string;
}
add_shortcode("custom_user", "custom_dynamic_classes");
function custom_dynamic_classes(){
global $current_user,$wpdb,$user_tracking,$post;
ob_start();
?>
<span>Welcome <?php echo $current_user->user_login; ?></span>
<div class="class_badges">
<div class="image_container">
<?php $query = $wpdb->get_results("SELECT `post_id` FROM `{$user_tracking}` WHERE `user_id`= $current_user->ID ORDER BY `post_id` ASC");
if($query){
$meta_value = get_option('_head_badges');
$_head_badges_title = get_option('_head_badges_title');
$_head_badges_link = get_option('_head_badges_link');
foreach($query as $que){
foreach($_head_badges_title as $head => $tit){
if($head == $que->post_id){
$head_title = $tit;
}
}
foreach($_head_badges_link as $he => $bad){
if($he == $que->post_id){
$head_bd_link = $bad;
}
}
foreach($meta_value as $key => $value){
if($key == $que->post_id){
$title = get_the_title( $que->post_id);
?>
<div class="badges_images" style="float:left;"><h4><?php echo $title; ?></h4><span class="class-img" ><a href="<?php echo $head_bd_link; ?>" target="_blank" title="<?php echo $head_title; ?>" ><img src="<?php echo $value; ?>"/></a></span></div>
<?php
}
}
}
}
?>
</div>
</div>
<?php
$string = ob_get_contents();
ob_end_clean();
return $string;
}
add_shortcode("custom_register", 'register_extra');
function register_extra(){
ob_start();
wp_register();
$string = ob_get_contents();
ob_end_clean();
return $string;
}
function ez_tracking_evaluation(){
global $wpdb, $user_tracking;
$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
$items_per_page = 20;
$offset = ( $page * $items_per_page ) - $items_per_page;
$new_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin' LIMIT $offset, $items_per_page");
$total = $wpdb->get_var("SELECT COUNT(*) FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
?>
<br><br>
<form method="post" action="">
Search Username: <input type="text" name="custom_user" value="<?php echo $cus_user; ?>"/>
<input type="submit" value="All Users" class="button button-primary" id="submit" name="tracking_evaluation" style="float:right">
</form>
<br><br>
<div class="accordion_outer">
<div class="accordion">
<?php
foreach ($new_query as $user_q){
?>
<h3><?php echo $user_q->user_login; ?></h3>
<?php
$customization_query = $wpdb->get_results("SELECT `post_id` FROM `{$user_tracking}` WHERE `user_id`= $user_q->ID ORDER BY `post_id` ASC");
?>
<div>
<p>
<?php if(!$customization_query){?>
<div class="no-class">
<?php _e("This User not Evaluated any Class");?>
</div>
<?php } ?>
<div class="accordion">
<?php
foreach ($customization_query as $custom_q) {
$evaluation_content = $wpdb->get_row("SELECT `Evaluation_answers` FROM `{$user_tracking}` WHERE `user_id`= $user_q->ID AND `post_id`= $custom_q->post_id");
$evaluaton_con = explode('||',$evaluation_content->Evaluation_answers);
?>
<h3><?php echo get_the_title($custom_q->post_id);?></h3>
<div>
<ul>
<li>1) What was the general themes of this course?</li>
<span> Ans: <?php echo $evaluaton_con[0]; ?></span>
<li>2) What were the major thought or conscience difficulties that the Holy Spirit brought to your attention through this course?</li>
<span>Ans: <?php echo $evaluaton_con[1]; ?></span>
<li>3) How can what you learned through this course be useful for today’s Kingdom work?</li>
<span>Ans: <?php echo $evaluaton_con[2]; ?></span>
</ul>
</div>
<?php
}
$eval_learned = get_user_meta($user_q->ID, 'eval_learned',true);
$util_learned = get_user_meta($user_q->ID, 'util_learned', true);
if($eval_learned && $util_learned ){
?>
<h3><?php _e('Graduation Evaluation');?></h3>
<div>
<ul>
<li>1. What have you learned?</li>
<span> Ans: <?php echo $eval_learned; ?></span>
<li>2. How will you use what you have learned?</li>
<span>Ans: <?php echo $util_learned; ?></span>
</ul>
</div>
<?php
}
?>
</div>
</p>
</div>
<?php
}
?>
</div>
</div>
<div class="admin_pagination">
<?php
echo paginate_links( array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',
'prev_text' => __('«'),
'next_text' => __('»'),
'total' => ceil($total / $items_per_page),
'current' => $page
));
?>
</div>
<?php
}
function ez_purge_users(){
global $wpdb,$private_table;
$count = 1;
if(isset($_POST['submit'])){
$sorted_group = $_POST['sorted_group'];
$sort_submit = $_POST['sort_submit'];
if($sorted_group == 'last_login' && $sort_submit){
$user_query = $wpdb->get_results("SELECT *
FROM `{$wpdb->users}` AS U, `{$wpdb->usermeta}` AS M
WHERE M.META_KEY = '_LAST_LOGIN'
AND U.user_login!='admin' AND M.USER_ID = U.ID
ORDER BY M.META_VALUE $sort_submit");
}
else if($sorted_group == 'to_be_deleted' && $sort_submit){
$user_query = $wpdb->get_results("SELECT *
FROM `{$wpdb->users}` AS U, `{$wpdb->usermeta}` AS M
WHERE M.META_KEY = 'deleted_date'
AND U.user_login!='admin' AND M.USER_ID = U.ID
ORDER BY M.META_VALUE $sort_submit");
}
else{
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
}
}
else{
$user_query = $wpdb->get_results("SELECT * FROM `{$wpdb->users}` WHERE `user_login`!='admin'");
}
?>
<br><br>
<form method="post" action="">
SORT <select name="sorted_group">
<option value="">Select</option>
<option value="last_login" <?php if($sorted_group == 'last_login'){ echo 'selected=selected';}?>>Last Login</option>
<option value="to_be_deleted" <?php if($sorted_group == 'to_be_deleted'){ echo 'selected=selected';}?>>To-be-deleted</option>
</select>
ORDER BY <select name="sort_submit">
<option value="">Select</option>
<option value="ASC" <?php if($sort_submit == 'ASC'){ echo 'selected=selected';}?>>ASC</option>
<option value="DESC" <?php if($sort_submit == 'DESC'){ echo 'selected=selected';}?>>DESC</option>
</select>
<input type="submit" value="Search" class="button button-primary" id="submit" name="submit">
</form>
<table class="ez_purge_users" border="1" cellspacing="5">
<thead>
<tr>
<th width="5%" height="46px">S.No.</th>
<th width="10%" style="text-align:center">Username</th>
<th width="20%" style="text-align:center">Email Address</th>
<th width="20%" style="text-align:center">Private Groups</th>
<th width="15%" style="text-align:center">Last Login</th>
<th width="15%" style="text-align:center">To-be-deleted</th>
</tr>
</thead>
<?php
if ($user_query) {
foreach ($user_query as $user_q) {
$last_login = get_user_meta($user_q->ID, '_last_login', true);
$t = '-';
$no_days = '-';
$deleted_date = '-';
if($last_login){
$t = gmdate("m-d-y",(int)$last_login);
$now = time();
$your_date = $last_login;
if($your_date){
$datediff = $now - $your_date;
$no_days = floor($datediff/(60*60*24));
if($no_days >= 90){
$find_date = strtotime("+104 day", $your_date);
$deleted_date = gmdate("m-d-y", (int)$find_date);
$save_deleted_date = update_user_meta($user_q->ID, 'deleted_date',$deleted_date);
}
}
}
$get_group = $wpdb->get_results("SELECT `group_name` FROM `{$private_table}` WHERE `group_members` LIKE '%$user_q->user_email%'",ARRAY_A);
?>
<tr class="custom-<?php echo $count; ?>">
<td style="text-align:center"><?php echo $count . ')'; ?></td>
<td style="text-align:center"><?php echo $user_q->user_login; ?></td>
<td width="20%" style="text-align:center" ><?php echo $user_q->user_email; ?></td>
<td width="20%" style="text-align:center" >
<?php
if($get_group){
$c_grp = count($get_group);
foreach ($get_group as $ggrp){
if($c_grp > 1){
echo $ggrp['group_name'].',';
}
else{
echo $ggrp['group_name'];
}
$c_grp--;
}
}
else{
echo '-';
}?>
</td>
<td width="15%" style="text-align:center" ><?php echo $t; ?></td>
<td width="15%" style="text-align:center"><?php echo $deleted_date; ?></td>
</tr>
<?php
$count++;
}
}
?>
</table>
<?php
}
function ez_footer_options(){
$submit = isset($_POST['submit']) ? $_POST['submit'] : '';
if ($submit) {
update_option('_footer_email', $_POST['_footer_email']);
echo '<div class="updated settings-error" id="setting-error-settings_updated">
<p><strong>Settings saved.</strong></p></div>';
}
$email = get_option('_footer_email');
?>
<div id="footer_options">
<br>
<br>
<form action="" method="POST" >
<div id="footer_options">
<table>
<tr>
<th><label for="_footer_email">Email:</label></th>
<td><input size="70px" type="text" value="<?php echo $email; ?>" name="_footer_email" id="_footer_email"/></td>
</tr>
</table>
</div>
<br><br>
<input type="submit" name="submit" value="Save Changes" class="button button-primary"/>
</form>
</div>
<?php
}
Comments
Post a Comment