Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< Updated upstream
Copy link

Copilot AI Oct 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflict markers are present in the file. These must be resolved before merging. Remove the conflict markers and consolidate both versions of the README into a single coherent document.

Suggested change
<<<<<<< Updated upstream

Copilot uses AI. Check for mistakes.
# WordPress FOSSASIA Event Plugin (WPFAevent)

The **FOSSASIA Event Plugin** provides WordPress integrations for [Eventyay](https://eventyay.com)-based events.
Expand Down Expand Up @@ -183,3 +184,45 @@ Before submitting:

Licensed under the **Apache License, Version 2.0**
Copyright © 2025 [FOSSASIA](https://fossasia.org)
=======
# FOSSASIA Event WordPress Plugin

A plugin to create and manage event landing pages, speakers, schedules, and sponsors within WordPress using Custom Post Types.

## Features
- Creates `Event` and `Speaker` Custom Post Types (CPTs).
- Provides a clean, database-driven way to manage event data.
- (For Developers) A WP-CLI command to seed test data for development and testing.

## Getting Started

1. **Install and Activate** the plugin.
2. You will see new "Events" and "Speakers" menu items in your WordPress admin sidebar.
3. You can now create and manage events and speakers just like standard WordPress posts.
4. To display your content, you will use shortcodes (e.g., `[wpfa_speakers]`) or custom templates that query these new post types.


## For Developers: Seeding Data with WP-CLI

The plugin includes a WP-CLI command for developers to quickly seed test data. This is useful for setting up a development environment, especially when working with the Custom Post Type architecture.

**Prerequisites:**
- WP-CLI must be installed.
- The plugin must be activated.

**Commands:**

1. **Seed Minimal Data:**
This command creates 2 placeholder speakers and 1 event in the database.
```bash
wp wpfa seed --minimal
```

2. **Seed from JSON file:**
This command populates CPT data from a specified JSON file. A sample fixture is included in the plugin.
```bash
wp wpfa seed --from-json=wp-content/plugins/wpfa-event/assets/demo/minimal.json
```

The seeder command is **idempotent**, meaning it is safe to re-run. It will update existing posts based on their slugs instead of creating duplicates.
>>>>>>> Stashed changes
89 changes: 89 additions & 0 deletions fossasia-landing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php
/**
* Plugin Name: WPFA Event
* Description: A plugin to create and manage events, speakers, schedules, and sponsors within WordPress using Custom Post Types.
* Version: 1.0.0
* Author: Nishil
* Text Domain: wpfa-event
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

define( 'WPFA_EVENT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'WPFA_EVENT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

/**
* The core plugin class.
*/
final class WPFA_Event {

/**
* The single instance of the class.
*
* @var WPFA_Event
*/
private static $instance;

/**
* Main Instance.
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WPFA_Event ) ) {
self::$instance = new WPFA_Event();
self::$instance->setup_constants();
self::$instance->includes();
}
return self::$instance;
}

/**
* Setup plugin constants.
*/
private function setup_constants() {
// Plugin version.
define( 'WPFA_EVENT_VERSION', '1.0.0' );
}

/**
* Include required files.
*/
private function includes() {
require_once WPFA_EVENT_PLUGIN_DIR . 'includes/class-wpfa-cpt.php';
require_once WPFA_EVENT_PLUGIN_DIR . 'public/class-wpfa-public.php';

if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once WPFA_EVENT_PLUGIN_DIR . 'includes/class-wpfa-cli.php';
}
}

/**
* Run the plugin.
*/
public function run() {
$cpt_handler = new WPFA_CPT();
$public_handler = new WPFA_Public( 'wpfa-event', WPFA_EVENT_VERSION );

add_action( 'init', array( $cpt_handler, 'register_cpts' ) );
add_action( 'init', array( $cpt_handler, 'register_meta' ) );

add_action( 'wp_enqueue_scripts', array( $public_handler, 'enqueue_styles' ) );
add_action( 'init', array( $public_handler, 'register_shortcodes' ) );
}
}

/**
* Begins execution of the plugin.
*/
function run_wpfa_event() {
$plugin = WPFA_Event::instance();
$plugin->run();
}

add_action( 'plugins_loaded', 'run_wpfa_event' );

// Register WP-CLI command if in CLI context.
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'wpfa', 'WPFA_CLI' );
}
73 changes: 73 additions & 0 deletions includes/class-fossasia-uninstaller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* WPFA Event Uninstaller
*
* Handles the cleanup of CPTs, data files, and options.
*
* @package WPFA-Event
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Class WPFA_Event_Uninstaller.
*/
class WPFA_Event_Uninstaller {

/**
* Main entry point for cleanup.
*
* This static method is called to perform all cleanup operations.
*/
public static function uninstall() {
self::delete_plugin_posts();
self::delete_data_directory();
flush_rewrite_rules();
}

/**
* Deletes all CPT posts created by the plugin.
*/
private static function delete_plugin_posts() {
$cpts_to_delete = [
'wpfa_event',
'wpfa_speaker',
];

foreach ( $cpts_to_delete as $post_type ) {
$query = new WP_Query( [
'post_type' => $post_type,
'posts_per_page' => -1,
'fields' => 'ids',
] );

if ( $query->have_posts() ) {
foreach ( $query->posts as $post_id ) {
wp_delete_post( $post_id, true );
}
}
}
}

/**
* Deletes the plugin's data directory using the WP_Filesystem API.
*/
private static function delete_data_directory() {
global $wp_filesystem;

// Ensure the filesystem is initialized.
if ( empty( $wp_filesystem ) ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
}

$upload_dir = wp_upload_dir();
$data_dir = $upload_dir['basedir'] . '/fossasia-data';

if ( $wp_filesystem->is_dir( $data_dir ) ) {
$wp_filesystem->rmdir( $data_dir, true );
}
}
}
Loading