Description

Plugin to allow show progression links.

Screenshot of the Import page

The plugin uses 1 shortcode.
Code is divided into separate folders and files. It contains the following files:
The plugin supports auto updates.

Tested in WordPress 6.3.2

Code

mic-progressions.php

/**
 * Plugin Name: MIC Progressions
 * Plugin URI: 	https://plugins.ccoc.ie/mic_progressions/
 * Description:	Shows courses progressions
 * Version:		0.9.0
 * Author:		Cork College of FET, Morrisons Island Campus
 * Author URI:	https://morrisonsislandcampus.ie
 * Update URI:	https://plugins.ccoc.ie/mic_progressions/info.json
*/

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

// Files to include
require_once MIC_PROGRESSIONS_PLUGIN_DIR . "/includes/db.php";
if( is_admin() ){
	require_once MIC_PROGRESSIONS_PLUGIN_DIR . "/includes/admin.php";
}
require_once MIC_PROGRESSIONS_PLUGIN_DIR . "/includes/settings.php";
require_once MIC_PROGRESSIONS_PLUGIN_DIR . "/includes/shortcodes.php";
require_once MIC_PROGRESSIONS_PLUGIN_DIR . "/includes/progressions.php";

// Add options
mic_progressions_add_options();

// Activate the plugin, create tables
function mic_progressions_activate() {	
	require_once MIC_PROGRESSIONS_PLUGIN_DIR . "/includes/create-tables.php";
	mic_progressions_create_table( 5 );
	mic_progressions_create_table( 6 );
}

// Adds style sheet and javascript files to the end of the queue
function mic_progressions_scripts_styles() {
    wp_enqueue_style( "mic_progressions_style", MIC_PROGRESSIONS_PLUGIN_URL . "/css/style.css" );
	//wp_enqueue_script( "mic_progressions_script", MIC_PROGRESSIONS_PLUGIN_URL . "/js/script.js" ); //Currently not using javascript
}

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

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

// Check for updates
function mic_progressions_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_progressions_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/
Updating - https://wordpress.stackexchange.com/questions/13/updates-for-a-private-plugin