コード例 #1
0
ファイル: relist-job-process.php プロジェクト: besimhu/legacy
/**
 * JobRoller Relist Job Process
 * Processes a job edit/relist.
 *
 *
 * @version 1.3
 * @author AppThemes
 * @package JobRoller
 * @copyright 2010 all rights reserved
 *
 */
function jr_process_relist_job_form()
{
    global $user_ID, $post, $posted, $job_details, $wpdb, $jr_log;
    $errors = new WP_Error();
    if (isset($_POST['job_submit']) && $_POST['job_submit']) {
        include_once ABSPATH . 'wp-admin/includes/file.php';
        include_once ABSPATH . 'wp-admin/includes/image.php';
        include_once ABSPATH . 'wp-admin/includes/media.php';
        // Get (and clean) data
        $fields = array('your_name', 'website', 'job_title', 'job_term_type', 'job_term_cat', 'job_pack', 'jr_geo_latitude', 'jr_geo_longitude', 'jr_address', 'details', 'apply', 'tags');
        foreach ($fields as $field) {
            $posted[$field] = stripslashes(trim($_POST[$field]));
        }
        if (isset($_POST['featureit']) && $_POST['featureit']) {
            $posted['featureit'] = 'yes';
        } else {
            $posted['featureit'] = '';
        }
        ### Strip html
        if (get_option('jr_html_allowed') == 'no') {
            $posted['details'] = strip_tags($posted['details']);
            $posted['apply'] = strip_tags($posted['apply']);
        }
        ### End strip
        // Check required fields
        $required = array('job_title' => __('Job title', 'appthemes'), 'job_term_type' => __('Job type', 'appthemes'), 'details' => __('Job description', 'appthemes'));
        if (get_option('jr_submit_cat_required') == 'yes') {
            $submit_cat = array('job_term_cat' => __('Job category', 'appthemes'));
            $required = array_merge($required, $submit_cat);
        }
        foreach ($required as $field => $name) {
            if (empty($posted[$field])) {
                $errors->add('submit_error', __('<strong>ERROR</strong>: &ldquo;', 'appthemes') . $name . __('&rdquo; is a required field.', 'appthemes'));
            }
        }
        if ($errors && sizeof($errors) > 0 && $errors->get_error_code()) {
            // Do nothing - edit has failed
        } else {
            // So far, so good. Upload logo if set.
            if (isset($_FILES['company-logo']) && !empty($_FILES['company-logo']['name'])) {
                $posted['company-logo-name'] = $_FILES['company-logo']['name'];
                // Check valid extension
                $allowed = array('png', 'gif', 'jpg', 'jpeg');
                //$extension = strtolower(pathinfo($_FILES['company-logo']['name'], PATHINFO_EXTENSION));
                $extension = strtolower(substr(strrchr($_FILES['company-logo']['name'], "."), 1));
                if (!in_array($extension, $allowed)) {
                    $errors->add('submit_error', __('<strong>ERROR</strong>: Only jpg, gif, and png images are allowed.', 'appthemes'));
                }
                function company_logo_upload_dir($pathdata)
                {
                    $subdir = '/company_logos' . $pathdata['subdir'];
                    $pathdata['path'] = str_replace($pathdata['subdir'], $subdir, $pathdata['path']);
                    $pathdata['url'] = str_replace($pathdata['subdir'], $subdir, $pathdata['url']);
                    $pathdata['subdir'] = str_replace($pathdata['subdir'], $subdir, $pathdata['subdir']);
                    return $pathdata;
                }
                add_filter('upload_dir', 'company_logo_upload_dir');
                $time = current_time('mysql');
                $overrides = array('test_form' => false);
                $file = wp_handle_upload($_FILES['company-logo'], $overrides, $time);
                remove_filter('upload_dir', 'company_logo_upload_dir');
                if (!isset($file['error'])) {
                    $posted['company-logo'] = $file['url'];
                    $posted['company-logo-type'] = $file['type'];
                    $posted['company-logo-file'] = $file['file'];
                } else {
                    $errors->add('submit_error', __('<strong>ERROR</strong>: ', 'appthemes') . $file['error'] . '');
                }
            }
        }
        if ($errors && sizeof($errors) > 0 && $errors->get_error_code()) {
            // Do nothing - edit has failed
        } else {
            // Good to go, lets save this bad boy and show a confirmation message
            // Calc costs/get packs
            $cost = 0;
            $job_pack = '';
            $user_pack = '';
            $jobs_last = '';
            // Get Pack from previous step
            if (isset($posted['job_pack']) && !empty($posted['job_pack'])) {
                if (strstr($posted['job_pack'], 'user_')) {
                    $user_pack_id = (int) str_replace('user_', '', $posted['job_pack']);
                    $user_pack = new jr_user_pack($user_pack_id);
                    if (!$user_pack->get_valid_pack()) {
                        wp_die(__('Error: Invalid Pack.', 'appthemes'));
                    }
                    $jobs_last = $user_pack->job_duration;
                } else {
                    $job_pack = new jr_pack($posted['job_pack']);
                    $cost += $job_pack->pack_cost;
                    $jobs_last = $job_pack->job_duration;
                }
            } else {
                // No Packs
                $listing_cost = get_option('jr_jobs_relisting_cost');
                $cost += $listing_cost;
            }
            // Caculate expirey date from today
            if (!$jobs_last) {
                $jobs_last = 30;
            }
            // 30 day default
            $date = strtotime('+' . $jobs_last . ' day', current_time('timestamp'));
            // Get Featured from previous step
            if ($posted['featureit'] == 'yes') {
                $featured_cost = get_option('jr_cost_to_feature');
                $cost += $featured_cost;
            }
            ### Approval needed?
            $status = 'publish';
            if ($cost > 0 && !$user_pack) {
                $status = 'pending';
            }
            ### Update Post
            $data = array('ID' => $job_details->ID, 'post_content' => $wpdb->escape($posted['details']), 'post_title' => $wpdb->escape($posted['job_title']), 'post_status' => $status, 'post_date' => date('Y-m-d H:i:s'), 'post_date_gmt' => get_gmt_from_date(date('Y-m-d H:i:s')));
            wp_update_post($data);
            ### Update meta data and category
            update_post_meta($job_details->ID, '_Company', $posted['your_name']);
            update_post_meta($job_details->ID, '_CompanyURL', $posted['website']);
            update_post_meta($job_details->ID, '_how_to_apply', $posted['apply']);
            update_post_meta($job_details->ID, '_expires', $date);
            $post_into_cats = array();
            $post_into_types = array();
            if ($posted['job_term_cat'] > 0) {
                $post_into_cats[] = get_term_by('id', $posted['job_term_cat'], 'job_cat')->slug;
            }
            ### Set Categories
            if ($posted['featureit'] == 'yes') {
                global $featured_job_cat_id;
                $featured_job_cat_name = get_term_by('id', $featured_job_cat_id, 'job_cat')->name;
                $post_into_cats[] = sanitize_title($featured_job_cat_name);
            }
            if (sizeof($post_into_cats) > 0) {
                wp_set_object_terms($job_details->ID, $post_into_cats, 'job_cat');
            }
            $post_into_types[] = get_term_by('slug', sanitize_title($posted['job_term_type']), 'job_type')->slug;
            if (sizeof($post_into_types) > 0) {
                wp_set_object_terms($job_details->ID, $post_into_types, 'job_type');
            }
            ### Salary
            $salary = array();
            if ($posted['job_term_salary'] > 0) {
                $salary[] = get_term_by('id', $posted['job_term_salary'], 'job_salary')->slug;
            }
            wp_set_object_terms($job_details->ID, $salary, 'job_salary');
            ### Tags
            if ($posted['tags']) {
                $thetags = explode(',', $posted['tags']);
                $thetags = array_map('trim', $thetags);
                $thetags = array_map('strtolower', $thetags);
                if (sizeof($thetags) > 0) {
                    wp_set_object_terms($job_details->ID, $thetags, 'job_tag');
                }
            }
            ### GEO
            if (!empty($posted['jr_address'])) {
                $latitude = jr_clean_coordinate($posted['jr_geo_latitude']);
                $longitude = jr_clean_coordinate($posted['jr_geo_longitude']);
                update_post_meta($job_details->ID, '_jr_geo_latitude', $latitude);
                update_post_meta($job_details->ID, '_jr_geo_longitude', $longitude);
                if ($latitude && $longitude) {
                    $address = jr_reverse_geocode($latitude, $longitude);
                    update_post_meta($job_details->ID, 'geo_address', $address['address']);
                    update_post_meta($job_details->ID, 'geo_country', $address['country']);
                    update_post_meta($job_details->ID, 'geo_short_address', $address['short_address']);
                    update_post_meta($job_details->ID, 'geo_short_address_country', $address['short_address_country']);
                }
            } else {
                // They left the field blank so we assume the job is for 'anywhere'
                delete_post_meta($job_details->ID, '_jr_geo_latitude');
                delete_post_meta($job_details->ID, '_jr_geo_longitude');
                delete_post_meta($job_details->ID, 'geo_address');
                delete_post_meta($job_details->ID, 'geo_country');
                delete_post_meta($job_details->ID, 'geo_short_address');
                delete_post_meta($job_details->ID, 'geo_short_address_country');
            }
            ## Link to company image
            if (isset($posted['company-logo']) && $posted['company-logo']) {
                $name_parts = pathinfo($posted['company-logo-name']);
                $name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
                $url = $posted['company-logo'];
                $type = $posted['company-logo-type'];
                $file = $posted['company-logo-file'];
                $title = $posted['company-logo-name'];
                $content = '';
                // use image exif/iptc data for title and caption defaults if possible
                if ($image_meta = @wp_read_image_metadata($file)) {
                    if (trim($image_meta['title'])) {
                        $title = $image_meta['title'];
                    }
                    if (trim($image_meta['caption'])) {
                        $content = $image_meta['caption'];
                    }
                }
                // Construct the attachment array
                $attachment = array_merge(array('post_mime_type' => $type, 'guid' => $url, 'post_parent' => $job_details->ID, 'post_title' => $title, 'post_content' => $content), array());
                // Save the data
                $id = wp_insert_attachment($attachment, $file, $job_details->ID);
                if (!is_wp_error($id)) {
                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
                }
                update_post_meta($job_details->ID, '_thumbnail_id', $id);
            }
            ### If paying with pack, update the customers pack totals
            if ($user_pack) {
                $inspack = '';
                $user_pack->inc_job_count();
            } elseif (!empty($posted['job_pack'])) {
                $inspack = $posted['job_pack'];
            }
            if ($posted['featureit'] == 'yes') {
                $insfeatured = 1;
            } else {
                $insfeatured = 0;
            }
            ### Create the order in the database so it can be confirmed by user/IPN before going live
            if ($cost > 0) {
                $jr_order = new jr_order(0, $user_ID, $cost, $job_details->ID, $inspack, $insfeatured);
                $jr_order->insert_order();
                ### Redirect to paypal payment page	(if paid listing)
                $name = urlencode(__('Relisting ', 'appthemes') . $posted['job_title'] . __(' w/ Job Pack ', 'appthemes') . $job_pack->pack_name);
                $link = $jr_order->generate_paypal_link($name);
                header('Location: ' . $link);
                exit;
            } else {
                ### Relisting was free
                wp_mail(get_option('admin_email'), __('Job Re-Listed ', 'appthemes') . '[' . get_bloginfo('name') . ']', __('A job has been re-listed called  ', 'appthemes') . '"' . $posted['job_title'] . '" (' . __('ID', 'appthemes') . ': ' . $job_details->ID . ")\n\nEdit post link: " . admin_url("post.php?action=edit&post=" . $job_details->ID . "") . "\nView Post: " . get_permalink($job_details->ID));
                ### Redirect to my jobs
                $args = array('message' => urlencode('Job relisted successfully'));
                redirect_myjobs($args);
            }
        }
        // endif errors
    }
    $form_results = array('errors' => $errors, 'posted' => $posted);
    return $form_results;
}
コード例 #2
0
ファイル: write-panel.php プロジェクト: besimhu/legacy
function jr_save_meta_box($post_id)
{
    global $post, $meta_boxes, $key;
    if (!isset($_POST[$key . '_wpnonce'])) {
        return $post_id;
    }
    if (!wp_verify_nonce($_POST[$key . '_wpnonce'], plugin_basename(__FILE__))) {
        return $post_id;
    }
    if (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    foreach ($meta_boxes as $meta_box) {
        if ($meta_box['name'] == '_jr_geo_latitude' || $meta_box['name'] == '_jr_geo_longitude') {
            update_post_meta($post_id, $meta_box['name'], jr_clean_coordinate($_POST[$meta_box['name']]));
        } elseif ($meta_box['type'] == 'datetime') {
            $year = $_POST[$meta_box['name'] . '_year'];
            $month = $_POST[$meta_box['name'] . '_month'];
            $day = $_POST[$meta_box['name'] . '_day'];
            $hour = $_POST[$meta_box['name'] . '_hour'];
            $min = $_POST[$meta_box['name'] . '_min'];
            if (!$hour) {
                $hour = '00';
            }
            if (!$min) {
                $min = '00';
            }
            if (checkdate($month, $day, $year)) {
                $date = $year . $month . $day . ' ' . $hour . ':' . $min;
                update_post_meta($post_id, $meta_box['name'], strtotime($date));
                // Only if fields were posted; dont delete if they are not shown
            } elseif (isset($_POST[$meta_box['name'] . '_year'])) {
                delete_post_meta($post_id, $meta_box['name']);
            }
        } else {
            update_post_meta($post_id, $meta_box['name'], $_POST[$meta_box['name']]);
        }
    }
    // Update location
    if (!empty($_POST['jr_address'])) {
        $latitude = jr_clean_coordinate($_POST['jr_geo_latitude']);
        $longitude = jr_clean_coordinate($_POST['jr_geo_longitude']);
        update_post_meta($post_id, '_jr_geo_latitude', $latitude);
        update_post_meta($post_id, '_jr_geo_longitude', $longitude);
        if ($latitude && $longitude) {
            // If we don't have address data, do a look-up
            if ($_POST['jr_address'] && $_POST['jr_geo_country'] && $_POST['jr_geo_short_address'] && $_POST['jr_geo_short_address_country']) {
                update_post_meta($post_id, 'geo_address', $_POST['jr_address']);
                update_post_meta($post_id, 'geo_country', $_POST['jr_geo_country']);
                update_post_meta($post_id, 'geo_short_address', $_POST['jr_geo_short_address']);
                update_post_meta($post_id, 'geo_short_address_country', $_POST['jr_geo_short_address_country']);
            } else {
                $address = jr_reverse_geocode($latitude, $longitude);
                update_post_meta($post_id, 'geo_address', $address['address']);
                update_post_meta($post_id, 'geo_country', $address['country']);
                update_post_meta($post_id, 'geo_short_address', $address['short_address']);
                update_post_meta($post_id, 'geo_short_address_country', $address['short_address_country']);
            }
        }
    } else {
        // They left the field blank so we assume the job is for 'anywhere'
        delete_post_meta($post_id, '_jr_geo_latitude');
        delete_post_meta($post_id, '_jr_geo_longitude');
        delete_post_meta($post_id, 'geo_address');
        delete_post_meta($post_id, 'geo_country');
        delete_post_meta($post_id, 'geo_short_address');
        delete_post_meta($post_id, 'geo_short_address_country');
    }
}
コード例 #3
0
ファイル: edit-job-process.php プロジェクト: besimhu/legacy
/**
 * JobRoller Edit Job Process
 * Processes a job edit.
 *
 *
 * @version 1.2
 * @author AppThemes
 * @package JobRoller
 * @copyright 2010 all rights reserved
 *
 */
function jr_process_edit_job_form()
{
    global $post, $posted, $job_details, $wpdb;
    $errors = new WP_Error();
    if (isset($_POST['job_submit']) && $_POST['job_submit']) {
        include_once ABSPATH . 'wp-admin/includes/file.php';
        include_once ABSPATH . 'wp-admin/includes/image.php';
        include_once ABSPATH . 'wp-admin/includes/media.php';
        // Get (and clean) data
        $fields = array('your_name', 'website', 'job_title', 'job_term_type', 'job_term_cat', 'job_term_salary', 'jr_geo_latitude', 'jr_geo_longitude', 'jr_address', 'details', 'apply', 'tags');
        foreach ($fields as $field) {
            $posted[$field] = stripslashes(trim($_POST[$field]));
        }
        ### Strip html
        if (get_option('jr_html_allowed') == 'no') {
            $posted['details'] = strip_tags($posted['details']);
            $posted['apply'] = strip_tags($posted['apply']);
        }
        ### End strip
        // Check required fields
        $required = array('job_title' => __('Job title', 'appthemes'), 'job_term_type' => __('Job type', 'appthemes'), 'details' => __('Job description', 'appthemes'));
        if (get_option('jr_submit_cat_required') == 'yes') {
            $submit_cat = array('job_term_cat' => __('Job category', 'appthemes'));
            $required = array_merge($required, $submit_cat);
        }
        foreach ($required as $field => $name) {
            if (empty($posted[$field])) {
                $errors->add('submit_error', __('<strong>ERROR</strong>: &ldquo;', 'appthemes') . $name . __('&rdquo; is a required field.', 'appthemes'));
            }
        }
        if ($errors && sizeof($errors) > 0 && $errors->get_error_code()) {
            // Do nothing - edit has failed
        } else {
            // So far, so good. Upload logo if set.
            if (isset($_FILES['company-logo']) && !empty($_FILES['company-logo']['name'])) {
                $posted['company-logo-name'] = $_FILES['company-logo']['name'];
                // Check valid extension
                $allowed = array('png', 'gif', 'jpg', 'jpeg');
                //$extension = strtolower(pathinfo($_FILES['company-logo']['name'], PATHINFO_EXTENSION));
                $extension = strtolower(substr(strrchr($_FILES['company-logo']['name'], "."), 1));
                if (!in_array($extension, $allowed)) {
                    $errors->add('submit_error', __('<strong>ERROR</strong>: Only jpg, gif, and png images are allowed.', 'appthemes'));
                }
                function company_logo_upload_dir($pathdata)
                {
                    $subdir = '/company_logos' . $pathdata['subdir'];
                    $pathdata['path'] = str_replace($pathdata['subdir'], $subdir, $pathdata['path']);
                    $pathdata['url'] = str_replace($pathdata['subdir'], $subdir, $pathdata['url']);
                    $pathdata['subdir'] = str_replace($pathdata['subdir'], $subdir, $pathdata['subdir']);
                    return $pathdata;
                }
                add_filter('upload_dir', 'company_logo_upload_dir');
                $time = current_time('mysql');
                $overrides = array('test_form' => false);
                $file = wp_handle_upload($_FILES['company-logo'], $overrides, $time);
                remove_filter('upload_dir', 'company_logo_upload_dir');
                if (!isset($file['error'])) {
                    $posted['company-logo'] = $file['url'];
                    $posted['company-logo-type'] = $file['type'];
                    $posted['company-logo-file'] = $file['file'];
                } else {
                    $errors->add('submit_error', __('<strong>ERROR</strong>: ', 'appthemes') . $file['error'] . '');
                }
            }
        }
        if ($errors && sizeof($errors) > 0 && $errors->get_error_code()) {
            // Do nothing - edit has failed
        } else {
            // Good to go, lets save this bad boy and show a confirmation message
            ### Approval needed?
            if ($job_details->post_status == 'publish') {
                $status = 'publish';
                if (get_option('jr_editing_needs_approval') == 'yes') {
                    // Post is made pending
                    $status = 'pending';
                }
            } else {
                $status = $job_details->post_status;
            }
            ### Update Post
            $data = array('ID' => $job_details->ID, 'post_content' => $wpdb->escape($posted['details']), 'post_title' => $wpdb->escape($posted['job_title']), 'post_status' => $status);
            wp_update_post($data);
            ### Update meta data and category
            update_post_meta($job_details->ID, '_Company', $posted['your_name']);
            update_post_meta($job_details->ID, '_CompanyURL', $posted['website']);
            update_post_meta($job_details->ID, '_how_to_apply', $posted['apply']);
            $post_into_cats = array();
            $post_into_types = array();
            if ($posted['job_term_cat'] > 0) {
                $post_into_cats[] = get_term_by('id', $posted['job_term_cat'], 'job_cat')->slug;
            }
            ### KEEP featured category if already featured
            global $featured_job_cat_id;
            $is_featured = false;
            $get_terms = wp_get_post_terms($job_details->ID, 'job_cat');
            foreach ($get_terms as $term) {
                if ($term->term_id == $featured_job_cat_id) {
                    $is_featured = true;
                }
            }
            if ($is_featured) {
                $featured_job_cat_name = get_term_by('id', $featured_job_cat_id, 'job_cat')->name;
                $post_into_cats[] = sanitize_title($featured_job_cat_name);
            }
            if (sizeof($post_into_cats) > 0) {
                wp_set_object_terms($job_details->ID, $post_into_cats, 'job_cat');
            }
            $post_into_types[] = get_term_by('slug', sanitize_title($posted['job_term_type']), 'job_type')->slug;
            if (sizeof($post_into_types) > 0) {
                wp_set_object_terms($job_details->ID, $post_into_types, 'job_type');
            }
            ### Salary
            $salary = array();
            if ($posted['job_term_salary'] > 0) {
                $salary[] = get_term_by('id', $posted['job_term_salary'], 'job_salary')->slug;
            }
            wp_set_object_terms($job_details->ID, $salary, 'job_salary');
            ### Tags
            if ($posted['tags']) {
                $thetags = explode(',', $posted['tags']);
                $thetags = array_map('trim', $thetags);
                $thetags = array_map('strtolower', $thetags);
                if (sizeof($thetags) > 0) {
                    wp_set_object_terms($job_details->ID, $thetags, 'job_tag');
                }
            }
            ### GEO
            if (!empty($posted['jr_address'])) {
                $latitude = jr_clean_coordinate($posted['jr_geo_latitude']);
                $longitude = jr_clean_coordinate($posted['jr_geo_longitude']);
                update_post_meta($job_details->ID, '_jr_geo_latitude', $latitude);
                update_post_meta($job_details->ID, '_jr_geo_longitude', $longitude);
                if ($latitude && $longitude) {
                    $address = jr_reverse_geocode($latitude, $longitude);
                    update_post_meta($job_details->ID, 'geo_address', $address['address']);
                    update_post_meta($job_details->ID, 'geo_country', $address['country']);
                    update_post_meta($job_details->ID, 'geo_short_address', $address['short_address']);
                    update_post_meta($job_details->ID, 'geo_short_address_country', $address['short_address_country']);
                }
            } else {
                // They left the field blank so we assume the job is for 'anywhere'
                delete_post_meta($job_details->ID, '_jr_geo_latitude');
                delete_post_meta($job_details->ID, '_jr_geo_longitude');
                delete_post_meta($job_details->ID, 'geo_address');
                delete_post_meta($job_details->ID, 'geo_country');
                delete_post_meta($job_details->ID, 'geo_short_address');
                delete_post_meta($job_details->ID, 'geo_short_address_country');
            }
            ## Link to company image
            if (isset($posted['company-logo']) && $posted['company-logo']) {
                $name_parts = pathinfo($posted['company-logo-name']);
                $name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
                $url = $posted['company-logo'];
                $type = $posted['company-logo-type'];
                $file = $posted['company-logo-file'];
                $title = $posted['company-logo-name'];
                $content = '';
                // use image exif/iptc data for title and caption defaults if possible
                if ($image_meta = @wp_read_image_metadata($file)) {
                    if (trim($image_meta['title'])) {
                        $title = $image_meta['title'];
                    }
                    if (trim($image_meta['caption'])) {
                        $content = $image_meta['caption'];
                    }
                }
                // Construct the attachment array
                $attachment = array_merge(array('post_mime_type' => $type, 'guid' => $url, 'post_parent' => $job_details->ID, 'post_title' => $title, 'post_content' => $content), array());
                // Save the data
                $id = wp_insert_attachment($attachment, $file, $job_details->ID);
                if (!is_wp_error($id)) {
                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
                }
                update_post_meta($job_details->ID, '_thumbnail_id', $id);
            }
            ### Inform admin
            if (get_option('jr_jobs_require_moderation') == 'yes') {
                jr_edited_job_pending($job_details->ID);
            }
            $args = array('message' => urlencode(__('Job edited successfully', 'appthemes')));
            redirect_myjobs($args);
        }
        // endif errors
    }
    $form_results = array('errors' => $errors, 'posted' => $posted);
    return $form_results;
}
コード例 #4
0
ファイル: preview-job-form.php プロジェクト: besimhu/legacy
/**
 * JobRoller Preview Job form
 * Function outputs the job preview form
 *
 *
 * @version 1.0
 * @author AppThemes
 * @package JobRoller
 * @copyright 2010 all rights reserved
 *
 */
function jr_preview_job_form()
{
    global $post, $posted;
    ?>
	<form action="<?php 
    echo get_permalink($post->ID);
    ?>
" method="post" enctype="multipart/form-data" id="submit_form" class="submit_form main_form">			
		<p><?php 
    _e('Below is a preview of what your job listing will look like when published:', 'appthemes');
    ?>
</p>				
		
		<ol class="jobs">
			<li class="job <?php 
    if ($alt == 1) {
        echo 'job-alt';
    }
    ?>
" style="padding-left:0; padding-right:0;"><dl>
				<dt><?php 
    _e('Type', 'appthemes');
    ?>
</dt>
				<dd class="type"><?php 
    $job_type = get_term_by('slug', sanitize_title($posted['job_term_type']), 'job_type');
    echo '<span class="' . $job_type->slug . '">' . wptexturize($job_type->name) . '</span>';
    ?>
&nbsp;</dd>
				<dt><?php 
    _e('Job', 'appthemes');
    ?>
</dt>
				<dd class="title"><strong><?php 
    echo $posted['job_title'];
    ?>
 </strong><?php 
    $author = get_user_by('id', get_current_user_id());
    if ($posted['your_name']) {
        echo $posted['your_name'];
        if ($author && ($link = get_author_posts_url($author->ID, $author->user_nicename))) {
            echo sprintf(__(' &ndash; Posted by <a href="%s">%s</a>', 'appthemes'), $link, $author->display_name);
        }
    } else {
        if ($author && ($link = get_author_posts_url($author->ID, $author->user_nicename))) {
            echo sprintf(__('<a href="%s">%s</a>', 'appthemes'), $link, $author->display_name);
        }
    }
    ?>
				</dd>
				<dt><?php 
    _e('_Location', 'appthemes');
    ?>
</dt>
				<dd class="location"><?php 
    $latitude = jr_clean_coordinate($posted['jr_geo_latitude']);
    $longitude = jr_clean_coordinate($posted['jr_geo_longitude']);
    if ($latitude && $longitude) {
        $address = jr_reverse_geocode($latitude, $longitude);
        echo '<strong>' . wptexturize($address['short_address']) . '</strong> ' . wptexturize($address['short_address_country']) . '';
    } else {
        echo '<strong>Anywhere</strong>';
    }
    ?>
</dd>
				<dt><?php 
    _e('Date Posted', 'appthemes');
    ?>
</dt>
				<dd class="date"><strong><?php 
    echo date_i18n(__('j M', 'appthemes'));
    ?>
</strong> <span class="year"><?php 
    echo date_i18n(__('Y', 'appthemes'));
    ?>
</span></dd>
			</dl></li>
		</ol>
		
		<p><?php 
    _e('The job listing&rsquo;s page will contain the following information:', 'appthemes');
    ?>
</p>
		
		<blockquote>
			<h2><?php 
    _e('Job description', 'appthemes');
    ?>
</h2>
			<?php 
    echo wpautop(wptexturize($posted['details']));
    ?>
			<?php 
    if (get_option('jr_submit_how_to_apply_display') == 'yes') {
        ?>
				<h2><?php 
        _e('How to apply', 'appthemes');
        ?>
</h2>
				<?php 
        echo wpautop(wptexturize($posted['apply']));
        ?>
			<?php 
    }
    ?>
		</blockquote>
		
		<?php 
    $packs = jr_get_job_packs();
    $user_packs = jr_get_user_job_packs();
    if (sizeof($packs) > 0 || sizeof($user_packs) > 0) {
        echo '<h2>' . __('Select a Job Pack:', 'appthemes') . '</h2>';
        echo '<ul class="packs">';
        $checked = 'checked="checked"';
        if (sizeof($user_packs) > 0) {
            foreach ($user_packs as $pack) {
                $choose_or_use = __('Choose this pack', 'appthemes');
                if (!$pack->jobs_limit) {
                    $pack->jobs_count = __('Unlimited', 'appthemes') . ' ' . __('Jobs remaining', 'appthemes');
                } else {
                    $pack->jobs_count = $pack->jobs_limit - $pack->jobs_count;
                    if ($pack->jobs_count == 1) {
                        $pack->jobs_count = $pack->jobs_count . ' ' . __('Job remaining', 'appthemes');
                    } else {
                        $pack->jobs_count = $pack->jobs_count . ' ' . __('Jobs remaining', 'appthemes');
                    }
                }
                if ($pack->pack_expires) {
                    $pack->pack_expires = __('Usable before ', 'appthemes') . mysql2date(get_option('date_format'), $pack->pack_expires);
                }
                if ($pack->job_duration) {
                    $pack->job_duration = __(' lasting ', 'appthemes') . $pack->job_duration . __(' days', 'appthemes');
                }
                echo '<li><span class="cost">' . __('Purchased', 'appthemes') . '</span><h3>' . $pack->pack_name . '</h3>
						<p>' . $pack->jobs_count . '' . $pack->job_duration . '. ' . $pack->pack_expires . '.</p>
						<div><label>' . $choose_or_use . ': <input type="radio" name="job_pack" value="user_' . $pack->id . '" ' . $checked . ' /></label></div>
					</li>';
                $checked = '';
            }
        }
        if (sizeof($packs) > 0) {
            foreach ($packs as $pack) {
                $choose_or_use = '';
                if (!$pack->job_count) {
                    $pack->job_count = __('Unlimited', 'appthemes');
                }
                if ($pack->pack_duration) {
                    $pack->pack_duration = __(' usable within ', 'appthemes') . $pack->pack_duration . __(' days', 'appthemes');
                }
                if ($pack->job_duration) {
                    $pack->job_duration = __(' lasting ', 'appthemes') . $pack->job_duration . __(' days', 'appthemes');
                }
                if ($pack->pack_cost) {
                    $pack->pack_cost = jr_get_currency($pack->pack_cost) . '';
                    $choose_or_use = __('Buy this pack', 'appthemes');
                } else {
                    $pack->pack_cost = __('Free', 'appthemes');
                    $choose_or_use = __('Choose this pack', 'appthemes');
                }
                echo '<li><span class="cost">' . $pack->pack_cost . '</span><h3>' . $pack->pack_name . ' &ndash; <small>' . $pack->pack_description . '</small></h3>
						<p>' . $pack->job_count . ' ' . __('Jobs', 'appthemes') . '' . $pack->job_duration . $pack->pack_duration . '.</p>
						<div><label>' . $choose_or_use . ': <input type="radio" name="job_pack" value="' . $pack->id . '" ' . $checked . ' /></label></div>
					</li>';
                $checked = '';
            }
        }
        echo '</ul>';
    }
    ?>

		<?php 
    $featured_cost = get_option('jr_cost_to_feature');
    if ($featured_cost && is_numeric($featured_cost) && $featured_cost > 0) {
        // Featuring is an option
        echo '<h2>' . __('Feature your listing for ', 'appthemes') . jr_get_currency($featured_cost) . __('?', 'appthemes') . '</h2>';
        echo '<p>' . __('Featured listings are displayed on the homepage and are also highlighted in all other listing pages.', 'appthemes') . '</p>';
        echo '<p><input type="checkbox" name="featureit" id="featureit" /> <label for="featureit" style="float:none">' . __('Yes please, feature my listing.', 'appthemes') . '</label></p>';
    }
    ?>
		
		<p>
            <input type="submit" name="goback" class="goback" value="<?php 
    _e('Go Back', 'appthemes');
    ?>
"  /> 
            <input type="submit" class="submit" name="preview_submit" value="<?php 
    _e('Next &rarr;', 'appthemes');
    ?>
" />
            <input type="hidden" value='<?php 
    echo htmlentities(json_encode($posted), ENT_QUOTES);
    ?>
' name="posted" />
        </p>
		
		<div class="clear"></div>
	</form>
	<?php 
}
コード例 #5
0
/**
 * JobRoller Submit Resume Process
 * Processes a job submission.
 *
 *
 * @version 1.4
 * @author AppThemes
 * @package JobRoller
 * @copyright 2010 all rights reserved
 *
 */
function jr_process_submit_resume_form($resume_id = 0)
{
    global $post, $posted;
    $errors = new WP_Error();
    if (isset($_POST['save_resume']) && $_POST['save_resume']) {
        // Get (and clean) data
        $fields = array('resume_name', 'summary', 'skills', 'specialities', 'groups', 'languages', 'desired_salary', 'desired_position', 'resume_cat', 'mobile', 'tel', 'email_address', 'education', 'experience', 'jr_geo_latitude', 'jr_geo_longitude', 'jr_address');
        $posted = stripslashes_deep(wp_array_slice_assoc($_POST, $fields));
        $sanitizer = get_option('jr_html_allowed') == 'no' ? 'strip_tags' : 'wp_kses_post';
        foreach ($posted as $key => &$value) {
            if (in_array($key, array('summary', 'education', 'experience'))) {
                $value = $sanitizer($value);
            } else {
                $value = strip_tags($value);
            }
        }
        // Check required fields
        $required = array('resume_name' => __('Resume name', 'appthemes'), 'summary' => __('Summary', 'appthemes'), 'jr_geo_latitude' => __('Location', 'appthemes'), 'jr_geo_longitude' => __('Location', 'appthemes'));
        foreach ($required as $field => $name) {
            if (empty($posted[$field])) {
                $errors->add('submit_error', __('<strong>ERROR</strong>: &ldquo;', 'appthemes') . $name . __('&rdquo; is a required field.', 'appthemes'));
            }
        }
        if ($errors && sizeof($errors) > 0 && $errors->get_error_code()) {
        } else {
            if (isset($_FILES['your-photo']) && !empty($_FILES['your-photo']['name'])) {
                $posted['your-photo-name'] = $_FILES['your-photo']['name'];
                // Check valid extension
                $allowed = array('png', 'gif', 'jpg', 'jpeg');
                $extension = strtolower(pathinfo($_FILES['your-photo']['name'], PATHINFO_EXTENSION));
                if (!in_array($extension, $allowed)) {
                    $errors->add('submit_error', __('<strong>ERROR</strong>: Only jpg, gif, and png images are allowed.', 'appthemes'));
                } else {
                    /** WordPress Administration File API */
                    include_once ABSPATH . 'wp-admin/includes/file.php';
                    /** WordPress Media Administration API */
                    include_once ABSPATH . 'wp-admin/includes/media.php';
                    function resume_photo_upload_dir($pathdata)
                    {
                        $subdir = '/resume_photos' . $pathdata['subdir'];
                        $pathdata['path'] = str_replace($pathdata['subdir'], $subdir, $pathdata['path']);
                        $pathdata['url'] = str_replace($pathdata['subdir'], $subdir, $pathdata['url']);
                        $pathdata['subdir'] = str_replace($pathdata['subdir'], $subdir, $pathdata['subdir']);
                        return $pathdata;
                    }
                    add_filter('upload_dir', 'resume_photo_upload_dir');
                    $time = current_time('mysql');
                    $overrides = array('test_form' => false);
                    $file = wp_handle_upload($_FILES['your-photo'], $overrides, $time);
                    remove_filter('upload_dir', 'resume_photo_upload_dir');
                    if (!isset($file['error'])) {
                        $posted['your-photo'] = $file['url'];
                        $posted['your-photo-type'] = $file['type'];
                        $posted['your-photo-file'] = $file['file'];
                    } else {
                        $errors->add('submit_error', __('<strong>ERROR</strong>: ', 'appthemes') . $file['error'] . '');
                    }
                }
            }
        }
        if ($errors && sizeof($errors) > 0 && $errors->get_error_code()) {
        } else {
            // No errors? Create the resume post
            global $wpdb;
            if ($resume_id > 0) {
                $data = array('ID' => $resume_id, 'post_content' => $wpdb->escape($posted['summary']), 'post_title' => $wpdb->escape($posted['resume_name']));
                wp_update_post($data);
            } else {
                $data = array('post_content' => $wpdb->escape($posted['summary']), 'post_title' => $wpdb->escape($posted['resume_name']), 'post_status' => 'private', 'post_author' => get_current_user_id(), 'post_type' => 'resume', 'post_name' => get_current_user_id() . uniqid(rand(10, 1000), false));
                $resume_id = wp_insert_post($data);
                if ($resume_id == 0 || is_wp_error($resume_id)) {
                    wp_die(__('Error: Unable to create entry.', 'appthemes'));
                }
            }
            ### Add meta data
            update_post_meta($resume_id, '_skills', $posted['skills']);
            update_post_meta($resume_id, '_desired_salary', $posted['desired_salary']);
            update_post_meta($resume_id, '_mobile', $posted['mobile']);
            update_post_meta($resume_id, '_tel', $posted['tel']);
            update_post_meta($resume_id, '_email_address', $posted['email_address']);
            update_post_meta($resume_id, '_education', $posted['education']);
            update_post_meta($resume_id, '_experience', $posted['experience']);
            ## Desired position
            $post_into_types[] = get_term_by('slug', sanitize_title($posted['desired_position']), 'resume_job_type')->slug;
            if (sizeof($post_into_types) > 0) {
                wp_set_object_terms($resume_id, $post_into_types, 'resume_job_type');
            }
            ### Category
            $post_into_cats = array();
            if ($posted['resume_cat'] > 0) {
                $post_into_cats[] = get_term_by('id', $posted['resume_cat'], 'resume_category')->slug;
            }
            if (sizeof($post_into_cats) > 0) {
                wp_set_object_terms($resume_id, $post_into_cats, 'resume_category');
            }
            ### Tags
            if ($posted['specialities']) {
                $thetags = explode(',', $posted['specialities']);
                $thetags = array_map('trim', $thetags);
                if (sizeof($thetags) > 0) {
                    wp_set_object_terms($resume_id, $thetags, 'resume_specialities');
                }
            }
            if ($posted['groups']) {
                $thetags = explode(',', $posted['groups']);
                $thetags = array_map('trim', $thetags);
                if (sizeof($thetags) > 0) {
                    wp_set_object_terms($resume_id, $thetags, 'resume_groups');
                }
            }
            if ($posted['languages']) {
                $thetags = explode(',', $posted['languages']);
                $thetags = array_map('trim', $thetags);
                if (sizeof($thetags) > 0) {
                    wp_set_object_terms($resume_id, $thetags, 'resume_languages');
                }
            }
            ### GEO
            if (!empty($posted['jr_address'])) {
                $latitude = jr_clean_coordinate($posted['jr_geo_latitude']);
                $longitude = jr_clean_coordinate($posted['jr_geo_longitude']);
                update_post_meta($resume_id, '_jr_geo_latitude', $posted['jr_geo_latitude'], true);
                update_post_meta($resume_id, '_jr_geo_longitude', $posted['jr_geo_longitude'], true);
                if ($latitude && $longitude) {
                    $address = jr_reverse_geocode($latitude, $longitude);
                    update_post_meta($resume_id, 'geo_address', $address['address'], true);
                    update_post_meta($resume_id, 'geo_country', $address['country'], true);
                    update_post_meta($resume_id, 'geo_short_address', $address['short_address'], true);
                    update_post_meta($resume_id, 'geo_short_address_country', $address['short_address_country'], true);
                }
            }
            ## Load APIs and Link to photo
            include_once ABSPATH . 'wp-admin/includes/file.php';
            include_once ABSPATH . 'wp-admin/includes/image.php';
            include_once ABSPATH . 'wp-admin/includes/media.php';
            $name_parts = pathinfo($posted['your-photo-name']);
            $name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
            $url = $posted['your-photo'];
            $type = $posted['your-photo-type'];
            $file = $posted['your-photo-file'];
            $title = $posted['your-photo-name'];
            $content = '';
            if ($file) {
                // use image exif/iptc data for title and caption defaults if possible
                if ($image_meta = @wp_read_image_metadata($file)) {
                    if (trim($image_meta['title'])) {
                        $title = $image_meta['title'];
                    }
                    if (trim($image_meta['caption'])) {
                        $content = $image_meta['caption'];
                    }
                }
                // Construct the attachment array
                $attachment = array_merge(array('post_mime_type' => $type, 'guid' => $url, 'post_parent' => $resume_id, 'post_title' => $title, 'post_content' => $content), array());
                // Save the data
                $id = wp_insert_attachment($attachment, $file, $resume_id);
                if (!is_wp_error($id)) {
                    wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
                }
                update_post_meta($resume_id, '_thumbnail_id', $id);
            }
            // Redirect to Resume
            $url = get_permalink($resume_id);
            if (!$url) {
                $url = get_permalink(get_option('jr_user_profile_page_id'));
            }
            wp_redirect($url);
            exit;
        }
    }
    $submit_form_results = array('errors' => $errors, 'posted' => $posted);
    return $submit_form_results;
}
コード例 #6
0
/**
 * JobRoller Confirm Job Process
 * Once a job has been confirmed, this takes the posted data and adds it to WordPress.
 *
 *
 * @version 1.3
 * @author AppThemes
 * @package JobRoller
 * @copyright 2010 all rights reserved
 *
 */
function jr_process_confirm_job_form()
{
    global $user_ID, $post, $posted, $wpdb, $jr_log;
    $posted = json_decode(stripslashes($_POST['posted']), true);
    // Calc costs/get packs
    $cost = 0;
    $job_pack = '';
    $user_pack = '';
    $jobs_last = null;
    // Get Pack from previous step
    if (isset($posted['job_pack']) && !empty($posted['job_pack'])) {
        if (strstr($posted['job_pack'], 'user_')) {
            $user_pack_id = (int) str_replace('user_', '', $posted['job_pack']);
            $user_pack = new jr_user_pack($user_pack_id);
            if (!$user_pack->get_valid_pack()) {
                wp_die(__('Error: Invalid Pack.', 'appthemes'));
            }
            $jobs_last = $user_pack->job_duration;
        } else {
            $job_pack = new jr_pack($posted['job_pack']);
            $cost += $job_pack->pack_cost;
            $jobs_last = $job_pack->job_duration;
        }
    } else {
        // No Packs
        $listing_cost = get_option('jr_jobs_listing_cost');
        $cost += $listing_cost;
    }
    // Caculate expirey date from today
    if (!isset($jobs_last)) {
        $jobs_last = get_option('jr_jobs_default_expires');
    }
    // 30 day default
    $date = strtotime('+' . $jobs_last . ' day', current_time('timestamp'));
    // Get Featured from previous step
    if ($posted['featureit'] == 'yes') {
        $featured_cost = get_option('jr_cost_to_feature');
        $cost += $featured_cost;
    }
    ### Validate required again - just in case
    $required = array('job_title' => __('Job title', 'appthemes'), 'job_term_type' => __('Job type', 'appthemes'), 'details' => __('Job description', 'appthemes'));
    foreach ($required as $field => $name) {
        if (empty($posted[$field])) {
            wp_die(__('Error: Unable to create entry.', 'appthemes'));
        }
    }
    ### Approval needed?
    $status = 'publish';
    if ($cost > 0) {
        $status = 'pending';
    } else {
        // Free listing
        if (get_option('jr_jobs_require_moderation') == 'yes') {
            $status = 'pending';
        }
    }
    if ($user_pack) {
        $status = 'publish';
    }
    ### Create Post
    $data = array('post_content' => $wpdb->escape($posted['details']), 'post_title' => $wpdb->escape(strip_tags($posted['job_title'])), 'post_status' => $status, 'post_author' => $user_ID, 'post_type' => 'job_listing');
    jr_before_insert_job($data);
    // do_action hook
    $post_id = wp_insert_post($data);
    jr_after_insert_job($post_id);
    // do_action hook
    // Was the post created?
    if ($post_id == 0 || is_wp_error($post_id)) {
        wp_die(__('Error: Unable to create entry.', 'appthemes'));
    }
    ### Add meta data and category
    add_post_meta($post_id, '_Company', strip_tags($posted['your_name']), true);
    add_post_meta($post_id, '_CompanyURL', $posted['website'], true);
    add_post_meta($post_id, '_how_to_apply', $posted['apply'], true);
    add_post_meta($post_id, 'user_IP', jr_getIP(), true);
    add_post_meta($post_id, '_expires', $date);
    ### GEO
    if (!empty($posted['jr_address'])) {
        $latitude = jr_clean_coordinate($posted['jr_geo_latitude']);
        $longitude = jr_clean_coordinate($posted['jr_geo_longitude']);
        add_post_meta($post_id, '_jr_geo_latitude', $posted['jr_geo_latitude'], true);
        add_post_meta($post_id, '_jr_geo_longitude', $posted['jr_geo_longitude'], true);
        if ($latitude && $longitude) {
            // If we don't have address data, do a look-up
            if ($posted['jr_geo_short_address'] && $posted['jr_geo_country'] && $posted['jr_geo_short_address'] && $posted['jr_geo_short_address_country']) {
                add_post_meta($post_id, 'geo_address', $posted['jr_geo_short_address'], true);
                add_post_meta($post_id, 'geo_country', $posted['jr_geo_country'], true);
                add_post_meta($post_id, 'geo_short_address', $posted['jr_geo_short_address'], true);
                add_post_meta($post_id, 'geo_short_address_country', $posted['jr_geo_short_address_country'], true);
            } else {
                $address = jr_reverse_geocode($latitude, $longitude);
                add_post_meta($post_id, 'geo_address', $address['address'], true);
                add_post_meta($post_id, 'geo_country', $address['country'], true);
                add_post_meta($post_id, 'geo_short_address', $address['short_address'], true);
                add_post_meta($post_id, 'geo_short_address_country', $address['short_address_country'], true);
            }
        }
    } else {
        // They left the field blank so we assume the job is for 'anywhere'
    }
    ### Set terms
    $post_into_cats = array();
    $post_into_types = array();
    if ($posted['job_term_cat'] > 0) {
        $post_into_cats[] = get_term_by('id', $posted['job_term_cat'], 'job_cat')->slug;
    }
    if ($featured_cost && is_numeric($featured_cost) && $featured_cost > 0 && $posted['featureit'] == 'yes') {
        global $featured_job_cat_id;
        $featured_job_cat_name = get_term_by('id', $featured_job_cat_id, 'job_cat')->name;
        $post_into_cats[] = sanitize_title($featured_job_cat_name);
    }
    if (sizeof($post_into_cats) > 0) {
        wp_set_object_terms($post_id, $post_into_cats, 'job_cat');
    }
    $post_into_types[] = get_term_by('slug', sanitize_title($posted['job_term_type']), 'job_type')->slug;
    if (sizeof($post_into_types) > 0) {
        wp_set_object_terms($post_id, $post_into_types, 'job_type');
    }
    ### Salary
    $salary = array();
    if ($posted['job_term_salary'] > 0) {
        $salary[] = get_term_by('id', $posted['job_term_salary'], 'job_salary')->slug;
    }
    if (sizeof($salary) > 0) {
        wp_set_object_terms($post_id, $salary, 'job_salary');
    }
    ### Tags
    if ($posted['tags']) {
        $thetags = explode(',', $posted['tags']);
        $thetags = array_map('trim', $thetags);
        $thetags = array_map('strtolower', $thetags);
        if (sizeof($thetags) > 0) {
            wp_set_object_terms($post_id, $thetags, 'job_tag');
        }
    }
    ## Load APIs and Link to company image
    include_once ABSPATH . 'wp-admin/includes/file.php';
    include_once ABSPATH . 'wp-admin/includes/image.php';
    include_once ABSPATH . 'wp-admin/includes/media.php';
    $name_parts = pathinfo($posted['company-logo-name']);
    $name = trim(substr($name, 0, -(1 + strlen($name_parts['extension']))));
    $url = $posted['company-logo'];
    $type = $posted['company-logo-type'];
    $file = $posted['company-logo-file'];
    $title = $posted['company-logo-name'];
    $content = '';
    if ($file) {
        // use image exif/iptc data for title and caption defaults if possible
        if ($image_meta = @wp_read_image_metadata($file)) {
            if (trim($image_meta['title'])) {
                $title = $image_meta['title'];
            }
            if (trim($image_meta['caption'])) {
                $content = $image_meta['caption'];
            }
        }
        // Construct the attachment array
        $attachment = array_merge(array('post_mime_type' => $type, 'guid' => $url, 'post_parent' => $post_id, 'post_title' => $title, 'post_content' => $content), array());
        // Save the data
        $id = wp_insert_attachment($attachment, $file, $post_id);
        if (!is_wp_error($id)) {
            wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file));
        }
        update_post_meta($post_id, '_thumbnail_id', $id);
    }
    ### If paying with user pack, update the customers pack totals
    if ($user_pack) {
        $inspack = '';
        $user_pack->inc_job_count();
    } elseif (!empty($posted['job_pack'])) {
        $inspack = $posted['job_pack'];
    }
    if ($posted['featureit'] == 'yes') {
        $insfeatured = 1;
    }
    ### Create the order in the database so it can be confirmed by user/IPN before going live
    if ($cost > 0) {
        $jr_order = new jr_order(0, $user_ID, $cost, $post_id, $inspack, $insfeatured);
        $jr_order->insert_order();
        ### Redirect to paypal payment page	(if paid listing)
        $name = urlencode(__('Job Listing ', 'appthemes') . $posted['job_title'] . __(' with Job Pack ', 'appthemes') . $job_pack->pack_name);
        $link = $jr_order->generate_paypal_link($name);
        $jr_log->write_log('Sending user (#' . $user_ID . ') to paypal after job submission (' . $posted['job_title'] . ' - order#' . $jr_order->id . ').');
        header('Location: ' . $link);
        exit;
    } else {
        ### FREE LISTING / LISTING PAID WITH USER PACK (no additional cost)
        if (get_option('jr_jobs_require_moderation') == 'yes') {
            if (get_option('jr_new_ad_email') !== 'no') {
                jr_admin_new_job_pending($post_id);
            }
            jr_owner_new_job_pending($post_id);
        } elseif (get_option('jr_new_ad_email') !== 'no') {
            jr_admin_new_job($post_id);
        }
        redirect_myjobs();
    }
}