/** * Insert attention message * * This function will show "Attention! This job is ..." message if current user * is on job details page and currently viewed job is older than X days. * * @since 1.0 * @return void */ function push_attention_msg() { $job = null; if (is_singular("job")) { $query = new Daq_Db_Query(); $query->from("Wpjb_Model_Job t"); $query->where("post_id = ?", get_the_ID()); $query->limit(1); $result = $query->execute(); if (isset($result[0])) { $job = $result[0]; } } if (is_wpjb() && wpjb_is_routed_to("index.single")) { $job = Wpjb_Project::getInstance()->placeHolder->job; } if ($job === null) { return; } $old = wpjb_conf("front_mark_as_old"); if ($old > 0 && time() - strtotime($job->job_created_at) > $old * 3600 * 24) { $diff = floor((time() - strtotime($job->job_created_at)) / (3600 * 24)); $msg = _n("Attention! This job posting is one day old and might be already filled.", "Attention! This job posting is %d days old and might be already filled.", $diff, "wpjobboard"); $flash = new Wpjb_Utility_Session(); $flash->addInfo(sprintf($msg, $diff)); $flash->save(); } }
public function addScriptsFront() { if (!is_wpjb() && !is_wpjr()) { return; } wp_enqueue_script('wpjb-js', trim(site_url(), "/") . '/wp-content/plugins/wpjobboard/templates/js.js', array("jquery")); $listing = array(); if (is_wpjb() && $this->router()->isRoutedTo("addJob.add")) { $query = new Daq_Db_Query(); $result = $query->select("*")->from("Wpjb_Model_Listing t")->where("is_active = 1")->execute(); foreach ($result as $l) { /* @var $l Wpjb_Model_Listing */ $temp = $l->toArray(); $temp['symbol'] = Wpjb_List_Currency::getCurrencySymbol($l->currency); $listing[] = $temp; } wp_enqueue_script("wpjb-suggest"); } if (wpjb_is_routed_to(array("employer_new", "employer_edit"), "frontend")) { wp_enqueue_script("wpjb-suggest"); } $object = array("Listing" => $listing, "Lang" => json_encode(array("Check" => __("check", WPJB_DOMAIN), "SelectListingType" => __("Select listing type", WPJB_DOMAIN), "ListingCost" => __("Listing cost", WPJB_DOMAIN), "Discount" => __("Discount", WPJB_DOMAIN), "Total" => __("Total", WPJB_DOMAIN), "Remove" => __("remove", WPJB_DOMAIN), "CurrencyMismatch" => __("Cannot use selected coupon with this listing. Currencies does not match.", WPJB_DOMAIN), "ResetForm" => __("Reset all form fields?", WPJB_DOMAIN))), "Ajax" => admin_url("admin-ajax.php"), "AjaxRequest" => Wpjb_Project::getInstance()->getUrl() . "/plain/discount", "Protection" => Wpjb_Project::getInstance()->conf("front_protection", "pr0t3ct1on")); //wp_localize_script("wpjb-js", "Wpjb.Lang", $object); }