File: /mnt/data/mentoring-wp/wp-content/plugins/simple-shortcode/shortcodes.php
<?php
/**
* Plugin Name: Simple Shortcode
* Description: This is simple shortcode plugin.
* Version: 1.2.9
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: mentoring_simple_shortcode
* * Domain Path: /languages
*/
function mentors_loop_shortcode() {
$args = array(
'post_type' => 'mentors',
'post_status' => 'publish',
'posts_per_page' => -1
);
$my_query = null;
$my_query = new WP_query($args);
?>
<div class="home_mentor_slider">
<?php
if($my_query->have_posts()):
while($my_query->have_posts()) : $my_query->the_post();
$custom = get_post_custom( get_the_ID() );
if ( has_post_thumbnail() ) {
$url = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()), 'thumbnail' );
}else{
$url=get_template_directory_uri( ) ."/assets/images/dravatar-100x100.jpg";
}
$am_courses = mentoring_get_post_meta( get_the_ID(),'am_courses');
$feedback = get_post_meta(get_the_ID(),'review_data',true);
$feedback = !empty( $feedback ) ? $feedback : array();
$total_rating = !empty( $feedback['dc_total_rating'] ) ? $feedback['dc_total_rating'] : 0 ;
$total_percentage = !empty( $feedback['dc_total_percentage'] ) ? $feedback['dc_total_percentage'] : 0 ;
$name = mentoring_full_name(get_the_ID() );
$name = !empty( $name ) ? $name : '';
$starting_price = mentoring_get_post_meta( get_the_ID(), 'am_starting_price');
ob_start();
?>
<div class="col-xl-4 col-lg-6 col-md-6 col-sm-12 slide_item" style="width:370px;">
<div class="row">
<div class="col-lg-12">
<div class="sigma_mentor-thumb sigma-filter-img-wrapper">
<img src="<?php echo esc_html ($url);?>"/>
</div>
</div>
<div class="col-lg-12">
<div class="sigma_mentor-body">
<h5>
<a href="<?php echo get_permalink(get_the_ID())?>"><?php echo esc_html ($name);?></a>
</h5>
<span class="mentor_spec"><?php do_action('mentoring_specilities_list',get_the_ID(),1);?></span>
<div class="ratings">
<div class="empty-stars"></div>
<div class="full-stars" style="width: <?php echo intval( $total_percentage );?>%"></div>
</div>
<div class="mentor_loc">
<i class="fas fa-map-marker-alt"></i>
<?php
$first_category = wp_get_post_terms( get_the_ID(), 'locations' )[0]->name;
echo esc_html($first_category);
?>
</div>
</div>
</div>
</div>
</div>
<?php
echo ob_get_clean();
endwhile;
wp_reset_postdata();
else :
_e( 'Sorry, no posts matched your criteria.' );
?>
<?php
endif;
?>
</div>
<?php
}
function home_searchform_shortcode(){
global $mentoring_options;
$hide_location = !empty($mentoring_options['hide_location']) ? $mentoring_options['hide_location'] : 'no';
$search_settings = !empty( $mentoring_options['search_form'] ) ? $mentoring_options['search_form'] : '';
$search_option = !empty($mentoring_options['search_type']) ? $mentoring_options['search_type'] : '';
$search_type = !empty($mentoring_options['search_type']) ? $mentoring_options['search_type'] : '';
ob_start();
if( !empty($search_settings) ){?>
<div class="search-box">
<form action="<?php echo home_url();?>/search-mentors" method="get" id="search_form">
<div class="form-group search-location">
<div class="dc-select">
<?php do_action('mentoring_get_search_locations');?>
</div>
</div>
<div class="form-group search-info">
<?php do_action('mentoring_get_search_text_field');?>
</div>
<button type="submit" class="btn btn-primary search-btn"><span><?php esc_attr_e('Search','mentoring_simple_shortcode');?></span></button>
</form>
</div>
<?php
}
echo ob_get_clean();
}
function shortcodes_init(){
add_shortcode( 'mentors_loop', 'mentors_loop_shortcode' );
add_shortcode( 'homesearch_form', 'home_searchform_shortcode' );
}
add_action('init', 'shortcodes_init');
/* Register*/
function mentoring_registerform(){
global $current_user, $wp_roles,$mentoring_options;
ob_start();
$site_key = '';
$protocol = is_ssl() ? 'https' : 'http';
$login_register = !empty( $mentoring_options['user_registration'] ) ? $mentoring_options['user_registration'] : '';
$registration_form = !empty( $mentoring_options['registration_form'] ) ? $mentoring_options['registration_form'] : '';
$login_form = !empty( $mentoring_options['login_form'] ) ? $mentoring_options['login_form'] : '';
$redirect = !empty( $_GET['redirect'] ) ? esc_url( $_GET['redirect'] ) : '';
$reg_option = !empty( $mentoring_options['user_type_registration'] ) ? $mentoring_options['user_type_registration'] : array();
$step_image = !empty( $mentoring_options['step_image']['url'] ) ? $mentoring_options['step_image']['url'] : '';
$step_title = !empty( $mentoring_options['step_title'] ) ? $mentoring_options['step_title'] : esc_html__('Join For a Good Start', 'mentoring_simple_shortcode');
$step_desc = !empty( $mentoring_options['step_description'] ) ? $mentoring_options['step_description'] : '';
$term_text = !empty( $mentoring_options['term_text'] ) ? $mentoring_options['term_text'] : '';
$remove_location = !empty( $mentoring_options['remove_location'] ) ? $mentoring_options['remove_location'] : 'no';
$terms_link = !empty( $mentoring_options['term_page'] ) ? get_permalink( intval( $mentoring_options['term_page'] ) ) : '';
$user_types = array();
if( function_exists( 'mentoring_list_user_types' ) ) {
$user_types = mentoring_list_user_types();
}
?>
<div class="bg-pattern-style bg-pattern-style-register">
<div class="content">
<div class="account-content">
<div class="account-box">
<div class="login-right">
<div class="login-header">
<h3>
<?php bloginfo( 'name' ); ?>
<span>
<?php if( !empty( $step_title ) ) { ?>
<?php if( !empty( $step_title ) ) { ?>
<?php echo esc_attr( $step_title ); ?>
<?php } ?>
<?php } ?>
</span></h3>
<p class="text-muted">
<?php if( !empty( $step_desc ) ) { ?>
<?php echo do_shortcode( $step_desc ); ?>
<?php } ?>
</p>
</div>
<?php
if (!is_user_logged_in()) {?>
<div class="dc-registerformhold">
<form class="dc-formtheme dc-formregister">
<div class="tab-content dc-registertabcontent">
<div class="dc-registerformmain">
<div class="dc-joinforms">
<fieldset class="dc-registerformgroup">
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label><?php esc_html_e('First Name', 'mentoring_simple_shortcode'); ?></label>
<input type="text" name="first_name" class="form-control" value="">
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label><?php esc_html_e('Last Name', 'mentoring_simple_shortcode'); ?></label>
<input type="text" name="last_name" value="" class="form-control">
</div>
</div>
</div>
<div class="form-group">
<label><?php esc_html_e('Username', 'mentoring_simple_shortcode'); ?></label>
<input type="text" name="username" class="form-control" value="">
</div>
<div class="form-group">
<label>Email Address</label>
<input type="email" name="email" class="form-control" value="">
</div>
</fieldset>
<fieldset class="dc-registerformgroup">
<div class="form-group">
<?php if(!empty($remove_location) && $remove_location == 'no'){?>
<span class="dc-select">
<?php do_action('mentoring_get_locations_list','location',''); ?>
</span>
<?php }?>
</div>
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label><?php esc_html_e('Password', 'mentoring_simple_shortcode'); ?></label>
<input type="password" name="password" class="form-control" >
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label><?php esc_html_e('Confirm Password', 'mentoring_simple_shortcode'); ?></label>
<input type="password" name="verify_password" class="form-control">
</div>
</div>
</div>
</fieldset>
<fieldset class="dc-formregisterstart">
<div class="row">
<div class="col-lg-12 col-md-12">
<div class="form-group">
<label>Start as</label>
<?php if( !empty( $user_types ) ){ ?>
<ul class="dc-startoption">
<?php
foreach( $user_types as $key => $val) {
$checked = !empty( $key ) && $key === 'mentors' ? 'checked=""' : '';
$display = !empty( $key ) && $key === 'seller' ? esc_html__('Store name','mentoring_simple_shortcode') : esc_html__('Display name','mentoring_simple_shortcode');
?>
<li>
<span class="dc-radio" data-display="<?php echo esc_attr($display);?>">
<input id="dc-<?php echo esc_attr($key);?>" type="radio" name="user_type" value="<?php echo esc_attr($key);?>" <?php echo esc_attr($checked);?>>
<label for="dc-<?php echo esc_attr($key);?>"><?php echo esc_html($val);?></label>
</span>
</li>
<?php ?>
<?php } ?>
</ul>
<?php } ?>
</div>
</div>
</div>
</fieldset>
<fieldset class="dc-termsconditions">
<div class="dc-checkboxholder">
<div class="form-group form-group-half wt-display-type">
<label><?php esc_html_e('Display Name', 'mentoring_simple_shortcode'); ?></label>
<input type="text" name="display_name" class="form-control" value="" >
</div>
<span>
<input id="termsconditions" type="checkbox" name="termsconditions" value="checked">
<label for="termsconditions">
<span>
<?php echo esc_html( $term_text ); ?>
<?php if( !empty( $terms_link ) ) { ?>
<a target="_blank" rel="noopener" href="<?php echo esc_url( $terms_link ); ?>">
<?php esc_html_e('Terms & Conditions', 'mentoring_simple_shortcode'); ?>
</a>
<?php } ?>
</span>
</label>
</span>
<div class="form-group mb-0">
<button class="dc-btn rg-step-start" type="submit"><?php esc_html_e('Create Account', 'mentoring_simple_shortcode'); ?></button>
</div>
</div>
</fieldset>
</div>
</div>
</div>
<?php if( !is_user_logged_in() ){ ?>
<div class="text-center dont-have">
<span><?php esc_html_e('Already Have an Account?', 'mentoring_simple_shortcode' ); ?><a href="<?php echo home_url();?>/login"> <?php esc_html_e('Login', 'mentoring_simple_shortcode'); ?></a></span>
</div>
<?php } ?>
</form>
</div>
</div>
</div>
<?php
} ?>
</div>
</div>
</div>
<?php
echo ob_get_clean();
}
add_shortcode( 'mentoring_register', 'mentoring_registerform' );
/*Login */
function mentoring_loginform(){
global $mentoring_options,$post,$current_user;
$is_auth = !empty( $mentoring_options['user_registration'] ) ? $mentoring_options['user_registration'] : '';
$is_register = !empty( $mentoring_options['registration_form'] ) ? $mentoring_options['registration_form'] : '';
$is_login = !empty( $mentoring_options['login_form'] ) ? $mentoring_options['login_form'] : '';
$redirect = !empty( $_GET['redirect'] ) ? esc_url( $_GET['redirect'] ) : '';
$current_page = '';
if ( is_singular('mentors')){
$current_page = !empty( $post->ID ) ? intval( $post->ID ) : '';
}
$user_identity = !empty($current_user->ID) ? $current_user->ID : 0;
$user_type = apply_filters('mentoring_get_user_type', $user_identity );
$step_desc = !empty( $mentoring_options['step_description'] ) ? $mentoring_options['step_description'] : '';
if ( is_user_logged_in() ) {
if ( !empty($menu) && $menu === 'yes' && ( $user_type === 'mentors' || $user_type === 'institute' || $user_type === 'mentee') ) {
echo '<div class="dc-afterauth-buttons">';
do_action('mentoring_print_user_nav');
echo '</div>';
}
} else{
if( !empty( $is_auth ) ){
ob_start();
?>
<div class="main-wrapper">
<div class="bg-pattern-style">
<div class="content">
<div class="account-content">
<div class="account-box">
<div class="login-right">
<?php if( !empty( $is_login ) ) {?>
<div class="dc-loginoption">
<div class="dc-loginformhold">
<div class="dc-loginheader">
<h3><span class="titlelogin"><?php esc_html_e('LOGIN','mentoring_simple_shortcode');?></span><span class="mentoringtitle"><?php bloginfo( 'name' ); ?></span></h3>
<p class="text-muted">
<?php if( !empty( $step_desc ) ) { ?>
<?php echo do_shortcode( $step_desc ); ?>
<?php } ?>
</p>
</div>
<form class="dc-formtheme dc-loginform do-login-form">
<div class="form-group form-focus">
<label class="form-control-label"><?php esc_html_e('Username / Email','mentoring_simple_shortcode');?></label>
<input type="text" name="username" id="user_login" class="form-control">
</div>
<div class="form-group form-focus">
<label class="form-control-label"><?php esc_html_e('Password','mentoring_simple_shortcode');?></label>
<input type="password" name="password" id="user_pass" class="form-control pass-input">
<span class="fas fa-eye toggle-password"></span>
</div>
<a class="forgot-link" href="<?php echo home_url(); ?>/forgot-password"><?php esc_html_e('Forgot password?','mentoring_simple_shortcode');?></a>
<div class="dc-logininfo">
<input type="submit" class="login-btn dc-btn do-login-button" data-id="<?php echo intval($current_page);?>" value="<?php esc_attr_e('Login','mentoring');?>">
</div>
<input type="hidden" name="redirect" value="<?php echo esc_url( $redirect );?>">
<input type="hidden" name="redirect_id" value="<?php echo intval($current_page);?>">
<?php if( !is_user_logged_in() ){ ?>
<div class="text-center dont-have">
<span><?php esc_html_e('Don’t have an account?', 'mentoring_simple_shortcode' ); ?><a href="<?php echo home_url();?>/register"> <?php esc_html_e('Register', 'mentoring_simple_shortcode'); ?></a></span>
</div>
<?php } ?>
</form>
<style>
.login-or {
color: #818181;
margin-bottom: 30px;
margin-top: 30px;
padding-bottom: 10px;
padding-top: 10px;
position: relative;
}
.or-line {
background-color: #EFEFEF;
height: 1px;
margin-bottom: 0;
margin-top: 0;
display: block;
}
.span-or {
background-color: #fff;
display: block;
left: 50%;
transform: translateX(-50%);
position: absolute;
text-align: center;
top: -3px;
width: 190px;
}
.login-info {
margin-top: 20px;
background: #fff;
}
.login-wrap .info-box .badge {
margin: 0;
}
.info-box {
gap: 10px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
border: 1px solid #F7F7FF;
margin-bottom: 10px;
text-align: left;
background: #F7F7FF;
border-radius: 10px;
}
.info-box p{
text-align: left;
font-weight: bold;
margin-bottom: 0;
}
.info-box span {
font-weight: normal;
}
.demobutton,.demobutton:hover, .demobutton:active{
background:var(--doccure_secthemecolor) !important;
border-color:var(--doccure_secthemecolor) !important;
}
</style>
<div class="login-or">
<span class="or-line"></span>
<h5 class="span-or">Demo Login </h5>
</div>
<div class="login-info">
<div class="info-box">
<span class="btn btn-dark dc-btn btn-sm">Mentor</span>
<div>
<p>Username: <span id="provider-email">mentordemo</span></p>
<p>Password: <span id="provider-password">123456</span></p>
</div>
<button class="fill-btn btn btn-primary dc-btn btn-sm" onclick="fillLogin('mentordemo', '123456')"><i class="fa fa-copy"></i></button>
</div>
<div class="info-box">
<span class="btn btn-dark dc-btn btn-sm ">Mentee</span>
<div>
<p>Username: <span id="user-email">menteedemo</span></p>
<p>Password: <span id="user-password">123456</span></p>
</div>
<button class="fill-btn btn btn-primary dc-btn btn-sm" onclick="fillLogin('menteedemo', '123456')"><i class="fa fa-copy"></i></button>
</div>
</div>
<script>
// Function to fill email and password fields
function fillLogin(email, password) {
document.getElementById('user_login').value = email;
document.getElementById('user_pass').value = password;
}
</script>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php }
}
echo ob_get_clean();
}
add_shortcode( 'mentoring_login', 'mentoring_loginform' );
/*Homepage Blog */
function homeblog_loop_shortcode() {
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' =>3,
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
$my_query = null;
$my_query = new WP_query($args);
?>
<div class="latest-news">
<div class="row">
<?php
if($my_query->have_posts()):
while($my_query->have_posts()) : $my_query->the_post();
$custom = get_post_custom( get_the_ID() );
if ( has_post_thumbnail() ) {
$url = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()), 'thumbnail' );
}else{
$url=get_template_directory_uri( ) ."/assets/images/dravatar-100x100.jpg";
}
ob_start();
?>
<div class="col-lg-12 col-md-12 col-sm-12">
<article>
<div class="homeblog_img">
<a href="<?php the_permalink();?>"><img src="<?php echo $url;?>"/></a>
</div>
<div class="homeblog_content_block">
<div class="homeblog_meta">
<span class="author">
<?php echo get_avatar( get_the_author_meta( 'ID' ), 32 ); ?>
<a class="url fn n" href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?>">
<?php echo get_the_author(); ?> </a>
</span>
<span class="posted-on">
<i class="far fa-clock"></i><?php echo get_the_date(); ?>
</span>
</div>
<h5><a href="<?php the_permalink();?>"><?php the_title();?></a></h5>
<p>
<?php echo wp_trim_words( get_the_content(), 20, '...' );?>
</p>
</div>
</article>
</div>
<?php //default blog
echo ob_get_clean();
endwhile;
wp_reset_postdata();
else :
esc_html( 'Sorry, no posts matched your criteria.' );
endif;
?>
</div>
</div>
<?php
}
add_shortcode( 'homeblog_loop', 'homeblog_loop_shortcode' );
/*Homepage Faq */
function homefaq_loop_shortcode() {
$args = array(
'post_type' => 'testimonials',
'post_status' => 'publish',
'posts_per_page' =>4,
'orderby' => 'meta_value_num',
'order' => 'DESC'
);
$my_query = null;
$my_query = new WP_query($args);
?>
<div class="testimonial-news">
<div class="row">
<?php
if($my_query->have_posts()):
while($my_query->have_posts()) : $my_query->the_post();
$custom = get_post_custom( get_the_ID() );
ob_start();
?>
<div class="col-xl-6 col-lg-6 col-md-12 col-sm-12">
<article>
<div class="testimonial_body">
<div class="d-flex align-items-center">
<div class="testimonial_author">
<h5><?php the_title();?></h5>
</div>
</div>
<div class="d-block d-sm-flex mt-4">
<span class="fas fa-quote-left testimonial-icon"></span>
<p><?php echo wp_trim_words( get_the_content(), 20, '...' );?></p>
</div>
</div>
</article>
</div>
<?php //default blog
echo ob_get_clean();
endwhile;
wp_reset_postdata();
else :
esc_html( 'Sorry, no posts matched your criteria.' );
endif;
?>
</div>
</div>
<?php
}
add_shortcode( 'homefaq_loop', 'homefaq_loop_shortcode' );
/**
* Load plugin textdomain.
*
* @since 1.0.0
*/
/**
* Deactive plugin
*
* @throws error
* @return
*/
if( !function_exists('mentoring_simple_shortcode_load_textdomain') ) {
add_action( 'init', 'mentoring_simple_shortcode_load_textdomain' );
function mentoring_simple_shortcode_load_textdomain() {
load_plugin_textdomain( 'mentoring_simple_shortcode', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
}