<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
/*
add_action( 'wp_enqueue_scripts', 'mpcth_child_enqueue_scripts', 1000 );
function mpcth_child_enqueue_scripts() {
wp_enqueue_style( 'mpc-styles-child', get_stylesheet_directory_uri() . '/style_custom.css' );
}
*/
function registration_form( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
?>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 260px;
}
</style>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -33.8688, lng: 151.2195},
zoom: 13
});
var input = document.getElementById('searchInput');
// map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
map: map,
anchorPoint: new google.maps.Point(0, -29)
});
autocomplete.addListener('place_changed', function() {
infowindow.close();
marker.setVisible(false);
var place = autocomplete.getPlace();
if (!place.geometry) {
window.alert("Autocomplete's returned place contains no geometry");
return;
}
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
marker.setIcon(({
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(35, 35)
}));
marker.setPosition(place.geometry.location);
marker.setVisible(true);
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] && place.address_components[0].short_name || ''),
(place.address_components[1] && place.address_components[1].short_name || ''),
(place.address_components[2] && place.address_components[2].short_name || '')
].join(' ');
}
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
infowindow.open(map, marker);
//Location details
for (var i = 0; i < place.address_components.length; i++) {
if(place.address_components[i].types[0] == 'postal_code'){
// document.getElementById('postal_code').innerHTML = place.address_components[i].long_name;
}
if(place.address_components[i].types[0] == 'country'){
// document.getElementById('country').innerHTML = place.address_components[i].long_name;
}
}
document.getElementById("school").value = "";
document.getElementById("school_address").value = "";
document.getElementById("school").value = place.name;
document.getElementById("school_address").value = place.formatted_address;
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA3rAnj20W3D99Am3KiVer8TQ5LRfsWfJE&libraries=places&callback=initMap"
async defer></script>
<?php
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 0){
?>
<style>
#invcodehide{display:none !important;}
</style>
<?php
}
?>
<?php
echo '
<form id="regform" action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<!--<div class="regi-loginpage-btn"><p>Aleady have an account? <a href="login">Log In</a></p></div>-->
<div class="form-group">
<input placeholder="username" type="text" name="username" id="username" value="' . ( isset( $_POST['username']) ? $username : null ) . '" class="form-control validate[required] username" data-errormessage-value-missing="* username is required" data-prompt-position="topLeft" >
</div>
<div class="cust_transpernt_form">
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 fir">
<div class="form-group">
<input placeholder="First Name" type="text" name="fname" id="fname" value="' . ( isset( $_POST['fname']) ? $fname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] fname" data-errormessage-value-missing="* First name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 sec">
<div class="form-group">
<input placeholder="Last Name" type="text" name="lname" id="lname" value="' . ( isset( $_POST['lname']) ? $lname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] lname" data-errormessage-value-missing="* Last name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<input placeholder="Email" type="text" name="email" id="email" value="' . ( isset( $_POST['email']) ? $email : null ) . '" class="form-control validate[required,custom[email]] email" data-errormessage-value-missing="* Email is required" data-errormessage-custom-error="* Invalid email. Let me give you a hint: someone@nowhere.com" data-prompt-position="topLeft" >
</div>
<div class="form-group">
<input placeholder="Set Password" type="password" name="password" id="password" value="' . ( isset( $_POST['password'] ) ? $password : null ) . '" class="form-control validate[required,custom[password]] password" data-errormessage-value-missing="* Password is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<input placeholder="Confirm Password" type="password" name="confirm_password" id="confirm_password" value="' . ( isset( $_POST['confirm_password'] ) ? $confirm_password : null ) . '" class="form-control validate[required,equals[password]] confirm_password" data-errormessage-value-missing="* Confirm password is required" data-errormessage="* Confirm password field is not matching with password field" data-prompt-position="topLeft" >
<input type="hidden" name="arrayindex" id="arrayindex" value="1"/>
</div>
<div class="form-group">
<input placeholder="Distict/City" type="text" name="distict_city" id="distict_city" value="' . ( isset( $_POST['distict_city'] ) ? $distict_city : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* distict/city is required" data-prompt-position="topLeft">
</div>
<div class="form-group" id="invcodehide">
<input placeholder="Invitation Code*" type="text" name="invcode" id="invcode" value="' . ( isset( $_POST['invcode'] ) ? $invcode : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* Invitation Code is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<div id="locationField">
<input id="searchInput" placeholder="Search for your school.." type="text" class="controls search-school-inp"></input>
</div>
</div>
<div class="form-group"><br>
<div id="map"></div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Name</label>
<input placeholder="" type="text" name="school_name" id="school" value="' . ( isset( $_POST['school_name'] ) ? $school_name : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school name is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Address</label>
<input placeholder="" type="text" name="school_address" id="school_address" value="' . ( isset( $_POST['school_address'] ) ? $school_address : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school address is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type is required" data-prompt-position="topLeft">
<option value="">Select School Type </option>
<option value="Elementary School">Elementary School</option>
<option value="Middle School">Middle School</option>
<option value="High School">High School</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level is required" data-prompt-position="topLeft">
<option value="">Select Grade Level </option>
<option value="Pre K">Pre K </option>
<option value="K">K</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="other">other</option>
</select>
</div>
<div class="form-group check-main-box">
<input type="checkbox" name="vehicle" value="yes" class="form-control validate[required]" > Yes, I accept the <a href="../terms-conditions">Terms & Conditions</a> of & Demo.<br>
</div>
</div>
<input class="btn btn-primary btn-lg btn-block regbtn reg-btn-subb" type="submit" name="submit" value="Register"/>
</form>';
}
function registration_validation( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
global $reg_errors;
$reg_errors = new WP_Error;
global $wpdb;
if(username_exists($username)) {
// Username already registered
$reg_errors->add('username_unavailable', __('Username already taken'));
}
if(!validate_username($username)) {
// invalid username
$reg_errors->add('username_invalid', __('Invalid username'));
}
if ( 4 > strlen( $username ) ) {
$reg_errors->add( 'username_length', 'Username too short. At least 4 characters is required' );
}
if ($fname=="") {
$reg_errors->add( 'empty_fname', 'Required first name field missing' );
}
if ($lname=="") {
$reg_errors->add( 'empty_lname', 'Required last name field missing' );
}
if ( !is_email( $email ) ) {
$reg_errors->add( 'email_invalid', 'Email is not valid' );
}
if ( email_exists( $email ) ) {
$reg_errors->add( 'email', 'Email Already in use' );
}
if ($password=="") {
$reg_errors->add( 'empty_password', 'Required password field missing' );
}else
if ( 5 > strlen( $password ) ) {
$reg_errors->add( 'password', 'Password length must be greater than 5' );
}
if ($password!="") {
if($confirm_password=="")
$reg_errors->add( 'empty_cpassword', 'Required confirm password field missing' );
if($confirm_password!="" && ($confirm_password!=$password)){
$reg_errors->add( 'mismatch_cpassword', 'Required password and confirm password field is mismatch--'.$confirm_password."--".$password );
}
}
if ($school_name=="") {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 1){
$sql = "SELECT * FROM w9p_invitation_code where `invitation_code` = '$invcode' and status = '1';";
$pageposts = $wpdb->get_results($sql);
if(empty($pageposts))
{
$reg_errors->add( 'invcode', 'Invitation Code is not valid' );
}
}
if ($invcode=="" && $statusss == 1) {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
if ( is_wp_error( $reg_errors ) ) {
if ($reg_errors->get_error_messages()) {
echo '<div class="error-regi">';
foreach ( $reg_errors->get_error_messages() as $error ) {
echo '<p><strong>ERROR </strong>:';
echo $error . '</p>';
}
echo '</div>';
}
}
/* registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level
); */
}
function complete_registration() {
global $reg_errors, $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
if ( 1 > count( $reg_errors->get_error_messages() ) ) {
$userdata = array(
'user_login' => $username,
'user_email' => $email,
'user_pass' => $password,
'display_name' => $fname,
'first_name' => $fname,
'last_name' => $lname,
'user_status' => 1,
//'nickname' => $nickname,
//'description' => $bio,
);
$user = wp_insert_user( $userdata );
//$encpassword = base64_encode ($password);
//add_user_meta( $user, 'pwd', $encpassword);
add_user_meta( $user, 'account_type', $account_type);
add_user_meta( $user, 'distict_city', $distict_city);
add_user_meta( $user, 'school_address', $school_address);
add_user_meta( $user, 'school_type', $school_type);
add_user_meta( $user, 'school_name', $school_name);
add_user_meta( $user, 'grade_level', $grade_level);
add_user_meta( $user, 'invitation_code', $invcode);
//sending email for activation email.
$activation_email = activation_email($user);
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
//exit;
echo '<p class="regi-thanku">Registration complete.</p>';
$_POST = array();
?>
<script>
document.getElementById("regform").reset();
</script>
<?php
}
}
add_action('user_register','continue_to_registration');
function continue_to_registration($user_id) {
if(is_admin()){
$invcode = $_POST['fields']['field_5a8e6ccd1c8bc'];
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
}
}
function activation_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$subject = 'Activation Email';
$link = get_stylesheet_directory_uri()."/activation.php?userid=$userid";
$linkurl = "<a style='color:#333' href=$link>Activation Link</a>";
$message = get_header_email_template();
//$message .= "<p>Hello $username ,<br> Please click on below link to activate your account.<br> $link</p>";
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">Please click on below link to activate your account.<br> <br> '.$linkurl.'</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message, $headers)){
echo '<p class="regi-thanku">Thank You! Please check your email to activate your account.</p>';
// $location = home_url()."/login/?status=pending";
//wp_safe_redirect($location);
} else{
//echo 'Unable to send email. Please try again.';
}
//exit;
}
function after_activation_welcome_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$pwd = get_user_meta($userid,'pwd');
$pwdd = base64_decode($pwd[0]);
$subject = 'Welcome to Demo Portal
';
$link = site_url();
$linkurl = "<a style='color:#333' href=$link> Demo Portal </a>";
$message = get_header_email_template();
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
Thank you & Welcome to Demo Portal . <br> Your email is successfully verified.</p><br>
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
You can now login to the website and shop for the study material.</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message,$headers)){
echo 'Your mail has been sent successfully.';
} else{
// echo 'Unable to send email. Please try again.';
}
//exit;
}
function custom_registration_function() {
if ( isset($_POST['submit'] ) ) {
registration_validation(
$_POST['username'],
$_POST['fname'],
$_POST['lname'],
$_POST['email'],
$_POST['password'],
$_POST['confirm_password'],
$_POST['account_type'],
$_POST['distict_city'],
$_POST['school_name'],
$_POST['school_address'],
$_POST['school_type'],
$_POST['grade_level'],
$_POST['invcode']
);
// sanitize user form input
global $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
$username = sanitize_user( $_POST['username'] );
$password = esc_attr( $_POST['password'] );
$confirm_password = esc_attr( $_POST['confirm_password'] );
$email = sanitize_email( $_POST['email'] );
$fname = sanitize_text_field( $_POST['fname'] );
$lname = sanitize_text_field( $_POST['lname'] );
$account_type = sanitize_text_field( $_POST['account_type'] );
$distict_city = esc_textarea( $_POST['distict_city'] );
$school_name = esc_textarea( $_POST['school_name'] );
$school_address = esc_textarea( $_POST['school_address'] );
$school_type = $_POST['school_type'];
$grade_level = $_POST['grade_level'];
$invcode = $_POST['invcode'];
complete_registration(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
// Register a new shortcode: [cr_custom_registration]
add_shortcode( 'cr_custom_registration', 'custom_registration_shortcode' );
// The callback function that will replace [book]
function custom_registration_shortcode() {
ob_start();
custom_registration_function();
return ob_get_clean();
}
function get_header_email_template(){
$diruri = get_stylesheet_directory_uri();
$siteuri = site_url();
$header =
'
<style>
table { border:solid 1px #0056a2;margin:20px auto;line-height:20px;color:#666;}
table tr td {padding:10px;font-size:13px;}
.border-top {border-top:solid 1px #d7d7d7;}
.social_links a {display:inline-block;margin-left:5px;}
a{color:#ffffff;}
</style>
<body>
<table width="600" cellspacing="0" cellpadding="10" style="border:solid 2px #00582e; background:url('.$diruri.'/images/body_bg.jpg) no-repeat fixed center top / cover; border-radius:4px; margin:20px auto;line-height:20px;color:#666; font-family:Arial, Helvetica, sans-serif;">
<thead>
<tr bgcolor="">
<td align="left" style="padding:20px 30px;" title="Demo"><a href="'.$siteuri.'/about/welcome-letter/"><img width="100%" src="'.$diruri.'/images/logo.png"></a></td>
<td align="right" style="color:#ffffff; line-height:normal; padding:20px 30px;"><strong style="display:block; margin-top:22px;"></strong></td>
</tr>
<tr bgcolor="#dddddd">
<td style="padding:0px; height:1px;"></td>
<td style="padding:0px; height:1px;"></td>
</tr>
</thead>';
return $header;
}
function get_footer_email_template(){
$footer = '
<tr bgcolor="#ffffff">
<td colspan="2" style="color:#00582e; padding:0;"></td>
</tr>
<tr bgcolor="">
<td style="color:#fff;">
<strong style="color:#fff">Demo Portal </strong><br>
<strong>Email:</strong> <a href="mailto:info@Demo.com" style="color:#fff;">info@Demo.com</a></td>
<td width="50%" align="right" style="color:#fff;"> </td>
</tr>
</table></body></html> ';
return $footer;
}
function wpse_131562_redirect() {
if (
! is_user_logged_in() && !is_page(array( 31,147,16895,35,34,17026 ))
/* && (is_woocommerce() || is_cart() || is_checkout() || is_product() || is_singular( 'sfwd-courses' ) || is_singular( 'sfwd-topic' ) || is_page(array( 293,40,29,417,194, 16156, 16424, 7736, 16445, 16452 )) || is_post_type_archive( 'Demo' ) || is_singular( 'Demo' ))*/
) {
// feel free to customize the following line to suit your needs
//wp_redirect(home_url());
auth_redirect();
exit;
}
if (
is_user_logged_in()
&& (is_page(147))
) {
$location = home_url()."/courses-list/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit;
}
}
add_action('template_redirect', 'wpse_131562_redirect');
function so_27030769_maybe_empty_cart( $valid, $product_id, $quantity ) {
if( ! empty ( WC()->cart->get_cart() ) && $valid ){
WC()->cart->empty_cart();
wc_add_notice( 'Whoa hold up. You can only have an item in your cart', 'error' );
?>
<style>
.woocommerce-message {
display: none;
}
</style>
<?php
}
return $valid;
}
add_filter( 'woocommerce_add_to_cart_validation', 'so_27030769_maybe_empty_cart', 10, 3 );
/*
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['action']) && !empty($_POST['action'])) ) {
add_filter('login_redirect', 'my_login_redirect', 10, 3);
function my_login_redirect() {
$location = $_SERVER['HTTP_REFERER'];
$location = home_url()."/my-account/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit();
}
}
*/
/**
* Opening div for our content wrapper
*/
add_action('woocommerce_before_main_content', 'iconic_open_div', 5);
function iconic_open_div() {
echo '<div class="iconic-div">';
}
/**
* Closing div for our content wrapper
*/
add_action('woocommerce_after_main_content', 'iconic_close_div', 50);
function iconic_close_div() {
echo '</div>';
}
add_action( 'user_register', 'registration_save', 10, 1 );
function registration_save( $user_id ) {
if ( !isset( $_POST['password'] ) )
{
sleep(5);
$user_data = update_user_meta( $user_id, 'pw_user_status','approved' );
add_option( 'group_leader_id_'.$user_id, get_current_user_id() );
$distict_city = get_user_meta( get_current_user_id(), 'distict_city', true );
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
$school_type = get_user_meta( get_current_user_id(), 'school_type', true );
$school_name = get_user_meta( get_current_user_id(), 'school_name', true );
$grade_level = get_user_meta( get_current_user_id(), 'grade_level', true );
$user = new WP_User( get_current_user_id() );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
$people_role = $user->roles;
if (!in_array("administrator", $people_role) && in_array("group_leader", $people_role))
{
update_user_meta( $user_id, 'distict_city', $distict_city);
update_user_meta( $user_id, 'school_address', $school_address);
update_user_meta( $user_id, 'school_type', $school_type);
update_user_meta( $user_id, 'school_name', $school_name);
update_user_meta( $user_id, 'grade_level', $grade_level);
}
}
}
}
function admin_default_page() {
//return home_url().'/my-account/';
// return $_SERVER['HTTP_REFERER'];
}
//add_filter('login_redirect', 'admin_default_page');
function my_login_redirect( $redirect_to, $request, $user ){
//is there a user to check?
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if( in_array( "administrator", $user->roles ) ) {
// redirect them to the default place
return home_url(); //admin redirect url
} else {
return admin_url( 'edit.php?post_type=page' ); //user redirect url
}
}
else {
// return $redirect_to;
if($redirect_to==home_url()."/wp-admin/"){
return home_url().'/courses-list/';
}else{
return $redirect_to;
}
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
add_action( 'woocommerce_edit_account_form', 'my_woocommerce_edit_account_form' );
add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' );
function my_woocommerce_edit_account_form() {
$user_id = get_current_user_id();
$user = get_userdata( $user_id );
if ( !$user )
return;
$account_type = get_user_meta( $user_id, 'account_type', true );
$distict_city = get_user_meta( $user_id, 'distict_city', true );
$school_address = get_user_meta( $user_id, 'school_address', true );
$school_type = get_user_meta( $user_id, 'school_type', true );
$school_name = get_user_meta( $user_id, 'school_name', true );
$grade_level = get_user_meta( $user_id, 'grade_level', true );
$twitter = get_user_meta( $user_id, 'twitter', true );
$url = $user->user_url;
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Distict/City:</label>
<input type="text" name="distict_city" value="<?php echo esc_attr( $distict_city ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Name:</label>
<input type="text" name="school_name" value="<?php echo esc_attr( $school_name ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Address:</label>
<input type="text" name="school_address" value="<?php echo esc_attr( $school_address ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Type:</label>
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type required">
<option value="">Select School Type </option>
<option value="Elementary" <?php if($school_type=="Elementary") echo 'selected="selected"'; ?>>Elementary </option>
<option value="Middle School" <?php if($school_type=="Middle School") echo 'selected="selected"'; ?>>Middle School</option>
<option value="High School" <?php if($school_type=="High School") echo 'selected="selected"'; ?>>High School</option>
<option value="Other" <?php if($school_type=="Other") echo 'selected="selected"'; ?>>Other</option>
</select>
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Grade Level:</label>
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level required">
<option value="">Select Grade Level </option>
<option value="Pre K" <?php if($grade_level=="Pre K") echo 'selected="selected"'; ?> >Pre K </option>
<option value="K" <?php if($grade_level=="K") echo 'selected="selected"'; ?>>K</option>
<option value="1" <?php if($grade_level=="1") echo 'selected="selected"'; ?>>1</option>
<option value="2" <?php if($grade_level=="2") echo 'selected="selected"'; ?>>2</option>
<option value="3" <?php if($grade_level=="3") echo 'selected="selected"'; ?>>3</option>
<option value="4" <?php if($grade_level=="4") echo 'selected="selected"'; ?>>4</option>
<option value="5" <?php if($grade_level=="5") echo 'selected="selected"'; ?>>5</option>
<option value="6" <?php if($grade_level=="6") echo 'selected="selected"'; ?>>6</option>
<option value="7" <?php if($grade_level=="7") echo 'selected="selected"'; ?>>7</option>
<option value="8" <?php if($grade_level=="8") echo 'selected="selected"'; ?>>8</option>
<option value="9" <?php if($grade_level=="9") echo 'selected="selected"'; ?>>9</option>
<option value="10" <?php if($grade_level=="10") echo 'selected="selected"'; ?>>10</option>
<option value="11" <?php if($grade_level=="11") echo 'selected="selected"'; ?>>11</option>
<option value="12" <?php if($grade_level=="12") echo 'selected="selected"'; ?>>12</option>
<option value="other" <?php if($grade_level=="other") echo 'selected="selected"'; ?>>other</option>
</select>
</fieldset>
<?php /* ?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter"><?php _e('Main Profile Image', 'shr') ?></label>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</p>
</fieldset>
<?php */ ?>
<?php
}
function my_woocommerce_save_account_details( $user_id ) {
update_user_meta( $user_id, 'account_type', $_POST[ 'account_type' ]);
update_user_meta( $user_id, 'distict_city', $_POST[ 'distict_city' ]);
update_user_meta( $user_id, 'school_address', $_POST[ 'school_address' ]);
update_user_meta( $user_id, 'school_type', $_POST[ 'school_type' ]);
update_user_meta( $user_id, 'school_name', $_POST[ 'school_name' ]);
update_user_meta( $user_id, 'grade_level', $_POST[ 'grade_level' ]);
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
update_user_meta( $user_id, 'twitter', htmlentities( $_POST[ 'twitter' ] ) );
$user = wp_update_user( array( 'ID' => $user_id, 'user_url' => esc_url( $_POST[ 'url' ] ) ) );
}
add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' );
function misha_remove_my_account_links( $menu_links ){
$customer_orders = get_posts( array(
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => 'shop_order',
'post_status' => array_keys( wc_get_order_statuses() ),
'numberposts' => -1,
));
if ( $customer_orders ){
}else{
unset( $menu_links['edit-address'] ); // Addresses
unset( $menu_links['orders'] );
unset( $menu_links['downloads'] );
}
unset( $menu_links['edit-address'] );
//unset( $menu_links['dashboard'] ); // Dashboard
//unset( $menu_links['payment-methods'] ); // Payment Methods
//unset( $menu_links['orders'] ); // Orders
unset( $menu_links['downloads'] ); // Downloads
//unset( $menu_links['edit-account'] ); // Account details
//unset( $menu_links['customer-logout'] ); // Logout
return $menu_links;
}
function shr_add_admin_scriptss(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('admin_enqueue_scripts', 'shr_add_admin_scriptss');
function shr_add_admin_scripts(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('wp_enqueue_scripts', 'shr_add_admin_scripts');
function shr_extra_profile_fields( $user ) {
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
} ?>
<table class="form-table fh-profile-upload-options">
<tr>
<th>
<label for="image"><?php _e('Main Profile Image', 'shr') ?></label>
</th>
<td>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</td>
</tr>
</table><?php
}
add_action( 'show_user_profile', 'shr_extra_profile_fields' );
add_action( 'edit_user_profile', 'shr_extra_profile_fields' );
add_action( 'user_new_form', 'shr_extra_profile_fields' );
function shr_profile_update($user_id){
if( current_user_can('edit_users') ){
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
}
}
add_action('profile_update', 'shr_profile_update');
add_action('user_register', 'shr_profile_update');
//change the role to fit your needs
function enable_file_uploads_by_role( ) {
$role = 'subscriber';
if(!current_user_can($role) || current_user_can('upload_files'))
return;
$contributor = get_role( $role );
$contributor->add_cap('upload_files');
} add_action('admin_init', 'enable_file_uploads_by_role');
///// ************************************//////
/*----------------------------------------------------------------------------*
* Register custom post types
*----------------------------------------------------------------------------*/
add_action( 'init', 'fusion_register_post_types' );
function fusion_register_post_types() {
global $smof_data;
$permalinks = get_option( 'avada_permalinks' );
register_post_type(
'Demo',
array(
'labels' => array(
'name' => _x( 'Demo', 'Post Type General Name', 'fusion-core' ),
'singular_name' => _x( 'Demo', 'Post Type Singular Name', 'fusion-core' ),
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => $smof_data['Demo_slug']
),
'supports' => array( 'title', 'editor', 'author', 'excerpt', 'thumbnail', 'comments'),
'can_export' => true,
)
);
/*
register_taxonomy('iam_an', 'Demo',
array(
'hierarchical' => true,
'label' => __('I am a(n)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_iam_an_base'] ) ? _x( 'iam_an', 'slug', 'fusion-core' ) : $permalinks['Demo_iam_base'],
'with_front' => false
),
)
);*/
register_taxonomy('looking_for', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'Looking For', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['portfolio_looking_for_base'] ) ? _x( 'looking_for', 'slug', 'fusion-core' ) : $permalinks['portfolio_looking_for_base'],
'with_front' => false
),
)
);
register_taxonomy('about', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'About', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_about_base'] ) ? _x( 'about', 'slug', 'fusion-core' ) : $permalinks['Demo_about_base'],
'with_front' => false
),
)
);
register_taxonomy('age_group', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'For (Age group)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_age_group'] ) ? _x( 'age_group', 'slug', 'fusion-core' ) : $permalinks['Demo_age_group'],
'with_front' => false
),
)
);
register_taxonomy('Demo_tags', 'Demo',
array(
'hierarchical' => false,
'label' => __( 'Tags', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_tags_base'] ) ? _x( 'Demo_tags', 'slug', 'fusion-core' ) : $permalinks['Demo_tags_base'],
'with_front' => false
),
)
);
if( function_exists('qtrans_getLanguage') ) {
add_action('age_group_add_form', 'qtrans_modifyTermFormFor');
add_action('age_group_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_edit_form', 'qtrans_modifyTermFormFor');
add_action('faq_category_edit_form', 'qtrans_modifyTermFormFor');
}
}
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'Demo' )
{
return locate_template('archive-Demo.php'); // redirect to archive-search.php
}
return $template;
}
add_filter('template_include', 'template_chooser');
function limit_text($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
function wpsites_change_comment_form_submit_label($arg) {
$arg['label_submit'] = 'Post Feedback';
$arg['comment_field'] = '<p class="comment-form-comment"><label for="comment" >' . _x( 'Your Feedback Is Appreciated', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>';
$arg['title_reply'] = __('Leave Feedback');
return $arg;
}
add_filter('comment_form_defaults', 'wpsites_change_comment_form_submit_label');
function mytheme_comment($comment, $args, $depth) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body tt">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) //echo get_avatar( $comment, $args['avatar_size'] );
$current_user = wp_get_current_user();
$user = get_comment_author_link();
$current_user->display_name;
echo "<dl class='comments_boxses'>";
echo "<dt class=".strtoupper( $user[0] ).">".strtoupper( $user[0] )."</dt>";
?>
<dd>
<div class="author_heading"> <?php printf( __( '<div class="authorename fn">%s</div> ' ), get_comment_author_link() ); ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php //edit_comment_link( __( '(Edit)' ), ' ', '' );
?></div>
</div>
<div class="reply_text"><?php comment_text(); ?>
<span class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</span>
<?php if ( $comment->comment_approved == '0' ) : ?> <br />
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting for approved.' ); ?></em>
<br />
<?php endif; ?>
</div>
</dd>
</dl>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
add_action('user_register', 'save_user_notifaction_field');
function save_user_notifaction_field($user_id) {
$user_email = get_userdata($user_id)->user_email;
global $wpdb;
$wpdb->query("INSERT INTO `w9p_Demo_notification` (`id`, `user_id`, `user_email`, `post_count`, `post_id`) VALUES (NULL, '$user_id', '$user_email', '0', '0');");
}
function wcs_send_mail_on_publish_category_posts( $new_status, $old_status, $post ) {
global $post;
global $wpdb;
if ( 'publish' !== $new_status or 'publish' === $old_status ) return;
$posttype = "Demo";
if ($post->post_type == $posttype ) {
$post_id = $post->ID;
$wpdb->query("UPDATE `w9p_Demo_notification` SET `post_count` = post_count+1, `post_id` = CONCAT(post_id,',$post_id');");
$body = sprintf( 'Hey there is a new entry! See <%s %s>', get_permalink( $post ), $post->post_title );
}
}
add_action( 'transition_post_status', 'wcs_send_mail_on_publish_category_posts', 10, 3 );
add_action( 'wp_trash_post', 'function_to_run_on_post_trash' );
function function_to_run_on_post_trash( $post_id ){
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
global $wpdb;
$rid = ",".$post_id;
$wpdb->query("UPDATE w9p_Demo_notification SET post_id = REPLACE(post_id, '$rid', '');");
//wp_mail( 'samrat.p@edreamz.in', 'trash_post entry!', "trash" );
}
$new_general_setting = new new_general_setting();
class new_general_setting {
function new_general_setting( ) {
add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
}
function register_fields() {
register_setting( 'general', 'notification_show', 'esc_attr' );
add_settings_field('notification_show', '<label for="favorite_color">'.__('Show Notification?' , 'notification_show' ).'</label>' , array(&$this, 'fields_html') , 'general' );
register_setting( 'general', 'show_per_page', 'esc_attr' );
add_settings_field('show_per_page', '<label for="favorite_color">'.__('Notification Page Show Limit' , 'show_per_page' ).'</label>' , array(&$this, 'fields_htmls') , 'general' );
register_setting( 'general', 'show_add_content', 'esc_attr' );
add_settings_field('show_add_content', '<label for="favorite_color">'.__('Show Add Content' , 'show_add_content' ).'</label>' , array(&$this, 'fields_htmlss') , 'general' );
}
function fields_htmls() {
$show_per_page = get_option( 'show_per_page', '' );
?>
<input type="text" name="show_per_page" value="<?php echo $show_per_page; ?>" />
<?php
}
function fields_htmlss() {
$show_add_content = get_option( 'show_add_content', '' );
?>
<input type="checkbox" <?php if($show_add_content==1)echo 'checked="checked"'; ?> name="show_add_content" id="show_add_content" value="1">
<?php
}
function fields_html() {
$value = get_option( 'notification_show', '' );
?>
<input type="checkbox" <?php if($value==1)echo 'checked="checked"'; ?> name="notification_show" id="notification_show" value="1">
<a href="javascript:;" onclick="funDismiss()">Clear all notifications for all users</a>
<script>
function funDismiss(){
var r = confirm("Are you sure to clear all notifications for all users?");
if (r == true) {
jQuery.ajax({
type:'POST',
data:{action:'delete_noti'},
url: '<?php echo get_site_url(); ?>/wp-content/themes/midsets/action.php',
success: function(value) {
},
});
} else {
}
}
</script>
<?php
}
}
//new changes
require 'submit_Demo.php';
require 'resource_head.php';
if ( !current_user_can( 'administrator' )) {
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
remove_menu_page( 'admin.php?page=aiowpsec' );
remove_menu_page( 'aiowpsec' );
remove_menu_page( 'edit.php?post_type=acf' );
remove_menu_page( 'wpcf7' );
remove_menu_page( 'cfs' );
remove_menu_page( 'edit.php?post_type=cfs' );
remove_menu_page( 'w3tc_dashboard' );
remove_menu_page( 'invitation_details' );
remove_menu_page( 'yst_ga_dashboard' );
remove_menu_page( 'bws_panel' );
remove_menu_page( 'bhittani_plugin_kksr_settings' );
remove_menu_page( 'register-plus-redux' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=wpeditor_admin' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=invitation_details' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
?>
<style>
#toplevel_page_master-slider, #toplevel_page_edit-post_type-acf, #toplevel_page_wpeditor_admin{display:none;}
</style>
<?php
}
add_action( 'admin_menu', 'remove_menus' );
}
function cjobs_admin_head()
{
do_action('acf/input/admin_head');
}
add_action('admin_head', 'cjobs_admin_head');
function makeiframevideo($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
// Instagram
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"443\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframevideos($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
// Instagram
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"350\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframe($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
// Instagram
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"182\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
global $wpdb;
$title = $_POST['resource_title'];
$about=$_POST['about'];
$age_group=$_POST['age_group'];
$looking_for=$_POST['looking_for'];
$c_text = $_POST['c_text'];
$Demo_tags = $_POST['Demo_tags'];
$video_url = $_POST['video_url'];
$mindset_anchors = $_POST['mindset_anchors'];
$discussion_prompts = $_POST['discussion_prompts'];
$file_size = $_FILES['my_file_upload']['size'];
if ($file_size > 20971520){
}
// save code here
$my_post = array(
'post_title' => $_POST['resource_title'],
'post_content' => $c_text,
'post_type'=>'Demo',
'post_status' => 'pending',
'filter' => false,
'post_author' => get_current_user_id(),
);
// Insert the post into the database.
$post_id = wp_insert_post( $my_post );
wp_set_object_terms( $post_id, $looking_for, 'looking_for' );
wp_set_object_terms( $post_id, $age_group, 'age_group' );
wp_set_object_terms( $post_id, $about, 'about' );
wp_set_object_terms( $post_id, $Demo_tags, 'Demo_tags' );
if ( !function_exists('wp_handle_upload') ) {
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}
if($_FILES['my_image_upload']['name']!=""){
$movefile = wp_handle_upload( $_FILES['my_image_upload'], array('test_form' => false) );
}
// If move was successful, insert WordPress attachment
if ( $movefile && !isset($movefile['error']) ) {
$wp_upload_dir = wp_upload_dir();
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename($movefile['file']),
'post_mime_type' => $movefile['type'],
'post_title' => preg_replace( '/\.[^.]+$/', "", basename($movefile['file']) ),
'post_content' => "",
'post_status' => 'inherit'
);
if($_FILES['my_image_upload']['name']!=""){
$attach_id = wp_insert_attachment($attachment, $movefile['file']);
$thumbnail_image_url = wp_get_attachment_url( $attach_id );
update_field('thumbnail_image', $attach_id, $post_id);
}
if($_FILES['my_file_upload']['name']!=""){
$attachment_id = media_handle_upload( 'my_file_upload', $post_id );
$attachment_url = wp_get_attachment_url( $attachment_id );
update_field('attach_file', $attachment_id, $post_id);
}
}
update_field('video_url', $video_url, $post_id);
update_field('mindset_anchors', $mindset_anchors, $post_id);
update_field('discussion_prompts', $discussion_prompts, $post_id);
$current_user = wp_get_current_user();
$email = $current_user->user_email;
$user_id = $current_user->ID;
$cdate = date("Y-m-d H:i:s");
$sql = "INSERT INTO `wp_Demo` (`id`, `pid`, `user_id`, `user_email`, `title`, `content`, `Demo_tags`, `video_url`, `mindset_anchors`, `discussion_prompts`, `attach_file`, `thumbnail_image`, `looking_for`, `about`, `age_group`, `status`, `date`) VALUES (NULL, '$post_id', '$user_id', '$email', '$title', '$c_text', '$Demo_tags', '$video_url', '$mindset_anchors', '$discussion_prompts', '$attachment_url', '$thumbnail_image_url', '$looking_for', '$about', '$age_group', '0', '$cdate');";
$wpdb->query($sql);
return $post_id;
}
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
//wp_deregister_style( 'amethyst-dashicons-style' );
wp_deregister_style( 'common' );
}
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
.acf-image-uploader img {
width: 48%;
}
</style>';
}
//samrat
//add_filter( 'login_redirect', 'skp_login_redirect', 10, 3 );
function my_force_logins() {
global $post;
if (!is_user_logged_in()) {
//auth_redirect();
wp_redirect( $_SERVER["REQUEST_URI"] );
}
}
function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
// Validate inputs.
if ( ! $url || ( ! $width && ! $height ) ) return $url;
// Caipt'n, ready to hook.
if ( true === $upscale ) add_filter( 'image_resize_dimensions', 'aq_upscale', 10, 6 );
// Define upload path & dir.
$upload_info = wp_upload_dir();
$upload_dir = $upload_info['basedir'];
$upload_url = $upload_info['baseurl'];
$http_prefix = "http://";
$https_prefix = "https://";
/* if the $url scheme differs from $upload_url scheme, make them match
if the schemes differe, images don't show up. */
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
}
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
}
// Check if $img_url is local.
if ( false === strpos( $url, $upload_url ) ) return $url;
// Define path of image.
$rel_path = str_replace( $upload_url, '', $url );
$img_path = $upload_dir . $rel_path;
// Check if img path exists, and is an image indeed.
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return $url;
// Get image info.
$info = pathinfo( $img_path );
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $img_path );
// Get image size after cropping.
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
$dst_w = $dims[4];
$dst_h = $dims[5];
// Return the original image only if it exactly fits the needed measures.
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
$img_url = $url;
$dst_w = $orig_w;
$dst_h = $orig_h;
} else {
// Use this to check if cropped image already exists, so we can return that instead.
$suffix = "{$dst_w}x{$dst_h}";
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
// Can't resize, so return origin image url.
return $url;
}
// Else check if cache exists.
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
}
// Else, we resize the image and return the new resized image url.
else {
// Note: This pre-3.5 fallback check will edited out in subsequent version.
if ( function_exists( 'wp_get_image_editor' ) ) {
$editor = wp_get_image_editor( $img_path );
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
return $url;
$resized_file = $editor->save();
if ( ! is_wp_error( $resized_file ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
} else {
$resized_img_path = image_resize( $img_path, $width, $height, $crop ); // Fallback foo.
if ( ! is_wp_error( $resized_img_path ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_img_path );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
}
}
}
// Okay, leave the ship.
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', 'aq_upscale' );
// Return the output.
if ( $single ) {
// str return.
$image = $img_url;
} else {
// array return.
$image = array (
0 => $img_url,
1 => $dst_w,
2 => $dst_h
);
}
return $image;
}
function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
if ( ! $crop ) return $url; // Let the wordpress default function handle this.
// Here is the point we allow to use larger image size than the original one.
$aspect_ratio = $orig_w / $orig_h;
$new_w = $dest_w;
$new_h = $dest_h;
if ( ! $new_w ) {
$new_w = intval( $new_h * $aspect_ratio );
}
if ( ! $new_h ) {
$new_h = intval( $new_w / $aspect_ratio );
}
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
$crop_w = round( $new_w / $size_ratio );
$crop_h = round( $new_h / $size_ratio );
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
/*
add_action( 'wp_default_scripts', function( $scripts ) {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) );
}
} );
*/
add_filter( 'auto_update_plugin', '__return_false' );
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');
function wpb_get_post_views($postID){
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
$count = round($count/2);
return $count.' Views';
}
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
// Disable REST API link tag
remove_action('wp_head', 'rest_output_link_wp_head', 10);
// Disable oEmbed Discovery Links
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
// Disable REST API link in HTTP headers
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
add_action('admin_head', 'my_custom_fontss');
function my_custom_fontss() {
echo '<style>
#toplevel_page_invitation_details li:nth-child(4){
display:none;
}
#toplevel_page_invitation_details li:nth-child(6){
display:none;
}
</style>';
}
add_filter( 'manage_edit-groups_columns', 'my_edit_groups_columns' ) ;
function my_edit_groups_columns( $columns ) {
$columns_new = array();
foreach( $columns as $col_key => $col_label ) {
if ($col_key == 'date') {
//$columns_new['groups_group_leaders'] = __('Group Information', 'learndash');
$columns_new['school_name'] = __( 'Group Information', 'learndash' );
$columns_new['groups_group_courses'] = sprintf( _x('Group %s', 'Group Courses', 'learndash'), LearnDash_Custom_Label::get_label( 'courses' ));
$columns_new['groups_group_users'] = __('Group Users', 'learndash');
}
$columns_new[$col_key] = $col_label;
}
return $columns_new;
}
/*
// Add the custom columns to the book post type:
add_filter( 'manage_groups_posts_columns', 'set_custom_edit_book_columns' );
function set_custom_edit_book_columns($columns) {
$columns['school_name'] = __( 'School Name', 'your_text_domain' );
return $columns;
}
*/
// Add the data to the custom columns for the book post type:
add_action( 'manage_groups_posts_custom_column' , 'custom_book_column', 1, 2 );
function custom_book_column( $column, $post_id ) {
switch ( $column ) {
case 'school_name':
$group_leaders = learndash_get_groups_administrator_ids( $post_id );
foreach( $group_leaders as $user_id ) {
$user = get_user_by( 'id', $user_id );
echo "<b>School: ".get_user_meta( $user_id, 'school_name', true )."</b><br>";
echo 'Name: <a href="'. get_edit_user_link( $user_id ) .'">'. $user->first_name .' '.$user->last_name .'</a><br>';
}
break;
}
}
function wpachievements_myachievements_func_new( $atts ) {
if( is_user_logged_in() ){
extract( shortcode_atts( array(
'user_id' => '',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $current_user, $wpdb;
get_currentuserinfo();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
//$myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', WPACHIEVEMENTS_TEXT_DOMAIN) .'</h3>';
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
if(function_exists('is_multisite') && is_multisite()){
$sim_ach = get_blog_option(1,'wpachievements_sim_ach');
} else{
$sim_ach = get_option('wpachievements_sim_ach');
}
$ii=0;
$iii=0;
$achievement_badges='';
if( !empty($userachievement) && $userachievement != '' ){
if(function_exists('is_multisite') && is_multisite()){
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'true'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(function_exists('is_multisite') && is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
$myachievements .= '</div>';
return $myachievements;
}
}
add_shortcode( 'wpa_myachievements_new', 'wpachievements_myachievements_func_new' );
// Register and load the widget
function wpb_load_widget() {
register_widget( 'wpb_widget' );
}
add_action( 'widgets_init', 'wpb_load_widget' );
// Creating the widget
class wpb_widget extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widget',
// Widget name will appear in UI
__('Achievements Widget', 'wpb_widget_domain'),
// Widget description
array( 'description' => __( 'Sample widget based on Achievements', 'wpb_widget_domain' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
// This is where you run the code and display the output
//echo __( 'Hello, World!', 'wpb_widget_domain' );
if( is_user_logged_in() ){
echo "<div class='achievements_users'>";
?>
<div class="image-users-wrp">
<div class="image">
<?php
$user_id = get_current_user_id();
/*
$user = get_userdata( $user_id );
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
*/
$profile_img = 'profile_img';
$profile_pic = get_post_meta($user_id, $profile_img, true);
if(empty($profile_pic)){ ?>
<img src="<?php echo home_url(); ?>/wp-content/uploads/2017/12/user-icon.png" class="user-icon" />
<?php }else{ ?>
<img class="user-icon" src="<?php echo home_url("/img/").$profile_pic; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?>" />
<?php } ?>
</div>
<div class="user-info">
<?php
$current_user = wp_get_current_user();
echo "<b>".$current_user->user_firstname ." ". $current_user->user_lastname."</b><br>";
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
echo $school_name = get_user_meta( get_current_user_id(), 'school_name', true );
?>
</div>
</div>
<?php
echo "<div class='achievements'>";
extract( shortcode_atts( array(
'user_id' => '',
'show_title' => 'true',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $wpdb;
$current_user = wp_get_current_user();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = (array) get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
if( $show_title == 'true' || $show_title == 'True' ){
// $myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', 'wpachievements') .'</h3>';
}
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
$sim_ach = wpachievements_get_site_option( 'wpachievements_sim_ach' );
$ii=0;
$iii=0;
$achievement_badges = array();
if ( ! empty( $userachievement ) ) {
if( is_multisite() ) {
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_woopoints = get_post_meta( $ach_ID, '_achievement_woo_points', true );
$ach_rank = get_post_meta( $ach_ID, '_achievement_rank', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'yes'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
$myachievements .= '</div></div>';
echo $myachievements;
echo '</div>';
echo '</div>';
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<!--<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>-->
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgets() {
register_widget( 'wpb_widgets' );
}
add_action( 'widgets_init', 'wpb_load_widgets' );
// Creating the widget
class wpb_widgets extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgets',
// Widget name will appear in UI
__('Quick Training', 'wpb_widget_domainss'),
// Widget description
array( 'description' => __( 'Sample widget based on Quick Training', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
$value = get_field( "quick_training", get_the_ID() );
echo '<h2 class="widget-title">Quick Training</h2>';
if($value){
echo $value;
}else{
echo "<style>#wpb_widgets-2{display:none;}</style>";
echo "<style>#wpb_widgets-3{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgetss() {
register_widget( 'wpb_widgetss' );
}
add_action( 'widgets_init', 'wpb_load_widgetss' );
// Creating the widget
class wpb_widgetss extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgetss',
// Widget name will appear in UI
__('Rating', 'wpb_widget_domainsss'),
// Widget description
array( 'description' => __( 'Sample widget based on Rating', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( is_singular( 'sfwd-topic' ) ) {
if(function_exists('the_ratings')){ the_ratings(); }
}else{
echo "<style>#wpb_widgetss-2{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
function register_my_session(){
if( !session_id() ){
session_start();<?php
/*
add_action( 'wp_enqueue_scripts', 'mpcth_child_enqueue_scripts', 1000 );
function mpcth_child_enqueue_scripts() {
wp_enqueue_style( 'mpc-styles-child', get_stylesheet_directory_uri() . '/style_custom.css' );
}
*/
function registration_form( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
?>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 260px;
}
</style>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -33.8688, lng: 151.2195},
zoom: 13
});
var input = document.getElementById('searchInput');
// map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
map: map,
anchorPoint: new google.maps.Point(0, -29)
});
autocomplete.addListener('place_changed', function() {
infowindow.close();
marker.setVisible(false);
var place = autocomplete.getPlace();
if (!place.geometry) {
window.alert("Autocomplete's returned place contains no geometry");
return;
}
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
marker.setIcon(({
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(35, 35)
}));
marker.setPosition(place.geometry.location);
marker.setVisible(true);
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] && place.address_components[0].short_name || ''),
(place.address_components[1] && place.address_components[1].short_name || ''),
(place.address_components[2] && place.address_components[2].short_name || '')
].join(' ');
}
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
infowindow.open(map, marker);
//Location details
for (var i = 0; i < place.address_components.length; i++) {
if(place.address_components[i].types[0] == 'postal_code'){
// document.getElementById('postal_code').innerHTML = place.address_components[i].long_name;
}
if(place.address_components[i].types[0] == 'country'){
// document.getElementById('country').innerHTML = place.address_components[i].long_name;
}
}
document.getElementById("school").value = "";
document.getElementById("school_address").value = "";
document.getElementById("school").value = place.name;
document.getElementById("school_address").value = place.formatted_address;
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA3rAnj20W3D99Am3KiVer8TQ5LRfsWfJE&libraries=places&callback=initMap"
async defer></script>
<?php
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 0){
?>
<style>
#invcodehide{display:none !important;}
</style>
<?php
}
?>
<?php
echo '
<form id="regform" action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<!--<div class="regi-loginpage-btn"><p>Aleady have an account? <a href="login">Log In</a></p></div>-->
<div class="form-group">
<input placeholder="username" type="text" name="username" id="username" value="' . ( isset( $_POST['username']) ? $username : null ) . '" class="form-control validate[required] username" data-errormessage-value-missing="* username is required" data-prompt-position="topLeft" >
</div>
<div class="cust_transpernt_form">
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 fir">
<div class="form-group">
<input placeholder="First Name" type="text" name="fname" id="fname" value="' . ( isset( $_POST['fname']) ? $fname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] fname" data-errormessage-value-missing="* First name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 sec">
<div class="form-group">
<input placeholder="Last Name" type="text" name="lname" id="lname" value="' . ( isset( $_POST['lname']) ? $lname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] lname" data-errormessage-value-missing="* Last name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<input placeholder="Email" type="text" name="email" id="email" value="' . ( isset( $_POST['email']) ? $email : null ) . '" class="form-control validate[required,custom[email]] email" data-errormessage-value-missing="* Email is required" data-errormessage-custom-error="* Invalid email. Let me give you a hint: someone@nowhere.com" data-prompt-position="topLeft" >
</div>
<div class="form-group">
<input placeholder="Set Password" type="password" name="password" id="password" value="' . ( isset( $_POST['password'] ) ? $password : null ) . '" class="form-control validate[required,custom[password]] password" data-errormessage-value-missing="* Password is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<input placeholder="Confirm Password" type="password" name="confirm_password" id="confirm_password" value="' . ( isset( $_POST['confirm_password'] ) ? $confirm_password : null ) . '" class="form-control validate[required,equals[password]] confirm_password" data-errormessage-value-missing="* Confirm password is required" data-errormessage="* Confirm password field is not matching with password field" data-prompt-position="topLeft" >
<input type="hidden" name="arrayindex" id="arrayindex" value="1"/>
</div>
<div class="form-group">
<input placeholder="Distict/City" type="text" name="distict_city" id="distict_city" value="' . ( isset( $_POST['distict_city'] ) ? $distict_city : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* distict/city is required" data-prompt-position="topLeft">
</div>
<div class="form-group" id="invcodehide">
<input placeholder="Invitation Code*" type="text" name="invcode" id="invcode" value="' . ( isset( $_POST['invcode'] ) ? $invcode : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* Invitation Code is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<div id="locationField">
<input id="searchInput" placeholder="Search for your school.." type="text" class="controls search-school-inp"></input>
</div>
</div>
<div class="form-group"><br>
<div id="map"></div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Name</label>
<input placeholder="" type="text" name="school_name" id="school" value="' . ( isset( $_POST['school_name'] ) ? $school_name : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school name is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Address</label>
<input placeholder="" type="text" name="school_address" id="school_address" value="' . ( isset( $_POST['school_address'] ) ? $school_address : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school address is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type is required" data-prompt-position="topLeft">
<option value="">Select School Type </option>
<option value="Elementary School">Elementary School</option>
<option value="Middle School">Middle School</option>
<option value="High School">High School</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level is required" data-prompt-position="topLeft">
<option value="">Select Grade Level </option>
<option value="Pre K">Pre K </option>
<option value="K">K</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="other">other</option>
</select>
</div>
<div class="form-group check-main-box">
<input type="checkbox" name="vehicle" value="yes" class="form-control validate[required]" > Yes, I accept the <a href="../terms-conditions">Terms & Conditions</a> of & Demo.<br>
</div>
</div>
<input class="btn btn-primary btn-lg btn-block regbtn reg-btn-subb" type="submit" name="submit" value="Register"/>
</form>';
}
function registration_validation( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
global $reg_errors;
$reg_errors = new WP_Error;
global $wpdb;
if(username_exists($username)) {
// Username already registered
$reg_errors->add('username_unavailable', __('Username already taken'));
}
if(!validate_username($username)) {
// invalid username
$reg_errors->add('username_invalid', __('Invalid username'));
}
if ( 4 > strlen( $username ) ) {
$reg_errors->add( 'username_length', 'Username too short. At least 4 characters is required' );
}
if ($fname=="") {
$reg_errors->add( 'empty_fname', 'Required first name field missing' );
}
if ($lname=="") {
$reg_errors->add( 'empty_lname', 'Required last name field missing' );
}
if ( !is_email( $email ) ) {
$reg_errors->add( 'email_invalid', 'Email is not valid' );
}
if ( email_exists( $email ) ) {
$reg_errors->add( 'email', 'Email Already in use' );
}
if ($password=="") {
$reg_errors->add( 'empty_password', 'Required password field missing' );
}else
if ( 5 > strlen( $password ) ) {
$reg_errors->add( 'password', 'Password length must be greater than 5' );
}
if ($password!="") {
if($confirm_password=="")
$reg_errors->add( 'empty_cpassword', 'Required confirm password field missing' );
if($confirm_password!="" && ($confirm_password!=$password)){
$reg_errors->add( 'mismatch_cpassword', 'Required password and confirm password field is mismatch--'.$confirm_password."--".$password );
}
}
if ($school_name=="") {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 1){
$sql = "SELECT * FROM w9p_invitation_code where `invitation_code` = '$invcode' and status = '1';";
$pageposts = $wpdb->get_results($sql);
if(empty($pageposts))
{
$reg_errors->add( 'invcode', 'Invitation Code is not valid' );
}
}
if ($invcode=="" && $statusss == 1) {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
if ( is_wp_error( $reg_errors ) ) {
if ($reg_errors->get_error_messages()) {
echo '<div class="error-regi">';
foreach ( $reg_errors->get_error_messages() as $error ) {
echo '<p><strong>ERROR </strong>:';
echo $error . '</p>';
}
echo '</div>';
}
}
/* registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level
); */
}
function complete_registration() {
global $reg_errors, $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
if ( 1 > count( $reg_errors->get_error_messages() ) ) {
$userdata = array(
'user_login' => $username,
'user_email' => $email,
'user_pass' => $password,
'display_name' => $fname,
'first_name' => $fname,
'last_name' => $lname,
'user_status' => 1,
//'nickname' => $nickname,
//'description' => $bio,
);
$user = wp_insert_user( $userdata );
//$encpassword = base64_encode ($password);
//add_user_meta( $user, 'pwd', $encpassword);
add_user_meta( $user, 'account_type', $account_type);
add_user_meta( $user, 'distict_city', $distict_city);
add_user_meta( $user, 'school_address', $school_address);
add_user_meta( $user, 'school_type', $school_type);
add_user_meta( $user, 'school_name', $school_name);
add_user_meta( $user, 'grade_level', $grade_level);
add_user_meta( $user, 'invitation_code', $invcode);
//sending email for activation email.
$activation_email = activation_email($user);
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
//exit;
echo '<p class="regi-thanku">Registration complete.</p>';
$_POST = array();
?>
<script>
document.getElementById("regform").reset();
</script>
<?php
}
}
add_action('user_register','continue_to_registration');
function continue_to_registration($user_id) {
if(is_admin()){
$invcode = $_POST['fields']['field_5a8e6ccd1c8bc'];
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
}
}
function activation_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$subject = 'Activation Email';
$link = get_stylesheet_directory_uri()."/activation.php?userid=$userid";
$linkurl = "<a style='color:#333' href=$link>Activation Link</a>";
$message = get_header_email_template();
//$message .= "<p>Hello $username ,<br> Please click on below link to activate your account.<br> $link</p>";
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">Please click on below link to activate your account.<br> <br> '.$linkurl.'</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message, $headers)){
echo '<p class="regi-thanku">Thank You! Please check your email to activate your account.</p>';
// $location = home_url()."/login/?status=pending";
//wp_safe_redirect($location);
} else{
//echo 'Unable to send email. Please try again.';
}
//exit;
}
function after_activation_welcome_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$pwd = get_user_meta($userid,'pwd');
$pwdd = base64_decode($pwd[0]);
$subject = 'Welcome to Demo Portal
';
$link = site_url();
$linkurl = "<a style='color:#333' href=$link> Demo Portal </a>";
$message = get_header_email_template();
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
Thank you & Welcome to Demo Portal . <br> Your email is successfully verified.</p><br>
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
You can now login to the website and shop for the study material.</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message,$headers)){
echo 'Your mail has been sent successfully.';
} else{
// echo 'Unable to send email. Please try again.';
}
//exit;
}
function custom_registration_function() {
if ( isset($_POST['submit'] ) ) {
registration_validation(
$_POST['username'],
$_POST['fname'],
$_POST['lname'],
$_POST['email'],
$_POST['password'],
$_POST['confirm_password'],
$_POST['account_type'],
$_POST['distict_city'],
$_POST['school_name'],
$_POST['school_address'],
$_POST['school_type'],
$_POST['grade_level'],
$_POST['invcode']
);
// sanitize user form input
global $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
$username = sanitize_user( $_POST['username'] );
$password = esc_attr( $_POST['password'] );
$confirm_password = esc_attr( $_POST['confirm_password'] );
$email = sanitize_email( $_POST['email'] );
$fname = sanitize_text_field( $_POST['fname'] );
$lname = sanitize_text_field( $_POST['lname'] );
$account_type = sanitize_text_field( $_POST['account_type'] );
$distict_city = esc_textarea( $_POST['distict_city'] );
$school_name = esc_textarea( $_POST['school_name'] );
$school_address = esc_textarea( $_POST['school_address'] );
$school_type = $_POST['school_type'];
$grade_level = $_POST['grade_level'];
$invcode = $_POST['invcode'];
complete_registration(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
// Register a new shortcode: [cr_custom_registration]
add_shortcode( 'cr_custom_registration', 'custom_registration_shortcode' );
// The callback function that will replace [book]
function custom_registration_shortcode() {
ob_start();
custom_registration_function();
return ob_get_clean();
}
function get_header_email_template(){
$diruri = get_stylesheet_directory_uri();
$siteuri = site_url();
$header =
'
<style>
table { border:solid 1px #0056a2;margin:20px auto;line-height:20px;color:#666;}
table tr td {padding:10px;font-size:13px;}
.border-top {border-top:solid 1px #d7d7d7;}
.social_links a {display:inline-block;margin-left:5px;}
a{color:#ffffff;}
</style>
<body>
<table width="600" cellspacing="0" cellpadding="10" style="border:solid 2px #00582e; background:url('.$diruri.'/images/body_bg.jpg) no-repeat fixed center top / cover; border-radius:4px; margin:20px auto;line-height:20px;color:#666; font-family:Arial, Helvetica, sans-serif;">
<thead>
<tr bgcolor="">
<td align="left" style="padding:20px 30px;" title="Demo"><a href="'.$siteuri.'/about/welcome-letter/"><img width="100%" src="'.$diruri.'/images/logo.png"></a></td>
<td align="right" style="color:#ffffff; line-height:normal; padding:20px 30px;"><strong style="display:block; margin-top:22px;"></strong></td>
</tr>
<tr bgcolor="#dddddd">
<td style="padding:0px; height:1px;"></td>
<td style="padding:0px; height:1px;"></td>
</tr>
</thead>';
return $header;
}
function get_footer_email_template(){
$footer = '
<tr bgcolor="#ffffff">
<td colspan="2" style="color:#00582e; padding:0;"></td>
</tr>
<tr bgcolor="">
<td style="color:#fff;">
<strong style="color:#fff">Demo Portal </strong><br>
<strong>Email:</strong> <a href="mailto:info@Demo.com" style="color:#fff;">info@Demo.com</a></td>
<td width="50%" align="right" style="color:#fff;"> </td>
</tr>
</table></body></html> ';
return $footer;
}
function wpse_131562_redirect() {
if (
! is_user_logged_in() && !is_page(array( 31,147,16895,35,34,17026 ))
/* && (is_woocommerce() || is_cart() || is_checkout() || is_product() || is_singular( 'sfwd-courses' ) || is_singular( 'sfwd-topic' ) || is_page(array( 293,40,29,417,194, 16156, 16424, 7736, 16445, 16452 )) || is_post_type_archive( 'Demo' ) || is_singular( 'Demo' ))*/
) {
// feel free to customize the following line to suit your needs
//wp_redirect(home_url());
auth_redirect();
exit;
}
if (
is_user_logged_in()
&& (is_page(147))
) {
$location = home_url()."/courses-list/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit;
}
}
add_action('template_redirect', 'wpse_131562_redirect');
function so_27030769_maybe_empty_cart( $valid, $product_id, $quantity ) {
if( ! empty ( WC()->cart->get_cart() ) && $valid ){
WC()->cart->empty_cart();
wc_add_notice( 'Whoa hold up. You can only have an item in your cart', 'error' );
?>
<style>
.woocommerce-message {
display: none;
}
</style>
<?php
}
return $valid;
}
add_filter( 'woocommerce_add_to_cart_validation', 'so_27030769_maybe_empty_cart', 10, 3 );
/*
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['action']) && !empty($_POST['action'])) ) {
add_filter('login_redirect', 'my_login_redirect', 10, 3);
function my_login_redirect() {
$location = $_SERVER['HTTP_REFERER'];
$location = home_url()."/my-account/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit();
}
}
*/
/**
* Opening div for our content wrapper
*/
add_action('woocommerce_before_main_content', 'iconic_open_div', 5);
function iconic_open_div() {
echo '<div class="iconic-div">';
}
/**
* Closing div for our content wrapper
*/
add_action('woocommerce_after_main_content', 'iconic_close_div', 50);
function iconic_close_div() {
echo '</div>';
}
add_action( 'user_register', 'registration_save', 10, 1 );
function registration_save( $user_id ) {
if ( !isset( $_POST['password'] ) )
{
sleep(5);
$user_data = update_user_meta( $user_id, 'pw_user_status','approved' );
add_option( 'group_leader_id_'.$user_id, get_current_user_id() );
$distict_city = get_user_meta( get_current_user_id(), 'distict_city', true );
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
$school_type = get_user_meta( get_current_user_id(), 'school_type', true );
$school_name = get_user_meta( get_current_user_id(), 'school_name', true );
$grade_level = get_user_meta( get_current_user_id(), 'grade_level', true );
$user = new WP_User( get_current_user_id() );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
$people_role = $user->roles;
if (!in_array("administrator", $people_role) && in_array("group_leader", $people_role))
{
update_user_meta( $user_id, 'distict_city', $distict_city);
update_user_meta( $user_id, 'school_address', $school_address);
update_user_meta( $user_id, 'school_type', $school_type);
update_user_meta( $user_id, 'school_name', $school_name);
update_user_meta( $user_id, 'grade_level', $grade_level);
}
}
}
}
function admin_default_page() {
//return home_url().'/my-account/';
// return $_SERVER['HTTP_REFERER'];
}
//add_filter('login_redirect', 'admin_default_page');
function my_login_redirect( $redirect_to, $request, $user ){
//is there a user to check?
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if( in_array( "administrator", $user->roles ) ) {
// redirect them to the default place
return home_url(); //admin redirect url
} else {
return admin_url( 'edit.php?post_type=page' ); //user redirect url
}
}
else {
// return $redirect_to;
if($redirect_to==home_url()."/wp-admin/"){
return home_url().'/courses-list/';
}else{
return $redirect_to;
}
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
add_action( 'woocommerce_edit_account_form', 'my_woocommerce_edit_account_form' );
add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' );
function my_woocommerce_edit_account_form() {
$user_id = get_current_user_id();
$user = get_userdata( $user_id );
if ( !$user )
return;
$account_type = get_user_meta( $user_id, 'account_type', true );
$distict_city = get_user_meta( $user_id, 'distict_city', true );
$school_address = get_user_meta( $user_id, 'school_address', true );
$school_type = get_user_meta( $user_id, 'school_type', true );
$school_name = get_user_meta( $user_id, 'school_name', true );
$grade_level = get_user_meta( $user_id, 'grade_level', true );
$twitter = get_user_meta( $user_id, 'twitter', true );
$url = $user->user_url;
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Distict/City:</label>
<input type="text" name="distict_city" value="<?php echo esc_attr( $distict_city ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Name:</label>
<input type="text" name="school_name" value="<?php echo esc_attr( $school_name ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Address:</label>
<input type="text" name="school_address" value="<?php echo esc_attr( $school_address ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Type:</label>
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type required">
<option value="">Select School Type </option>
<option value="Elementary" <?php if($school_type=="Elementary") echo 'selected="selected"'; ?>>Elementary </option>
<option value="Middle School" <?php if($school_type=="Middle School") echo 'selected="selected"'; ?>>Middle School</option>
<option value="High School" <?php if($school_type=="High School") echo 'selected="selected"'; ?>>High School</option>
<option value="Other" <?php if($school_type=="Other") echo 'selected="selected"'; ?>>Other</option>
</select>
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Grade Level:</label>
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level required">
<option value="">Select Grade Level </option>
<option value="Pre K" <?php if($grade_level=="Pre K") echo 'selected="selected"'; ?> >Pre K </option>
<option value="K" <?php if($grade_level=="K") echo 'selected="selected"'; ?>>K</option>
<option value="1" <?php if($grade_level=="1") echo 'selected="selected"'; ?>>1</option>
<option value="2" <?php if($grade_level=="2") echo 'selected="selected"'; ?>>2</option>
<option value="3" <?php if($grade_level=="3") echo 'selected="selected"'; ?>>3</option>
<option value="4" <?php if($grade_level=="4") echo 'selected="selected"'; ?>>4</option>
<option value="5" <?php if($grade_level=="5") echo 'selected="selected"'; ?>>5</option>
<option value="6" <?php if($grade_level=="6") echo 'selected="selected"'; ?>>6</option>
<option value="7" <?php if($grade_level=="7") echo 'selected="selected"'; ?>>7</option>
<option value="8" <?php if($grade_level=="8") echo 'selected="selected"'; ?>>8</option>
<option value="9" <?php if($grade_level=="9") echo 'selected="selected"'; ?>>9</option>
<option value="10" <?php if($grade_level=="10") echo 'selected="selected"'; ?>>10</option>
<option value="11" <?php if($grade_level=="11") echo 'selected="selected"'; ?>>11</option>
<option value="12" <?php if($grade_level=="12") echo 'selected="selected"'; ?>>12</option>
<option value="other" <?php if($grade_level=="other") echo 'selected="selected"'; ?>>other</option>
</select>
</fieldset>
<?php /* ?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter"><?php _e('Main Profile Image', 'shr') ?></label>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</p>
</fieldset>
<?php */ ?>
<?php
}
function my_woocommerce_save_account_details( $user_id ) {
update_user_meta( $user_id, 'account_type', $_POST[ 'account_type' ]);
update_user_meta( $user_id, 'distict_city', $_POST[ 'distict_city' ]);
update_user_meta( $user_id, 'school_address', $_POST[ 'school_address' ]);
update_user_meta( $user_id, 'school_type', $_POST[ 'school_type' ]);
update_user_meta( $user_id, 'school_name', $_POST[ 'school_name' ]);
update_user_meta( $user_id, 'grade_level', $_POST[ 'grade_level' ]);
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
update_user_meta( $user_id, 'twitter', htmlentities( $_POST[ 'twitter' ] ) );
$user = wp_update_user( array( 'ID' => $user_id, 'user_url' => esc_url( $_POST[ 'url' ] ) ) );
}
add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' );
function misha_remove_my_account_links( $menu_links ){
$customer_orders = get_posts( array(
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => 'shop_order',
'post_status' => array_keys( wc_get_order_statuses() ),
'numberposts' => -1,
));
if ( $customer_orders ){
}else{
unset( $menu_links['edit-address'] ); // Addresses
unset( $menu_links['orders'] );
unset( $menu_links['downloads'] );
}
unset( $menu_links['edit-address'] );
//unset( $menu_links['dashboard'] ); // Dashboard
//unset( $menu_links['payment-methods'] ); // Payment Methods
//unset( $menu_links['orders'] ); // Orders
unset( $menu_links['downloads'] ); // Downloads
//unset( $menu_links['edit-account'] ); // Account details
//unset( $menu_links['customer-logout'] ); // Logout
return $menu_links;
}
function shr_add_admin_scriptss(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('admin_enqueue_scripts', 'shr_add_admin_scriptss');
function shr_add_admin_scripts(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('wp_enqueue_scripts', 'shr_add_admin_scripts');
function shr_extra_profile_fields( $user ) {
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
} ?>
<table class="form-table fh-profile-upload-options">
<tr>
<th>
<label for="image"><?php _e('Main Profile Image', 'shr') ?></label>
</th>
<td>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</td>
</tr>
</table><?php
}
add_action( 'show_user_profile', 'shr_extra_profile_fields' );
add_action( 'edit_user_profile', 'shr_extra_profile_fields' );
add_action( 'user_new_form', 'shr_extra_profile_fields' );
function shr_profile_update($user_id){
if( current_user_can('edit_users') ){
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
}
}
add_action('profile_update', 'shr_profile_update');
add_action('user_register', 'shr_profile_update');
//change the role to fit your needs
function enable_file_uploads_by_role( ) {
$role = 'subscriber';
if(!current_user_can($role) || current_user_can('upload_files'))
return;
$contributor = get_role( $role );
$contributor->add_cap('upload_files');
} add_action('admin_init', 'enable_file_uploads_by_role');
///// ************************************//////
/*----------------------------------------------------------------------------*
* Register custom post types
*----------------------------------------------------------------------------*/
add_action( 'init', 'fusion_register_post_types' );
function fusion_register_post_types() {
global $smof_data;
$permalinks = get_option( 'avada_permalinks' );
register_post_type(
'Demo',
array(
'labels' => array(
'name' => _x( 'Demo', 'Post Type General Name', 'fusion-core' ),
'singular_name' => _x( 'Demo', 'Post Type Singular Name', 'fusion-core' ),
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => $smof_data['Demo_slug']
),
'supports' => array( 'title', 'editor', 'author', 'excerpt', 'thumbnail', 'comments'),
'can_export' => true,
)
);
/*
register_taxonomy('iam_an', 'Demo',
array(
'hierarchical' => true,
'label' => __('I am a(n)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_iam_an_base'] ) ? _x( 'iam_an', 'slug', 'fusion-core' ) : $permalinks['Demo_iam_base'],
'with_front' => false
),
)
);*/
register_taxonomy('looking_for', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'Looking For', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['portfolio_looking_for_base'] ) ? _x( 'looking_for', 'slug', 'fusion-core' ) : $permalinks['portfolio_looking_for_base'],
'with_front' => false
),
)
);
register_taxonomy('about', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'About', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_about_base'] ) ? _x( 'about', 'slug', 'fusion-core' ) : $permalinks['Demo_about_base'],
'with_front' => false
),
)
);
register_taxonomy('age_group', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'For (Age group)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_age_group'] ) ? _x( 'age_group', 'slug', 'fusion-core' ) : $permalinks['Demo_age_group'],
'with_front' => false
),
)
);
register_taxonomy('Demo_tags', 'Demo',
array(
'hierarchical' => false,
'label' => __( 'Tags', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_tags_base'] ) ? _x( 'Demo_tags', 'slug', 'fusion-core' ) : $permalinks['Demo_tags_base'],
'with_front' => false
),
)
);
if( function_exists('qtrans_getLanguage') ) {
add_action('age_group_add_form', 'qtrans_modifyTermFormFor');
add_action('age_group_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_edit_form', 'qtrans_modifyTermFormFor');
add_action('faq_category_edit_form', 'qtrans_modifyTermFormFor');
}
}
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'Demo' )
{
return locate_template('archive-Demo.php'); // redirect to archive-search.php
}
return $template;
}
add_filter('template_include', 'template_chooser');
function limit_text($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
function wpsites_change_comment_form_submit_label($arg) {
$arg['label_submit'] = 'Post Feedback';
$arg['comment_field'] = '<p class="comment-form-comment"><label for="comment" >' . _x( 'Your Feedback Is Appreciated', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>';
$arg['title_reply'] = __('Leave Feedback');
return $arg;
}
add_filter('comment_form_defaults', 'wpsites_change_comment_form_submit_label');
function mytheme_comment($comment, $args, $depth) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body tt">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) //echo get_avatar( $comment, $args['avatar_size'] );
$current_user = wp_get_current_user();
$user = get_comment_author_link();
$current_user->display_name;
echo "<dl class='comments_boxses'>";
echo "<dt class=".strtoupper( $user[0] ).">".strtoupper( $user[0] )."</dt>";
?>
<dd>
<div class="author_heading"> <?php printf( __( '<div class="authorename fn">%s</div> ' ), get_comment_author_link() ); ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php //edit_comment_link( __( '(Edit)' ), ' ', '' );
?></div>
</div>
<div class="reply_text"><?php comment_text(); ?>
<span class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</span>
<?php if ( $comment->comment_approved == '0' ) : ?> <br />
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting for approved.' ); ?></em>
<br />
<?php endif; ?>
</div>
</dd>
</dl>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
add_action('user_register', 'save_user_notifaction_field');
function save_user_notifaction_field($user_id) {
$user_email = get_userdata($user_id)->user_email;
global $wpdb;
$wpdb->query("INSERT INTO `w9p_Demo_notification` (`id`, `user_id`, `user_email`, `post_count`, `post_id`) VALUES (NULL, '$user_id', '$user_email', '0', '0');");
}
function wcs_send_mail_on_publish_category_posts( $new_status, $old_status, $post ) {
global $post;
global $wpdb;
if ( 'publish' !== $new_status or 'publish' === $old_status ) return;
$posttype = "Demo";
if ($post->post_type == $posttype ) {
$post_id = $post->ID;
$wpdb->query("UPDATE `w9p_Demo_notification` SET `post_count` = post_count+1, `post_id` = CONCAT(post_id,',$post_id');");
$body = sprintf( 'Hey there is a new entry! See <%s %s>', get_permalink( $post ), $post->post_title );
}
}
add_action( 'transition_post_status', 'wcs_send_mail_on_publish_category_posts', 10, 3 );
add_action( 'wp_trash_post', 'function_to_run_on_post_trash' );
function function_to_run_on_post_trash( $post_id ){
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
global $wpdb;
$rid = ",".$post_id;
$wpdb->query("UPDATE w9p_Demo_notification SET post_id = REPLACE(post_id, '$rid', '');");
//wp_mail( 'samrat.p@edreamz.in', 'trash_post entry!', "trash" );
}
$new_general_setting = new new_general_setting();
class new_general_setting {
function new_general_setting( ) {
add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
}
function register_fields() {
register_setting( 'general', 'notification_show', 'esc_attr' );
add_settings_field('notification_show', '<label for="favorite_color">'.__('Show Notification?' , 'notification_show' ).'</label>' , array(&$this, 'fields_html') , 'general' );
register_setting( 'general', 'show_per_page', 'esc_attr' );
add_settings_field('show_per_page', '<label for="favorite_color">'.__('Notification Page Show Limit' , 'show_per_page' ).'</label>' , array(&$this, 'fields_htmls') , 'general' );
register_setting( 'general', 'show_add_content', 'esc_attr' );
add_settings_field('show_add_content', '<label for="favorite_color">'.__('Show Add Content' , 'show_add_content' ).'</label>' , array(&$this, 'fields_htmlss') , 'general' );
}
function fields_htmls() {
$show_per_page = get_option( 'show_per_page', '' );
?>
<input type="text" name="show_per_page" value="<?php echo $show_per_page; ?>" />
<?php
}
function fields_htmlss() {
$show_add_content = get_option( 'show_add_content', '' );
?>
<input type="checkbox" <?php if($show_add_content==1)echo 'checked="checked"'; ?> name="show_add_content" id="show_add_content" value="1">
<?php
}
function fields_html() {
$value = get_option( 'notification_show', '' );
?>
<input type="checkbox" <?php if($value==1)echo 'checked="checked"'; ?> name="notification_show" id="notification_show" value="1">
<a href="javascript:;" onclick="funDismiss()">Clear all notifications for all users</a>
<script>
function funDismiss(){
var r = confirm("Are you sure to clear all notifications for all users?");
if (r == true) {
jQuery.ajax({
type:'POST',
data:{action:'delete_noti'},
url: '<?php echo get_site_url(); ?>/wp-content/themes/midsets/action.php',
success: function(value) {
},
});
} else {
}
}
</script>
<?php
}
}
//new changes
require 'submit_Demo.php';
require 'resource_head.php';
if ( !current_user_can( 'administrator' )) {
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
remove_menu_page( 'admin.php?page=aiowpsec' );
remove_menu_page( 'aiowpsec' );
remove_menu_page( 'edit.php?post_type=acf' );
remove_menu_page( 'wpcf7' );
remove_menu_page( 'cfs' );
remove_menu_page( 'edit.php?post_type=cfs' );
remove_menu_page( 'w3tc_dashboard' );
remove_menu_page( 'invitation_details' );
remove_menu_page( 'yst_ga_dashboard' );
remove_menu_page( 'bws_panel' );
remove_menu_page( 'bhittani_plugin_kksr_settings' );
remove_menu_page( 'register-plus-redux' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=wpeditor_admin' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=invitation_details' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
?>
<style>
#toplevel_page_master-slider, #toplevel_page_edit-post_type-acf, #toplevel_page_wpeditor_admin{display:none;}
</style>
<?php
}
add_action( 'admin_menu', 'remove_menus' );
}
function cjobs_admin_head()
{
do_action('acf/input/admin_head');
}
add_action('admin_head', 'cjobs_admin_head');
function makeiframevideo($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
// Instagram
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"443\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframevideos($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
// Instagram
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"350\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframe($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
// Instagram
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"182\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
global $wpdb;
$title = $_POST['resource_title'];
$about=$_POST['about'];
$age_group=$_POST['age_group'];
$looking_for=$_POST['looking_for'];
$c_text = $_POST['c_text'];
$Demo_tags = $_POST['Demo_tags'];
$video_url = $_POST['video_url'];
$mindset_anchors = $_POST['mindset_anchors'];
$discussion_prompts = $_POST['discussion_prompts'];
$file_size = $_FILES['my_file_upload']['size'];
if ($file_size > 20971520){
}
// save code here
$my_post = array(
'post_title' => $_POST['resource_title'],
'post_content' => $c_text,
'post_type'=>'Demo',
'post_status' => 'pending',
'filter' => false,
'post_author' => get_current_user_id(),
);
// Insert the post into the database.
$post_id = wp_insert_post( $my_post );
wp_set_object_terms( $post_id, $looking_for, 'looking_for' );
wp_set_object_terms( $post_id, $age_group, 'age_group' );
wp_set_object_terms( $post_id, $about, 'about' );
wp_set_object_terms( $post_id, $Demo_tags, 'Demo_tags' );
if ( !function_exists('wp_handle_upload') ) {
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}
if($_FILES['my_image_upload']['name']!=""){
$movefile = wp_handle_upload( $_FILES['my_image_upload'], array('test_form' => false) );
}
// If move was successful, insert WordPress attachment
if ( $movefile && !isset($movefile['error']) ) {
$wp_upload_dir = wp_upload_dir();
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename($movefile['file']),
'post_mime_type' => $movefile['type'],
'post_title' => preg_replace( '/\.[^.]+$/', "", basename($movefile['file']) ),
'post_content' => "",
'post_status' => 'inherit'
);
if($_FILES['my_image_upload']['name']!=""){
$attach_id = wp_insert_attachment($attachment, $movefile['file']);
$thumbnail_image_url = wp_get_attachment_url( $attach_id );
update_field('thumbnail_image', $attach_id, $post_id);
}
if($_FILES['my_file_upload']['name']!=""){
$attachment_id = media_handle_upload( 'my_file_upload', $post_id );
$attachment_url = wp_get_attachment_url( $attachment_id );
update_field('attach_file', $attachment_id, $post_id);
}
}
update_field('video_url', $video_url, $post_id);
update_field('mindset_anchors', $mindset_anchors, $post_id);
update_field('discussion_prompts', $discussion_prompts, $post_id);
$current_user = wp_get_current_user();
$email = $current_user->user_email;
$user_id = $current_user->ID;
$cdate = date("Y-m-d H:i:s");
$sql = "INSERT INTO `wp_Demo` (`id`, `pid`, `user_id`, `user_email`, `title`, `content`, `Demo_tags`, `video_url`, `mindset_anchors`, `discussion_prompts`, `attach_file`, `thumbnail_image`, `looking_for`, `about`, `age_group`, `status`, `date`) VALUES (NULL, '$post_id', '$user_id', '$email', '$title', '$c_text', '$Demo_tags', '$video_url', '$mindset_anchors', '$discussion_prompts', '$attachment_url', '$thumbnail_image_url', '$looking_for', '$about', '$age_group', '0', '$cdate');";
$wpdb->query($sql);
return $post_id;
}
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
//wp_deregister_style( 'amethyst-dashicons-style' );
wp_deregister_style( 'common' );
}
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
.acf-image-uploader img {
width: 48%;
}
</style>';
}
//samrat
//add_filter( 'login_redirect', 'skp_login_redirect', 10, 3 );
function my_force_logins() {
global $post;
if (!is_user_logged_in()) {
//auth_redirect();
wp_redirect( $_SERVER["REQUEST_URI"] );
}
}
function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
// Validate inputs.
if ( ! $url || ( ! $width && ! $height ) ) return $url;
// Caipt'n, ready to hook.
if ( true === $upscale ) add_filter( 'image_resize_dimensions', 'aq_upscale', 10, 6 );
// Define upload path & dir.
$upload_info = wp_upload_dir();
$upload_dir = $upload_info['basedir'];
$upload_url = $upload_info['baseurl'];
$http_prefix = "http://";
$https_prefix = "https://";
/* if the $url scheme differs from $upload_url scheme, make them match
if the schemes differe, images don't show up. */
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
}
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
}
// Check if $img_url is local.
if ( false === strpos( $url, $upload_url ) ) return $url;
// Define path of image.
$rel_path = str_replace( $upload_url, '', $url );
$img_path = $upload_dir . $rel_path;
// Check if img path exists, and is an image indeed.
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return $url;
// Get image info.
$info = pathinfo( $img_path );
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $img_path );
// Get image size after cropping.
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
$dst_w = $dims[4];
$dst_h = $dims[5];
// Return the original image only if it exactly fits the needed measures.
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
$img_url = $url;
$dst_w = $orig_w;
$dst_h = $orig_h;
} else {
// Use this to check if cropped image already exists, so we can return that instead.
$suffix = "{$dst_w}x{$dst_h}";
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
// Can't resize, so return origin image url.
return $url;
}
// Else check if cache exists.
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
}
// Else, we resize the image and return the new resized image url.
else {
// Note: This pre-3.5 fallback check will edited out in subsequent version.
if ( function_exists( 'wp_get_image_editor' ) ) {
$editor = wp_get_image_editor( $img_path );
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
return $url;
$resized_file = $editor->save();
if ( ! is_wp_error( $resized_file ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
} else {
$resized_img_path = image_resize( $img_path, $width, $height, $crop ); // Fallback foo.
if ( ! is_wp_error( $resized_img_path ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_img_path );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
}
}
}
// Okay, leave the ship.
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', 'aq_upscale' );
// Return the output.
if ( $single ) {
// str return.
$image = $img_url;
} else {
// array return.
$image = array (
0 => $img_url,
1 => $dst_w,
2 => $dst_h
);
}
return $image;
}
function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
if ( ! $crop ) return $url; // Let the wordpress default function handle this.
// Here is the point we allow to use larger image size than the original one.
$aspect_ratio = $orig_w / $orig_h;
$new_w = $dest_w;
$new_h = $dest_h;
if ( ! $new_w ) {
$new_w = intval( $new_h * $aspect_ratio );
}
if ( ! $new_h ) {
$new_h = intval( $new_w / $aspect_ratio );
}
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
$crop_w = round( $new_w / $size_ratio );
$crop_h = round( $new_h / $size_ratio );
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
/*
add_action( 'wp_default_scripts', function( $scripts ) {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) );
}
} );
*/
add_filter( 'auto_update_plugin', '__return_false' );
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');
function wpb_get_post_views($postID){
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
$count = round($count/2);
return $count.' Views';
}
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
// Disable REST API link tag
remove_action('wp_head', 'rest_output_link_wp_head', 10);
// Disable oEmbed Discovery Links
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
// Disable REST API link in HTTP headers
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
add_action('admin_head', 'my_custom_fontss');
function my_custom_fontss() {
echo '<style>
#toplevel_page_invitation_details li:nth-child(4){
display:none;
}
#toplevel_page_invitation_details li:nth-child(6){
display:none;
}
</style>';
}
add_filter( 'manage_edit-groups_columns', 'my_edit_groups_columns' ) ;
function my_edit_groups_columns( $columns ) {
$columns_new = array();
foreach( $columns as $col_key => $col_label ) {
if ($col_key == 'date') {
//$columns_new['groups_group_leaders'] = __('Group Information', 'learndash');
$columns_new['school_name'] = __( 'Group Information', 'learndash' );
$columns_new['groups_group_courses'] = sprintf( _x('Group %s', 'Group Courses', 'learndash'), LearnDash_Custom_Label::get_label( 'courses' ));
$columns_new['groups_group_users'] = __('Group Users', 'learndash');
}
$columns_new[$col_key] = $col_label;
}
return $columns_new;
}
/*
// Add the custom columns to the book post type:
add_filter( 'manage_groups_posts_columns', 'set_custom_edit_book_columns' );
function set_custom_edit_book_columns($columns) {
$columns['school_name'] = __( 'School Name', 'your_text_domain' );
return $columns;
}
*/
// Add the data to the custom columns for the book post type:
add_action( 'manage_groups_posts_custom_column' , 'custom_book_column', 1, 2 );
function custom_book_column( $column, $post_id ) {
switch ( $column ) {
case 'school_name':
$group_leaders = learndash_get_groups_administrator_ids( $post_id );
foreach( $group_leaders as $user_id ) {
$user = get_user_by( 'id', $user_id );
echo "<b>School: ".get_user_meta( $user_id, 'school_name', true )."</b><br>";
echo 'Name: <a href="'. get_edit_user_link( $user_id ) .'">'. $user->first_name .' '.$user->last_name .'</a><br>';
}
break;
}
}
function wpachievements_myachievements_func_new( $atts ) {
if( is_user_logged_in() ){
extract( shortcode_atts( array(
'user_id' => '',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $current_user, $wpdb;
get_currentuserinfo();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
//$myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', WPACHIEVEMENTS_TEXT_DOMAIN) .'</h3>';
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
if(function_exists('is_multisite') && is_multisite()){
$sim_ach = get_blog_option(1,'wpachievements_sim_ach');
} else{
$sim_ach = get_option('wpachievements_sim_ach');
}
$ii=0;
$iii=0;
$achievement_badges='';
if( !empty($userachievement) && $userachievement != '' ){
if(function_exists('is_multisite') && is_multisite()){
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'true'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(function_exists('is_multisite') && is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
$myachievements .= '</div>';
return $myachievements;
}
}
add_shortcode( 'wpa_myachievements_new', 'wpachievements_myachievements_func_new' );
// Register and load the widget
function wpb_load_widget() {
register_widget( 'wpb_widget' );
}
add_action( 'widgets_init', 'wpb_load_widget' );
// Creating the widget
class wpb_widget extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widget',
// Widget name will appear in UI
__('Achievements Widget', 'wpb_widget_domain'),
// Widget description
array( 'description' => __( 'Sample widget based on Achievements', 'wpb_widget_domain' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
// This is where you run the code and display the output
//echo __( 'Hello, World!', 'wpb_widget_domain' );
if( is_user_logged_in() ){
echo "<div class='achievements_users'>";
?>
<div class="image-users-wrp">
<div class="image">
<?php
$user_id = get_current_user_id();
/*
$user = get_userdata( $user_id );
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
*/
$profile_img = 'profile_img';
$profile_pic = get_post_meta($user_id, $profile_img, true);
if(empty($profile_pic)){ ?>
<img src="<?php echo home_url(); ?>/wp-content/uploads/2017/12/user-icon.png" class="user-icon" />
<?php }else{ ?>
<img class="user-icon" src="<?php echo home_url("/img/").$profile_pic; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?>" />
<?php } ?>
</div>
<div class="user-info">
<?php
$current_user = wp_get_current_user();
echo "<b>".$current_user->user_firstname ." ". $current_user->user_lastname."</b><br>";
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
echo $school_name = get_user_meta( get_current_user_id(), 'school_name', true );
?>
</div>
</div>
<?php
echo "<div class='achievements'>";
extract( shortcode_atts( array(
'user_id' => '',
'show_title' => 'true',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $wpdb;
$current_user = wp_get_current_user();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = (array) get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
if( $show_title == 'true' || $show_title == 'True' ){
// $myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', 'wpachievements') .'</h3>';
}
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
$sim_ach = wpachievements_get_site_option( 'wpachievements_sim_ach' );
$ii=0;
$iii=0;
$achievement_badges = array();
if ( ! empty( $userachievement ) ) {
if( is_multisite() ) {
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_woopoints = get_post_meta( $ach_ID, '_achievement_woo_points', true );
$ach_rank = get_post_meta( $ach_ID, '_achievement_rank', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'yes'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
$myachievements .= '</div></div>';
echo $myachievements;
echo '</div>';
echo '</div>';
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<!--<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>-->
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgets() {
register_widget( 'wpb_widgets' );
}
add_action( 'widgets_init', 'wpb_load_widgets' );
// Creating the widget
class wpb_widgets extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgets',
// Widget name will appear in UI
__('Quick Training', 'wpb_widget_domainss'),
// Widget description
array( 'description' => __( 'Sample widget based on Quick Training', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
$value = get_field( "quick_training", get_the_ID() );
echo '<h2 class="widget-title">Quick Training</h2>';
if($value){
echo $value;
}else{
echo "<style>#wpb_widgets-2{display:none;}</style>";
echo "<style>#wpb_widgets-3{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgetss() {
register_widget( 'wpb_widgetss' );
}
add_action( 'widgets_init', 'wpb_load_widgetss' );
// Creating the widget
class wpb_widgetss extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgetss',
// Widget name will appear in UI
__('Rating', 'wpb_widget_domainsss'),
// Widget description
array( 'description' => __( 'Sample widget based on Rating', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( is_singular( 'sfwd-topic' ) ) {
if(function_exists('the_ratings')){ the_ratings(); }
}else{
echo "<style>#wpb_widgetss-2{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
function register_my_session(){
if( !session_id() ){
session_start();
}
}
add_action('init', 'register_my_session');
//require 'rate-lessons.php';
function bartag_func( $atts ) {
return get_the_title( get_the_ID() );
}
add_shortcode( 'lesson-name', 'bartag_func' );
/*
function iconic_account_menu_items( $items ) {
$items['manage-content'] = __( 'Manage Content', 'iconic' );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'iconic_account_menu_items', 10, 1 );
*/
}
}
add_action('init', 'register_my_session');
//require 'rate-lessons.php';
function bartag_func( $atts ) {
return get_the_title( get_the_ID() );
}
add_shortcode( 'lesson-name', 'bartag_func' );
/*
function iconic_account_menu_items( $items ) {
$items['manage-content'] = __( 'Manage Content', 'iconic' );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'iconic_account_menu_items', 10, 1 );
*/
/*
add_action( 'wp_enqueue_scripts', 'mpcth_child_enqueue_scripts', 1000 );
function mpcth_child_enqueue_scripts() {
wp_enqueue_style( 'mpc-styles-child', get_stylesheet_directory_uri() . '/style_custom.css' );
}
*/
function registration_form( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
?>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 260px;
}
</style>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -33.8688, lng: 151.2195},
zoom: 13
});
var input = document.getElementById('searchInput');
// map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
map: map,
anchorPoint: new google.maps.Point(0, -29)
});
autocomplete.addListener('place_changed', function() {
infowindow.close();
marker.setVisible(false);
var place = autocomplete.getPlace();
if (!place.geometry) {
window.alert("Autocomplete's returned place contains no geometry");
return;
}
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
marker.setIcon(({
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(35, 35)
}));
marker.setPosition(place.geometry.location);
marker.setVisible(true);
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] && place.address_components[0].short_name || ''),
(place.address_components[1] && place.address_components[1].short_name || ''),
(place.address_components[2] && place.address_components[2].short_name || '')
].join(' ');
}
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
infowindow.open(map, marker);
//Location details
for (var i = 0; i < place.address_components.length; i++) {
if(place.address_components[i].types[0] == 'postal_code'){
// document.getElementById('postal_code').innerHTML = place.address_components[i].long_name;
}
if(place.address_components[i].types[0] == 'country'){
// document.getElementById('country').innerHTML = place.address_components[i].long_name;
}
}
document.getElementById("school").value = "";
document.getElementById("school_address").value = "";
document.getElementById("school").value = place.name;
document.getElementById("school_address").value = place.formatted_address;
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA3rAnj20W3D99Am3KiVer8TQ5LRfsWfJE&libraries=places&callback=initMap"
async defer></script>
<?php
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 0){
?>
<style>
#invcodehide{display:none !important;}
</style>
<?php
}
?>
<?php
echo '
<form id="regform" action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<!--<div class="regi-loginpage-btn"><p>Aleady have an account? <a href="login">Log In</a></p></div>-->
<div class="form-group">
<input placeholder="username" type="text" name="username" id="username" value="' . ( isset( $_POST['username']) ? $username : null ) . '" class="form-control validate[required] username" data-errormessage-value-missing="* username is required" data-prompt-position="topLeft" >
</div>
<div class="cust_transpernt_form">
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 fir">
<div class="form-group">
<input placeholder="First Name" type="text" name="fname" id="fname" value="' . ( isset( $_POST['fname']) ? $fname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] fname" data-errormessage-value-missing="* First name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 sec">
<div class="form-group">
<input placeholder="Last Name" type="text" name="lname" id="lname" value="' . ( isset( $_POST['lname']) ? $lname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] lname" data-errormessage-value-missing="* Last name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<input placeholder="Email" type="text" name="email" id="email" value="' . ( isset( $_POST['email']) ? $email : null ) . '" class="form-control validate[required,custom[email]] email" data-errormessage-value-missing="* Email is required" data-errormessage-custom-error="* Invalid email. Let me give you a hint: someone@nowhere.com" data-prompt-position="topLeft" >
</div>
<div class="form-group">
<input placeholder="Set Password" type="password" name="password" id="password" value="' . ( isset( $_POST['password'] ) ? $password : null ) . '" class="form-control validate[required,custom[password]] password" data-errormessage-value-missing="* Password is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<input placeholder="Confirm Password" type="password" name="confirm_password" id="confirm_password" value="' . ( isset( $_POST['confirm_password'] ) ? $confirm_password : null ) . '" class="form-control validate[required,equals[password]] confirm_password" data-errormessage-value-missing="* Confirm password is required" data-errormessage="* Confirm password field is not matching with password field" data-prompt-position="topLeft" >
<input type="hidden" name="arrayindex" id="arrayindex" value="1"/>
</div>
<div class="form-group">
<input placeholder="Distict/City" type="text" name="distict_city" id="distict_city" value="' . ( isset( $_POST['distict_city'] ) ? $distict_city : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* distict/city is required" data-prompt-position="topLeft">
</div>
<div class="form-group" id="invcodehide">
<input placeholder="Invitation Code*" type="text" name="invcode" id="invcode" value="' . ( isset( $_POST['invcode'] ) ? $invcode : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* Invitation Code is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<div id="locationField">
<input id="searchInput" placeholder="Search for your school.." type="text" class="controls search-school-inp"></input>
</div>
</div>
<div class="form-group"><br>
<div id="map"></div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Name</label>
<input placeholder="" type="text" name="school_name" id="school" value="' . ( isset( $_POST['school_name'] ) ? $school_name : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school name is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Address</label>
<input placeholder="" type="text" name="school_address" id="school_address" value="' . ( isset( $_POST['school_address'] ) ? $school_address : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school address is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type is required" data-prompt-position="topLeft">
<option value="">Select School Type </option>
<option value="Elementary School">Elementary School</option>
<option value="Middle School">Middle School</option>
<option value="High School">High School</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level is required" data-prompt-position="topLeft">
<option value="">Select Grade Level </option>
<option value="Pre K">Pre K </option>
<option value="K">K</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="other">other</option>
</select>
</div>
<div class="form-group check-main-box">
<input type="checkbox" name="vehicle" value="yes" class="form-control validate[required]" > Yes, I accept the <a href="../terms-conditions">Terms & Conditions</a> of & Demo.<br>
</div>
</div>
<input class="btn btn-primary btn-lg btn-block regbtn reg-btn-subb" type="submit" name="submit" value="Register"/>
</form>';
}
function registration_validation( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
global $reg_errors;
$reg_errors = new WP_Error;
global $wpdb;
if(username_exists($username)) {
// Username already registered
$reg_errors->add('username_unavailable', __('Username already taken'));
}
if(!validate_username($username)) {
// invalid username
$reg_errors->add('username_invalid', __('Invalid username'));
}
if ( 4 > strlen( $username ) ) {
$reg_errors->add( 'username_length', 'Username too short. At least 4 characters is required' );
}
if ($fname=="") {
$reg_errors->add( 'empty_fname', 'Required first name field missing' );
}
if ($lname=="") {
$reg_errors->add( 'empty_lname', 'Required last name field missing' );
}
if ( !is_email( $email ) ) {
$reg_errors->add( 'email_invalid', 'Email is not valid' );
}
if ( email_exists( $email ) ) {
$reg_errors->add( 'email', 'Email Already in use' );
}
if ($password=="") {
$reg_errors->add( 'empty_password', 'Required password field missing' );
}else
if ( 5 > strlen( $password ) ) {
$reg_errors->add( 'password', 'Password length must be greater than 5' );
}
if ($password!="") {
if($confirm_password=="")
$reg_errors->add( 'empty_cpassword', 'Required confirm password field missing' );
if($confirm_password!="" && ($confirm_password!=$password)){
$reg_errors->add( 'mismatch_cpassword', 'Required password and confirm password field is mismatch--'.$confirm_password."--".$password );
}
}
if ($school_name=="") {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 1){
$sql = "SELECT * FROM w9p_invitation_code where `invitation_code` = '$invcode' and status = '1';";
$pageposts = $wpdb->get_results($sql);
if(empty($pageposts))
{
$reg_errors->add( 'invcode', 'Invitation Code is not valid' );
}
}
if ($invcode=="" && $statusss == 1) {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
if ( is_wp_error( $reg_errors ) ) {
if ($reg_errors->get_error_messages()) {
echo '<div class="error-regi">';
foreach ( $reg_errors->get_error_messages() as $error ) {
echo '<p><strong>ERROR </strong>:';
echo $error . '</p>';
}
echo '</div>';
}
}
/* registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level
); */
}
function complete_registration() {
global $reg_errors, $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
if ( 1 > count( $reg_errors->get_error_messages() ) ) {
$userdata = array(
'user_login' => $username,
'user_email' => $email,
'user_pass' => $password,
'display_name' => $fname,
'first_name' => $fname,
'last_name' => $lname,
'user_status' => 1,
//'nickname' => $nickname,
//'description' => $bio,
);
$user = wp_insert_user( $userdata );
//$encpassword = base64_encode ($password);
//add_user_meta( $user, 'pwd', $encpassword);
add_user_meta( $user, 'account_type', $account_type);
add_user_meta( $user, 'distict_city', $distict_city);
add_user_meta( $user, 'school_address', $school_address);
add_user_meta( $user, 'school_type', $school_type);
add_user_meta( $user, 'school_name', $school_name);
add_user_meta( $user, 'grade_level', $grade_level);
add_user_meta( $user, 'invitation_code', $invcode);
//sending email for activation email.
$activation_email = activation_email($user);
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
//exit;
echo '<p class="regi-thanku">Registration complete.</p>';
$_POST = array();
?>
<script>
document.getElementById("regform").reset();
</script>
<?php
}
}
add_action('user_register','continue_to_registration');
function continue_to_registration($user_id) {
if(is_admin()){
$invcode = $_POST['fields']['field_5a8e6ccd1c8bc'];
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
}
}
function activation_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$subject = 'Activation Email';
$link = get_stylesheet_directory_uri()."/activation.php?userid=$userid";
$linkurl = "<a style='color:#333' href=$link>Activation Link</a>";
$message = get_header_email_template();
//$message .= "<p>Hello $username ,<br> Please click on below link to activate your account.<br> $link</p>";
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">Please click on below link to activate your account.<br> <br> '.$linkurl.'</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message, $headers)){
echo '<p class="regi-thanku">Thank You! Please check your email to activate your account.</p>';
// $location = home_url()."/login/?status=pending";
//wp_safe_redirect($location);
} else{
//echo 'Unable to send email. Please try again.';
}
//exit;
}
function after_activation_welcome_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$pwd = get_user_meta($userid,'pwd');
$pwdd = base64_decode($pwd[0]);
$subject = 'Welcome to Demo Portal
';
$link = site_url();
$linkurl = "<a style='color:#333' href=$link> Demo Portal </a>";
$message = get_header_email_template();
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
Thank you & Welcome to Demo Portal . <br> Your email is successfully verified.</p><br>
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
You can now login to the website and shop for the study material.</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message,$headers)){
echo 'Your mail has been sent successfully.';
} else{
// echo 'Unable to send email. Please try again.';
}
//exit;
}
function custom_registration_function() {
if ( isset($_POST['submit'] ) ) {
registration_validation(
$_POST['username'],
$_POST['fname'],
$_POST['lname'],
$_POST['email'],
$_POST['password'],
$_POST['confirm_password'],
$_POST['account_type'],
$_POST['distict_city'],
$_POST['school_name'],
$_POST['school_address'],
$_POST['school_type'],
$_POST['grade_level'],
$_POST['invcode']
);
// sanitize user form input
global $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
$username = sanitize_user( $_POST['username'] );
$password = esc_attr( $_POST['password'] );
$confirm_password = esc_attr( $_POST['confirm_password'] );
$email = sanitize_email( $_POST['email'] );
$fname = sanitize_text_field( $_POST['fname'] );
$lname = sanitize_text_field( $_POST['lname'] );
$account_type = sanitize_text_field( $_POST['account_type'] );
$distict_city = esc_textarea( $_POST['distict_city'] );
$school_name = esc_textarea( $_POST['school_name'] );
$school_address = esc_textarea( $_POST['school_address'] );
$school_type = $_POST['school_type'];
$grade_level = $_POST['grade_level'];
$invcode = $_POST['invcode'];
complete_registration(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
// Register a new shortcode: [cr_custom_registration]
add_shortcode( 'cr_custom_registration', 'custom_registration_shortcode' );
// The callback function that will replace [book]
function custom_registration_shortcode() {
ob_start();
custom_registration_function();
return ob_get_clean();
}
function get_header_email_template(){
$diruri = get_stylesheet_directory_uri();
$siteuri = site_url();
$header =
'
<style>
table { border:solid 1px #0056a2;margin:20px auto;line-height:20px;color:#666;}
table tr td {padding:10px;font-size:13px;}
.border-top {border-top:solid 1px #d7d7d7;}
.social_links a {display:inline-block;margin-left:5px;}
a{color:#ffffff;}
</style>
<body>
<table width="600" cellspacing="0" cellpadding="10" style="border:solid 2px #00582e; background:url('.$diruri.'/images/body_bg.jpg) no-repeat fixed center top / cover; border-radius:4px; margin:20px auto;line-height:20px;color:#666; font-family:Arial, Helvetica, sans-serif;">
<thead>
<tr bgcolor="">
<td align="left" style="padding:20px 30px;" title="Demo"><a href="'.$siteuri.'/about/welcome-letter/"><img width="100%" src="'.$diruri.'/images/logo.png"></a></td>
<td align="right" style="color:#ffffff; line-height:normal; padding:20px 30px;"><strong style="display:block; margin-top:22px;"></strong></td>
</tr>
<tr bgcolor="#dddddd">
<td style="padding:0px; height:1px;"></td>
<td style="padding:0px; height:1px;"></td>
</tr>
</thead>';
return $header;
}
function get_footer_email_template(){
$footer = '
<tr bgcolor="#ffffff">
<td colspan="2" style="color:#00582e; padding:0;"></td>
</tr>
<tr bgcolor="">
<td style="color:#fff;">
<strong style="color:#fff">Demo Portal </strong><br>
<strong>Email:</strong> <a href="mailto:info@Demo.com" style="color:#fff;">info@Demo.com</a></td>
<td width="50%" align="right" style="color:#fff;"> </td>
</tr>
</table></body></html> ';
return $footer;
}
function wpse_131562_redirect() {
if (
! is_user_logged_in() && !is_page(array( 31,147,16895,35,34,17026 ))
/* && (is_woocommerce() || is_cart() || is_checkout() || is_product() || is_singular( 'sfwd-courses' ) || is_singular( 'sfwd-topic' ) || is_page(array( 293,40,29,417,194, 16156, 16424, 7736, 16445, 16452 )) || is_post_type_archive( 'Demo' ) || is_singular( 'Demo' ))*/
) {
// feel free to customize the following line to suit your needs
//wp_redirect(home_url());
auth_redirect();
exit;
}
if (
is_user_logged_in()
&& (is_page(147))
) {
$location = home_url()."/courses-list/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit;
}
}
add_action('template_redirect', 'wpse_131562_redirect');
function so_27030769_maybe_empty_cart( $valid, $product_id, $quantity ) {
if( ! empty ( WC()->cart->get_cart() ) && $valid ){
WC()->cart->empty_cart();
wc_add_notice( 'Whoa hold up. You can only have an item in your cart', 'error' );
?>
<style>
.woocommerce-message {
display: none;
}
</style>
<?php
}
return $valid;
}
add_filter( 'woocommerce_add_to_cart_validation', 'so_27030769_maybe_empty_cart', 10, 3 );
/*
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['action']) && !empty($_POST['action'])) ) {
add_filter('login_redirect', 'my_login_redirect', 10, 3);
function my_login_redirect() {
$location = $_SERVER['HTTP_REFERER'];
$location = home_url()."/my-account/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit();
}
}
*/
/**
* Opening div for our content wrapper
*/
add_action('woocommerce_before_main_content', 'iconic_open_div', 5);
function iconic_open_div() {
echo '<div class="iconic-div">';
}
/**
* Closing div for our content wrapper
*/
add_action('woocommerce_after_main_content', 'iconic_close_div', 50);
function iconic_close_div() {
echo '</div>';
}
add_action( 'user_register', 'registration_save', 10, 1 );
function registration_save( $user_id ) {
if ( !isset( $_POST['password'] ) )
{
sleep(5);
$user_data = update_user_meta( $user_id, 'pw_user_status','approved' );
add_option( 'group_leader_id_'.$user_id, get_current_user_id() );
$distict_city = get_user_meta( get_current_user_id(), 'distict_city', true );
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
$school_type = get_user_meta( get_current_user_id(), 'school_type', true );
$school_name = get_user_meta( get_current_user_id(), 'school_name', true );
$grade_level = get_user_meta( get_current_user_id(), 'grade_level', true );
$user = new WP_User( get_current_user_id() );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
$people_role = $user->roles;
if (!in_array("administrator", $people_role) && in_array("group_leader", $people_role))
{
update_user_meta( $user_id, 'distict_city', $distict_city);
update_user_meta( $user_id, 'school_address', $school_address);
update_user_meta( $user_id, 'school_type', $school_type);
update_user_meta( $user_id, 'school_name', $school_name);
update_user_meta( $user_id, 'grade_level', $grade_level);
}
}
}
}
function admin_default_page() {
//return home_url().'/my-account/';
// return $_SERVER['HTTP_REFERER'];
}
//add_filter('login_redirect', 'admin_default_page');
function my_login_redirect( $redirect_to, $request, $user ){
//is there a user to check?
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if( in_array( "administrator", $user->roles ) ) {
// redirect them to the default place
return home_url(); //admin redirect url
} else {
return admin_url( 'edit.php?post_type=page' ); //user redirect url
}
}
else {
// return $redirect_to;
if($redirect_to==home_url()."/wp-admin/"){
return home_url().'/courses-list/';
}else{
return $redirect_to;
}
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
add_action( 'woocommerce_edit_account_form', 'my_woocommerce_edit_account_form' );
add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' );
function my_woocommerce_edit_account_form() {
$user_id = get_current_user_id();
$user = get_userdata( $user_id );
if ( !$user )
return;
$account_type = get_user_meta( $user_id, 'account_type', true );
$distict_city = get_user_meta( $user_id, 'distict_city', true );
$school_address = get_user_meta( $user_id, 'school_address', true );
$school_type = get_user_meta( $user_id, 'school_type', true );
$school_name = get_user_meta( $user_id, 'school_name', true );
$grade_level = get_user_meta( $user_id, 'grade_level', true );
$twitter = get_user_meta( $user_id, 'twitter', true );
$url = $user->user_url;
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Distict/City:</label>
<input type="text" name="distict_city" value="<?php echo esc_attr( $distict_city ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Name:</label>
<input type="text" name="school_name" value="<?php echo esc_attr( $school_name ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Address:</label>
<input type="text" name="school_address" value="<?php echo esc_attr( $school_address ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Type:</label>
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type required">
<option value="">Select School Type </option>
<option value="Elementary" <?php if($school_type=="Elementary") echo 'selected="selected"'; ?>>Elementary </option>
<option value="Middle School" <?php if($school_type=="Middle School") echo 'selected="selected"'; ?>>Middle School</option>
<option value="High School" <?php if($school_type=="High School") echo 'selected="selected"'; ?>>High School</option>
<option value="Other" <?php if($school_type=="Other") echo 'selected="selected"'; ?>>Other</option>
</select>
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Grade Level:</label>
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level required">
<option value="">Select Grade Level </option>
<option value="Pre K" <?php if($grade_level=="Pre K") echo 'selected="selected"'; ?> >Pre K </option>
<option value="K" <?php if($grade_level=="K") echo 'selected="selected"'; ?>>K</option>
<option value="1" <?php if($grade_level=="1") echo 'selected="selected"'; ?>>1</option>
<option value="2" <?php if($grade_level=="2") echo 'selected="selected"'; ?>>2</option>
<option value="3" <?php if($grade_level=="3") echo 'selected="selected"'; ?>>3</option>
<option value="4" <?php if($grade_level=="4") echo 'selected="selected"'; ?>>4</option>
<option value="5" <?php if($grade_level=="5") echo 'selected="selected"'; ?>>5</option>
<option value="6" <?php if($grade_level=="6") echo 'selected="selected"'; ?>>6</option>
<option value="7" <?php if($grade_level=="7") echo 'selected="selected"'; ?>>7</option>
<option value="8" <?php if($grade_level=="8") echo 'selected="selected"'; ?>>8</option>
<option value="9" <?php if($grade_level=="9") echo 'selected="selected"'; ?>>9</option>
<option value="10" <?php if($grade_level=="10") echo 'selected="selected"'; ?>>10</option>
<option value="11" <?php if($grade_level=="11") echo 'selected="selected"'; ?>>11</option>
<option value="12" <?php if($grade_level=="12") echo 'selected="selected"'; ?>>12</option>
<option value="other" <?php if($grade_level=="other") echo 'selected="selected"'; ?>>other</option>
</select>
</fieldset>
<?php /* ?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter"><?php _e('Main Profile Image', 'shr') ?></label>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</p>
</fieldset>
<?php */ ?>
<?php
}
function my_woocommerce_save_account_details( $user_id ) {
update_user_meta( $user_id, 'account_type', $_POST[ 'account_type' ]);
update_user_meta( $user_id, 'distict_city', $_POST[ 'distict_city' ]);
update_user_meta( $user_id, 'school_address', $_POST[ 'school_address' ]);
update_user_meta( $user_id, 'school_type', $_POST[ 'school_type' ]);
update_user_meta( $user_id, 'school_name', $_POST[ 'school_name' ]);
update_user_meta( $user_id, 'grade_level', $_POST[ 'grade_level' ]);
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
update_user_meta( $user_id, 'twitter', htmlentities( $_POST[ 'twitter' ] ) );
$user = wp_update_user( array( 'ID' => $user_id, 'user_url' => esc_url( $_POST[ 'url' ] ) ) );
}
add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' );
function misha_remove_my_account_links( $menu_links ){
$customer_orders = get_posts( array(
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => 'shop_order',
'post_status' => array_keys( wc_get_order_statuses() ),
'numberposts' => -1,
));
if ( $customer_orders ){
}else{
unset( $menu_links['edit-address'] ); // Addresses
unset( $menu_links['orders'] );
unset( $menu_links['downloads'] );
}
unset( $menu_links['edit-address'] );
//unset( $menu_links['dashboard'] ); // Dashboard
//unset( $menu_links['payment-methods'] ); // Payment Methods
//unset( $menu_links['orders'] ); // Orders
unset( $menu_links['downloads'] ); // Downloads
//unset( $menu_links['edit-account'] ); // Account details
//unset( $menu_links['customer-logout'] ); // Logout
return $menu_links;
}
function shr_add_admin_scriptss(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('admin_enqueue_scripts', 'shr_add_admin_scriptss');
function shr_add_admin_scripts(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('wp_enqueue_scripts', 'shr_add_admin_scripts');
function shr_extra_profile_fields( $user ) {
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
} ?>
<table class="form-table fh-profile-upload-options">
<tr>
<th>
<label for="image"><?php _e('Main Profile Image', 'shr') ?></label>
</th>
<td>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</td>
</tr>
</table><?php
}
add_action( 'show_user_profile', 'shr_extra_profile_fields' );
add_action( 'edit_user_profile', 'shr_extra_profile_fields' );
add_action( 'user_new_form', 'shr_extra_profile_fields' );
function shr_profile_update($user_id){
if( current_user_can('edit_users') ){
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
}
}
add_action('profile_update', 'shr_profile_update');
add_action('user_register', 'shr_profile_update');
//change the role to fit your needs
function enable_file_uploads_by_role( ) {
$role = 'subscriber';
if(!current_user_can($role) || current_user_can('upload_files'))
return;
$contributor = get_role( $role );
$contributor->add_cap('upload_files');
} add_action('admin_init', 'enable_file_uploads_by_role');
///// ************************************//////
/*----------------------------------------------------------------------------*
* Register custom post types
*----------------------------------------------------------------------------*/
add_action( 'init', 'fusion_register_post_types' );
function fusion_register_post_types() {
global $smof_data;
$permalinks = get_option( 'avada_permalinks' );
register_post_type(
'Demo',
array(
'labels' => array(
'name' => _x( 'Demo', 'Post Type General Name', 'fusion-core' ),
'singular_name' => _x( 'Demo', 'Post Type Singular Name', 'fusion-core' ),
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => $smof_data['Demo_slug']
),
'supports' => array( 'title', 'editor', 'author', 'excerpt', 'thumbnail', 'comments'),
'can_export' => true,
)
);
/*
register_taxonomy('iam_an', 'Demo',
array(
'hierarchical' => true,
'label' => __('I am a(n)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_iam_an_base'] ) ? _x( 'iam_an', 'slug', 'fusion-core' ) : $permalinks['Demo_iam_base'],
'with_front' => false
),
)
);*/
register_taxonomy('looking_for', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'Looking For', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['portfolio_looking_for_base'] ) ? _x( 'looking_for', 'slug', 'fusion-core' ) : $permalinks['portfolio_looking_for_base'],
'with_front' => false
),
)
);
register_taxonomy('about', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'About', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_about_base'] ) ? _x( 'about', 'slug', 'fusion-core' ) : $permalinks['Demo_about_base'],
'with_front' => false
),
)
);
register_taxonomy('age_group', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'For (Age group)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_age_group'] ) ? _x( 'age_group', 'slug', 'fusion-core' ) : $permalinks['Demo_age_group'],
'with_front' => false
),
)
);
register_taxonomy('Demo_tags', 'Demo',
array(
'hierarchical' => false,
'label' => __( 'Tags', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_tags_base'] ) ? _x( 'Demo_tags', 'slug', 'fusion-core' ) : $permalinks['Demo_tags_base'],
'with_front' => false
),
)
);
if( function_exists('qtrans_getLanguage') ) {
add_action('age_group_add_form', 'qtrans_modifyTermFormFor');
add_action('age_group_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_edit_form', 'qtrans_modifyTermFormFor');
add_action('faq_category_edit_form', 'qtrans_modifyTermFormFor');
}
}
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'Demo' )
{
return locate_template('archive-Demo.php'); // redirect to archive-search.php
}
return $template;
}
add_filter('template_include', 'template_chooser');
function limit_text($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
function wpsites_change_comment_form_submit_label($arg) {
$arg['label_submit'] = 'Post Feedback';
$arg['comment_field'] = '<p class="comment-form-comment"><label for="comment" >' . _x( 'Your Feedback Is Appreciated', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>';
$arg['title_reply'] = __('Leave Feedback');
return $arg;
}
add_filter('comment_form_defaults', 'wpsites_change_comment_form_submit_label');
function mytheme_comment($comment, $args, $depth) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body tt">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) //echo get_avatar( $comment, $args['avatar_size'] );
$current_user = wp_get_current_user();
$user = get_comment_author_link();
$current_user->display_name;
echo "<dl class='comments_boxses'>";
echo "<dt class=".strtoupper( $user[0] ).">".strtoupper( $user[0] )."</dt>";
?>
<dd>
<div class="author_heading"> <?php printf( __( '<div class="authorename fn">%s</div> ' ), get_comment_author_link() ); ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php //edit_comment_link( __( '(Edit)' ), ' ', '' );
?></div>
</div>
<div class="reply_text"><?php comment_text(); ?>
<span class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</span>
<?php if ( $comment->comment_approved == '0' ) : ?> <br />
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting for approved.' ); ?></em>
<br />
<?php endif; ?>
</div>
</dd>
</dl>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
add_action('user_register', 'save_user_notifaction_field');
function save_user_notifaction_field($user_id) {
$user_email = get_userdata($user_id)->user_email;
global $wpdb;
$wpdb->query("INSERT INTO `w9p_Demo_notification` (`id`, `user_id`, `user_email`, `post_count`, `post_id`) VALUES (NULL, '$user_id', '$user_email', '0', '0');");
}
function wcs_send_mail_on_publish_category_posts( $new_status, $old_status, $post ) {
global $post;
global $wpdb;
if ( 'publish' !== $new_status or 'publish' === $old_status ) return;
$posttype = "Demo";
if ($post->post_type == $posttype ) {
$post_id = $post->ID;
$wpdb->query("UPDATE `w9p_Demo_notification` SET `post_count` = post_count+1, `post_id` = CONCAT(post_id,',$post_id');");
$body = sprintf( 'Hey there is a new entry! See <%s %s>', get_permalink( $post ), $post->post_title );
}
}
add_action( 'transition_post_status', 'wcs_send_mail_on_publish_category_posts', 10, 3 );
add_action( 'wp_trash_post', 'function_to_run_on_post_trash' );
function function_to_run_on_post_trash( $post_id ){
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
global $wpdb;
$rid = ",".$post_id;
$wpdb->query("UPDATE w9p_Demo_notification SET post_id = REPLACE(post_id, '$rid', '');");
//wp_mail( 'samrat.p@edreamz.in', 'trash_post entry!', "trash" );
}
$new_general_setting = new new_general_setting();
class new_general_setting {
function new_general_setting( ) {
add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
}
function register_fields() {
register_setting( 'general', 'notification_show', 'esc_attr' );
add_settings_field('notification_show', '<label for="favorite_color">'.__('Show Notification?' , 'notification_show' ).'</label>' , array(&$this, 'fields_html') , 'general' );
register_setting( 'general', 'show_per_page', 'esc_attr' );
add_settings_field('show_per_page', '<label for="favorite_color">'.__('Notification Page Show Limit' , 'show_per_page' ).'</label>' , array(&$this, 'fields_htmls') , 'general' );
register_setting( 'general', 'show_add_content', 'esc_attr' );
add_settings_field('show_add_content', '<label for="favorite_color">'.__('Show Add Content' , 'show_add_content' ).'</label>' , array(&$this, 'fields_htmlss') , 'general' );
}
function fields_htmls() {
$show_per_page = get_option( 'show_per_page', '' );
?>
<input type="text" name="show_per_page" value="<?php echo $show_per_page; ?>" />
<?php
}
function fields_htmlss() {
$show_add_content = get_option( 'show_add_content', '' );
?>
<input type="checkbox" <?php if($show_add_content==1)echo 'checked="checked"'; ?> name="show_add_content" id="show_add_content" value="1">
<?php
}
function fields_html() {
$value = get_option( 'notification_show', '' );
?>
<input type="checkbox" <?php if($value==1)echo 'checked="checked"'; ?> name="notification_show" id="notification_show" value="1">
<a href="javascript:;" onclick="funDismiss()">Clear all notifications for all users</a>
<script>
function funDismiss(){
var r = confirm("Are you sure to clear all notifications for all users?");
if (r == true) {
jQuery.ajax({
type:'POST',
data:{action:'delete_noti'},
url: '<?php echo get_site_url(); ?>/wp-content/themes/midsets/action.php',
success: function(value) {
},
});
} else {
}
}
</script>
<?php
}
}
//new changes
require 'submit_Demo.php';
require 'resource_head.php';
if ( !current_user_can( 'administrator' )) {
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
remove_menu_page( 'admin.php?page=aiowpsec' );
remove_menu_page( 'aiowpsec' );
remove_menu_page( 'edit.php?post_type=acf' );
remove_menu_page( 'wpcf7' );
remove_menu_page( 'cfs' );
remove_menu_page( 'edit.php?post_type=cfs' );
remove_menu_page( 'w3tc_dashboard' );
remove_menu_page( 'invitation_details' );
remove_menu_page( 'yst_ga_dashboard' );
remove_menu_page( 'bws_panel' );
remove_menu_page( 'bhittani_plugin_kksr_settings' );
remove_menu_page( 'register-plus-redux' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=wpeditor_admin' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=invitation_details' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
?>
<style>
#toplevel_page_master-slider, #toplevel_page_edit-post_type-acf, #toplevel_page_wpeditor_admin{display:none;}
</style>
<?php
}
add_action( 'admin_menu', 'remove_menus' );
}
function cjobs_admin_head()
{
do_action('acf/input/admin_head');
}
add_action('admin_head', 'cjobs_admin_head');
function makeiframevideo($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"443\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframevideos($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"350\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframe($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"182\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
global $wpdb;
$title = $_POST['resource_title'];
$about=$_POST['about'];
$age_group=$_POST['age_group'];
$looking_for=$_POST['looking_for'];
$c_text = $_POST['c_text'];
$Demo_tags = $_POST['Demo_tags'];
$video_url = $_POST['video_url'];
$mindset_anchors = $_POST['mindset_anchors'];
$discussion_prompts = $_POST['discussion_prompts'];
$file_size = $_FILES['my_file_upload']['size'];
if ($file_size > 20971520){
}
// save code here
$my_post = array(
'post_title' => $_POST['resource_title'],
'post_content' => $c_text,
'post_type'=>'Demo',
'post_status' => 'pending',
'filter' => false,
'post_author' => get_current_user_id(),
);
// Insert the post into the database.
$post_id = wp_insert_post( $my_post );
wp_set_object_terms( $post_id, $looking_for, 'looking_for' );
wp_set_object_terms( $post_id, $age_group, 'age_group' );
wp_set_object_terms( $post_id, $about, 'about' );
wp_set_object_terms( $post_id, $Demo_tags, 'Demo_tags' );
if ( !function_exists('wp_handle_upload') ) {
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}
if($_FILES['my_image_upload']['name']!=""){
$movefile = wp_handle_upload( $_FILES['my_image_upload'], array('test_form' => false) );
}
// If move was successful, insert WordPress attachment
if ( $movefile && !isset($movefile['error']) ) {
$wp_upload_dir = wp_upload_dir();
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename($movefile['file']),
'post_mime_type' => $movefile['type'],
'post_title' => preg_replace( '/\.[^.]+$/', "", basename($movefile['file']) ),
'post_content' => "",
'post_status' => 'inherit'
);
if($_FILES['my_image_upload']['name']!=""){
$attach_id = wp_insert_attachment($attachment, $movefile['file']);
$thumbnail_image_url = wp_get_attachment_url( $attach_id );
update_field('thumbnail_image', $attach_id, $post_id);
}
if($_FILES['my_file_upload']['name']!=""){
$attachment_id = media_handle_upload( 'my_file_upload', $post_id );
$attachment_url = wp_get_attachment_url( $attachment_id );
update_field('attach_file', $attachment_id, $post_id);
}
}
update_field('video_url', $video_url, $post_id);
update_field('mindset_anchors', $mindset_anchors, $post_id);
update_field('discussion_prompts', $discussion_prompts, $post_id);
$current_user = wp_get_current_user();
$email = $current_user->user_email;
$user_id = $current_user->ID;
$cdate = date("Y-m-d H:i:s");
$sql = "INSERT INTO `wp_Demo` (`id`, `pid`, `user_id`, `user_email`, `title`, `content`, `Demo_tags`, `video_url`, `mindset_anchors`, `discussion_prompts`, `attach_file`, `thumbnail_image`, `looking_for`, `about`, `age_group`, `status`, `date`) VALUES (NULL, '$post_id', '$user_id', '$email', '$title', '$c_text', '$Demo_tags', '$video_url', '$mindset_anchors', '$discussion_prompts', '$attachment_url', '$thumbnail_image_url', '$looking_for', '$about', '$age_group', '0', '$cdate');";
$wpdb->query($sql);
return $post_id;
}
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
//wp_deregister_style( 'amethyst-dashicons-style' );
wp_deregister_style( 'common' );
}
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
.acf-image-uploader img {
width: 48%;
}
</style>';
}
//samrat
//add_filter( 'login_redirect', 'skp_login_redirect', 10, 3 );
function my_force_logins() {
global $post;
if (!is_user_logged_in()) {
//auth_redirect();
wp_redirect( $_SERVER["REQUEST_URI"] );
}
}
function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
// Validate inputs.
if ( ! $url || ( ! $width && ! $height ) ) return $url;
// Caipt'n, ready to hook.
if ( true === $upscale ) add_filter( 'image_resize_dimensions', 'aq_upscale', 10, 6 );
// Define upload path & dir.
$upload_info = wp_upload_dir();
$upload_dir = $upload_info['basedir'];
$upload_url = $upload_info['baseurl'];
$http_prefix = "http://";
$https_prefix = "https://";
/* if the $url scheme differs from $upload_url scheme, make them match
if the schemes differe, images don't show up. */
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
}
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
}
// Check if $img_url is local.
if ( false === strpos( $url, $upload_url ) ) return $url;
// Define path of image.
$rel_path = str_replace( $upload_url, '', $url );
$img_path = $upload_dir . $rel_path;
// Check if img path exists, and is an image indeed.
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return $url;
// Get image info.
$info = pathinfo( $img_path );
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $img_path );
// Get image size after cropping.
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
$dst_w = $dims[4];
$dst_h = $dims[5];
// Return the original image only if it exactly fits the needed measures.
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
$img_url = $url;
$dst_w = $orig_w;
$dst_h = $orig_h;
} else {
// Use this to check if cropped image already exists, so we can return that instead.
$suffix = "{$dst_w}x{$dst_h}";
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
// Can't resize, so return origin image url.
return $url;
}
// Else check if cache exists.
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
}
// Else, we resize the image and return the new resized image url.
else {
// Note: This pre-3.5 fallback check will edited out in subsequent version.
if ( function_exists( 'wp_get_image_editor' ) ) {
$editor = wp_get_image_editor( $img_path );
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
return $url;
$resized_file = $editor->save();
if ( ! is_wp_error( $resized_file ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
} else {
$resized_img_path = image_resize( $img_path, $width, $height, $crop ); // Fallback foo.
if ( ! is_wp_error( $resized_img_path ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_img_path );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
}
}
}
// Okay, leave the ship.
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', 'aq_upscale' );
// Return the output.
if ( $single ) {
// str return.
$image = $img_url;
} else {
// array return.
$image = array (
0 => $img_url,
1 => $dst_w,
2 => $dst_h
);
}
return $image;
}
function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
if ( ! $crop ) return $url; // Let the wordpress default function handle this.
// Here is the point we allow to use larger image size than the original one.
$aspect_ratio = $orig_w / $orig_h;
$new_w = $dest_w;
$new_h = $dest_h;
if ( ! $new_w ) {
$new_w = intval( $new_h * $aspect_ratio );
}
if ( ! $new_h ) {
$new_h = intval( $new_w / $aspect_ratio );
}
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
$crop_w = round( $new_w / $size_ratio );
$crop_h = round( $new_h / $size_ratio );
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
/*
add_action( 'wp_default_scripts', function( $scripts ) {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) );
}
} );
*/
add_filter( 'auto_update_plugin', '__return_false' );
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');
function wpb_get_post_views($postID){
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
$count = round($count/2);
return $count.' Views';
}
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
// Disable REST API link tag
remove_action('wp_head', 'rest_output_link_wp_head', 10);
// Disable oEmbed Discovery Links
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
// Disable REST API link in HTTP headers
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
add_action('admin_head', 'my_custom_fontss');
function my_custom_fontss() {
echo '<style>
#toplevel_page_invitation_details li:nth-child(4){
display:none;
}
#toplevel_page_invitation_details li:nth-child(6){
display:none;
}
</style>';
}
add_filter( 'manage_edit-groups_columns', 'my_edit_groups_columns' ) ;
function my_edit_groups_columns( $columns ) {
$columns_new = array();
foreach( $columns as $col_key => $col_label ) {
if ($col_key == 'date') {
//$columns_new['groups_group_leaders'] = __('Group Information', 'learndash');
$columns_new['school_name'] = __( 'Group Information', 'learndash' );
$columns_new['groups_group_courses'] = sprintf( _x('Group %s', 'Group Courses', 'learndash'), LearnDash_Custom_Label::get_label( 'courses' ));
$columns_new['groups_group_users'] = __('Group Users', 'learndash');
}
$columns_new[$col_key] = $col_label;
}
return $columns_new;
}
/*
// Add the custom columns to the book post type:
add_filter( 'manage_groups_posts_columns', 'set_custom_edit_book_columns' );
function set_custom_edit_book_columns($columns) {
$columns['school_name'] = __( 'School Name', 'your_text_domain' );
return $columns;
}
*/
// Add the data to the custom columns for the book post type:
add_action( 'manage_groups_posts_custom_column' , 'custom_book_column', 1, 2 );
function custom_book_column( $column, $post_id ) {
switch ( $column ) {
case 'school_name':
$group_leaders = learndash_get_groups_administrator_ids( $post_id );
foreach( $group_leaders as $user_id ) {
$user = get_user_by( 'id', $user_id );
echo "<b>School: ".get_user_meta( $user_id, 'school_name', true )."</b><br>";
echo 'Name: <a href="'. get_edit_user_link( $user_id ) .'">'. $user->first_name .' '.$user->last_name .'</a><br>';
}
break;
}
}
function wpachievements_myachievements_func_new( $atts ) {
if( is_user_logged_in() ){
extract( shortcode_atts( array(
'user_id' => '',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $current_user, $wpdb;
get_currentuserinfo();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
//$myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', WPACHIEVEMENTS_TEXT_DOMAIN) .'</h3>';
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
if(function_exists('is_multisite') && is_multisite()){
$sim_ach = get_blog_option(1,'wpachievements_sim_ach');
} else{
$sim_ach = get_option('wpachievements_sim_ach');
}
$ii=0;
$iii=0;
$achievement_badges='';
if( !empty($userachievement) && $userachievement != '' ){
if(function_exists('is_multisite') && is_multisite()){
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'true'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(function_exists('is_multisite') && is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
$myachievements .= '</div>';
return $myachievements;
}
}
add_shortcode( 'wpa_myachievements_new', 'wpachievements_myachievements_func_new' );
// Register and load the widget
function wpb_load_widget() {
register_widget( 'wpb_widget' );
}
add_action( 'widgets_init', 'wpb_load_widget' );
// Creating the widget
class wpb_widget extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widget',
// Widget name will appear in UI
__('Achievements Widget', 'wpb_widget_domain'),
// Widget description
array( 'description' => __( 'Sample widget based on Achievements', 'wpb_widget_domain' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
// This is where you run the code and display the output
//echo __( 'Hello, World!', 'wpb_widget_domain' );
if( is_user_logged_in() ){
echo "<div class='achievements_users'>";
?>
<div class="image-users-wrp">
<div class="image">
<?php
$user_id = get_current_user_id();
/*
$user = get_userdata( $user_id );
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
*/
$profile_img = 'profile_img';
$profile_pic = get_post_meta($user_id, $profile_img, true);
if(empty($profile_pic)){ ?>
<img src="<?php echo home_url(); ?>/wp-content/uploads/2017/12/user-icon.png" class="user-icon" />
<?php }else{ ?>
<img class="user-icon" src="<?php echo home_url("/img/").$profile_pic; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?>" />
<?php } ?>
</div>
<div class="user-info">
<?php
$current_user = wp_get_current_user();
echo "<b>".$current_user->user_firstname ." ". $current_user->user_lastname."</b><br>";
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
echo $school_name = get_user_meta( get_current_user_id(), 'school_name', true );
?>
</div>
</div>
<?php
echo "<div class='achievements'>";
extract( shortcode_atts( array(
'user_id' => '',
'show_title' => 'true',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $wpdb;
$current_user = wp_get_current_user();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = (array) get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
if( $show_title == 'true' || $show_title == 'True' ){
// $myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', 'wpachievements') .'</h3>';
}
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
$sim_ach = wpachievements_get_site_option( 'wpachievements_sim_ach' );
$ii=0;
$iii=0;
$achievement_badges = array();
if ( ! empty( $userachievement ) ) {
if( is_multisite() ) {
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_woopoints = get_post_meta( $ach_ID, '_achievement_woo_points', true );
$ach_rank = get_post_meta( $ach_ID, '_achievement_rank', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'yes'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
$myachievements .= '</div></div>';
echo $myachievements;
echo '</div>';
echo '</div>';
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<!--<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>-->
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgets() {
register_widget( 'wpb_widgets' );
}
add_action( 'widgets_init', 'wpb_load_widgets' );
// Creating the widget
class wpb_widgets extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgets',
// Widget name will appear in UI
__('Quick Training', 'wpb_widget_domainss'),
// Widget description
array( 'description' => __( 'Sample widget based on Quick Training', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
$value = get_field( "quick_training", get_the_ID() );
echo '<h2 class="widget-title">Quick Training</h2>';
if($value){
echo $value;
}else{
echo "<style>#wpb_widgets-2{display:none;}</style>";
echo "<style>#wpb_widgets-3{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgetss() {
register_widget( 'wpb_widgetss' );
}
add_action( 'widgets_init', 'wpb_load_widgetss' );
// Creating the widget
class wpb_widgetss extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgetss',
// Widget name will appear in UI
__('Rating', 'wpb_widget_domainsss'),
// Widget description
array( 'description' => __( 'Sample widget based on Rating', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( is_singular( 'sfwd-topic' ) ) {
if(function_exists('the_ratings')){ the_ratings(); }
}else{
echo "<style>#wpb_widgetss-2{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
function register_my_session(){
if( !session_id() ){
session_start();<?php
/*
add_action( 'wp_enqueue_scripts', 'mpcth_child_enqueue_scripts', 1000 );
function mpcth_child_enqueue_scripts() {
wp_enqueue_style( 'mpc-styles-child', get_stylesheet_directory_uri() . '/style_custom.css' );
}
*/
function registration_form( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
?>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 260px;
}
</style>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -33.8688, lng: 151.2195},
zoom: 13
});
var input = document.getElementById('searchInput');
// map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
var infowindow = new google.maps.InfoWindow();
var marker = new google.maps.Marker({
map: map,
anchorPoint: new google.maps.Point(0, -29)
});
autocomplete.addListener('place_changed', function() {
infowindow.close();
marker.setVisible(false);
var place = autocomplete.getPlace();
if (!place.geometry) {
window.alert("Autocomplete's returned place contains no geometry");
return;
}
// If the place has a geometry, then present it on a map.
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
marker.setIcon(({
url: place.icon,
size: new google.maps.Size(71, 71),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(17, 34),
scaledSize: new google.maps.Size(35, 35)
}));
marker.setPosition(place.geometry.location);
marker.setVisible(true);
var address = '';
if (place.address_components) {
address = [
(place.address_components[0] && place.address_components[0].short_name || ''),
(place.address_components[1] && place.address_components[1].short_name || ''),
(place.address_components[2] && place.address_components[2].short_name || '')
].join(' ');
}
infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
infowindow.open(map, marker);
//Location details
for (var i = 0; i < place.address_components.length; i++) {
if(place.address_components[i].types[0] == 'postal_code'){
// document.getElementById('postal_code').innerHTML = place.address_components[i].long_name;
}
if(place.address_components[i].types[0] == 'country'){
// document.getElementById('country').innerHTML = place.address_components[i].long_name;
}
}
document.getElementById("school").value = "";
document.getElementById("school_address").value = "";
document.getElementById("school").value = place.name;
document.getElementById("school_address").value = place.formatted_address;
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA3rAnj20W3D99Am3KiVer8TQ5LRfsWfJE&libraries=places&callback=initMap"
async defer></script>
<?php
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 0){
?>
<style>
#invcodehide{display:none !important;}
</style>
<?php
}
?>
<?php
echo '
<form id="regform" action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<!--<div class="regi-loginpage-btn"><p>Aleady have an account? <a href="login">Log In</a></p></div>-->
<div class="form-group">
<input placeholder="username" type="text" name="username" id="username" value="' . ( isset( $_POST['username']) ? $username : null ) . '" class="form-control validate[required] username" data-errormessage-value-missing="* username is required" data-prompt-position="topLeft" >
</div>
<div class="cust_transpernt_form">
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 fir">
<div class="form-group">
<input placeholder="First Name" type="text" name="fname" id="fname" value="' . ( isset( $_POST['fname']) ? $fname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] fname" data-errormessage-value-missing="* First name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="grid-50 tablet-grid-100 mobile-grid-100 padd-00 sec">
<div class="form-group">
<input placeholder="Last Name" type="text" name="lname" id="lname" value="' . ( isset( $_POST['lname']) ? $lname : null ) . '" class="form-control validate[required,custom[onlyLetterSp]] lname" data-errormessage-value-missing="* Last name is required" data-errormessage-custom-error="* Only alphabets please" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<input placeholder="Email" type="text" name="email" id="email" value="' . ( isset( $_POST['email']) ? $email : null ) . '" class="form-control validate[required,custom[email]] email" data-errormessage-value-missing="* Email is required" data-errormessage-custom-error="* Invalid email. Let me give you a hint: someone@nowhere.com" data-prompt-position="topLeft" >
</div>
<div class="form-group">
<input placeholder="Set Password" type="password" name="password" id="password" value="' . ( isset( $_POST['password'] ) ? $password : null ) . '" class="form-control validate[required,custom[password]] password" data-errormessage-value-missing="* Password is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<input placeholder="Confirm Password" type="password" name="confirm_password" id="confirm_password" value="' . ( isset( $_POST['confirm_password'] ) ? $confirm_password : null ) . '" class="form-control validate[required,equals[password]] confirm_password" data-errormessage-value-missing="* Confirm password is required" data-errormessage="* Confirm password field is not matching with password field" data-prompt-position="topLeft" >
<input type="hidden" name="arrayindex" id="arrayindex" value="1"/>
</div>
<div class="form-group">
<input placeholder="Distict/City" type="text" name="distict_city" id="distict_city" value="' . ( isset( $_POST['distict_city'] ) ? $distict_city : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* distict/city is required" data-prompt-position="topLeft">
</div>
<div class="form-group" id="invcodehide">
<input placeholder="Invitation Code*" type="text" name="invcode" id="invcode" value="' . ( isset( $_POST['invcode'] ) ? $invcode : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* Invitation Code is required" data-prompt-position="topLeft">
</div>
<div class="form-group">
<div id="locationField">
<input id="searchInput" placeholder="Search for your school.." type="text" class="controls search-school-inp"></input>
</div>
</div>
<div class="form-group"><br>
<div id="map"></div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Name</label>
<input placeholder="" type="text" name="school_name" id="school" value="' . ( isset( $_POST['school_name'] ) ? $school_name : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school name is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<div class="main-school-name-div">
<label>School Address</label>
<input placeholder="" type="text" name="school_address" id="school_address" value="' . ( isset( $_POST['school_address'] ) ? $school_address : null ) . '" class="form-control validate[required]" data-errormessage-value-missing="* school address is required" data-prompt-position="topLeft">
</div>
</div>
<div class="form-group">
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type is required" data-prompt-position="topLeft">
<option value="">Select School Type </option>
<option value="Elementary School">Elementary School</option>
<option value="Middle School">Middle School</option>
<option value="High School">High School</option>
<option value="Other">Other</option>
</select>
</div>
<div class="form-group">
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level is required" data-prompt-position="topLeft">
<option value="">Select Grade Level </option>
<option value="Pre K">Pre K </option>
<option value="K">K</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="other">other</option>
</select>
</div>
<div class="form-group check-main-box">
<input type="checkbox" name="vehicle" value="yes" class="form-control validate[required]" > Yes, I accept the <a href="../terms-conditions">Terms & Conditions</a> of & Demo.<br>
</div>
</div>
<input class="btn btn-primary btn-lg btn-block regbtn reg-btn-subb" type="submit" name="submit" value="Register"/>
</form>';
}
function registration_validation( $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode ) {
global $reg_errors;
$reg_errors = new WP_Error;
global $wpdb;
if(username_exists($username)) {
// Username already registered
$reg_errors->add('username_unavailable', __('Username already taken'));
}
if(!validate_username($username)) {
// invalid username
$reg_errors->add('username_invalid', __('Invalid username'));
}
if ( 4 > strlen( $username ) ) {
$reg_errors->add( 'username_length', 'Username too short. At least 4 characters is required' );
}
if ($fname=="") {
$reg_errors->add( 'empty_fname', 'Required first name field missing' );
}
if ($lname=="") {
$reg_errors->add( 'empty_lname', 'Required last name field missing' );
}
if ( !is_email( $email ) ) {
$reg_errors->add( 'email_invalid', 'Email is not valid' );
}
if ( email_exists( $email ) ) {
$reg_errors->add( 'email', 'Email Already in use' );
}
if ($password=="") {
$reg_errors->add( 'empty_password', 'Required password field missing' );
}else
if ( 5 > strlen( $password ) ) {
$reg_errors->add( 'password', 'Password length must be greater than 5' );
}
if ($password!="") {
if($confirm_password=="")
$reg_errors->add( 'empty_cpassword', 'Required confirm password field missing' );
if($confirm_password!="" && ($confirm_password!=$password)){
$reg_errors->add( 'mismatch_cpassword', 'Required password and confirm password field is mismatch--'.$confirm_password."--".$password );
}
}
if ($school_name=="") {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
$statusss = get_post_meta(1, 'invcode', true);
if($statusss == 1){
$sql = "SELECT * FROM w9p_invitation_code where `invitation_code` = '$invcode' and status = '1';";
$pageposts = $wpdb->get_results($sql);
if(empty($pageposts))
{
$reg_errors->add( 'invcode', 'Invitation Code is not valid' );
}
}
if ($invcode=="" && $statusss == 1) {
$reg_errors->add( 'empty_school', 'Required school field missing' );
}
if ( is_wp_error( $reg_errors ) ) {
if ($reg_errors->get_error_messages()) {
echo '<div class="error-regi">';
foreach ( $reg_errors->get_error_messages() as $error ) {
echo '<p><strong>ERROR </strong>:';
echo $error . '</p>';
}
echo '</div>';
}
}
/* registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level
); */
}
function complete_registration() {
global $reg_errors, $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
if ( 1 > count( $reg_errors->get_error_messages() ) ) {
$userdata = array(
'user_login' => $username,
'user_email' => $email,
'user_pass' => $password,
'display_name' => $fname,
'first_name' => $fname,
'last_name' => $lname,
'user_status' => 1,
//'nickname' => $nickname,
//'description' => $bio,
);
$user = wp_insert_user( $userdata );
//$encpassword = base64_encode ($password);
//add_user_meta( $user, 'pwd', $encpassword);
add_user_meta( $user, 'account_type', $account_type);
add_user_meta( $user, 'distict_city', $distict_city);
add_user_meta( $user, 'school_address', $school_address);
add_user_meta( $user, 'school_type', $school_type);
add_user_meta( $user, 'school_name', $school_name);
add_user_meta( $user, 'grade_level', $grade_level);
add_user_meta( $user, 'invitation_code', $invcode);
//sending email for activation email.
$activation_email = activation_email($user);
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
//exit;
echo '<p class="regi-thanku">Registration complete.</p>';
$_POST = array();
?>
<script>
document.getElementById("regform").reset();
</script>
<?php
}
}
add_action('user_register','continue_to_registration');
function continue_to_registration($user_id) {
if(is_admin()){
$invcode = $_POST['fields']['field_5a8e6ccd1c8bc'];
$count = get_post_meta(1, $invcode, true);
if($count==''){
$count = 1;
add_post_meta(1, $invcode, $count);
}else{
$count++;
update_post_meta(1, $invcode, $count);
}
}
}
function activation_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$subject = 'Activation Email';
$link = get_stylesheet_directory_uri()."/activation.php?userid=$userid";
$linkurl = "<a style='color:#333' href=$link>Activation Link</a>";
$message = get_header_email_template();
//$message .= "<p>Hello $username ,<br> Please click on below link to activate your account.<br> $link</p>";
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">Please click on below link to activate your account.<br> <br> '.$linkurl.'</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message, $headers)){
echo '<p class="regi-thanku">Thank You! Please check your email to activate your account.</p>';
// $location = home_url()."/login/?status=pending";
//wp_safe_redirect($location);
} else{
//echo 'Unable to send email. Please try again.';
}
//exit;
}
function after_activation_welcome_email($userid){
$user_info = get_userdata($userid);
$username = $user_info->first_name;
$userlname = $user_info->last_name;
$to = $user_info->user_email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: Demo Portal <info@Demo.com' . "\r\n";
$pwd = get_user_meta($userid,'pwd');
$pwdd = base64_decode($pwd[0]);
$subject = 'Welcome to Demo Portal
';
$link = site_url();
$linkurl = "<a style='color:#333' href=$link> Demo Portal </a>";
$message = get_header_email_template();
$message .=
'<tbody>
<tr bgcolor="#ffffff">
<td style="padding:20px 30px 0" colspan="2"><div style="color:#000;">
<h2 style="margin:0; color:#333; font-weight:normal; line-height:normal;">Dear '.$username.' '.$userlname.',<br /></h2></div>
</td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="2" style="padding:20px 20px 20px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="" style="border:none; margin:0;">
<tbody><tr>
<td style="padding:0;" colspan="2">
<div style="padding:10px; color:#000; font-size:14px;">
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
Thank you & Welcome to Demo Portal . <br> Your email is successfully verified.</p><br>
<p style="margin:0; color:#333; font-weight:normal; line-height:normal;">
You can now login to the website and shop for the study material.</p>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>';
$message .= get_footer_email_template();
//wp_mail($to, $subject, $message);
if(wp_mail($to, $subject, $message,$headers)){
echo 'Your mail has been sent successfully.';
} else{
// echo 'Unable to send email. Please try again.';
}
//exit;
}
function custom_registration_function() {
if ( isset($_POST['submit'] ) ) {
registration_validation(
$_POST['username'],
$_POST['fname'],
$_POST['lname'],
$_POST['email'],
$_POST['password'],
$_POST['confirm_password'],
$_POST['account_type'],
$_POST['distict_city'],
$_POST['school_name'],
$_POST['school_address'],
$_POST['school_type'],
$_POST['grade_level'],
$_POST['invcode']
);
// sanitize user form input
global $username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode;
$username = sanitize_user( $_POST['username'] );
$password = esc_attr( $_POST['password'] );
$confirm_password = esc_attr( $_POST['confirm_password'] );
$email = sanitize_email( $_POST['email'] );
$fname = sanitize_text_field( $_POST['fname'] );
$lname = sanitize_text_field( $_POST['lname'] );
$account_type = sanitize_text_field( $_POST['account_type'] );
$distict_city = esc_textarea( $_POST['distict_city'] );
$school_name = esc_textarea( $_POST['school_name'] );
$school_address = esc_textarea( $_POST['school_address'] );
$school_type = $_POST['school_type'];
$grade_level = $_POST['grade_level'];
$invcode = $_POST['invcode'];
complete_registration(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
registration_form(
$username, $fname, $lname, $email, $password, $confirm_password, $account_type, $distict_city, $school_name ,$school_address, $school_type, $grade_level, $invcode
);
}
// Register a new shortcode: [cr_custom_registration]
add_shortcode( 'cr_custom_registration', 'custom_registration_shortcode' );
// The callback function that will replace [book]
function custom_registration_shortcode() {
ob_start();
custom_registration_function();
return ob_get_clean();
}
function get_header_email_template(){
$diruri = get_stylesheet_directory_uri();
$siteuri = site_url();
$header =
'
<style>
table { border:solid 1px #0056a2;margin:20px auto;line-height:20px;color:#666;}
table tr td {padding:10px;font-size:13px;}
.border-top {border-top:solid 1px #d7d7d7;}
.social_links a {display:inline-block;margin-left:5px;}
a{color:#ffffff;}
</style>
<body>
<table width="600" cellspacing="0" cellpadding="10" style="border:solid 2px #00582e; background:url('.$diruri.'/images/body_bg.jpg) no-repeat fixed center top / cover; border-radius:4px; margin:20px auto;line-height:20px;color:#666; font-family:Arial, Helvetica, sans-serif;">
<thead>
<tr bgcolor="">
<td align="left" style="padding:20px 30px;" title="Demo"><a href="'.$siteuri.'/about/welcome-letter/"><img width="100%" src="'.$diruri.'/images/logo.png"></a></td>
<td align="right" style="color:#ffffff; line-height:normal; padding:20px 30px;"><strong style="display:block; margin-top:22px;"></strong></td>
</tr>
<tr bgcolor="#dddddd">
<td style="padding:0px; height:1px;"></td>
<td style="padding:0px; height:1px;"></td>
</tr>
</thead>';
return $header;
}
function get_footer_email_template(){
$footer = '
<tr bgcolor="#ffffff">
<td colspan="2" style="color:#00582e; padding:0;"></td>
</tr>
<tr bgcolor="">
<td style="color:#fff;">
<strong style="color:#fff">Demo Portal </strong><br>
<strong>Email:</strong> <a href="mailto:info@Demo.com" style="color:#fff;">info@Demo.com</a></td>
<td width="50%" align="right" style="color:#fff;"> </td>
</tr>
</table></body></html> ';
return $footer;
}
function wpse_131562_redirect() {
if (
! is_user_logged_in() && !is_page(array( 31,147,16895,35,34,17026 ))
/* && (is_woocommerce() || is_cart() || is_checkout() || is_product() || is_singular( 'sfwd-courses' ) || is_singular( 'sfwd-topic' ) || is_page(array( 293,40,29,417,194, 16156, 16424, 7736, 16445, 16452 )) || is_post_type_archive( 'Demo' ) || is_singular( 'Demo' ))*/
) {
// feel free to customize the following line to suit your needs
//wp_redirect(home_url());
auth_redirect();
exit;
}
if (
is_user_logged_in()
&& (is_page(147))
) {
$location = home_url()."/courses-list/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit;
}
}
add_action('template_redirect', 'wpse_131562_redirect');
function so_27030769_maybe_empty_cart( $valid, $product_id, $quantity ) {
if( ! empty ( WC()->cart->get_cart() ) && $valid ){
WC()->cart->empty_cart();
wc_add_notice( 'Whoa hold up. You can only have an item in your cart', 'error' );
?>
<style>
.woocommerce-message {
display: none;
}
</style>
<?php
}
return $valid;
}
add_filter( 'woocommerce_add_to_cart_validation', 'so_27030769_maybe_empty_cart', 10, 3 );
/*
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['action']) && !empty($_POST['action'])) ) {
add_filter('login_redirect', 'my_login_redirect', 10, 3);
function my_login_redirect() {
$location = $_SERVER['HTTP_REFERER'];
$location = home_url()."/my-account/";
// echo wp_get_referer();
wp_safe_redirect($location);
exit();
}
}
*/
/**
* Opening div for our content wrapper
*/
add_action('woocommerce_before_main_content', 'iconic_open_div', 5);
function iconic_open_div() {
echo '<div class="iconic-div">';
}
/**
* Closing div for our content wrapper
*/
add_action('woocommerce_after_main_content', 'iconic_close_div', 50);
function iconic_close_div() {
echo '</div>';
}
add_action( 'user_register', 'registration_save', 10, 1 );
function registration_save( $user_id ) {
if ( !isset( $_POST['password'] ) )
{
sleep(5);
$user_data = update_user_meta( $user_id, 'pw_user_status','approved' );
add_option( 'group_leader_id_'.$user_id, get_current_user_id() );
$distict_city = get_user_meta( get_current_user_id(), 'distict_city', true );
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
$school_type = get_user_meta( get_current_user_id(), 'school_type', true );
$school_name = get_user_meta( get_current_user_id(), 'school_name', true );
$grade_level = get_user_meta( get_current_user_id(), 'grade_level', true );
$user = new WP_User( get_current_user_id() );
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
$people_role = $user->roles;
if (!in_array("administrator", $people_role) && in_array("group_leader", $people_role))
{
update_user_meta( $user_id, 'distict_city', $distict_city);
update_user_meta( $user_id, 'school_address', $school_address);
update_user_meta( $user_id, 'school_type', $school_type);
update_user_meta( $user_id, 'school_name', $school_name);
update_user_meta( $user_id, 'grade_level', $grade_level);
}
}
}
}
function admin_default_page() {
//return home_url().'/my-account/';
// return $_SERVER['HTTP_REFERER'];
}
//add_filter('login_redirect', 'admin_default_page');
function my_login_redirect( $redirect_to, $request, $user ){
//is there a user to check?
global $user;
if( isset( $user->roles ) && is_array( $user->roles ) ) {
//check for admins
if( in_array( "administrator", $user->roles ) ) {
// redirect them to the default place
return home_url(); //admin redirect url
} else {
return admin_url( 'edit.php?post_type=page' ); //user redirect url
}
}
else {
// return $redirect_to;
if($redirect_to==home_url()."/wp-admin/"){
return home_url().'/courses-list/';
}else{
return $redirect_to;
}
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
add_action( 'woocommerce_edit_account_form', 'my_woocommerce_edit_account_form' );
add_action( 'woocommerce_save_account_details', 'my_woocommerce_save_account_details' );
function my_woocommerce_edit_account_form() {
$user_id = get_current_user_id();
$user = get_userdata( $user_id );
if ( !$user )
return;
$account_type = get_user_meta( $user_id, 'account_type', true );
$distict_city = get_user_meta( $user_id, 'distict_city', true );
$school_address = get_user_meta( $user_id, 'school_address', true );
$school_type = get_user_meta( $user_id, 'school_type', true );
$school_name = get_user_meta( $user_id, 'school_name', true );
$grade_level = get_user_meta( $user_id, 'grade_level', true );
$twitter = get_user_meta( $user_id, 'twitter', true );
$url = $user->user_url;
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Distict/City:</label>
<input type="text" name="distict_city" value="<?php echo esc_attr( $distict_city ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Name:</label>
<input type="text" name="school_name" value="<?php echo esc_attr( $school_name ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Address:</label>
<input type="text" name="school_address" value="<?php echo esc_attr( $school_address ); ?>" class="input-text" />
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">School Type:</label>
<select type="text" name="school_type" id="school_type" class="form-control validate[required]" data-errormessage-value-missing="* school type required" data-errormessage-value-missing="* school type required">
<option value="">Select School Type </option>
<option value="Elementary" <?php if($school_type=="Elementary") echo 'selected="selected"'; ?>>Elementary </option>
<option value="Middle School" <?php if($school_type=="Middle School") echo 'selected="selected"'; ?>>Middle School</option>
<option value="High School" <?php if($school_type=="High School") echo 'selected="selected"'; ?>>High School</option>
<option value="Other" <?php if($school_type=="Other") echo 'selected="selected"'; ?>>Other</option>
</select>
</p>
</fieldset>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter">Grade Level:</label>
<select type="text" name="grade_level" id="grade_level" class="form-control validate[required]" data-errormessage-value-missing="* grade level required">
<option value="">Select Grade Level </option>
<option value="Pre K" <?php if($grade_level=="Pre K") echo 'selected="selected"'; ?> >Pre K </option>
<option value="K" <?php if($grade_level=="K") echo 'selected="selected"'; ?>>K</option>
<option value="1" <?php if($grade_level=="1") echo 'selected="selected"'; ?>>1</option>
<option value="2" <?php if($grade_level=="2") echo 'selected="selected"'; ?>>2</option>
<option value="3" <?php if($grade_level=="3") echo 'selected="selected"'; ?>>3</option>
<option value="4" <?php if($grade_level=="4") echo 'selected="selected"'; ?>>4</option>
<option value="5" <?php if($grade_level=="5") echo 'selected="selected"'; ?>>5</option>
<option value="6" <?php if($grade_level=="6") echo 'selected="selected"'; ?>>6</option>
<option value="7" <?php if($grade_level=="7") echo 'selected="selected"'; ?>>7</option>
<option value="8" <?php if($grade_level=="8") echo 'selected="selected"'; ?>>8</option>
<option value="9" <?php if($grade_level=="9") echo 'selected="selected"'; ?>>9</option>
<option value="10" <?php if($grade_level=="10") echo 'selected="selected"'; ?>>10</option>
<option value="11" <?php if($grade_level=="11") echo 'selected="selected"'; ?>>11</option>
<option value="12" <?php if($grade_level=="12") echo 'selected="selected"'; ?>>12</option>
<option value="other" <?php if($grade_level=="other") echo 'selected="selected"'; ?>>other</option>
</select>
</fieldset>
<?php /* ?>
<fieldset>
<p class="form-row form-row-thirds">
<label for="twitter"><?php _e('Main Profile Image', 'shr') ?></label>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</p>
</fieldset>
<?php */ ?>
<?php
}
function my_woocommerce_save_account_details( $user_id ) {
update_user_meta( $user_id, 'account_type', $_POST[ 'account_type' ]);
update_user_meta( $user_id, 'distict_city', $_POST[ 'distict_city' ]);
update_user_meta( $user_id, 'school_address', $_POST[ 'school_address' ]);
update_user_meta( $user_id, 'school_type', $_POST[ 'school_type' ]);
update_user_meta( $user_id, 'school_name', $_POST[ 'school_name' ]);
update_user_meta( $user_id, 'grade_level', $_POST[ 'grade_level' ]);
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
update_user_meta( $user_id, 'twitter', htmlentities( $_POST[ 'twitter' ] ) );
$user = wp_update_user( array( 'ID' => $user_id, 'user_url' => esc_url( $_POST[ 'url' ] ) ) );
}
add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' );
function misha_remove_my_account_links( $menu_links ){
$customer_orders = get_posts( array(
'meta_key' => '_customer_user',
'meta_value' => get_current_user_id(),
'post_type' => 'shop_order',
'post_status' => array_keys( wc_get_order_statuses() ),
'numberposts' => -1,
));
if ( $customer_orders ){
}else{
unset( $menu_links['edit-address'] ); // Addresses
unset( $menu_links['orders'] );
unset( $menu_links['downloads'] );
}
unset( $menu_links['edit-address'] );
//unset( $menu_links['dashboard'] ); // Dashboard
//unset( $menu_links['payment-methods'] ); // Payment Methods
//unset( $menu_links['orders'] ); // Orders
unset( $menu_links['downloads'] ); // Downloads
//unset( $menu_links['edit-account'] ); // Account details
//unset( $menu_links['customer-logout'] ); // Logout
return $menu_links;
}
function shr_add_admin_scriptss(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('admin_enqueue_scripts', 'shr_add_admin_scriptss');
function shr_add_admin_scripts(){
wp_enqueue_media();
wp_enqueue_script('shr-uploader', get_stylesheet_directory_uri().'/js/uploader.js', array('jquery'), false, true );
}
add_action('wp_enqueue_scripts', 'shr_add_admin_scripts');
function shr_extra_profile_fields( $user ) {
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
} ?>
<table class="form-table fh-profile-upload-options">
<tr>
<th>
<label for="image"><?php _e('Main Profile Image', 'shr') ?></label>
</th>
<td>
<input type="button" data-id="shr_image_id" data-src="shr-img" class="button shr-image" name="shr_image" id="shr-image" value="Upload" />
<input type="hidden" class="button" name="shr_image_id" id="shr_image_id" value="<?php echo !empty($profile_pic) ? $profile_pic : ''; ?>" />
<img id="shr-img" src="<?php echo !empty($profile_pic) ? $image[0] : ''; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?> max-width: 100px; max-height: 100px;" />
</td>
</tr>
</table><?php
}
add_action( 'show_user_profile', 'shr_extra_profile_fields' );
add_action( 'edit_user_profile', 'shr_extra_profile_fields' );
add_action( 'user_new_form', 'shr_extra_profile_fields' );
function shr_profile_update($user_id){
if( current_user_can('edit_users') ){
$profile_pic = empty($_POST['shr_image_id']) ? '' : $_POST['shr_image_id'];
update_user_meta($user_id, 'shr_pic', $profile_pic);
}
}
add_action('profile_update', 'shr_profile_update');
add_action('user_register', 'shr_profile_update');
//change the role to fit your needs
function enable_file_uploads_by_role( ) {
$role = 'subscriber';
if(!current_user_can($role) || current_user_can('upload_files'))
return;
$contributor = get_role( $role );
$contributor->add_cap('upload_files');
} add_action('admin_init', 'enable_file_uploads_by_role');
///// ************************************//////
/*----------------------------------------------------------------------------*
* Register custom post types
*----------------------------------------------------------------------------*/
add_action( 'init', 'fusion_register_post_types' );
function fusion_register_post_types() {
global $smof_data;
$permalinks = get_option( 'avada_permalinks' );
register_post_type(
'Demo',
array(
'labels' => array(
'name' => _x( 'Demo', 'Post Type General Name', 'fusion-core' ),
'singular_name' => _x( 'Demo', 'Post Type Singular Name', 'fusion-core' ),
),
'public' => true,
'has_archive' => true,
'rewrite' => array(
'slug' => $smof_data['Demo_slug']
),
'supports' => array( 'title', 'editor', 'author', 'excerpt', 'thumbnail', 'comments'),
'can_export' => true,
)
);
/*
register_taxonomy('iam_an', 'Demo',
array(
'hierarchical' => true,
'label' => __('I am a(n)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_iam_an_base'] ) ? _x( 'iam_an', 'slug', 'fusion-core' ) : $permalinks['Demo_iam_base'],
'with_front' => false
),
)
);*/
register_taxonomy('looking_for', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'Looking For', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['portfolio_looking_for_base'] ) ? _x( 'looking_for', 'slug', 'fusion-core' ) : $permalinks['portfolio_looking_for_base'],
'with_front' => false
),
)
);
register_taxonomy('about', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'About', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_about_base'] ) ? _x( 'about', 'slug', 'fusion-core' ) : $permalinks['Demo_about_base'],
'with_front' => false
),
)
);
register_taxonomy('age_group', 'Demo',
array(
'hierarchical' => true,
'label' => __( 'For (Age group)', 'fusion-core' ),
'query_var' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_age_group'] ) ? _x( 'age_group', 'slug', 'fusion-core' ) : $permalinks['Demo_age_group'],
'with_front' => false
),
)
);
register_taxonomy('Demo_tags', 'Demo',
array(
'hierarchical' => false,
'label' => __( 'Tags', 'fusion-core' ),
'query_var' => true,
'show_admin_column' => true,
'rewrite' => array(
'slug' => empty( $permalinks['Demo_tags_base'] ) ? _x( 'Demo_tags', 'slug', 'fusion-core' ) : $permalinks['Demo_tags_base'],
'with_front' => false
),
)
);
if( function_exists('qtrans_getLanguage') ) {
add_action('age_group_add_form', 'qtrans_modifyTermFormFor');
add_action('age_group_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_skills_edit_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_add_form', 'qtrans_modifyTermFormFor');
add_action('portfolio_tags_edit_form', 'qtrans_modifyTermFormFor');
add_action('faq_category_edit_form', 'qtrans_modifyTermFormFor');
}
}
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'Demo' )
{
return locate_template('archive-Demo.php'); // redirect to archive-search.php
}
return $template;
}
add_filter('template_include', 'template_chooser');
function limit_text($text, $limit) {
if (str_word_count($text, 0) > $limit) {
$words = str_word_count($text, 2);
$pos = array_keys($words);
$text = substr($text, 0, $pos[$limit]) . '...';
}
return $text;
}
function wpsites_change_comment_form_submit_label($arg) {
$arg['label_submit'] = 'Post Feedback';
$arg['comment_field'] = '<p class="comment-form-comment"><label for="comment" >' . _x( 'Your Feedback Is Appreciated', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>';
$arg['title_reply'] = __('Leave Feedback');
return $arg;
}
add_filter('comment_form_defaults', 'wpsites_change_comment_form_submit_label');
function mytheme_comment($comment, $args, $depth) {
if ( 'div' === $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body tt">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ( $args['avatar_size'] != 0 ) //echo get_avatar( $comment, $args['avatar_size'] );
$current_user = wp_get_current_user();
$user = get_comment_author_link();
$current_user->display_name;
echo "<dl class='comments_boxses'>";
echo "<dt class=".strtoupper( $user[0] ).">".strtoupper( $user[0] )."</dt>";
?>
<dd>
<div class="author_heading"> <?php printf( __( '<div class="authorename fn">%s</div> ' ), get_comment_author_link() ); ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>">
<?php
/* translators: 1: date, 2: time */
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php //edit_comment_link( __( '(Edit)' ), ' ', '' );
?></div>
</div>
<div class="reply_text"><?php comment_text(); ?>
<span class="reply">
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</span>
<?php if ( $comment->comment_approved == '0' ) : ?> <br />
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting for approved.' ); ?></em>
<br />
<?php endif; ?>
</div>
</dd>
</dl>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php
}
add_action('user_register', 'save_user_notifaction_field');
function save_user_notifaction_field($user_id) {
$user_email = get_userdata($user_id)->user_email;
global $wpdb;
$wpdb->query("INSERT INTO `w9p_Demo_notification` (`id`, `user_id`, `user_email`, `post_count`, `post_id`) VALUES (NULL, '$user_id', '$user_email', '0', '0');");
}
function wcs_send_mail_on_publish_category_posts( $new_status, $old_status, $post ) {
global $post;
global $wpdb;
if ( 'publish' !== $new_status or 'publish' === $old_status ) return;
$posttype = "Demo";
if ($post->post_type == $posttype ) {
$post_id = $post->ID;
$wpdb->query("UPDATE `w9p_Demo_notification` SET `post_count` = post_count+1, `post_id` = CONCAT(post_id,',$post_id');");
$body = sprintf( 'Hey there is a new entry! See <%s %s>', get_permalink( $post ), $post->post_title );
}
}
add_action( 'transition_post_status', 'wcs_send_mail_on_publish_category_posts', 10, 3 );
add_action( 'wp_trash_post', 'function_to_run_on_post_trash' );
function function_to_run_on_post_trash( $post_id ){
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
global $wpdb;
$rid = ",".$post_id;
$wpdb->query("UPDATE w9p_Demo_notification SET post_id = REPLACE(post_id, '$rid', '');");
//wp_mail( 'samrat.p@edreamz.in', 'trash_post entry!', "trash" );
}
$new_general_setting = new new_general_setting();
class new_general_setting {
function new_general_setting( ) {
add_filter( 'admin_init' , array( &$this , 'register_fields' ) );
}
function register_fields() {
register_setting( 'general', 'notification_show', 'esc_attr' );
add_settings_field('notification_show', '<label for="favorite_color">'.__('Show Notification?' , 'notification_show' ).'</label>' , array(&$this, 'fields_html') , 'general' );
register_setting( 'general', 'show_per_page', 'esc_attr' );
add_settings_field('show_per_page', '<label for="favorite_color">'.__('Notification Page Show Limit' , 'show_per_page' ).'</label>' , array(&$this, 'fields_htmls') , 'general' );
register_setting( 'general', 'show_add_content', 'esc_attr' );
add_settings_field('show_add_content', '<label for="favorite_color">'.__('Show Add Content' , 'show_add_content' ).'</label>' , array(&$this, 'fields_htmlss') , 'general' );
}
function fields_htmls() {
$show_per_page = get_option( 'show_per_page', '' );
?>
<input type="text" name="show_per_page" value="<?php echo $show_per_page; ?>" />
<?php
}
function fields_htmlss() {
$show_add_content = get_option( 'show_add_content', '' );
?>
<input type="checkbox" <?php if($show_add_content==1)echo 'checked="checked"'; ?> name="show_add_content" id="show_add_content" value="1">
<?php
}
function fields_html() {
$value = get_option( 'notification_show', '' );
?>
<input type="checkbox" <?php if($value==1)echo 'checked="checked"'; ?> name="notification_show" id="notification_show" value="1">
<a href="javascript:;" onclick="funDismiss()">Clear all notifications for all users</a>
<script>
function funDismiss(){
var r = confirm("Are you sure to clear all notifications for all users?");
if (r == true) {
jQuery.ajax({
type:'POST',
data:{action:'delete_noti'},
url: '<?php echo get_site_url(); ?>/wp-content/themes/midsets/action.php',
success: function(value) {
},
});
} else {
}
}
</script>
<?php
}
}
//new changes
require 'submit_Demo.php';
require 'resource_head.php';
if ( !current_user_can( 'administrator' )) {
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'jetpack' ); //Jetpack*
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'themes.php' ); //Appearance
remove_menu_page( 'plugins.php' ); //Plugins
remove_menu_page( 'users.php' ); //Users
remove_menu_page( 'tools.php' ); //Tools
remove_menu_page( 'options-general.php' ); //Settings
remove_menu_page( 'admin.php?page=aiowpsec' );
remove_menu_page( 'aiowpsec' );
remove_menu_page( 'edit.php?post_type=acf' );
remove_menu_page( 'wpcf7' );
remove_menu_page( 'cfs' );
remove_menu_page( 'edit.php?post_type=cfs' );
remove_menu_page( 'w3tc_dashboard' );
remove_menu_page( 'invitation_details' );
remove_menu_page( 'yst_ga_dashboard' );
remove_menu_page( 'bws_panel' );
remove_menu_page( 'bhittani_plugin_kksr_settings' );
remove_menu_page( 'register-plus-redux' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=wpeditor_admin' );
remove_menu_page( 'admin.php?page=master-slider-setting' );
remove_menu_page( 'admin.php?page=invitation_details' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
remove_menu_page( 'admin.php?page=pmxi-admin-import' );
?>
<style>
#toplevel_page_master-slider, #toplevel_page_edit-post_type-acf, #toplevel_page_wpeditor_admin{display:none;}
</style>
<?php
}
add_action( 'admin_menu', 'remove_menus' );
}
function cjobs_admin_head()
{
do_action('acf/input/admin_head');
}
add_action('admin_head', 'cjobs_admin_head');
function makeiframevideo($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"443\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"443\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframevideos($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"350\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"350\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
function makeiframe($url)
{
// Youtube
$ytRegExp = "/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/";
preg_match($ytRegExp, $url, $ytMatch);
if ($ytMatch && strlen($ytMatch[1]) === 11) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src=\"//www.youtube.com/embed/{$ytMatch[1]}?showinfo=0\" ></iframe>";
}
$igRegExp = "/^(?:https?:\/\/)?(?:www\.)?instagram.com\/p\/(.[a-zA-Z0-9\_]*)/";
preg_match($igRegExp, $url, $igMatch);
if ($igMatch && strlen($igMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$igMatch[0]}/embed/' ></iframe>";
}
// Vine
$vRegExp = "/^(?:https?:\/\/)?(?:www\.)?vine.co\/v\/(.[a-zA-Z0-9]*)/";
preg_match($vRegExp, $url, $vMatch);
if ($vMatch && strlen($vMatch[0])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='{$vMatch[0]}/embed/simple' ></iframe>";
}
// Vimeo
$vimRegExp = " /\/\/(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/";
preg_match($vimRegExp, $url, $vimMatch);
if ($vimMatch && strlen($vimMatch[3])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.vimeo.com/video/{$vimMatch[3]}' ></iframe>";
}
// Dailymotion
$dmRegExp = "/.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/";
preg_match($dmRegExp, $url, $dmMatch);
if ($dmMatch && strlen($dmMatch[2])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//www.dailymotion.com/embed/video/{$dmMatch[2]}' ></iframe>";
}
// Youku
$youkuRegExp = "/\/\/v\.youku\.com\/v_show\/id_(\w+)/";
preg_match($youkuRegExp, $url, $youkuMatch);
if ($youkuMatch && strlen($youkuMatch[1])) {
return "<iframe frameborder=\"0\" allowfullscreen class=\"pull-left\" id=\"ytplayer\" type=\"text/html\" width=\"100%\" height=\"182\" src='//player.youku.com/embed/{$youkuMatch[1]}' ></iframe>";
}
if (preg_match("/\bfacebook\b/i", $url)) {
$match = ( explode( "/", $url ) );
return "<iframe src=\"https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F{$match[5]}%2F&width=500&show_text=false&height=280&appId\" width=\"100%\" height=\"182\" style=\"border:none;overflow:hidden\" scrolling=\"no\" frameborder=\"0\" allowTransparency=\"true\"></iframe>";
}
$mp4RegExp = '/^.+.(mp4|m4v)$/';
preg_match($mp4RegExp, $url, $mp4Match);
$oggRegExp = '/^.+.(ogg|ogv)$/';
preg_match($oggRegExp, $url, $oggMatch);
$webmRegExp = '/^.+.(webm)$/';
preg_match($webmRegExp, $url, $webmMatch);
if ($mp4Match || $oggMatch || $webmMatch) {
return $url;
}
return "";
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
function my_pre_save_post( $post_id ) {
global $wpdb;
$title = $_POST['resource_title'];
$about=$_POST['about'];
$age_group=$_POST['age_group'];
$looking_for=$_POST['looking_for'];
$c_text = $_POST['c_text'];
$Demo_tags = $_POST['Demo_tags'];
$video_url = $_POST['video_url'];
$mindset_anchors = $_POST['mindset_anchors'];
$discussion_prompts = $_POST['discussion_prompts'];
$file_size = $_FILES['my_file_upload']['size'];
if ($file_size > 20971520){
}
// save code here
$my_post = array(
'post_title' => $_POST['resource_title'],
'post_content' => $c_text,
'post_type'=>'Demo',
'post_status' => 'pending',
'filter' => false,
'post_author' => get_current_user_id(),
);
// Insert the post into the database.
$post_id = wp_insert_post( $my_post );
wp_set_object_terms( $post_id, $looking_for, 'looking_for' );
wp_set_object_terms( $post_id, $age_group, 'age_group' );
wp_set_object_terms( $post_id, $about, 'about' );
wp_set_object_terms( $post_id, $Demo_tags, 'Demo_tags' );
if ( !function_exists('wp_handle_upload') ) {
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
}
if($_FILES['my_image_upload']['name']!=""){
$movefile = wp_handle_upload( $_FILES['my_image_upload'], array('test_form' => false) );
}
// If move was successful, insert WordPress attachment
if ( $movefile && !isset($movefile['error']) ) {
$wp_upload_dir = wp_upload_dir();
$attachment = array(
'guid' => $wp_upload_dir['url'] . '/' . basename($movefile['file']),
'post_mime_type' => $movefile['type'],
'post_title' => preg_replace( '/\.[^.]+$/', "", basename($movefile['file']) ),
'post_content' => "",
'post_status' => 'inherit'
);
if($_FILES['my_image_upload']['name']!=""){
$attach_id = wp_insert_attachment($attachment, $movefile['file']);
$thumbnail_image_url = wp_get_attachment_url( $attach_id );
update_field('thumbnail_image', $attach_id, $post_id);
}
if($_FILES['my_file_upload']['name']!=""){
$attachment_id = media_handle_upload( 'my_file_upload', $post_id );
$attachment_url = wp_get_attachment_url( $attachment_id );
update_field('attach_file', $attachment_id, $post_id);
}
}
update_field('video_url', $video_url, $post_id);
update_field('mindset_anchors', $mindset_anchors, $post_id);
update_field('discussion_prompts', $discussion_prompts, $post_id);
$current_user = wp_get_current_user();
$email = $current_user->user_email;
$user_id = $current_user->ID;
$cdate = date("Y-m-d H:i:s");
$sql = "INSERT INTO `wp_Demo` (`id`, `pid`, `user_id`, `user_email`, `title`, `content`, `Demo_tags`, `video_url`, `mindset_anchors`, `discussion_prompts`, `attach_file`, `thumbnail_image`, `looking_for`, `about`, `age_group`, `status`, `date`) VALUES (NULL, '$post_id', '$user_id', '$email', '$title', '$c_text', '$Demo_tags', '$video_url', '$mindset_anchors', '$discussion_prompts', '$attachment_url', '$thumbnail_image_url', '$looking_for', '$about', '$age_group', '0', '$cdate');";
$wpdb->query($sql);
return $post_id;
}
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
//wp_deregister_style( 'amethyst-dashicons-style' );
wp_deregister_style( 'common' );
}
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
echo '<style>
.acf-image-uploader img {
width: 48%;
}
</style>';
}
//samrat
//add_filter( 'login_redirect', 'skp_login_redirect', 10, 3 );
function my_force_logins() {
global $post;
if (!is_user_logged_in()) {
//auth_redirect();
wp_redirect( $_SERVER["REQUEST_URI"] );
}
}
function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
// Validate inputs.
if ( ! $url || ( ! $width && ! $height ) ) return $url;
// Caipt'n, ready to hook.
if ( true === $upscale ) add_filter( 'image_resize_dimensions', 'aq_upscale', 10, 6 );
// Define upload path & dir.
$upload_info = wp_upload_dir();
$upload_dir = $upload_info['basedir'];
$upload_url = $upload_info['baseurl'];
$http_prefix = "http://";
$https_prefix = "https://";
/* if the $url scheme differs from $upload_url scheme, make them match
if the schemes differe, images don't show up. */
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
}
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
}
// Check if $img_url is local.
if ( false === strpos( $url, $upload_url ) ) return $url;
// Define path of image.
$rel_path = str_replace( $upload_url, '', $url );
$img_path = $upload_dir . $rel_path;
// Check if img path exists, and is an image indeed.
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) ) return $url;
// Get image info.
$info = pathinfo( $img_path );
$ext = $info['extension'];
list( $orig_w, $orig_h ) = getimagesize( $img_path );
// Get image size after cropping.
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
$dst_w = $dims[4];
$dst_h = $dims[5];
// Return the original image only if it exactly fits the needed measures.
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
$img_url = $url;
$dst_w = $orig_w;
$dst_h = $orig_h;
} else {
// Use this to check if cropped image already exists, so we can return that instead.
$suffix = "{$dst_w}x{$dst_h}";
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
// Can't resize, so return origin image url.
return $url;
}
// Else check if cache exists.
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
}
// Else, we resize the image and return the new resized image url.
else {
// Note: This pre-3.5 fallback check will edited out in subsequent version.
if ( function_exists( 'wp_get_image_editor' ) ) {
$editor = wp_get_image_editor( $img_path );
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) )
return $url;
$resized_file = $editor->save();
if ( ! is_wp_error( $resized_file ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
} else {
$resized_img_path = image_resize( $img_path, $width, $height, $crop ); // Fallback foo.
if ( ! is_wp_error( $resized_img_path ) ) {
$resized_rel_path = str_replace( $upload_dir, '', $resized_img_path );
$img_url = $upload_url . $resized_rel_path;
} else {
return $url;
}
}
}
}
// Okay, leave the ship.
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', 'aq_upscale' );
// Return the output.
if ( $single ) {
// str return.
$image = $img_url;
} else {
// array return.
$image = array (
0 => $img_url,
1 => $dst_w,
2 => $dst_h
);
}
return $image;
}
function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
if ( ! $crop ) return $url; // Let the wordpress default function handle this.
// Here is the point we allow to use larger image size than the original one.
$aspect_ratio = $orig_w / $orig_h;
$new_w = $dest_w;
$new_h = $dest_h;
if ( ! $new_w ) {
$new_w = intval( $new_h * $aspect_ratio );
}
if ( ! $new_h ) {
$new_h = intval( $new_w / $aspect_ratio );
}
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
$crop_w = round( $new_w / $size_ratio );
$crop_h = round( $new_h / $size_ratio );
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
}
/*
add_action( 'wp_default_scripts', function( $scripts ) {
if ( ! empty( $scripts->registered['jquery'] ) ) {
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) );
}
} );
*/
add_filter( 'auto_update_plugin', '__return_false' );
function wpb_set_post_views($postID) {
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count++;
update_post_meta($postID, $count_key, $count);
}
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
function wpb_track_post_views ($post_id) {
if ( !is_single() ) return;
if ( empty ( $post_id) ) {
global $post;
$post_id = $post->ID;
}
wpb_set_post_views($post_id);
}
add_action( 'wp_head', 'wpb_track_post_views');
function wpb_get_post_views($postID){
$count_key = 'wpb_post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
$count = round($count/2);
return $count.' Views';
}
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
// Disable REST API link tag
remove_action('wp_head', 'rest_output_link_wp_head', 10);
// Disable oEmbed Discovery Links
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
// Disable REST API link in HTTP headers
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
add_action('admin_head', 'my_custom_fontss');
function my_custom_fontss() {
echo '<style>
#toplevel_page_invitation_details li:nth-child(4){
display:none;
}
#toplevel_page_invitation_details li:nth-child(6){
display:none;
}
</style>';
}
add_filter( 'manage_edit-groups_columns', 'my_edit_groups_columns' ) ;
function my_edit_groups_columns( $columns ) {
$columns_new = array();
foreach( $columns as $col_key => $col_label ) {
if ($col_key == 'date') {
//$columns_new['groups_group_leaders'] = __('Group Information', 'learndash');
$columns_new['school_name'] = __( 'Group Information', 'learndash' );
$columns_new['groups_group_courses'] = sprintf( _x('Group %s', 'Group Courses', 'learndash'), LearnDash_Custom_Label::get_label( 'courses' ));
$columns_new['groups_group_users'] = __('Group Users', 'learndash');
}
$columns_new[$col_key] = $col_label;
}
return $columns_new;
}
/*
// Add the custom columns to the book post type:
add_filter( 'manage_groups_posts_columns', 'set_custom_edit_book_columns' );
function set_custom_edit_book_columns($columns) {
$columns['school_name'] = __( 'School Name', 'your_text_domain' );
return $columns;
}
*/
// Add the data to the custom columns for the book post type:
add_action( 'manage_groups_posts_custom_column' , 'custom_book_column', 1, 2 );
function custom_book_column( $column, $post_id ) {
switch ( $column ) {
case 'school_name':
$group_leaders = learndash_get_groups_administrator_ids( $post_id );
foreach( $group_leaders as $user_id ) {
$user = get_user_by( 'id', $user_id );
echo "<b>School: ".get_user_meta( $user_id, 'school_name', true )."</b><br>";
echo 'Name: <a href="'. get_edit_user_link( $user_id ) .'">'. $user->first_name .' '.$user->last_name .'</a><br>';
}
break;
}
}
function wpachievements_myachievements_func_new( $atts ) {
if( is_user_logged_in() ){
extract( shortcode_atts( array(
'user_id' => '',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $current_user, $wpdb;
get_currentuserinfo();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
//$myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', WPACHIEVEMENTS_TEXT_DOMAIN) .'</h3>';
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
if(function_exists('is_multisite') && is_multisite()){
$sim_ach = get_blog_option(1,'wpachievements_sim_ach');
} else{
$sim_ach = get_option('wpachievements_sim_ach');
}
$ii=0;
$iii=0;
$achievement_badges='';
if( !empty($userachievement) && $userachievement != '' ){
if(function_exists('is_multisite') && is_multisite()){
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'true'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$already_counted[$type] = $ach_occurences;
$achievement_badges[$type] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon',WPACHIEVEMENTS_TEXT_DOMAIN).'" title="'.stripslashes($ach_title).': '.stripslashes($ach_desc).'" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(function_exists('is_multisite') && is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', WPACHIEVEMENTS_TEXT_DOMAIN) .'</p>';
}
$myachievements .= '</div>';
return $myachievements;
}
}
add_shortcode( 'wpa_myachievements_new', 'wpachievements_myachievements_func_new' );
// Register and load the widget
function wpb_load_widget() {
register_widget( 'wpb_widget' );
}
add_action( 'widgets_init', 'wpb_load_widget' );
// Creating the widget
class wpb_widget extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widget',
// Widget name will appear in UI
__('Achievements Widget', 'wpb_widget_domain'),
// Widget description
array( 'description' => __( 'Sample widget based on Achievements', 'wpb_widget_domain' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( ! empty( $title ) )
echo $args['before_title'] . $title . $args['after_title'];
// This is where you run the code and display the output
//echo __( 'Hello, World!', 'wpb_widget_domain' );
if( is_user_logged_in() ){
echo "<div class='achievements_users'>";
?>
<div class="image-users-wrp">
<div class="image">
<?php
$user_id = get_current_user_id();
/*
$user = get_userdata( $user_id );
$profile_pic = ($user!=='add-new-user') ? get_user_meta($user->ID, 'shr_pic', true): false;
if( !empty($profile_pic) ){
$image = wp_get_attachment_image_src( $profile_pic, 'thumbnail' );
}
*/
$profile_img = 'profile_img';
$profile_pic = get_post_meta($user_id, $profile_img, true);
if(empty($profile_pic)){ ?>
<img src="<?php echo home_url(); ?>/wp-content/uploads/2017/12/user-icon.png" class="user-icon" />
<?php }else{ ?>
<img class="user-icon" src="<?php echo home_url("/img/").$profile_pic; ?>" style="<?php echo empty($profile_pic) ? 'display:none;' :'' ?>" />
<?php } ?>
</div>
<div class="user-info">
<?php
$current_user = wp_get_current_user();
echo "<b>".$current_user->user_firstname ." ". $current_user->user_lastname."</b><br>";
$school_address = get_user_meta( get_current_user_id(), 'school_address', true );
echo $school_name = get_user_meta( get_current_user_id(), 'school_name', true );
?>
</div>
</div>
<?php
echo "<div class='achievements'>";
extract( shortcode_atts( array(
'user_id' => '',
'show_title' => 'true',
'title_class' => '',
'image_holder_class' => '',
'image_class' => 'wpa_a_image',
'image_width' => '30',
'achievement_limit' => '',
), $atts ) );
global $wpdb;
$current_user = wp_get_current_user();
if( $user_id ){
$cur_user = $user_id;
} else{
$cur_user = $current_user->ID;
}
$userachievement = (array) get_user_meta( $cur_user, 'achievements_gained', true );
$myachievements = '';
if( $show_title == 'true' || $show_title == 'True' ){
// $myachievements .= '<h3 class="ach_short_title '. $title_class .'">'. __('My Achievements', 'wpachievements') .'</h3>';
}
$myachievements .= '<div class="'. $image_holder_class .'">';
$already_counted[] = array();
$sim_ach = wpachievements_get_site_option( 'wpachievements_sim_ach' );
$ii=0;
$iii=0;
$achievement_badges = array();
if ( ! empty( $userachievement ) ) {
if( is_multisite() ) {
switch_to_blog(1);
}
$args = array(
'post_type' => 'wpachievements',
'post_status' => 'publish',
'post__in' => $userachievement,
'posts_per_page' => -1
);
$achievement_query = new WP_Query( $args );
if( $achievement_query->have_posts() ){
while( $achievement_query->have_posts() ){
$achievement_query->the_post();
$ii++;
$ach_ID = get_the_ID();
$ach_title = get_the_title();
$ach_desc = get_the_content();
$ach_data = $ach_title.': '.$ach_desc;
$ach_img = get_post_meta( $ach_ID, '_achievement_image', true );
$ach_points = get_post_meta( $ach_ID, '_achievement_points', true );
$ach_woopoints = get_post_meta( $ach_ID, '_achievement_woo_points', true );
$ach_rank = get_post_meta( $ach_ID, '_achievement_rank', true );
$ach_occurences = get_post_meta( $ach_ID, '_achievement_occurrences', true );
$type = 'wpachievements_achievement_'.get_post_meta( $ach_ID, '_achievement_type', true );
if($sim_ach == 'yes'){
if( !array_key_exists($type,$already_counted) ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
} elseif( $already_counted[$type] <= $ach_occurences ){
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
if( $type != 'wpachievements_achievement_custom_achievement' ){
$already_counted[$type] = $ach_occurences;
}
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
} else{
$iii++;
if( $iii == 1 ){ $first='first '; } else{ $first=''; }
$achievement_badges[$ii] = '<img src="'.$ach_img.'" width="'. $image_width .'" class="'. $first . $image_class .'" alt="'.stripslashes($ach_title).__(' Icon','wpachievements').'" title="'.stripslashes($ach_title).': '.stripslashes(strip_tags($ach_desc)).'" style="width:'.$image_width.'px !important;" />';
}
if( $achievement_limit > 0 && $iii >= $achievement_limit ){ break; }
}
if( is_array($achievement_badges) ){
foreach( $achievement_badges as $achievement_badge ){
$myachievements .= $achievement_badge;
}
}
}
wp_reset_postdata();
if(is_multisite()){
restore_current_blog();
}
if( $iii==0 ){
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
} else{
$myachievements .= '<p>'. __('No Achievements Yet!', 'wpachievements') .'</p>';
}
$myachievements .= '</div></div>';
echo $myachievements;
echo '</div>';
echo '</div>';
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<!--<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>-->
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgets() {
register_widget( 'wpb_widgets' );
}
add_action( 'widgets_init', 'wpb_load_widgets' );
// Creating the widget
class wpb_widgets extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgets',
// Widget name will appear in UI
__('Quick Training', 'wpb_widget_domainss'),
// Widget description
array( 'description' => __( 'Sample widget based on Quick Training', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
$value = get_field( "quick_training", get_the_ID() );
echo '<h2 class="widget-title">Quick Training</h2>';
if($value){
echo $value;
}else{
echo "<style>#wpb_widgets-2{display:none;}</style>";
echo "<style>#wpb_widgets-3{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
// Register and load the widget
function wpb_load_widgetss() {
register_widget( 'wpb_widgetss' );
}
add_action( 'widgets_init', 'wpb_load_widgetss' );
// Creating the widget
class wpb_widgetss extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widgetss',
// Widget name will appear in UI
__('Rating', 'wpb_widget_domainsss'),
// Widget description
array( 'description' => __( 'Sample widget based on Rating', 'wpb_widget_domainss' ), )
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
// before and after widget arguments are defined by themes
echo $args['before_widget'];
if ( is_singular( 'sfwd-topic' ) ) {
if(function_exists('the_ratings')){ the_ratings(); }
}else{
echo "<style>#wpb_widgetss-2{display:none;}</style>";
}
echo $args['after_widget'];
}
// Widget Backend
public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ];
}
else {
$title = __( 'New title', 'wpb_widget_domain' );
}
// Widget admin form
?>
<?php
}
// Updating widget replacing old instances with new
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
function register_my_session(){
if( !session_id() ){
session_start();
}
}
add_action('init', 'register_my_session');
//require 'rate-lessons.php';
function bartag_func( $atts ) {
return get_the_title( get_the_ID() );
}
add_shortcode( 'lesson-name', 'bartag_func' );
/*
function iconic_account_menu_items( $items ) {
$items['manage-content'] = __( 'Manage Content', 'iconic' );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'iconic_account_menu_items', 10, 1 );
*/
}
add_action('init', 'register_my_session');
//require 'rate-lessons.php';
function bartag_func( $atts ) {
return get_the_title( get_the_ID() );
}
add_shortcode( 'lesson-name', 'bartag_func' );
/*
function iconic_account_menu_items( $items ) {
$items['manage-content'] = __( 'Manage Content', 'iconic' );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'iconic_account_menu_items', 10, 1 );
*/
Comments
Post a Comment