Description

Plugin to allow employers advertise a job on the website and students register and view the jobs.

Screenshot of the Settings page

The plugin uses 3 shortcodes, one for Student Registration, one for Student Login and one for Adding Jobs.
Code is divided into separate folders and files. It contains the following files:
The plugin supports auto updates.

Tested in WordPress 6.1.1

Code

mic-jobs-register.php

/**
 * Plugin Name: MIC Jobs Register
 * Plugin URI: 	https://plugins.ccoc.ie/mic_jobs_register/
 * Description:	Allows employers to add a job to the website and registered students to view them
 * Version:		1.0.3
 * Author:		Cork College of FET, Morrisons Island Campus
 * Author URI:	https://morrisonsislandcampus.ie
 * Update URI:	https://plugins.ccoc.ie/mic_jobs_register/info.json
*/

// Constants used for Plugin Directory and URL
define( "MIC_JOBS_REGISTER_PLUGIN_DIR", dirname( __FILE__ ) );
define( "MIC_JOBS_REGISTER_PLUGIN_URL", plugin_dir_url ( __FILE__ ) );

// Files to include
require_once MIC_JOBS_REGISTER_PLUGIN_DIR . "/includes/core.php";
if( is_admin() ){
	require_once MIC_JOBS_REGISTER_PLUGIN_DIR . "/includes/admin.php";
}
require_once MIC_JOBS_REGISTER_PLUGIN_DIR . "/includes/settings.php";
require_once MIC_JOBS_REGISTER_PLUGIN_DIR . "/includes/shortcodes.php";
require_once MIC_JOBS_REGISTER_PLUGIN_DIR . "/includes/settings.php";

// Add options
mic_jobs_register_add_options();

// Activate the plugin, create tables
function mic_jobs_register_activate() {	
	require_once MIC_JOBS_REGISTER_PLUGIN_DIR . "/includes/create-tables.php";
	mic_jobs_register_create_table();
	mic_jobs_register_students_create_table();
	mic_jobs_register_users_create_table();
}

// Adds style sheet and javascript files to the end of the queue
function mic_jobs_register_scripts_styles() {
    wp_enqueue_style( "mic_jobs_register_style", MIC_JOBS_REGISTER_PLUGIN_URL . "/css/style.css" );
	wp_enqueue_script( "mic_jobs_register_script", MIC_JOBS_REGISTER_PLUGIN_URL . "/js/script.js" );
}

// Add to scripts and styles to both frontend and admin pages
add_action( "wp_enqueue_scripts", "mic_jobs_register_scripts_styles", PHP_INT_MAX );
add_action( "admin_enqueue_scripts", "mic_jobs_register_scripts_styles", PHP_INT_MAX );

// Called when plugin is activated
register_activation_hook( __FILE__, "mic_jobs_register_activate" );

// Check for updates
function mic_jobs_register_check_for_updates( $update, $plugin_data, $plugin_file ) {        
	static $response = false;   
	if( empty( $plugin_data["UpdateURI"] ) || !empty( $update ) ) {
		return $update;
	}
	if( $response === false ) {
		$response = wp_remote_get( $plugin_data['UpdateURI'] );
	}
	if( empty( $response["body"] ) ) {
		return $update;
	}
	$custom_plugins_data = json_decode( $response['body'], true );
	if( !empty( $custom_plugins_data[ $plugin_file ] ) ) {
		return $custom_plugins_data[ $plugin_file ];
	}
	else {
		return $update; 
	}
}

// Called when checking for updates
add_filter('update_plugins_plugins.ccoc.ie', 'mic_jobs_register_check_for_updates', 10, 3);
		


Download Plugin

Updates Page

References


WordPress Developer Reference - https://developer.wordpress.org/reference/functions/
WordPress Plugin Tutorial - https://www.davidangulo.xyz/how-to-create-crud-operations-plugin-in-wordpress/
Password Hashing - https://www.positioniseverything.net/php-password_hash
Updating - https://wordpress.stackexchange.com/questions/13/updates-for-a-private-plugin