Skip to content

Instantly share code, notes, and snippets.

@ndugger
Last active July 22, 2023 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndugger/37abc2d5635f89c2a5281845dd53724e to your computer and use it in GitHub Desktop.
Save ndugger/37abc2d5635f89c2a5281845dd53724e to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Clubhouse
* Plugin URI: https://fyrware.com/
* Description: Turn WordPress into a premium clubhouse with paid memberships and more.
* Author: Fyrware
* Version: 1.0.0
* Author URI: https://fyrware.com
* Text Domain: clubhouse-core
*/
const CLUBHOUSE_TEXT_DOMAIN = 'clubhouse-core';
const CLUBHOUSE_ORG_POST_TYPE = 'club_org';
const CLUBHOUSE_MEMBER_POST_TYPE = 'club_member';
const CLUBHOUSE_CREATE_ORG_ACTION = 'clubhouse_create_org';
/**
* Return true if on a page which uses Clubhouse
* @return bool
*/
function is_clubhouse(): bool {
return true; // TODO implement
}
function clubhouse_can_run(): bool {
return function_exists('is_yuzu');
}
register_activation_hook(__FILE__, function() {
if (!clubhouse_can_run()) {
wp_die('Missing required dependencies for Clubhouse.');
}
});
add_action('admin_notices', function() {
if (!clubhouse_can_run()) {
yz_notice([
'variant' => 'error',
'title' => __('Missing Dependencies', CLUBHOUSE_TEXT_DOMAIN),
'content' => function() {
yz_text(__('Some plugin dependencies are missing for <em>Clubhouse</em>', CLUBHOUSE_TEXT_DOMAIN));
yz_text(__('Please consult the documentation for more information.', CLUBHOUSE_TEXT_DOMAIN));
}
]);
}
});
add_action('admin_menu', function() {
if (clubhouse_can_run()) {
require_once plugin_dir_path(__FILE__) . 'pages/index-page.php';
yz_add_menu_separator(50.1);
yz_add_page([
'position' => 50.2,
'icon' => yz_icon_svg(['glyph' => 'feather', 'appearance' => 'fill']),
'title' => __('Clubhouse', CLUBHOUSE_COURSES_TEXT_DOMAIN),
'slug' => 'clubhouse',
'capability' => 'manage_options',
'content' => function() {
clubhouse_render_index_styles();
clubhouse_render_index_page();
}
]);
}
});
add_action('admin_init', function(): void {
if (clubhouse_can_run()) {
require_once plugin_dir_path(__FILE__) . 'post-types/club-org.php';
require_once plugin_dir_path(__FILE__) . 'post-types/club-member.php';
if (function_exists('is_woocommerce')) {
require_once plugin_dir_path(__FILE__) . 'integrations/woocommerce/woocommerce.php';
}
clubhouse_register_org();
clubpress_register_member();
yz_intercept_form(CLUBHOUSE_CREATE_ORG_ACTION, function(array $data) {
// TODO implement
});
do_action('clubhouse_init');
}
});
add_action('woocommerce_init', function() {
if (clubhouse_can_run()) {
require_once plugin_dir_path(__FILE__) . 'integrations/woocommerce/woocommerce.php';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment