HEX
Server: LiteSpeed
System: Linux server315.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: globfdxw (6114)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //home/globfdxw/diasporameetsafrica.com/wp-content/themes/DA10/_dating/functions.php
<?php

define('THEME_NAME','Dating Theme');
define('THEME_FOLDER','_dating'); 
define('THEME_KEY','da');


$CORE_TEMPLATE = new core_dating;
class core_dating  {

	function __construct(){
	
		// REGISTER TAXONOMIES	
		$tax = array("dagender","dasexuality","dathnicity","daeyes","dahair","dabody","dasmoke","dadrink","features","dahairlength");//"age",
		foreach($tax as $t){

			$caption = $t;
			$showMe = true;
			if(is_admin()){

				$d = get_option("core_admin_values"); 
				 
				if(isset($d['hidetax']) && is_array($d['hidetax']) && in_array($t, $d['hidetax']) ){
					$showMe = false;
				}
				if(isset($d['taxcaption']) && is_array($d['taxcaption']) && isset($d['taxcaption'][$t]) ){
					$caption = $d['taxcaption'][$t];
				}
			}
		
			register_taxonomy( $t, THEME_TAXONOMY.'_type', 
				array( 
					'hierarchical' => true, 
					'labels' => array (
						'name' => $caption,
						'singular_name' =>  $caption,
					), 
					'query_var' => true, 
					'rewrite' => true, 
					'rewrite' => array('slug' => $t),
					'show_ui' => $showMe,
					) 
			);
		}
		
		// SHORTCODES			
		add_shortcode( 'GENDER',  array($this, 'shortcode_gender' ) );
		add_shortcode( 'GENDERICON', array($this,'shortcode_gendericon') );
		add_shortcode( 'SEXUALITY',  array($this, 'shortcode_sexuality' ) );
		add_shortcode( 'AGE',  array($this, 'shortcode_age' ) );		
		add_shortcode( 'LOOKINGFOR',  array($this, 'shortcode_lookingfor' ) );	 	
		
		// USER END FIELDS
		add_action('hook_add_fieldlist',  array($this, '_hook_customfields' ) );		
		add_action('hook_register_top', array($this, '_hook_register_top'));
		 
 		
	} 
	

