Viewing 3 replies - 1 through 3 (of 3 total)
  • i have add a filter in application listing so this is my admin-applications.php, hope this is help you :

    <?php
    function jobman_list_applications() {
    global $wpdb;
    $options = get_option( ‘jobman_options’ );

    $deleted = false;
    $emailed = false;
    if(array_key_exists( ‘jobman-mass-edit’, $_REQUEST ) && ‘delete’ == $_REQUEST[‘jobman-mass-edit’] ) {
    if( array_key_exists( ‘jobman-delete-confirmed’, $_REQUEST ) ) {
    check_admin_referer( ‘jobman-mass-delete-applications’ );
    jobman_application_delete();
    $deleted = true;
    }
    else {
    check_admin_referer( ‘jobman-mass-edit-applications’ );
    jobman_application_delete_confirm();
    return;
    }
    }
    else if( array_key_exists( ‘jobman-mass-edit’, $_REQUEST ) && ’email’ == $_REQUEST[‘jobman-mass-edit’] ) {
    check_admin_referer( ‘jobman-mass-edit-applications’ );
    jobman_application_mailout();
    return;
    }
    else if(array_key_exists( ‘appid’, $_REQUEST ) ) {
    jobman_application_details_layout( $_REQUEST[‘appid’] );
    return;
    }
    else if( array_key_exists( ‘jobman-mailout-send’, $_REQUEST ) ) {
    check_admin_referer( ‘jobman-mailout-send’ );
    jobman_application_mailout_send();
    $emailed = true;
    }
    ?>
    <div class=”wrap”>
    <h2><?php _e( ‘Job Manager: Applications’, ‘jobman’ ) ?></h2>
    <?php
    if( $deleted )
    echo ‘<p class=”error”>’ . __( ‘Selected applications have been deleted.’, ‘jobman’ ) . ‘</p>’;
    if( $emailed )
    echo ‘<p class=”error”>’ . __( ‘The mailout has been sent.’, ‘jobman’ ) . ‘</p>’;

    $fields = $options[‘fields’];

    $categories = get_terms( ‘jobman_category’, ‘hide_empty=0’ );
    ?>
    <div id=”filter_application”>
    <form action=”” method=”post”>
    <div id=”job_filter”>
    <?php _e( ‘Job ID’, ‘jobman’ ) ?>:
    <input type=”text” name=”jobman-jobid” value=”<?php echo ( array_key_exists( ‘jobman-jobid’, $_REQUEST ) )?( $_REQUEST[‘jobman-jobid’] ):( ” ) ?>” />
    </div>
    <div id=”categories_filter”>
    <?php
    if( count( $categories ) > 0 ) {
    $ii = 0;
    foreach( $categories as $cat ) {
    $checked = ”;
    if( array_key_exists( ‘jobman-categories’, $_REQUEST ) && is_array( $_REQUEST[‘jobman-categories’] ) && in_array( $cat->term_id, $_REQUEST[‘jobman-categories’] ) )
    $checked = ‘ checked=”checked”‘;
    ?>
    <input type=”checkbox” name=”jobman-categories[]” value=”<?php echo $cat->term_id ?>”<?php echo $checked ?> /> <?php echo $cat->name ?>
    <?php
    }
    }
    ?>
    </div>
    <?php
    if( count( $fields ) > 0 ) {
    uasort( $fields, ‘jobman_sort_fields’ );

    foreach( $fields as $id => $field ) {
    if( ! $field[‘listdisplay’] )
    continue;

    $req_value = ”;
    if( array_key_exists( “jobman-field-$id”, $_REQUEST ) )
    $req_value = $_REQUEST[“jobman-field-$id”];
    switch( $field[‘type’] ) {
    case ‘text’:
    case ‘textarea’:
    echo “<div id=’text_filter’>”;
    if ($id == ‘2’){ echo “| Name: <input type=’text’ name=’jobman-field-$id’ value=’$req_value’ />”;
    }
    if ($id == ‘3’){ echo “Surname: <input type=’text’ name=’jobman-field-$id’ value=’$req_value’ />”;
    }
    //echo “<input type=’text’ name=’jobman-field-$id’ value=’$req_value’ />”;
    echo “</div>”;
    break;
    case ‘date’:
    echo “<input type=’text’ class=’datepicker’ name=’jobman-field-$id’ value=’$req_value’ />”;
    break;
    case ‘radio’:
    case ‘checkbox’:

    // —> test du drop down pour les filtes
    case ‘select’:
    echo ‘<div id=”select_filter”><select name=jobman-field-20[]>’;
    $values = split( “\n”, $field[‘data’] );

    foreach( $values as $value ) {
    $checked = ”;
    if( is_array( $req_value ) && in_array( trim( $value ), $req_value ) )
    $checked = ‘ selected’;
    echo “<option value='”.trim( $value ).”‘”.$checked.”>”.trim( $value ).”</option>”;
    }
    //echo ‘<option value=”fran?aise”>fran?aise</option></select></td>’;
    echo “</div>”;
    break;

    default:
    echo __( ‘This field cannot be filtered.’, ‘jobman’ );
    }
    }
    }
    ?>

    <div style=”float:left;”><input type=”submit” name=”submit” class=”button-primary” value=”<?php _e( ‘Filter Applications’, ‘jobman’ ) ?>” /></div>

    </form>
    </div>
    <form action=”” method=”post”>
    <?php
    wp_nonce_field( ‘jobman-mass-edit-applications’ );
    ?>
    <div style=”margin-top:70px;”></div>
    <table id=”jobman-applications-list” class=”widefat page fixed” cellspacing=”0″>
    <thead>
    <tr>
    <th scope=”col” id=”cb” class=”column-cb check-column”><input type=”checkbox”></th>
    <th scope=”col”><?php _e( ‘Application’, ‘jobman’ ) ?></th>
    <?php
    if( count( $fields ) > 0 ) {
    foreach( $fields as $field ) {
    if( $field[‘listdisplay’] ) {
    ?>
    <th scope=”col”><?php echo $field[‘label’] ?></th>
    <?php
    }
    }
    }
    ?>
    <th scope=”col”><?php _e( ‘Information’, ‘jobman’ ) ?></th>
    </tr>
    </thead>

    <tfoot>
    <tr>
    <th scope=”col” class=”column-cb check-column”><input type=”checkbox”></th>
    <th scope=”col”><?php _e( ‘Application’, ‘jobman’ ) ?></th>
    <?php
    if( count( $fields ) > 0 ) {
    foreach( $fields as $field ) {
    if( $field[‘listdisplay’] ) {
    ?>
    <th scope=”col”><?php echo $field[‘label’] ?></th>
    <?php
    }
    }
    }
    ?>
    <th scope=”col”><?php _e( ‘Information’, ‘jobman’ ) ?></th>
    </tr>
    </tfoot>
    <?php
    $args = array();
    $args[‘post_type’] = ‘jobman_app’;
    $args[‘post_status’] = ‘private,publish’;
    $args[‘offset’] = 0;
    $args[‘numberposts’] = -1;

    $filtered = false;

    // Add applicant filter
    if( array_key_exists( ‘jobman-applicant’, $_REQUEST ) )
    $args[‘author_name’] = $_REQUEST[‘jobman-applicant’];

    // Add category filter
    // Removed this until WP_Query supports *__in for custom taxonomy.
    /*if( array_key_exists( ‘jobman-categories’, $_REQUEST ) && is_array( $_REQUEST[‘jobman-categories’] ) ) {
    $filtered = true;
    $args[‘jcat__in’] = array();
    foreach( $_REQUEST[‘jobman-categories’] as $cat ) {
    $args[‘jcat__in’][] = $cat;
    }
    }*/

    $applications = get_posts( $args );
    echo ‘Total of applications : ‘.count( $applications );
    $app_displayed = false;
    if( count( $applications ) > 0 ) {
    foreach( $applications as $app ) {
    // Filter jobs
    if( array_key_exists( ‘jobman-jobid’, $_REQUEST ) && ! empty ( $_REQUEST[‘jobman-jobid’] ) ) {
    $jobs = get_post_meta( $app->ID, ‘job’, false );

    if( empty( $jobs ) || ! in_array( $_REQUEST[‘jobman-jobid’], $jobs ) )
    continue;
    }

    $appmeta = get_post_custom( $app->ID );

    $appdata = array();
    foreach( $appmeta as $key => $value ) {
    if( is_array( $value ) )
    $appdata[$key] = $value[0];
    else
    $appdata[$key] = $value;
    }

    if( array_key_exists( ‘jobman-rating’, $_REQUEST ) && is_numeric( $_REQUEST[‘jobman-rating’] ) && $_REQUEST[‘jobman-rating’] > 0 ) {
    if( array_key_exists( ‘rating’, $appdata ) && $appdata[‘rating’] < $_REQUEST[‘jobman-rating’] ) {
    // App is underrated. Skip it.
    continue;
    }
    }

    // Workaround for WP_Query not supporting *__in for custom taxonomy.
    if( array_key_exists( ‘jobman-categories’, $_REQUEST ) && is_array( $_REQUEST[‘jobman-categories’] ) ) {
    $cats = wp_get_object_terms( $app->ID, ‘jobman_category’ );
    if( count( $cats ) > 0 ) {
    $found = false;
    foreach( $cats as $cat ) {
    if( in_array( $cat->term_id, $_REQUEST[‘jobman-categories’] ) ) {
    // $app is in the list of selected categories. Let it through.
    $found = true;
    break;
    }
    }

    // $app wasn’t in the categories. Skip it.
    if( ! $found ) {
    $filtered = true;
    continue;
    }
    }
    else {
    // $app has no categories. Skip it.
    $filtered = true;
    continue;
    }
    }

    // Check against field filters
    if( count( $fields ) > 0 ) {
    foreach( $fields as $id => $field ) {
    if( ! array_key_exists( “jobman-field-$id”, $_REQUEST ) || ” == $_REQUEST[“jobman-field-$id”] )
    continue;
    if( ! array_key_exists( “data$id”, $appdata ) ) {
    // No data for this key application, so it can’t match. Go to next $app.
    $filtered = true;
    continue 2;
    }
    switch( $field[‘type’] ) {
    case ‘text’:
    case ‘textarea’:
    case ‘date’:
    if( $appdata[“data$id”] != $_REQUEST[“jobman-field-$id”] ) {
    // App doesn’t match. Go to the next item in the $applications loop.
    $filtered = true;
    continue 3;
    }
    break;
    case ‘radio’:
    case ‘checkbox’:
    case ‘select’:
    if( is_array( $_REQUEST[“jobman-field-$id”] ) ) {
    $data = split( ‘,’, $appdata[“data$id”] );
    //echo $selected;
    foreach( $_REQUEST[“jobman-field-$id”] as $selected ) {

    if ($selected == “Select a nationality”)
    // Si Select est sélectionné par défaut on ignore le filtre
    continue 2;

    if( in_array( trim( $selected ), $data ) )
    // We have a match. Go to the next item in the $fields loop.
    continue 3;
    }
    // There was no match. Go to next in $applications loop.
    $filtered = true;
    continue 3;
    }
    break;
    case ‘geoloc’:
    if( empty( $_REQUEST[“jobman-field2-$id”] ) || ! is_numeric( $_REQUEST[“jobman-field2-$id”] ) )
    // No value or bad value entered for distance
    continue 2;

    $url = ‘https://maps.google.com/maps/geo?output=xml&key=&#8217; . $options[‘api_keys’][‘google_maps’];
    $searchurl = “$url&q=” . urlencode( $_REQUEST[“jobman-field-$id”] );

    if( ! $xml = simplexml_load_file( $searchurl ) )
    // Something broken with XML load
    continue 2;
    $status = $xml->Response->Status->code;
    if (strcmp($status, “200”) == 0) {
    $coordinates = $xml->Response->Placemark->Point->coordinates;
    $coordinatesSplit = split(“,”, $coordinates);

    $search_lat = $coordinatesSplit[1];
    $search_lng = $coordinatesSplit[0];

    $data = $appdata[“data$id”];
    if( ! preg_match( ‘/^[0-9.]+,[0-9.]+$/’, $data ) ) {
    // Data not stored as lat,long. Ask Google.
    $searchurl = “$url&q=” . urlencode( $data );
    if( ! $xml = simplexml_load_file( $searchurl ) )
    // Something broken with XML load
    continue 2;

    $status = $xml->Response->Status->code;
    if (strcmp($status, “200”) == 0) {
    $coordinates = $xml->Response->Placemark->Point->coordinates;
    $coordinatesSplit = split(“,”, $coordinates);

    $data_lat = $coordinatesSplit[1];
    $data_lng = $coordinatesSplit[0];
    }
    else {
    // Geocode failed
    continue 2;
    }
    }
    else {
    list( $data_lat, $data_lng ) = split( ‘,’, $data );
    }

    // Calculate distance between locations
    $distance = sin( deg2rad( $data_lat ) ) * sin( deg2rad( $search_lat ) ) +
    cos( deg2rad( $data_lat ) ) * cos( deg2rad( $search_lat ) ) * cos( deg2rad( $data_lng – $search_lng ) );

    $distance = rad2deg( acos( $distance ) ) * 69.09 * 1.609344;

    if( $distance > $_REQUEST[“jobman-field2-$id”] )
    // Too far away. Move to the next $app
    continue 3;
    }
    else {
    // Geocode failed
    continue 2;
    }
    }
    }
    }
    $app_displayed = true;

    $fromid = $options[‘application_email_from’];
    $email = $appdata[“data$fromid”];
    $grav_url = ‘https://www.gravatar.com/avatar/&#8217; . md5( strtolower( $email ) ) . ‘?size=45’;

    $parents = get_post_meta( $app->ID, ‘job’, false );
    $jobstr = ”;
    if( ! empty( $parents ) ) {
    $parentstr = array();
    foreach( $parents as $parent ) {
    $data = get_post( $parent );
    $parentstr[] = “ID’>$data->ID – $data->post_title“;
    }

    $jobstr = implode( ‘, ‘, $parentstr );
    }
    else {
    $jobstr = __( ‘No job’, ‘jobman’ );
    }

    $cats = wp_get_object_terms( $app->ID, ‘jobman_category’ );
    $cats_arr = array();
    if( count( $cats ) > 0 ) {
    foreach( $cats as $cat ) {
    $cats_arr[] = $cat->name;
    }
    }

    $cats_str = ”;
    if( !empty( $cats_arr ) )
    $cats_str = implode( ‘, ‘, $cats_arr ) . ‘
    ‘;

    $name = ”;
    if( $options[‘user_registration’] ) {
    if( 0 == $app->post_author ) {
    $name = __( ‘Unregistered Applicant’, ‘jobman’ );
    }
    else {
    $author = get_userdata( $app->post_author );
    $name = __( ‘User’, ‘jobman’ ) . “: $author->display_name”;
    }
    $name .= ‘
    ‘;
    }
    ?>
    <tr>
    <th scope=”row” class=”check-column”><input type=”checkbox” name=”application[]” value=”<?php echo $app->ID ?>” /></th>
    <td>
    <!–<img src=”<?php echo $grav_url; ?>” alt=”” class=”jobman-gravatar-list” /> –>
    <?php echo $jobstr ?>
    <?php echo $cats_str ?>
    <?php echo $name ?>
    <?php $post_date = date_i18n( ‘l, d F Y’, strtotime( $app->post_date ) );
    echo $post_date.’
    ‘; ?>
    ID ?>”><?php _e( ‘View Details’, ‘jobman’ ) ?>
    </td>
    <?php
    if( count( $fields ) ) {
    foreach( $fields as $id => $field ) {
    if( $field[‘listdisplay’] ) {
    $data = ”;
    if( array_key_exists(“data$id”, $appdata ) && ” != $appdata[“data$id”] ) {
    switch( $field[‘type’] ) {
    case ‘text’:
    case ‘radio’:
    case ‘checkbox’:
    case ‘date’:
    case ‘textarea’:
    case ‘select’:
    $data = $appdata[“data$id”];
    break;
    case ‘file’:
    $data = ‘‘ . __( ‘Download’, ‘jobman’ ) . ‘‘;
    break;
    case ‘geoloc’:
    $data = $appdata[“data-display$id”];
    break;
    }
    }
    ?>
    <td><?php echo $data ?></td>
    <?php
    }
    }
    }
    ?>
    <td>
    <?php
    echo __( ‘Emails’, ‘jobman’ ) . ‘: ‘;
    $emailids = get_post_meta( $app->ID, ‘contactmail’, false );
    if( count( $emailids ) > 0 )
    echo “ID’>” . count( $emailids ) . ‘‘;
    else
    echo ‘0’;
    echo ‘
    ‘;

    if( $options[‘interviews’] ) {
    $iids = get_post_meta( $app->ID, ‘interview’, false );
    echo __( ‘Interviews’, ‘jobman’ ) . “: ID’>” . count( $iids ) . ‘
    ‘;
    }

    $rating = 0;
    if( array_key_exists( ‘rating’, $appdata ) )
    $rating = $appdata[‘rating’];

    //jobman_print_rating_stars( $app->ID, $rating );
    ?>
    </td>
    </tr>
    <?php
    }
    }
    if( ! $app_displayed ) {
    if( $filtered )
    $msg = __( ‘There were no applications that matched your search.’, ‘jobman’ );
    else
    $msg = __( ‘There are currently no applications in the system.’, ‘jobman’ );

    ?>
    <tr>
    <td colspan=”<?php echo 3 + $fieldcount ?>”><?php echo $msg ?></td>
    </tr>
    <?php
    }
    ?>
    </table>
    <div class=”alignleft actions”>
    <select name=”jobman-mass-edit”>
    <option value=””><?php _e( ‘Bulk Actions’, ‘jobman’ ) ?></option>
    <option value=”email”><?php _e( ‘Email’, ‘jobman’ ) ?></option>
    <option value=”delete”><?php _e( ‘Delete’, ‘jobman’ ) ?></option>
    <option value=”export-csv”><?php _e( ‘Export as CSV file’, ‘jobman’ ) ?></option>
    </select>
    <input type=”submit” value=”<?php _e( ‘Apply’, ‘jobman’ ) ?>” name=”submit” class=”button-secondary action” />
    </div>
    </form>
    </div>
    <?php
    }

    function jobman_rate_application() {
    $rating = get_post_meta( $_REQUEST[‘appid’], ‘rating’, true );
    if( ” == $rating )
    add_post_meta( $_REQUEST[‘appid’], ‘rating’, $_REQUEST[‘rating’], true );
    else
    update_post_meta( $_REQUEST[‘appid’], ‘rating’, $_REQUEST[‘rating’] );

    die();
    }

    function jobman_application_details_layout( $appid ) {
    $options = get_option( ‘jobman_options’ );

    if( array_key_exists( ‘jobman-email’, $_REQUEST ) ) {
    check_admin_referer( ‘jobman-reemail-application’ );
    jobman_email_application( $appid, $_REQUEST[‘jobman-email’] );
    }

    if( array_key_exists( ‘new-interview’, $_REQUEST ) )
    jobman_interview_new();

    if( array_key_exists( ‘comment’, $_REQUEST ) )
    jobman_store_comment();
    ?>
    <div id=”jobman-application” class=”wrap”>
    <h2><?php _e( ‘Job Manager: Application Details’, ‘jobman’ ) ?></h2>
    <div class=”printicon”><img src=”<?php echo JOBMAN_URL ?>/images/print-icon.png” /></div>
    ←<?php _e( ‘Back to Application List’, ‘jobman’ ) ?>
    <!–←<?php _e( ‘Back to Application List’, ‘jobman’ ) ?> –>
    <?php

    $widths = array( ‘59%’, ‘39%’ );
    $functions = array(
    array( ‘jobman_application_display_details’ ),
    array( ‘jobman_comments’, ‘jobman_application_email_form’ )
    );
    $titles = array(
    array( __( ‘Application’, ‘jobman’ ) ),
    array( __( ‘Application Comments’, ‘jobman’ ), __( ‘Share Application’, ‘jobman’ ) )
    );
    $params = array(
    array( array( $appid ) ),
    array( array( $appid, true ), array() )
    );

    if( $options[‘interviews’] ) {
    $functions[1] = array_insert( $functions[1], 1, ‘jobman_interview_application’ );
    $titles[1] = array_insert( $titles[1], 1, __( ‘Interviews’, ‘jobman’ ) );
    $params[1] = array_insert( $params[1], 1, array( $appid, ‘summary’ ) );
    }
    jobman_create_dashboard( $widths, $functions, $titles, $params );
    ?>
    ←<?php _e( ‘Back to Application List’, ‘jobman’ ) ?>
    <!–←<?php _e( ‘Back to Application List’, ‘jobman’ ) ?> –>
    </div>
    <?php
    }

    function jobman_application_display_details( $appid ) {
    $options = get_option( ‘jobman_options’ );
    $fromid = $options[‘application_email_from’];

    $app = get_post( $appid );
    $appmeta = get_post_custom( $appid );

    $appdata = array();
    if( ! empty( $appmeta ) ) {
    foreach( $appmeta as $key => $value ) {
    if( is_array( $value ) )
    $appdata[$key] = $value[0];
    else
    $appdata[$key] = $value;
    }
    }

    $fromid = $options[‘application_email_from’];
    $email = $appdata[“data$fromid”];
    $grav_url = ‘https://www.gravatar.com/avatar/&#8217; . md5( strtolower( $email ) ) . ‘?size=120’;
    //echo “<img src=’$grav_url’ alt=” class=’jobman-gravatar’ />”;

    if( NULL != $app ) {
    echo ‘<table class=”form-table jobman-form-table”>’;

    $parents = get_post_meta( $app->ID, ‘job’, false );
    if( ! empty( $parents ) ) {
    $parentstr = array();
    foreach( $parents as $parent ) {
    $data = get_post( $parent );

    $children = get_posts( “post_type=jobman_app&meta_key=job&meta_value=$data->ID&post_status=publish,private” );
    if( count( $children ) > 0 )
    $applications = ‘ID”) . ‘”>’ . count( $children ) . ‘‘;
    else
    $applications = 0;

    $parentstr[] = “ID’>$data->post_title ($applications)”;
    }
    $title = __( ‘Job’, ‘jobman’ );
    if( count( $parentstr ) > 1 )
    $title = __( ‘Jobs’, ‘jobman’ );
    echo “<tr><th scope=’row’>$title</th><td>” . implode( ‘, ‘, $parentstr ) . ‘</td></tr>’;
    }
    $post_date = date_i18n( ‘l, d F Y, H:i:s’, strtotime( $app->post_date ) );
    echo ‘<tr><th scope=”row”>‘ . __( ‘Timestamp’, ‘jobman’ ) . “</th><td>$post_date</td></tr>”;

    //echo ‘<tr><th scope=”row”>‘ . __( ‘Rating’, ‘jobman’ ) . ‘</th>’;
    //echo ‘<td>’;

    $rating = 0;
    if( array_key_exists( ‘rating’, $appdata ) )
    $rating = $appdata[‘rating’];

    //jobman_print_rating_stars( $app->ID, $rating );

    //echo ‘</div></td><tr>’;
    echo ‘<td colspan=”2″> </td></tr>’;

    $fields = $options[‘fields’];
    if( count( $fields ) > 0 ) {
    uasort( $fields, ‘jobman_sort_fields’ );
    foreach( $fields as $fid => $field ) {
    if( ! array_key_exists( “data$fid”, $appdata ) )
    continue;

    $item = $appdata[“data$fid”];

    echo ‘<tr><th scope=”row” style=”min-width: 150px;”>‘ . $fields[$fid][‘label’] . ‘</th><td>’;
    if( $fid == $fromid ) {
    echo ““;
    }
    switch( $fields[$fid][‘type’] ) {
    case ‘text’:
    case ‘radio’:
    case ‘checkbox’:
    case ‘date’:
    case ‘textarea’:
    case ‘select’:
    echo $item;
    break;
    case ‘file’:
    $fileurl = wp_get_attachment_url( $item );
    if( ! empty( $fileurl ) )
    echo “
    ” . __( ‘Download’, ‘jobman’ ) . ““;
    break;
    case ‘geoloc’:
    echo ‘‘ . $appdata[‘data-display’.$fid] . ‘ (‘ . $item . ‘)‘;
    break;
    }
    if( $fid == $fromid ) {
    echo ”;
    }
    echo ‘</td></tr>’;
    }
    }
    }
    ?>
    </table>
    <?php
    }

    function jobman_application_email_form() {
    ?>
    <div class=”emailapplication”>
    <p><?php _e( ‘Use this form to email the application to a new email address.’, ‘jobman’ ) ?></p>
    <form action=”” method=”post”>
    <?php
    wp_nonce_field( ‘jobman-reemail-application’ );
    ?>
    <input type=”text” name=”jobman-email” />
    <input type=”submit” name=”submit” value=”<?php _e( ‘Email’, ‘jobman’ ) ?>!” />
    </form>
    </div>

    <?php
    }

    function jobman_application_delete_confirm() {
    ?>
    <div class=”wrap”>
    <form action=”” method=”post”>
    <input type=”hidden” name=”jobman-delete-confirmed” value=”1″ />
    <input type=”hidden” name=”jobman-mass-edit” value=”delete” />
    <input type=”hidden” name=”jobman-app-ids” value=”<?php echo implode( ‘,’, $_REQUEST[‘application’] ) ?>” />
    <?php
    wp_nonce_field( ‘jobman-mass-delete-applications’ );
    ?>
    <h2><?php _e( ‘Job Manager: Applications’, ‘jobman’ ) ?></h2>
    <p class=”error”><?php _e( ‘This will permanently delete all of the selected applications. Please confirm that you want to continue.’, ‘jobman’ ) ?></p>
    <p class=”submit”><input type=”submit” name=”submit” class=”button-primary” value=”<?php _e( ‘Delete Applications’, ‘jobman’ ) ?>” /></p>
    </form>
    </div>
    <?php
    }

    function jobman_application_delete() {
    $options = get_option( ‘jobman_options’ );

    $apps = explode( ‘,’, $_REQUEST[‘jobman-app-ids’] );

    // Get the file fields
    $file_fields = array();
    foreach( $options[‘fields’] as $id => $field ) {
    if( ‘file’ == $field[‘type’] )
    $file_fields[] = $id;
    }

    foreach( $apps as $app ) {
    $appmeta = get_post_custom( $app );
    $appdata = array();
    if( is_array( $appmeta ) ) {
    foreach( $appmeta as $key => $value ) {
    if( is_array( $value ) )
    $appdata[$key] = $value[0];
    else
    $appdata[$key] = $value;
    }
    }

    // Delete any files uploaded
    foreach( $file_fields as $fid ) {
    if( array_key_exists( “data$fid”, $appdata ) && ” != $appdata[“data$fid”] )
    wp_delete_post( $appdata[“data$fid”] );
    }
    // Delete the application
    wp_delete_post( $app );
    }
    }

    function jobman_get_application_csv() {
    if( is_multisite() ) {
    // Multisite seems to do some late loading. We need the cookie info now, so we can validate the user.
    require_once( ABSPATH . WPINC . ‘/default-constants.php’ );
    wp_cookie_constants();
    }
    require_once( ABSPATH . WPINC . ‘/pluggable.php’ );

    $options = get_option( ‘jobman_options’ );

    header( ‘Cache-Control: no-cache’ );
    header( ‘Expires: -1’ );

    if( ! current_user_can( ‘read_private_pages’ ) ) {
    header( $_SERVER[“SERVER_PROTOCOL”] . ‘ 403 Forbidden’ );
    header( ‘Refresh: 0; url=’ . admin_url() );
    echo ‘<html><head><title>403 Forbidden</title></head><body><p>Access is forbidden.</p></body></html>’;
    exit;
    }

    header( ‘Content-Type: application/force-download’ );
    header( ‘Content-type: text/csv’ );
    header( ‘Content-Type: application/download’ );
    header( “Content-Disposition: attachment; filename=applications.csv ” );

    $fields = $options[‘fields’];
    $out = fopen( ‘php://output’, ‘w’ );

    if( count( $fields ) > 0 ) {
    uasort( $fields, ‘jobman_sort_fields’ );

    $labels = array();
    foreach( $fields as $field ) {
    $labels[] = $field[‘label’];
    }
    fputcsv( $out, $labels );

    $posts = array();
    if( array_key_exists( ‘application’, $_REQUEST ) && is_array( $_REQUEST[‘application’] ) )
    $posts = $_REQUEST[‘application’];
    $apps = get_posts( array( ‘post_type’ => ‘jobman_app’, ‘post__in’ => $posts, ‘numberposts’ => -1, ‘post_status’ => ‘public,private’ ) );

    if( count( $apps ) > 0 ) {
    foreach( $apps as $app ) {
    $data = array();

    $appmeta = get_post_custom( $app->ID );

    $appdata = array();
    foreach( $appmeta as $key => $value ) {
    if( is_array( $value ) )
    $appdata[$key] = $value[0];
    else
    $appdata[$key] = $value;
    }

    foreach( $fields as $id => $field ) {
    if( array_key_exists( “data$id”, $appdata ) ) {
    $item = $appdata[“data$id”];
    switch( $field[‘type’] ) {
    case ‘text’:
    case ‘radio’:
    case ‘checkbox’:
    case ‘date’:
    case ‘textarea’:
    case ‘select’:
    $data[] = $item;
    break;
    case ‘file’:
    $data[] = admin_url(“admin.php?page=jobman-list-applications&appid=$app->ID&getfile=$item”);
    break;
    case ‘geoloc’:
    $data[] = $appdata[‘data-display’.$id] . ‘ (‘ . $item . ‘)’;
    break;
    default:
    $data[] = ”;
    }
    }
    else {
    $data[] = ”;
    }
    }

    fputcsv( $out, $data );
    }
    }
    }

    fclose( $out );

    exit;
    }
    ?>

    sophie30

    (@sophie30)

    Hi,

    Please can you show me what’s the result of this code? I’d like add filters to my job list but I don’t know how to do this.

    Thanks.

    benjazz

    (@benjazz)

    Hi Sophie,

    This code is for the back-end of applications, note for the job listing.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Job Manager] Custom Filters and Application filtering’ is closed to new replies.