/** * 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(); } }
function wpjb_is_routed_to($path, $module = "frontend") { $i = Wpjb_Project::getInstance(); $path = (array) $path; foreach ($path as $p) { $router = false; if ($module == "frontend" && is_wpjb()) { $router = $i->getApplication($module)->getRouter()->isRoutedTo($p); } elseif ($module == "resumes" && is_wpjr()) { $router = $i->getApplication($module)->getRouter()->isRoutedTo($p); } if ($router) { return true; } } return false; }
public function adminBarMenu() { global $wp_admin_bar; if (!is_super_admin() || !is_admin_bar_showing()) { return; } if (is_wpjb() || is_wpjr()) { $wp_admin_bar->remove_menu("edit"); $wp_admin_bar->remove_menu("comments"); } if (is_wpjb() && $this->router()->isRoutedTo("index.single")) { $object = $this->getApplication("frontend")->controller; if (is_object($object)) { $object = $object->getObject(); $wp_admin_bar->add_menu(array('id' => 'edit-job', 'title' => __("Edit Job", WPJB_DOMAIN), 'href' => admin_url("admin.php?page=wpjb/job&action=edit/id/" . $object->getId()))); } } if (is_wpjr() && $this->router("resumes")->isRoutedTo("index.view")) { $object = $this->getApplication("resumes")->controller; if (is_object($object)) { $object = $object->getObject(); $wp_admin_bar->add_menu(array('id' => 'edit-resume', 'title' => __("Edit Resume", WPJB_DOMAIN), 'href' => admin_url("admin.php?page=wpjb/resumes&action=edit/id/" . $object->getId()))); } } }