Skip to content

Commit

Permalink
Merge pull request #611 from CodingBlackFemales:update-dependencies
Browse files Browse the repository at this point in the history
Updates dependencies
  • Loading branch information
Genyus authored Oct 7, 2024
2 parents 8b79993 + 4eabdf1 commit 24b6b88
Show file tree
Hide file tree
Showing 1,138 changed files with 98,106 additions and 30,629 deletions.
196 changes: 100 additions & 96 deletions composer.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions web/app/plugins/wp-job-manager-alerts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
*** WordPress Job Manager alerts changelog ***

2024-04-29 - version 3.2.0
* New: Add job statistics about how many times the job was sent out in alert e-mails
* Dev: Add alert modal logged out version as template

2024-03-14 - version 3.1.1
* Fix jobs not being filtered by date for alert e-mails (#467)
* Fix: Update alert e-mail schedule when alert is edited in the admin screen (#469)
Expand Down
22 changes: 3 additions & 19 deletions web/app/plugins/wp-job-manager-alerts/includes/class-add-alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,13 @@ public function single_alert_link() {
* @return string
*/
private function logged_out_message(): string {
$message = Notice::render(
[
'title' => __( 'Add Alert', 'wp-job-manager-alerts' ),
'message' => __( 'Sign in or create an account to continue.', 'wp-job-manager-alerts' ),
'buttons' => [
[
'url' => apply_filters( 'job_manager_alerts_login_url', wp_login_url( get_permalink() ) ),
'label' => __( 'Sign in', 'wp-job-manager-alerts' ),
'class' => [],
],
[
'url' => apply_filters( 'job_manager_alerts_register_url', wp_registration_url() ),
'label' => __( 'Create Account', 'wp-job-manager-alerts' ),
'class' => [],
],
],
]
);

$template = WP_Job_Manager_Alerts::get_template( 'add-alert-modal-login.php', [] );

/**
* Filter the logged out notice in the 'Add Alert' modal.
*/
return apply_filters( 'job_manager_alerts_modal_logged_out_message', $message );
return apply_filters( 'job_manager_alerts_modal_logged_out_message', $template );
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?php
/**
* Job Alerts stats.
*
* @package wp-job-manager-alerts
*/

namespace WP_Job_Manager_Alerts;

use WP_Job_Manager\Job_Listing_Stats;
use WP_Job_Manager\Stats;

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}

/**
* Job Alerts plugin stats.
*/
class Alert_Stats {
use Singleton;

const ALERT_IMPRESSION = 'job_alert_impression';

const MAIL_ICON = 'url("data:image/svg+xml,%3csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'24\' height=\'24\' fill=\'none\' viewBox=\'0 0 24 24\'%3e%3cpath fill=\'black\' fill-rule=\'evenodd\' d=\'M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.28 0 .5.22.5.5v.94L12 13.56 4.5 7.94V7c0-.28.22-.5.5-.5Zm-.5 3.31V17c0 .28.22.5.5.5h14a.5.5 0 0 0 .5-.5V9.81L12 15.44 4.5 9.8Z\' clip-rule=\'evenodd\'/%3e%3c/svg%3e")';

/**
* Initialize hooks for alert stats.
*/
private function __construct() {
add_filter( 'job_manager_job_stats_summary', [ $this, 'job_stats_summary' ], 10, 2 );
}

/**
* Log the stats for the jobs sent in the alert.
*
* @param \WP_Query $jobs
*/
public static function log_jobs_sent( $jobs ) {

if ( ! class_exists( 'WP_Job_Manager\Stats' ) || ! Stats::is_enabled() ) {
return;
}

$stats = array_map(
fn( $job ) => [
'post_id' => $job->ID,
'name' => self::ALERT_IMPRESSION,
],
$jobs->posts
);

Stats::instance()->batch_log_stats( $stats );

}

/**
* Add alert e-mail impressions to job listing overlay stats section.
*
* @access private
*
* @param array $stats
* @param \WP_Post $job
*
* @return array
*/
public function job_stats_summary( $stats, $job ) {

if ( ! empty( $stats['impressions']['stats'] ) && ! empty( $job->ID ) ) {
$stats['impressions']['stats'][] =
[
'icon' => self::MAIL_ICON,
'label' => __( 'Alerts sent', 'wp-job-manager' ),
'value' => self::get_alert_impression_count( $job->ID ),
];
$stats['impressions']['help'] = __( 'How many times the listing was seen in search results or sent out in job alert e-mails.', 'wp-job-manager' );
}

return $stats;
}

/**
* Get the count of alert impressions for a job.
*
* @param int $job_id
*
* @return int
*/
public static function get_alert_impression_count( $job_id ) {
$stats = new Job_Listing_Stats( $job_id );
return $stats->get_event_total( self::ALERT_IMPRESSION );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace WP_Job_Manager_Alerts;

use WP_Job_Manager\Stats;
use WP_Job_Manager_Alerts\Emails\Job_Alert_Email;

if ( ! defined( 'ABSPATH' ) ) {
Expand Down Expand Up @@ -166,6 +167,8 @@ private function send_alert_email( Alert $alert, bool $force = false ) {
}

Emails\Job_Alert_Email::send( $alert, $jobs, $user );

Alert_Stats::log_jobs_sent( $jobs );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ public function settings( $settings = [] ) {
'cb_label' => __( 'Require an account to create job alerts', 'wp-job-manager-alerts' ),
'desc' => __( 'Limit alert creation to registered, logged-in users.', 'wp-job-manager-alerts' ),
'type' => 'checkbox',
'track' => 'bool',
],
[
'name' => self::OPTION_BRAND_COLOR,
'label' => __( 'Brand Color', 'wp-job-manager-alerts' ),
'std' => self::DEFAULT_BRAND_COLOR,
'type' => 'color',
'desc' => __( 'Set the color used for links and buttons in e-mails and shortcodes.', 'wp-job-manager-alerts' ),
'track' => 'is-default',
],
[
'name' => self::OPTION_FORM_FIELDS,
Expand All @@ -100,6 +102,7 @@ public function settings( $settings = [] ) {
'std' => [
'fields' => array_keys( Alert_Form_Fields::get_default_fields() ),
],
'track' => 'is-default',
],
[
'name' => self::OPTION_EMAIL_TEMPLATE,
Expand All @@ -116,6 +119,7 @@ public function settings( $settings = [] ) {
'<strong>Note: </strong> {display_name}' . __( ' is not available when accounts are not required.', 'wp-job-manager-alerts' ),
'type' => 'textarea',
'required' => true,
'track' => 'is-default',
],
[
'name' => self::OPTION_JOB_DETAILS_VISIBLE,
Expand All @@ -128,13 +132,15 @@ public function settings( $settings = [] ) {
'location' => __( 'Location', 'wp-job-manager-alerts' ),
],
'std' => self::DEFAULT_JOB_DETAILS_VISIBLE,
'track' => 'is-default',
],
[
'name' => self::OPTION_JOB_ALERTS_AUTO_DISABLE,
'std' => '90',
'label' => __( 'Alert Duration', 'wp-job-manager-alerts' ),
'desc' => __( 'Enter the number of days before alerts are automatically disabled, or leave blank to disable this feature. By default, alerts will be turned off for a search after 90 days.', 'wp-job-manager-alerts' ),
'type' => 'input',
'track' => 'value',
],
[
'name' => self::OPTION_JOB_MATCHES_ONLY,
Expand All @@ -143,13 +149,15 @@ public function settings( $settings = [] ) {
'cb_label' => __( 'Send alerts with matches only', 'wp-job-manager-alerts' ),
'desc' => __( 'Only send an alert when jobs are found matching its criteria. When disabled, an alert is sent regardless.', 'wp-job-manager-alerts' ),
'type' => 'checkbox',
'track' => 'bool',
],
[
'name' => self::OPTION_JOB_ALERTS_PAGE_ID,
'std' => '',
'label' => __( 'Alerts Page ID', 'wp-job-manager-alerts' ),
'desc' => __( 'So that the plugin knows where to link users to view their alerts, you must select the page where you have placed the [job_alerts] shortcode.', 'wp-job-manager-alerts' ),
'type' => 'page',
'track' => 'bool',
],
]
),
Expand Down
Loading

0 comments on commit 24b6b88

Please sign in to comment.