Skip to content

Commit

Permalink
feat: UI Switching & Import Settings Refactoring
Browse files Browse the repository at this point in the history
See Issue Settings Option To Switch User Interface #368
  • Loading branch information
kiyote33 committed Mar 21, 2022
1 parent 9bf8814 commit c733924
Show file tree
Hide file tree
Showing 8 changed files with 1,172 additions and 877 deletions.
2 changes: 1 addition & 1 deletion 12-step-meeting-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: 12 Step Meeting List
* Plugin URI: https://wordpress.org/plugins/12-step-meeting-list/
* Description: Manage a list of recovery meetings
* Version: 3.13
* Version: 3.14
* Requires PHP: 5.6
* Author: Code for Recovery
* Author URI: https://github.com/code4recovery/12-step-meeting-list
Expand Down
Binary file added assets/img/code4recovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,963 changes: 1,089 additions & 874 deletions includes/admin_import.php

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions includes/admin_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,16 @@ function tsml_fix_highlight($parent_file)
}
add_filter('parent_file', 'tsml_fix_highlight');
});

// Add a Widget to the main WordPress Dashboard Page
add_action('wp_dashboard_setup', 'tsml_dashboard_widgets');
function tsml_dashboard_widgets()
{
global $wp_meta_boxes;

wp_add_dashboard_widget('tsml_help_widget', 'Code for Recovery/12 Step Meeting List(TSML) Plugin', 'tsml_dashboard_help', null, null, 'normal', 'high');
}
function tsml_dashboard_help()
{
echo '<p><a href="https://code4recovery.org/">Code for Recovery</a> ' . __('is a nonprofit organization of volunteer members building technology services for recovery fellowships, such as AA and Al-Anon. If you need help, please join our discussion forum. If you would like to make a tax-deductible contribution, please', '12-step-meeting-list') . ' <a href="https://code4recovery.org/"> ' . __('visit our website', '12-step-meeting-list') . '.</a></p>';
}
12 changes: 11 additions & 1 deletion includes/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@
add_filter('archive_template', 'tsml_archive_template');
function tsml_archive_template($template)
{
global $tsml_user_interface;

if (is_post_type_archive('tsml_meeting')) {
$user_theme_file = get_stylesheet_directory() . '/archive-meetings.php';
if (file_exists($user_theme_file)) {
return $user_theme_file;
}

return dirname(__FILE__) . '/../templates/archive-meetings.php';
if ($tsml_user_interface == 'tsml_ui') {
if (function_exists('wp_is_block_theme') && wp_is_block_theme()) {
return dirname(__FILE__) . '/../templates/archive-tsml-ui-blocks.php';
} else {
return dirname(__FILE__) . '/../templates/archive-tsml-ui-classic.php';
}
} else { // legacy_ui
return dirname(__FILE__) . '/../templates/archive-meetings.php';
}
}
return $template;
}
Expand Down
8 changes: 7 additions & 1 deletion includes/variables.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
$tsml_bounds = get_option('tsml_bounds');

//get the secret cache location
$tsml_cache = '/meetings.json';
if (!$tsml_cache = get_option('tsml_cache')) {
$tsml_cache = '/tsml-cache-' . substr(str_shuffle(md5(microtime())), 0, 10) . '.json';
update_option('tsml_cache', $tsml_cache);
}

// Define attendance options
$tsml_meeting_attendance_options = [
Expand Down Expand Up @@ -100,6 +103,9 @@
//load the geocoding method
$tsml_geocoding_method = get_option('tsml_geocoding_method', 'legacy');

//load the screen user interface choice
$tsml_user_interface = get_option('tsml_user_interface', 'legacy_ui');

/*
unfortunately the google geocoding API is not always perfect. used by tsml_import() and admin.js
find correct coordinates with http://nominatim.openstreetmap.org/ and https://www.latlong.net/
Expand Down
27 changes: 27 additions & 0 deletions templates/archive-tsml-ui-blocks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- USE WITH TSML UI IN A BLOCK THEME -->
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div class="wp-site-blocks">

<?php
echo do_blocks( '<!-- wp:template-part {"slug":"header","theme":"twentytwentytwo","tagName":"header","className":"site-header","layout":{"inherit":true}} /-->' );
//block_header_area();

echo do_shortcode('[tsml_ui]');

//block_footer_area();
echo do_blocks('<!-- wp:template-part {"slug":"footer","theme":"twentytwentytwo","tagName":"footer","className":"site-footer","layout":{"inherit":true}} /-->');

?>

</div>
<?php wp_footer(); ?>
</body>
</html>

24 changes: 24 additions & 0 deletions templates/archive-tsml-ui-classic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- USE WITH TSML UI IN A CLASSIC THEME -->
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<div class="wp-site-blocks">

<?php
get_header();

echo do_shortcode('[tsml_ui]');

get_footer();
?>

</div>
<?php wp_footer(); ?>
</body>
</html>

0 comments on commit c733924

Please sign in to comment.