Skip to content

Commit

Permalink
Merge branch 'release/v3.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
wpmark committed Apr 24, 2019
2 parents 0966d98 + 5e48f8c commit 934bfda
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 20 deletions.
9 changes: 0 additions & 9 deletions assets/css/wpbb-admin-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@
.wpbb-cta-box__content {
padding: 6px 10px 16px;
}
.wpbb-settings-col .description {
max-width: 60%;
}
@media all and ( max-width: 1400px ) {
.wpbb-settings-col .description {
max-width: 80%;
}
}


img.hd-logo {
margin-top: 16px;
Expand Down
5 changes: 5 additions & 0 deletions inc/applications/application-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ function wpbb_job_application_form( $job_id = 0 ) {
*/
function wpbb_job_application_form_output( $content ) {

// if the job application type is not a form.
if ( 'form' !== wpbb_get_job_application_type() ) {
return $content;
}

// if this is not a single job view.
if ( ! is_singular( wpbb_job_post_type_name() ) ) {
return $content;
Expand Down
31 changes: 30 additions & 1 deletion inc/filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function wpbb_add_setting_description( $setting, $value ) {

// output the description, below the input.
?>
<p class="description"><?php echo esc_html( $setting['description'] ); ?></p>
<p class="description"><?php echo wp_kses_post( $setting['description'] ); ?></p>
<?php

}
Expand Down Expand Up @@ -109,6 +109,35 @@ function wpbb_maybe_add_plugin_credit( $content ) {

add_filter( 'the_content', 'wpbb_maybe_add_plugin_credit', 99 );

/**
* If application tracking by url is active, append an apply link to the job post content.
*
* @param string $content The current job post content.
* @return string The modified job post content.
*/
function wpbb_add_job_application_url( $content ) {

// if the job application type is not a form.
if ( 'url' !== wpbb_get_job_application_type() ) {
return $content;
}

// if this is not a single job view.
if ( ! is_singular( wpbb_job_post_type_name() ) ) {
return $content;
}

// get the job application url.
global $post;
$application_url = wpbb_get_job_applicant_tracking_url( $post->ID );

// return the content with application url appended.
return $content . '<a target="_blank" class="wpbb-application-url" href="' . esc_url( $application_url ) . '">' . esc_html__( 'Apply Now', 'wpbroadbean' ) . '</a>';

}

add_filter( 'the_content', 'wpbb_add_job_application_url', 20, 1 );

/**
* Adds the job field descriptions under the fields.
*
Expand Down
33 changes: 30 additions & 3 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function wpbb_get_feed_password() {
* @return bool True if the footer credit is to be shown and false otherwise.
*/
function wpbb_show_plugin_credit() {
return apply_filters( 'wpbb_plugin_credit_status', (bool) get_option( 'wpbb_plugin_credit', false ) );
return apply_filters( 'wpbb_plugin_credit_status', (bool) get_option( 'wpbb_plugin_credit', false ) );
}

/**
Expand All @@ -46,7 +46,16 @@ function wpbb_show_plugin_credit() {
* @return bool True if the data should be hidden and false otherwise.
*/
function wpbb_hide_job_data_output() {
return apply_filters( 'wpbb_hide_job_data_output', (bool) get_option( 'wpbb_hide_job_data_output', false ) );
return apply_filters( 'wpbb_hide_job_data_output', (bool) get_option( 'wpbb_hide_job_data_output', false ) );
}

/**
* Gets the application type from settings - defauly to form.
*
* @return string the type of application to use.
*/
function wpbb_get_job_application_type() {
return apply_filters( 'wpbb_job_application_type', get_option( 'wpbb_job_application_type', 'form' ) );
}

/**
Expand Down Expand Up @@ -145,6 +154,24 @@ function wpbb_get_job_applicant_tracking_email( $job_id = 0 ) {

}

/**
* Get the tracking or application url for a specified job.
*
* @param integer $job_id the job post id to get the tracking url from.
* @return mixed if the job has a tracking url, returns a string of that address.
* if the job does not have a tracking url returns and empty string.
*/
function wpbb_get_job_applicant_tracking_url( $job_id = 0 ) {

// return the tracking url from post meta.
return apply_filters(
'wpbb_job_applicant_tracking_url',
get_post_meta( $job_id, '_wpbb_job_broadbean_application_url', true ),
$job_id
);

}

/**
* Prepare terms sent via the broadbean feed to adding to a job post once created.
* returns an array of mixed term ids and terms names.
Expand Down Expand Up @@ -413,7 +440,7 @@ function wpbb_load_view( $path = '', $data = array() ) {
ob_start();

/* grab the file asked for */
include_once( $view_path );
include( $view_path );

/* get the content of the buffer - the file asked for and clean up */
$content = ob_get_clean();
Expand Down
2 changes: 1 addition & 1 deletion inc/meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function wpbb_register_job_information_meta_box() {
'wpbb-job-info',
__( 'Job Information', 'wpbroadbean' ),
'wpbb_job_meta_box_output',
'wpbb_job',
wpbb_job_post_type_name(),
'normal',
'default'
);
Expand Down
14 changes: 14 additions & 0 deletions inc/settings/default-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ function wpbb_register_default_general_settings( $settings ) {
'order' => 40,
);

// add the setting to hide the job data on a single job listing.
$settings['application_type'] = array(
'label' => __( 'Application Type', 'wpbroadbean' ),
'option_name' => 'wpbb_job_application_type',
'input_type' => 'select',
'options' => array(
'form' => __( 'Application Form', 'wpbroadbean' ),
'url' => __( 'External URL', 'wpbroadbean' ),
),
'description' => sprintf( __( 'Choose how candidates should apply for jobs, either using the Broadbean tracking URL (external URL) or the tracking email address (application form). Learn more about the two types %s.', 'wpbroadbean' ), '<a href="https://integrations.broadbean.com/hc/en-us/articles/213311449-What-is-Aplitrak-">here</a>' ),
'settings_group' => 'wpbb_settings',
'order' => 40,
);

// return the modified settings array.
return $settings;

Expand Down
14 changes: 13 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: jobs, recruitment
Requires at least: 5.1
Requires PHP: 5.6
Tested up to: 5.1
Stable tag: 3.0
Stable tag: 3.0.1
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -46,6 +46,18 @@ It is a new version, therefore we don't have any FAQs just yet. Feel free to [su

== Changelog ==

= 3.0.1 (24/04/2019) =
* Adds support for application via either an application form on site, or an external application URL.
* Improved some functions in terms of coding standards.
* Added a setting for the application type - allows site admins to choose whether candidates should apply via a form or an external URL.
* Escaped settings field description using `wp_kses_post` rather than 'esc_html' so they can include links.
* Added new function `wpbb_get_job_application_type()` which returns the type of application chosen. Either `form` or `url`.
* If applications are set to url, output a apply now button linking to the URL below the job content.
* Correct an incorrect entry in the `sample-add.xml` file.
* Adds plugin update routines.
* Corrects an issue where the plugin version does not show correctly in the admin settings page.


= 3.0 =
* IMPORTANT NOTICE BEOFRE UPDATING: WP Broadbean version 3.0 is a major overhaul of the plugin from earlier versions. With this in mind, this version is NOT backward compatible to earlier versions. This means if you are running a version earlier than version 3.0 already, it is crucial that you test the update on a staging or test site before updating to the latest version.
* Deprecated the theme inbox file version located at `wpbb/inbox.php` in the active theme and replaced with `wpbroadbean.php` in the root of the active theme.
Expand Down
2 changes: 1 addition & 1 deletion sample-xml/sample-add.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<job_reference>abc123</job_reference>
<salary_from>25000</salary_from>
<salary_to>30000</salary_to>
<salary_currency>GBP</salary_currency>
<currency>GBP</currency>
<salary>30000</salary>
<salary_display>Up to £30,000 with benefits.</salary_display>
<consultant_email>contact@domain.com</consultant_email>
Expand Down
2 changes: 1 addition & 1 deletion views/settings-ctas.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<h2 class="hndle ui-sortable-handle wpbb-postbox-title"><?php esc_html_e( 'WP Broadbean information', 'wpbroadbean' ); ?></h3>
<div class="inside">
<p class="plugin-info">
Version: <?php echo esc_html( get_option( 'wpbroadbean_version' ) ); ?>, written by <a href="https://highrise.digital"><?php esc_html_e( 'Highrise Digital', 'wpbroadbean' ); ?></a><br />
Version: <?php echo esc_html( WPBB_PLUGIN_VERSION ); ?>, written by <a href="https://highrise.digital"><?php esc_html_e( 'Highrise Digital', 'wpbroadbean' ); ?></a><br />
</p>
<p><?php printf( esc_html__( 'Your sites endpoint URL is: %s', 'wpbroadbean' ), '<code>' . esc_url( home_url( '/wpbb/jobfeed/' ) ) . '</code>' ); ?></p>
<p><?php printf( esc_html__( 'Sample XML files can be found in the %s folder in the plugin root.', 'wpbroadbean' ), '<code>sample-xml</code>' ); ?></p>
Expand Down
52 changes: 49 additions & 3 deletions wpbroadbean.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: WP Broadbean
Plugin URI: https://highrise.digital/products/wpbroadbean-wordpress-plugin/
Description: A plugin which integrates <a href="https://www.broadbean.com/uk/products/features/job-posting-distribution/">Broadbean job posting and distribution</a> with WordPress. It allows jobs written in Broadbean to be distributed to a WordPress site and have applications made to those jobs in WordPress delivered back to Broadbean.
Version: 3.0
Version: 3.0.1
Author: Highrise Digital
Author URI: https://highrise.digital
License: GPLv3 or later
Expand All @@ -30,8 +30,9 @@
define( 'WPBB_LOCATION', dirname( __FILE__ ) );
define( 'WPBB_LOCATION_URL', plugins_url( '', __FILE__ ) );

// Define plugin version constant.
define( 'WPBB_PLUGIN_VERSION', '3.0' );
// Define plugin version constant and db version constant.
define( 'WPBB_PLUGIN_VERSION', '3.0.1' );
define( 'WPBB_PLUGIN_DB_VERSION', 2 );

/**
* Load the plugins translated strings.
Expand All @@ -57,12 +58,57 @@ function wpbb_on_activation() {
// store the plugin version number on activation.
update_option( 'wpbroadbean_version', WPBB_PLUGIN_VERSION );

// store the plugin db version on activation.
update_option( 'wpbroadbean_db_version', WPBB_PLUGIN_DB_VERSION );

// flush the rewrite rules.
flush_rewrite_rules();

}

register_activation_hook( __FILE__, 'wpbb_on_activation' );

/**
* Handles plugin update routines.
*/
function wpbb_plugin_upgrade_routines() {

// get the current db version of the plugin stored in the sites database.
$wpbb_site_db_version = absint( get_option( 'wpbroadbean_db_version' ) );

// require updates defaults to false.
$require_update = false;

// if we have no stored site db version.
if ( empty( $wpbb_site_db_version ) ) {

// updates are needed as the version is not present.
$require_update = true;

}

// if the site db version is less than 2.
if ( $wpbb_site_db_version < 2 ) {

// an update is required.
$require_update = true;

// start with removing the plugin version as we don't need this - using a db version instead as is best practice.
delete_option( 'wpbroadbean_version' );

}

// if updates are required.
if ( true === $require_update ) {

// update the plugins db version on this site.
update_option( 'wpbroadbean_db_version', WPBB_PLUGIN_DB_VERSION );

}

}

add_action( 'admin_init', 'wpbb_plugin_upgrade_routines' );

/* load required files & functions */
require_once( dirname( __FILE__ ) . '/inc/loader.php' );

0 comments on commit 934bfda

Please sign in to comment.