PageRenderTime 63ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/themes/ProjectTheme/functions.php

https://github.com/JeremyHoxie/bloocollar
PHP | 8285 lines | 5093 code | 2217 blank | 975 comment | 892 complexity | 23aade3d04310846c28d6956076780e4 MD5 | raw file
Possible License(s): GPL-2.0, MIT, GPL-3.0, LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /***************************************************************************
  3. *
  4. * ProjectTheme - copyright (c) - sitemile.com
  5. * The only project theme for wordpress on the world wide web.
  6. *
  7. * Coder: Andrei Dragos Saioc
  8. * Email: sitemile[at]sitemile.com | andreisaioc[at]gmail.com
  9. * More info about the theme here: http://sitemile.com/products/wordpress-project-freelancer-theme/
  10. * since v1.2.5.3
  11. *
  12. ***************************************************************************/
  13. load_theme_textdomain( 'ProjectTheme', TEMPLATEPATH . '/languages' );
  14. // load the theme template for translation
  15. DEFINE("PROJECTTHEME_VERSION", "1.4.2b");
  16. DEFINE("PROJECTTHEME_RELEASE", "14 January 2014");
  17. //----------------------------------------------------------
  18. add_theme_support( 'post-thumbnails' );
  19. remove_action('wp_head', 'wp_generator');
  20. //----------------------------------------------------------
  21. global $current_theme_locale_name, $category_url_link, $location_url_link, $projects_url_nm;
  22. $current_theme_locale_name = 'ProjectTheme';
  23. $category_url_link = "classification";
  24. $cc = get_option('projectTheme_category_slug_link');
  25. if(!empty($cc) && ProjectTheme_using_permalinks()) $category_url_link = $cc;
  26. $location_url_link = "location";
  27. $cc = get_option('projectTheme_location_slug_link');
  28. if(!empty($cc) && ProjectTheme_using_permalinks()) $location_url_link = $cc;
  29. $projects_url_nm = "projects";
  30. $cc = get_option('projectTheme_projects_slug_link');
  31. if(!empty($cc) && ProjectTheme_using_permalinks()) $projects_url_nm = $cc;
  32. //------------------ file includes -----------------------------
  33. include('lib/first_run.php');
  34. include('lib/first_run_emails.php');
  35. include('lib/admin_menu.php');
  36. include('lib/post_new.php');
  37. include('lib/cronjob.php');
  38. include('lib/all_categories.php');
  39. include('lib/all_locations.php');
  40. include('lib/advanced_search.php');
  41. include('lib/blog_page.php');
  42. include('lib/recently_closed.php');
  43. include('lib/provider_search.php');
  44. include('lib/all-posted-projects.php');
  45. //---------------
  46. include('lib/widgets/browse-by-category.php');
  47. include('lib/widgets/browse-by-location.php');
  48. include('lib/widgets/best-rated-users.php');
  49. include('lib/widgets/most-visited-projects.php');
  50. include('lib/widgets/featured-projects.php');
  51. include('lib/widgets/ending-soonest.php');
  52. include('lib/widgets/latest-posted-projects.php');
  53. //---------------
  54. include('lib/login_register/custom2.php');
  55. include('lib/my_account/my_account.php');
  56. include('lib/my_account/personal_information.php');
  57. include('lib/my_account/payments.php');
  58. include('lib/my_account/private_messages.php');
  59. include('lib/my_account/feedbacks.php');
  60. //include('lib/my_account/disputes.php');
  61. include('lib/my_account/completed_projects.php');
  62. include('lib/my_account/awaiting_payments.php');
  63. include('lib/my_account/outstanding_payments.php');
  64. include('lib/my_account/awaiting_completion.php');
  65. include('lib/my_account/unpublished_projects.php');
  66. include('lib/my_account/closed_projects.php');
  67. include('lib/my_account/active_projects.php');
  68. include('lib/my_account/outstanding_project.php');
  69. include('lib/my_account/delivered_projects.php');
  70. include('lib/my_account/won_projects.php');
  71. include('lib/my_account/bid_projects.php');
  72. include('lib/my_account/pay_for_project.php');
  73. include('lib/my_account/pay_with_credits.php');
  74. //include 'lib/social/social.php';
  75. //--------------------------------------------------------------
  76. //------------ hooks and filters -------------------------------
  77. add_action('save_post', 'projectTheme_save_custom_fields');
  78. add_action('generate_rewrite_rules', 'projectTheme_rewrite_rules' );
  79. add_action('query_vars', 'ProjectTheme_add_query_vars');
  80. add_action("template_redirect", 'ProjectTheme_template_redirect');
  81. add_action('init', 'ProjectTheme_create_post_type' );
  82. add_action('wp_head', 'ProjectTheme_add_js_coin_slider');
  83. add_action('the_content', 'ProjectTheme_display_my_account_page');
  84. add_action('the_content', 'ProjectTheme_display_my_account_pay_with_credits');
  85. add_action('the_content', 'ProjectTheme_display_my_account_outstanding_projects');
  86. add_action('the_content', 'ProjectTheme_display_my_account_awaiting_payments_page');
  87. add_action('the_content', 'ProjectTheme_display_advanced_search_disp_page');
  88. add_action('the_content', 'ProjectTheme_display_my_account_pay_for_project');
  89. add_action('the_content', 'ProjectTheme_display_my_account_awaiting_completion_page');
  90. add_action('the_content', 'ProjectTheme_display_provider_search_disp_page');
  91. add_filter('the_content', 'ProjectTheme_display_blog_content_page');
  92. add_filter('the_content', 'ProjectTheme_display_latest_closed_projects_page');
  93. add_action('the_content', 'ProjectTheme_display_all_locations_page');
  94. add_action('the_content', 'ProjectTheme_display_all_categories_page');
  95. add_action('the_content', 'ProjectTheme_display_my_account_personal_info');
  96. add_action('the_content', 'ProjectTheme_display_my_account_payments');
  97. add_action('the_content', 'ProjectTheme_display_my_account_private_messages');
  98. add_action('the_content', 'ProjectTheme_display_my_account_feedbacks');
  99. add_action('the_content', 'ProjectTheme_display_my_account_delivered_projects');
  100. add_action('the_content', 'ProjectTheme_display_my_account_active_projects');
  101. add_action('the_content', 'ProjectTheme_display_my_account_unpublished_projects');
  102. add_action('the_content', 'ProjectTheme_display_my_account_outstanding_payments');
  103. add_action('the_content', 'ProjectTheme_display_my_account_closed_projects');
  104. add_action('the_content', 'ProjectTheme_display_my_account_completed_projects');
  105. add_action('the_content', 'ProjectTheme_display_my_account_won_projects');
  106. add_action('the_content', 'ProjectTheme_display_my_account_bid_projects');
  107. add_action('the_content', 'ProjectTheme_display_all_projects_page');
  108. add_action('draft_to_publish', 'ProjectTheme_run_when_post_published',10,1);
  109. add_action('the_content', 'ProjectTheme_display_post_new_pg');
  110. add_action('admin_menu', 'ProjectTheme_set_admin_menu');
  111. add_action('admin_head', 'ProjectTheme_admin_style_sheet');
  112. add_action('widgets_init', 'ProjectTheme_framework_init_widgets' );
  113. add_action("manage_project_posts_custom_column", "ProjectTheme_my_custom_columns");
  114. add_filter("manage_edit-project_columns", "ProjectTheme_my_projects_columns");
  115. add_action('wp_enqueue_scripts', 'ProjectTheme_add_theme_styles');
  116. add_action('wp_head', 'ProjectTheme_custom_css_thing');
  117. add_action('admin_notices', 'projectTheme_admin_notices');
  118. add_filter('wp_head', 'ProjectTheme_add_max_nr_of_images');
  119. add_filter("ProjectTheme_get_regular_post_project", 'projectTheme_get_post_main_function', 0, 1);
  120. add_filter( 'manage_edit-project_sortable_columns', 'ProjectTheme_sortable_cake_column' );
  121. add_action( 'pre_get_posts', 'ProjectTheme_my_backend_projects_orderby' );
  122. add_filter("ProjectTheme_get_post_blog_function", 'ProjectTheme_get_post_blog_function', 1);
  123. add_filter("projectTheme_get_post_outstanding_project_function", 'projectTheme_get_post_outstanding_project_function', 1);
  124. add_filter("projectTheme_get_post_paid_function", 'projectTheme_get_post_paid_function', 1);
  125. add_filter("projectTheme_get_post_pay_function", 'projectTheme_get_post_pay_function', 1);
  126. add_filter("projectTheme_get_post_awaiting_compl_function", 'projectTheme_get_post_awaiting_compl_function', 1);
  127. add_filter("projectTheme_get_post_awaiting_payment_function", 'projectTheme_get_post_awaiting_payment_function', 1);
  128. add_filter('wp_mail_from', 'ProjectTheme_1_mail_from');
  129. add_filter('wp_mail_from_name', 'ProjectTheme_1_mail_from_name');
  130. /*************************************************************
  131. *
  132. * ProjectTheme (c) sitemile.com - function
  133. *
  134. **************************************************************/
  135. function ProjectTheme_1_mail_from()
  136. {
  137. $emailaddress = 'wordpress@wordpress.org';
  138. $opt = get_option('ProjectTheme_email_addr_from');
  139. if(!empty($opt)) $emailaddress = $opt;
  140. return $emailaddress;
  141. }
  142. /*************************************************************
  143. *
  144. * ProjectTheme (c) sitemile.com - function
  145. *
  146. **************************************************************/
  147. function ProjectTheme_1_mail_from_name()
  148. {
  149. $sendername = 'WordPress';
  150. $opt = get_option('ProjectTheme_email_name_from');
  151. if(!empty($opt)) $sendername = $opt;
  152. return $sendername;
  153. }
  154. /*************************************************************
  155. *
  156. * ProjectTheme (c) sitemile.com - function
  157. *
  158. **************************************************************/
  159. function ProjectTheme_run_when_post_published($post)
  160. {
  161. if(is_array($post))
  162. {
  163. if($post['post_type'] == 'project'):
  164. ProjectTheme_send_email_subscription($post['ID']);
  165. ProjectTheme_send_email_posted_project_approved($post['ID']);
  166. ProjectTheme_send_email_posted_project_approved_admin($post['ID']);
  167. endif;
  168. }
  169. if(is_object($post))
  170. {
  171. if($post->post_type == 'project'):
  172. ProjectTheme_send_email_subscription($post->ID);
  173. ProjectTheme_send_email_posted_project_approved($post->ID);
  174. ProjectTheme_send_email_posted_project_approved_admin($post->ID);
  175. endif;
  176. }
  177. }
  178. /*************************************************************
  179. *
  180. * ProjectTheme (c) sitemile.com - function
  181. *
  182. **************************************************************/
  183. function projectTheme_search_into($custid, $val)
  184. {
  185. global $wpdb;
  186. $s = "select * from ".$wpdb->prefix."project_custom_relations where custid='$custid'";
  187. $r = $wpdb->get_results($s);
  188. if(count($r) == 0) return 0;
  189. else
  190. foreach($r as $row) // = mysql_fetch_object($r))
  191. {
  192. if($row->catid == $val) return 1;
  193. }
  194. return 0;
  195. }
  196. function projectTheme_search_into_users($custid, $val)
  197. {
  198. global $wpdb;
  199. $s = "select * from ".$wpdb->prefix."project_user_custom_relations where custid='$custid'";
  200. $r = $wpdb->get_results($s);
  201. if(count($r) == 0) return 0;
  202. else
  203. foreach($r as $row) // = mysql_fetch_object($r))
  204. {
  205. if($row->catid == $val) return 1;
  206. }
  207. return 0;
  208. }
  209. function ProjectTheme_register_my_menus() {
  210. register_nav_menu( 'primary-projecttheme-header', 'ProjectTheme Top Header Menu' );
  211. register_nav_menu( 'primary-projecttheme-main-header', 'ProjectTheme Main Header Menu' );
  212. }
  213. add_action( 'init', 'ProjectTheme_register_my_menus' );
  214. function cimy_update_ExtraFields_new_me() {
  215. global $wpdb, $wpdb_data_table, $user_ID, $max_length_value, $fields_name_prefix, $cimy_uef_file_types, $user_level, $cimy_uef_domain;
  216. include_once(ABSPATH.'/wp-admin/includes/user.php');
  217. // if updating meta-data from registration post then exit
  218. if (isset($_POST['cimy_post']))
  219. return;
  220. if (isset($_POST['user_id'])) {
  221. $get_user_id = $_POST['user_id'];
  222. if (!current_user_can('edit_user', $get_user_id))
  223. return;
  224. }
  225. else
  226. return;
  227. //echo "asd";
  228. if(!function_exists('get_cimyFields')) return;
  229. $get_user_id = intval($get_user_id);
  230. $profileuser = get_user_to_edit($get_user_id);
  231. $user_login = $profileuser->user_login;
  232. $user_displayname = $profileuser->display_name;
  233. $extra_fields = get_cimyFields(false, true);
  234. $query = "UPDATE ".$wpdb_data_table." SET VALUE=CASE FIELD_ID";
  235. $i = 0;
  236. $field_ids = "";
  237. $mail_changes = "";
  238. foreach ($extra_fields as $thisField) {
  239. $field_id = $thisField["ID"];
  240. $name = $thisField["NAME"];
  241. $type = $thisField["TYPE"];
  242. $label = $thisField["LABEL"];
  243. $rules = $thisField["RULES"];
  244. $unique_id = $fields_name_prefix.$field_id;
  245. $input_name = $fields_name_prefix.esc_attr($name);
  246. $field_id_data = $input_name."_".$field_id."_data";
  247. $advanced_options = cimy_uef_parse_advanced_options($rules["advanced_options"]);
  248. cimy_insert_ExtraFields_if_not_exist($get_user_id, $field_id);
  249. // if the current user LOGGED IN has not enough permissions to see the field, skip it
  250. // apply only for EXTRA FIELDS
  251. if ($rules['show_level'] == 'view_cimy_extra_fields')
  252. {
  253. if (!current_user_can($rules['show_level']))
  254. continue;
  255. }
  256. else if ($user_level < $rules['show_level'])
  257. continue;
  258. // if show_level == anonymous then do NOT ovverride other show_xyz rules
  259. if ($rules['show_level'] == -1) {
  260. // if flag to show the field in the profile is NOT activated, skip it
  261. if (!$rules['show_in_profile'])
  262. continue;
  263. }
  264. $prev_value = $wpdb->escape(stripslashes($_POST[$input_name."_".$field_id."_prev_value"]));
  265. if (cimy_uef_is_field_disabled($type, $rules['edit'], $prev_value))
  266. continue;
  267. if ((isset($_POST[$input_name])) && (!in_array($type, $cimy_uef_file_types))) {
  268. if ($type == "dropdown-multi")
  269. $field_value = stripslashes(implode(",", $_POST[$input_name]));
  270. else
  271. $field_value = stripslashes($_POST[$input_name]);
  272. if ($type == "picture-url")
  273. $field_value = str_replace('../', '', $field_value);
  274. if (isset($rules['max_length']))
  275. $field_value = substr($field_value, 0, $rules['max_length']);
  276. else
  277. $field_value = substr($field_value, 0, $max_length_value);
  278. $field_value = $wpdb->escape($field_value);
  279. if ($i > 0)
  280. $field_ids.= ", ";
  281. else
  282. $i = 1;
  283. $field_ids.= $field_id;
  284. $query.= " WHEN ".$field_id." THEN ";
  285. switch ($type) {
  286. case 'dropdown':
  287. case 'dropdown-multi':
  288. $ret = cimy_dropDownOptions($label, $field_value);
  289. $label = $ret['label'];
  290. case 'picture-url':
  291. case 'textarea':
  292. case 'textarea-rich':
  293. case 'password':
  294. case 'text':
  295. $value = "'".$field_value."'";
  296. $prev_value = "'".$prev_value."'";
  297. break;
  298. case 'checkbox':
  299. $value = $field_value == '1' ? "'YES'" : "'NO'";
  300. $prev_value = $prev_value == "YES" ? "'YES'" : "'NO'";
  301. break;
  302. case 'radio':
  303. $value = $field_value == $field_id ? "'selected'" : "''";
  304. $prev_value = "'".$prev_value."'";
  305. break;
  306. }
  307. $query.= $value;
  308. }
  309. // when a checkbox is not selected then it isn't present in $_POST at all
  310. // file input in html also is not present into $_POST at all so manage here
  311. else {
  312. $rules = $thisField['RULES'];
  313. if (in_array($type, $cimy_uef_file_types)) {
  314. if ($type == "avatar") {
  315. // since avatars are drawn max to 512px then we can save bandwith resizing, do it!
  316. $rules['equal_to'] = 512;
  317. }
  318. if (isset($_POST[$input_name.'_del']))
  319. $delete_file = true;
  320. else
  321. $delete_file = false;
  322. if (isset($_POST[$input_name."_".$field_id."_prev_value"]))
  323. $old_file = stripslashes($_POST[$input_name."_".$field_id."_prev_value"]);
  324. else
  325. $old_file = false;
  326. $field_value = cimy_manage_upload($input_name, $user_login, $rules, $old_file, $delete_file, $type, (!empty($advanced_options["filename"])) ? $advanced_options["filename"] : "");
  327. if ((!empty($field_value)) || ($delete_file)) {
  328. if ($i > 0)
  329. $field_ids.= ", ";
  330. else
  331. $i = 1;
  332. $field_ids.= $field_id;
  333. $value = "'".$field_value."'";
  334. $prev_value = "'".$prev_value."'";
  335. $query.= " WHEN ".$field_id." THEN ";
  336. $query.= $value;
  337. }
  338. else {
  339. $prev_value = $value;
  340. $file_on_server = cimy_uef_get_dir_or_filename($user_login, $old_file, false);
  341. if (($type == "picture") || ($type == "avatar"))
  342. cimy_uef_crop_image($file_on_server, $field_id_data);
  343. }
  344. }
  345. if ($type == 'checkbox') {
  346. // if can be editable then write NO
  347. // there is no way to understand if was YES or NO previously
  348. // without adding other hidden inputs so write always
  349. if ($i > 0)
  350. $field_ids.= ", ";
  351. else
  352. $i = 1;
  353. $field_ids.= $field_id;
  354. $field_value = "NO";
  355. $value = "'".$field_value."'";
  356. $prev_value = $prev_value == "YES" ? "'YES'" : "'NO'";
  357. $query.= " WHEN ".$field_id." THEN ";
  358. $query.= $value;
  359. }
  360. if ($type == 'dropdown-multi') {
  361. // if can be editable then write ''
  362. // there is no way to understand if was YES or NO previously
  363. // without adding other hidden inputs so write always
  364. if ($i > 0)
  365. $field_ids.= ", ";
  366. else
  367. $i = 1;
  368. $field_ids.= $field_id;
  369. $field_value = '';
  370. $value = "'".$field_value."'";
  371. $prev_value = "'".$prev_value."'";
  372. $ret = cimy_dropDownOptions($label, $field_value);
  373. $label = $ret['label'];
  374. $query.= " WHEN ".$field_id." THEN ";
  375. $query.= $value;
  376. }
  377. }
  378. if (($rules["email_admin"]) && ($value != $prev_value) && ($type != "registration-date")) {
  379. $mail_changes.= sprintf(__("%s previous value: %s new value: %s", $cimy_uef_domain), $label, stripslashes($prev_value), stripslashes($value));
  380. $mail_changes.= "\r\n";
  381. }
  382. }
  383. if ($i > 0) {
  384. $query.=" ELSE FIELD_ID END WHERE FIELD_ID IN(".$field_ids.") AND USER_ID = ".$get_user_id;
  385. // $query WILL BE: UPDATE <table> SET VALUE=CASE FIELD_ID WHEN <field_id1> THEN <value1> [WHEN ... THEN ...] ELSE FIELD_ID END WHERE FIELD_ID IN(<field_id1>, [<field_id2>...]) AND USER_ID=<user_id>
  386. $wpdb->query($query);
  387. }
  388. // mail only if set and if there is something to mail
  389. if (!empty($mail_changes)) {
  390. $admin_email = get_option('admin_email');
  391. $mail_subject = sprintf(__("%s (%s) has changed one or more fields", $cimy_uef_domain), $user_displayname, $user_login);
  392. wp_mail($admin_email, $mail_subject, $mail_changes);
  393. }
  394. }
  395. /*************************************************************
  396. *
  397. * ProjectTheme (c) sitemile.com - function
  398. *
  399. **************************************************************/
  400. function ProjectTheme_add_max_nr_of_images()
  401. {
  402. ?>
  403. <script type="text/javascript">
  404. <?php
  405. $ProjectTheme_enable_max_images_limit = get_option('ProjectTheme_enable_max_images_limit');
  406. if($ProjectTheme_enable_max_images_limit == "yes")
  407. {
  408. $projectTheme_nr_max_of_images = get_option('projectTheme_nr_max_of_images');
  409. if(empty($projectTheme_nr_max_of_images)) $projectTheme_nr_max_of_images = 10;
  410. }
  411. else $ProjectTheme_enable_max_images_limit = 1000;
  412. if(empty($projectTheme_nr_max_of_images)) $projectTheme_nr_max_of_images = 100;
  413. ?>
  414. var maxNrImages_PT = <?php echo $projectTheme_nr_max_of_images; ?>;
  415. </script>
  416. <?php
  417. }
  418. /*************************************************************
  419. *
  420. * ProjectTheme (c) sitemile.com - function
  421. *
  422. **************************************************************/
  423. function projectTheme_save_custom_fields($pid)
  424. {
  425. $pst = get_post($pid);
  426. if($pst->post_type == "project"):
  427. if(isset($_POST['fromadmin']))
  428. {
  429. update_post_meta($pid, 'finalised_posted', '1');
  430. $ending = get_post_meta($pid,"ending",true);
  431. $views = get_post_meta($pid,"views",true);
  432. $closed = get_post_meta($pid,"closed",true);
  433. $reverse = get_post_meta($pid, "reverse", true);
  434. update_post_meta($pid,"ending",strtotime($_POST['ending']));
  435. if(empty($views)) update_post_meta($pid,"views",0);
  436. if($reverse == "yes") update_post_meta($pid, "reverse", "yes");
  437. else update_post_meta($pid, "reverse", "no");
  438. update_post_meta($pid, "budgets", $_POST["budgets"]);
  439. if($_POST['hide_project'] == '1')
  440. update_post_meta($pid,"hide_project",'1');
  441. else
  442. update_post_meta($pid,"hide_project",'0');
  443. if($_POST['featureds'] == '1')
  444. update_post_meta($pid,"featured",'1');
  445. else
  446. update_post_meta($pid,"featured",'0');
  447. if($_POST['closed'] == '1')
  448. {
  449. update_post_meta($pid,"closed",'1');
  450. }
  451. else
  452. {
  453. if($closed == "1") update_post_meta($pid,"ending",current_time('timestamp',0) + 30*24*3600);
  454. update_post_meta($pid,"closed",'0');
  455. }
  456. if(isset($_POST['private_bids']))
  457. update_post_meta($pid, "private_bids", $_POST['private_bids']);
  458. if(isset($_POST['price']))
  459. update_post_meta($pid,"price",$_POST['price']);
  460. if(isset($_POST['Location']))
  461. update_post_meta($pid,"Location",$_POST['Location']);
  462. for($i=0;$i<count($_POST['custom_field_id']);$i++)
  463. {
  464. $id = $_POST['custom_field_id'][$i];
  465. $valval = $_POST['custom_field_value_'.$id];
  466. if(is_array($valval))
  467. {
  468. delete_post_meta($pid, 'custom_field_ID_'.$id);
  469. for($k=0;$k<count($valval);$k++)
  470. add_post_meta($pid, 'custom_field_ID_'.$id, $valval[$k]);
  471. }
  472. else
  473. update_post_meta($pid, 'custom_field_ID_'.$id, $valval);
  474. }
  475. }
  476. update_post_meta($pid,'unpaid','0');
  477. do_action('ProjectTheme_execute_on_submit_1', $pid);
  478. endif;
  479. }
  480. /*************************************************************
  481. *
  482. * ProjectTheme (c) sitemile.com - function
  483. *
  484. **************************************************************/
  485. function ProjectTheme_custom_css_thing()
  486. {
  487. $str = get_option('projectTheme_custom_CSS');
  488. $opt = stripslashes($str);
  489. if(!empty($op)):
  490. ?>
  491. <style type="text/css">
  492. <?php echo $opt; ?>
  493. </style>
  494. <?php
  495. endif;
  496. }
  497. /*************************************************************
  498. *
  499. * ProjectTheme (c) sitemile.com - function
  500. *
  501. **************************************************************/
  502. add_action('wp_print_scripts', 'projecttheme_my_enqueue_scripts');
  503. function wp_tiny_mce_mine( $teeny = false, $settings = false ) {
  504. static $num = 1;
  505. if ( ! class_exists('_WP_Editors' ) )
  506. require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
  507. $editor_id = 'content' . $num++;
  508. $set = array(
  509. 'teeny' => $teeny,
  510. 'tinymce' => $settings ? $settings : true,
  511. 'quicktags' => false
  512. );
  513. $set = _WP_Editors::parse_settings($editor_id, $set);
  514. _WP_Editors::editor_settings($editor_id, $set);
  515. }
  516. function projecttheme_my_enqueue_scripts() {
  517. wp_enqueue_script( 'tiny_mce' );
  518. wp_tiny_mce_mine();
  519. }
  520. function ProjectTheme_get_my_pagination_main($url, $current_page, $field_page, $total_pages, $other = '')
  521. {
  522. $s = '';
  523. $s .= '<div class="wp-pagenavi"> <span class="pages">'.sprintf(__('Page %s of %s','ProjectTheme'), $current_page, $total_pages).'</span>';
  524. $batch = 5;
  525. $raport = ceil($current_page/$batch) - 1; if ($raport < 0) $raport = 0;
  526. $start = $raport * $batch + 1;
  527. $end = $start + $batch - 1;
  528. if($end > $total_pages) $end = $total_pages;
  529. $previous_pg = $current_page - 1;
  530. $next_pg = $current_page + 1;
  531. if($next_pg > $total_pages) $next_pg = 1;
  532. //----------------------
  533. if($current_page > 1)
  534. $s .= '<a href="'.$url.'&'.$field_page.'=1'.$other.'">&laquo; '.__('First','Walleto').'</a>';
  535. if($previous_pg > 0)
  536. $s.= '<a href="'.$url.'&'.$field_page.'='.$previous_pg.$other.'">&laquo;</a>';
  537. for($i = $start; $i <= $end; $i ++) {
  538. if ($i == $current_page) {
  539. $s .= '<span class="current">'.$i.'</span>';
  540. } else {
  541. $s .= '<a class="page larger" href="'.$url.'&'.$field_page.'='.$i.$other.'">'.$i.'</a>';
  542. }
  543. }
  544. //extend
  545. if($end < $total_pages) $s .= '<span class="extend">...</span>';
  546. $next_pg = $current_page + 1;
  547. if($next_pg > $total_pages) $next_pg = 1;
  548. if($total_pages > $current_page)
  549. $s .= '<a href="'.$url.'&'.$field_page.'='.$next_pg.$other.'" class="page larger">&raquo;</a>';
  550. if($total_pages > $current_page)
  551. $s .= '<a href="'.$url.'&'.$field_page.'='.$total_pages.$other.'" class="page larger">'.__('Last','ProjectTheme').' &raquo;</a>';
  552. return $s.'</div>';
  553. }
  554. function ProjectTheme_add_theme_styles()
  555. {
  556. global $wp_query;
  557. $new_Project_step = $wp_query->query_vars['post_new_step'];
  558. $p_action = $wp_query->query_vars['p_action'];
  559. // Register the style like this for a theme:
  560. // (First the unique name for the style (custom-style) then the src,
  561. // then dependencies and ver no. and media type)
  562. wp_register_style( 'bootstrap_style1', get_bloginfo('template_url').'/css/bootstrap_min.css', array(), '20120822', 'all' );
  563. wp_register_style( 'bootstrap_style2', get_bloginfo('template_url').'/css/css.css', array(), '20120822', 'all' );
  564. wp_register_style( 'bootstrap_style3', get_bloginfo('template_url').'/css/bootstrap_responsive.css', array(), '20120822', 'all' );
  565. wp_register_style( 'bootstrap_ie6', get_bloginfo('template_url').'/css/bootstrap_ie6.css', array(), '20120822', 'all' );
  566. wp_register_style( 'bootstrap_gal', get_bloginfo('template_url').'/css/bootstrap_gal.css', array(), '20120822', 'all' );
  567. wp_register_style( 'fileupload_ui', get_bloginfo('template_url').'/css/fileupload_ui.css', array(), '20120822', 'all' );
  568. wp_register_style( 'mega_menu_thing', get_bloginfo('template_url').'/css/menu.css', array(), '20120822', 'all' );
  569. wp_register_style( 'uploadify_css', get_bloginfo('template_url').'/lib/uploadify/uploadify.css', array(), '20120822', 'all' );
  570. wp_register_script( 'social_pr', get_bloginfo('template_url').'/js/connect.js');
  571. wp_register_style( 'bx_styles', get_bloginfo('template_url').'/css/bx_styles.css', array(), '20120822', 'all' );
  572. wp_register_script( 'easing', get_bloginfo('template_url').'/js/jquery.easing.1.3.js');
  573. wp_register_script( 'bx_slider', get_bloginfo('template_url').'/js/jquery.bxSlider.min.js');
  574. wp_register_script( 'html5_js', get_bloginfo('template_url').'/js/html5.js');
  575. wp_register_script( 'jquery_ui', get_bloginfo('template_url').'/js/vendor/jquery.ui.widget.js');
  576. wp_register_script( 'templ_min', get_bloginfo('template_url').'/js/templ.min.js');
  577. wp_register_script( 'load_image', get_bloginfo('template_url').'/js/load_image.min.js');
  578. wp_register_script( 'canvas_to_blob', get_bloginfo('template_url').'/js/canvas_to_blob.js');
  579. wp_register_script( 'iframe_transport', get_bloginfo('template_url').'/js/jquery.iframe-transport.js');
  580. wp_register_script( 'fileupload_main', get_bloginfo('template_url').'/js/jquery.fileupload.js');
  581. wp_register_script( 'fileupload_fp', get_bloginfo('template_url').'/js/jquery.fileupload-fp.js');
  582. wp_register_script( 'fileupload_ui', get_bloginfo('template_url').'/js/jquery.fileupload-ui.js');
  583. wp_register_script( 'locale_thing', get_bloginfo('template_url').'/js/locale.js');
  584. wp_register_script( 'main_thing', get_bloginfo('template_url').'/js/main.js');
  585. wp_register_script( 'uploadify_js', get_bloginfo('template_url').'/lib/uploadify/jquery.uploadify-3.1.js');
  586. wp_enqueue_script( 'jqueryhoverintent', get_bloginfo('template_url') . '/js/jquery.hoverIntent.minified.js', array('jquery') );
  587. wp_enqueue_script( 'dcjqmegamenu', get_bloginfo('template_url') . '/js/jquery.dcmegamenu.1.3.4.min.js', array('jquery') );
  588. global $wp_styles, $wp_scripts;
  589. wp_enqueue_script( 'social_pr' );
  590. wp_enqueue_style( 'bx_styles' );
  591. wp_enqueue_script( 'easing' );
  592. wp_enqueue_script( 'bx_slider' );
  593. wp_enqueue_script( 'jqueryhoverintent' );
  594. wp_enqueue_script( 'dcjqmegamenu' );
  595. wp_enqueue_style( 'mega_menu_thing' );
  596. global $post;
  597. $ssl = get_option('ProjectTheme_my_account_personal_info_id');
  598. if($new_Project_step == "2" or $p_action == "edit_project" or $p_action == "repost_project" or $post->ID == $ssl ):
  599. // enqueing:
  600. wp_enqueue_style( 'bootstrap_style1' );
  601. wp_enqueue_style( 'bootstrap_style2' );
  602. wp_enqueue_style( 'bootstrap_style3' );
  603. wp_enqueue_style( 'bootstrap_ie6' );
  604. wp_enqueue_style( 'bootstrap_gal' );
  605. wp_enqueue_style( 'fileupload_ui' );
  606. wp_enqueue_style( 'uploadify_css' );
  607. wp_enqueue_script( 'html5_js' );
  608. wp_enqueue_script( 'jquery_ui' );
  609. wp_enqueue_script( 'templ_min' );
  610. wp_enqueue_script( 'load_image' );
  611. wp_enqueue_script( 'canvas_to_blob' );
  612. wp_enqueue_script( 'iframe_transport' );
  613. wp_enqueue_script( 'fileupload_main' );
  614. wp_enqueue_script( 'fileupload_fp' );
  615. wp_enqueue_script( 'fileupload_ui' );
  616. wp_enqueue_script( 'locale_thing' );
  617. wp_enqueue_script( 'main_thing' );
  618. wp_enqueue_script( 'uploadify_js' );
  619. $wp_styles->add_data('bootstrap_ie6', 'conditional', 'lte IE 7');
  620. endif;
  621. }
  622. /*************************************************************
  623. *
  624. * ProjectTheme (c) sitemile.com - function
  625. *
  626. **************************************************************/
  627. function ProjectTheme_2_user_types()
  628. {
  629. $ProjectTheme_enable_2_user_tp = get_option('ProjectTheme_enable_2_user_tp');
  630. if( $ProjectTheme_enable_2_user_tp == "yes") return true;
  631. return false;
  632. }
  633. /*************************************************************
  634. *
  635. * ProjectTheme (c) sitemile.com - function
  636. *
  637. **************************************************************/
  638. /*function ProjectTheme_is_user_provider($uid)
  639. {
  640. if(!ProjectTheme_2_user_types()) return true;
  641. //----------------------
  642. $can_do_both = get_user_meta($uid, 'can_do_both', true);
  643. if($can_do_both == "yes") return true;
  644. //----------------------
  645. $user_tp = get_user_meta($uid, 'user_tp', true);
  646. if($user_tp == "service_provider") return true;
  647. $user = get_userdata($uid);
  648. if($user->user_level == 10) return true;
  649. return false;
  650. }*/
  651. function ProjectTheme_is_user_provider($uid)
  652. {
  653. if(!ProjectTheme_2_user_types()) return true;
  654. //----------------------
  655. $can_do_both = get_user_meta($uid, 'can_do_both', true);
  656. if($can_do_both == "yes") return true;
  657. //----------------------
  658. $user_data = get_userdata($uid);
  659. $user_roles = $user_data->roles;
  660. if(is_array($user_roles))
  661. $user_role = array_shift($user_roles);
  662. if($user_role == "service_provider") return true;
  663. $user_tp = get_user_meta($uid, 'user_tp', true);
  664. if($user_tp == "service_provider") return true;
  665. if($user_role == "administrator") return true;
  666. $user = get_userdata($uid);
  667. if($user->user_level == 10) return true;
  668. return false;
  669. }
  670. /*************************************************************
  671. *
  672. * ProjectTheme (c) sitemile.com - function
  673. *
  674. **************************************************************/
  675. /*function ProjectTheme_is_user_business($uid)
  676. {
  677. if(!ProjectTheme_2_user_types()) return true;
  678. //----------------------
  679. $can_do_both = get_user_meta($uid, 'can_do_both', true);
  680. if($can_do_both == "yes") return true;
  681. //----------------------
  682. $user_tp = get_user_meta($uid, 'user_tp', true);
  683. if($user_tp != "service_provider") return true;
  684. $user = get_userdata($uid);
  685. if($user->user_level == 10) return true;
  686. return false;
  687. } */
  688. function ProjectTheme_is_user_business($uid)
  689. {
  690. if(!ProjectTheme_2_user_types()) return true;
  691. //----------------------
  692. $can_do_both = get_user_meta($uid, 'can_do_both', true);
  693. if($can_do_both == "yes") return true;
  694. //----------------------
  695. $user = get_userdata($uid);
  696. $user_roles = $user->roles;
  697. if(is_array($user_roles))
  698. $user_role = array_shift($user_roles);
  699. if($user_role == "business_owner") return true;
  700. if($user_role == "administrator") return true;
  701. if($user->user_level == 10) return true;
  702. return false;
  703. }
  704. /*************************************************************
  705. *
  706. * ProjectTheme (c) sitemile.com - function
  707. *
  708. **************************************************************/
  709. function project_isValidEmail($email){
  710. return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email);
  711. }
  712. /*************************************************************
  713. *
  714. * ProjectTheme (c) sitemile.com - function
  715. *
  716. **************************************************************/
  717. function projectTheme_small_post()
  718. {
  719. $ending = get_post_meta(get_the_ID(), 'ending', true);
  720. $sec = $ending - current_time('timestamp',0);
  721. $location = get_post_meta(get_the_ID(), 'Location', true);
  722. $price = get_post_meta(get_the_ID(), 'price', true);
  723. $closed = get_post_meta(get_the_ID(), 'closed', true);
  724. $featured = get_post_meta(get_the_ID(), 'featured', true);
  725. $private_bids = get_post_meta(get_the_ID(), 'at', true);
  726. ?>
  727. <div class="post" id="post-<?php the_ID(); ?>">
  728. <?php if($featured == "1"): ?>
  729. <div class="featured-two"></div>
  730. <?php endif; ?>
  731. <?php if($private_bids == "yes" or $private_bids == "1"): ?>
  732. <div class="sealed-two"></div>
  733. <?php endif; ?>
  734. <div class="image_holder2">
  735. <a href="<?php the_permalink(); ?>"><img width="50" height="50" class="image_class"
  736. src="<?php echo ProjectTheme_get_first_post_image(get_the_ID(),75,65); ?>" /></a>
  737. </div>
  738. <div class="title_holder2" >
  739. <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
  740. <?php
  741. the_title();
  742. ?></a></h2>
  743. <p class="mypostedon2">
  744. <?php _e("Posted in",'ProjectTheme');?> <?php echo get_the_term_list( get_the_ID(), 'project_cat', '', ', ', '' ); ?><br/>
  745. <?php
  746. $ProjectTheme_enable_project_location = get_option('ProjectTheme_enable_project_location');
  747. if($ProjectTheme_enable_project_location == "yes"):
  748. ?>
  749. <?php _e("Location",'ProjectTheme');?>: <?php
  750. $lc = get_the_term_list( get_the_ID(), 'project_location', '', ', ', '' );
  751. echo (empty($lc) ? __("not defined",'ProjectTheme') : $lc );
  752. endif;
  753. ?> </p>
  754. </div></div> <?php
  755. }
  756. /*************************************************************
  757. *
  758. * ProjectTheme (c) sitemile.com - function
  759. *
  760. **************************************************************/
  761. function ProjectTheme_is_home()
  762. {
  763. global $current_user, $wp_query;
  764. $p_action = $wp_query->query_vars['p_action'];
  765. if(!empty($p_action)) return false;
  766. if(is_home()) return true;
  767. return false;
  768. }
  769. /*************************************************************
  770. *
  771. * ProjectTheme (c) sitemile.com - function
  772. *
  773. **************************************************************/
  774. function ProjectTheme_replace_stuff_for_me($find, $replace, $subject)
  775. {
  776. $i = 0;
  777. foreach($find as $item)
  778. {
  779. $replace_with = $replace[$i];
  780. $subject = str_replace($item, $replace_with, $subject);
  781. $i++;
  782. }
  783. return $subject;
  784. }
  785. /*************************************************************
  786. *
  787. * ProjectTheme (c) sitemile.com - function
  788. *
  789. **************************************************************/
  790. function projectTheme_get_winner_bid($pid)
  791. {
  792. global $wpdb;
  793. $s = "select * from ".$wpdb->prefix."project_bids where pid='$pid' and winner='1'";
  794. $r = $wpdb->get_results($s);
  795. return $r[0];
  796. }
  797. function projectTheme_get_bid_by_uid($pid, $uid)
  798. {
  799. global $wpdb;
  800. $s = "select * from ".$wpdb->prefix."project_bids where pid='$pid' and uid='$uid'";
  801. $r = $wpdb->get_results($s);
  802. return $r[0];
  803. }
  804. /*************************************************************
  805. *
  806. * ProjectTheme (c) sitemile.com - function
  807. *
  808. **************************************************************/
  809. function ProjectTheme_my_backend_projects_orderby( $query ) {
  810. if( ! is_admin() )
  811. return;
  812. $post_type = $query->query_vars['post_type'];
  813. $orderby = $query->get( 'orderby');
  814. if($post_type == "project"):
  815. $query->set('meta_key','ending');
  816. $query->set('orderby','meta_value_num');
  817. if( 'exp' == $orderby ) {
  818. $query->set('meta_key','ending');
  819. $query->set('orderby','meta_value_num');
  820. }
  821. if( 'feat' == $orderby ) {
  822. $query->set('meta_key','featured');
  823. $query->set('orderby','meta_value_num');
  824. }
  825. endif;
  826. }
  827. /*************************************************************
  828. *
  829. * ProjectTheme (c) sitemile.com - function
  830. *
  831. **************************************************************/
  832. function ProjectTheme_sortable_cake_column( $columns ) {
  833. $columns['exp'] = 'exp';
  834. $columns['feat'] = 'feat';
  835. return $columns;
  836. }
  837. /*************************************************************
  838. *
  839. * ProjectTheme (c) sitemile.com - function
  840. *
  841. **************************************************************/
  842. function ProjectTheme_my_projects_columns($columns) //this function display the columns headings
  843. {
  844. $columns = array(
  845. "cb" => "<input type=\"checkbox\" />",
  846. "title" => __("Project Title","ProjectTheme"),
  847. "author" => __("Author","ProjectTheme"),
  848. "posted" => __("Posted On","ProjectTheme"),
  849. "price" => __("Price","ProjectTheme"),
  850. "exp" => __("Expires in","ProjectTheme"),
  851. "feat" => __("Featured","ProjectTheme"),
  852. "approveds" => __("Approved","ProjectTheme"),
  853. "thumbnail" => __("Thumbnail","ProjectTheme"),
  854. "options" => __("Options","ProjectTheme")
  855. );
  856. return $columns;
  857. }
  858. /*************************************************************
  859. *
  860. * ProjectTheme (c) sitemile.com - function
  861. *
  862. **************************************************************/
  863. function ProjectTheme_my_custom_columns($column)
  864. {
  865. global $post;
  866. if ("ID" == $column) echo $post->ID; //displays title
  867. elseif ("description" == $column) echo $post->ID; //displays the content excerpt
  868. elseif ("posted" == $column) echo date_i18n('jS \of F, Y \<\b\r\/\>H:i:s',strtotime($post->post_date)); //displays the content excerpt
  869. elseif ("thumbnail" == $column)
  870. {
  871. echo '<a href="'.get_bloginfo('siteurl').'/wp-admin/post.php?post='.$post->ID.'&action=edit"><img class="image_class"
  872. src="'.ProjectTheme_get_first_post_image($post->ID,75,65).'" width="75" height="65" /></a>'; //shows up our post thumbnail that we previously created.
  873. }
  874. elseif ("author" == $column)
  875. {
  876. echo $post->post_author;
  877. }
  878. elseif ("approveds" == $column)
  879. {
  880. $paid = get_post_meta($post->ID, 'paid', true);
  881. if($post->post_status == "draft") echo "No";
  882. else echo "Yes";
  883. }
  884. elseif ("feat" == $column)
  885. {
  886. $f = get_post_meta($post->ID,'featured', true);
  887. if($f == "1") echo __("Yes","ProjectTheme");
  888. else echo __("No","ProjectTheme");
  889. }
  890. elseif ("price" == $column)
  891. {
  892. echo ProjectTheme_get_budget_name_string_fromID(get_post_meta($post->ID,'budgets',true));
  893. }
  894. elseif ("exp" == $column)
  895. {
  896. $ending = get_post_meta($post->ID, 'ending', true);
  897. echo ProjectTheme_prepare_seconds_to_words($ending - current_time('timestamp',0));
  898. }
  899. elseif ("options" == $column)
  900. {
  901. echo '<div style="padding-top:20px">';
  902. echo '<a class="awesome" href="'.get_bloginfo('siteurl').'/wp-admin/post.php?post='.$post->ID.'&action=edit">Edit</a> ';
  903. echo '<a class="awesome" href="'.get_permalink($post->ID).'" target="_blank">View</a> ';
  904. echo '<a class="trash" href="'.get_delete_post_link($post->ID).'">Trash</a> ';
  905. echo '</div>';
  906. }
  907. }
  908. /*************************************************************
  909. *
  910. * ProjectTheme (c) sitemile.com - function
  911. *
  912. **************************************************************/
  913. function ProjecTheme_get_budgets_dropdown($selected = '', $class = '' , $rui = 0)
  914. {
  915. $ech = '<select name="budgets" class="'.$class.'">';
  916. global $wpdb;
  917. $s = "select * from ".$wpdb->prefix."project_bidding_intervals order by low_limit asc";
  918. $r = $wpdb->get_results($s);
  919. if($rui == 1) $ech .= '<option value="">'.__('Select','ProjectTheme').'</option>';
  920. foreach($r as $row)
  921. {
  922. $nm = ProjectTheme_get_budget_name_string($row);
  923. $ech .= '<option value="'.$row->id.'" '.($row->id == $selected ? 'selected="selected"' : '').'>'.$nm.'</option>';
  924. }
  925. return $ech.'</select>';
  926. }
  927. /*************************************************************
  928. *
  929. * ProjectTheme (c) sitemile.com - function
  930. *
  931. **************************************************************/
  932. function projectTheme_set_metaboxes()
  933. {
  934. add_meta_box( 'project_custom_fields', 'Project Custom Fields', 'projectTheme_custom_fields_html', 'project', 'advanced','high' );
  935. add_meta_box( 'project_images', 'Project Images', 'projectTheme_theme_project_images', 'project', 'advanced', 'high' );
  936. add_meta_box( 'project_files', 'Project Files', 'projectTheme_theme_project_files', 'project', 'advanced', 'high' );
  937. add_meta_box( 'project_bids', 'Project Bids', 'projectTheme_theme_project_bids', 'project', 'advanced', 'high' );
  938. add_meta_box( 'project_dets', 'Project Details', 'projectTheme_theme_project_dts', 'project', 'side', 'high' );
  939. }
  940. function projectTheme_custom_fields_html()
  941. {
  942. global $post, $wpdb;
  943. $pid = $post->ID;
  944. ?>
  945. <table width="100%">
  946. <input type="hidden" value="1" name="fromadmin" />
  947. <?php
  948. $cat = wp_get_object_terms($pid, 'project_cat');
  949. $catidarr = $cat[0]->term_id;
  950. $arr = ProjectTheme_get_project_category_fields($catidarr, $pid);
  951. for($i=0;$i<count($arr);$i++)
  952. {
  953. echo '<tr>';
  954. echo '<td>'.$arr[$i]['field_name'].$arr[$i]['id'].':</td>';
  955. echo '<td>'.$arr[$i]['value'];
  956. do_action('ProjectTheme_step3_after_custom_field_'.$arr[$i]['id'].'_field');
  957. echo '</td>';
  958. echo '</tr>';
  959. }
  960. ?>
  961. </table>
  962. <?php
  963. }
  964. /*************************************************************
  965. *
  966. * ProjectTheme (c) sitemile.com - function
  967. *
  968. **************************************************************/
  969. function projectTheme_theme_project_dts()
  970. {
  971. global $post;
  972. $pid = $post->ID;
  973. $price = get_post_meta($pid, "price", true);
  974. $location = get_post_meta($pid, "Location", true);
  975. $f = get_post_meta($pid, "featured", true);
  976. $t = get_post_meta($pid, "closed", true);
  977. $hide_project = get_post_meta($pid, "hide_project", true);
  978. ?>
  979. <ul id="post-new4">
  980. <input name="fromadmin" type="hidden" value="1" />
  981. <li>
  982. <h2><?php echo __('Price','ProjectTheme'); ?>:</h2>
  983. <p>
  984. <?php
  985. $sel = get_post_meta($pid, 'budgets', true);
  986. echo ProjecTheme_get_budgets_dropdown($sel, 'do_input');
  987. ?>
  988. </p>
  989. </li>
  990. <li>
  991. <h2><?php echo __('Sealed Bids','ProjectTheme'); ?>:</h2>
  992. <p><select name="private_bids">
  993. <option value="0" <?php if(get_post_meta($pid,'private_bids',true) == "0") echo 'selected="selected"'; ?>><?php _e("No",'ProjectTheme'); ?></option>
  994. <option value="1" <?php if(get_post_meta($pid,'private_bids',true) == "1") echo 'selected="selected"'; ?>><?php _e("Yes",'ProjectTheme'); ?></option>
  995. </select>
  996. </p>
  997. </li>
  998. <li>
  999. <h2><?php _e("Feature this project",'ProjectTheme');?>:</h2>
  1000. <p><input type="checkbox" value="1" name="featureds" <?php if($f == '1') echo ' checked="checked" '; ?> /></p>
  1001. </li>
  1002. <li>
  1003. <h2><?php _e("Hide this project",'ProjectTheme');?>:</h2>
  1004. <p><input type="checkbox" value="1" name="hide_project" <?php if($hide_project == '1') echo ' checked="checked" '; ?> /></p>
  1005. </li>
  1006. <li>
  1007. <h2><?php _e("Closed",'ProjectTheme');?>:</h2>
  1008. <p><input type="checkbox" value="1" name="closed" <?php if($t == '1') echo ' checked="checked" '; ?> /></p>
  1009. </li>
  1010. <li>
  1011. <h2><?php _e("Address",'ProjectTheme');?>:</h2>
  1012. <p><input type="text" value="<?php echo get_post_meta($pid,'Location',true); ?>" name="Location" /></p>
  1013. </li>
  1014. <li>
  1015. <h2>
  1016. <link rel="stylesheet" media="all" type="text/css" href="<?php echo get_bloginfo('template_url'); ?>/css/ui-thing.css" />
  1017. <script type="text/javascript" language="javascript" src="<?php echo get_bloginfo('template_url'); ?>/js/jquery-ui-timepicker-addon.js"></script>
  1018. <?php _e("Project Ending On",'ProjectTheme'); ?>:</h2>
  1019. <p><input type="text" name="ending" id="ending" value="<?php
  1020. $d = get_post_meta($pid,'ending',true);
  1021. if(!empty($d)) {
  1022. $r = date_i18n('m/d/Y H:i:s', $d);
  1023. echo $r;
  1024. }
  1025. ?>" class="do_input" /></p>
  1026. </li>
  1027. <script>
  1028. jQuery(document).ready(function() {
  1029. jQuery('#ending').datetimepicker({
  1030. showSecond: true,
  1031. timeFormat: 'hh:mm:ss'
  1032. });});
  1033. </script>
  1034. </ul>
  1035. <?php
  1036. }
  1037. /*************************************************************
  1038. *
  1039. * ProjectTheme (c) sitemile.com - function
  1040. *
  1041. **************************************************************/
  1042. function projectTheme_get_highest_bid($pid)
  1043. {
  1044. global $wpdb;
  1045. $s = "select bid from ".$wpdb->prefix."project_bids where pid='$pid' order by bid desc limit 1";
  1046. $r = $wpdb->get_results($s);
  1047. if(count($r) == 0)
  1048. {
  1049. $start_price = get_post_meta($pid, 'start_price', true);
  1050. if(empty($start_price)) return false;
  1051. return $start_price;
  1052. }
  1053. $r = $r[0];
  1054. return $r->bid;
  1055. }
  1056. /*************************************************************
  1057. *
  1058. * ProjectTheme (c) sitemile.com - function
  1059. *
  1060. **************************************************************/
  1061. function projectTheme_get_highest_bid_owner($pid)
  1062. {
  1063. global $wpdb;
  1064. $s = "select bid from ".$wpdb->prefix."project_bids where pid='$pid' order by bid desc limit 1";
  1065. $r = $wpdb->get_results($s);
  1066. if(count($r) == 0)
  1067. return false;
  1068. $r = $r[0];
  1069. return $r->uid;
  1070. }
  1071. /*************************************************************
  1072. *
  1073. * ProjectTheme (c) sitemile.com - function
  1074. *
  1075. **************************************************************/
  1076. function projectTheme_get_bid_values($pid)
  1077. {
  1078. global $wpdb;
  1079. $s = "select bid from ".$wpdb->prefix."project_bids where pid='$pid' order by bid desc";
  1080. $r = $wpdb->get_results($s);
  1081. return $r;
  1082. }
  1083. /*************************************************************
  1084. *
  1085. * ProjectTheme (c) sitemile.com - function
  1086. *
  1087. **************************************************************/
  1088. function projectTheme_get_current_price($pid = '')
  1089. {
  1090. if(empty($pid)) $pid = get_the_ID();
  1091. $only_buy_now = get_post_meta($pid, 'only_buy_now' ,true);
  1092. if($only_buy_now == '1') return get_post_meta($pid, 'buy_now', true);
  1093. $reverse = get_post_meta($pid, "reverse", true);
  1094. if($reverse == "yes") return get_post_meta($pid, 'price', true);
  1095. else
  1096. {
  1097. $bids = projectTheme_get_bid_values($pid);
  1098. if(count($bids) == 0)
  1099. {
  1100. $start = projectTheme_get_start_price($pid);
  1101. return ($start == false ? 0 : $start );
  1102. }
  1103. else
  1104. {
  1105. return projectTheme_get_highest_bid($pid);
  1106. }
  1107. }
  1108. }
  1109. /*************************************************************
  1110. *
  1111. * ProjectTheme (c) sitemile.com - function
  1112. *
  1113. **************************************************************/
  1114. function projectTheme_get_start_price($pid = '')
  1115. {
  1116. if(empty($pid)) $pid = get_the_ID();
  1117. $price = get_post_meta($pid, 'start_price', true);
  1118. if(empty($price)) $price = false;
  1119. return $price;
  1120. }
  1121. /*************************************************************
  1122. *
  1123. * ProjectTheme (c) sitemile.com - function
  1124. *
  1125. **************************************************************/
  1126. add_filter('post_type_link', 'ProjectTheme_post_type_link_filter_function', 1, 3);
  1127. function ProjectTheme_post_type_link_filter_function( $post_link, $id = 0, $leavename = FALSE ) {
  1128. global $category_url_link;
  1129. if ( strpos('%project_cat%', $post_link) === 'FALSE' ) {
  1130. return $post_link;
  1131. }
  1132. $post = get_post($id);
  1133. if ( !is_object($post) || $post->post_type != 'project' ) {
  1134. return str_replace("project_cat", $category_url_link ,$post_link);
  1135. }
  1136. $terms = wp_get_object_terms($post->ID, 'project_cat');
  1137. if ( !$terms ) {
  1138. return str_replace('%project_cat%', 'uncategorized', $post_link);
  1139. }
  1140. return str_replace('%project_cat%', $terms[0]->slug, $post_link);
  1141. }
  1142. /*************************************************************
  1143. *
  1144. * ProjectTheme (c) sitemile.com - function
  1145. *
  1146. **************************************************************/
  1147. function projectTheme_theme_project_files()
  1148. {
  1149. global $current_user;
  1150. get_currentuserinfo();
  1151. $cid = $current_user->ID;
  1152. global $post;
  1153. $pid = $post->ID;
  1154. $cwd = str_replace('wp-admin','',getcwd());
  1155. $cwd .= 'wp-content/uploads';
  1156. //echo get_template_directory();
  1157. ?>
  1158. <div style="overflow:hidden">
  1159. <script type="text/javascript" src="<?php echo get_bloginfo('template_url'); ?>/lib/uploadify/jquery.uploadify-3.1.js"></script>
  1160. <link rel="stylesheet" href="<?php echo get_bloginfo('template_url'); ?>/lib/uploadify/uploadify.css" type="text/css" />
  1161. <script type="text/javascript">
  1162. function delete_this(id)
  1163. {
  1164. jQuery.ajax({
  1165. method: 'get',
  1166. url : '<?php echo get_bloginfo('siteurl');?>/index.php/?_ad_delete_pid='+id,
  1167. dataType : 'text',
  1168. success: function (text) { jQuery('#image_ss'+id).remove(); }
  1169. });
  1170. //alert("a");
  1171. }
  1172. jQuery(function() {
  1173. jQuery("#fileUpload3").uploadify({
  1174. height : 30,
  1175. auto: true,
  1176. swf : '<?php echo get_bloginfo('template_url'); ?>/lib/uploadify/uploadify.swf',
  1177. uploader : '<?php echo get_bloginfo('template_url'); ?>/lib/uploadify/uploady2.php',
  1178. width : 120,
  1179. fileTypeExts : '*.zip;*.pdf;*.doc;*.docx',
  1180. fileTypeDesc : '<?php _e('Select Project Files','ProjectTheme'); ?>',
  1181. formData : {'ID':<?php echo $pid; ?>,'author':<?php echo $cid; ?>},
  1182. onUploadSuccess : function(file, data, response) {
  1183. //alert(data);
  1184. var bar = data.split("|");
  1185. jQuery('#thumbnails2').append('<div class="div_div" id="image_ss'+bar[1]+'" > ' + bar[0] + '" <a href="javascript: void(0)" onclick="delete_this('+ bar[1] +')"><img border="0" src="<?php echo get_bloginfo('template_url'); ?>/images/delete_icon.png" border="0" /></a></div>');
  1186. }
  1187. });
  1188. });
  1189. </script>
  1190. <style type="text/css">
  1191. .div_div1
  1192. {
  1193. margin-left:5px; float:left;
  1194. width:100%;
  1195. margin-top:10px;
  1196. }
  1197. </style>
  1198. <div id="fileUpload3">You have a problem with your javascript</div>
  1199. <div id="thumbnails2" style="overflow:hidden;margin-top:20px">
  1200. <?php
  1201. $args = array(
  1202. 'order' => 'ASC',
  1203. 'orderby' => 'menu_order',
  1204. 'post_type' => 'attachment',
  1205. 'post_parent' => $pid,
  1206. 'post_status' => null,
  1207. 'numberposts' => -1,
  1208. );
  1209. $attachments = get_posts($args);
  1210. if ($attachments) {
  1211. foreach ($at

Large files files are truncated, but you can click here to view the full file