Initial commit after correcting all Plugin Check errors - including renaming the plugin and all parameters, functions, etc

This commit is contained in:
2025-02-21 22:07:40 +01:00
commit fad1c6c3c6
7 changed files with 834 additions and 0 deletions

View File

@@ -0,0 +1,270 @@
<?php
function my_sanitize_options ($data){
return $data;
}
function out_of_office_for_woo_options_init()
{
add_settings_section(
'out-of-office-for-woo-section', //id of the options section
'Woo Out of Office Settings', //title to be displayed
'', //callback function to be called when opening section
'out-of-office-for-woo' // page on which to display the section, this should be the same as the slug used in add_submenu_page()
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_start_date',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo-woo-start-date', // id of the settings field
'Start Date of the Out of Office', // title
'out_of_office_for_woo_options_cb_start_date', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_end_date',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo-woo-end-date', // id of the settings field
'End Date of the Out of Office', // title
'out_of_office_for_woo_options_cb_end_date', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_title',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo-woo-title', // id of the settings field
'Title for the Out of Office message', // title
'out_of_office_for_woo_options_cb_title', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_message',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_textarea_field',
)
);
add_settings_field(
'ooo-woo-message', // id of the settings field
'Message for the Out of Office', // title
'out_of_office_for_woo_options_cb_message', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_is_active',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo-woo-is-active', // id of the settings field
'How should Out of Office be activated', // title
'out_of_office_for_woo_options_cb_is_active', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_show_in_order_confirmation_email',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo_woo_show_in_order_confirmation_email', // id of the settings field
'Show message in the order confirmation Email', // title
'out_of_office_for_woo_options_cb_show_in_order_confirmation_email', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_show_on_shopping_cart_page',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo_woo_show_on_shopping_cart_page', // id of the settings field
'Show message on the Shopping Cart page', // title
'out_of_office_for_woo_options_cb_show_on_shopping_cart_page', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_show_on_checkout_page',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo_woo_show_on_checkout_page', // id of the settings field
'Show message on the Checkout page', // title
'out_of_office_for_woo_options_cb_show_on_checkout_page', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);
/*register_setting(
'out-of-office-for-woo', //option group ???? check if this should be the slug or the option section id!!!
'ooo_woo_show_top_bar',
array(
'type' => 'string',
'sanitize_callback'=> 'sanitize_text_field',
)
);
add_settings_field(
'ooo_woo_show_top_bar', // id of the settings field
'Show a top bar with the out of office', // title
'out_of_office_for_woo_options_cb_show_top_bar', // callback function
'out-of-office-for-woo', // page on which settings display
'out-of-office-for-woo-section' // section on which to show the settings
);*/
}
function out_of_office_for_woo_options_cb_start_date()
{
$ooo_woo_start_date = get_option( 'ooo_woo_start_date', '' );
?>
<div>
<input id="title" type="date" name="ooo_woo_start_date" value="<?php echo esc_attr( $ooo_woo_start_date);?>">
</div>
<?php
}
function out_of_office_for_woo_options_cb_end_date()
{
$ooo_woo_end_date = get_option( 'ooo_woo_end_date', '' );
?>
<div>
<input id="title" type="date" name="ooo_woo_end_date" value="<?php echo esc_attr($ooo_woo_end_date); ?>">
</div>
<?php
}
function out_of_office_for_woo_options_cb_title()
{
$ooo_woo_title = get_option( 'ooo_woo_title', '' );
?>
<div>
<input id="title" type="text" name="ooo_woo_title" value="<?php echo esc_attr($ooo_woo_title); ?>">
</div>
<?php
}
function out_of_office_for_woo_options_cb_message()
{
$ooo_woo_message = get_option( 'ooo_woo_message', '' );
?>
<div>
<textarea id="title" name="ooo_woo_message" rows="6" cols="80"><?php echo esc_attr($ooo_woo_message); ?></textarea>
<br>
Use <strong><i>[StartDate]</i></strong> and <strong><i>[EndDate]</i></strong> as shortcodes within the text in order to incorporate the actual dates.
<br>
For example: "We are between [StartDate] and [EndDate] on vacation :)"
</div>
<?php
}
function out_of_office_for_woo_options_cb_is_active()
{
$ooo_woo_is_active = get_option( 'ooo_woo_is_active', '' );
//
?>
<div>
<input type="radio" id="title" name="ooo_woo_is_active" value="Automatic" <?php if ($ooo_woo_is_active == "Automatic") {echo('checked');}?>>
<label for="Automatic">Automatic (Out of office will be active only in the period between StartDate and EndDate)</label><br>
<input type="radio" id="title" name="ooo_woo_is_active" value="Active" <?php if ($ooo_woo_is_active == "Active") {echo('checked');}?>>
<label for="Active">Active (Out of office is always active - ON)</label><br>
<input type="radio" id="title" name="ooo_woo_is_active" value="Inactive" <?php if ($ooo_woo_is_active == "Inactive") {echo('checked');}?>>
<label for="Inactive">Inactive (Out of office is inactive - OFF)</label><br>
</div>
<?php
}
function out_of_office_for_woo_options_cb_show_in_order_confirmation_email()
{
$ooo_woo_show_in_order_confirmation_email = get_option( 'ooo_woo_show_in_order_confirmation_email', '' );
//
?>
<div>
<input type="radio" id="title" name="ooo_woo_show_in_order_confirmation_email" value="Yes" <?php if ($ooo_woo_show_in_order_confirmation_email == "Yes") {echo('checked');}?>>
<label for="Yes">Yes</label><br>
<input type="radio" id="title" name="ooo_woo_show_in_order_confirmation_email" value="No" <?php if ($ooo_woo_show_in_order_confirmation_email == "No") {echo('checked');}?>>
<label for="No">No</label><br>
</div>
<?php
}
function out_of_office_for_woo_options_cb_show_on_shopping_cart_page()
{
$ooo_woo_show_on_shopping_cart_page = get_option( 'ooo_woo_show_on_shopping_cart_page', '' );
//
?>
<div>
<input type="radio" id="title" name="ooo_woo_show_on_shopping_cart_page" value="Yes" <?php if ($ooo_woo_show_on_shopping_cart_page == "Yes") {echo('checked');}?>>
<label for="Yes">Yes</label><br>
<input type="radio" id="title" name="ooo_woo_show_on_shopping_cart_page" value="No" <?php if ($ooo_woo_show_on_shopping_cart_page == "No") {echo('checked');}?>>
<label for="No">No</label><br>
</div>
<?php
}
function out_of_office_for_woo_options_cb_show_on_checkout_page()
{
$ooo_woo_show_on_checkout_page = get_option( 'ooo_woo_show_on_checkout_page', '' );
//
?>
<div>
<input type="radio" id="title" name="ooo_woo_show_on_checkout_page" value="Yes" <?php if ($ooo_woo_show_on_checkout_page == "Yes") {echo('checked');}?>>
<label for="Yes">Yes</label><br>
<input type="radio" id="title" name="ooo_woo_show_on_checkout_page" value="No" <?php if ($ooo_woo_show_on_checkout_page == "No") {echo('checked');}?>>
<label for="No">No</label><br>
</div>
<?php
}
/*
function out_of_office_for_woo_options_cb_show_top_bar()
{
$ooo_woo_show_top_bar = get_option( 'ooo_woo_show_top_bar', '' );
//
?>
<div>
<input type="radio" id="title" name="ooo_woo_show_top_bar" value="Yes" <?php if ($ooo_woo_show_top_bar == "Yes") {echo('checked');}?>>
<label for="Yes">Yes</label><br>
<input type="radio" id="title" name="ooo_woo_show_top_bar" value="No" <?php if ($ooo_woo_show_top_bar == "No") {echo('checked');}?>>
<label for="No">No</label><br>
<br>
<strong>Not yet implemented</strong>
</div>
<?php
}
*/
//add_action('admin_init', 'out_of_office_for_woo_options');