	function _defaults($t){
	 
	$data = array(  );
				
	if($t == "all"){
				return $data;
			}elseif(isset($data[$t])){		
				return $data[$t];		
			}else{
				return "";
			}
	
	}
	
	
 
	
	function _user_types(){
	
			return array();
	
			$accountTypes = array(
		
			"user_1" => array(
				"name" => __("Man Seeking Women","premiumpress"), 
				"desc" => "", 
				"img" => DEMO_IMG_PATH."_usertypes/da1.jpg",
				"can_add"	=> 1,
			),
			
			"user_2" => array(
				"name" => __("Women Seeking Man","premiumpress"), 
				"desc" => "", 
				"img" => DEMO_IMG_PATH."_usertypes/da2.jpg",
				"can_add"	=> 1,
			),	
			
			
			"user_3" => array(
				"name" => __("Seeking Other Guys","premiumpress"), 
				"desc" => "", 
				"img" => DEMO_IMG_PATH."_usertypes/da3.jpg",
				"can_add"	=> 1,
			),	
			
			"user_4" => array(
				"name" => __("Seeking Other Women","premiumpress"), 
				"desc" => "", 
				"img" => DEMO_IMG_PATH."_usertypes/da4.jpg",
				"can_add"	=> 1,
			),	 
			
			"user_other" => array(
				"name" => __("Not Sure Yet","premiumpress"), 
				"desc" => "", 
				"img" => "",
				"can_add"	=> 1,
			),	
				
		);
		
		return $accountTypes;
	
	}
	
	
	function _hook_register_top(){ global $CORE;	 
	  
    
	$accountTypes = $this->_user_types();
	$count = 0;
	
	?>
 
  <?php foreach($accountTypes as $k => $g){ 
  
  if( in_array(_ppt(array("usertype",$k)), array("","1")) ){ }else{ continue; }
  
  // IMAGE
  $IMAGE = $g['img'];
  if(strlen(_ppt(array("usertype",$k."_image"))) > 5 ){
  $IMAGE =  _ppt(array("usertype",$k."_image"));
  }
  
  $count ++;
  $lastkey = $k;
  
  
  ?>
 
  <?php } ?>
 
<script>
	function switchtypedata(thisid){
	
		jQuery(".introtxt").hide();
	
		var names = [];
		<?php foreach($accountTypes as $k => $g){  ?>
		names['<?php echo $k; ?>'] = "<?php echo $g['name']; ?>";
		<?php } ?>
		
		
		jQuery("#regtopmsg").html("<h2 class='font-weight-bold'><?php  echo __("Hello! Welcome.","premiumpress"); ?></h2><p class='opacity-5'><?php  echo __("Please complete the fields below;","premiumpress"); ?></p>");
		
		
		if(thisid == "user_1"){ // man seeks girl
		
	 	<?php if(_ppt(array('usertype', 'user_1_a')) != ""){ ?>
		
			jQuery('select[name=da-seek1] option[value="<?php echo _ppt(array('usertype', 'user_1_a')); ?>"]').attr('selected', 'selected');
			jQuery('select[name=da-seek2] option[value="<?php echo _ppt(array('usertype', 'user_1_b')); ?>"]').attr('selected', 'selected');
		
		<?php }else{ ?>
		if(typeof jQuery('select[name=da-seek1] option:contains("<?php  echo __("Male","premiumpress"); ?>")').val() !== "undefined"){
		
			jQuery('select[name=da-seek1] option:contains("<?php  echo __("Male","premiumpress"); ?>")').attr('selected', 'selected');
			jQuery('select[name=da-seek2] option:contains("<?php  echo __("Female","premiumpress"); ?>")').attr('selected', 'selected');
					
		}else{
			
			jQuery("select[name=da-seek1] option:eq(2)").attr('selected', 'selected');
			jQuery("select[name=da-seek2] option:eq(1)").attr('selected', 'selected');	
		
		}
		<?php } ?>
		
			
		
		}else if(thisid == "user_2"){ // girl seeks Male

		<?php if(_ppt(array('usertype', 'user_2_a')) != ""){ ?>
		
			jQuery('select[name=da-seek1] option[value="<?php echo _ppt(array('usertype', 'user_2_a')); ?>"]').attr('selected', 'selected');
			jQuery('select[name=da-seek2] option[value="<?php echo _ppt(array('usertype', 'user_2_b')); ?>"]').attr('selected', 'selected');
		
		<?php }else{ ?>
		
			if(typeof jQuery('select[name=da-seek1] option:contains("<?php  echo __("Male","premiumpress"); ?>")').val() !== "undefined"){
			
				jQuery('select[name=da-seek2] option:contains("<?php  echo __("Male","premiumpress"); ?>")').attr('selected', 'selected');
				jQuery('select[name=da-seek1] option:contains("<?php  echo __("Female","premiumpress"); ?>")').attr('selected', 'selected');
						
			}else{
				
				jQuery("select[name=da-seek2] option:eq(2)").attr('selected', 'selected');
				jQuery("select[name=da-seek1] option:eq(1)").attr('selected', 'selected');
				jQuery("#otherusers").show();	
			
			}
		<?php } ?>
		
		
		}else if(thisid == "user_3"){ // Male seeks Male
		
		<?php if(_ppt(array('usertype', 'user_3_a')) != ""){ ?>
		
			jQuery('select[name=da-seek1] option[value="<?php echo _ppt(array('usertype', 'user_3_a')); ?>"]').attr('selected', 'selected');
			jQuery('select[name=da-seek2] option[value="<?php echo _ppt(array('usertype', 'user_3_b')); ?>"]').attr('selected', 'selected');
		
		<?php }else{ ?>


			if(typeof jQuery('select[name=da-seek1] option:contains("<?php  echo __("Male","premiumpress"); ?>")').val() !== "undefined"){
			
				jQuery('select[name=da-seek2] option:contains("<?php  echo __("Male","premiumpress"); ?>")').attr('selected', 'selected');
				jQuery('select[name=da-seek1] option:contains("<?php  echo __("Male","premiumpress"); ?>")').attr('selected', 'selected');
						
			}else{
				
				jQuery("select[name=da-seek2] option:eq(2)").attr('selected', 'selected');
				jQuery("select[name=da-seek1] option:eq(2)").attr('selected', 'selected');	
				jQuery("#otherusers").show();
			
			}
		<?php } ?>

		}else if(thisid == "user_4"){ // girl seeks girl
		
		<?php if(_ppt(array('usertype', 'user_4_a')) != ""){ ?>
		
			jQuery('select[name=da-seek1] option[value="<?php echo _ppt(array('usertype', 'user_4_a')); ?>"]').attr('selected', 'selected');
			jQuery('select[name=da-seek2] option[value="<?php echo _ppt(array('usertype', 'user_4_b')); ?>"]').attr('selected', 'selected');
		
		<?php }else{ ?>

			if(typeof jQuery('select[name=da-seek1] option:contains("<?php  echo __("Female","premiumpress"); ?>")').val() !== "undefined"){
			
				jQuery('select[name=da-seek2] option:contains("<?php  echo __("Female","premiumpress"); ?>")').attr('selected', 'selected');
				jQuery('select[name=da-seek1] option:contains("<?php  echo __("Female","premiumpress"); ?>")').attr('selected', 'selected');
						
			}else{
				
				jQuery("select[name=da-seek2] option:eq(2)").attr('selected', 'selected');
				jQuery("select[name=da-seek1] option:eq(2)").attr('selected', 'selected');	
				jQuery("#otherusers").show();
			
			}
		<?php } ?>
					 	
		}else if(thisid == "user_other"){
		
		jQuery("#otherusers").show();		
		 
		}
	 
		jQuery("#socialregbot").hide();
		jQuery("#user_type").val(thisid);		
		jQuery(".form-usertype-fields").hide();		
		jQuery(".form-default-fields").show();
		jQuery(".form-default-fields").addClass('w-100');
	
	}
	
	
	jQuery(document).ready(function(){ 
		<?php if($count  > 0){ ?>
		jQuery(".form-default-fields").hide();
		jQuery("#socialregbot").hide();
		
		 
		<?php }else{ ?>		
		jQuery("#otherusers").show();
		<?php } ?>
		
		<?php if($count == 1){ ?>
		switchtypedata('<?php echo $lastkey; ?>');
		jQuery("#socialregbot").hide();
		<?php } ?>		 
		
	}); 
	
	</script>
   
    
    
    
    
    
    <div class="row" id="otherusers" style="display:none;">
        <div class="col-xs-12 col-md-6">
      <div class="form-group" <?php if(_ppt(array('register','da_reggender')) == "1"){ echo 'style="display:none;"'; } ?>>
        <div class="row">
          <div class="col-md-12 position-relative">
            <select id="da-seek1" name="da-seek1" class="form-control <?php if(_ppt(array('register','da_reggender')) != "1"){ echo 'required'; } ?>" >
              <option value=""><?php echo __("I'm a","premiumpress"); ?></option>
              <?php
$count = 1;
$cats = get_terms( 'dagender', array( 'hide_empty' => 0, 'parent' => 0  ));
if(!empty($cats)){
foreach($cats as $cat){ 
if($cat->parent != 0){ continue; } 
 
?>
              <option value="<?php echo $cat->term_id; ?>"><?php echo $CORE->GEO("translation_tax", array($cat->term_id, $cat->name)); ?></option>
              <?php $count++; } } ?>
            </select>
          </div>
        </div>
      </div>
    </div>
    <div class="col-xs-12 col-md-6">
      <div class="form-group" <?php if(_ppt(array('register','da_seeking')) == "1"){ echo 'style="display:none;"'; } ?>>
        <div class="row">
          <div class="col-md-12 position-relative">
            <select name="da-seek2" class="form-control <?php if(_ppt(array('register','da_seeking')) != "1"){ echo 'required'; } ?>" >
              <option value=""><?php echo __("Seeking a","premiumpress"); ?></option>
              <?php
$count = 1;
$cats = get_terms( 'dagender', array( 'hide_empty' => 0, 'parent' => 0  ));
if(!empty($cats)){
foreach($cats as $cat){ 
if($cat->parent != 0){ continue; } 
 
?>
              <option value="<?php echo $cat->term_id; ?>" ><?php echo $CORE->GEO("translation_tax", array($cat->term_id, $cat->name)); ?></option>
              <?php $count++; } } ?>
            </select>
              
            </div>
        </div>
      </div>
    </div>
    </div>
    <?php	
	}
	 
	
	function shortcode_lookingfor( $atts, $content = null ) { global $post, $CORE;

		extract( shortcode_atts( array( 'type' => "desc"  ), $atts ) );
		
		switch($type){
			
			case "desc": {
			
				$text = get_post_meta($post->ID, 'lookingdesc', true);
				
				if(strlen($text) > 2){
				$text = wpautop($text);
				}
				
			} break;
			
			case "gen": {
			
				$text = get_post_meta($post->ID, 'lookinggen', true);
			
				$count = 1;
				$cats = get_terms( 'dagender', array( 'hide_empty' => 0, 'parent' => 0  ));
				if(!empty($cats)){
				foreach($cats as $cat){ 
				if($cat->parent != 0){ continue; } 
				if($cat->term_id == $text){
				 return $CORE->GEO("translation_tax", array($cat->term_id, $cat->name));
				}
				  } }
			 
				 
				
			} break;
			
			case "age": {
			
			$text = get_post_meta($post->ID, 'lookingage', true);
			
			 $vv = array(
				1 => __("Any Age","premiumpress"),
				2 => __("Over 20","premiumpress"),
				3 => __("Between 20 &amp; 30","premiumpress"),
				4 => __("Between 30 &amp; 40","premiumpress"),
				5 => __("Between 40 &amp; 50","premiumpress"),
				6 => __("Over 50","premiumpress"), 
			 );
				
			if(isset($vv[$text])){
			$text = $vv[$text];
			}	
				
			} break;
		
		}
		
		return $text;
	
	}
	
  
	function shortcode_age($atts, $content = null ){ global $CORE, $post, $wpdb, $userdata; 
	 
		extract( shortcode_atts( array(  "uid" =>  0 ), $atts ) );
		 
		if($uid == 0 && isset($post->ID)){
		$uid = $post->ID;
		}
		
		// HIDE AGE
		if(_ppt(array('design', "element_age")) == "0" || _ppt(array('lst', 'da_age')) == "0" ){ return ""; }
	
		$age = get_post_meta($uid,'daage',true);
		if($age == ""){
		$age = 18;
		}
		
		return $age;
	
	}
	
