Skip to content

Commit

Permalink
FIX: Compatability issue when free plugin hiresuit version & pro plug…
Browse files Browse the repository at this point in the history
…in is <4.0
  • Loading branch information
nithinjohn22 committed Dec 31, 2024
1 parent 7c15bde commit ff1df83
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions wp-job-openings.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@ public function deactivate() {
flush_rewrite_rules();
}

public function pro_version_admin_notice() {
?>
<div class="notice notice-error">
<p>
<?php
echo esc_html__( 'The Pro version of the plugin is outdated. Please update it to version 4.0 or higher to work with the Free version.', 'awsm-job-openings' );
?>
</p>
</div>
<?php
}

public function check_pro_version_for_free_plugin() {
if ( defined( 'AWSM_JOBS_PRO_PLUGIN_BASENAME' ) ) {
if ( is_plugin_active( AWSM_JOBS_PRO_PLUGIN_BASENAME ) ) {
$pro_plugin_path = WP_PLUGIN_DIR . '/' . AWSM_JOBS_PRO_PLUGIN_BASENAME;
if ( file_exists( $pro_plugin_path ) ) {
$plugin_data = get_plugin_data( $pro_plugin_path );
$pro_version = $plugin_data['Version'];

$required_pro_version = '4.0';

if ( version_compare( $pro_version, $required_pro_version, '<' ) ) {
add_action( 'admin_notices', array( $this, 'pro_version_admin_notice' ) );
deactivate_plugins( AWSM_JOBS_PRO_PLUGIN_BASENAME );
}
}
}
}
}

public static function log( $data, $prefix = '' ) {
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG && defined( 'AWSM_JOBS_DEBUG' ) && AWSM_JOBS_DEBUG ) {
if ( is_string( $data ) ) {
Expand Down Expand Up @@ -237,6 +268,7 @@ public function admin_actions() {
// Add custom status to status dropdown under post submit meta box (existing and new) for job openings.
add_action( 'admin_footer-post.php', array( $this, 'job_submit_meta_box_custom_status' ) );
add_action( 'admin_footer-post-new.php', array( $this, 'job_submit_meta_box_custom_status' ) );
add_action( 'admin_init', array( $this, 'check_pro_version_for_free_plugin' ) );
}
}

Expand Down

0 comments on commit ff1df83

Please sign in to comment.