devamı...
################################# CLIENT EMAIL FUNCTION END ##############################################################
################################# ADMIN EMAIL FUNCTION ##############################################################
if (!function_exists('adminEmail')) {
function adminEmail($page_id,$user_id,$message_type,$custom_1=''){
if($message_type=='expiration'){$subject = stripslashes(get_option('renew_email_subject')); $client_message = stripslashes(get_option('renew_email_content'));}
elseif($message_type=='post_submited'){$subject = get_option('post_submited_success_email_subject_admin'); $client_message = get_option('post_submited_success_email_content_admin');}
elseif($message_type=='renew'){$subject = get_option('post_renew_success_email_subject_admin'); $client_message = get_option('post_renew_success_email_content_admin');}
elseif($message_type=='upgrade'){$subject = get_option('post_upgrade_success_email_subject_admin'); $client_message = get_option('post_upgrade_success_email_content_admin');}
elseif($message_type=='claim_approved'){$subject = get_option('claim_approved_email_subject'); $client_message = get_option('claim_approved_email_content');}
elseif($message_type=='claim_rejected'){$subject = get_option('claim_rejected_email_subject'); $client_message = get_option('claim_rejected_email_content');}
elseif($message_type=='claim_requested'){$subject = get_option('claim_email_subject_admin'); $client_message = get_option('claim_email_content_admin');}
elseif($message_type=='auto_claim'){$subject = get_option('auto_claim_email_subject'); $client_message = get_option('auto_claim_email_content');}
elseif($message_type=='payment_success'){$subject = get_option('post_payment_success_admin_email_subject'); $client_message = get_option('post_payment_success_admin_email_content');}
elseif($message_type=='payment_fail'){$subject = get_option('post_payment_fail_admin_email_subject'); $client_message = get_option('post_payment_fail_admin_email_content');}
$transaction_details = $custom_1;
$approve_listing_link = '<a href="'.get_option('siteurl').'/?ptype=verify&rs='.$custom_1.'">'.VERIFY_TEXT.'</a>';
$fromEmail = get_option('site_email');
$fromEmailName = get_site_emailName();
//$alivedays = get_post_meta($page_id,'alive_days',true);
$pkg_limit = get_property_price_info_listing($page_id);
$alivedays = $pkg_limit['days'];
$productlink = get_permalink($page_id);
$post_info = get_post($page_id);
$post_date = date('dS F,Y',strtotime($post_info->post_date));
$listingLink ='<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
$loginurl = site_url().'/?ptype=login';
$loginurl_link = '<a href="'.$loginurl.'">login</a>';
$siteurl = site_url();
$siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>';
$user_info = get_userdata($user_id);
$user_email = $user_info->user_email;
$display_name = $user_info->first_name;
$user_login = $user_info->user_login;
if($number_of_grace_days==''){$number_of_grace_days=1;}else{$number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');}
if($post_info->post_type == 'event'){$post_type='event';}else{$post_type='listing';}
$renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>';
$search_array = array('[#client_name#]','[#listing_link#]','[#posted_date#]','[#number_of_days#]','[#number_of_grace_days#]','[#login_url#]','[#username#]','[#user_email#]','[#site_name_url#]','[#renew_link#]','[#post_id#]','[#site_name#]','[#approve_listing_link#]','[#transaction_details#]');
$replace_array = array($display_name,$listingLink,$post_date,$alivedays,$number_of_grace_days,$loginurl_link,$user_login,$user_email,$siteurl_link,$renew_link,$page_id,$fromEmailName,$approve_listing_link,$transaction_details);
$client_message = str_replace($search_array,$replace_array,$client_message);
$subject = str_replace($search_array,$replace_array,$subject);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= 'To: <'.$fromEmail.'>' . "\r\n";
$headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>' . "\r\n";
@wp_mail($fromEmail,$subject,$client_message,$headers);///To client email
}}
################################# ADMIN EMAIL FUNCTION END ##############################################################
################################# SEND EMAIL FUNCTION START #############################################################
if (!function_exists('sendEmail')) {
function sendEmail($fromEmail,$fromEmailName,$toEmail,$toEmailName,$to_subject,$to_message,$extra='',$message_type,$post_id='',$user_id='')
{
$login_details ='';
if($message_type=='send_friend'){$subject = stripslashes(get_option('email_friend_subject')); $message = stripslashes(get_option('email_friend_content'));}
elseif($message_type=='send_enquiry'){$subject = get_option('email_enquiry_subject'); $message = get_option('email_enquiry_content');}
elseif($message_type=='forgot_password'){$subject = get_option('forgot_password_subject'); $message = get_option('forgot_password_content'); $login_details =$to_message; }
elseif($message_type=='registration'){$subject = get_option('registration_success_email_subject'); $message = get_option('registration_success_email_content'); $login_details =$to_message; }
$to_message = nl2br($to_message);
$sitefromEmail = get_option('site_email');
$sitefromEmailName = get_site_emailName();
$productlink = get_permalink($post_id);
$post_info = get_post($post_id);
$listingLink ='<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
$siteurl = site_url();
$siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
$loginurl = site_url().'/?ptype=login';
$loginurl_link = '<a href="'.$loginurl.'">login</a>';
if($fromEmail==''){$fromEmail = get_option('site_email_name');}
if($fromEmailName==''){$fromEmailName = get_option('site_email');}
$search_array = array('[#listing_link#]','[#site_name_url#]','[#post_id#]','[#site_name#]','[#to_name#]','[#from_name#]','[#subject#]','[#comments#]','[#login_url#]','[#login_details#]','[#client_name#]');
$replace_array = array($listingLink,$siteurl_link,$post_id,$sitefromEmailName,$toEmailName,$fromEmailName,$to_subject,$to_message,$loginurl_link,$login_details,$toEmailName);
$message = str_replace($search_array,$replace_array,$message);
$search_array = array('[#listing_link#]','[#site_name_url#]','[#post_id#]','[#site_name#]','[#to_name#]','[#from_name#]','[#subject#]','[#client_name#]');
$replace_array = array($listingLink,$siteurl_link,$post_id,$sitefromEmailName,$toEmailName,$fromEmailName,$to_subject,$toEmailName);
$subject = str_replace($search_array,$replace_array,$subject);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "Reply-To: ".$fromEmail. "\r\n";
$headers .= 'To: '.$toEmailName.' <'.$toEmail.'>' . "\r\n";
$headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>' . "\r\n";
@wp_mail($toEmail, $subject, $message, $headers);
///////// ADMIN BCC EMIALS
$adminEmail = get_bloginfo('admin_email');
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "Reply-To: ".$fromEmail. "\r\n";
$headers .= 'To: <'.$adminEmail.'>' . "\r\n";
$headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>' . "\r\n";
if($message_type=='registration' && get_option('bcc_new_user')){$subject.=' - ADMIN BCC COPY'; @wp_mail($adminEmail, $subject, $message, $headers);}
if($message_type=='send_friend' && get_option('bcc_friend')){$subject.=' - ADMIN BCC COPY'; @wp_mail($adminEmail, $subject, $message, $headers);}
if($message_type=='send_enquiry' && get_option('bcc_enquiry')){$subject.=' - ADMIN BCC COPY'; @wp_mail($adminEmail, $subject, $message, $headers);}
}}
################################# SEND EMAIL FUNCTION END ##############################################################
################################# DATABASE UPDATE FUNCTIONS ############################################################
if (!function_exists('add_column_if_not_exist')) {
function add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL" ){
$exists = false;
$columns = mysql_query("show columns from $db");
while($c = mysql_fetch_assoc($columns)){
if($c['Field'] == $column){
$exists = true;
break;
}
}
if(!$exists){
mysql_query("ALTER TABLE `$db` ADD `$column` $column_attr");
}
}}
################################# ENF DATABASE UPDATE FUNCTIONS ########################################################
if (!function_exists('gt_custom_login_logo')) {
function gt_custom_login_logo() {
echo '<style type="text/css">
h1 a { background-image:url('.get_bloginfo('template_url').'/skins/1-default/logo.png) !important; }
</style>';
}}
add_action('login_head', 'gt_custom_login_logo');
if (!function_exists('checkForUpdates')) {
function checkForUpdates(){
if( !get_option( 'GeoTheme Version' ) ) {
add_option( 'GeoTheme Version', '3.1.1');
} else {
if(get_option('GeoTheme Version') < '3.1.1'){update_option( 'GeoTheme Version', '3.1.1' );} // Get the current version
### CHECK FOR UPDATE ANOUNCMENTS ###
$ctx = stream_context_create(array('http' => array('timeout' => 3)));
file_get_contents("http://example.com/", 0, $ctx);
$gt_s = '&s='.get_bloginfo("url");
$this_ver = get_option('GeoTheme Version'); // Get the current version
$ver_url = "http://geotheme.com/version.php?show=version";
$cur_ver = file_get_contents($ver_url.$gt_s,false,$ctx);
if($this_ver < $cur_ver){
$message_url = "http://geotheme.com/version.php?show=message";
$message = file_get_contents($message_url,false,$ctx);
update_option( 'GT_UD_MSG', $message );
}else{update_option( 'GT_UD_MSG', '' );}
### CHECK FOR SECURITY ANOUNCMENTS ###
$security_url = "http://geotheme.com/version.php?show=security";
$security_msg = file_get_contents($security_url,false,$ctx);
update_option( 'GT_SC_MSG', $security_msg );
### END CHECK FOR SECURITY ANOUNCMENTS ###
}
}}// end update function
if (!function_exists('showNotifications')) {
function showNotifications(){
if($_GET['gt_hide']=='1'){
update_option( 'GT_UD_MSG', '');
update_option( 'GT_SC_MSG', '' );
}
$site_url = get_bloginfo("url");
$admin_url = $site_url.'/wp-admin/';
$hide= '<a href="'.$admin_url.'?gt_hide=1" style="float:right;margin-top:-20px;">Hide</a>';
if(get_option( 'GT_UD_MSG' )!='' && get_option( 'gt_update' )==1){echo get_option( 'GT_UD_MSG' ).$hide;}
if(get_option( 'GT_SC_MSG' )!='' && get_option( 'gt_security' )==1){echo get_option( 'GT_SC_MSG' ).$hide;}
}}
if (!function_exists('db_fix')) {
function db_fix(){
global $wpdb;
if(!get_option('gt_db_fix')){
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ENGINE = MYISAM;');
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT bsearch (post_title, post_content);');
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT bsearch_title (post_title);');
$wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT bsearch_content (post_content);');
$wpdb->show_errors();
update_option('gt_db_fix',1);
}
}}
add_action("admin_head", "checkForUpdates");
add_action("admin_head", "showNotifications");
add_action("admin_head", "db_fix");
###################################################
######## FUNCTION TO GET USER SOCIAL PIC ##########
###################################################
if (!function_exists('get_user_pic')) {
function get_user_pic(){
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID; // get user id
if($user_id){
#### CHECK FOR FACEBOOK PIC
if(get_user_meta($user_id, 'social_connect_facebook_id', true) && !get_user_meta($user_id, 'user_pic_url', true)){
$facbook_id = get_user_meta($user_id, 'social_connect_facebook_id', true);
//$facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture?type=large'; // large
$facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture'; // small
update_user_meta($user_id, 'user_pic_url', $facebook_pic_url);
} //END FACBOOK CHECK
#### CHECK FOR TWITTER PIC
if(get_user_meta($user_id, 'social_connect_twitter_id', true) && !get_user_meta($user_id, 'user_pic_url', true)){
$twitter_id = get_user_meta($user_id, 'social_connect_twitter_id', true);
$json = file_get_contents("http://api.twitter.com/1/users/lookup.json?user_id=".$twitter_id."&include_entities=false");
$json_array = json_decode($json, true);
$twitter_pic_url = $json_array['0']['profile_image_url'];
update_user_meta($user_id, 'user_pic_url', $twitter_pic_url);
} //END TWITTER CHECK
} // END IF USER IF
}}
get_user_pic(); // run the function if on there profile page.
if (!function_exists('get_facebook_pic')) {
function get_facebook_pic(){
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID; // get user id
if($user_id){
#### CHECK FOR FACEBOOK PIC
if(get_user_meta($user_id, 'social_connect_facebook_id', true)){
$facbook_id = get_user_meta($user_id, 'social_connect_facebook_id', true);
//$facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture?type=large'; // large
$facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture'; // small
update_user_meta($user_id, 'user_pic_url', $facebook_pic_url);
} //END FACBOOK CHECK
} // END IF USER IF
}}
if (!function_exists('get_twitter_pic')) {
function get_twitter_pic(){
global $current_user;
get_currentuserinfo();
$user_id = $current_user->ID; // get user id
if($user_id){
#### CHECK FOR TWITTER PIC
if(get_user_meta($user_id, 'social_connect_twitter_id', true)){
$twitter_id = get_user_meta($user_id, 'social_connect_twitter_id', true);
$json = file_get_contents("http://api.twitter.com/1/users/lookup.json?user_id=".$twitter_id."&include_entities=false");
$json_array = json_decode($json, true);
$twitter_pic_url = $json_array['0']['profile_image_url'];
update_user_meta($user_id, 'user_pic_url', $twitter_pic_url);
} //END TWITTER CHECK
} // END IF USER IF
}}
###################################################
### FUNCTION TO REPLACE AVATAR WITH SOCIAL PIC ####
###################################################
if (!function_exists('show_user_avatar')) {
function show_user_avatar($avatar, $comment, $size) {
global $wpdb;
if(isset($comment->user_id)){$user_id = $comment->user_id;}
elseif(get_user_by('email', $comment)){$user_info = get_user_by('email', $comment);$user_id = $user_info->ID;}
else{$user_id = $comment;}
if($user_id){$user_pic = get_user_meta($user_id, 'user_pic_url', true);}
if($user_pic){
$avatar = "<img alt='Profile pic' src='$user_pic' class='avatar avatar-$size photo' height='$size' width='$size' />";
}
return $avatar;
}}
add_filter( 'get_avatar','show_user_avatar', 1, 3 );
############################## FUNCTION TO NOT LIST REPLIES AS REVIEWS
add_filter('get_comments_number', 'fix_comment_count', 10, 2);
function fix_comment_count( $count, $post_id) {
if ( ! is_admin() ) {
$comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $post_id . '&parent=0'));
return count($comments_by_type['comment']);
} else {
return $count;
}
}
############################## END FUNCTION TO NOT LIST REPLIES AS REVIEWS
############################## NATIVE MENU SUPPORT START
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array(
'main_menu' => __( 'Main Menu' ),
'top_menu' => __( 'Top Menu' ),
'footer_menu' => __( 'Footer Menu' )
)
);
}
############################## NATIVE MENU SUPPORT End
############################## LOAD EXTRA STYLES FOR ADMIN AND EVENTS
$uri = $_SERVER["REQUEST_URI"];
if(
$_REQUEST['page']=='gt_tools'
|| $_REQUEST['ptype']=='post_event'
|| $_REQUEST['page']=='app_settings'
|| strpos($uri, 'edit-tags.php')
|| strpos($uri, 'post.php')
){
$plugin_path = get_bloginfo('template_url').'/library/cat-meta';
wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );
wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
wp_enqueue_style( 'tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/base/jquery-ui.css' );
wp_enqueue_script( 'tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js', array( 'jquery' ) );
wp_enqueue_script( 'at-timepicker', $plugin_path . '/js/jquery-ui-timepicker-addon.js', array( 'tmc-jquery-ui' ),false,true );
}
###################################################
####### SETUP THE DATABSE FOR GEOTHEME V3 #########
###################################################
if(strpos($_SERVER["REQUEST_URI"], 'themes.php?activated=true')){
geotheme_activation_setup();
}
###################################################
####### ADD LOCATION TO CATEGORY LINKS ############
###################################################
if(get_option('cat_link_locations')){
add_filter( 'term_link', 'my_term_to_type', 10, 3 );
function my_term_to_type( $link, $term, $taxonomy ) {
if($taxonomy == 'placecategory' || $taxonomy == 'eventcategory' || $taxonomy == 'category') {
$location = $_SESSION['location_slug'];
$loc_area = 'multi_city';
if($_SESSION['multi_country'] || $_SESSION['multi_region'] || $_SESSION['area']){
if($_SESSION['multi_country']){$loc_area = 'multi_country';}
if($_SESSION['multi_region']){$loc_area = 'multi_region';}
if($_SESSION['area']){$loc_area = ''; $location ='';}
}
if($location){
$link = add_query_arg( $loc_area, $location, $link );
}
}
return $link;
}
}
###################################################
####### ADD LOCATION TO CATEGORY LINKS END ########
###################################################
###################################################
####### SHORTEN STRING FUNCTION START #############
###################################################
if (!function_exists('gt_user_short')) {
function gt_user_short($str, $limit=16) {
if (strlen ($str) > $limit) {
$str = substr ($str, 0, $limit - 3);
return $str.'...';
}
return trim($str);
}
}
###################################################
####### SHORTEN STRING FUNCTION END ###############
###################################################
###################################################
############# GET CURRENT PAGE URL ################
###################################################
if (!function_exists('curPageURL')) {
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}}
###################################################
############# MODERATION REASONS ##################
###################################################
if (!function_exists('gt_moderation_reason(')) {
function gt_moderation_reason($reason='') {
$reason_arr = array(1=>__('Spam'),2=>__('Language'),3=>__('Comments'),4=>__('Images'));
if($reason=='array'){return $reason_arr;}
elseif($reason && $reason!='array'){return $reason_arr[$reason];}else{
?>
<option value=""><?php _e('Select Reason');?></option>
<option value="1"><?php echo $reason_arr[1];?></option>
<option value="2"><?php echo $reason_arr[2];?></option>
<option value="3"><?php echo $reason_arr[3];?></option>
<option value="4"><?php echo $reason_arr[4];?></option>
<?php }
}}
###################################################
############# MODERATION FORM OUTPUT ##############
###################################################
if (!function_exists('gt_moderation_form')) {
function gt_moderation_form($post_id) {
?>
<script type="text/javascript">
function send_moderation(){
jQuery('#report_this_ajax').slideToggle("200");
post_id = jQuery("#moderation_post_id").val();
reason = jQuery("#moderation_reason").val();
modText = jQuery("#moderation_text").val();
ajaxUrl = "<?php echo site_url().'/?ajax=report'; ?>";
jQuery.ajax({ type: "POST", url: ajaxUrl, data: "reason="+reason+"&modText="+modText+"&id="+post_id,
success: function(msg)
{
if(msg != "Error")
{
jQuery("#report_this_ajax").html("<span id='moderation_thanks'>"+msg+"</span");
jQuery('#report_this_ajax').slideToggle("200");
//alert('done');
//alert(msg);
}
}
});
return false;
}
</script>
<form action="#">
<input type="hidden" name="moderation_post_id" id="moderation_post_id" value="<?php echo $post_id;?>" />
<select name="moderation_reason" id="moderation_reason">
<?php echo gt_moderation_reason();?>
</select>
<br />
<label><?php _e('Notes (optional):');?></label>
<br />
<textarea name="moderation_text" id="moderation_text"></textarea>
<br />
<input name="submit" type="submit" id="submit" tabindex="5" value="Submit" onclick="return send_moderation();">
</form>
<?php
}}
###################################################
############# MODERATION SUBMIT ###################
###################################################
if (!function_exists('gt_moderation_submit')) {
function gt_moderation_submit($post_id,$reason,$mod_text) {
global $wpdb,$current_user,$moderation_db_table_name;
if(!$reason){ return REPORT_NO_REASON;}
if($current_user->ID && $post_id){
$wpdb->query("SELECT * from $moderation_db_table_name where user_id='".$current_user->ID."' AND list_id='".$post_id."'");
$reports = $wpdb->num_rows;
if($reports >0){echo REPORT_ALREADY_MSG;}else{
$time = time();
$reported = get_post($post_id, ARRAY_A);
$moderation_insert = '
INSERT INTO `'.$moderation_db_table_name.'` (`list_id`, `list_title`, `user_id`, `user_comments`, `user_ip`, `claim_date`, `moderation_reason`, `authorid`, `status`) VALUES
("'.$post_id.'", "'.$reported['post_title'].'", '.$current_user->ID.', "'.$mod_text.'", "'.$_SERVER['REMOTE_ADDR'].'", "'.$time.'", "'.$reason.'", "'.$reported['post_author'].'", "")';
$wpdb->query($moderation_insert);
echo REPORT_REPORTED;
}
}
}}
/*
if (!function_exists('localization_theme_setup')) {
function localization_theme_setup() {
// Retrieve the directory for the localization files
$lang_dir = get_template_directory() . '/localization');
// Set the theme's text domain using the unique identifier from above
load_theme_textdomain('gt_local', $lang_dir);
} // end custom_theme_setup
}
add_action('after_theme_setup', 'localization_theme_setup'):
*/
?>