Guest User

GeoTheme Functions.php

a guest
Nov 19th, 2013
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.95 KB | None | 0 0
  1. <?php
  2.  
  3. function gt_check_sessions(){
  4. // Set error reporting to display all errors and notices
  5. error_reporting(E_ALL);
  6. // Start a session
  7. session_start();
  8. // Check for the existence of a known session variable
  9. if ( $_SESSION['test_value'] ) {
  10. _e('Found a session');
  11. } else {
  12. _e('No session exists - writing to test_value, refresh to check.');
  13. $_SESSION['test_value'] = true;
  14. }
  15. // Close and write session
  16. session_write_close();
  17. $foldername = session_save_path();
  18. if (is_writable($foldername)) {
  19. echo '<br>The Sessions folder is writable';
  20. } else {
  21. echo '<br>The Sessions folder is not writable';
  22. }
  23. exit;
  24. }
  25.  
  26. //print_r(wp_get_schedules());
  27. //echo wp_get_schedule( 'my_task_hook' );
  28. $child_dir = get_stylesheet_directory();
  29. $child_fn_dir = get_stylesheet_directory() . '/library/functions/';
  30. if (file_exists($child_dir.'/child.txt')) {
  31. $ct_on=1;
  32. } else{$ct_on=0;}
  33. /*************************************************************
  34. * Do not modify unless you know what you're doing, SERIOUSLY!
  35. *************************************************************/
  36. //error_reporting(E_ALL);
  37. error_reporting(E_ERROR);
  38. if($_REQUEST['gt_check_sessions']){gt_check_sessions();}
  39. //date_default_timezone_set('Europe/London'); // Use this to set your tiem zone if wordpress is messing it up, STIOFAN
  40. define('TAGKW_TEXT_COUNT',40);
  41. load_theme_textdomain('default');
  42. //load_textdomain( 'default', TEMPLATEPATH.'/en_US.mo' );
  43. // This theme uses post thumbnails
  44. if(!strstr($_SERVER['REQUEST_URI'],'/wp-admin/')){
  45. if($ct_on && file_exists($child_dir.'/library/js/add_js.php')){include_once ($child_dir.'/library/js/add_js.php');}
  46. else{include_once (TEMPLATEPATH . '/library/js/add_js.php');}// add javascript to the head
  47. }
  48. add_theme_support( 'post-thumbnails' );
  49. // Add default posts and comments RSS feed links to head
  50. add_theme_support( 'automatic-feed-links' );
  51. global $blog_id;
  52. if(get_option('upload_path') && !strstr(get_option('upload_path'),'wp-content/uploads'))
  53. {
  54. $upload_folder_path = "wp-content/blogs.dir/$blog_id/files/";
  55. }else
  56. {
  57. $upload_folder_path = "wp-content/uploads/";
  58. }
  59. global $blog_id;
  60. if($blog_id){ $thumb_url = "&amp;bid=$blog_id";}
  61. if ( function_exists( 'add_theme_support' ) ){
  62. add_theme_support( 'post-thumbnails' );
  63. }
  64. ############################## WEE FUNCTION TO GET FEATURED IMAGE URL
  65. function get_the_post_thumbnail_src($img)
  66. {
  67. return (preg_match('~\bsrc="([^"]++)"~', $img, $matches)) ? $matches[1] : '';
  68. }
  69.  
  70. function get_cat_icon($cat_id)
  71. {
  72. $term_icon_url = get_tax_meta($cat_id,'ct_cat_icon');
  73. if($term_icon_url){return $term_icon_url['src'];}else{return get_bloginfo('template_directory').'/library/map/icons/pin.png';}
  74. }
  75.  
  76. if (!function_exists('get_post_default_img')) {
  77. function get_post_default_img($post_id, $taxonomy)
  78. { $cat_id_arr = get_the_terms( $post_id, $taxonomy.'category' );
  79. $cat_id ='';
  80. $cat_default_img = '';
  81. foreach($cat_id_arr as $cats){
  82. $cat_id = $cats->term_id;
  83. if(get_tax_meta($cat_id,'ct_cat_default_img') && $cats->parent!='0'){$cat_default_img = get_tax_meta($cat_id,'ct_cat_default_img');}
  84. elseif(!$cat_default_img && get_tax_meta($cat_id,'ct_cat_default_img')){$cat_default_img = get_tax_meta($cat_id,'ct_cat_default_img');}
  85. }
  86. if($cat_default_img){return $cat_default_img['src'];}else{return get_bloginfo('template_url').'/images/no-image.jpg';}
  87.  
  88. }}
  89.  
  90. if (!function_exists('get_post_cat_icon')) {
  91. function get_post_cat_icon($post_id, $taxonomy)
  92. { $cat_id_arr = get_the_terms( $post_id, $taxonomy.'category' );
  93. $cat_id ='';
  94. $cat_default_img = '';
  95. foreach($cat_id_arr as $cats){
  96. $cat_id = $cats->term_id;
  97. if(get_tax_meta($cat_id,'ct_cat_icon') && $cats->parent!='0'){$cat_default_img = get_tax_meta($cat_id,'ct_cat_icon');}
  98. elseif(!$cat_default_img && get_tax_meta($cat_id,'ct_cat_icon')){$cat_default_img = get_tax_meta($cat_id,'ct_cat_icon');}
  99. }
  100. if($cat_default_img){return $cat_default_img['src'];}else{return get_bloginfo('template_directory').'/library/map/icons/pin.png';}
  101.  
  102. }}
  103.  
  104. ############################## WEE FUNCTION TO GET FEATURED IMAGE URL
  105. ### Rating Logs Table Name
  106. global $wpdb;
  107. $price_db_table_name = $wpdb->prefix . "price";
  108. $rating_table_name = $wpdb->prefix.'ratings';
  109. if($ct_on && file_exists($child_dir."/product_menu.php")){require ($child_dir. "/product_menu.php");}
  110. else{require (TEMPLATEPATH . "/product_menu.php");}
  111. if(get_option('ptthemes_captcha_dislay')=='No'){}else
  112. {
  113. if($ct_on && file_exists($child_dir.'/library/captcha/captcha_function.php')){include_once ($child_dir. '/library/captcha/captcha_function.php');}
  114. else{include_once (TEMPLATEPATH . '/library/captcha/captcha_function.php');}
  115. }
  116. if($ct_on && file_exists($child_dir.'/language.php')){include_once ($child_dir.'/language.php');}
  117. else{include_once (TEMPLATEPATH . '/language.php');}
  118. if($ct_on && file_exists($child_dir.'/library/includes/post_custom_settings.php')){include_once ($child_dir.'/library/includes/post_custom_settings.php');}
  119. else{include_once (TEMPLATEPATH . '/library/includes/post_custom_settings.php');}// custom fields settings + database settings
  120. if($ct_on && file_exists($child_dir.'/library/includes/post_custom_fields.php')){include_once ($child_dir.'/library/includes/post_custom_fields.php');}
  121. else{include_once (TEMPLATEPATH . '/library/includes/post_custom_fields.php');}// custom fields HTML Tag coding
  122. // Theme variables
  123. if($ct_on && file_exists($child_dir.'/library/functions/theme_variables.php')){include_once ($child_dir.'/library/functions/theme_variables.php');}
  124. else{include_once (TEMPLATEPATH . '/library/functions/theme_variables.php');}
  125. // DB Checks First
  126. if($ct_on && file_exists($child_fn_dir.'db_checks.php')){include_once ($child_fn_dir.'db_checks.php');}
  127. else{include_once ($functions_path . 'db_checks.php');}
  128. //** ADMINISTRATION FILES **//
  129. if($ct_on && file_exists($child_fn_dir.'multi_city_functions.php')){include_once ($child_fn_dir.'multi_city_functions.php');}
  130. else{include_once ($functions_path . 'multi_city_functions.php');}
  131.  
  132.  
  133. //custom post type
  134. ### START FUNCTION FO GET CLEAN CITY NAME
  135. if (!function_exists('city_name_url')) {
  136. function city_name_url($city_id) {
  137. global $wpdb,$multicity_db_table_name;
  138. $spec_arr = array(
  139. 'Š'=>'S', 'š'=>'s', 'Ð'=>'Dj','Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A',
  140. 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I',
  141. 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U', 'Ú'=>'U',
  142. 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss','à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a',
  143. 'å'=>'a', 'æ'=>'a', 'ç'=>'c', 'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i',
  144. 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o', 'ö'=>'o', 'ø'=>'o', 'ù'=>'u',
  145. 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y', 'ƒ'=>'f'
  146. );
  147. if($wpdb->get_var("select city_slug from $multicity_db_table_name where city_id=\"$city_id\""))
  148. {$city = $wpdb->get_var("select city_slug from $multicity_db_table_name where city_id=\"$city_id\"");}else
  149. {$city = $wpdb->get_var("select cityname from $multicity_db_table_name where city_id=\"$city_id\"");}
  150. $city = utf8_decode($city);
  151. $city = strtr($city, $spec_arr);
  152. $city = strtolower ($city);
  153. $city = str_replace(" ", "-", $city);
  154. return $city;
  155.  
  156. }}
  157. ### END FUNCTION FO GET CLEAN CITY NAME
  158. if($ct_on && file_exists($child_dir.'/library/functions/custom_post_type.php')){include_once ($child_dir.'/library/functions/custom_post_type.php');}
  159. else{include_once (TEMPLATEPATH . '/library/functions/custom_post_type.php');}
  160. // Theme admin functions
  161. if($ct_on && file_exists($child_fn_dir.'admin_functions.php')){include_once ($child_fn_dir.'admin_functions.php');}
  162. else{include_once ($functions_path . 'admin_functions.php');}
  163. if(strstr($_SERVER['REQUEST_URI'],'/wp-admin/')){ // hide all the code we dont need on the front end.
  164. // Theme admin options
  165. if($ct_on && file_exists($child_fn_dir.'admin_options.php')){include_once ($child_fn_dir.'admin_options.php');}
  166. else{include_once ($functions_path . 'admin_options.php');}
  167. // User Profiles Options
  168. if($ct_on && file_exists($child_fn_dir.'user_profile.php')){include_once ($child_fn_dir.'user_profile.php');}
  169. else{include_once ($functions_path . 'user_profile.php');}
  170. // Theme Activation Setup
  171. if($ct_on && file_exists($child_fn_dir.'activation_function.php')){include_once ($child_fn_dir.'activation_function.php');}
  172. else{include_once ($functions_path . 'activation_function.php');}
  173. // App setting page
  174. //if($ct_on && file_exists($child_dir.'/app/admin_settings.php')){include_once ($child_dir.'/app/admin_settings.php');}
  175. //else{include_once (TEMPLATEPATH . '/app/admin_settings.php');}
  176. }/////////////////////////////////////////////////////////////// END HIDE FRONT END
  177. // Code to add meta info to categories
  178. if($ct_on && file_exists($child_dir.'/library/cat-meta/cat_meta.php')){include_once ($child_dir.'/library/cat-meta/cat_meta.php');}
  179. else{include_once (TEMPLATEPATH . '/library/cat-meta/cat_meta.php');}// custom fields HTML Tag coding
  180. // Theme admin Settings
  181. if($ct_on && file_exists($child_fn_dir.'admin_settings.php')){include_once ($child_fn_dir.'admin_settings.php');}
  182. else{include_once ($functions_path . 'admin_settings.php');}
  183. //** FRONT-END FILES **//
  184. // Widgets
  185. if($ct_on && file_exists($child_fn_dir.'widgets_functions.php')){include_once ($child_fn_dir.'widgets_functions.php');}
  186. else{include_once ($functions_path . 'widgets_functions.php');}
  187. // Custom
  188. if($ct_on && file_exists($child_fn_dir.'custom_functions.php')){include_once ($child_fn_dir.'custom_functions.php');}
  189. else{include_once ($functions_path . 'custom_functions.php');}
  190. // Comments
  191. if($ct_on && file_exists($child_fn_dir.'comments_functions.php')){include_once ($child_fn_dir.'comments_functions.php');}
  192. else{include_once ($functions_path . 'comments_functions.php');}
  193. if($ct_on && file_exists($child_dir.'/library/breadcrumb-navxt/breadcrumb_navxt_admin.php')){include_once ($child_dir.'/library/breadcrumb-navxt/breadcrumb_navxt_admin.php');}
  194. else{include_once (TEMPLATEPATH . '/library/breadcrumb-navxt/breadcrumb_navxt_admin.php');}
  195. if($ct_on && file_exists($child_fn_dir.'image_resizer.php')){include_once ($child_fn_dir.'image_resizer.php');}
  196. else{include_once ($functions_path . 'image_resizer.php');}
  197. if($ct_on && file_exists($child_dir.'/library/rating/post_rating.php')){include_once ($child_dir.'/library/rating/post_rating.php');}
  198. else{include_once (TEMPLATEPATH . '/library/rating/post_rating.php');}
  199. //Listing filters type
  200. if($ct_on && file_exists($child_dir.'/library/functions/listing_filters.php')){include_once ($child_dir.'/library/functions/listing_filters.php');}
  201. else{include_once (TEMPLATEPATH . '/library/functions/listing_filters.php');}
  202. //** CUSTOM ADDED FUNTIONS **//
  203. // RSS Images
  204. if($ct_on && file_exists($child_fn_dir.'rss_images.php')){include_once ($child_fn_dir.'rss_images.php');}
  205. else{include_once ($functions_path . 'rss_images.php');}
  206.  
  207. // LINK EVENT TO BUSINESS
  208. if($ct_on && file_exists($child_fn_dir.'link_event.php')){include_once ($child_fn_dir.'link_event.php');}
  209. else{include_once ($functions_path . 'link_event.php');}
  210. // RECURRING EVENTS
  211. if($ct_on && file_exists($child_fn_dir.'recurring_event.php')){include_once ($child_fn_dir.'recurring_event.php');}
  212. else{include_once ($functions_path . 'recurring_event.php');}
  213. // COMMENTS EDITOR
  214. if($ct_on && file_exists($child_dir.'/library/comments/wp-ajax-edit-comments.php')){include_once ($child_dir.'/library/comments/wp-ajax-edit-comments.php');}
  215. else{include_once (TEMPLATEPATH . '/library/comments/wp-ajax-edit-comments.php');}
  216. // COMMENTS UPLOAD
  217. if($ct_on && file_exists($child_dir.'/library/comment-uploads/main.php')){include_once ($child_dir.'/library/comment-uploads/main.php');}
  218. else{include_once (TEMPLATEPATH . '/library/comment-uploads/main.php');}
  219. //theme.php
  220. if (!function_exists('autoinstall_admin_header')) {
  221. function autoinstall_admin_header()
  222. {
  223. global $wpdb,$ct_on;
  224. if(strstr($_SERVER['REQUEST_URI'],'themes.php') && $_REQUEST['template']=='' && $_GET['page']=='')
  225. {
  226. if($_REQUEST['dummy']=='del')
  227. {
  228. delete_dummy_data();
  229. $dummy_deleted = '<p><b>All Dummy data has been removed from your database successfully!</b></p>';
  230. }
  231. if($_REQUEST['dummy_insert'])
  232. {
  233. if($ct_on && file_exists($child_dir.'/auto_install.php')){include_once ($child_dir.'/auto_install.php');}
  234. else{include_once (TEMPLATEPATH . '/auto_install.php');}
  235. }
  236. if($_REQUEST['activated']=='true')
  237. {
  238. $theme_actived_success = '<p class="message">Theme activated successfully.</p>';
  239. }
  240. $post_counts = $wpdb->get_var("select count(post_id) from $wpdb->postmeta where (meta_key='pt_dummy_content' || meta_key='tl_dummy_content') and meta_value=1");
  241. if($post_counts>0)
  242. {
  243. $dummy_data_msg = '<p> <b>Sample data has been populated on your site. Wish to delete sample data?</b><br />If you have problem with image, please copy images/dummy folder to wp-content/uploads <br /> <a class="button_delete" href="#" onclick="return delete_dummy();">Yes Delete Please!</a><p>';
  244. ?>
  245. <script type='text/javascript'>
  246. function delete_dummy()
  247. {
  248. if(confirm('<?php _e('Are you sure you want to delete dummy data? You will lose your current widget setup.');?>'))
  249. {
  250. window.location.href="<?php echo site_url().'/wp-admin/themes.php?dummy=del'?>";
  251. return true;
  252. }else
  253. {
  254. return false;
  255. }
  256. }
  257. </script>
  258. <?php
  259. }else
  260. {
  261. $dummy_data_msg = '<p> <b>Would you like to auto install this theme and populate sample data on your site?</b> <br /> <a class="button_insert" href="'.site_url().'/wp-admin/themes.php?dummy_insert=1">Yes, insert sample data please</a></p>';
  262. }
  263. define('THEME_ACTIVE_MESSAGE','
  264. <style>
  265. .highlight { width:60% !important; background:#FFFFE0 !important; overflow:hidden; display:table; border:2px solid #558e23 !important; padding:15px 20px 0px 20px !important; -moz-border-radius:11px !important; -webkit-border-radius:11px !important; }
  266. .highlight p { color:#444 !important; font:15px Arial, Helvetica, sans-serif !important; text-align:center; }
  267. .highlight p.message { font-size:13px !important; }
  268. .highlight p a { color:#ff7e00; text-decoration:none !important; }
  269. .highlight p a:hover { color:#000; }
  270. .highlight p a.button_insert
  271. { display:block; width:230px; margin:10px auto 0 auto; background:#5aa145; padding:10px 15px; color:#fff; border:1px solid #4c9a35; -moz-border-radius:5px; -webkit-border-radius:5px; }
  272. .highlight p a:hover.button_insert { background:#347c1e; color:#fff; border:1px solid #4c9a35; }
  273. .highlight p a.button_delete
  274. { display:block; width:140px; margin:10px auto 0 auto; background:#dd4401; padding:10px 15px; color:#fff; border:1px solid #9e3000; -moz-border-radius:5px; -webkit-border-radius:5px; }
  275. .highlight p a:hover.button_delete { background:#c43e03; color:#fff; border:1px solid #9e3000; }
  276. #message0 { display:none !important; }
  277. </style>
  278. <div class="updated highlight fade"> '.$theme_actived_success.$dummy_deleted.$dummy_data_msg.'</div>');
  279. echo THEME_ACTIVE_MESSAGE;
  280. if($ct_on && get_option('ptthemes_alt_stylesheet')!='none'){
  281. echo '<div class="updated highlight fade">Looks like you have a child theme running, you should set your skin to "none" <a href="'.site_url().'/wp-admin/admin.php?page=theme_settings"> HERE</a></div>';}
  282.  
  283. }
  284. }
  285. }
  286. add_action("admin_head", "autoinstall_admin_header"); // please comment this line if you wish to DEACTIVE SAMPLE DATA INSERT.
  287. #####################################################################################################################################################
  288. if (!function_exists('user_warning_msg')) {
  289. function user_warning_msg()
  290. {
  291. global $wpdb;
  292. if(is_allow_user_register())
  293. {
  294. if($wpdb->get_var("select option_value from $wpdb->options WHERE option_name='default_role'") != 'author')
  295. {
  296. echo '<br><br><div style="background-color:#F00;color:#FFF;font-size:18px;height:60px;width:100%; text-align:center;">User role must be set to Author for correct user permissions to apply!<br />Settings>General>New User Default Role> SET TO "Author"<br />Please also check your current user roles</div>';
  297. }
  298. }
  299. }
  300. }
  301. if (!function_exists('user_check')) {
  302. function user_check()
  303. {
  304. global $wpdb;
  305. if(get_option('is_allow_user') == '0')
  306. {
  307. if ( is_user_logged_in() )
  308. {
  309. if( current_user_can( 'manage_options' ) ) {}
  310. else{ wp_redirect( home_url() ); exit; }
  311. }
  312. }
  313. }
  314. }
  315. add_action("admin_head", "user_warning_msg"); // check if default user is set to Author
  316. add_action("admin_head", "user_check"); // check user is admin
  317. ###########################################################################################################################################
  318. if (!function_exists('delete_dummy_data')) {
  319. function delete_dummy_data()
  320. {
  321. global $wpdb;
  322. //delete_option('sidebars_widgets'); //delete widgets
  323. $productArray = array();
  324. $pids_sql = "select p.ID from $wpdb->posts p join $wpdb->postmeta pm on pm.post_id=p.ID where (meta_key='pt_dummy_content' || meta_key='tl_dummy_content') and meta_value=1";
  325. $pids_info = $wpdb->get_results($pids_sql);
  326. foreach($pids_info as $pids_info_obj)
  327. {
  328. wp_delete_post($pids_info_obj->ID);
  329. }
  330. }
  331. }
  332.  
  333.  
  334.  
  335. ############create random string ##################
  336. if (!function_exists('createRandomString')) {
  337. function createRandomString() {
  338. $chars = "abcdefghijkmlnopqrstuvwxyz1023456789";
  339. srand((double)microtime()*1000000);
  340. $i = 0;
  341. $rstring = '' ;
  342. while ($i <= 25) {
  343. $num = rand() % 33;
  344. $tmp = substr($chars, $num, 1);
  345. $rstring = $rstring . $tmp;
  346. $i++;
  347. }
  348. return $rstring;
  349. }
  350. }
  351. ############ End create random string ###############
  352.  
  353. /////////////////PLACE EXPIRY SETTINGS CODING START/////////////////
  354. if (!function_exists('place_expire_check')) {
  355. function place_expire_check(){
  356. global $table_prefix, $wpdb,$price_db_table_name;
  357. $table_name = $table_prefix . "place_expire_session";
  358. $current_date = date('Y-m-d');
  359. if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name)
  360. {
  361. //global $table_prefix, $wpdb,$table_name;
  362. //$sql = 'DROP TABLE `' . $table_name . '`'; // drop the existing table
  363. $wpdb->query($sql);
  364. $sql = 'CREATE TABLE `'.$table_name.'` (
  365. `session_id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  366. `execute_date` DATE NOT NULL ,
  367. `is_run` TINYINT( 4 ) NOT NULL DEFAULT "0"
  368. ) ENGINE = MYISAM ;';
  369. $wpdb->query($sql);
  370. $wpdb->query("insert into $table_name (session_id,execute_date,is_run) values ('1',\"$current_date\",'1')");
  371. //$rc_run_once = '1';
  372. }
  373. if($wpdb->get_var("SELECT COUNT(*) FROM $table_name") == '0')
  374. { $wpdb->query("insert into $table_name (session_id,execute_date,is_run) values ('1',\"$current_date\",'1')"); $rc_run_once = '1';}
  375. $today_executed = $wpdb->get_var("select is_run from $table_name where datediff(\"$current_date\",date_format(execute_date,'%Y-%m-%d')) > 0");
  376. //$rc_run_once = '1';
  377. if($today_executed && $today_executed>0 || $rc_run_once)
  378. {
  379. if(get_option('ptthemes_listing_expiry_disable'))
  380. {
  381. if(get_option('ptthemes_listing_preexpiry_notice_disable'))
  382. {
  383. $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
  384. if($number_of_grace_days=='')
  385. {
  386. $number_of_grace_days=1;
  387. }
  388.  
  389. $today = date('Y-m-d', strtotime("+".$number_of_grace_days." days"));
  390. //echo $today;
  391. $postid_str = $wpdb->get_results("select pm.meta_value, p.ID,p.post_author, p.post_title from $wpdb->posts p join $wpdb->postmeta pm on pm.post_id=p.ID where (p.post_type='place' or p.post_type='event') AND meta_key='expire_date' AND meta_value!='Never' AND meta_value!='' AND meta_value='".$today."' ");
  392.  
  393. foreach($postid_str as $postid_str_obj)
  394. {
  395. clientEmail($postid_str_obj->ID,$postid_str_obj->post_author,'expiration'); // send expiration email
  396. }
  397. }
  398.  
  399.  
  400. ############################################# SET THE NEW PACKAGE OR SET AS DRAFT #######################################
  401. $today = date('Y-m-d');
  402. $postid_str = $wpdb->get_results("select pm.meta_value, p.ID,p.post_author, p.post_title from $wpdb->posts p join $wpdb->postmeta pm on pm.post_id=p.ID where (p.post_type='place' or p.post_type='event') AND meta_key='expire_date' AND meta_value!='Never' AND meta_value!='' AND meta_value<='".$today."' ");
  403.  
  404. foreach($postid_str as $postid_str_obj)
  405. {
  406. $downgrade_pkg_num='';
  407. $downgrade_pkg_num = $wpdb->get_var("SELECT downgrade_pkg FROM $price_db_table_name where pid=(SELECT meta_value FROM $wpdb->postmeta where meta_key='package_pid' and post_id=$postid_str_obj->ID )");
  408.  
  409. if($downgrade_pkg_num!=0){
  410. $downgrade_pkg = array();
  411. $downgrade_pkg = $wpdb->get_row("SELECT * FROM $price_db_table_name where pid=$downgrade_pkg_num");
  412. //print_r($downgrade_pkg);
  413. $pkg_days = $downgrade_pkg->days;
  414. if($downgrade_pkg->days=='0' || $downgrade_pkg->days==''){$expire_date = 'Never';}
  415. else{$expire_date = date('Y-m-d', strtotime("+".$pkg_days." days"));}
  416. $wpdb->query("update $wpdb->postmeta set meta_value=\"$downgrade_pkg_num\" where meta_key='package_pid' and post_id=$postid_str_obj->ID");
  417. $wpdb->query("update $wpdb->postmeta set meta_value=\"$downgrade_pkg->is_featured\" where meta_key='is_featured' and post_id=$postid_str_obj->ID");
  418. $wpdb->query("update $wpdb->postmeta set meta_value=\"$expire_date\" where meta_key='expire_date' and post_id=$postid_str_obj->ID");
  419.  
  420. ### DOWNGRADE THE NUMBER OF CATEGORYS ###
  421. if($downgrade_pkg->cat_limit!=''){
  422. if($postid_str_obj->post_type =='event'){$post_tax ='eventcategory';}else{$post_tax ='placecategory';}
  423. $terms = wp_get_post_terms($postid_str_obj->ID, $post_tax, array("fields" => "all"));
  424. //print_r($terms);exit;
  425. $term_ids = array();
  426. foreach($terms as $termsObj){
  427. if($termsObj->parent==0){
  428. $term_ids[] = $termsObj->term_id;
  429. }
  430. }
  431. $cat_arr = array_slice($term_ids, 0, $downgrade_pkg->cat_limit);
  432. $term_ids = implode(",", $cat_arr);
  433. wp_set_post_terms( $postid_str_obj->ID, $term_ids, $post_tax, false );
  434. }// end cat limit
  435. ### END DOWNGRADE THE NUMBER OF CATEGORYS ###
  436.  
  437.  
  438. ### REMOVE THE TAGS IF THE DOWNGRADE PACKAGE DOES NOT HAVE THEM ###
  439. if($downgrade_pkg->kw_tags_pkg!='1'){
  440. if($postid_str_obj->post_type =='event'){$post_tax_tag ='event_tags';}else{$post_tax_tag ='place_tags';}
  441. wp_set_object_terms($postid_str_obj->ID, array(), $post_tax_tag, false);
  442. }
  443. ### REMOVE THE TAGS IF THE DOWNGRADE PACKAGE DOES NOT HAVE THEM ###
  444.  
  445. }else{
  446. $listing_ex_status = get_option('ptthemes_listing_ex_status');
  447. if($listing_ex_status=='')
  448. {$listing_ex_status = 'draft';}
  449. $wpdb->query("update $wpdb->posts set post_status=\"$listing_ex_status\" where ID=$postid_str_obj->ID");}
  450. }
  451. ############################################# SET THE NEW PACKAGE OR SET AS DRAFT #######################################
  452.  
  453. $wpdb->query("update $table_name set execute_date=\"$current_date\" ,is_run=1 where session_id=1");
  454. }
  455. }
  456. }
  457. }
  458.  
  459.  
  460.  
  461. ################################# FIX FOR FACEBOOK LIKE THUMB URL #############################################
  462. add_action( 'wp_head', 'fb_like_thumbnails' );
  463. if (!function_exists('fb_like_thumbnails')) {
  464. function fb_like_thumbnails()
  465. {
  466.  
  467. global $wpdb,$thumb_url,$wp_query;
  468. if($wp_query->post->ID){
  469. $default = get_option('ptthemes_logo_url');
  470. $post_images = bdw_get_images($wp_query->post->ID,'large');
  471. if ( $post_images > 0 )
  472. $thumb = $post_images[0];
  473. else
  474. $thumb = $default;
  475. }else{$thumb = $default;}
  476. echo "\n\n<!-- Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End Facebook Like Thumbnail -->\n\n";
  477. }}
  478. ################################# END FIX FOR FACEBOOK LIKE THUMB URL ##########################################
  479. ################################# FUNCTION TO CALCULATE DISTANCE FOR SEARCH #############################################
  480. if (!function_exists('calculateDistanceFromLatLong')) {
  481. function calculateDistanceFromLatLong($point1,$point2,$uom='km') {
  482. // Use Haversine formula to calculate the great circle distance
  483. // between two points identified by longitude and latitude
  484. switch (strtolower($uom)) {
  485. case 'km' :
  486. $earthMeanRadius = 6371.009; // km
  487. break;
  488. case 'm' :
  489. case 'meters' :
  490. $earthMeanRadius = 6371.009 * 1000; // km
  491. break;
  492. case 'miles' :
  493. $earthMeanRadius = 3958.761; // miles
  494. break;
  495. case 'yards' :
  496. case 'yds' :
  497. $earthMeanRadius = 3958.761 * 1760; // yards
  498. break;
  499. case 'feet' :
  500. case 'ft' :
  501. $earthMeanRadius = 3958.761 * 1760 * 3; // feet
  502. break;
  503. case 'nm' :
  504. $earthMeanRadius = 3440.069; // miles
  505. break;
  506. }
  507. $deltaLatitude = deg2rad($point2['latitude'] - $point1['latitude']);
  508. $deltaLongitude = deg2rad($point2['longitude'] - $point1['longitude']);
  509. $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) +
  510. cos(deg2rad($point1['latitude'])) * cos(deg2rad($point2['latitude'])) *
  511. sin($deltaLongitude / 2) * sin($deltaLongitude / 2);
  512. $c = 2 * atan2(sqrt($a), sqrt(1-$a));
  513. $distance = $earthMeanRadius * $c;
  514. return $distance;
  515. }}
  516. ################################# END FUNCTION TO CALCULATE DISTANCE FOR SEARCH #########################################
  517.  
  518. ################################# CLIENT EMAIL FUNCTION ##############################################################
  519. if (!function_exists('clientEmail')) {
  520. function clientEmail($page_id,$user_id,$message_type,$custom_1=''){
  521. global $wpdb;
  522. if($message_type=='expiration'){$subject = stripslashes(get_option('renew_email_subject')); $client_message = stripslashes(get_option('renew_email_content'));}
  523. elseif($message_type=='post_submited'){$subject = get_option('post_submited_success_email_subject'); $client_message = get_option('post_submited_success_email_content');}
  524. elseif($message_type=='renew'){$subject = get_option('post_renew_success_email_subject'); $client_message = get_option('post_renew_success_email_content');}
  525. elseif($message_type=='upgrade'){$subject = get_option('post_upgrade_success_email_subject'); $client_message = get_option('post_upgrade_success_email_content');}
  526. elseif($message_type=='claim_approved'){$subject = get_option('claim_approved_email_subject'); $client_message = get_option('claim_approved_email_content');}
  527. elseif($message_type=='claim_rejected'){$subject = get_option('claim_rejected_email_subject'); $client_message = get_option('claim_rejected_email_content');}
  528. elseif($message_type=='claim_requested'){$subject = get_option('claim_email_subject'); $client_message = get_option('claim_email_content');}
  529. elseif($message_type=='auto_claim'){$subject = get_option('auto_claim_email_subject'); $client_message = get_option('auto_claim_email_content');}
  530. elseif($message_type=='payment_success'){$subject = get_option('post_payment_success_client_email_subject'); $client_message = get_option('post_payment_success_client_email_content');}
  531. elseif($message_type=='payment_fail'){$subject = get_option('post_payment_fail_admin_email_subject'); $client_message = get_option('post_payment_fail_admin_email_content');}
  532. $transaction_details = $custom_1;
  533. $approve_listing_link = '<a href="'.get_option('siteurl').'/?ptype=verify&rs='.$custom_1.'">'.VERIFY_TEXT.'</a>';
  534. $fromEmail = get_option('site_email');
  535. $fromEmailName = get_site_emailName();
  536. //$alivedays = get_post_meta($page_id,'alive_days',true);
  537. $pkg_limit = get_property_price_info_listing($page_id);
  538. $alivedays = $pkg_limit['days'];
  539. $productlink = get_permalink($page_id);
  540. $post_info = get_post($page_id);
  541. $post_date = date('dS F,Y',strtotime($post_info->post_date));
  542. $listingLink ='<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
  543. $loginurl = home_url().'/?ptype=login';
  544. $loginurl_link = '<a href="'.$loginurl.'">login</a>';
  545. $siteurl = home_url();
  546. $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>';
  547. $user_info = get_userdata($user_id);
  548. $user_email = $user_info->user_email;
  549. $display_name = $user_info->first_name;
  550. $user_login = $user_info->user_login;
  551. $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
  552. if($number_of_grace_days==''){$number_of_grace_days=1;}
  553. if($post_info->post_type == 'event'){$post_type='event';}else{$post_type='listing';}
  554. $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>';
  555. $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#]');
  556. $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);
  557. $client_message = str_replace($search_array,$replace_array,$client_message);
  558. $subject = str_replace($search_array,$replace_array,$subject);
  559. //$client_message2 = 'message type:'.$message_type.'# post id:'.$page_id.'#user id:'.$user_id;
  560. $headers = 'MIME-Version: 1.0' . "\r\n";
  561. $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
  562. //$headers .= 'To: '.$display_name.' <'.$user_email.'>' . "\r\n";
  563. $headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>' . "\r\n";
  564. @wp_mail($user_email,$subject,stripslashes($client_message),$headers);///To client email
  565. }}
  566. ################################# CLIENT EMAIL FUNCTION END ##############################################################
  567. ################################# ADMIN EMAIL FUNCTION ##############################################################
  568. if (!function_exists('adminEmail')) {
  569. function adminEmail($page_id,$user_id,$message_type,$custom_1=''){
  570. global $wpdb;
  571. if($message_type=='expiration'){$subject = stripslashes(get_option('renew_email_subject')); $client_message = stripslashes(get_option('renew_email_content'));}
  572. elseif($message_type=='post_submited'){$subject = get_option('post_submited_success_email_subject_admin'); $client_message = get_option('post_submited_success_email_content_admin');}
  573. elseif($message_type=='renew'){$subject = get_option('post_renew_success_email_subject_admin'); $client_message = get_option('post_renew_success_email_content_admin');}
  574. elseif($message_type=='upgrade'){$subject = get_option('post_upgrade_success_email_subject_admin'); $client_message = get_option('post_upgrade_success_email_content_admin');}
  575. elseif($message_type=='claim_approved'){$subject = get_option('claim_approved_email_subject'); $client_message = get_option('claim_approved_email_content');}
  576. elseif($message_type=='claim_rejected'){$subject = get_option('claim_rejected_email_subject'); $client_message = get_option('claim_rejected_email_content');}
  577. elseif($message_type=='claim_requested'){$subject = get_option('claim_email_subject_admin'); $client_message = get_option('claim_email_content_admin');}
  578. elseif($message_type=='auto_claim'){$subject = get_option('auto_claim_email_subject'); $client_message = get_option('auto_claim_email_content');}
  579. elseif($message_type=='payment_success'){$subject = get_option('post_payment_success_admin_email_subject'); $client_message = get_option('post_payment_success_admin_email_content');}
  580. elseif($message_type=='payment_fail'){$subject = get_option('post_payment_fail_admin_email_subject'); $client_message = get_option('post_payment_fail_admin_email_content');}
  581. $transaction_details = $custom_1;
  582. $approve_listing_link = '<a href="'.get_option('siteurl').'/?ptype=verify&rs='.$custom_1.'">'.VERIFY_TEXT.'</a>';
  583. $fromEmail = get_option('site_email');
  584. $fromEmailName = get_site_emailName();
  585. //$alivedays = get_post_meta($page_id,'alive_days',true);
  586. $pkg_limit = get_property_price_info_listing($page_id);
  587. $alivedays = $pkg_limit['days'];
  588. $productlink = get_permalink($page_id);
  589. $post_info = get_post($page_id);
  590. $post_date = date('dS F,Y',strtotime($post_info->post_date));
  591. $listingLink ='<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
  592. $loginurl = home_url().'/?ptype=login';
  593. $loginurl_link = '<a href="'.$loginurl.'">login</a>';
  594. $siteurl = home_url();
  595. $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>';
  596. $user_info = get_userdata($user_id);
  597. $user_email = $user_info->user_email;
  598. $display_name = $user_info->first_name;
  599. $user_login = $user_info->user_login;
  600. $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
  601. if($number_of_grace_days==''){$number_of_grace_days=1;}
  602. if($post_info->post_type == 'event'){$post_type='event';}else{$post_type='listing';}
  603. $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>';
  604. $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#]');
  605. $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);
  606. $client_message = str_replace($search_array,$replace_array,$client_message);
  607. $subject = str_replace($search_array,$replace_array,$subject);
  608. $headers = 'MIME-Version: 1.0' . "\r\n";
  609. $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
  610. //$headers .= 'To: <'.$fromEmail.'>' . "\r\n";
  611. $headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>' . "\r\n";
  612. @wp_mail($fromEmail,$subject,stripslashes($client_message),$headers);///To client email
  613. }}
  614. ################################# ADMIN EMAIL FUNCTION END ##############################################################
  615. ################################# SEND EMAIL FUNCTION START #############################################################
  616. if (!function_exists('sendEmail')) {
  617. function sendEmail($fromEmail,$fromEmailName,$toEmail,$toEmailName,$to_subject,$to_message,$extra='',$message_type,$post_id='',$user_id='')
  618. {
  619. $login_details ='';
  620. if($message_type=='send_friend'){$subject = stripslashes(get_option('email_friend_subject')); $message = stripslashes(get_option('email_friend_content'));}
  621. elseif($message_type=='send_enquiry'){$subject = get_option('email_enquiry_subject'); $message = get_option('email_enquiry_content');}
  622. elseif($message_type=='forgot_password'){$subject = get_option('forgot_password_subject'); $message = get_option('forgot_password_content'); $login_details =$to_message; }
  623. elseif($message_type=='registration'){$subject = get_option('registration_success_email_subject'); $message = get_option('registration_success_email_content'); $login_details =$to_message; }
  624. $to_message = nl2br($to_message);
  625. $sitefromEmail = get_option('site_email');
  626. $sitefromEmailName = get_site_emailName();
  627. $productlink = get_permalink($post_id);
  628. $post_info = get_post($post_id);
  629. $listingLink ='<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>';
  630. $siteurl = home_url();
  631. $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>';
  632. $loginurl = home_url().'/?ptype=login';
  633. $loginurl_link = '<a href="'.$loginurl.'">login</a>';
  634. if($fromEmail==''){$fromEmail = get_option('site_email_name');}
  635. $fromEmail = str_replace('%40','@',$fromEmail );
  636. if($fromEmailName==''){$fromEmailName = get_option('site_email');}
  637. $search_array = array('[#listing_link#]','[#site_name_url#]','[#post_id#]','[#site_name#]','[#to_name#]','[#from_name#]','[#subject#]','[#comments#]','[#login_url#]','[#login_details#]','[#client_name#]','[#sender_email#]');
  638. $replace_array = array($listingLink,$siteurl_link,$post_id,$sitefromEmailName,$toEmailName,$fromEmailName,$to_subject,$to_message,$loginurl_link,$login_details,$toEmailName,$fromEmail);
  639. $message = str_replace($search_array,$replace_array,$message);
  640.  
  641. if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
  642. $message .= '<br /><br />'.__('Country:','geotheme').' '.$_SERVER["HTTP_CF_IPCOUNTRY"].' '.__('IP: ','geotheme').$_SERVER["HTTP_CF_CONNECTING_IP"];
  643. }
  644.  
  645. $search_array = array('[#listing_link#]','[#site_name_url#]','[#post_id#]','[#site_name#]','[#to_name#]','[#from_name#]','[#subject#]','[#client_name#]');
  646. $replace_array = array($listingLink,$siteurl_link,$post_id,$sitefromEmailName,$toEmailName,$fromEmailName,$to_subject,$toEmailName);
  647. $subject = str_replace($search_array,$replace_array,$subject);
  648. $headers = 'MIME-Version: 1.0' . "\r\n";
  649. $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
  650. $headers .= "Reply-To: ".$fromEmail. "\r\n";
  651. //$headers .= 'To: '.$toEmailName.' <'.$toEmail.'>' . "\r\n";
  652. $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>' . "\r\n";
  653. @wp_mail($toEmail, $subject, stripslashes($message), $headers);
  654.  
  655. ///////// ADMIN BCC EMIALS
  656. if($message_type=='registration'){
  657. $message_raw = explode("Password:", $message);
  658. $message_raw2 = explode("</p>", $message_raw[1],2);
  659. $message = $message_raw[0].'Password: **********</p>'.$message_raw2[1];
  660. }
  661. $adminEmail = get_bloginfo('admin_email');
  662.  
  663. $headers = 'MIME-Version: 1.0' . "\r\n";
  664. $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
  665. $headers .= "Reply-To: ".$fromEmail. "\r\n";
  666. //$headers .= 'To: <'.$adminEmail.'>' . "\r\n";
  667. $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>' . "\r\n";
  668. if($message_type=='registration' && get_option('bcc_new_user')){$subject.=' - ADMIN BCC COPY'; @wp_mail($adminEmail, $subject, stripslashes($message), $headers);}
  669. if($message_type=='send_friend' && get_option('bcc_friend')){$subject.=' - ADMIN BCC COPY'; @wp_mail($adminEmail, $subject, stripslashes($message), $headers);}
  670. if($message_type=='send_enquiry' && get_option('bcc_enquiry')){$subject.=' - ADMIN BCC COPY'; @wp_mail($adminEmail, $subject, stripslashes($message), $headers);}
  671. }}
  672. ################################# SEND EMAIL FUNCTION END ##############################################################
  673. ################################# DATABASE UPDATE FUNCTIONS ############################################################
  674. if (!function_exists('add_column_if_not_exist')) {
  675. function add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL" ){
  676. $exists = false;
  677. $columns = mysql_query("show columns from $db");
  678. while($c = mysql_fetch_assoc($columns)){
  679. if($c['Field'] == $column){
  680. $exists = true;
  681. break;
  682. }
  683. }
  684. if(!$exists){
  685. mysql_query("ALTER TABLE `$db` ADD `$column` $column_attr");
  686. }
  687. }}
  688. ################################# ENF DATABASE UPDATE FUNCTIONS ########################################################
  689.  
  690.  
  691. if (!function_exists('gt_custom_login_logo')) {
  692. function gt_custom_login_logo() {
  693. echo '<style type="text/css">
  694. h1 a { background-image:url('.get_bloginfo('template_url').'/skins/1-default/logo.png) !important; }
  695. </style>';
  696. }}
  697.  
  698. add_action('login_head', 'gt_custom_login_logo');
  699.  
  700. if (!function_exists('checkForUpdates')) {
  701. function checkForUpdates(){
  702. $gt_ver = get_option( 'GeoTheme Version' );
  703. $a = get_option('gt_show_app_page');
  704. if( !$gt_ver ) {
  705. add_option( 'GeoTheme Version', '3.3.8');
  706. } else {
  707. if($gt_ver < '3.3.8'){
  708. geotheme_activation_setup();
  709. update_option( 'GeoTheme Version', '3.3.8' );
  710. } // Get the current version
  711. ### CHECK FOR UPDATE ANOUNCMENTS ###
  712. $ctx = stream_context_create(array('http' => array('timeout' => 3)));
  713. $gt_s = '&s='.get_bloginfo("url").'&v='.$gt_ver.'&a='.$a;
  714. $this_ver = get_option('GeoTheme Version'); // Get the current version
  715. $ver_url = "http://geotheme.com/version.php?show=version";
  716. $cur_ver = file_get_contents($ver_url.$gt_s,false,$ctx);
  717. if($this_ver < $cur_ver){
  718. $message_url = "http://geotheme.com/version.php?show=message";
  719. $message = file_get_contents($message_url,false,$ctx);
  720. update_option( 'GT_UD_MSG', $message );
  721. }else{update_option( 'GT_UD_MSG', '' );}
  722. ### CHECK FOR SECURITY ANOUNCMENTS ###
  723. $security_url = "http://geotheme.com/version.php?show=security";
  724. $security_msg = file_get_contents($security_url.$gt_s,false,$ctx);
  725. update_option( 'GT_SC_MSG', $security_msg );
  726. ### END CHECK FOR SECURITY ANOUNCMENTS ###
  727. }
  728. }}// end update function
  729.  
  730. if (!function_exists('showNotifications')) {
  731. function showNotifications(){
  732. if($_GET['gt_hide']=='1'){
  733. update_option( 'GT_UD_MSG', '');
  734. update_option( 'GT_SC_MSG', '' );
  735.  
  736. }
  737.  
  738. $site_url = get_bloginfo("url");
  739. $admin_url = $site_url.'/wp-admin/';
  740. $hide= '<a href="'.$admin_url.'?gt_hide=1" style="float:right;margin-top:-20px;">Hide</a>';
  741. if(get_option( 'GT_UD_MSG' )!='' && get_option( 'gt_update' )==1){echo get_option( 'GT_UD_MSG' ).$hide;}
  742. if(get_option( 'GT_SC_MSG' )!='' && get_option( 'gt_security' )==1){echo get_option( 'GT_SC_MSG' ).$hide;}
  743. }}
  744.  
  745. if (!function_exists('db_fix')) {
  746. function db_fix(){
  747. global $wpdb;
  748. if(!get_option('gt_db_fix')){
  749. $wpdb->query('ALTER TABLE '.$wpdb->posts.' ENGINE = MYISAM;');
  750. $wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT bsearch (post_title, post_content);');
  751. $wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT bsearch_title (post_title);');
  752. $wpdb->query('ALTER TABLE '.$wpdb->posts.' ADD FULLTEXT bsearch_content (post_content);');
  753. $wpdb->show_errors();
  754. update_option('gt_db_fix',1);
  755. }
  756. }}
  757.  
  758. add_action("admin_head", "checkForUpdates");
  759. add_action("admin_head", "showNotifications");
  760. add_action("admin_head", "db_fix");
  761.  
  762. ###################################################
  763. ######## FUNCTION TO GET USER SOCIAL PIC ##########
  764. ###################################################
  765. if (!function_exists('get_user_pic')) {
  766. function get_user_pic(){
  767. global $current_user;
  768. get_currentuserinfo();
  769. $user_id = $current_user->ID; // get user id
  770. if($user_id){
  771.  
  772. #### CHECK FOR FACEBOOK PIC
  773. if(get_user_meta($user_id, 'social_connect_facebook_id', true) && !get_user_meta($user_id, 'user_pic_url', true)){
  774. $facbook_id = get_user_meta($user_id, 'social_connect_facebook_id', true);
  775. //$facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture?type=large'; // large
  776. $facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture'; // small
  777. update_user_meta($user_id, 'user_pic_url', $facebook_pic_url);
  778. } //END FACBOOK CHECK
  779.  
  780. #### CHECK FOR TWITTER PIC
  781. if(get_user_meta($user_id, 'social_connect_twitter_id', true) && !get_user_meta($user_id, 'user_pic_url', true)){
  782. //$twitter_id = get_user_meta($user_id, 'social_connect_twitter_id', true);
  783. //$twitter_pic = get_user_meta($user_id, 'twitter_pic_url', true);
  784. //$json = file_get_contents("http://api.twitter.com/1/users/lookup.json?user_id=".$twitter_id."&include_entities=false");
  785. //$json_array = json_decode($json, true);
  786. //$twitter_pic_url = $json_array['0']['profile_image_url'];
  787. $twitter_pic_url = get_user_meta($user_id, 'twitter_pic_url', true);
  788. update_user_meta($user_id, 'user_pic_url', $twitter_pic_url);
  789. } //END TWITTER CHECK
  790.  
  791. } // END IF USER IF
  792. }}
  793.  
  794. get_user_pic(); // run the function if on there profile page.
  795.  
  796. if (!function_exists('get_facebook_pic')) {
  797. function get_facebook_pic(){
  798. global $current_user;
  799. get_currentuserinfo();
  800. $user_id = $current_user->ID; // get user id
  801. if($user_id){
  802.  
  803. #### CHECK FOR FACEBOOK PIC
  804. if(get_user_meta($user_id, 'social_connect_facebook_id', true)){
  805. $facbook_id = get_user_meta($user_id, 'social_connect_facebook_id', true);
  806. //$facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture?type=large'; // large
  807. $facebook_pic_url = 'http://graph.facebook.com/'.$facbook_id.'/picture'; // small
  808. update_user_meta($user_id, 'user_pic_url', $facebook_pic_url);
  809. } //END FACBOOK CHECK
  810.  
  811. } // END IF USER IF
  812. }}
  813.  
  814.  
  815. if (!function_exists('get_twitter_pic')) {
  816. function get_twitter_pic(){
  817. global $current_user;
  818. get_currentuserinfo();
  819. $user_id = $current_user->ID; // get user id
  820. if($user_id){
  821.  
  822. #### CHECK FOR TWITTER PIC
  823. if(get_user_meta($user_id, 'social_connect_twitter_id', true)){
  824. /*
  825. $twitter_id = get_user_meta($user_id, 'social_connect_twitter_id', true);
  826. $json = file_get_contents("http://api.twitter.com/1/users/lookup.json?user_id=".$twitter_id."&include_entities=false");
  827. $json_array = json_decode($json, true);
  828. $twitter_pic_url = $json_array['0']['profile_image_url'];
  829. */
  830. $twitter_pic_url = get_user_meta($user_id, 'twitter_pic_url', true);
  831. update_user_meta($user_id, 'user_pic_url', $twitter_pic_url);
  832. } //END TWITTER CHECK
  833.  
  834. } // END IF USER IF
  835. }}
  836.  
  837.  
  838. ###################################################
  839. ### FUNCTION TO REPLACE AVATAR WITH SOCIAL PIC ####
  840. ###################################################
  841. if (!function_exists('show_user_avatar')) {
  842. function show_user_avatar($avatar, $comment, $size, $default, $alt) {
  843. global $wpdb;
  844. if(isset($comment->user_id)){$user_id = $comment->user_id;}
  845. elseif(get_user_by('email', $comment)){$user_info = get_user_by('email', $comment);$user_id = $user_info->ID;}
  846. else{$user_id = $comment;}
  847. if($user_id){$user_pic = get_user_meta($user_id, 'user_pic_url', true);}
  848. if($user_pic){
  849. $avatar = "<img alt='Profile pic' src='$user_pic' class='avatar avatar-$size photo' height='$size' width='$size' />";
  850. }
  851. return $avatar;
  852. }}
  853. add_filter( 'get_avatar','show_user_avatar', 10, 5 );
  854.  
  855.  
  856.  
  857. ############################## FUNCTION TO NOT LIST REPLIES AS REVIEWS
  858. add_filter('get_comments_number', 'fix_comment_count', 10, 2);
  859. function fix_comment_count( $count, $post_id) {
  860. if ( ! is_admin() ) {
  861. $comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $post_id . '&parent=0'));
  862. return count($comments_by_type['comment']);
  863. } else {
  864. return $count;
  865. }
  866. }
  867.  
  868. ############################## END FUNCTION TO NOT LIST REPLIES AS REVIEWS
  869.  
  870. ############################## NATIVE MENU SUPPORT START
  871.  
  872. add_action( 'init', 'register_my_menus' );
  873.  
  874. function register_my_menus() {
  875. register_nav_menus(
  876. array(
  877. 'main_menu' => __( 'Main Menu' ),
  878. 'top_menu' => __( 'Top Menu' ),
  879. 'footer_menu' => __( 'Footer Menu' )
  880. )
  881. );
  882. }
  883. ############################## NATIVE MENU SUPPORT End
  884.  
  885. ############################## LOAD EXTRA STYLES FOR ADMIN AND EVENTS
  886. $uri = $_SERVER["REQUEST_URI"];
  887. if(
  888. $_REQUEST['page']=='gt_tools'
  889. || $_REQUEST['ptype']=='post_event'
  890. || $_REQUEST['page']=='app_settings'
  891. || strpos($uri, 'edit-tags.php')
  892. || strpos($uri, 'post.php')
  893. ){
  894. $plugin_path = get_bloginfo('template_url').'/library/cat-meta';
  895. if($_REQUEST['ptype']=='post_event' ){}else{wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' );}
  896. wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true );
  897. wp_enqueue_style( 'tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css' );
  898. wp_enqueue_script( 'tmc-jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js', array( 'jquery' ) );
  899. wp_enqueue_script( 'at-timepicker', $plugin_path . '/js/jquery-ui-timepicker-addon.js', array( 'tmc-jquery-ui' ),false,true );
  900. }
  901.  
  902.  
  903.  
  904. ###################################################
  905. ####### SETUP THE DATABSE FOR GEOTHEME V3 #########
  906. ###################################################
  907. if(strpos($_SERVER["REQUEST_URI"], 'themes.php?activated=true')){
  908. geotheme_activation_setup();
  909. }
  910.  
  911.  
  912. ###################################################
  913. ####### ADD LOCATION TO CATEGORY LINKS ############
  914. ###################################################
  915. if(get_option('cat_link_locations')){
  916. add_filter( 'term_link', 'my_term_to_type', 10, 3 );
  917.  
  918. function my_term_to_type( $link, $term, $taxonomy ) {
  919. if($taxonomy == 'placecategory' || $taxonomy == 'eventcategory' || $taxonomy == 'category') {
  920. $location = $_SESSION['location_slug'];
  921. $loc_area = 'multi_city';
  922. if($_SESSION['multi_country'] || $_SESSION['multi_region'] || $_SESSION['area']){
  923. if($_SESSION['multi_country']){$loc_area = 'multi_country';}
  924. if($_SESSION['multi_region']){$loc_area = 'multi_region';}
  925. if($_SESSION['area']){$loc_area = ''; $location ='';}
  926. }
  927. if($location){
  928. $link = add_query_arg( $loc_area, $location, $link );
  929. }
  930. }
  931.  
  932. return $link;
  933. }
  934. }
  935. ###################################################
  936. ####### ADD LOCATION TO CATEGORY LINKS END ########
  937. ###################################################
  938.  
  939. ###################################################
  940. ####### SHORTEN STRING FUNCTION START #############
  941. ###################################################
  942. if (!function_exists('gt_user_short')) {
  943. function gt_user_short($str, $limit=16) {
  944. if (strlen ($str) > $limit) {
  945. $str = substr ($str, 0, $limit - 3);
  946. return $str.'...';
  947. }
  948. return trim($str);
  949. }
  950. }
  951. ###################################################
  952. ####### SHORTEN STRING FUNCTION END ###############
  953. ###################################################
  954.  
  955. ###################################################
  956. ############# GET CURRENT PAGE URL ################
  957. ###################################################
  958. if (!function_exists('curPageURL')) {
  959. function curPageURL() {
  960. $pageURL = 'http';
  961. if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  962. $pageURL .= "://";
  963. if ($_SERVER["SERVER_PORT"] != "80") {
  964. $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  965. } else {
  966. $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  967. }
  968. return $pageURL;
  969. }}
  970. ###################################################
  971. ############# MODERATION REASONS ##################
  972. ###################################################
  973. if (!function_exists('gt_moderation_reason')) {
  974. function gt_moderation_reason($reason='') {
  975. $reason_arr = array(1=>__('Spam'),2=>__('Language'),3=>__('Comments'),4=>__('Images'));
  976. if($reason=='array'){return $reason_arr;}
  977. elseif($reason && $reason!='array'){return $reason_arr[$reason];}else{
  978. ?>
  979. <option value=""><?php _e('Select Reason');?></option>
  980. <option value="1"><?php echo $reason_arr[1];?></option>
  981. <option value="2"><?php echo $reason_arr[2];?></option>
  982. <option value="3"><?php echo $reason_arr[3];?></option>
  983. <option value="4"><?php echo $reason_arr[4];?></option>
  984. <?php }
  985. }}
  986. ###################################################
  987. ############# MODERATION FORM OUTPUT ##############
  988. ###################################################
  989. if (!function_exists('gt_moderation_form')) {
  990. function gt_moderation_form($post_id) {
  991. ?>
  992. <script type="text/javascript">
  993. function send_moderation(){
  994. jQuery('#report_this_ajax').slideToggle("200");
  995. post_id = jQuery("#moderation_post_id").val();
  996. reason = jQuery("#moderation_reason").val();
  997. modText = jQuery("#moderation_text").val();
  998.  
  999. ajaxUrl = "<?php echo home_url().'/?ajax=report'; ?>";
  1000. jQuery.ajax({ type: "POST", url: ajaxUrl, data: "reason="+reason+"&modText="+modText+"&id="+post_id,
  1001. success: function(msg)
  1002. {
  1003. if(msg != "Error")
  1004. {
  1005.  
  1006. jQuery("#report_this_ajax").html("<span id='moderation_thanks'>"+msg+"</span");
  1007. jQuery('#report_this_ajax').slideToggle("200");
  1008. //alert('done');
  1009. //alert(msg);
  1010. }
  1011. }
  1012. });
  1013. return false;
  1014. }
  1015. </script>
  1016. <form action="#">
  1017. <input type="hidden" name="moderation_post_id" id="moderation_post_id" value="<?php echo $post_id;?>" />
  1018. <select name="moderation_reason" id="moderation_reason">
  1019. <?php echo gt_moderation_reason();?>
  1020. </select>
  1021. <br />
  1022. <label><?php _e('Notes (optional):');?></label>
  1023. <br />
  1024. <textarea name="moderation_text" id="moderation_text"></textarea>
  1025. <br />
  1026. <input name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit');?>" onclick="return send_moderation();">
  1027. </form>
  1028. <?php
  1029.  
  1030. }}
  1031. ###################################################
  1032. ############# MODERATION SUBMIT ###################
  1033. ###################################################
  1034. if (!function_exists('gt_moderation_submit')) {
  1035. function gt_moderation_submit($post_id,$reason,$mod_text) {
  1036. global $wpdb,$current_user,$moderation_db_table_name;
  1037. if(!$reason){ return REPORT_NO_REASON;}
  1038. if($current_user->ID && $post_id){
  1039. $wpdb->query("SELECT * from $moderation_db_table_name where user_id='".$current_user->ID."' AND list_id='".$post_id."'");
  1040. $reports = $wpdb->num_rows;
  1041. if($reports >0){echo REPORT_ALREADY_MSG;}else{
  1042. $time = time();
  1043. $reported = get_post($post_id, ARRAY_A);
  1044. $moderation_insert = '
  1045. INSERT INTO `'.$moderation_db_table_name.'` (`list_id`, `list_title`, `user_id`, `user_comments`, `user_ip`, `claim_date`, `moderation_reason`, `authorid`, `status`) VALUES
  1046. ("'.$post_id.'", "'.$reported['post_title'].'", '.$current_user->ID.', "'.$mod_text.'", "'.$_SERVER['REMOTE_ADDR'].'", "'.$time.'", "'.$reason.'", "'.$reported['post_author'].'", "")';
  1047. $wpdb->query($moderation_insert);
  1048. echo REPORT_REPORTED;
  1049. }
  1050. }
  1051. }}
  1052.  
  1053.  
  1054. if(!function_exists('gt_max_upload_size')) {
  1055. function gt_max_upload_size() {
  1056. return '2mb';
  1057. }}
  1058.  
  1059. if(!function_exists('gt_plupload_admin_head')) {
  1060. function gt_plupload_admin_head() {
  1061. // place js config array for plupload
  1062. $plupload_init = array(
  1063. 'runtimes' => 'html5,silverlight,flash,html4',
  1064. 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader
  1065. 'container' => 'plupload-upload-ui', // will be adjusted per uploader
  1066. 'drop_element' => 'drag-drop-area', // will be adjusted per uploader
  1067. 'file_data_name' => 'async-upload', // will be adjusted per uploader
  1068. 'multiple_queues' => true,
  1069. //'max_file_size' => wp_max_upload_size() . 'b',
  1070. 'max_file_size' => gt_max_upload_size(),
  1071. 'url' => admin_url('admin-ajax.php'),
  1072. 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
  1073. 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
  1074. 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => 'jpeg,jpg,gif,png')),
  1075. 'multipart' => true,
  1076. 'urlstream_upload' => true,
  1077. 'multi_selection' => false, // will be added per uploader
  1078. // additional post data to send to our ajax hook
  1079. 'multipart_params' => array(
  1080. '_ajax_nonce' => "", // will be added per uploader
  1081. 'action' => 'plupload_action', // the ajax action name
  1082. 'imgid' => 0 // will be added per uploader
  1083. )
  1084. );
  1085. ?>
  1086. <script type="text/javascript">
  1087. var base_plupload_config=<?php echo json_encode($plupload_init); ?>;
  1088. </script>
  1089. <?php
  1090. }
  1091. }
  1092.  
  1093.  
  1094. function g_plupload_action() {
  1095.  
  1096. // check ajax noonce
  1097. $imgid = $_POST["imgid"];
  1098. check_ajax_referer($imgid . 'pluploadan');
  1099.  
  1100. // handle file upload
  1101. $status = wp_handle_upload($_FILES[$imgid . 'async-upload'], array('test_form' => true, 'action' => 'plupload_action'));
  1102. //print_r( $status);
  1103. // send the uploaded file url in response
  1104. echo $status['url'];
  1105. exit;
  1106. }
  1107. add_action('wp_ajax_plupload_action', "g_plupload_action");
  1108. add_action( 'wp_ajax_nopriv_plupload_action', 'g_plupload_action' ); // call for not logged in ajax
  1109.  
  1110.  
  1111. function gt_add_remove_images($pid,$newArr){
  1112. global $wpdb;
  1113. if($pid){}else{ return false;}
  1114. $curImgArr = array();
  1115. $newImgArr = array();
  1116. $curIdArr = array();
  1117. $newIdArr = array();
  1118. $noDup = array();
  1119. $curArr = get_children('order=ASC&orderby=menu_order ID&post_type=attachment&post_mime_type=image&post_parent=' . $pid );
  1120.  
  1121. // Get image name
  1122. foreach($curArr as $key=>$val)
  1123. {
  1124. $imgUrl = wp_get_attachment_image_src($val->ID,'large');
  1125. $imgName = end(explode('/',$imgUrl[0]));
  1126. $curImgArr[] = $imgName;
  1127. $curIdArr[$imgName] = $val->ID;
  1128. }
  1129.  
  1130. // Get image name
  1131. foreach($newArr as $imgN)
  1132. {
  1133. $nimgName = end(explode('/',$imgN));
  1134. $newImgArr[] = $nimgName;
  1135. $newIdArr[$nimgName] = $imgN;
  1136. }
  1137.  
  1138. // Delete images that have been removed
  1139. $noDup = $curImgArr;
  1140. $delArr = array_diff(array_unique($noDup), $newImgArr);
  1141. foreach($delArr as $del)
  1142. {
  1143. wp_delete_attachment( $curIdArr[$del], $force_delete = true );
  1144. }
  1145.  
  1146. // Add new images
  1147. $menu_order = 0;
  1148. $newArr = array_diff($newImgArr,$curImgArr);
  1149. foreach($newImgArr as $new)
  1150. {
  1151. $menu_order++;
  1152. // you must first include the image.php file
  1153. // for the function wp_generate_attachment_metadata() to work
  1154. require_once(ABSPATH . 'wp-admin/includes/image.php');
  1155. if($curIdArr[$new]){
  1156. $thisattachment = array();
  1157. $thisattachment['ID'] = $curIdArr[$new];
  1158. $thisattachment['menu_order'] = $menu_order;
  1159. wp_update_post($thisattachment);
  1160. }else{
  1161. $wp_upload_dir = wp_upload_dir(); // Array of key => value pairs
  1162. $filename = $wp_upload_dir['path'] . '/'. $new;
  1163. $attachment = array(
  1164. 'guid' => $wp_upload_dir['url'] . '/'. $new,
  1165. 'post_mime_type' => 'image/jpeg',
  1166. 'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
  1167. 'post_content' => '',
  1168. 'menu_order' => $menu_order,
  1169. 'post_status' => 'inherit'
  1170. );
  1171.  
  1172. $attach_id = wp_insert_attachment( $attachment, $filename, $pid );
  1173.  
  1174. $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
  1175. wp_update_attachment_metadata( $attach_id, $attach_data );
  1176. }
  1177.  
  1178. }
  1179. }
  1180.  
  1181.  
  1182. // run the expiry check twice a day
  1183. if ( !wp_next_scheduled('my_task_hook') ) {
  1184. wp_schedule_event( time(), 'twicedaily', 'my_task_hook' ); // hourly, daily and twicedaily
  1185. }
  1186. if (!function_exists('place_expire_check_cron')) {
  1187. function place_expire_check_cron() {
  1188. place_expire_check();
  1189. checkForUpdates();
  1190. }}
  1191. add_action('my_task_hook', 'place_expire_check_cron');
  1192. //place_expire_check();
  1193. /////////////////PLACE EXPIRY SETTINGS CODING END/////////////////
  1194.  
  1195.  
  1196. // ADVANCED NEAR SEARCH LOCATION FUNCTION
  1197. if (!function_exists('gt_advanced_near_search')) {
  1198. function gt_advanced_near_search(){
  1199. global $wpdb;
  1200. $near_add = "";
  1201. if(get_option('advanced_near_search')!=0){
  1202. if($_SESSION['location_name'] && $_SESSION['location_name']!='EVERYWHERE' && $_SESSION['multi_city']!=0 ){
  1203. $near_add .= "+' ";
  1204. $near_add .= $_SESSION['location_name'];
  1205. }
  1206. }
  1207.  
  1208. if($near_add && get_option('search_near_add')){ $near_add .= ", ".get_option('search_near_add')."'";}
  1209. elseif(get_option('search_near_add')){ $near_add .= "+' ".get_option('search_near_add')."'";}
  1210. elseif($near_add){$near_add .= "'";}
  1211.  
  1212. echo $near_add;
  1213.  
  1214. }
  1215. }
  1216.  
  1217.  
  1218.  
  1219. // Add specific CSS class by filter
  1220. add_filter('body_class','gt_class_names');
  1221. if (!function_exists('gt_class_names')) {
  1222. function gt_class_names($classes) {
  1223. if($_REQUEST['ptype']=='preview'){
  1224. $classes[] = 'single';
  1225. $classes[] = 'single-place';
  1226. }
  1227.  
  1228. if($_REQUEST['ptype']=='preview_event'){
  1229. $classes[] = 'single';
  1230. $classes[] = 'single-event';
  1231. }
  1232.  
  1233.  
  1234. return $classes;
  1235. }
  1236. }
  1237.  
  1238.  
  1239.  
  1240. function gt_reset_password( $user, $new_pass ) {
  1241. do_action( 'password_reset', $user, $new_pass );
  1242.  
  1243. wp_set_password( $new_pass, $user->ID );
  1244.  
  1245. }
  1246.  
  1247. if (!function_exists('gt_fix_cat_sep')) {
  1248. function gt_fix_cat_sep( $separators ) {
  1249. //$separators['between'] = ', ';
  1250. $separators['between_last_two'] = ' '.__("and").' ';
  1251. $separators['between_only_two'] = ' '.__("and").' ';
  1252. return $separators;
  1253. }
  1254. }
  1255. add_filter( 'wp_sprintf_l', 'gt_fix_cat_sep' );
  1256.  
  1257. if (!function_exists('gt_twitter_email_nag')) {
  1258. function gt_twitter_email_nag() {
  1259. $msg = '<div id="twitter-email-nag">'.__('As you signed up with twitter you must edit your profile with a valid email address (as twitter does not provide this).').'</div>';
  1260. global $wpdb;
  1261. $current_user = wp_get_current_user();
  1262. if($current_user->ID){
  1263. $email = $current_user->user_email;
  1264. if (substr($email , 0, 3) === 'tw_' && !$_POST){echo $msg;}
  1265.  
  1266. }
  1267.  
  1268.  
  1269.  
  1270. }
  1271. }
  1272.  
  1273. /*
  1274. if (!function_exists('localization_theme_setup')) {
  1275. function localization_theme_setup() {
  1276.  
  1277. // Retrieve the directory for the localization files
  1278. $lang_dir = get_template_directory() . '/localization');
  1279.  
  1280. // Set the theme's text domain using the unique identifier from above
  1281. load_theme_textdomain('gt_local', $lang_dir);
  1282.  
  1283. } // end custom_theme_setup
  1284. }
  1285. add_action('after_theme_setup', 'localization_theme_setup'):
  1286. */
  1287.  
  1288. ?>
Advertisement
Add Comment
Please, Sign In to add comment