Skip to content

Commit

Permalink
Added scheduling plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelpivato committed Jun 1, 2024
1 parent 0606335 commit 2c3989b
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ For more information about Mahoee, visit our [website](https://mahoee.com).
- [Plugins](#plugins)
- [mahoee-tracking](#mahoee-tracking)
- [mahoee-acme](#mahoee-acme)
- [mahoee-scheduling](#mahoee-scheduling)
- [Installation](#installation)
- [Usage](#usage)
- [Contributing](#contributing)
Expand All @@ -34,6 +35,15 @@ For more information about Mahoee, visit our [website](https://mahoee.com).
- Easy integration with your WordPress site
- Enhances site security with SSL/TLS encryption

### mahoee-scheduling

**mahoee-scheduling** will let you define scheduling for your business and let you add scheduling controls in your web site using shortcodes and custom HTML classes.

#### Features:
- Lets you configure business operating schedule
- Provides shortcode to actiate scheduling on a page
- Uses CSS selectors to toggle elements required for scheduling

## Installation

To install any of the plugins, follow these steps:
Expand All @@ -57,6 +67,13 @@ To install any of the plugins, follow these steps:
2. Follow the instructions to configure your Let's Encrypt account.
3. Request a new certificate for your site and the plugin will handle the rest.

### mahoee-scheduling

1. After activating the plugin, go to the plugin settings page in your WordPress admin dashboard.
2. Go do scheduling admin page and set working weekdays and shifts.
3. Add shortcode to your page where you want scheduling to starts.
4. Add CSS elements to the HTML blocks that need to be activated.

## Contributing

We welcome contributions from the community! If you have any suggestions, bug reports, or feature requests, please open an issue on the [GitHub repository](https://github.com/mahoee-labs/wordpress-plugins/issues).
Expand Down
83 changes: 83 additions & 0 deletions mahoee-scheduling/admin/site-settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

function mahoee_scheduling_site_settings_page()
{
if (!current_user_can('manage_options')) {
return;
}

echo '<form method="post" action="options.php">';
settings_fields('mahoee_scheduling');
do_settings_sections('mahoee-scheduling');
submit_button();
echo '</form>';

}

function mahoee_scheduling_register_settings()
{
register_setting('mahoee_scheduling', 'mahoee_scheduling_recurring', ['type' => 'object']);

add_settings_section(
'recurring',
'Agenda Recorrente',
'mahoee_scheduling_recurring_section_callback',
'mahoee-scheduling',
);

add_settings_field(
'weekdays',
'Dias da Semana',
'mahoee_scheduling_recurring_weekdays_callback',
'mahoee-scheduling',
'recurring'
);

add_settings_field(
'shifts',
'Turnos nesses Dias',
'mahoee_scheduling_recurring_shifts_callback',
'mahoee-scheduling',
'recurring'
);
}
add_action('admin_init', 'mahoee_scheduling_register_settings');

function mahoee_scheduling_recurring_section_callback()
{
echo 'Informe quais dias da semana você opera consistentemente com os turnos selecionado.';
}

function mahoee_scheduling_recurring_weekdays_callback()
{
$options = get_option('mahoee_scheduling_recurring');
$weekdays = isset($options['weekdays']) ? $options['weekdays'] : [];
$days = [
0 => 'Domingo',
1 => 'Segunda-feira',
2 => 'Terça-feira',
3 => 'Quarta-feira',
4 => 'Quinta-feira',
5 => 'Sexta-feira',
6 => 'Sábado',
];

foreach ($days as $value => $day) {
echo '<label><input type="checkbox" name="mahoee_scheduling_recurring[weekdays][]" value="' . $value . '" ' . (in_array($value, $weekdays) ? 'checked' : '') . '> ' . $day . '</label><br>';
}
}

function mahoee_scheduling_recurring_shifts_callback()
{
$options = get_option('mahoee_scheduling_recurring');
$shifts = isset($options['shifts']) ? $options['shifts'] : [];
$days = [
0 => 'Manhã',
1 => 'Tarde',
2 => 'Noite',
];

foreach ($days as $value => $shift) {
echo '<label><input type="checkbox" name="mahoee_scheduling_recurring[shifts][]" value="' . $value . '" ' . (in_array($value, $shifts) ? 'checked' : '') . '> ' . $shift . '</label><br>';
}
}
1 change: 1 addition & 0 deletions mahoee-scheduling/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
18 changes: 18 additions & 0 deletions mahoee-scheduling/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions mahoee-scheduling/mahoee-scheduling.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/*
Plugin Name: Mahoee Scheduling
Plugin URI: https://github.com/mahoee-labs/wordpress-plugins/
Author: Mahoee
Author URI: http://mahoee.com/
Description: Manage Let's Encrypt certificates for a multisite network.
Version: 0.1.0
License: MIT License
License URI: https://opensource.org/licenses/MIT
Text Domain: mahoee-scheduling
*/

if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}

require_once __DIR__ . '/vendor/autoload.php';

define('MAHOEE_SCHEDULING_PLUGIN_DIR', plugin_dir_path(__FILE__));

require_once MAHOEE_SCHEDULING_PLUGIN_DIR . 'admin/site-settings.php';

// Site admin menu
function mahoee_scheduling_site_menu()
{
add_menu_page(
'Agendamentos desse Site',
'Agendamentos',
'manage_options',
'mahoee-scheduling',
'mahoee_scheduling_site_settings_page',
'dashicons-schedule',
31
);
}
add_action('admin_menu', 'mahoee_scheduling_site_menu');

0 comments on commit 2c3989b

Please sign in to comment.