	function shortcode_gender( $atts, $content = null ) { global $post, $CORE;

		extract( shortcode_atts( array( 'btn' => false, "uid" =>  "" ), $atts ) );
		 
		$uid = 0;
		if(isset($post->ID)){
		$uid = $post->ID;
		} 
		  
		// HIDE AGE
		if(_ppt(array('design', "element_gender")) == "0"){ return ""; }
	 
		$cl = $CORE->_language_current();
		  
		if(_ppt(array('lang','switch')) == 1 && $cl != "en_US"){
		
			$cats = get_the_terms( $uid, 'dagender');
				
			if(isset($cats[0])){
			 
				$t = $CORE->GEO("translation_tax", array($cats[0]->term_id, $cats[0]->name));		 
				
			}else{
			
				$t = get_the_term_list( $uid, 'dagender', "", ', ', '' );
			}
			
		
		}else{
		
			$t = get_the_term_list( $uid, 'dagender', "", ', ', '' );
		
		}  
		 
		return strip_tags($t);
	}	
	
	function shortcode_sexuality( $atts, $content = null ) { global $post;

		extract( shortcode_atts( array( 'btn' => false  ), $atts ) );
		
		// HIDE AGE
		if(_ppt(array('design', "element_sexuality")) == "0"){ return ""; }
	
		$t = get_the_term_list( $post->ID, 'dasexuality', "", ', ', '' );
		 
		return strip_tags($t);
	}	
	
