Created
December 25, 2021 11:49
-
-
Save imranhoshain/62ed8a5e7d00416feed2e50126129456 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // child here | |
| function ptc_my_theme_enqueue_styles() | |
| { | |
| $parent_style = "parent-style"; // | |
| //wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); | |
| wp_enqueue_style( | |
| "child-style", | |
| get_stylesheet_directory_uri() . "/style.css", | |
| [$parent_style], | |
| wp_get_theme()->get("Version") | |
| ); | |
| } | |
| add_action("wp_enqueue_scripts", "ptc_my_theme_enqueue_styles"); | |
| //Entrepreneur All User ShortCode | |
| if(!function_exists('entrepreneur_all_user_list_shortcode')) | |
| { | |
| function entrepreneur_all_user_list_shortcode($uid) | |
| { | |
| $args = array( | |
| 'role' => 'business_owner', | |
| 'orderby' => 'user_nicename', | |
| 'order' => 'ASC' | |
| ); | |
| $users = get_users( $args ); | |
| ?> | |
| <div class="box_content " style="padding:0"> | |
| <?php | |
| foreach ( $users as $user ) { | |
| $uid = $user->ID; | |
| $all_meta_for_user = get_user_meta($uid); | |
| $get_user_info = get_userdata($uid); | |
| $full_name = $get_user_info->first_name. ' '. $get_user_info->last_name; | |
| $full_name_tem = trim($full_name); | |
| if(empty($full_name_tem)) $full_name = $get_user_info->user_login; | |
| ?> | |
| <div class="card p-3 pt-4 pb-4"> | |
| <div class="user-table-row"> | |
| <div class="row"> | |
| <div class="col-xs-12 col-sm-8 col-md-4 col-lg-2 av-usr"> | |
| <div class="full-width-div"> | |
| <a href="<?php echo ProjectTheme_get_user_profile_link($uid); ?>"><img src="<?php echo ProjectTheme_get_avatar($uid,95, 95) ?>" | |
| alt="avatar-user" class="acc_m1 av1z" width="95" height="95" /> | |
| </a> | |
| <?php //echo get_avatar($uid, 64 );?> | |
| </div> | |
| </div> | |
| <div class="user-table-user-info col-xs-12 col-sm-4 col-md-8 col-lg-10"> | |
| <h3> | |
| <a href="<?php echo ProjectTheme_get_user_profile_link($uid) ?>"><?php echo $full_name ?> | |
| </a> | |
| </h3> | |
| <p class="about-ttl">About:</p> | |
| <p class="excerpt-thing pt-0"> | |
| <?php | |
| $user_description = get_user_meta($uid,'user_description',true); | |
| $user_description = strip_tags($user_description); | |
| if(empty($user_description)) _e('This user doesnt have a description.','ProjectTheme'); | |
| else{ | |
| echo substr(trim($user_description),0,270); | |
| } | |
| ?> | |
| </p> | |
| <p class="about-ttl">Location: </p> | |
| <div class="row-with-tags"> | |
| <h5 class="my-badge3"> | |
| <?php | |
| $user_location = get_user_meta($uid,'user_location',true); | |
| $user_location = strip_tags($user_location); | |
| if(empty($user_location)) _e('This user doesnt select any location.','ProjectTheme'); | |
| else{ | |
| echo substr(trim($user_location),0,270); | |
| } | |
| ?> | |
| </h5> | |
| </div> | |
| <div class="user-poster-thing"> | |
| <div class="user-avatar-me fun-time"> | |
| <div class="post-main-details"> | |
| <ul> | |
| <li><?php echo ProjectTheme_project_get_star_rating($uid); ?></li> | |
| <li> | |
| <a href="<?php echo ProjectTheme_get_priv_mess_page_url('send', '', '&uid='.$uid.'&pid='); ?>"><?php _e('Contact User','ProjectTheme'); ?> | |
| </a> | |
| </li> | |
| <li class="last"> | |
| <a href="<?php echo ProjectTheme_get_user_feedback_link($uid); ?>"><?php _e('User Feedback','ProjectTheme'); ?> | |
| </a> | |
| </li> | |
| </ul> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- end user-poster-thing --> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <?php | |
| } ?> | |
| </div> | |
| <?php | |
| } | |
| add_shortcode("entrepreneur_all_user", "entrepreneur_all_user_list_shortcode"); | |
| } | |
| ///Entrepreneur Search User ShortCode | |
| if(!function_exists('entrepreneur_search_shortcode')) | |
| { | |
| function entrepreneur_search_shortcode() | |
| { | |
| global $wpdb; | |
| ?> | |
| <script> | |
| jQuery(document).ready(function() { | |
| jQuery("#filters-button-show-hide").click(function(){ | |
| jQuery("#filter-optns").slideToggle(); | |
| }); | |
| }); | |
| </script> | |
| <div id="right-sidebar" class="search-area"> | |
| <ul class="search-sidebar-ul" id="search-page-ulz"> | |
| <li class="" id="filters-things"> | |
| <h3 class="widget-title"><?php _e('Filter Options','ProjectTheme'); ?></h3> | |
| <a href="#" id="filters-button-show-hide"><i class="fas fa-filter"></i></a> | |
| <form method="get" id="filter-optns"> | |
| <div class="my_row_m1"> | |
| <div class="full_width_m1"><?php _e('Username like:','ProjectTheme'); ?></div> | |
| <div class="full_width_m1"><input type="text" class="form-control" value="<?php echo htmlentities($_GET['username']); ?>" name="username" /></div> | |
| </div> | |
| <script> | |
| jQuery(document).ready(function( ) { | |
| jQuery('#onlinestatus').lc_switch('<?php _e('YES', 'ProjectTheme') ?>','<?php _e('NO', 'ProjectTheme') ?>'); | |
| }); | |
| </script> | |
| <div class="my_row_m1"> | |
| <div class="full_width_m1" style="float: left; width: auto"><?php _e('Online status?','ProjectTheme'); ?></div> | |
| <div class="full_width_m1" style="float: right; width: auto"><input type="checkbox" value="1" name="online" id="onlinestatus" <?php echo $_GET['online'] == "1" ? "checked='checked'" : "" ?> /></div> | |
| </div> | |
| <div class="my_row_m1 apply-filters-button-container"> | |
| <div class="full_width_m1"> | |
| <input type="submit" value="<?php _e('Apply Filters','ProjectTheme'); ?>" class="btn btn-block btn-primary" name="business_owner" /> | |
| </div> | |
| </div> | |
| </form> | |
| </li> | |
| <?php dynamic_sidebar( 'other-page-area' ); ?> | |
| </ul> | |
| </div> | |
| <div class='col-xs-12 col-sm-12 col-md-8 col-lg-9' > | |
| <div class="box_content " style="padding:0"> | |
| <?php | |
| $ProjectTheme_enable_2_user_tp = get_option('ProjectTheme_enable_2_user_tp'); | |
| $pg = $_GET['pg']; | |
| if(empty($pg)) $pg = 1; | |
| $nrRes = 8; | |
| //------------------ | |
| $offset = ($pg-1)*$nrRes; | |
| //------------------ | |
| if(isset($_GET['username'])) | |
| $args['search'] = "*".trim($_GET['username'])."*"; | |
| // prepare arguments | |
| $args['orderby'] = 'display_name'; | |
| $arr_aray = array(); | |
| $inner = ''; | |
| $where = ''; | |
| $rf_demo = true; | |
| $rf_demo = apply_filters("ProjectTheme_rf_demo", $rf_demo); | |
| if($ProjectTheme_enable_2_user_tp == "yes" and $rf_demo) | |
| { | |
| $arr_sbg = array( | |
| // uses compare like WP_Query | |
| 'key' => 'user_tp', | |
| 'value' => 'business_owner', | |
| 'compare' => '=' | |
| ); | |
| array_push( $arr_aray, $arr_sbg); | |
| } | |
| //----------------------------------------------- | |
| global $wpdb; | |
| $wpdb->show_errors = true; | |
| if(!empty($_GET['username'])) | |
| { | |
| $us = addslashes($_GET['username']); | |
| $inner .= ' INNER JOIN '.$wpdb->prefix.'usermeta AS mt2 ON ( '.$wpdb->prefix.'users.ID = mt2.user_id ) INNER JOIN '.$wpdb->prefix.'usermeta AS mt3 ON ( '.$wpdb->prefix.'users.ID = mt3.user_id ) '; | |
| $addition = " AND ( user_login like '%".$us."%' or (mt2.meta_key = 'first_name' AND mt2.meta_value LIKE '%".$us."%') | |
| or (mt3.meta_key = 'last_name' AND mt3.meta_value LIKE '%".$us."%') ) "; | |
| } | |
| //online | |
| if(!empty($_GET['online'])) | |
| { | |
| $tm = current_time('timestamp') - 300; | |
| $inner .= ' INNER JOIN '.$wpdb->prefix.'usermeta AS mt5 ON ( '.$wpdb->prefix.'users.ID = mt5.user_id ) '; | |
| $addition .= " AND (mt5.meta_key = 'lastonline' AND mt5.meta_value > $tm) "; | |
| } | |
| //---- main query here ---------- | |
| $main_query = "SELECT SQL_CALC_FOUND_ROWS distinct ".$wpdb->prefix."users.* FROM ".$wpdb->prefix."users | |
| ".$inner." | |
| INNER JOIN ".$wpdb->prefix."usermeta AS mt1 ON ( ".$wpdb->prefix."users.ID = mt1.user_id ) | |
| WHERE 1=1 | |
| ".$where." | |
| AND mt1.meta_key = '".$wpdb->prefix."capabilities' AND mt1.meta_value LIKE '%business\_owner%' ".$addition." ORDER BY display_name ASC LIMIT ".$offset.", " . $nrRes; | |
| $res = $wpdb->get_results($main_query); | |
| $found_rows = "SELECT FOUND_ROWS() as XROWS"; | |
| $res2 = $wpdb->get_results($found_rows); | |
| var_dump($res); | |
| $fnd_rows = $res2[0]->XROWS; | |
| // $wpdb->print_error(); | |
| // Get the results | |
| $ttl = $fnd_rows; | |
| $nrPages = ceil($ttl / $nrRes); | |
| // Check for results | |
| if (count($res) > 0) | |
| { | |
| foreach ($res as $author) | |
| { | |
| // get all the user's data | |
| echo '<div class="card p-3 pt-4 pb-4">'; | |
| //entrepreneur_all_user_list_shortcode($uid); | |
| echo '</div>'; | |
| } | |
| echo '<ul class="pagination">'; | |
| $totalPages = $nrPages; | |
| $my_page = $pg; | |
| $page = $pg; | |
| $batch = 10; | |
| $nrpostsPage = $nrRes; | |
| $end = $batch * $nrpostsPage; | |
| if ($end > $pagess) { | |
| $end = $pagess; | |
| } | |
| $start = $end - $nrpostsPage + 1; | |
| if($start < 1) $start = 1; | |
| $links = ''; | |
| $raport = ceil($my_page/$batch) - 1; if ($raport < 0) $raport = 0; | |
| $start = $raport * $batch + 1; | |
| $end = $start + $batch - 1; | |
| $end_me = $end + 1; | |
| $start_me = $start - 1; | |
| if($end > $totalPages) $end = $totalPages; | |
| if($end_me > $totalPages) $end_me = $totalPages; | |
| if($start_me <= 0) $start_me = 1; | |
| $previous_pg = $page - 1; | |
| if($previous_pg <= 0) $previous_pg = 1; | |
| $next_pg = $page + 1; | |
| if($next_pg > $totalPages) $next_pg = 1; | |
| if($my_page > 1) | |
| { | |
| echo '<li class="page-item"><a href="'.projectTheme_provider_search_link() .'pg='.$previous_pg.'" class="page-link"><i class="fas fa-chevron-left"></i> '.__('Previous','ProjectTheme').'</a></li>'; | |
| echo '<li class="page-item"><a href="'.projectTheme_provider_search_link() .'pg='.$start_me.'" class="page-link"><</a></li>'; | |
| } | |
| for($i=$start;$i<=$end;$i++) | |
| { | |
| if($i == $pg) | |
| echo '<li class="page-item active"><a href="#" class="page-link" >'.$i.'</a></li>'; | |
| else | |
| echo '<li class="page-item"><a href="'.projectTheme_provider_search_link() .'pg='.$i.'" class="page-link">'.$i.'</a></li>'; | |
| } | |
| if($totalPages > $my_page) | |
| echo '<li class="page-item"><a href="'.projectTheme_provider_search_link() .'pg='.$end_me.'" class="page-link">></a></li>'; | |
| if($page < $totalPages) | |
| echo '<li class="page-item"><a href="'.projectTheme_provider_search_link() .'pg='.$next_pg.'" class="page-link">'.__('Next','ProjectTheme').' <i class="fas fa-chevron-right"></i></a></li>'; | |
| echo '</ul>'; | |
| } else { | |
| echo '<div class="card p-3">'; | |
| echo __('No service providers found for this query.', 'ProjectTheme' ); | |
| echo '</div>'; | |
| } | |
| ?> | |
| </div> | |
| </div> | |
| <?php | |
| } } | |
| add_shortcode("entrepreneur_search", "entrepreneur_search_shortcode"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment