commit 5fcbce164780a408069d900687bd67e2893d4619 Author: Alen Kolarić Date: Fri Mar 17 13:37:11 2023 +0100 initial plugin commit diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..0819797 --- /dev/null +++ b/README.txt @@ -0,0 +1,114 @@ +=== Plugin Name === +Contributors: (this should be a list of wordpress.org userid's) +Donate link: https://kolarix.com/biztime +Tags: comments, spam +Requires at least: 3.0.1 +Tested up to: 3.4 +Stable tag: 4.3 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +Here is a short description of the plugin. This should be no more than 150 characters. No markup here. + +== Description == + +This is the long description. No limit, and you can use Markdown (as well as in the following sections). + +For backwards compatibility, if this section is missing, the full length of the short description will be used, and +Markdown parsed. + +A few notes about the sections above: + +* "Contributors" is a comma separated list of wp.org/wp-plugins.org usernames +* "Tags" is a comma separated list of tags that apply to the plugin +* "Requires at least" is the lowest version that the plugin will work on +* "Tested up to" is the highest version that you've *successfully used to test the plugin*. Note that it might work on +higher versions... this is just the highest one you've verified. +* Stable tag should indicate the Subversion "tag" of the latest stable version, or "trunk," if you use `/trunk/` for +stable. + + Note that the `readme.txt` of the stable tag is the one that is considered the defining one for the plugin, so +if the `/trunk/readme.txt` file says that the stable tag is `4.3`, then it is `/tags/4.3/readme.txt` that'll be used +for displaying information about the plugin. In this situation, the only thing considered from the trunk `readme.txt` +is the stable tag pointer. Thus, if you develop in trunk, you can update the trunk `readme.txt` to reflect changes in +your in-development version, without having that information incorrectly disclosed about the current stable version +that lacks those changes -- as long as the trunk's `readme.txt` points to the correct stable tag. + + If no stable tag is provided, it is assumed that trunk is stable, but you should specify "trunk" if that's where +you put the stable version, in order to eliminate any doubt. + +== Installation == + +This section describes how to install the plugin and get it working. + +e.g. + +1. Upload `biztime.php` to the `/wp-content/plugins/` directory +1. Activate the plugin through the 'Plugins' menu in WordPress +1. Place `` in your templates + +== Frequently Asked Questions == + += A question that someone might have = + +An answer to that question. + += What about foo bar? = + +Answer to foo bar dilemma. + +== Screenshots == + +1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from +the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets +directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png` +(or jpg, jpeg, gif). +2. This is the second screen shot + +== Changelog == + += 1.0 = +* A change since the previous version. +* Another change. + += 0.5 = +* List versions from most recent at top to oldest at bottom. + +== Upgrade Notice == + += 1.0 = +Upgrade notices describe the reason a user should upgrade. No more than 300 characters. + += 0.5 = +This version fixes a security related bug. Upgrade immediately. + +== Arbitrary section == + +You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated +plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or +"installation." Arbitrary sections will be shown below the built-in sections outlined above. + +== A brief Markdown Example == + +Ordered list: + +1. Some feature +1. Another feature +1. Something else about the plugin + +Unordered list: + +* something +* something else +* third thing + +Here's a link to [WordPress](http://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax]. +Titles are optional, naturally. + +[markdown syntax]: http://daringfireball.net/projects/markdown/syntax + "Markdown is what the parser uses to process much of the readme file" + +Markdown uses email style notation for blockquotes and I've been told: +> Asterisks for *emphasis*. Double it up for **strong**. + +`` \ No newline at end of file diff --git a/admin/class-biztime-admin.php b/admin/class-biztime-admin.php new file mode 100644 index 0000000..db6b19d --- /dev/null +++ b/admin/class-biztime-admin.php @@ -0,0 +1,358 @@ + + */ +class Biztime_Admin { + + /** + * The ID of this plugin. + * + * @since 1.0.0 + * @access private + * @var string $plugin_name The ID of this plugin. + */ + private $plugin_name; + + /** + * The version of this plugin. + * + * @since 1.0.0 + * @access private + * @var string $version The current version of this plugin. + */ + private $version; + + /** + * Initialize the class and set its properties. + * + * @since 1.0.0 + * @param string $plugin_name The name of this plugin. + * @param string $version The version of this plugin. + */ + public function __construct( $plugin_name, $version ) { + + $this->plugin_name = $plugin_name; + $this->version = $version; + + } + + /** + * Register the stylesheets for the admin area. + * + * @since 1.0.0 + */ + public function enqueue_styles() { + + /** + * This function is provided for demonstration purposes only. + * + * An instance of this class should be passed to the run() function + * defined in Biztime_Loader as all of the hooks are defined + * in that particular class. + * + * The Biztime_Loader will then create the relationship + * between the defined hooks and the functions defined in this + * class. + */ + + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/biztime-admin.css', array(), $this->version, 'all' ); + wp_enqueue_style( $this->plugin_name . '-timepicker', plugin_dir_url( __FILE__ ) . 'css/timepicker.min.css', array(), $this->version, 'all' ); + + } + + /** + * Register the JavaScript for the admin area. + * + * @since 1.0.0 + */ + public function enqueue_scripts() { + + /** + * This function is provided for demonstration purposes only. + * + * An instance of this class should be passed to the run() function + * defined in Biztime_Loader as all of the hooks are defined + * in that particular class. + * + * The Biztime_Loader will then create the relationship + * between the defined hooks and the functions defined in this + * class. + */ + + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/biztime-admin.js', array( 'jquery' ), $this->version, false ); + wp_enqueue_script( $this->plugin_name . '-timepicker', plugin_dir_url( __FILE__ ) . 'js/timepicker.min.js', array( 'jquery' ), $this->version, false ); + + } + + /** + * Register the settings page for the admin area. + * + * @since 1.0.0 + */ + public function register_settings_page() { + + add_submenu_page( + 'options-general.php', + __( 'Biztime', 'biztime' ), + __( 'Biztime', 'biztime' ), + 'manage_options', + 'biztime', + array( $this, 'display_settings_page' ) + ); + } + + /** + * Display the settings page content for the page we have created. + * + * @since 1.0.0 + */ + public function display_settings_page() { + + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/biztime-admin-display.php'; + + } + + /** + * Register the settings for our settings page. + * + * @since 1.0.0 + */ + public function register_settings() { + + register_setting( + $this->plugin_name . '-availability', + $this->plugin_name . '-availability', + array( $this, 'biztime_register_availability' ) + ); + + add_settings_section( + $this->plugin_name . '-availability-section', + __('Availability', 'biztime' ), + array( $this, 'biztime_add_availability_section' ), + $this->plugin_name . '-availability' + ); + + $days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); + + foreach ( $days as $day ) { + add_settings_field( + $day, + __( ucfirst( $day ), 'biztime' ), + array( $this, 'biztime_add_availability_fields' ), + $this->plugin_name . '-availability', + $this->plugin_name . '-availability-section', + array( + 'label_for' => $day, + 'description' => __( 'Available', 'biztime' ) + ) + ); + }; + + add_settings_field( + 'phone-number', + __( 'Phone number', 'biztime' ), + array( $this, 'biztime_add_availability_input' ), + $this->plugin_name . '-availability', + $this->plugin_name . '-availability-section', + array( + 'label_for' => 'phone-number', + 'description' => __('Number to be shown in modal', 'biztime' ), + 'default' => __( '+01 123 4567', 'biztime' ) + ) + ); + + add_settings_field( + 'true-msg', + __( 'Message when available', 'biztime' ), + array( $this, 'biztime_add_availability_textarea' ), + $this->plugin_name . '-availability', + $this->plugin_name . '-availability-section', + array( + 'label_for' => 'true-msg', + 'description' => __('Message to be displayed when user visits page during available hours', 'biztime' ), + 'default' => __( 'We are open!', 'biztime' ) + ) + ); + + add_settings_field( + 'false-msg', + __( 'Message when not available', 'biztime' ), + array( $this, 'biztime_add_availability_textarea' ), + $this->plugin_name . '-availability', + $this->plugin_name . '-availability-section', + array( + 'label_for' => 'false-msg', + 'description' => __('Message to be displayed when user visits page during unavailable hours', 'biztime' ), + 'default' => __( 'We are currently closed!', 'biztime' ) + ) + ); + + add_settings_field( + 'show-next', + __( 'Next available day', 'biztime' ), + array( $this, 'biztime_add_availability_checkbox' ), + $this->plugin_name . '-availability', + $this->plugin_name . '-availability-section', + array( + 'label_for' => 'show-next', + 'description' => __('Show the next available day?', 'biztime' ) + ) + ); + + + add_settings_field( + 'next-msg', + __( 'Next available day message', 'biztime' ), + array( $this, 'biztime_add_availability_textarea' ), + $this->plugin_name . '-availability', + $this->plugin_name . '-availability-section', + array( + 'label_for' => 'next-msg', + 'description' => __('Message to be displayed with the next available day', 'biztime' ), + 'default' => __( 'We are back in business on:', 'biztime' ) + ) + ); + } + + + /** + * Section for the settings. + * + * @since 1.0.0 + */ + public function biztime_add_availability_section() { + + return; + + } + + /** + * Availability fields, checkbox and two inputs with timepicker. + * + * @since 1.0.0 + */ + public function biztime_add_availability_fields( $args ) { + + $field_id = $args['label_for']; + $options = get_option( $this->plugin_name . '-availability', array(), 'no' ); + $to = ''; + $from = ''; + + if ( !empty( $options[$field_id]['check'] ) ) { + $to = !empty( $options[$field_id]['to'] ) ? esc_attr( $options[$field_id]['to'] ) : ''; + $from = !empty( $options[$field_id]['from'] ) ? esc_attr( $options[$field_id]['from'] ) : ''; + } + ?> + + /> + + + + + + plugin_name . '-availability', array(), 'no' ); + $option = $field_default; + + if ( ! empty( $options[ $field_id ] ) ) { + + $option = $options[ $field_id ]; + + } + + ?> + + +

+ + plugin_name . '-availability', array(), 'no' ); + $option = $field_default; + + if ( ! empty( $options[ $field_id ] ) ) { + + $option = $options[ $field_id ]; + + } + + ?> + + +

+ + plugin_name . '-availability', array(), 'no' ); + $option = isset( $options[ $field_id ] ) ? $options[ $field_id ] : 0; + ?> + + + + ").addClass("ui-timepicker-container").addClass("ui-timepicker-hidden ui-helper-hidden").appendTo("body").hide(),t.ui=e("
").addClass("ui-timepicker").addClass("ui-widget ui-widget-content ui-menu").addClass("ui-corner-all").appendTo(t.container),t.viewport=e("").addClass("ui-timepicker-viewport").appendTo(t.ui),e.fn.jquery>="1.4.2"&&t.ui.delegate("a","mouseenter.timepicker",function(){t.activate(!1,e(this).parent())}).delegate("a","mouseleave.timepicker",function(){t.deactivate(!1)}).delegate("a","click.timepicker",function(i){i.preventDefault(),t.select(!1,e(this).parent())}))},e.TimePicker.count=0,e.TimePicker.instance=function(){return e.TimePicker._instance||(e.TimePicker._instance=new e.TimePicker),e.TimePicker._instance},e.TimePicker.prototype={keyCode:{ALT:18,BLOQ_MAYUS:20,CTRL:17,DOWN:40,END:35,ENTER:13,HOME:36,LEFT:37,NUMPAD_ENTER:108,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,SHIFT:16,TAB:9,UP:38},_items:function(t,i){var r,a,o=this,s=e(""),c=null;for(-1===t.options.timeFormat.indexOf("m")&&t.options.interval%60!==0&&(t.options.interval=60*Math.max(Math.round(t.options.interval/60),1)),r=i?n(i):t.options.startTime?n(t.options.startTime):n(t.options.startHour,t.options.startMinutes),a=new Date(r.getTime()+864e5);a>r;)o._isValidTime(t,r)&&(c=e("
  • ").addClass("ui-menu-item").appendTo(s),e("").addClass("ui-corner-all").text(e.fn.timepicker.formatTime(t.options.timeFormat,r)).appendTo(c),c.data("time-value",r)),r=new Date(r.getTime()+60*t.options.interval*1e3);return s.children()},_isValidTime:function(e,t){var i=null,r=null;return t=n(t),null!==e.options.minTime?i=n(e.options.minTime):null===e.options.minHour&&null===e.options.minMinutes||(i=n(e.options.minHour,e.options.minMinutes)),null!==e.options.maxTime?r=n(e.options.maxTime):null===e.options.maxHour&&null===e.options.maxMinutes||(r=n(e.options.maxHour,e.options.maxMinutes)),null!==i&&null!==r?t>=i&&r>=t:null!==i?t>=i:null!==r?r>=t:!0},_hasScroll:function(){var e="undefined"!=typeof this.ui.prop?"prop":"attr";return this.ui.height()r?i.ui.scrollTop(a+r):r>=o&&i.ui.scrollTop(a+r-o+t.height())}i.active=t.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-item").end()}},deactivate:function(){var e=this;e.active&&(e.active.children("a").removeClass("ui-state-hover").removeAttr("id"),e.active=null)},next:function(e){return(this.closed()||this.instance===e)&&this._move(e,"next",".ui-menu-item:first"),e.element},previous:function(e){return(this.closed()||this.instance===e)&&this._move(e,"prev",".ui-menu-item:last"),e.element},first:function(e){return this.instance===e?this.active&&0===this.active.prevAll(".ui-menu-item").length:!1},last:function(e){return this.instance===e?this.active&&0===this.active.nextAll(".ui-menu-item").length:!1},selected:function(e){return this.instance===e&&this.active?this.active:null},open:function(t){var n=this,r=t.getTime(),a=t.options.dynamic&&r;if(!t.options.dropdown)return t.element;switch(t.element.data("timepicker-event-namespace",Math.random()),e(i).bind("click.timepicker-"+t.element.data("timepicker-event-namespace"),function(e){t.element.get(0)===e.target?t.element.data("timepicker-user-clicked-outside",!1):t.element.data("timepicker-user-clicked-outside",!0).blur()}),(t.rebuild||!t.items||a)&&(t.items=n._items(t,a?r:null)),(t.rebuild||n.instance!==t||a)&&(e.fn.jquery<"1.4.2"?(n.viewport.children().remove(),n.viewport.append(t.items),n.viewport.find("a").bind("mouseover.timepicker",function(){n.activate(t,e(this).parent())}).bind("mouseout.timepicker",function(){n.deactivate(t)}).bind("click.timepicker",function(i){i.preventDefault(),n.select(t,e(this).parent())})):(n.viewport.children().detach(),n.viewport.append(t.items))),t.rebuild=!1,n.container.removeClass("ui-helper-hidden ui-timepicker-hidden ui-timepicker-standard ui-timepicker-corners").show(),t.options.theme){case"standard":n.container.addClass("ui-timepicker-standard");break;case"standard-rounded-corners":n.container.addClass("ui-timepicker-standard ui-timepicker-corners")}n.container.hasClass("ui-timepicker-no-scrollbar")||t.options.scrollbar||(n.container.addClass("ui-timepicker-no-scrollbar"),n.viewport.css({paddingRight:40}));var o=n.container.outerHeight()-n.container.height(),s=t.options.zindex?t.options.zindex:t.element.offsetParent().css("z-index"),c=t.element.offset();n.container.css({top:c.top+t.element.outerHeight(),left:c.left}),n.container.show(),n.container.css({left:t.element.offset().left,height:n.ui.outerHeight()+o,width:t.element.outerWidth(),zIndex:s,cursor:"default"});var u=n.container.width()-(n.ui.outerWidth()-n.ui.width());return n.ui.css({width:u}),n.viewport.css({width:u}),t.items.css({width:u}),n.instance=t,r?t.items.each(function(){var i,a=e(this);return i=e.fn.jquery<"1.4.2"?e.fn.timepicker.parseTime(a.find("a").text()):a.data("time-value"),i.getTime()===r.getTime()?(n.activate(t,a),!1):!0}):n.deactivate(t),t.element},close:function(t){var n=this;return n.instance===t&&(n.container.addClass("ui-helper-hidden ui-timepicker-hidden").hide(),n.ui.scrollTop(0),n.ui.children().removeClass("ui-state-hover")),e(i).unbind("click.timepicker-"+t.element.data("timepicker-event-namespace")),t.element},closed:function(){return this.ui.is(":hidden")},destroy:function(e){var t=this;return t.close(e,!0),e.element.unbind(".timepicker").data("TimePicker",null)},parse:function(t,i){return e.fn.timepicker.parseTime(i)},format:function(t,i,n){return n=n||t.options.timeFormat,e.fn.timepicker.formatTime(n,i)},getTime:function(t){var i=this,n=e.fn.timepicker.parseTime(t.element.val());return n instanceof Date&&!i._isValidTime(t,n)?null:n instanceof Date&&t.selectedTime?t.format(n)===t.format(t.selectedTime)?t.selectedTime:n:n instanceof Date?n:null},setTime:function(t,i,r){var a=this,o=t.selectedTime;if("string"==typeof i&&(i=t.parse(i)),i&&i.getMinutes&&a._isValidTime(t,i)){if(i=n(i),t.selectedTime=i,t.element.val(t.format(i,t.options.timeFormat)),r)return t}else t.selectedTime=null;return null===o&&null===t.selectedTime||(t.element.trigger("time-change",[i]),e.isFunction(t.options.change)&&t.options.change.apply(t.element,[i])),t.element},option:function(t,i,n){if("undefined"==typeof n)return t.options[i];var r,a,o=t.getTime();"string"==typeof i?(r={},r[i]=n):r=i,a=["minHour","minMinutes","minTime","maxHour","maxMinutes","maxTime","startHour","startMinutes","startTime","timeFormat","interval","dropdown"],e.each(r,function(i){t.options[i]=r[i],t.rebuild=t.rebuild||e.inArray(i,a)>-1}),t.rebuild&&t.setTime(o)}},e.TimePicker.defaults={timeFormat:"hh:mm p",minHour:null,minMinutes:null,minTime:null,maxHour:null,maxMinutes:null,maxTime:null,startHour:null,startMinutes:null,startTime:null,interval:30,dynamic:!0,theme:"standard",zindex:null,dropdown:!0,scrollbar:!1,change:function(){}},e.TimePicker.methods={chainable:["next","previous","open","close","destroy","setTime"]},e.fn.timepicker=function(t){if("string"==typeof t){var i,n,r=Array.prototype.slice.call(arguments,1);return i="option"===t&&arguments.length>2?"each":-1!==e.inArray(t,e.TimePicker.methods.chainable)?"each":"map",n=this[i](function(){var i=e(this),n=i.data("TimePicker");return"object"==typeof n?n[t].apply(n,r):void 0}),"map"===i&&1===this.length?e.makeArray(n).shift():"map"===i?e.makeArray(n):n}if(1===this.length&&this.data("TimePicker"))return this.data("TimePicker");var a=e.extend({},e.TimePicker.defaults,t);return this.each(function(){e.TimePicker.instance().register(this,a)})},e.fn.timepicker.formatTime=function(e,i){var n=i.getHours(),r=n%12,a=i.getMinutes(),o=i.getSeconds(),s={hh:t((0===r?12:r).toString(),"0",2),HH:t(n.toString(),"0",2),mm:t(a.toString(),"0",2),ss:t(o.toString(),"0",2),h:0===r?12:r,H:n,m:a,s:o,p:n>11?"PM":"AM"},c=e,u="";for(u in s)s.hasOwnProperty(u)&&(c=c.replace(new RegExp(u,"g"),s[u]));return c=c.replace(new RegExp("a","g"),n>11?"pm":"am")},e.fn.timepicker.parseTime=function(){var t=[[/^(\d+)$/,"$1"],[/^:(\d)$/,"$10"],[/^:(\d+)/,"$1"],[/^(\d):([7-9])$/,"0$10$2"],[/^(\d):(\d\d)$/,"$1$2"],[/^(\d):(\d{1,})$/,"0$1$20"],[/^(\d\d):([7-9])$/,"$10$2"],[/^(\d\d):(\d)$/,"$1$20"],[/^(\d\d):(\d*)$/,"$1$2"],[/^(\d{3,}):(\d)$/,"$10$2"],[/^(\d{3,}):(\d{2,})/,"$1$2"],[/^(\d):(\d):(\d)$/,"0$10$20$3"],[/^(\d{1,2}):(\d):(\d\d)/,"$10$2$3"]],i=t.length;return function(r){var a=n(new Date),o=!1,s=!1,c=!1,u=!1,l=!1;if("undefined"==typeof r||!r.toLowerCase)return null;r=r.toLowerCase(),o=/a/.test(r),s=o?!1:/p/.test(r),r=r.replace(/[^0-9:]/g,"").replace(/:+/g,":");for(var m=0;i>m;m+=1)if(t[m][0].test(r)){r=r.replace(t[m][0],t[m][1]);break}return r=r.replace(/:/g,""),1===r.length?c=r:2===r.length?c=r:3===r.length||5===r.length?(c=r.substr(0,1),u=r.substr(1,2),l=r.substr(3,2)):(4===r.length||r.length>5)&&(c=r.substr(0,2),u=r.substr(2,2),l=r.substr(4,2)),r.length>0&&r.length<5&&(r.length<3&&(u=0),l=0),c===!1||u===!1||l===!1?!1:(c=parseInt(c,10),u=parseInt(u,10),l=parseInt(l,10),o&&12===c?c=0:s&&12>c&&(c+=12),c>24?r.length>=6?e.fn.timepicker.parseTime(r.substr(0,5)):e.fn.timepicker.parseTime(r+"0"+(o?"a":"")+(s?"p":"")):(a.setHours(c,u,l),a))}}()}()}); \ No newline at end of file diff --git a/admin/partials/biztime-admin-display.php b/admin/partials/biztime-admin-display.php new file mode 100644 index 0000000..84b8522 --- /dev/null +++ b/admin/partials/biztime-admin-display.php @@ -0,0 +1,38 @@ + + + + +
    +
    + +
    +
    + diff --git a/biztime.php b/biztime.php new file mode 100644 index 0000000..6086e02 --- /dev/null +++ b/biztime.php @@ -0,0 +1,82 @@ +run(); + +} +run_biztime(); diff --git a/includes/class-biztime-activator.php b/includes/class-biztime-activator.php new file mode 100644 index 0000000..3b0e89a --- /dev/null +++ b/includes/class-biztime-activator.php @@ -0,0 +1,36 @@ + + */ +class Biztime_Activator { + + /** + * Short Description. (use period) + * + * Long Description. + * + * @since 1.0.0 + */ + public static function activate() { + + } + +} diff --git a/includes/class-biztime-deactivator.php b/includes/class-biztime-deactivator.php new file mode 100644 index 0000000..1c26d02 --- /dev/null +++ b/includes/class-biztime-deactivator.php @@ -0,0 +1,36 @@ + + */ +class Biztime_Deactivator { + + /** + * Short Description. (use period) + * + * Long Description. + * + * @since 1.0.0 + */ + public static function deactivate() { + + } + +} diff --git a/includes/class-biztime-i18n.php b/includes/class-biztime-i18n.php new file mode 100644 index 0000000..d22b0e2 --- /dev/null +++ b/includes/class-biztime-i18n.php @@ -0,0 +1,47 @@ + + */ +class Biztime_i18n { + + + /** + * Load the plugin text domain for translation. + * + * @since 1.0.0 + */ + public function load_plugin_textdomain() { + + load_plugin_textdomain( + 'biztime', + false, + dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' + ); + + } + + + +} diff --git a/includes/class-biztime-loader.php b/includes/class-biztime-loader.php new file mode 100644 index 0000000..23e742c --- /dev/null +++ b/includes/class-biztime-loader.php @@ -0,0 +1,157 @@ + + */ +class Biztime_Loader { + + /** + * The array of actions registered with WordPress. + * + * @since 1.0.0 + * @access protected + * @var array $actions The actions registered with WordPress to fire when the plugin loads. + */ + protected $actions; + + /** + * The array of filters registered with WordPress. + * + * @since 1.0.0 + * @access protected + * @var array $filters The filters registered with WordPress to fire when the plugin loads. + */ + protected $filters; + + /** + * The array of shortcodes registered with WordPress. + * + * @since 1.0.0 + * @access protected + * @var array $shortcodes The shortcodes registered with WordPress to fire when the plugin loads. + */ + protected $shortcodes; + + /** + * Initialize the collections used to maintain the actions and filters. + * + * @since 1.0.0 + */ + public function __construct() { + + $this->actions = array(); + $this->filters = array(); + $this->shortcodes = array(); + + } + + /** + * Add a new action to the collection to be registered with WordPress. + * + * @since 1.0.0 + * @param string $hook The name of the WordPress action that is being registered. + * @param object $component A reference to the instance of the object on which the action is defined. + * @param string $callback The name of the function definition on the $component. + * @param int $priority Optional. The priority at which the function should be fired. Default is 10. + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. + */ + public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { + $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); + } + + /** + * Add a new filter to the collection to be registered with WordPress. + * + * @since 1.0.0 + * @param string $hook The name of the WordPress filter that is being registered. + * @param object $component A reference to the instance of the object on which the filter is defined. + * @param string $callback The name of the function definition on the $component. + * @param int $priority Optional. The priority at which the function should be fired. Default is 10. + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 + */ + public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { + $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); + } + + /** + * Add a new shortcode to the collection to be registered with WordPress. + * + * @since 1.0.0 + * @param string $hook The name of the WordPress shortcode that is being registered. + * @param object $component A reference to the instance of the object on which the shortcode is defined. + * @param string $callback The name of the function definition on the $component. + * @param int $priority Optional. he priority at which the function should be fired. Default is 10. + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 + */ + public function add_shortcode( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { + $this->shortcodes = $this->add( $this->shortcodes, $hook, $component, $callback, $priority, $accepted_args ); + } + + /** + * A utility function that is used to register the actions and hooks into a single + * collection. + * + * @since 1.0.0 + * @access private + * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). + * @param string $hook The name of the WordPress filter that is being registered. + * @param object $component A reference to the instance of the object on which the filter is defined. + * @param string $callback The name of the function definition on the $component. + * @param int $priority The priority at which the function should be fired. + * @param int $accepted_args The number of arguments that should be passed to the $callback. + * @return array The collection of actions and filters registered with WordPress. + */ + private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { + + $hooks[] = array( + 'hook' => $hook, + 'component' => $component, + 'callback' => $callback, + 'priority' => $priority, + 'accepted_args' => $accepted_args + ); + + return $hooks; + + } + + /** + * Register the filters and actions with WordPress. + * + * @since 1.0.0 + */ + public function run() { + + foreach ( $this->filters as $hook ) { + add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); + } + + foreach ( $this->actions as $hook ) { + add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); + } + + foreach ( $this->shortcodes as $hook ) { + add_shortcode( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); + } + + } + +} diff --git a/includes/class-biztime.php b/includes/class-biztime.php new file mode 100644 index 0000000..ae87e19 --- /dev/null +++ b/includes/class-biztime.php @@ -0,0 +1,222 @@ + + */ +class Biztime { + + /** + * The loader that's responsible for maintaining and registering all hooks that power + * the plugin. + * + * @since 1.0.0 + * @access protected + * @var Biztime_Loader $loader Maintains and registers all hooks for the plugin. + */ + protected $loader; + + /** + * The unique identifier of this plugin. + * + * @since 1.0.0 + * @access protected + * @var string $plugin_name The string used to uniquely identify this plugin. + */ + protected $plugin_name; + + /** + * The current version of the plugin. + * + * @since 1.0.0 + * @access protected + * @var string $version The current version of the plugin. + */ + protected $version; + + /** + * Define the core functionality of the plugin. + * + * Set the plugin name and the plugin version that can be used throughout the plugin. + * Load the dependencies, define the locale, and set the hooks for the admin area and + * the public-facing side of the site. + * + * @since 1.0.0 + */ + public function __construct() { + if ( defined( 'BIZTIME_VERSION' ) ) { + $this->version = BIZTIME_VERSION; + } else { + $this->version = '1.0.0'; + } + $this->plugin_name = 'biztime'; + + $this->load_dependencies(); + $this->set_locale(); + $this->define_admin_hooks(); + $this->define_public_hooks(); + + } + + /** + * Load the required dependencies for this plugin. + * + * Include the following files that make up the plugin: + * + * - Biztime_Loader. Orchestrates the hooks of the plugin. + * - Biztime_i18n. Defines internationalization functionality. + * - Biztime_Admin. Defines all hooks for the admin area. + * - Biztime_Public. Defines all hooks for the public side of the site. + * + * Create an instance of the loader which will be used to register the hooks + * with WordPress. + * + * @since 1.0.0 + * @access private + */ + private function load_dependencies() { + + /** + * The class responsible for orchestrating the actions and filters of the + * core plugin. + */ + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-biztime-loader.php'; + + /** + * The class responsible for defining internationalization functionality + * of the plugin. + */ + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-biztime-i18n.php'; + + /** + * The class responsible for defining all actions that occur in the admin area. + */ + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-biztime-admin.php'; + + /** + * The class responsible for defining all actions that occur in the public-facing + * side of the site. + */ + require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-biztime-public.php'; + + $this->loader = new Biztime_Loader(); + + } + + /** + * Define the locale for this plugin for internationalization. + * + * Uses the Biztime_i18n class in order to set the domain and to register the hook + * with WordPress. + * + * @since 1.0.0 + * @access private + */ + private function set_locale() { + + $plugin_i18n = new Biztime_i18n(); + + $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); + + } + + /** + * Register all of the hooks related to the admin area functionality + * of the plugin. + * + * @since 1.0.0 + * @access private + */ + private function define_admin_hooks() { + + $plugin_admin = new Biztime_Admin( $this->get_plugin_name(), $this->get_version() ); + + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); + $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); + $this->loader->add_action( 'admin_menu', $plugin_admin, 'register_settings_page' ); + $this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' ); + + } + + /** + * Register all of the hooks related to the public-facing functionality + * of the plugin. + * + * @since 1.0.0 + * @access private + */ + private function define_public_hooks() { + + $plugin_public = new Biztime_Public( $this->get_plugin_name(), $this->get_version() ); + + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); + $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); + $this->loader->add_shortcode( 'biztime_availability_checker', $plugin_public, 'biztime_availability_checker_shortcode' ); + $this->loader->add_shortcode( 'biztime_show_availability', $plugin_public,'biztime_show_availability_shortcode' ); + + } + + /** + * Run the loader to execute all of the hooks with WordPress. + * + * @since 1.0.0 + */ + public function run() { + $this->loader->run(); + } + + /** + * The name of the plugin used to uniquely identify it within the context of + * WordPress and to define internationalization functionality. + * + * @since 1.0.0 + * @return string The name of the plugin. + */ + public function get_plugin_name() { + return $this->plugin_name; + } + + /** + * The reference to the class that orchestrates the hooks with the plugin. + * + * @since 1.0.0 + * @return Biztime_Loader Orchestrates the hooks of the plugin. + */ + public function get_loader() { + return $this->loader; + } + + /** + * Retrieve the version number of the plugin. + * + * @since 1.0.0 + * @return string The version number of the plugin. + */ + public function get_version() { + return $this->version; + } + +} diff --git a/includes/index.php b/includes/index.php new file mode 100644 index 0000000..e71af0e --- /dev/null +++ b/includes/index.php @@ -0,0 +1 @@ + + */ +class Biztime_Public { + + /** + * The ID of this plugin. + * + * @since 1.0.0 + * @access private + * @var string $plugin_name The ID of this plugin. + */ + private $plugin_name; + + /** + * The version of this plugin. + * + * @since 1.0.0 + * @access private + * @var string $version The current version of this plugin. + */ + private $version; + + /** + * Initialize the class and set its properties. + * + * @since 1.0.0 + * @param string $plugin_name The name of the plugin. + * @param string $version The version of this plugin. + */ + public function __construct( $plugin_name, $version ) { + + $this->plugin_name = $plugin_name; + $this->version = $version; + + } + + /** + * Register the stylesheets for the public-facing side of the site. + * + * @since 1.0.0 + */ + public function enqueue_styles() { + + /** + * This function is provided for demonstration purposes only. + * + * An instance of this class should be passed to the run() function + * defined in Biztime_Loader as all of the hooks are defined + * in that particular class. + * + * The Biztime_Loader will then create the relationship + * between the defined hooks and the functions defined in this + * class. + */ + + wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/biztime-public.css', array(), $this->version, 'all' ); + + } + + /** + * Register the JavaScript for the public-facing side of the site. + * + * @since 1.0.0 + */ + public function enqueue_scripts() { + + /** + * This function is provided for demonstration purposes only. + * + * An instance of this class should be passed to the run() function + * defined in Biztime_Loader as all of the hooks are defined + * in that particular class. + * + * The Biztime_Loader will then create the relationship + * between the defined hooks and the functions defined in this + * class. + */ + + wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/biztime-public.js', array( 'jquery' ), $this->version, false ); + + } + + function biztime_availability_checker_shortcode( $atts ) { + $options = get_option( 'biztime-availability', array(), 'no' ); + $days = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); + + ob_start(); + include( plugin_dir_path( __FILE__ ) . 'partials/biztime-modal-public-display.php' ); + $output = ob_get_clean(); + + return $output; + } + + function biztime_show_availability_shortcode() { + $options = get_option( 'biztime-availability', array(), 'no' ); + $days = array( 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); + + ob_start(); + include( plugin_dir_path( __FILE__ ) . 'partials/biztime-availability-public-display.php' ); + $output = ob_get_clean(); + + return $output; + } + + +} diff --git a/public/css/biztime-public.css b/public/css/biztime-public.css new file mode 100644 index 0000000..02465d8 --- /dev/null +++ b/public/css/biztime-public.css @@ -0,0 +1,86 @@ +/** + * All of the CSS for your public-facing functionality should be + * included in this file. + */ + +.modal { + display: none; + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + width: 100%; + max-width: 100%; + margin: 0; + background-color: rgba(0, 0, 0, 0.5); + z-index: 99; +} + +.modal-content { + background-color: #ffffff; + border: 1px solid hsl(230, 11%, 40%); + border-radius: 5px; + box-shadow: 0 0 10px 5px hsl(230, 11%, 40%); + margin: 10% auto; + padding: 30px; + width: 80%; + max-width: 1440px; +} + +.modal-content__wrapper { + text-align: center; +} + +.modal-content__wrapper p { + font-size: 20px; +} + +.modal-content__wrapper .available p { + display: inline-block; + border-bottom: 2px solid hsla(119, 72%, 55%, 0.8); + margin-bottom: 10px; + padding-bottom: 10px; +} + +.modal-content__wrapper .available p span { + font-weight: bold; + font-size: 24px; +} + +.modal-content__wrapper .not-available p{ + display: inline-block; + border-bottom: 2px solid hsla(0, 72.1%, 55.1%, 0.8); + margin-bottom: 10px; + padding-bottom: 10px; +} + +.next-available { + margin-top: 20px; +} + +#close-modal { + cursor: pointer; + float: right; + font-size: 36px; + font-weight: bold; +} + +/* Available hours table */ +.table-availability { + width: 100%; + max-width: 300px; + border-collapse: collapse; + margin: 0 auto; +} + +.table-availability tr:nth-child(odd) { + background: rgba(255, 255, 255, 0.5); +} + +.table-availability td { + text-transform: capitalize; + padding: 5px 10px; + color: #666666; + border-bottom: 1px solid #CCCCCC; +} diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..e71af0e --- /dev/null +++ b/public/index.php @@ -0,0 +1 @@ + + + + + '; + } + ?> +
    ' . $day . '' . $from . '' . $to . '
    + + diff --git a/public/partials/biztime-modal-public-display.php b/public/partials/biztime-modal-public-display.php new file mode 100644 index 0000000..a9e744c --- /dev/null +++ b/public/partials/biztime-modal-public-display.php @@ -0,0 +1,83 @@ + + + + +
    + + +
    + + + diff --git a/uninstall.php b/uninstall.php new file mode 100644 index 0000000..bdda0a1 --- /dev/null +++ b/uninstall.php @@ -0,0 +1,31 @@ +