	function shortcode_gendericon($atts, $content = null){  global $userdata, $CORE, $post; $STRING = "";
	
		extract( shortcode_atts( array('id' => '', 'icononly' => 0 ), $atts ) ); 
		
		// HIDE AGE
		if(_ppt(array('design', "element_gender")) == "0"){ return ""; }	
		
		$t = get_the_term_list( $post->ID, 'dagender', "", ', ', '' );
		
		$icon = "fa fa-male";
		
		if(strpos(strtolower($t), "female") !== false){	
			
			$icon = "fa fa-female";	
		
		}elseif(strpos(strtolower($t), "female") !== false){	
			$icon = "fa fa-female";	
		}
		if(strpos(strtolower($t), "male") !== false){	
			$icon = "fa fa-male";
		}elseif(strpos(strtolower($t), "male") !== false){	
			$icon = "fa fa-male";
		}   			
		
		if($icononly == 1){		
		return $icon;		
		}
		
		return '<i class="'.$icon.'"></i>';
	
	
	}	
	
	/*
		this function adds new fields
		to the submission form
	*/
	function _hook_customfields($c){ global $CORE;

		$o = 50;
		
		/*
		$c[$o]['title'] 			= __("Date of Birth","premiumpress");
		$c[$o]['type'] 				= "date";
 		$c[$o]['name']				= "dadob";
		$c[$o]['class'] 			= "form-control";
		$c[$o]['help'] 			= "<script>jQuery(document).ready(function() { jQuery( '#field-daage' ).on(\"mouseover mouseout\", function() {  var today = new Date();
    var birthDate = new Date(jQuery('#field-dadob-date').val());    var age = today.getFullYear() - birthDate.getFullYear();    var m = today.getMonth() - birthDate.getMonth();    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { age--;    } console.log(age);   jQuery('#field-daage option[value='+age+']').attr('selected','selected');  }); });</script>";				 
		$o++;
		*/
		 
		$ageArray = array(); $i = 18;
		while($i < 101){
		$ageArray[$i] = $i;
		$i++;
		}
		
		if(_ppt(array('design', "element_age")) == "0" || _ppt(array('lst', 'da_age')) == "0"  ){
		
		}else{
		
		$c[$o]['title'] 			= __("Age","premiumpress");
		$c[$o]['type'] 				= "select";
 		$c[$o]['name']				= "daage";
		$c[$o]['listvalues']		= $ageArray;
		$c[$o]['class'] 			= "form-control";		 
		$o++;	
		
		}
 		 		
				
		return $c;
		
	}	

}
?>