├── gulpfile.js ├── .gitmodules ├── admin ├── includes │ ├── CMB2 │ │ ├── css │ │ │ └── index.php │ │ ├── index.php │ │ ├── js │ │ │ └── index.php │ │ ├── images │ │ │ ├── index.php │ │ │ ├── ico-delete.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ ├── ui-icons_454545_256x240.png │ │ │ ├── ui-icons_888888_256x240.png │ │ │ ├── ui-icons_cd0a0a_256x240.png │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ ├── includes │ │ │ ├── index.php │ │ │ ├── CMB2_Boxes.php │ │ │ ├── CMB2_Show_Filters.php │ │ │ ├── CMB2_JS.php │ │ │ ├── CMB2_Options.php │ │ │ └── CMB2_Utils.php │ │ ├── languages │ │ │ ├── index.php │ │ │ └── cmb2.mo │ │ ├── bootstrap.php │ │ ├── CONTRIBUTING.md │ │ └── init.php │ ├── index.php │ ├── WP-Admin-Notice │ │ └── WP_Admin_Notice.php │ └── class-admin-table-messages.php ├── index.php ├── assets │ ├── index.php │ ├── css │ │ ├── index.php │ │ ├── datePicker-images │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_2e83ff_256x240.png │ │ │ ├── ui-icons_454545_256x240.png │ │ │ ├── ui-icons_888888_256x240.png │ │ │ ├── ui-icons_cd0a0a_256x240.png │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ ├── user-profile.css │ │ ├── profile-cleanup.css │ │ └── admin.css │ ├── js │ │ ├── index.php │ │ ├── admin.js │ │ ├── datePicker.js │ │ ├── cb-helpers.js │ │ └── tableFilter.js │ └── sass │ │ ├── index.php │ │ └── admin.scss ├── views │ ├── index.php │ └── dashboard.php ├── cb-bookings │ ├── index.php │ ├── views │ │ ├── index.php │ │ └── bookings-table.php │ └── class-cb-bookings-setup.php ├── cb-codes │ ├── index.php │ ├── views │ │ ├── index.php │ │ └── codes-table.php │ ├── includes │ │ ├── index.php │ │ └── class-cb-codes-generate.php │ ├── class-cb-codes-setup.php │ └── class-cb-codes.php ├── cb-items │ ├── index.php │ └── includes │ │ ├── index.php │ │ └── cb-items-metaboxes.php ├── cb-settings │ ├── index.php │ └── views │ │ └── index.php ├── cb-users │ └── index.php ├── cb-locations │ ├── index.php │ └── includes │ │ ├── index.php │ │ └── cb-locations-metaboxes.php ├── cb-timeframes │ ├── index.php │ ├── includes │ │ ├── index.php │ │ └── class-cb-timeframes-list.php │ ├── cb-timeframes.php │ └── cb-timeframes-setup.php ├── cb-mail │ └── class-cb-mail.php └── cb-widgets │ ├── cb-category-widget.php │ ├── cb-user-widget.php │ └── cb-items-widget.php ├── index.php ├── public ├── index.php ├── views │ ├── index.php │ └── public.php ├── assets │ ├── css │ │ ├── index.php │ │ ├── public.css │ │ ├── tooltipster │ │ │ └── tooltipster-light.css │ │ └── profile-cleanup-tml.css │ ├── index.php │ ├── js │ │ ├── index.php │ │ └── comment-length.js │ └── sass │ │ ├── index.php │ │ ├── public.scss │ │ ├── themes │ │ ├── standard │ │ │ ├── standard.scss │ │ │ └── partials │ │ │ │ ├── variables.scss │ │ │ │ ├── bookingbar.scss │ │ │ │ ├── mixins.scss │ │ │ │ ├── calendar.scss │ │ │ │ └── base.scss │ │ └── kasimir │ │ │ ├── kasimir.scss │ │ │ └── partials │ │ │ ├── theme-my-login.scss │ │ │ ├── variables.scss │ │ │ ├── bookingbar.scss │ │ │ ├── mixins.scss │ │ │ ├── calendar.scss │ │ │ └── base.scss │ │ └── profile-cleanup-tml.scss ├── includes │ └── index.php └── cb-bookings │ ├── index.php │ ├── views │ └── index.php │ ├── class-cb-public-items.php │ └── class-cb-booking-comments.php ├── includes ├── index.php ├── CPT_Core │ ├── package.json │ ├── Gruntfile.js │ ├── composer.json │ ├── README.md │ └── languages │ │ └── cpt-core.pot ├── Taxonomy_Core │ ├── package.json │ ├── composer.json │ ├── Gruntfile.js │ ├── README.md │ └── languages │ │ └── taxonomy-core.pot ├── Widgets-Helper │ ├── README.md │ └── widget-sample.php ├── template.php ├── array_column.php └── commons-booking-helpers.php ├── help-docs ├── demo-example.html └── pn_settings.html ├── assets ├── cb-logo.png ├── icon-128x128.png ├── icon-256x256.png ├── screenshot-1.png ├── screenshot-2.png ├── screenshot-3.png ├── screenshot-4.png ├── banner-1544x500.png └── banner-772x250.png ├── languages └── commons-booking-de_DE.mo ├── zipdist.sh ├── templates ├── booking-review-code.php ├── booking-review-booking-comment.php ├── booking-review-cancel.php ├── booking-review-submit.php ├── user-bookings.php ├── item-list-timeframes-compact.php ├── user-bar.php ├── item-list-item.php ├── calendar-bookingbar.php ├── timeframes-full.php └── booking-review.php ├── .gitignore └── commons-booking.php /gulpfile.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /admin/includes/CMB2/css/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin/includes/CMB2/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin/includes/CMB2/js/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin/includes/CMB2/images/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin/includes/CMB2/includes/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 9 |
10 |
11 |
12 | 13 |
14 |
-------------------------------------------------------------------------------- /public/assets/css/profile-cleanup-tml.css: -------------------------------------------------------------------------------- 1 | .tml-profile .tml-user-admin-bar-front-wrap,.tml-profile .tml-nickname-wrap,.tml-profile .tml-display-name-wrap,.tml-profile .tml-user-url-wrap,.tml-profile .tml-user-description-wrap,.tml-profile .tml-user-contact-method-aim-wrap,.tml-profile .tml-user-contact-method-yim-wrap,.tml-profile .tml-user-contact-method-jabber-wrap,.tml-profile h3,.tml-profile h2{display:none} 2 | -------------------------------------------------------------------------------- /admin/assets/js/datePicker.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Date picker for Timeframes edit screen 3 | * 4 | */ 5 | 6 | (function($) { 7 | "use strict"; 8 | 9 | $(function() { 10 | 11 | // set German Localization @TODO 12 | $.datepicker.setDefaults( 13 | $.datepicker.regional["de"] 14 | ); 15 | 16 | $( '.cb-datepicker' ).each(function( ) { 17 | $(this).datepicker( { dateFormat: "yy-mm-dd" } ); 18 | 19 | }); 20 | }); 21 | 22 | }(jQuery)); -------------------------------------------------------------------------------- /admin/views/dashboard.php: -------------------------------------------------------------------------------- 1 | 10 | * @license GPL-2.0+ 11 | * @link http://www.wielebenwir.de 12 | * @copyright 2015 wielebenwir 13 | */ 14 | ?> 15 | 16 |

Nothing here yet

-------------------------------------------------------------------------------- /includes/Taxonomy_Core/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webdevstudios/taxonomy_core", 3 | "description": "A tool to make custom taxonomy registration just a bit simpler. Automatically registers taxonomy labels, and provides helpful methods.", 4 | "license": "GPLv2", 5 | "authors": [ 6 | { 7 | "name": "WebDevStudios", 8 | "email": "contact@webdevstudios.com" 9 | } 10 | ], 11 | "require": {}, 12 | "autoload": { 13 | "files": ["Taxonomy_Core.php"] 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /public/views/public.php: -------------------------------------------------------------------------------- 1 | 10 | * @license GPL-2.0+ 11 | * @link http://www.wielebenwir.de 12 | * @copyright 2015 wielebenwir 13 | */ 14 | ?> 15 | 16 | 17 | -------------------------------------------------------------------------------- /templates/booking-review-booking-comment.php: -------------------------------------------------------------------------------- 1 | 9 |
10 |
11 |
12 | 13 | 14 | 15 | 16 | 17 |
18 |
-------------------------------------------------------------------------------- /admin/includes/WP-Admin-Notice/WP_Admin_Notice.php: -------------------------------------------------------------------------------- 1 | class = $class; 9 | $this->message = $message; 10 | add_action( 'admin_notices', array( $this, 'output' ) ); 11 | add_action( 'network_admin_notices', array( $this, 'output' ) ); 12 | } 13 | 14 | function output(){ 15 | echo '

' . $this->message . '

'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /templates/booking-review-cancel.php: -------------------------------------------------------------------------------- 1 | 9 |
10 | 11 | 12 | 13 | 14 |
15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Numerous always-ignore extensions 2 | *.diff 3 | *.err 4 | *.orig 5 | *.log 6 | *.rej 7 | *.swo 8 | *.swp 9 | *.vi 10 | *~ 11 | *.sass-cache 12 | 13 | # OS or Editor folders 14 | .DS_Store 15 | Thumbs.db 16 | .cache 17 | .project 18 | .settings 19 | .tmproj 20 | *.esproj 21 | nbproject 22 | *.sublime-project 23 | *.sublime-workspace 24 | node_modules 25 | sftp-config.json 26 | 27 | # Dreamweaver added files 28 | _notes 29 | dwsync.xml 30 | 31 | # Komodo 32 | *.komodoproject 33 | .komodotools 34 | 35 | # Folders to ignore 36 | .hg 37 | .svn 38 | .CVS 39 | intermediate 40 | .idea 41 | cache 42 | .nova 43 | -------------------------------------------------------------------------------- /templates/booking-review-submit.php: -------------------------------------------------------------------------------- 1 | 9 |
10 | 11 | 12 | 13 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /public/assets/sass/themes/standard/standard.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard Theme 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.2 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /* Variables: colors, widths, padding */ 12 | @import "partials/variables"; 13 | /* Mixins */ 14 | @import "partials/mixins"; 15 | /* Base styles */ 16 | @import "partials/base"; 17 | /* Calendar styles */ 18 | @import "partials/calendar"; 19 | /* Booking Bar */ 20 | @import "partials/bookingbar"; 21 | /* Tooltips */ 22 | @import "partials/tooltipster"; 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /admin/assets/js/cb-helpers.js: -------------------------------------------------------------------------------- 1 | /* 2 | * JS HELPER FUNCTIONS 3 | * 4 | */ 5 | 6 | /* 7 | * Get Url Parameters in jQuery 8 | * http://www.jquerybyexample.net/2012/06/get-url-parameters-using-jquery.html 9 | * 10 | * Usage: var blog = GetURLParameter('blog'); 11 | * 12 | */ 13 | 14 | function getUrlParameter(sParam) 15 | { 16 | var sPageURL = window.location.search.substring(1); 17 | var sURLVariables = sPageURL.split('&'); 18 | for (var i = 0; i < sURLVariables.length; i++) 19 | { 20 | var sParameterName = sURLVariables[i].split('='); 21 | if (sParameterName[0] == sParam) 22 | { 23 | return sParameterName[1]; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /admin/assets/js/tableFilter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Table Filter for Wordpress Backend Tables 3 | * 4 | */ 5 | 6 | 7 | (function($) { 8 | "use strict"; 9 | 10 | $(function() { 11 | 12 | var page = getUrlParameter('page'); 13 | 14 | // Filters for Admin Table 15 | 16 | $( 'div.tablefilters select' ).each(function( ) { 17 | 18 | $( this ).change(function(){ 19 | var filterID = $(this).val(); 20 | if( filterID != '' ){ 21 | document.location.href = 'admin.php?page='+page+filterID; 22 | } else { 23 | document.location.href = 'admin.php?page='+page; 24 | } 25 | }); 26 | }); 27 | }); 28 | 29 | }(jQuery)); -------------------------------------------------------------------------------- /includes/CPT_Core/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | grunt.initConfig({ 4 | 5 | pkg: grunt.file.readJSON('package.json'), 6 | 7 | makepot: { 8 | target: { 9 | options: { 10 | domainPath: '/languages', 11 | potFileName: 'cpt-core.pot', 12 | mainFile: 'CPT_Core.php', 13 | type: 'wp-plugin' 14 | } 15 | } 16 | }, 17 | 18 | addtextdomain: { 19 | theme: { 20 | options: { 21 | textdomain: 'cpt-core' 22 | }, 23 | target: { 24 | files: { 25 | src: [ '*.php' ] 26 | } 27 | } 28 | }, 29 | } 30 | }); 31 | 32 | grunt.loadNpmTasks( 'grunt-wp-i18n' ); 33 | 34 | grunt.registerTask('default', ['makepot']); 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /includes/Taxonomy_Core/Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(grunt) { 2 | 3 | grunt.initConfig({ 4 | 5 | pkg: grunt.file.readJSON('package.json'), 6 | 7 | makepot: { 8 | target: { 9 | options: { 10 | domainPath: '/languages', 11 | mainFile: 'Taxonomy_Core.php', 12 | potFileName: 'taxonomy-core.pot', 13 | type: 'wp-plugin' 14 | } 15 | } 16 | }, 17 | 18 | addtextdomain: { 19 | theme: { 20 | options: { 21 | textdomain: 'taxonomy-core' 22 | }, 23 | target: { 24 | files: { 25 | src: [ '*.php' ] 26 | } 27 | } 28 | }, 29 | } 30 | }); 31 | 32 | grunt.loadNpmTasks( 'grunt-wp-i18n' ); 33 | 34 | grunt.registerTask('default', ['makepot']); 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /public/assets/sass/themes/kasimir/kasimir.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard Theme 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.2 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /* Variables: colors, widths, padding */ 12 | @import "partials/variables"; 13 | /* Mixins */ 14 | @import "partials/mixins"; 15 | /* Base styles */ 16 | @import "partials/base"; 17 | /* Calendar styles */ 18 | @import "partials/calendar"; 19 | /* Booking Bar */ 20 | @import "partials/bookingbar"; 21 | /* Tooltips */ 22 | @import "partials/tooltipster"; 23 | /* Theme My Login custom styles */ 24 | @import "partials/theme-my-login"; 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /public/assets/sass/profile-cleanup-tml.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Hides options from the user profile screen generated by Theme-My-Login WP Plugin 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /* TML profile */ 12 | .tml-profile { 13 | .tml-user-admin-bar-front-wrap, 14 | .tml-nickname-wrap, 15 | .tml-display-name-wrap, 16 | .tml-user-url-wrap, 17 | .tml-user-description-wrap, 18 | /* User social media messenger */ 19 | .tml-user-contact-method-aim-wrap, 20 | .tml-user-contact-method-yim-wrap, 21 | .tml-user-contact-method-jabber-wrap, 22 | h3, h2 23 | { 24 | display: none; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /admin/assets/css/user-profile.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Hides options from the user profile screen. 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @link http://www.wielebenwir.de 7 | * @copyright 2015 wielebenwir 8 | */ 9 | 10 | 11 | /* standard wordpress profile */ 12 | .admin_head, 13 | .user-rich-editing-wrap, 14 | .user-description-wrap, 15 | .user-admin-color-wrap, 16 | .user-display-name-wrap, 17 | .user-nickname-wrap, 18 | .user-comment-shortcuts-wrap, 19 | .user-admin-color-wrap, 20 | .user-admin-bar-front-wrap, 21 | .user-profile-picture, 22 | .user-sessions-wrap, 23 | .user-url-wrap, 24 | .user-aim-wrap, 25 | .user-yim-wrap, 26 | .user-jabber-wrap, 27 | h3, h2, 28 | #adminmenumain, 29 | #screen-meta-links 30 | { 31 | display: none; 32 | } 33 | -------------------------------------------------------------------------------- /templates/user-bookings.php: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 | 11 | 12 | 13 |
14 | 15 | 16 | - 17 | 18 |
19 | 20 |
21 | -------------------------------------------------------------------------------- /admin/assets/css/profile-cleanup.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Hides options from the user profile screen. 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @link http://www.wielebenwir.de 7 | * @copyright 2015 wielebenwir 8 | */ 9 | 10 | 11 | /* standard wordpress profile */ 12 | #wpadminbar, 13 | .admin_head, 14 | .user-rich-editing-wrap, 15 | .user-description-wrap, 16 | .user-admin-color-wrap, 17 | .user-display-name-wrap, 18 | .user-nickname-wrap, 19 | .user-comment-shortcuts-wrap, 20 | .user-admin-color-wrap, 21 | .user-admin-bar-front-wrap, 22 | .user-profile-picture, 23 | .user-sessions-wrap, 24 | .user-url-wrap, 25 | .user-aim-wrap, 26 | .user-yim-wrap, 27 | .user-jabber-wrap, 28 | h3, h2, 29 | #adminmenumain, 30 | #screen-meta-links, 31 | #wpfooter 32 | { 33 | display: none; 34 | } -------------------------------------------------------------------------------- /includes/CPT_Core/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webdevstudios/cpt-core", 3 | "description": "WordPress Custom Post Type OO wrapper", 4 | "license": "GPLv2", 5 | "authors": [ 6 | { 7 | "name": "WebDevStudios", 8 | "email": "contact@webdevstudios.com", 9 | "homepage": "https://github.com/WebDevStudios", 10 | "role": "Developer" 11 | } 12 | ], 13 | "keywords": ["wordpress", "plugin", "metabox"], 14 | "homepage": "https://github.com/WebDevStudios/CPT_Core", 15 | "type": "wordpress-plugin", 16 | "support": { 17 | "issues": "https://github.com/WebDevStudios/CPT_Core/issues" 18 | }, 19 | "require": {}, 20 | "suggest": { 21 | "composer/installers": "~1.0" 22 | }, 23 | "autoload": { 24 | "files": ["CPT_Core.php"] 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /admin/cb-timeframes/cb-timeframes.php: -------------------------------------------------------------------------------- 1 | 7 | * @license GPL-2.0+ 8 | * @link http://www.wielebenwir.de 9 | * @copyright 2015 wielebenwir 10 | */ 11 | 12 | /** 13 | * Include all necessary files for Timeframes 14 | * 15 | * @author Florian Egermann 16 | */ 17 | 18 | // @TODO Re-Organize. 19 | 20 | // Install 21 | require_once( plugin_dir_path( __FILE__ ) . 'cb-timeframes-setup.php' ); 22 | 23 | // List 24 | require_once( plugin_dir_path( __FILE__ ) . 'cb-timeframes-list.php' ); 25 | 26 | // Edit 27 | require_once( plugin_dir_path( __FILE__ ) . 'cb-timeframes-edit.php' ); 28 | 29 | // Displays the List of Timeframes at Item edit screen 30 | require_once( plugin_dir_path( __FILE__ ) . 'includes/class-cb-timeframes-list.php' ); 31 | 32 | ?> -------------------------------------------------------------------------------- /templates/item-list-timeframes-compact.php: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 | 11 |
12 | 13 | 14 | 15 | 16 |
17 | 18 |
19 | -------------------------------------------------------------------------------- /includes/Widgets-Helper/README.md: -------------------------------------------------------------------------------- 1 | # WordPress Widgets Helper Class 2 | 3 | ## Summary 4 | 5 | A class that extends the built-in WP_Widget class to provide an easier/faster way to create Widgets for WordPress. 6 | 7 | ### Features 8 | 9 | Automatic fields creation 10 | Validation methods 11 | Filter methods 12 | Before/After form output methods 13 | Custom form fields creation 14 | 15 | Check the inline comments and Widget sample for more information. 16 | 17 | ### Roadmap / Wishlist 18 | 19 | More Custom fields 20 | [Widget Logic](http://wordpress.org/extend/plugins/widget-logic/ "Widget Logic") alike functionality 21 | 22 | ### Version 23 | 24 | 1.6 25 | 26 | ### License 27 | 28 | GPLv2 29 | 30 | ### Credits 31 | 32 | by @sksmatt 33 | www.mattvarone.com 34 | 35 | Contributors: 36 | 37 | Joachim Kudish ( @jkudish ) 38 | Joaquin http://bit.ly/p18bOk 39 | markyoungdev http://bit.ly/GK6PwU -------------------------------------------------------------------------------- /templates/user-bar.php: -------------------------------------------------------------------------------- 1 | 8 |
9 | user_firstname); 17 | echo (''); 18 | printf(__('My Bookings ', 'commons-booking' ), $url ); 19 | printf(__('My Profile ', 'commons-booking' ), get_edit_profile_url() ); 20 | printf(__('Logout ', 'commons-booking' ), wp_logout_url( home_url() ) ); 21 | echo (''); 22 | 23 | ?> 24 |
-------------------------------------------------------------------------------- /public/assets/sass/themes/kasimir/partials/theme-my-login.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Forms created by Theme My Login 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | #theme-my-login, #respond { 12 | width: 100%; 13 | max-width: 100%; 14 | @extend .cb-box; 15 | form { 16 | @extend .cb-table; 17 | input#submit { 18 | @extend .cb-button; 19 | background: $highlight-color; 20 | margin-left: 0; 21 | } 22 | } 23 | 24 | p, .g-recaptcha { 25 | @extend .cb-row; 26 | margin-bottom: 1px; 27 | input { 28 | padding: 0.5em 1em; 29 | } 30 | 31 | } 32 | .message { 33 | // @extend .success; 34 | &.error { 35 | } 36 | } 37 | } 38 | 39 | p.message, p.error { 40 | border: none !important; 41 | margin-bottom: $padding !important; 42 | } -------------------------------------------------------------------------------- /admin/includes/class-admin-table-messages.php: -------------------------------------------------------------------------------- 1 | 7 | * @license GPL-2.0+ 8 | * @link http://www.wielebenwir.de 9 | * @copyright 2015 wielebenwir 10 | */ 11 | 12 | /** 13 | * Admin messages 14 | * 15 | * @package Commons Booking Admin Messages 16 | * @author Florian Egermann 17 | */ 18 | 19 | 20 | class Admin_Table_Message { 21 | 22 | public $class = ''; 23 | public $message = ''; 24 | 25 | function __construct( $message, $class = 'updated' ){ 26 | $this->class = $class; 27 | $this->message = $message; 28 | if ( !empty ( $this->message ) ) { 29 | $this->output(); 30 | } 31 | } 32 | 33 | function output(){ 34 | echo '

' . $this->message . '

'; 35 | } 36 | } 37 | ?> -------------------------------------------------------------------------------- /admin/cb-bookings/views/bookings-table.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | 18 | 19 | global $wpdb; 20 | 21 | $table = new Commons_Booking_Bookings_Table(); 22 | $table->prepare_items(); 23 | 24 | $message = ''; 25 | if ('delete' === $table->current_action()) { 26 | $message = sprintf(__('Items deleted: %d', 'cb_timeframes_table'), count($_REQUEST['id'])); 27 | } 28 | ?> 29 | 30 |
31 | 32 |

33 |

34 | 35 | 36 | 37 |
38 | 39 | display(); ?> 40 |
41 |
-------------------------------------------------------------------------------- /templates/item-list-item.php: -------------------------------------------------------------------------------- 1 | 8 |
9 | 10 |

11 |
12 | 13 |
14 | 15 |
16 | 17 | 18 |
19 | 20 |
21 | 22 |
23 | 24 | 25 | -------------------------------------------------------------------------------- /admin/cb-codes/views/codes-table.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | global $wpdb; 18 | 19 | $table = new Commons_Booking_Codes_Table(); 20 | $table->prepare_items(); 21 | 22 | $message = ''; 23 | if ('delete' === $table->current_action()) { 24 | $message = '

' . sprintf(__('Items deleted: %d', 'commons-booking'), count($_REQUEST['id'])) . '

'; 25 | } 26 | ?> 27 |
28 | 29 |

30 |

31 | 32 | 33 |
34 | 35 | display() ?> 36 |
37 | 38 |
-------------------------------------------------------------------------------- /public/assets/sass/themes/standard/partials/variables.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Base colors etc. 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /* Color Definitions */ 12 | 13 | $grey: #E1E1E1; 14 | $light-grey: #F6F6F6; 15 | $dark-grey: #414141; 16 | $black: #000; 17 | $white: #fff; 18 | 19 | $blue: #3356A4; 20 | $dark-blue: darken($blue, 10%); 21 | $light-blue: #E5FDFF; 22 | 23 | $green: #56A820; 24 | $light-green: #207B1C; 25 | 26 | $red: #FF0002; 27 | $dark-red: #A70001; 28 | 29 | /* Element styles */ 30 | 31 | $bg-color: $white; 32 | $bg-inner-color: $light-grey; 33 | 34 | $border-color: $grey; 35 | $border-inner-color: $white; 36 | 37 | $highlight-color: $blue; 38 | $highlight-color-dark: $dark-blue; 39 | $highlight-color-light: $light-blue; 40 | 41 | $action-color: $green; 42 | $action-color-light: $light-green; 43 | 44 | $inactive-color: $grey; 45 | 46 | $error-color: $red; 47 | $error-color-dark: $dark-red; 48 | 49 | 50 | /* Elements & widths */ 51 | $padding: 1em; 52 | $radius: 7px; 53 | $width: 100%; 54 | $cellwidth: $width / 7; 55 | $cellheight: 40px; -------------------------------------------------------------------------------- /admin/includes/CMB2/bootstrap.php: -------------------------------------------------------------------------------- 1 | prop( 'hookup' ) ) { 41 | $hookup = new CMB2_hookup( $cmb ); 42 | } 43 | } 44 | 45 | /** 46 | * Fires after CMB2 initiation process has been completed 47 | */ 48 | do_action( 'cmb2_after_init' ); 49 | 50 | // End. That's it, folks! // 51 | -------------------------------------------------------------------------------- /public/assets/sass/themes/kasimir/partials/variables.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Base colors etc. 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /* Color Definitions */ 12 | 13 | $grey: #E1E1E1; 14 | $light-grey: #F6F6F6; 15 | $dark-grey: #414141; 16 | $black: #000; 17 | $white: #fff; 18 | 19 | $blue: #3356A4; 20 | $dark-blue: darken($blue, 10%); 21 | $light-blue: #E5FDFF; 22 | 23 | $green: #56A820; 24 | $light-green: #207B1C; 25 | 26 | $red: #FF0002; 27 | $dark-red: #A70001; 28 | 29 | $kasi-blue: #CCEEFF; 30 | $kasi-orange: #D53E08; 31 | $kasi-orange-light: lighten($kasi-orange, 10%); 32 | $kasi-orange-dark: darken($kasi-orange, 10%); 33 | 34 | /* Element styles */ 35 | 36 | $bg-color: $kasi-blue; 37 | $bg-inner-color: $white; 38 | 39 | $border-color: darken ($kasi-blue, 30%); 40 | $border-inner-color: $kasi-blue; 41 | 42 | $highlight-color: $green; 43 | $highlight-color-dark: darken($green, 10%); 44 | $highlight-color-light: lighten($green, 50%); 45 | 46 | $action-color: $green; 47 | $action-color-light: $kasi-orange-light; 48 | 49 | $inactive-color: $grey; 50 | 51 | $error-color: $red; 52 | $error-color-dark: $dark-red; 53 | 54 | 55 | /* Elements & widths */ 56 | $padding: 1em; 57 | $radius: 3px; 58 | $width: 100%; 59 | $cellwidth: $width / 7; 60 | $cellheight: 40px; -------------------------------------------------------------------------------- /includes/Taxonomy_Core/README.md: -------------------------------------------------------------------------------- 1 | Taxonomy_Core 2 | ========= 3 | 4 | A tool to make custom taxonomy registration just a bit simpler. Automatically registers taxonomy labels, and provides helpful methods. 5 | 6 | Also see [CPT_Core](https://github.com/jtsternberg/CPT_Core). 7 | 8 | #### Example Usage: 9 | ```php 10 | get_args(); 41 | 42 | // Outputs 'film-actress', the taxonomoy registration name/slug 43 | $actress_slug = $actresses->taxonomy(); 44 | 45 | // Outputs 'Actresses' 46 | $actress_plural = $actresses->taxonomy( 'plural' ); 47 | 48 | // Outputs 'Actress' 49 | $actress_singular = $actresses->taxonomy( 'singular' ); 50 | -------------------------------------------------------------------------------- /admin/includes/CMB2/includes/CMB2_Boxes.php: -------------------------------------------------------------------------------- 1 | cmb_id ] = $cmb_instance; 27 | } 28 | 29 | /** 30 | * Remove a CMB2 instance object to the registry 31 | * @since 1.X.X 32 | * @param string $cmb_id A CMB2 instance id 33 | */ 34 | public static function remove( $cmb_id ) { 35 | if ( array_key_exists( $cmb_id, self::$cmb2_instances ) ) { 36 | unset( self::$cmb2_instances[ $cmb_id ] ); 37 | } 38 | } 39 | 40 | /** 41 | * Retrieve a CMB2 instance by cmb id 42 | * @since 1.X.X 43 | * @param string $cmb_id A CMB2 instance id 44 | * 45 | * @return mixed False or CMB2 object instance 46 | */ 47 | public static function get( $cmb_id ) { 48 | if ( empty( self::$cmb2_instances ) || empty( self::$cmb2_instances[ $cmb_id ] ) ) { 49 | return false; 50 | } 51 | 52 | return self::$cmb2_instances[ $cmb_id ]; 53 | } 54 | 55 | /** 56 | * Retrieve all CMB2 instances registered 57 | * @since 1.X.X 58 | * @return array Array of all registered metaboxes 59 | */ 60 | public static function get_all() { 61 | return self::$cmb2_instances; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /public/assets/sass/themes/kasimir/partials/bookingbar.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Booking bar displayed on calendar pages 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | #cb-bookingbar { 12 | z-index: 99; 13 | position: fixed; 14 | height: auto; 15 | left: 10px; 16 | right: 10px; 17 | bottom: 10px; 18 | @include transition(all .3s ease); 19 | 20 | 21 | .inner { 22 | @extend .cb-box; 23 | @include rounded($radius); 24 | @include box-shadow( 0, 0, 70px, 1px, #AFAFAF ); 25 | margin: 0; 26 | background: $white; 27 | color: $black; 28 | overflow: hidden; 29 | } 30 | .cb-userinfo { 31 | display: block; 32 | margin-bottom: 10px; 33 | a { 34 | 35 | } 36 | } 37 | .booking { 38 | #cb-intro, #date-start, #date-end, #cb-submit { 39 | font-weight: normal; 40 | float: left; 41 | } 42 | div.bb-date { 43 | display: inline-block; 44 | background: $bg-color; 45 | @include rounded($radius); 46 | background: $inactive-color; 47 | margin: 0 0.5em; 48 | .cb-cal-inner { 49 | font-weight: bold; 50 | margin: 0 10px 0 5px; 51 | border: 0; 52 | padding: 0; 53 | span { 54 | color: $blue; 55 | padding: 0; 56 | } 57 | span.cb-day { 58 | display: none; 59 | } 60 | } 61 | } 62 | #cb-submit { 63 | margin-right: 0; 64 | margin-top: 5px; 65 | .cb-button { 66 | line-height: 40px; 67 | height: 40px; 68 | } 69 | float: right; 70 | } 71 | } 72 | } 73 | 74 | #cb-bookingbar-msg { 75 | @extend .cb-message; 76 | margin-bottom: 0; 77 | } 78 | -------------------------------------------------------------------------------- /public/assets/sass/themes/standard/partials/bookingbar.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Booking bar displayed on calendar pages 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | #cb-bookingbar { 12 | z-index: 99; 13 | position: fixed; 14 | height: auto; 15 | left: 10px; 16 | right: 10px; 17 | bottom: 10px; 18 | @include transition(all .3s ease); 19 | 20 | 21 | .inner { 22 | @extend .cb-box; 23 | @include rounded($radius); 24 | @include box-shadow( 0, 0, 70px, 1px, #AFAFAF ); 25 | margin: 0; 26 | background: $bg-color; 27 | color: $black; 28 | overflow: hidden; 29 | } 30 | .cb-userinfo { 31 | display: block; 32 | margin-bottom: 10px; 33 | a { 34 | 35 | } 36 | } 37 | .booking { 38 | #cb-intro, #date-start, #date-end, #cb-submit { 39 | font-weight: normal; 40 | float: left; 41 | } 42 | div.bb-date { 43 | display: inline-block; 44 | background: $bg-color; 45 | @include rounded($radius); 46 | background: $inactive-color; 47 | margin: 0 0.5em; 48 | .cb-cal-inner { 49 | font-weight: bold; 50 | margin: 0 10px 0 5px; 51 | border: 0; 52 | padding: 0; 53 | span { 54 | color: $blue; 55 | padding: 0; 56 | } 57 | span.cb-day { 58 | display: none; 59 | } 60 | } 61 | } 62 | #cb-submit { 63 | margin-right: 0; 64 | margin-top: 5px; 65 | .cb-button { 66 | line-height: 40px; 67 | height: 40px; 68 | } 69 | float: right; 70 | } 71 | } 72 | } 73 | 74 | #cb-bookingbar-msg { 75 | @extend .cb-message; 76 | margin-bottom: 0; 77 | } 78 | -------------------------------------------------------------------------------- /templates/calendar-bookingbar.php: -------------------------------------------------------------------------------- 1 | 8 |
9 |
10 |
11 | 12 | ' . __( 'Logged in as', 'commons-booking' ) . ' '. esc_attr( $current_user->user_nicename ) .'
'; 15 | ?> 16 |
17 |
18 | 19 |
20 |
21 | 22 |
23 |
24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 |
34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 |
44 | 45 |

46 |

47 | 48 |
49 |
50 | -------------------------------------------------------------------------------- /admin/cb-mail/class-cb-mail.php: -------------------------------------------------------------------------------- 1 | 6 | * @license GPL-2.0+ 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | class CB_Mail extends Commons_Booking { 12 | 13 | public function __construct( ) { 14 | 15 | $this->settings = Parent::get_cb_settings(); 16 | 17 | $this->html = TRUE; 18 | 19 | $this->sender_mail_from = $this->return_mail_from(); 20 | $this->sender_mail_from_name = $this->return_mail_from_name(); 21 | $this->body = ''; 22 | $this->subject = ''; 23 | $this->recipient = ''; 24 | $this->headers = array(); 25 | 26 | } 27 | 28 | public function cb_send_mail() { 29 | 30 | $this->set_headers(); 31 | 32 | $to = $this->recipient; 33 | $subject = $this->subject; 34 | $body = $this->body; 35 | $headers = $this->headers; 36 | 37 | wp_mail( $to, $subject, $body, $headers ); 38 | 39 | } 40 | 41 | public function set_headers ( ) { 42 | 43 | if ( $this->validate_mail_settings() ) { 44 | 45 | $from_name = $this->return_mail_from_name(); 46 | $from_email = $this->return_mail_from(); 47 | 48 | $this->headers[] = 'From: ' . $from_name . '<' . $from_email . '>'; 49 | } 50 | 51 | if ( $this->html ) { 52 | 53 | $this->headers[] = 'Content-Type: text/html; charset=UTF-8'; 54 | } 55 | } 56 | 57 | public function set_subject ( $subject ) { 58 | $this->subject = $subject; 59 | } 60 | 61 | public function set_body ( $body ) { 62 | $this->body = $body; 63 | } 64 | public function set_recipient ( $recipient ) { 65 | $this->recipient = $recipient; 66 | } 67 | 68 | private function return_mail_from () { 69 | 70 | return $this->settings->get_settings('mail', 'mail_from'); 71 | } 72 | 73 | private function return_mail_from_name () { 74 | 75 | return $this->settings->get_settings('mail', 'mail_from_name'); 76 | } 77 | 78 | private function validate_mail_settings() { 79 | 80 | if ( ! empty ( $this->sender_mail_from ) && ! empty ( $this->sender_mail_from_name )) { 81 | return TRUE; 82 | } else { 83 | return FALSE; 84 | } 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /includes/CPT_Core/README.md: -------------------------------------------------------------------------------- 1 | CPT_Core 2 | ========= 3 | 4 | A tool to make custom post type registration just a bit simpler. Automatically registers post type labels and messages, and provides helpful methods. 5 | 6 | Also see [Taxonomy_Core](https://github.com/jtsternberg/Taxonomy_Core). 7 | 8 | #### Example Usage: 9 | ```php 10 | array( 'title', 'editor', 'excerpt', 'thumbnail' ), 46 | ) 47 | ); 48 | 49 | } 50 | 51 | /** 52 | * Registers admin columns to display. Hooked in via CPT_Core. 53 | * @since 0.1.0 54 | * @param array $columns Array of registered column names/labels 55 | * @return array Modified array 56 | */ 57 | public function columns( $columns ) { 58 | $new_column = array( 59 | 'headshot' => sprintf( __( '%s Headshot', 'your-text-domain' ), $this->post_type( 'singular' ) ), 60 | ); 61 | return array_merge( $new_column, $columns ); 62 | } 63 | 64 | /** 65 | * Handles admin column display. Hooked in via CPT_Core. 66 | * @since 0.1.0 67 | * @param array $column Array of registered column names 68 | */ 69 | public function columns_display( $column, $post_id ) { 70 | switch ( $column ) { 71 | case 'headshot': 72 | the_post_thumbnail(); 73 | break; 74 | } 75 | } 76 | 77 | } 78 | new Actress_CPT(); 79 | ``` 80 | -------------------------------------------------------------------------------- /includes/Taxonomy_Core/languages/taxonomy-core.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 WebDevStudios.com 2 | # This file is distributed under the GPLv2. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: WDS Taxonomy Core 0.2.3\n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/Taxonomy_Core\n" 7 | "POT-Creation-Date: 2015-07-07 21:20:39+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=utf-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: FULL NAME \n" 13 | "Language-Team: LANGUAGE \n" 14 | "X-Generator: grunt-wp-i18n 0.4.9\n" 15 | 16 | #: Taxonomy_Core.php:84 Taxonomy_Core.php:88 Taxonomy_Core.php:92 17 | msgid "It is required to pass a single, plural and slug string to Taxonomy_Core" 18 | msgstr "" 19 | 20 | #: Taxonomy_Core.php:126 21 | msgid "Search %s" 22 | msgstr "" 23 | 24 | #: Taxonomy_Core.php:127 25 | msgid "All %s" 26 | msgstr "" 27 | 28 | #: Taxonomy_Core.php:128 29 | msgid "Edit %s" 30 | msgstr "" 31 | 32 | #: Taxonomy_Core.php:129 33 | msgid "View %s" 34 | msgstr "" 35 | 36 | #: Taxonomy_Core.php:130 37 | msgid "Update %s" 38 | msgstr "" 39 | 40 | #: Taxonomy_Core.php:131 41 | msgid "Add New %s" 42 | msgstr "" 43 | 44 | #: Taxonomy_Core.php:132 45 | msgid "New %s Name" 46 | msgstr "" 47 | 48 | #: Taxonomy_Core.php:133 49 | msgid "No %s found." 50 | msgstr "" 51 | 52 | #: Taxonomy_Core.php:134 53 | msgid "No %s" 54 | msgstr "" 55 | 56 | #: Taxonomy_Core.php:137 57 | msgid "Parent %s" 58 | msgstr "" 59 | 60 | #: Taxonomy_Core.php:138 61 | msgid "Parent %s:" 62 | msgstr "" 63 | 64 | #: Taxonomy_Core.php:141 65 | msgid "Popular %s" 66 | msgstr "" 67 | 68 | #: Taxonomy_Core.php:142 69 | msgid "Separate %s with commas" 70 | msgstr "" 71 | 72 | #: Taxonomy_Core.php:143 73 | msgid "Add or remove %s" 74 | msgstr "" 75 | 76 | #: Taxonomy_Core.php:144 77 | msgid "Choose from the most used %s" 78 | msgstr "" 79 | 80 | #. Plugin Name of the plugin/theme 81 | msgid "WDS Taxonomy Core" 82 | msgstr "" 83 | 84 | #. Author URI of the plugin/theme 85 | msgid "http://webdevstudios.com" 86 | msgstr "" 87 | 88 | #. Description of the plugin/theme 89 | msgid "Taxonomy registration starter class" 90 | msgstr "" 91 | 92 | #. Author of the plugin/theme 93 | msgid "WebDevStudios.com" 94 | msgstr "" -------------------------------------------------------------------------------- /admin/cb-items/includes/cb-items-metaboxes.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | 18 | class Commons_Booking_Items_Metabox extends Commons_Booking { 19 | 20 | /** 21 | * Hook into the appropriate actions when the class is constructed. 22 | */ 23 | public function __construct() { 24 | 25 | } 26 | 27 | /** 28 | * Adds the timeframes meta box container. 29 | */ 30 | public function cb_items_add_timeframe_meta_box( $post_type ) { 31 | $post_types = array( 'cb_items' ); 32 | 33 | //limit meta box to certain post types 34 | if (in_array($post_type, $post_types)) { 35 | add_meta_box('cs-meta', 36 | __('Timeframes', 'commons-booking'), 37 | array($this, 'cb_items_timeframe_meta_box_function'), 38 | $post_type, 39 | 'normal', 40 | 'high'); 41 | } 42 | } 43 | 44 | /** 45 | * Render timeframes Meta Box content. 46 | * 47 | * @param WP_Post $post The post object. 48 | */ 49 | 50 | public function cb_items_timeframe_meta_box_function($post) { 51 | 52 | $timeframes = new Commons_Booking_Timeframes_List( $post->ID ); 53 | $timeframes->render_timeframes(); 54 | 55 | } 56 | 57 | /** 58 | * Set up the description meta box. 59 | * 60 | * @param WP_Post $post The post object. 61 | */ 62 | 63 | public function cb_item_descr_metaboxes( array $meta_boxes ) { 64 | 65 | $meta_boxes[ 'cb_item_metabox_descr' ] = array( 66 | 'id' => 'cb_item_metabox_descr', 67 | 'title' => __( 'Short description of the item, displayed in the list.', parent::$plugin_slug ), 68 | 'object_types' => array( 'cb_items', ), // Post type 69 | 'context' => 'normal', 70 | 'priority' => 'high', 71 | 'show_names' => true, // Show field names on the left 72 | 'fields' => array( 73 | array( 74 | 'name' => __( 'Short description', parent::$plugin_slug ), 75 | 'id' => parent::$plugin_slug . '_item_descr', 76 | 'type' => 'textarea', 77 | ), 78 | ), 79 | ); 80 | return $meta_boxes; 81 | } 82 | } -------------------------------------------------------------------------------- /includes/template.php: -------------------------------------------------------------------------------- 1 | 5 | * Based on WooCommerce function
6 | * 7 | * @package Commons_Booking 8 | * @author Mte90 9 | * @license GPL-2.0+ 10 | * @copyright 2014 11 | * @since 0.0.1 12 | */ 13 | function commons_booking_get_template_part( $slug, $name = '', $include = true ) { 14 | $template = ''; 15 | $path = plugin_dir_path( realpath( dirname( __FILE__ ) ) ) . 'templates/'; 16 | $plugin = Commons_Booking::get_instance(); 17 | $plugin_slug = $plugin->get_plugin_slug().'/'; 18 | 19 | // Look in yourtheme/slug-name.php and yourtheme/commons-booking/slug-name.php 20 | if ( $name ) { 21 | $template = locate_template( array( "{$slug}-{$name}.php", $plugin_slug . "{$slug}-{$name}.php" ) ); 22 | } else { 23 | $template = locate_template( array( "{$slug}.php", $plugin_slug . "{$slug}.php" ) ); 24 | } 25 | 26 | // Get default slug-name.php 27 | if ( !$template && $name && file_exists( $path . "{$slug}-{$name}.php" ) ) { 28 | $template = $path . "{$slug}-{$name}.php"; 29 | } 30 | 31 | // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php 32 | if ( !$template ) { 33 | $template = locate_template( array( "{$slug}.php", $plugin_slug . "{$slug}.php" ) ); 34 | } 35 | 36 | // Allow 3rd party plugin filter template file from their plugin 37 | //$template = apply_filters( 'pn_get_template_part', $template, $slug, $name ); 38 | 39 | if ( $template && $include === true ) { 40 | load_template( $template, false ); 41 | // include ($template); 42 | } else if($template && $include === false ) { 43 | return $template; 44 | } 45 | } 46 | 47 | function cb1_get_template_part( $template = '', $attributes = null, $buffer = FALSE ) { 48 | $path = plugin_dir_path( realpath( dirname( __FILE__ ) ) ) . 'templates/'; 49 | $plugin = Commons_Booking::get_instance(); 50 | $plugin_slug = $plugin->get_plugin_slug(); 51 | 52 | // Look in yourtheme/slug-name.php and yourtheme/plugin-name/slug-name.php 53 | if ( ! $attributes ) { 54 | $attributes = array(); 55 | } 56 | 57 | $attributes['plugin_slug'] = $plugin_slug; // add plugin-slug to the attributes 58 | 59 | if ( $buffer ) { 60 | ob_start(); 61 | include( $path . $template . '.php'); 62 | $content = ob_get_contents(); 63 | ob_end_clean(); 64 | return $content; 65 | } else { 66 | include ( $path . $template . '.php' ); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /admin/cb-codes/includes/class-cb-codes-generate.php: -------------------------------------------------------------------------------- 1 | 6 | * @license GPL-2.0+ 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /** 12 | * Generate Codes 13 | * 14 | * @package Commons_Booking_Codes 15 | * @author Florian Egermann 16 | */ 17 | class Commons_Booking_Codes_Generate extends Commons_Booking_Codes { 18 | 19 | public $item_id; 20 | 21 | /** 22 | * Gets all necessary variables from parent function, compares 23 | * 24 | * @param $item_id 25 | * @param $date_start 26 | * @param $date_end 27 | * 28 | */ 29 | public function __construct() { 30 | 31 | } 32 | /** 33 | * Get all necessary variables. 34 | * 35 | */ 36 | public function prepare( ) { 37 | 38 | if ( isset( $_REQUEST['item_id'] ) ) { 39 | 40 | $this->item_id = $_REQUEST['item_id']; 41 | $this->date_start = $_REQUEST['date_start']; 42 | $this->date_end = $_REQUEST['date_end']; 43 | parent::__construct( $this->item_id ); 44 | parent::compare(); 45 | 46 | } else { 47 | 48 | die ( __( 'No id!')); 49 | } 50 | 51 | } 52 | /** 53 | * Generate the codes, display message 54 | * 55 | */ 56 | public function generate_codes( ) { 57 | 58 | $this->prepare(); 59 | if ( count($this->missing_dates) > 0 ) { 60 | $this->sql_insert($this->item_id); 61 | } else { 62 | new Admin_Table_Message ( __('Codes already in Database.', 'commons-booking' ), 'updated' ); 63 | } 64 | } 65 | 66 | 67 | 68 | /** 69 | * Insert into Database. 70 | * 71 | */ 72 | private function sql_insert( ) { 73 | 74 | global $wpdb; 75 | 76 | $sqlcols = "item_id,booking_date,bookingcode"; 77 | $sqlcontents = array(); 78 | $sqlquery = ''; 79 | $count = count( $this->missing_dates ); 80 | 81 | if ( count( $this->codes_array ) < count( $this->missing_dates )) { 82 | new Admin_Table_Message ( __('Notice: Not enough codes defined in settings, some codes will be repeated.', $this->prefix), 'error' ); 83 | } 84 | new Admin_Table_Message ( __('Missing booking codes have been generated.', $this->prefix), 'updated' ); 85 | 86 | // create mysql query 87 | for ( $i=0; $i < $count; $i++ ) { 88 | $random = rand( 0, count( $this->codes_array ) -1 ); 89 | array_push($sqlcontents, '("' . $this->item_id. '","' . $this->missing_dates[$i]['date'] . '","' . $this->codes_array[ $random ] . '")'); 90 | } 91 | $sqlquery = 'INSERT INTO ' . $this->table_name . ' (' . $sqlcols . ') VALUES ' . implode (',', $sqlcontents ) . ';'; 92 | $wpdb->query($sqlquery); 93 | } 94 | 95 | } -------------------------------------------------------------------------------- /admin/includes/CMB2/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to CMB2 2 | 3 | Thank you for your interest in contributing back to CMB2. Please help us review your issues and/or merge your pull requests by following the below guidelines. 4 | 5 | #### NOTE: The issues section is for bug reports and feature requests only. 6 | _Support is not offered for this library, and the likelihood that the maintainers will respond is very low. If you need help, please use [stackoverflow](http://stackoverflow.com/search?q=cmb), or the [wordpress.org plugin forums](http://wordpress.org/support/plugin/cmb2)._ 7 | 8 | Before reporting a bug 9 | --- 10 | 1. Search [issues](https://github.com/WebDevStudios/CMB2/issues) to see if the issue has been previously reported. 11 | 2. Install the trunk version of CMB2 and test there. 12 | 13 | 14 | How to report a bug 15 | --- 16 | 1. Specify the version number for both WordPress and CMB2. 17 | 3. Describe the problem in detail. Explain what happened, and what you expected would happen. 18 | 4. Provide a small test-case and a link to a [gist](https://gist.github.com/) containing your entire metabox registration code. 19 | 5. If helpful, include a screenshot. Annotate the screenshot for clarity. 20 | 21 | 22 | How to contribute to CMB2 23 | --- 24 | All contributions welcome. If you would like to submit a pull request, please follow the steps below. 25 | 26 | 1. Make sure you have a GitHub account. 27 | 2. Fork the repository on GitHub. 28 | 3. **Check out the trunk version of CMB2.** If you submit to the master branch, the PR will be closed with a link back to this document. 29 | 4. **Verify your issue still exists in the trunk branch.** 30 | 5. Make changes to your clone of the repository. 31 | 1. Please follow the [WordPress code standards](https://make.wordpress.org/core/handbook/coding-standards). 32 | 2. If possible, and if applicable, please also add/update unit tests for your changes. 33 | 3. Please add documentation to any new functions, methods, actions and filters. 34 | 4. When committing, reference your issue (if present) and include a note about the fix. 35 | 6. [Submit a pull request](https://help.github.com/articles/creating-a-pull-request/). 36 | 37 | **Note:** You may gain more ground and avoid unecessary effort if you first open an issue with the proposed changes, but this step is not necessary. 38 | 39 | Additional Resources 40 | --- 41 | 42 | * [CMB2 Documentation Wiki](https://github.com/WebDevStudios/CMB2/wiki) 43 | * [CMB2 Snippet Library](https://github.com/WebDevStudios/CMB2-Snippet-Library) 44 | * [CMB2 API Documentation](http://cmb2.io/api/) 45 | * [General GitHub Documentation](http://help.github.com/) 46 | * [GitHub Pull Request documentation](http://help.github.com/send-pull-requests/) 47 | * [PHPUnit Tests Guide](http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html) -------------------------------------------------------------------------------- /templates/timeframes-full.php: -------------------------------------------------------------------------------- 1 | 8 |
9 | 10 | 11 | 12 |
13 | 14 |
15 | 16 |
17 |
18 |
19 | 20 | 21 |
22 |
23 |
24 |
25 |
26 |
    27 | 29 |
    30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
    38 | 39 | 40 | 41 |
  • 43 |
    44 |
  • 45 | 46 |
47 |
48 |
49 | 50 |
51 | -------------------------------------------------------------------------------- /templates/booking-review.php: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 |
12 |
13 |
14 | 15 | 16 |
17 |
18 |
19 | 20 |
21 |
22 | 23 |
24 |
25 | 26 |
27 |
28 | 29 |
30 |
31 | 32 | 33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | 41 | 42 |
43 |
44 |
45 | 46 |
47 |
48 | 49 |
50 |
-------------------------------------------------------------------------------- /public/assets/sass/themes/kasimir/partials/mixins.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Effects & eye-candy 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | @mixin transition($args...) { 12 | -webkit-transition: $args; 13 | -moz-transition: $args; 14 | -ms-transition: $args; 15 | -o-transition: $args; 16 | transition: $args; 17 | } 18 | 19 | @mixin rounded($radius) { 20 | -webkit-border-radius: $radius; 21 | -moz-border-radius: $radius; 22 | border-radius: $radius; 23 | } 24 | 25 | @mixin border-radius ($radius) { 26 | -webkit-border-radius: $radius; 27 | -moz-border-radius: $radius; 28 | border-radius: $radius; 29 | 30 | -moz-background-clip: padding; 31 | -webkit-background-clip: padding-box; 32 | background-clip: padding-box; 33 | } 34 | @mixin border-radiuses ($topright: 0, $bottomright: 0, $bottomleft: 0, $topleft: 0) { 35 | -webkit-border-top-right-radius: $topright; 36 | -webkit-border-bottom-right-radius: $bottomright; 37 | -webkit-border-bottom-left-radius: $bottomleft; 38 | -webkit-border-top-left-radius: $topleft; 39 | 40 | -moz-border-radius-topright: $topright; 41 | -moz-border-radius-bottomright: $bottomright; 42 | -moz-border-radius-bottomleft: $bottomleft; 43 | -moz-border-radius-topleft: $topleft; 44 | 45 | border-top-right-radius: $topright; 46 | border-bottom-right-radius: $bottomright; 47 | border-bottom-left-radius: $bottomleft; 48 | border-top-left-radius: $topleft; 49 | 50 | -moz-background-clip: padding; 51 | -webkit-background-clip: padding-box; 52 | background-clip: padding-box; 53 | } 54 | 55 | @mixin selection-end-round( $radius ) { 56 | -webkit-border-top-right-radius: $radius; 57 | -webkit-border-bottom-right-radius: $radius; 58 | 59 | -moz-border-radius-topright: $radius; 60 | -moz-border-radius-bottomright: $radius; 61 | 62 | border-top-right-radius: $radius; 63 | border-bottom-right-radius: $radius; 64 | } 65 | 66 | @mixin selection-start-round( $radius ) { 67 | -webkit-border-top-left-radius: $radius; 68 | -webkit-border-bottom-left-radius: $radius; 69 | 70 | -moz-border-radius-topleft: $radius; 71 | -moz-border-radius-bottomleft: $radius; 72 | 73 | border-top-left-radius: $radius; 74 | border-bottom-left-radius: $radius; 75 | } 76 | 77 | @mixin box-shadow( $horiz : .5em , $vert : .5em , $blur : 0px , $spread : 0px , $color : #000000 ){ 78 | -webkit-box-shadow: $horiz $vert $blur $spread $color; 79 | -moz-box-shadow: $horiz $vert $blur $spread $color; 80 | box-shadow: $horiz $vert $blur $spread $color; 81 | } -------------------------------------------------------------------------------- /public/assets/sass/themes/standard/partials/mixins.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Effects & eye-candy 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | @mixin transition($args...) { 12 | -webkit-transition: $args; 13 | -moz-transition: $args; 14 | -ms-transition: $args; 15 | -o-transition: $args; 16 | transition: $args; 17 | } 18 | 19 | @mixin rounded($radius) { 20 | -webkit-border-radius: $radius; 21 | -moz-border-radius: $radius; 22 | border-radius: $radius; 23 | } 24 | 25 | @mixin border-radius ($radius) { 26 | -webkit-border-radius: $radius; 27 | -moz-border-radius: $radius; 28 | border-radius: $radius; 29 | 30 | -moz-background-clip: padding; 31 | -webkit-background-clip: padding-box; 32 | background-clip: padding-box; 33 | } 34 | @mixin border-radiuses ($topright: 0, $bottomright: 0, $bottomleft: 0, $topleft: 0) { 35 | -webkit-border-top-right-radius: $topright; 36 | -webkit-border-bottom-right-radius: $bottomright; 37 | -webkit-border-bottom-left-radius: $bottomleft; 38 | -webkit-border-top-left-radius: $topleft; 39 | 40 | -moz-border-radius-topright: $topright; 41 | -moz-border-radius-bottomright: $bottomright; 42 | -moz-border-radius-bottomleft: $bottomleft; 43 | -moz-border-radius-topleft: $topleft; 44 | 45 | border-top-right-radius: $topright; 46 | border-bottom-right-radius: $bottomright; 47 | border-bottom-left-radius: $bottomleft; 48 | border-top-left-radius: $topleft; 49 | 50 | -moz-background-clip: padding; 51 | -webkit-background-clip: padding-box; 52 | background-clip: padding-box; 53 | } 54 | 55 | @mixin selection-end-round( $radius ) { 56 | -webkit-border-top-right-radius: $radius; 57 | -webkit-border-bottom-right-radius: $radius; 58 | 59 | -moz-border-radius-topright: $radius; 60 | -moz-border-radius-bottomright: $radius; 61 | 62 | border-top-right-radius: $radius; 63 | border-bottom-right-radius: $radius; 64 | } 65 | 66 | @mixin selection-start-round( $radius ) { 67 | -webkit-border-top-left-radius: $radius; 68 | -webkit-border-bottom-left-radius: $radius; 69 | 70 | -moz-border-radius-topleft: $radius; 71 | -moz-border-radius-bottomleft: $radius; 72 | 73 | border-top-left-radius: $radius; 74 | border-bottom-left-radius: $radius; 75 | } 76 | 77 | @mixin box-shadow( $horiz : .5em , $vert : .5em , $blur : 0px , $spread : 0px , $color : #000000 ){ 78 | -webkit-box-shadow: $horiz $vert $blur $spread $color; 79 | -moz-box-shadow: $horiz $vert $blur $spread $color; 80 | box-shadow: $horiz $vert $blur $spread $color; 81 | } -------------------------------------------------------------------------------- /includes/CPT_Core/languages/cpt-core.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014 2 | # This file is distributed under the same license as the package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: \n" 6 | "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/CPT_Core\n" 7 | "POT-Creation-Date: 2014-11-24 20:33:12+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=utf-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: FULL NAME \n" 13 | "Language-Team: LANGUAGE \n" 14 | "X-Generator: grunt-wp-i18n 0.4.9\n" 15 | 16 | #: CPT_Core.php:65 CPT_Core.php:69 CPT_Core.php:73 17 | msgid "It is required to pass a single, plural and slug string to CPT_Core" 18 | msgstr "" 19 | 20 | #: CPT_Core.php:122 CPT_Core.php:123 21 | msgid "Add New %s" 22 | msgstr "" 23 | 24 | #: CPT_Core.php:124 25 | msgid "Edit %s" 26 | msgstr "" 27 | 28 | #: CPT_Core.php:125 29 | msgid "New %s" 30 | msgstr "" 31 | 32 | #: CPT_Core.php:126 33 | msgid "All %s" 34 | msgstr "" 35 | 36 | #: CPT_Core.php:127 37 | msgid "View %s" 38 | msgstr "" 39 | 40 | #: CPT_Core.php:128 41 | msgid "Search %s" 42 | msgstr "" 43 | 44 | #: CPT_Core.php:129 45 | msgid "No %s" 46 | msgstr "" 47 | 48 | #: CPT_Core.php:130 49 | msgid "No %s found in Trash" 50 | msgstr "" 51 | 52 | #: CPT_Core.php:131 53 | msgid "Parent %s:" 54 | msgstr "" 55 | 56 | #: CPT_Core.php:180 57 | msgid "Custom field updated." 58 | msgstr "" 59 | 60 | #: CPT_Core.php:181 61 | msgid "Custom field deleted." 62 | msgstr "" 63 | 64 | #: CPT_Core.php:182 CPT_Core.php:199 65 | msgid "%1$s updated." 66 | msgstr "" 67 | 68 | #: CPT_Core.php:184 69 | #. translators: %s: date and time of the revision 70 | msgid "%1$s restored to revision from %2$s" 71 | msgstr "" 72 | 73 | #: CPT_Core.php:185 74 | msgid "%1$s saved." 75 | msgstr "" 76 | 77 | #: CPT_Core.php:190 78 | msgid "%1$s updated. View %1$s" 79 | msgstr "" 80 | 81 | #: CPT_Core.php:191 82 | msgid "%1$s published. View %1$s" 83 | msgstr "" 84 | 85 | #: CPT_Core.php:192 86 | msgid "%1$s submitted. Preview %1$s" 87 | msgstr "" 88 | 89 | #: CPT_Core.php:194 90 | #. translators: Publish box date format, see http:php.net/date 91 | msgid "" 92 | "%1$s scheduled for: %2$s. Preview %1$s" 94 | msgstr "" 95 | 96 | #: CPT_Core.php:194 CPT_Core.php:203 97 | msgid "M j, Y @ G:i" 98 | msgstr "" 99 | 100 | #: CPT_Core.php:195 101 | msgid "%1$s draft updated. Preview %1$s" 102 | msgstr "" 103 | 104 | #: CPT_Core.php:200 105 | msgid "%1$s published." 106 | msgstr "" 107 | 108 | #: CPT_Core.php:201 109 | msgid "%1$s submitted." 110 | msgstr "" 111 | 112 | #: CPT_Core.php:203 113 | #. translators: Publish box date format, see http:php.net/date 114 | msgid "%1$s scheduled for: %2$s." 115 | msgstr "" 116 | 117 | #: CPT_Core.php:204 118 | msgid "%1$s draft updated." 119 | msgstr "" 120 | 121 | #: CPT_Core.php:253 122 | msgid "%s Title" 123 | msgstr "" -------------------------------------------------------------------------------- /admin/cb-widgets/cb-category-widget.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GPL-2.0+ 9 | * @link http://www.wielebenwir.de 10 | * @copyright 2015 wielebenwir 11 | * @since 0.9 12 | */ 13 | 14 | // Create custom widget class extending WP_Widget 15 | class CB_Category_Widget extends WP_Widget { 16 | 17 | function __construct() { 18 | 19 | parent::__construct( 20 | 'cb_category_widget', // Base ID 21 | __( 'Commons Booking categories', 'commons-booking' ), // Name 22 | array( 'description' => __( 'List all item categories', 'commons-booking' ), ) // Args 23 | ); 24 | 25 | } 26 | 27 | /** 28 | * Back-end widget form. 29 | * 30 | * @see WP_Widget::form() 31 | * 32 | * @param array $instance Previously saved values from database. 33 | */ 34 | public function form( $instance ) { 35 | $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' ); 36 | ?> 37 |

38 | 39 | 40 |

41 | render_categories(); 75 | 76 | echo $args[ 'after_widget' ]; 77 | } 78 | /** 79 | * Get all item categories 80 | * 81 | **/ 82 | function render_categories() { 83 | 84 | $args = array ( 85 | 'taxonomy' => 'cb_items_category', 86 | 'echo' => FALSE, 87 | 'title_li' => '' 88 | ); 89 | 90 | $content = wp_list_categories( $args ); 91 | 92 | return $content; 93 | 94 | } 95 | 96 | } 97 | 98 | // register CB_User_Widget 99 | function register_cb_category_widget() { 100 | register_widget( 'CB_Category_Widget' ); 101 | } 102 | add_action( 'widgets_init', 'register_cb_category_widget' ); 103 | 104 | -------------------------------------------------------------------------------- /admin/cb-codes/class-cb-codes-setup.php: -------------------------------------------------------------------------------- 1 | 6 | * @license GPL-2.0+ 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /** 12 | * Handles install & update of the Codes Table 13 | * 14 | * @package Commons_Booking_Codes_Setup 15 | * @author Florian Egermann 16 | */ 17 | 18 | 19 | class Commons_Booking_Codes_Setup { 20 | 21 | public $table_db_version = '0.1'; // version changed from 1.0 to 0.1 22 | 23 | public function __construct () { 24 | 25 | $this->table_db_version = '0.1'; // version changed from 1.0 to 0.1 26 | 27 | } 28 | 29 | public function install() 30 | { 31 | global $wpdb; 32 | $table_name = $wpdb->prefix . 'cb_codes'; // do not forget about tables prefix 33 | 34 | // sql to create your table 35 | // NOTICE that: 36 | // 1. each field MUST be in separate line 37 | // 2. There must be two spaces between PRIMARY KEY and its name 38 | // Like this: PRIMARY KEY[space][space](id) 39 | // otherwise dbDelta will not work 40 | $sql = "CREATE TABLE " . $table_name . " ( 41 | id int(11) AUTO_INCREMENT, 42 | bookingcode text CHARACTER SET utf8, 43 | item_id int(11) DEFAULT NULL, 44 | booking_date date DEFAULT NULL, 45 | PRIMARY KEY (id) 46 | );"; 47 | 48 | // we do not execute sql directly 49 | // we are calling dbDelta which cant migrate database 50 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 51 | dbDelta($sql); 52 | 53 | // save current database version for later use (on upgrade) 54 | add_option('commons_booking_codes_table_db_version', $this->table_db_version); 55 | 56 | /** 57 | * [OPTIONAL] Example of updating to 0.1 version 58 | * 59 | * If you develop new version of plugin 60 | * just increment $cb_codes_$this->table_db_version variable 61 | * and add following block of code 62 | * 63 | */ 64 | $installed_ver = get_option('cb_codes_$this->table_db_version'); 65 | if ($installed_ver != $this->table_db_version) { 66 | $sql = "CREATE TABLE " . $table_name . " ( 67 | id int(11) AUTO_INCREMENT, 68 | bookingcode text CHARACTER SET utf8, 69 | item_id int(11) DEFAULT NULL, 70 | booking_date date DEFAULT NULL, 71 | PRIMARY KEY (id) 72 | );"; 73 | 74 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 75 | dbDelta($sql); 76 | 77 | // notice that we are updating option, rather than adding it 78 | update_option('commons_booking_codes_table_db_version', $this->table_db_version); 79 | } 80 | } 81 | 82 | 83 | /** 84 | * register_activation_hook implementation 85 | * 86 | * [OPTIONAL] 87 | * additional implementation of register_activation_hook 88 | * to insert some dummy data 89 | */ 90 | public function cb_codes_table_install_data() 91 | { 92 | global $wpdb; 93 | 94 | $table_name = $wpdb->prefix . 'cb_codes'; // do not forget about tables prefix 95 | 96 | } 97 | 98 | 99 | /** 100 | * Trick to update plugin database, see docs 101 | */ 102 | public function cb_codes_table_update_db_check() 103 | { 104 | if (get_site_option('cb_codes_table_db_version') != $this->table_db_version) { 105 | cb_codes_table_install(); 106 | } 107 | } 108 | } 109 | ?> -------------------------------------------------------------------------------- /public/cb-bookings/class-cb-public-items.php: -------------------------------------------------------------------------------- 1 | 8 | * @author Christian Wenzel 9 | * @license GPL-2.0+ 10 | * @link http://www.wielebenwir.de 11 | * @copyright 2015 wielebenwir 12 | */ 13 | 14 | /** 15 | * This class includes display of items 16 | * * 17 | * @package Commons_Booking_items 18 | * @author Florian Egermann 19 | * 20 | */ 21 | 22 | class CB_Public_Items { 23 | 24 | public $items; 25 | 26 | public function __construct() { 27 | 28 | // get timeframe data 29 | $this->data = new CB_Data; 30 | 31 | $this->defaults = array( 32 | 'p' => '', 33 | 'cat' => '', 34 | 'posts_per_page' => 10, 35 | 'post_type' => 'cb_items', 36 | 'orderby' => 'title', 37 | 'order' => 'DESC', 38 | ); 39 | } 40 | 41 | /** 42 | * Get items 43 | * 44 | * @since 0.4.5 45 | * @param mixed 46 | * @return array 47 | */ 48 | public function get_Items( $the_query ) { 49 | 50 | $content = array(); 51 | 52 | if ( $the_query->have_posts() ) { 53 | while ( $the_query->have_posts() ) { 54 | 55 | $the_query->the_post(); 56 | $item_id = get_the_ID(); 57 | array_push( $content, $item_id ); 58 | } 59 | } else { 60 | return __( ' Sorry, nothing found.'); 61 | } 62 | wp_reset_postdata(); 63 | return $content; 64 | } 65 | 66 | /** 67 | * Merge supplied arguments with defaults 68 | * 69 | * @TODO move this to main file so other classes can use it. 70 | * 71 | * @since 0.4.5 72 | * @param array 73 | * @return array 74 | */ 75 | public function merge_args( $args = array() ){ 76 | 77 | //sort out whether defaults were supplied or just the array of search values 78 | if( empty( $args ) ){ 79 | $array = $this->defaults; 80 | 81 | }else{ 82 | $array = array_merge($this->defaults, $args); 83 | } 84 | $array = array_filter( $array, 'strlen' ); // remove empty keys 85 | return ($array); 86 | } 87 | /** 88 | * Output the item list 89 | * 90 | * @since 0.4.5 91 | * @param args array 92 | * @return array 93 | */ 94 | public function output( $args = array() ) { 95 | 96 | $content = ''; 97 | $queryargs = $this->merge_args($args); 98 | 99 | $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 100 | $p = array( 'paged' => $paged ); 101 | 102 | $thequery = array_merge_recursive( $queryargs, $p ); 103 | 104 | $query = new WP_Query( $thequery ); 105 | wp_reset_postdata(); 106 | $item_ids = $this->get_Items( $query ); 107 | 108 | if ( is_array ($item_ids) ) { // if result 109 | 110 | foreach ($item_ids as $item_id) { 111 | $content .= $this->data->render_item_list( $item_id ); 112 | } 113 | 114 | } else { 115 | $content = __('No items found', 'commons-booking'); 116 | } 117 | 118 | $pagination = $this->item_pagination($query ); 119 | 120 | return $content . $pagination; 121 | } 122 | 123 | public function item_pagination( $query ) { 124 | $next = get_next_posts_link( __('Next items', 'commons-booking'), $query->max_num_pages ); 125 | $prev = get_previous_posts_link( __('Previous items', 'commons-booking') , $query->max_num_pages ); 126 | return $prev . $next; 127 | } 128 | } 129 | ?> -------------------------------------------------------------------------------- /admin/cb-timeframes/cb-timeframes-setup.php: -------------------------------------------------------------------------------- 1 | 6 | * @license GPL-2.0+ 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /** 12 | * Handles install & update of the Timeframes Table 13 | * 14 | * @package CB_Timeframes_Install 15 | * @author Florian Egermann 16 | */ 17 | 18 | 19 | class Commons_Booking_Timeframes_Setup { 20 | 21 | public $table_db_version = '0.1'; // version changed from 1.0 to 0.1 22 | 23 | public function __construct () { 24 | 25 | $this->table_db_version = '0.1'; // version changed from 1.0 to 0.1 26 | 27 | } 28 | 29 | /** 30 | * register_activation_hook implementation 31 | * 32 | * will be called when user activates plugin first time 33 | * must create needed database tables 34 | */ 35 | public function install() 36 | { 37 | 38 | global $wpdb; 39 | $table_name = $wpdb->prefix . 'cb_timeframes'; // do not forget about tables prefix 40 | 41 | // sql to create your table 42 | // NOTICE that: 43 | // 1. each field MUST be in separate line 44 | // 2. There must be two spaces between PRIMARY KEY and its name 45 | // Like this: PRIMARY KEY[space][space](id) 46 | // otherwise dbDelta will not work 47 | $sql = "CREATE TABLE " . $table_name . " ( 48 | id int(11) unsigned NOT NULL AUTO_INCREMENT, 49 | timeframe_title text, 50 | item_id int(11) DEFAULT NULL, 51 | location_id int(11) DEFAULT NULL, 52 | date_start date DEFAULT NULL, 53 | date_end date DEFAULT NULL, 54 | PRIMARY KEY (id) 55 | );"; 56 | 57 | // we do not execute sql directly 58 | // we are calling dbDelta which cant migrate database 59 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 60 | dbDelta($sql); 61 | 62 | // save current database version for later use (on upgrade) 63 | add_option('commons_booking_timeframes_table_db_version', $this->table_db_version); 64 | 65 | /** 66 | * [OPTIONAL] Example of updating to 0.1 version 67 | * 68 | * If you develop new version of plugin 69 | * just increment $this->table_db_version variable 70 | * and add following block of code 71 | * 72 | * must be repeated for each new version 73 | * in version 0.1 we change email field 74 | * to contain 200 chars rather 100 in version 1.0 75 | * and again we are not executing sql 76 | * we are using dbDelta to migrate table changes 77 | */ 78 | 79 | $installed_ver = get_option('commons_booking_timeframes_table_db_version'); 80 | if ($installed_ver != $this->table_db_version) { 81 | $sql = "CREATE TABLE " . $table_name . " ( 82 | id int(11) unsigned NOT NULL AUTO_INCREMENT, 83 | timeframe_title text, 84 | item_id int(11) DEFAULT NULL, 85 | location_id int(11) DEFAULT NULL, 86 | date_start date DEFAULT NULL, 87 | date_end date DEFAULT NULL, 88 | PRIMARY KEY (id) 89 | );"; 90 | 91 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 92 | dbDelta($sql); 93 | 94 | // notice that we are updating option, rather than adding it 95 | update_option('commons_booking_timeframes_table_db_version', $this->table_db_version); 96 | } 97 | } 98 | 99 | 100 | /** 101 | * register_activation_hook implementation 102 | * 103 | * [OPTIONAL] 104 | * additional implementation of register_activation_hook 105 | * to insert some dummy data 106 | */ 107 | public function install_data() 108 | { 109 | global $wpdb; 110 | 111 | $table_name = $wpdb->prefix . 'cb_timeframes'; // do not forget about tables prefix 112 | 113 | $wpdb->insert($table_name, array( 114 | 'timeframe_title' => 'Test' 115 | )); 116 | } 117 | 118 | 119 | /** 120 | * Trick to update plugin database, see docs 121 | */ 122 | public function update_db_check() 123 | { 124 | if (get_site_option('cb_timeframes_table_db_version') != $this->table_db_version) { 125 | cb_timeframes_table_install(); 126 | } 127 | } 128 | } 129 | 130 | ?> -------------------------------------------------------------------------------- /admin/cb-widgets/cb-user-widget.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GPL-2.0+ 9 | * @link http://www.wielebenwir.de 10 | * @copyright 2015 wielebenwir 11 | * @since 0.9 12 | */ 13 | 14 | // Create custom widget class extending WP_Widget 15 | class CB_User_Widget extends WP_Widget { 16 | 17 | function __construct() { 18 | 19 | $plugin = Commons_Booking::get_instance(); 20 | $this->plugin_slug = $plugin->get_plugin_slug(); 21 | $this->settings = $plugin->get_cb_settings(); 22 | 23 | parent::__construct( 24 | 'cb_user_widget', // Base ID 25 | __( 'Commons Booking user', 'commons-booking' ), // Name 26 | array( 'description' => __( 'User functions (login, logout, register, my bookings)', 'commons-booking' ), ) // Args 27 | ); 28 | 29 | } 30 | 31 | /** 32 | * Back-end widget form. 33 | * 34 | * @see WP_Widget::form() 35 | * 36 | * @param array $instance Previously saved values from database. 37 | */ 38 | public function form( $instance ) { 39 | $title = ! empty( $instance['title'] ) ? $instance['title'] : ""; 40 | ?> 41 |

42 | 43 | 44 |

45 | render_userinfo(); 78 | 79 | echo $args[ 'after_widget' ]; 80 | } 81 | /** 82 | * All the user info. 83 | * 84 | **/ 85 | function render_userinfo() { 86 | 87 | $content = ""; 88 | 89 | if ( is_user_logged_in() ) { 90 | 91 | $current_user = wp_get_current_user(); 92 | 93 | $bookings_page_id = $this->settings->get_settings('pages', 'user_bookings_page_select'); 94 | $bookings_page_url = get_permalink( $bookings_page_id ); 95 | 96 | $content .= sprintf( __( 'Welcome, %s.', 'commons-booking' ), $current_user->display_name); 97 | $content .= '
    '; 98 | $content .= sprintf( __( '
  • My Bookings
  • ', 'commons-booking' ), $bookings_page_url ); 99 | $content .= sprintf( __( '
  • My Profile
  • ', 'commons-booking' ), get_edit_profile_url() ); 100 | $content .= sprintf( __( '
  • Log out
  • ', 'commons-booking' ), wp_logout_url() ); 101 | $content .= '
'; 102 | 103 | } else { 104 | 105 | $content = __('You are not logged in.', 'commons-booking'); 106 | $content .= "
    "; 107 | $content .= sprintf(__('
  • Login
  • ', 'commons-booking'), wp_login_url() ); 108 | $content .= sprintf(__('
  • Register
  • ', 'commons-booking'), wp_registration_url() ); 109 | $content .= "
"; 110 | } 111 | 112 | return $content; 113 | 114 | } 115 | 116 | } 117 | 118 | // register CB_User_Widget 119 | function register_cb_user_widget() { 120 | register_widget( 'CB_User_Widget' ); 121 | } 122 | add_action( 'widgets_init', 'register_cb_user_widget' ); 123 | 124 | -------------------------------------------------------------------------------- /public/assets/sass/themes/standard/partials/calendar.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Calendar 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | .cb-timeframes-wrapper { 12 | } 13 | 14 | .cb-timeframe { 15 | 16 | @extend .cb-box; 17 | 18 | // this class pushes the calendar cells into the right position 19 | .pusher { 20 | &.day1 {margin-left: 0; } 21 | &.day2 {margin-left: $cellwidth; } 22 | &.day3 {margin-left: $cellwidth * 2; } 23 | &.day4 {margin-left: $cellwidth * 3; } 24 | &.day5 {margin-left: $cellwidth * 4; } 25 | &.day6 {margin-left: $cellwidth * 5; } 26 | &.day7 {margin-left: $cellwidth * 6; } 27 | 28 | } 29 | 30 | .cb-location { 31 | display: block; 32 | overflow: hidden; 33 | .cb-date, .cb-address, .cb-contact { 34 | 35 | } 36 | .cb-location-name { 37 | @extend .cb-big; 38 | } 39 | } 40 | 41 | /* Calendar */ 42 | ul.cb-calendar { 43 | list-style: none; 44 | clear: both; 45 | overflow: hidden; 46 | margin: 1em 0 1em 0; 47 | 48 | input { 49 | display:none; 50 | } 51 | 52 | .cb-weekday { 53 | 54 | } 55 | 56 | li:first-of-type { 57 | @extend .pusher; // add margin to push first entry. 58 | } 59 | 60 | 61 | li, div.cb-weekday-row span { 62 | -webkit-box-sizing: border-box; 63 | -moz-box-sizing: border-box; 64 | box-sizing: border-box; 65 | width: $cellwidth; 66 | position: relative; 67 | overflow: hidden; 68 | padding: 4px; 69 | float: left; 70 | text-align: center; 71 | background: $bg-color; 72 | color: $inactive-color; 73 | margin: 0; 74 | 75 | 76 | @include transition(all .3s ease); 77 | 78 | .cb-cal-inner { 79 | min-height: $cellheight; 80 | span.cb-j { 81 | margin-top:5px; 82 | display: block; 83 | line-height: 1em; 84 | } 85 | span.cb-M { 86 | margin-bottom:5px; 87 | display: block; 88 | font-size: 0.7em; 89 | } 90 | @include border-radius($radius); 91 | height: 100%; 92 | padding: 2px; 93 | 94 | &:hover { 95 | } 96 | } 97 | 98 | &.bookable { // selectable dates 99 | cursor: pointer; 100 | color: $action-color; 101 | 102 | .cb-cal-inner { 103 | } 104 | 105 | .cb-cal-inner:hover { 106 | background: $highlight-color-dark; 107 | color: $bg-color; 108 | } 109 | } 110 | &.selected { 111 | background: $highlight-color; 112 | color: mix($bg-color, $highlight-color, 60%); 113 | } 114 | &:hover { 115 | // @include border-radius($radius); 116 | } 117 | &.selected-first { 118 | @include selection-start-round($radius); 119 | .cb-cal-inner { 120 | color: $bg-color; 121 | background: $highlight-color-dark; 122 | } 123 | } 124 | &.selected-last { 125 | @include selection-end-round($radius); 126 | .cb-cal-inner { 127 | color: $bg-color; 128 | background: $highlight-color-dark; 129 | } 130 | } 131 | 132 | &.booked { 133 | cursor: not-allowed; 134 | color: $error-color-dark; 135 | .cb-cal-inner { 136 | // background: $grey; 137 | // color: $error-color-dark; 138 | background: $error-color-dark; 139 | color: $bg-color; 140 | } 141 | } 142 | &.closed { 143 | cursor: not-allowed; 144 | color: darken( $inactive-color, 20%); 145 | .cb-cal-inner { 146 | background: $bg-inner-color; 147 | } 148 | &.overbooking { 149 | @extend .selected; 150 | 151 | } 152 | } 153 | } 154 | div.cb-weekday-row { 155 | span { 156 | color: darken( $inactive-color, 20%); 157 | font-size: 0.7em; 158 | } 159 | 160 | } 161 | } 162 | } -------------------------------------------------------------------------------- /public/assets/sass/themes/kasimir/partials/calendar.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Calendar 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | .cb-timeframes-wrapper { 12 | } 13 | 14 | .cb-timeframe { 15 | 16 | @extend .cb-box; 17 | 18 | // this class pushes the calendar cells into the right position 19 | .pusher { 20 | &.day1 {margin-left: 0; } 21 | &.day2 {margin-left: $cellwidth; } 22 | &.day3 {margin-left: $cellwidth * 2; } 23 | &.day4 {margin-left: $cellwidth * 3; } 24 | &.day5 {margin-left: $cellwidth * 4; } 25 | &.day6 {margin-left: $cellwidth * 5; } 26 | &.day7 {margin-left: $cellwidth * 6; } 27 | 28 | } 29 | 30 | .cb-location { 31 | display: block; 32 | overflow: hidden; 33 | .cb-date, .cb-address, .cb-contact { 34 | 35 | } 36 | .cb-location-name { 37 | @extend .cb-big; 38 | } 39 | } 40 | 41 | /* Calendar */ 42 | ul.cb-calendar { 43 | list-style: none; 44 | clear: both; 45 | overflow: hidden; 46 | margin: 1em 0 1em 0; 47 | background: $white; 48 | @include border-radius($radius); 49 | 50 | 51 | input { 52 | display:none; 53 | } 54 | 55 | .cb-weekday { 56 | 57 | } 58 | 59 | li:first-of-type { 60 | @extend .pusher; // add margin to push first entry. 61 | } 62 | 63 | 64 | li, div.cb-weekday-row span { 65 | -webkit-box-sizing: border-box; 66 | -moz-box-sizing: border-box; 67 | box-sizing: border-box; 68 | width: $cellwidth; 69 | position: relative; 70 | overflow: hidden; 71 | padding: 4px; 72 | float: left; 73 | text-align: center; 74 | color: $black; 75 | @include transition(all .3s ease); 76 | 77 | .cb-cal-inner { 78 | min-height: $cellheight; 79 | 80 | span.cb-j { 81 | margin-top:5px; 82 | display: block; 83 | line-height: 1em; 84 | } 85 | span.cb-M { 86 | margin-bottom:5px; 87 | display: block; 88 | font-size: 0.7em; 89 | } 90 | @include border-radius($radius); 91 | height: 100%; 92 | padding: 2px; 93 | 94 | &:hover { 95 | } 96 | } 97 | 98 | &.bookable { // selectable dates 99 | cursor: pointer; 100 | color: $action-color; 101 | 102 | .cb-cal-inner { 103 | background: $white; 104 | } 105 | 106 | .cb-cal-inner:hover { 107 | background: $highlight-color-dark; 108 | color: $bg-color; 109 | } 110 | } 111 | &.selected { 112 | background: $highlight-color; 113 | color: mix($bg-color, $highlight-color, 60%); 114 | .cb-cal-inner { 115 | background: transparent; 116 | } 117 | } 118 | &:hover { 119 | // @include border-radius($radius); 120 | } 121 | &.selected-first { 122 | @include selection-start-round($radius); 123 | .cb-cal-inner { 124 | color: $white; 125 | background: $highlight-color-dark; 126 | } 127 | } 128 | &.selected-last { 129 | @include selection-end-round($radius); 130 | .cb-cal-inner { 131 | color: $white; 132 | background: $highlight-color-dark; 133 | } 134 | } 135 | 136 | &.booked { 137 | cursor: not-allowed; 138 | color: $error-color; 139 | .cb-cal-inner { 140 | // background: $grey; 141 | // color: $error-color-dark; 142 | background: $grey; 143 | color: $white; 144 | } 145 | } 146 | &.closed { 147 | cursor: not-allowed; 148 | color: darken( $inactive-color, 20%); 149 | .cb-cal-inner { 150 | // background: $bg-inner-color; 151 | } 152 | &.overbooking { 153 | @extend .selected; 154 | 155 | } 156 | } 157 | } 158 | div.cb-weekday-row { 159 | span { 160 | color: darken( $inactive-color, 20%); 161 | font-size: 0.7em; 162 | } 163 | 164 | } 165 | } 166 | } -------------------------------------------------------------------------------- /commons-booking.php: -------------------------------------------------------------------------------- 1 | 9 | * @license GPL-2.0+ 10 | * @link http://www.wielebenwir.de 11 | * @copyright 2015 wielebenwir 12 | * 13 | * @wordpress-plugin 14 | * Plugin Name: CB (legacy) 15 | * Plugin URI: https://www.commonsbooking.org 16 | * Description: Legacy version (0.X) of CommonsBooking 17 | * Version: 0.9.4.18 18 | * Author: Florian Egermann 19 | * Author URI: http://www.wielebenwir.de 20 | * Text Domain: commons-booking 21 | * License: GPL-2.0+ 22 | * License URI: http://www.gnu.org/licenses/gpl-2.0.txt 23 | * Domain Path: /languages 24 | * WordPress-Plugin-Boilerplate-Powered: v1.1.0 25 | */ 26 | // If this file is called directly, abort. 27 | if ( !defined( 'WPINC' ) ) { 28 | die; 29 | } 30 | 31 | /* ----------------------------------------------------------------------------* 32 | * Public-Facing Functionality 33 | * ---------------------------------------------------------------------------- */ 34 | 35 | /* 36 | * Load library for simple and fast creation of Taxonomy and Custom Post Type 37 | */ 38 | require_once( plugin_dir_path( __FILE__ ) . 'includes/CPT_Core/CPT_Core.php' ); 39 | require_once( plugin_dir_path( __FILE__ ) . 'includes/Taxonomy_Core/Taxonomy_Core.php' ); 40 | 41 | /* 42 | * Load main public class 43 | */ 44 | require_once( plugin_dir_path( __FILE__ ) . 'public/class-commons-booking.php' ); 45 | 46 | /* 47 | * Load classes for items, comments, bookings... 48 | */ 49 | // Booking functionality 50 | require_once( plugin_dir_path( __FILE__ ) . 'public/cb-bookings/class-cb-booking.php' ); 51 | // Items 52 | require_once( plugin_dir_path( __FILE__ ) . 'public/cb-bookings/class-cb-public-items.php' ); 53 | // Data: Class for accessing all Data generated by the plugin 54 | require_once( plugin_dir_path( __FILE__ ) . 'public/cb-bookings/class-cb-data.php' ); 55 | // Comments on Bookings 56 | require_once( plugin_dir_path( __FILE__ ) . 'public/cb-bookings/class-cb-booking-comments.php' ); 57 | // Timeframe object 58 | require_once( plugin_dir_path( __FILE__ ) . 'admin/cb-timeframes/cb-timeframes.php' ); 59 | // Users 60 | require_once( plugin_dir_path( __FILE__ ) . 'admin/cb-users/class-cb-users.php' ); 61 | // Load the settings module 62 | require_once( plugin_dir_path( __FILE__ ) . 'admin/cb-settings/cb-admin-settings.php' ); 63 | 64 | /* 65 | * Installers 66 | */ 67 | // Codes: Classes for Install/Update functionality for database tables 68 | require_once( plugin_dir_path( __FILE__ ) . 'admin/cb-codes/class-cb-codes-setup.php' ); 69 | // Bookings: Classes for Install/Update the database tables 70 | require_once( plugin_dir_path( __FILE__ ) . 'admin/cb-bookings/class-cb-bookings-setup.php' ); 71 | // Users: Classes for Install/Update the database Tables 72 | 73 | // TIMEFRAMES 74 | 75 | /* 76 | * Helper Functions 77 | */ 78 | require_once( plugin_dir_path( __FILE__ ) . 'includes/commons-booking-helpers.php' ); 79 | require_once( plugin_dir_path( __FILE__ ) . 'includes/array_column.php' ); 80 | 81 | /* 82 | * Load template system 83 | */ 84 | require_once( plugin_dir_path( __FILE__ ) . 'includes/template.php' ); 85 | 86 | 87 | /* 88 | * Load Widgets 89 | */ 90 | require_once( plugin_dir_path( __FILE__ ) . 'admin/cb-widgets/cb-user-widget.php' ); 91 | require_once( plugin_dir_path( __FILE__ ) . 'admin/cb-widgets/cb-category-widget.php' ); 92 | 93 | 94 | 95 | /* 96 | * Register hooks that are fired when the plugin is activated or deactivated. 97 | * 98 | */ 99 | 100 | register_activation_hook( __FILE__, array( 'Commons_Booking', 'single_activate' ) ); 101 | register_deactivation_hook( __FILE__, array( 'Commons_Booking', 'deactivate' ) ); 102 | 103 | add_action( 'plugins_loaded', array( 'Commons_Booking', 'get_instance' ) ); 104 | 105 | /* ----------------------------------------------------------------------------* 106 | * Dashboard and Administrative Functionality 107 | * ---------------------------------------------------------------------------- */ 108 | if ( is_admin() && (!defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) { 109 | 110 | require_once( plugin_dir_path( __FILE__ ) . 'admin/class-cb-admin.php' ); 111 | add_action( 'plugins_loaded', array( 'Commons_Booking_Admin', 'get_instance' ) ); 112 | } 113 | -------------------------------------------------------------------------------- /admin/cb-bookings/class-cb-bookings-setup.php: -------------------------------------------------------------------------------- 1 | 7 | * @license GPL-2.0+ 8 | * @link http://www.wielebenwir.de 9 | * @copyright 2015 wielebenwir 10 | */ 11 | 12 | /** 13 | * Handles install & update of the Bookings Table 14 | * 15 | * @package Commons_Booking_Booking_Setup 16 | * @author Florian Egermann 17 | */ 18 | 19 | 20 | class Commons_Booking_Bookings_Setup { 21 | 22 | public $table_db_version = '0.1'; 23 | 24 | public function __construct () { 25 | 26 | $this->table_db_version = '0.1'; 27 | 28 | } 29 | 30 | /** 31 | * register_activation_hook implementation 32 | * 33 | * will be called when user activates plugin first time 34 | * must create needed database tables 35 | */ 36 | public function install() 37 | { 38 | 39 | global $wpdb; 40 | $table_name = $wpdb->prefix . 'cb_bookings'; // do not forget about tables prefix 41 | 42 | // sql to create your table 43 | // NOTICE that: 44 | // 1. each field MUST be in separate line 45 | // 2. There must be two spaces between PRIMARY KEY and its name 46 | // Like this: PRIMARY KEY[space][space](id) 47 | // otherwise dbDelta will not work 48 | $sql = "CREATE TABLE " . $table_name . " ( 49 | id int(11) NOT NULL AUTO_INCREMENT, 50 | date_start date NOT NULL, 51 | date_end date NOT NULL, 52 | item_id int(11) NOT NULL, 53 | user_id int(11) NOT NULL, 54 | code_id int(11) NOT NULL, 55 | location_id int(11) NOT NULL, 56 | booking_time datetime NOT NULL, 57 | status varchar(50) NOT NULL, 58 | hash varchar(50) NOT NULL, 59 | comment text, 60 | PRIMARY KEY (id) 61 | );"; 62 | 63 | // we do not execute sql directly 64 | // we are calling dbDelta which cant migrate database 65 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 66 | dbDelta($sql); 67 | 68 | // save current database version for later use (on upgrade) 69 | add_option('commons_booking_bookings_table_db_version', $this->table_db_version); 70 | 71 | /** 72 | * [OPTIONAL] Example of updating to 0.1 version 73 | * 74 | * If you develop new version of plugin 75 | * just increment $this->table_db_version variable 76 | * and add following block of code 77 | * 78 | * must be repeated for each new version 79 | * in version 0.1 we change email field 80 | * to contain 200 chars rather 100 in version 1.0 81 | * and again we are not executing sql 82 | * we are using dbDelta to migrate table changes 83 | */ 84 | 85 | $installed_ver = get_option('commons_booking_bookings_table_db_version'); 86 | if ($installed_ver != $this->table_db_version) { 87 | $sql = "CREATE TABLE " . $table_name . " ( 88 | id int(11) NOT NULL AUTO_INCREMENT, 89 | date_start date NOT NULL, 90 | date_end date NOT NULL, 91 | item_id int(11) NOT NULL, 92 | user_id int(11) NOT NULL, 93 | code_id int(11) NOT NULL, 94 | location_id int(11) NOT NULL, 95 | booking_time datetime NOT NULL, 96 | status varchar(50) NOT NULL, 97 | hash varchar(50) NOT NULL, 98 | comment text, 99 | PRIMARY KEY (id) 100 | );"; 101 | 102 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 103 | dbDelta($sql); 104 | 105 | // notice that we are updating option, rather than adding it 106 | update_option('commons_booking_bookings_table_db_version', $this->table_db_version); 107 | } 108 | } 109 | 110 | 111 | /** 112 | * register_activation_hook implementation 113 | * 114 | * [OPTIONAL] 115 | * additional implementation of register_activation_hook 116 | * to insert some dummy data 117 | */ 118 | public function install_data() 119 | { 120 | global $wpdb; 121 | 122 | $table_name = $wpdb->prefix . 'cb_bookings'; // do not forget about tables prefix 123 | 124 | $wpdb->insert($table_name, array( 125 | 'date_start' => '2015-01-01' 126 | )); 127 | } 128 | 129 | 130 | /** 131 | * Trick to update plugin database, see docs 132 | */ 133 | public function update_db_check() 134 | { 135 | if (get_site_option('cb_bookings_table_db_version') != $this->table_db_version) { 136 | cb_bookings_table_install(); 137 | } 138 | } 139 | } 140 | 141 | ?> -------------------------------------------------------------------------------- /admin/assets/sass/admin.scss: -------------------------------------------------------------------------------- 1 | .box { 2 | padding: 20px; 3 | background: white; 4 | } 5 | 6 | /* Timeframe edit Time picker */ 7 | 8 | .ui-datepicker-div { 9 | background: #fff; 10 | } 11 | 12 | /* Overlays */ 13 | .ui-widget-overlay { 14 | position: fixed; 15 | top: 0; 16 | left: 0; 17 | width: 100%; 18 | height: 100%; 19 | } 20 | .ui-datepicker { 21 | width: 17em; 22 | padding: .2em .2em 0; 23 | display: none; 24 | } 25 | .ui-datepicker .ui-datepicker-header { 26 | position: relative; 27 | padding: .2em 0; 28 | } 29 | .ui-datepicker .ui-datepicker-prev, 30 | .ui-datepicker .ui-datepicker-next { 31 | position: absolute; 32 | top: 2px; 33 | width: 1.8em; 34 | height: 1.8em; 35 | } 36 | .ui-datepicker .ui-datepicker-prev-hover, 37 | .ui-datepicker .ui-datepicker-next-hover { 38 | top: 1px; 39 | } 40 | .ui-datepicker .ui-datepicker-prev { 41 | left: 2px; 42 | } 43 | .ui-datepicker .ui-datepicker-next { 44 | right: 2px; 45 | } 46 | .ui-datepicker .ui-datepicker-prev-hover { 47 | left: 1px; 48 | } 49 | .ui-datepicker .ui-datepicker-next-hover { 50 | right: 1px; 51 | } 52 | .ui-datepicker .ui-datepicker-prev span, 53 | .ui-datepicker .ui-datepicker-next span { 54 | display: block; 55 | position: absolute; 56 | left: 50%; 57 | margin-left: -8px; 58 | top: 50%; 59 | margin-top: -8px; 60 | } 61 | .ui-datepicker .ui-datepicker-title { 62 | margin: 0 2.3em; 63 | line-height: 1.8em; 64 | text-align: center; 65 | } 66 | .ui-datepicker .ui-datepicker-title select { 67 | font-size: 1em; 68 | margin: 1px 0; 69 | } 70 | .ui-datepicker select.ui-datepicker-month, 71 | .ui-datepicker select.ui-datepicker-year { 72 | width: 45%; 73 | } 74 | .ui-datepicker table { 75 | width: 100%; 76 | font-size: .9em; 77 | border-collapse: collapse; 78 | margin: 0 0 .4em; 79 | } 80 | .ui-datepicker th { 81 | padding: .7em .3em; 82 | text-align: center; 83 | font-weight: bold; 84 | border: 0; 85 | } 86 | .ui-datepicker td { 87 | border: 0; 88 | padding: 1px; 89 | } 90 | .ui-datepicker td span, 91 | .ui-datepicker td a { 92 | display: block; 93 | padding: .2em; 94 | text-align: right; 95 | text-decoration: none; 96 | } 97 | .ui-datepicker .ui-datepicker-buttonpane { 98 | background-image: none; 99 | margin: .7em 0 0 0; 100 | padding: 0 .2em; 101 | border-left: 0; 102 | border-right: 0; 103 | border-bottom: 0; 104 | } 105 | .ui-datepicker .ui-datepicker-buttonpane button { 106 | float: right; 107 | margin: .5em .2em .4em; 108 | cursor: pointer; 109 | padding: .2em .6em .3em .6em; 110 | width: auto; 111 | overflow: visible; 112 | } 113 | .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { 114 | float: left; 115 | } 116 | 117 | /* with multiple calendars */ 118 | .ui-datepicker.ui-datepicker-multi { 119 | width: auto; 120 | } 121 | .ui-datepicker-multi .ui-datepicker-group { 122 | float: left; 123 | } 124 | .ui-datepicker-multi .ui-datepicker-group table { 125 | width: 95%; 126 | margin: 0 auto .4em; 127 | } 128 | .ui-datepicker-multi-2 .ui-datepicker-group { 129 | width: 50%; 130 | } 131 | .ui-datepicker-multi-3 .ui-datepicker-group { 132 | width: 33.3%; 133 | } 134 | .ui-datepicker-multi-4 .ui-datepicker-group { 135 | width: 25%; 136 | } 137 | .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header, 138 | .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { 139 | border-left-width: 0; 140 | } 141 | .ui-datepicker-multi .ui-datepicker-buttonpane { 142 | clear: left; 143 | } 144 | .ui-datepicker-row-break { 145 | clear: both; 146 | width: 100%; 147 | font-size: 0; 148 | } 149 | 150 | /* RTL support */ 151 | .ui-datepicker-rtl { 152 | direction: rtl; 153 | } 154 | .ui-datepicker-rtl .ui-datepicker-prev { 155 | right: 2px; 156 | left: auto; 157 | } 158 | .ui-datepicker-rtl .ui-datepicker-next { 159 | left: 2px; 160 | right: auto; 161 | } 162 | .ui-datepicker-rtl .ui-datepicker-prev:hover { 163 | right: 1px; 164 | left: auto; 165 | } 166 | .ui-datepicker-rtl .ui-datepicker-next:hover { 167 | left: 1px; 168 | right: auto; 169 | } 170 | .ui-datepicker-rtl .ui-datepicker-buttonpane { 171 | clear: right; 172 | } 173 | .ui-datepicker-rtl .ui-datepicker-buttonpane button { 174 | float: left; 175 | } 176 | .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current, 177 | .ui-datepicker-rtl .ui-datepicker-group { 178 | float: right; 179 | } 180 | .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header, 181 | .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { 182 | border-right-width: 0; 183 | border-left-width: 1px; 184 | } 185 | 186 | 187 | -------------------------------------------------------------------------------- /includes/array_column.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /admin/assets/css/admin.css: -------------------------------------------------------------------------------- 1 | .box { 2 | padding: 20px; 3 | background: white; } 4 | 5 | /* Timeframe edit Time picker */ 6 | .ui-datepicker-div { 7 | background: #fff; } 8 | 9 | /* Overlays */ 10 | .ui-widget-overlay { 11 | position: fixed; 12 | top: 0; 13 | left: 0; 14 | width: 100%; 15 | height: 100%; } 16 | 17 | .ui-datepicker { 18 | width: 17em; 19 | padding: .2em .2em 0; 20 | display: none; } 21 | 22 | .ui-datepicker .ui-datepicker-header { 23 | position: relative; 24 | padding: .2em 0; } 25 | 26 | .ui-datepicker .ui-datepicker-prev, 27 | .ui-datepicker .ui-datepicker-next { 28 | position: absolute; 29 | top: 2px; 30 | width: 1.8em; 31 | height: 1.8em; } 32 | 33 | .ui-datepicker .ui-datepicker-prev-hover, 34 | .ui-datepicker .ui-datepicker-next-hover { 35 | top: 1px; } 36 | 37 | .ui-datepicker .ui-datepicker-prev { 38 | left: 2px; } 39 | 40 | .ui-datepicker .ui-datepicker-next { 41 | right: 2px; } 42 | 43 | .ui-datepicker .ui-datepicker-prev-hover { 44 | left: 1px; } 45 | 46 | .ui-datepicker .ui-datepicker-next-hover { 47 | right: 1px; } 48 | 49 | .ui-datepicker .ui-datepicker-prev span, 50 | .ui-datepicker .ui-datepicker-next span { 51 | display: block; 52 | position: absolute; 53 | left: 50%; 54 | margin-left: -8px; 55 | top: 50%; 56 | margin-top: -8px; } 57 | 58 | .ui-datepicker .ui-datepicker-title { 59 | margin: 0 2.3em; 60 | line-height: 1.8em; 61 | text-align: center; } 62 | 63 | .ui-datepicker .ui-datepicker-title select { 64 | font-size: 1em; 65 | margin: 1px 0; } 66 | 67 | .ui-datepicker select.ui-datepicker-month, 68 | .ui-datepicker select.ui-datepicker-year { 69 | width: 45%; } 70 | 71 | .ui-datepicker table { 72 | width: 100%; 73 | font-size: .9em; 74 | border-collapse: collapse; 75 | margin: 0 0 .4em; } 76 | 77 | .ui-datepicker th { 78 | padding: .7em .3em; 79 | text-align: center; 80 | font-weight: bold; 81 | border: 0; } 82 | 83 | .ui-datepicker td { 84 | border: 0; 85 | padding: 1px; } 86 | 87 | .ui-datepicker td span, 88 | .ui-datepicker td a { 89 | display: block; 90 | padding: .2em; 91 | text-align: right; 92 | text-decoration: none; } 93 | 94 | .ui-datepicker .ui-datepicker-buttonpane { 95 | background-image: none; 96 | margin: .7em 0 0 0; 97 | padding: 0 .2em; 98 | border-left: 0; 99 | border-right: 0; 100 | border-bottom: 0; } 101 | 102 | .ui-datepicker .ui-datepicker-buttonpane button { 103 | float: right; 104 | margin: .5em .2em .4em; 105 | cursor: pointer; 106 | padding: .2em .6em .3em .6em; 107 | width: auto; 108 | overflow: visible; } 109 | 110 | .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { 111 | float: left; } 112 | 113 | /* with multiple calendars */ 114 | .ui-datepicker.ui-datepicker-multi { 115 | width: auto; } 116 | 117 | .ui-datepicker-multi .ui-datepicker-group { 118 | float: left; } 119 | 120 | .ui-datepicker-multi .ui-datepicker-group table { 121 | width: 95%; 122 | margin: 0 auto .4em; } 123 | 124 | .ui-datepicker-multi-2 .ui-datepicker-group { 125 | width: 50%; } 126 | 127 | .ui-datepicker-multi-3 .ui-datepicker-group { 128 | width: 33.3%; } 129 | 130 | .ui-datepicker-multi-4 .ui-datepicker-group { 131 | width: 25%; } 132 | 133 | .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header, 134 | .ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { 135 | border-left-width: 0; } 136 | 137 | .ui-datepicker-multi .ui-datepicker-buttonpane { 138 | clear: left; } 139 | 140 | .ui-datepicker-row-break { 141 | clear: both; 142 | width: 100%; 143 | font-size: 0; } 144 | 145 | /* RTL support */ 146 | .ui-datepicker-rtl { 147 | direction: rtl; } 148 | 149 | .ui-datepicker-rtl .ui-datepicker-prev { 150 | right: 2px; 151 | left: auto; } 152 | 153 | .ui-datepicker-rtl .ui-datepicker-next { 154 | left: 2px; 155 | right: auto; } 156 | 157 | .ui-datepicker-rtl .ui-datepicker-prev:hover { 158 | right: 1px; 159 | left: auto; } 160 | 161 | .ui-datepicker-rtl .ui-datepicker-next:hover { 162 | left: 1px; 163 | right: auto; } 164 | 165 | .ui-datepicker-rtl .ui-datepicker-buttonpane { 166 | clear: right; } 167 | 168 | .ui-datepicker-rtl .ui-datepicker-buttonpane button { 169 | float: left; } 170 | 171 | .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current, 172 | .ui-datepicker-rtl .ui-datepicker-group { 173 | float: right; } 174 | 175 | .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header, 176 | .ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { 177 | border-right-width: 0; 178 | border-left-width: 1px; } 179 | -------------------------------------------------------------------------------- /public/assets/sass/themes/kasimir/partials/base.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard elements 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | .padding { padding: $padding; } 12 | .align-right { float: right; } 13 | .align-left { float: left; } 14 | .cb-small { font-size: 0.8em; } 15 | .cb-big { font-size: 1.4em; font-weight: bold; color: $kasi-orange; margin-bottom: $padding / 2; } 16 | .border { border-top: 1px solid $grey; display: block; } 17 | .cb-headline { 18 | @extend .cb-big; 19 | a { color: $highlight-color } 20 | } 21 | 22 | 23 | 24 | /* all individual elements (timeframes, items, etc) are grouped with cb-box */ 25 | .cb-wrapper {} 26 | 27 | /* all individual elements (timeframes, items, etc) are grouped with cb-box */ 28 | .cb-box { 29 | @extend .padding; 30 | overflow: hidden; 31 | border: 1px solid $border-color; 32 | @include rounded($radius); 33 | background: $bg-color; 34 | margin-bottom: $padding * 2; 35 | } 36 | 37 | .cb-big a { 38 | color: $kasi-orange; 39 | text-decoration: none; 40 | border-bottom: none !important; 41 | } 42 | 43 | .cb-table { 44 | margin-bottom: $padding; 45 | display: block; 46 | .cb-row { 47 | color: $dark-grey; 48 | border-top: 1px solid $border-inner-color; 49 | padding: $padding; 50 | overflow: hidden; 51 | background: $white; 52 | 53 | &:hover { 54 | } 55 | &:first-child { 56 | @include border-radiuses($radius, 0, 0, $radius ); 57 | } 58 | &:last-child { 59 | @include border-radiuses(0, $radius, $radius, 0 ); 60 | } 61 | &:only-child { 62 | @include border-radiuses($radius, $radius, $radius, $radius ); 63 | 64 | } 65 | .cb-row-title { 66 | font-weight: bold; 67 | margin-right: $padding; 68 | } 69 | .cb-big { 70 | display: block; 71 | } 72 | .cb-button { 73 | margin: 1em 0 1em 1em; 74 | } 75 | } 76 | } 77 | 78 | /* Bookings */ 79 | .cb-user-bar { 80 | margin-bottom: $padding * 2; 81 | a.cb-button { 82 | @extend .cb-small; 83 | background: $highlight-color; 84 | } 85 | } 86 | 87 | .cb-timeframe-title { 88 | display: none; 89 | } 90 | 91 | .entry-content .cb-box h2 { 92 | margin-top: 0; 93 | } 94 | 95 | .cb-location-name { 96 | display: block; 97 | font-weight: bold; 98 | } 99 | 100 | .cb-list-item-description { 101 | margin-bottom: $padding; 102 | display:block; 103 | overflow: hidden; 104 | img { 105 | @include rounded($radius); 106 | margin-right: $padding; 107 | } 108 | } 109 | 110 | a.cb-button, input#wp-submit, input#wp-submit-comment { 111 | @include transition(all .3s ease); 112 | white-space: nowrap; 113 | text-decoration: none; 114 | padding: 0.5em 1em; 115 | overflow: hidden; 116 | background: $action-color; 117 | color: $white; 118 | @include rounded($radius); 119 | border: none !important; 120 | &:hover { 121 | background: $highlight-color; 122 | color: $white; 123 | } 124 | &.cb-small { 125 | background: $highlight-color; 126 | border: 1px solid $grey; 127 | } 128 | &.warning { 129 | background: $dark-red; 130 | &:hover { 131 | background: $red; 132 | } 133 | } 134 | } 135 | 136 | .cb-row, 137 | .cb-user-bar { 138 | a.cb-button { 139 | } 140 | } 141 | 142 | .cb-booking-code strong{ 143 | padding: 5px; 144 | display:block; 145 | font-family: Courier, monospaced; 146 | color: green; 147 | font-weight: normal; 148 | } 149 | 150 | /***************** 151 | * MESSAGES 152 | * 153 | */ 154 | 155 | .cb-message { 156 | display: block; 157 | margin-bottom: $padding * 2; 158 | padding: $padding / 2 $padding ; 159 | @include rounded($radius); 160 | color: $white; 161 | strong { 162 | } 163 | &.success { 164 | color: darken( $green, 10%); 165 | background: lighten( $green, 40%); 166 | } 167 | &.error { 168 | background: $red; 169 | } 170 | } 171 | 172 | .cb-description { 173 | margin-bottom: 2em; 174 | } 175 | 176 | .cb-tooltipster { 177 | background: $highlight-color-dark; 178 | } 179 | 180 | /* FORMS */ 181 | 182 | .single-cb_items #comments { 183 | display: none; 184 | } 185 | 186 | .cb-booking-comment { 187 | @include rounded($radius); 188 | margin-bottom: $padding; 189 | overflow: hidden; 190 | form#cb-comment-form { 191 | } 192 | input { 193 | margin-top: $padding; 194 | float: right; 195 | 196 | } 197 | } 198 | 199 | .form-submit { 200 | background: transparent; 201 | input { 202 | float: right; 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /public/assets/sass/themes/standard/partials/base.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * Standard elements 3 | * @package Commons_Booking 4 | * @author Florian Egermann 5 | * @license GPL-2.0+ 6 | * @since 0.7 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | .padding { padding: $padding; } 12 | .align-right { float: right; } 13 | .align-left { float: left; } 14 | .cb-small { font-size: 0.8em; } 15 | .cb-big { font-size: 1.4em; font-weight: bold; color: $highlight-color; margin-bottom: $padding / 2; } 16 | .border { border-top: 1px solid $grey; display: block; } 17 | .cb-headline { 18 | @extend .cb-big; 19 | a { color: $highlight-color } 20 | } 21 | 22 | 23 | 24 | /* all individual elements (timeframes, items, etc) are grouped with cb-box */ 25 | .cb-wrapper {} 26 | 27 | /* all individual elements (timeframes, items, etc) are grouped with cb-box */ 28 | .cb-box { 29 | @extend .padding; 30 | overflow: hidden; 31 | border: 1px solid $border-color; 32 | @include rounded($radius); 33 | background: $bg-color; 34 | margin-bottom: $padding * 2; 35 | } 36 | 37 | .cb-big a { 38 | color: $highlight-color; 39 | text-decoration: none; 40 | border-bottom: none; 41 | } 42 | 43 | .cb-table { 44 | margin-bottom: $padding; 45 | display: block; 46 | .cb-row { 47 | color: $dark-grey; 48 | border-top: 1px solid $border-inner-color; 49 | padding: $padding / 2; 50 | overflow: hidden; 51 | background: $bg-inner-color; 52 | 53 | &:hover { 54 | } 55 | &:first-child { 56 | @include border-radiuses($radius, 0, 0, $radius ); 57 | } 58 | &:last-child { 59 | @include border-radiuses(0, $radius, $radius, 0 ); 60 | } 61 | &:only-child { 62 | @include border-radiuses($radius, $radius, $radius, $radius ); 63 | 64 | } 65 | .cb-row-title { 66 | font-weight: bold; 67 | margin-right: $padding; 68 | } 69 | .cb-big { 70 | display: block; 71 | } 72 | .cb-button { 73 | margin: 1em 0 1em 1em; 74 | } 75 | } 76 | } 77 | 78 | /* Bookings */ 79 | .cb-user-bar { 80 | margin-bottom: $padding * 2; 81 | a.cb-button { 82 | @extend .cb-small; 83 | background: $highlight-color; 84 | } 85 | } 86 | 87 | .cb-timeframe-title { 88 | display: none; 89 | } 90 | 91 | .entry-content .cb-box h2 { 92 | margin-top: 0; 93 | } 94 | 95 | .cb-location-name { 96 | display: block; 97 | color: $highlight-color; 98 | font-weight: bold; 99 | } 100 | 101 | .cb-list-item-description { 102 | margin-bottom: $padding; 103 | display:block; 104 | overflow: hidden; 105 | img { 106 | @include rounded($radius); 107 | margin-right: $padding; 108 | } 109 | } 110 | 111 | a.cb-button, input#wp-submit, input#wp-submit-comment { 112 | @include transition(all .3s ease); 113 | white-space: nowrap; 114 | text-decoration: none; 115 | padding: 10px 15px; 116 | overflow: hidden; 117 | background: $green; 118 | color: $white; 119 | @include rounded($radius); 120 | border: none !important; 121 | &:hover { 122 | background: $highlight-color; 123 | // border: 1px solid $highlight-color; 124 | color: $white; 125 | } 126 | &.cb-small { 127 | background: $highlight-color; 128 | border: 1px solid $grey; 129 | } 130 | &.warning { 131 | background: $dark-red; 132 | // border: 1px solid $dark-red !important; 133 | &:hover { 134 | background: $red; 135 | } 136 | } 137 | } 138 | 139 | .cb-row, 140 | .cb-user-bar { 141 | a.cb-button { 142 | padding: 5px 10px; 143 | } 144 | } 145 | 146 | .cb-booking-code strong{ 147 | padding: 5px; 148 | display:block; 149 | font-family: Courier, monospaced; 150 | color: green; 151 | font-weight: normal; 152 | } 153 | 154 | /***************** 155 | * MESSAGES 156 | * 157 | */ 158 | 159 | .cb-message { 160 | display: block; 161 | margin-bottom: $padding * 2; 162 | padding: $padding / 2 $padding ; 163 | @include rounded($radius); 164 | color: $white; 165 | strong { 166 | } 167 | &.success { 168 | color: darken( $green, 10%); 169 | background: lighten( $green, 40%); 170 | } 171 | &.error { 172 | background: $red; 173 | } 174 | } 175 | 176 | .cb-description { 177 | margin-bottom: 2em; 178 | } 179 | 180 | .cb-tooltipster { 181 | background: $highlight-color-dark; 182 | } 183 | 184 | /* FORMS */ 185 | 186 | .single-cb_items #comments { 187 | display: none; 188 | } 189 | 190 | .cb-booking-comment { 191 | background: $light-grey; 192 | padding: $padding; 193 | @include rounded($radius); 194 | margin-bottom: $padding; 195 | overflow: hidden; 196 | form#cb-comment-form { 197 | } 198 | input { 199 | margin-top: $padding; 200 | float: right; 201 | 202 | } 203 | } 204 | -------------------------------------------------------------------------------- /admin/cb-widgets/cb-items-widget.php: -------------------------------------------------------------------------------- 1 | plugin_slug = $plugin->get_plugin_slug(); 10 | 11 | // Configure widget array 12 | $args = array( 13 | 'label' => __( 'Items Widget', $this->plugin_slug ), 14 | 'description' => __( 'Show a list of items', $this->plugin_slug ), 15 | ); 16 | 17 | // Configure the widget fields 18 | // Example for: Title ( text ) and Amount of posts to show ( select box ) 19 | $args[ 'fields' ] = array( 20 | // Title field 21 | array( 22 | // field name/label 23 | 'name' => __( 'Title', $this->plugin_slug ), 24 | // field description 25 | 'desc' => __( 'Enter the widget title.', $this->plugin_slug ), 26 | // field id 27 | 'id' => 'title', 28 | // field type ( text, checkbox, textarea, select, select-group ) 29 | 'type' => 'text', 30 | // class, rows, cols 31 | 'class' => 'widefat', 32 | // default value 33 | 'std' => __( 'Recent Posts', $this->plugin_slug ), 34 | /* 35 | Set the field validation type/s 36 | /////////////////////////////// 37 | 38 | 'alpha_dash' 39 | Returns FALSE if the value contains anything other than alpha-numeric characters, underscores or dashes. 40 | 41 | 'alpha' 42 | Returns FALSE if the value contains anything other than alphabetical characters. 43 | 44 | 'alpha_numeric' 45 | Returns FALSE if the value contains anything other than alpha-numeric characters. 46 | 47 | 'numeric' 48 | Returns FALSE if the value contains anything other than numeric characters. 49 | 50 | 'boolean' 51 | Returns FALSE if the value contains anything other than a boolean value ( true or false ). 52 | 53 | ---------- 54 | 55 | You can define custom validation methods. Make sure to return a boolean ( TRUE/FALSE ). 56 | Example: 57 | 58 | 'validate' => 'my_custom_validation', 59 | 60 | Will call for: $this->my_custom_validation( $value_to_validate ); 61 | 62 | */ 63 | 'validate' => 'alpha_dash', 64 | /* 65 | 66 | Filter data before entering the DB 67 | ////////////////////////////////// 68 | 69 | strip_tags ( default ) 70 | wp_strip_all_tags 71 | esc_attr 72 | esc_url 73 | esc_textarea 74 | 75 | */ 76 | 'filter' => 'strip_tags|esc_attr' 77 | ), 78 | // Amount Field 79 | array( 80 | 'name' => __( 'Amount' ), 81 | 'desc' => __( 'Select how many posts to show.', $this->plugin_slug ), 82 | 'id' => 'amount', 83 | 'type' => 'select', 84 | // selectbox fields 85 | 'fields' => array( 86 | array( 87 | // option name 88 | 'name' => __( '1 Post', $this->plugin_slug ), 89 | // option value 90 | 'value' => '1' 91 | ), 92 | array( 93 | 'name' => __( '2 Posts', $this->plugin_slug ), 94 | 'value' => '2' 95 | ), 96 | array( 97 | 'name' => __( '3 Posts', $this->plugin_slug ), 98 | 'value' => '3' 99 | ) 100 | 101 | // add more options 102 | ), 103 | 'validate' => 'my_custom_validation', 104 | 'filter' => 'strip_tags|esc_attr', 105 | ), 106 | // Output type checkbox 107 | array( 108 | 'name' => __( 'Output as list', $this->plugin_slug ), 109 | 'desc' => __( 'Wraps posts with the
  • tag.', $this->plugin_slug ), 110 | 'id' => 'list', 111 | 'type' => 'checkbox', 112 | // checked by default: 113 | 'std' => 1, // 0 or 1 114 | 'filter' => 'strip_tags|esc_attr', 115 | ), 116 | // add more fields 117 | ); // fields array 118 | // create widget 119 | $this->create_widget( $args ); 120 | } 121 | 122 | // Custom validation for this widget 123 | 124 | function my_custom_validation( $value ) { 125 | if ( strlen( $value ) > 1 ) { 126 | return false; 127 | } else { 128 | return true; 129 | } 130 | } 131 | 132 | // Output function 133 | 134 | function widget( $args, $instance ) { 135 | 136 | // And here do whatever you want 137 | $out = $args[ 'before_title' ]; 138 | $out .= $instance[ 'title' ]; 139 | $out .= $args[ 'after_title' ]; 140 | 141 | // here you would get the most recent posts based on the selected amount: $instance['amount'] 142 | // Then return those posts on the $out variable ready for the output 143 | 144 | $out .= '

    Hey There!

    '; 145 | 146 | echo apply_filters( 'widget_text', $out ); 147 | } 148 | 149 | } 150 | 151 | // Register widget 152 | if ( !function_exists( 'my_register_widget' ) ) { 153 | 154 | function my_register_widget() { 155 | register_widget( 'My_Recent_Posts_Widget' ); 156 | } 157 | 158 | add_action( 'widgets_init', 'my_register_widget', 1 ); 159 | } 160 | -------------------------------------------------------------------------------- /public/cb-bookings/class-cb-booking-comments.php: -------------------------------------------------------------------------------- 1 | 8 | * @license GPL-2.0+ 9 | * @link http://www.wielebenwir.de 10 | 11 | * @copyright 2015 wielebenwir 12 | */ 13 | 14 | class CB_Booking_Comments { 15 | 16 | public $booking_hash; 17 | public $post_id; 18 | public $form_args; 19 | public $comments; 20 | public $url; 21 | public $table_name; 22 | 23 | public function __construct( ) { 24 | 25 | global $wpdb; 26 | $this->table_name = $wpdb->prefix . 'cb_bookings'; 27 | 28 | } 29 | 30 | 31 | public function set_booking_hash( $booking_hash ) { 32 | $this->booking_hash = $booking_hash; 33 | } 34 | 35 | public function set_post_id( $post_id ) { 36 | $this->post_id = $post_id; 37 | } 38 | 39 | public function get_booking_comments( $item_id ) { 40 | 41 | global $wpdb; 42 | $return = array(); 43 | $commentmeta_table = $wpdb->prefix . "commentmeta"; 44 | $comments_table = $wpdb->prefix . "comments"; 45 | 46 | // get booking_code-id from codes database 47 | $sqlresult = $wpdb->get_results($wpdb->prepare( 48 | " 49 | SELECT $this->table_name.hash, comment_content 50 | FROM $this->table_name 51 | INNER JOIN $commentmeta_table 52 | ON $commentmeta_table.meta_value=$this->table_name.hash 53 | INNER JOIN $comments_table 54 | ON $comments_table.comment_ID= $commentmeta_table.comment_id 55 | WHERE comment_approved = 1 AND item_id = %s 56 | ", 57 | $item_id), ARRAY_A); // get dates from 58 | 59 | foreach ($sqlresult as $comments) { 60 | $return[ $comments['hash'] ] = $comments['comment_content']; 61 | } 62 | return $return; 63 | 64 | 65 | } 66 | 67 | public function render_comments_form() { 68 | 69 | $comments = $this->get_comments(); 70 | 71 | ob_start(); 72 | 73 | 74 | if ( $comments ) { // there is already a comment for this item 75 | 76 | $args = array ( 77 | 'comment' => $comments[0]->comment_content 78 | ); 79 | cb1_get_template_part('booking-review-booking-comment', $args); 80 | 81 | } else { // No comment, show form 82 | 83 | $this->url = add_query_arg( 'booking', $this->booking_hash, get_the_permalink() ); 84 | 85 | $hash_field = ''; 86 | $redirect_field = ''; 87 | 88 | $comments_args = array( 89 | // change the title of send button 90 | 'label_submit'=>'Send', 91 | 'logged_in_as' =>'', // Hide the logged in message 92 | // change the title of the reply section 93 | 'title_reply'=> __('Leave a comment', 'commons-booking'), 94 | 'title_reply_before' => '
    ', 95 | 'title_reply_after' => '
    ', 96 | 'class_form' => 'cb-booking-comment', 97 | 'id_submit' => 'wp-submit-comment', 98 | // remove "Text or HTML to be displayed after the set of comment fields" 99 | 'comment_notes_after' => '', 100 | // redefine your own textarea (the comment body) 101 | 'comment_field' => '' . $hash_field . $redirect_field, 102 | ); 103 | 104 | comment_form( $comments_args, $this->post_id ); 105 | 106 | } 107 | $content = ob_get_contents(); 108 | ob_end_clean(); 109 | 110 | return $content; 111 | 112 | 113 | } 114 | 115 | public function after_comment_redirect( $location ) { 116 | if ( isset( $_POST['my_redirect_to'] ) ) // Don't use "redirect_to", internal WP var 117 | $location = $_POST['my_redirect_to']; 118 | 119 | return $location; 120 | } 121 | 122 | 123 | 124 | public function add_comment_fields( $fields ) { 125 | 126 | // echo $this->booking_hash . 127 | // ''; 128 | } 129 | 130 | public function get_comments( ) { 131 | $args = array( 132 | 'meta_query' => array( 133 | array( 134 | 'key' => 'booking_hash', 135 | 'value' => $this->booking_hash 136 | ) 137 | ) 138 | ); 139 | 140 | $comments_query = new WP_Comment_Query; 141 | $comments = $comments_query->query( $args ); 142 | 143 | if( $comments ) : 144 | return $comments; 145 | endif; 146 | } 147 | 148 | 149 | public function save_comment_meta_data( $comment_id ) { 150 | 151 | if ( isset( $_POST['hash']) ) { 152 | add_comment_meta( $comment_id, 'booking_hash', $_POST['hash'], true ); 153 | } 154 | 155 | } 156 | } 157 | ?> -------------------------------------------------------------------------------- /admin/cb-codes/class-cb-codes.php: -------------------------------------------------------------------------------- 1 | 6 | * @license GPL-2.0+ 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /** 12 | * 13 | * @package Commons_Booking_Codes 14 | * @author Florian Egermann 15 | */ 16 | class Commons_Booking_Codes { 17 | 18 | public $table_name; 19 | 20 | public $codes_array; 21 | public $csv; 22 | 23 | public $item_id; 24 | public $date_start; 25 | public $date_end; 26 | 27 | public $missing_dates; 28 | public $matched_dates; 29 | 30 | 31 | public $date; 32 | public $daterange_start; 33 | public $timeframe_id; 34 | 35 | /** 36 | * Constructor. 37 | * 38 | * @param $item_id 39 | * 40 | */ 41 | public function __construct( $item_id ) { 42 | 43 | // get Codes from Settings page 44 | $settings = new CB_Admin_Settings; 45 | 46 | global $wpdb; 47 | $this->table_name = $wpdb->prefix . 'cb_codes'; 48 | 49 | $this->prefix = "commons-booking"; 50 | 51 | $this->daterange_start = date('Y-m-d', strtotime( '-30 days' )); // currentdate - 30 days 52 | 53 | $this->item_id = $item_id; 54 | 55 | $csv = $settings->get_settings( 'codes', 'codes_pool' ); // codes as csv 56 | $this->codes_array = $this->split_csv( $csv ); // codes as array 57 | 58 | 59 | } 60 | 61 | /** 62 | * Sets the timeframe basic variables 63 | * 64 | */ 65 | 66 | public function set_timeframe ( $timeframe_id, $date_start, $date_end ) { 67 | 68 | $this->timeframe_id = $timeframe_id; 69 | $this->date_start = $date_start; 70 | $this->date_end = $date_end; 71 | } 72 | 73 | /** 74 | * Split comma-seperated values. 75 | * 76 | *@param $csv string 77 | *@return array 78 | */ 79 | public function split_csv( $csv ) { 80 | 81 | $splitted = explode(",", $csv); 82 | $splitted = array_filter($splitted); // Remove empty 83 | $splitted = array_map('trim', $splitted); // Remove white space 84 | 85 | return ($splitted); 86 | } 87 | 88 | /** 89 | * Get all entries from the codes DB. Ignore dates earlier than daterange_start 90 | * 91 | * @return array 92 | */ 93 | public function get_codes( ) { 94 | global $wpdb; 95 | $codes = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name WHERE item_id = %s AND booking_date > $this->daterange_start", $this->item_id ), ARRAY_A); // get dates from db 96 | // $single = $this->split_csv( $codes ); 97 | return $codes; 98 | } 99 | 100 | /** 101 | * Get code for date / item 102 | * 103 | * @return array 104 | */ 105 | public function get_code( $date ) { 106 | global $wpdb; 107 | $code = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name WHERE item_id = %s AND booking_date > $this->$date", $this->item_id ), ARRAY_A); // get dates from db 108 | return $code; 109 | } 110 | 111 | 112 | /** 113 | * Compare timeframe dates and entries in the codes db 114 | * 115 | */ 116 | public function compare() { 117 | $codes_db = $this->get_codes(); 118 | 119 | $tfDates = cb_get_dates_between( $this->date_start, $this->date_end ); 120 | $codeDates = array(); 121 | 122 | foreach ( $codes_db as $entry ) { 123 | array_push ($codeDates, $entry['booking_date']); 124 | } 125 | 126 | $matched = array(); 127 | $missing = array(); 128 | $missingFlat = ''; 129 | 130 | for ( $i = 0; $i < count($tfDates); $i++ ) { 131 | 132 | $index = array_search( $tfDates[ $i ], $codeDates ); 133 | $temp = array(); 134 | if ( ($index !== FALSE) ) { 135 | $temp[ 'date'] = $tfDates[ $i ]; 136 | $temp[ 'code'] = $codes_db[ $index ]['bookingcode']; 137 | array_push ($matched, $temp); 138 | } else { 139 | $temp[ 'date'] = $tfDates[ $i ]; 140 | array_push ($missing, $temp); 141 | } 142 | } 143 | $this->matched_dates = $matched; 144 | $this->missing_dates = $missing; 145 | } 146 | 147 | /** 148 | * Handle the display of the dates/codes interface on the timeframe edit screen 149 | */ 150 | public function render() { 151 | 152 | echo ( '

    '. __( 'Codes', 'commons-booking') . '

    '); 153 | 154 | $allDates = array_merge ($this->missing_dates, $this->matched_dates); 155 | $this->render_table( $allDates ); 156 | } 157 | /** 158 | * Render the dates/codes-table on the timeframe edit screen 159 | */ 160 | public function render_table( $dates ) { 161 | ?> 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | '. __( 'Code is missing!', 'commons-booking') .''); 172 | } ?> 173 | 174 | 175 |
    176 | object_id() : @get_the_id(); 85 | 86 | if ( ! $object_id ) { 87 | return false; 88 | } 89 | 90 | // If current page id is in the included array, display the metabox 91 | return in_array( $object_id, (array) self::get_show_on_value( $meta_box_args ) ); 92 | } 93 | 94 | /** 95 | * Add metaboxes for an specific Page Template 96 | * @since 1.0.0 97 | * @param bool $display To display or not 98 | * @param array $meta_box_args Metabox config array 99 | * @return bool Whether to display this metabox on the current page. 100 | */ 101 | public static function check_page_template( $display, $meta_box_args, $cmb ) { 102 | 103 | $key = self::get_show_on_key( $meta_box_args ); 104 | if ( ! $key || 'page-template' !== $key ) { 105 | return $display; 106 | } 107 | 108 | $object_id = $cmb->object_id(); 109 | 110 | if ( ! $object_id || 'post' !== $cmb->object_type() ) { 111 | return false; 112 | } 113 | 114 | // Get current template 115 | $current_template = get_post_meta( $object_id, '_wp_page_template', true ); 116 | 117 | // See if there's a match 118 | if ( $current_template && in_array( $current_template, (array) self::get_show_on_value( $meta_box_args ) ) ) { 119 | return true; 120 | } 121 | 122 | return false; 123 | } 124 | 125 | /** 126 | * Only show options-page metaboxes on their options page (but only enforce on the admin side) 127 | * @since 1.0.0 128 | * @param bool $display To display or not 129 | * @param array $meta_box_args Metabox config array 130 | * @return bool Whether to display this metabox on the current page. 131 | */ 132 | public static function check_admin_page( $display, $meta_box_args ) { 133 | 134 | $key = self::get_show_on_key( $meta_box_args ); 135 | // check if this is a 'options-page' metabox 136 | if ( ! $key || 'options-page' !== $key ) { 137 | return $display; 138 | } 139 | 140 | // Enforce 'show_on' filter in the admin 141 | if ( is_admin() ) { 142 | 143 | // If there is no 'page' query var, our filter isn't applicable 144 | if ( ! isset( $_GET['page'] ) ) { 145 | return $display; 146 | } 147 | 148 | $show_on = self::get_show_on_value( $meta_box_args ); 149 | 150 | if ( empty( $show_on ) ) { 151 | return false; 152 | } 153 | 154 | if ( is_array( $show_on ) ) { 155 | foreach ( $show_on as $page ) { 156 | if ( $_GET['page'] == $page ) { 157 | return true; 158 | } 159 | } 160 | } else { 161 | if ( $_GET['page'] == $show_on ) { 162 | return true; 163 | } 164 | } 165 | 166 | return false; 167 | 168 | } 169 | 170 | // Allow options-page metaboxes to be displayed anywhere on the front-end 171 | return true; 172 | } 173 | 174 | } 175 | -------------------------------------------------------------------------------- /admin/cb-locations/includes/cb-locations-metaboxes.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | 18 | class Commons_Booking_Locations_Metaboxes extends Commons_Booking { 19 | 20 | /** 21 | * Hook into the appropriate actions when the class is constructed. 22 | */ 23 | public function __construct() { 24 | 25 | } 26 | 27 | /** 28 | * Set up the meta boxes 29 | * 30 | * @param WP_Post $post The post object. 31 | */ 32 | 33 | public function add_metabox ( array $meta_boxes ) { 34 | 35 | $myitems = new CB_Data; 36 | $items = $myitems->get_items(); 37 | 38 | 39 | $meta_boxes[ 'cb_location_metabox_adress' ] = array( 40 | 'id' => 'cb_location_metabox_adress', 41 | 'title' => __( 'Address', 'commons-booking'), 42 | 'object_types' => array( 'cb_locations', ), // Post type 43 | 'context' => 'normal', 44 | 'priority' => 'high', 45 | 'show_names' => true, // Show field names on the left 46 | 'fields' => array( 47 | array( 48 | 'name' => __( 'Street', 'commons-booking'), 49 | 'id' => parent::$plugin_slug . '_location_adress_street', 50 | 'type' => 'text', 51 | ), 52 | array( 53 | 'name' => __( 'City', 'commons-booking'), 54 | 'id' => parent::$plugin_slug . '_location_adress_city', 55 | 'type' => 'text', 56 | ), 57 | array( 58 | 'name' => __( 'Zip Code', 'commons-booking'), 59 | 'id' => parent::$plugin_slug . '_location_adress_zip', 60 | 'type' => 'text', 61 | ), 62 | array( 63 | 'name' => __( 'Country', 'commons-booking'), 64 | 'id' => parent::$plugin_slug . '_location_adress_country', 65 | 'type' => 'text', 66 | ), 67 | ), 68 | ); 69 | 70 | $meta_boxes[ 'cb_location_metabox_contactinfo' ] = array( 71 | 'id' => 'cb_location_metabox_contactinfo', 72 | 'title' => __( 'Contact Information', 'commons-booking'), 73 | 'object_types' => array( 'cb_locations', ), // Post type 74 | 'context' => 'normal', 75 | 'priority' => 'high', 76 | 'show_names' => true, // Show field names on the left 77 | 'fields' => array( 78 | array( 79 | 'name' => __( 'Phone Number, Email, ...', 'commons-booking'), 80 | 'id' => parent::$plugin_slug . '_location_contactinfo_text', 81 | 'type' => 'textarea', 82 | ), 83 | array( 84 | 'name' => __( 'Hide contact information until user has confirmed the booking.', 'commons-booking'), 85 | 'id' => parent::$plugin_slug . '_location_contactinfo_hide', 86 | 'type' => 'checkbox', 87 | ), 88 | array( 89 | 'name' => __( 'Send copies of booking confirmation emails to the location. Any email address typed into "Phone Number, Email, ..." will receive copies.', 'commons-booking'), 90 | 'id' => parent::$plugin_slug . '_location_contactinfo_recv_copies', 91 | 'type' => 'checkbox', 92 | ), 93 | ), 94 | ); 95 | $meta_boxes[ 'cb_location_metabox_openinghours' ] = array( 96 | 'id' => 'cb_location_metabox_openinghours', 97 | 'title' => __( 'Opening hours', 'commons-booking'), 98 | 'object_types' => array( 'cb_locations', ), // Post type 99 | 'context' => 'normal', 100 | 'priority' => 'high', 101 | 'show_names' => true, // Show field names on the left 102 | 'fields' => array( 103 | array( 104 | 'name' => __( 'Enter the opening hours here. E.g.: Mon-Fri, 8:00 - 18:00', 'commons-booking'), 105 | 'id' => parent::$plugin_slug . '_location_openinghours', 106 | 'type' => 'textarea', 107 | ), 108 | ), 109 | ); 110 | 111 | $meta_boxes[ 'cb_location_metabox_closeddays' ] = array( 112 | 'id' => 'cb_location_metabox_closeddays', 113 | 'title' => __( 'Closed Days', 'commons-booking'), 114 | 'object_types' => array( 'cb_locations', ), // Post type 115 | 'context' => 'normal', 116 | 'priority' => 'high', 117 | 'show_names' => true, // Show field names on the left 118 | 'fields' => array( 119 | array( 120 | 'name' => __( 'Location is closed on the following days, booking is prohibited. ', 'commons-booking'), 121 | 'id' => parent::$plugin_slug . '_location_closeddays', 122 | 'type' => 'multicheck', 123 | 'options' => array( 124 | '1' => __( 'Monday', 'commons-booking'), 125 | '2' => __( 'Tuesday', 'commons-booking'), 126 | '3' => __( 'Wednesday', 'commons-booking'), 127 | '4' => __( 'Thursday', 'commons-booking'), 128 | '5' => __( 'Friday', 'commons-booking'), 129 | '6' => __( 'Saturday', 'commons-booking'), 130 | '7' => __( 'Sunday', 'commons-booking'), 131 | ), 132 | ), 133 | ), 134 | ); 135 | 136 | 137 | return $meta_boxes; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /admin/includes/CMB2/init.php: -------------------------------------------------------------------------------- 1 | l10ni18n(); 142 | 143 | // Include helper functions 144 | require_once 'includes/helper-functions.php'; 145 | 146 | // Now kick off the class autoloader 147 | spl_autoload_register( 'cmb2_autoload_classes' ); 148 | 149 | // Kick the whole thing off 150 | require_once 'bootstrap.php'; 151 | } 152 | 153 | /** 154 | * Registers CMB2 text domain path 155 | * @since 2.0.0 156 | */ 157 | public function l10ni18n() { 158 | $loaded = load_plugin_textdomain( 'cmb2', false, '/languages/' ); 159 | if ( ! $loaded ) { 160 | $loaded = load_muplugin_textdomain( 'cmb2', '/languages/' ); 161 | } 162 | if ( ! $loaded ) { 163 | $loaded = load_theme_textdomain( 'cmb2', '/languages/' ); 164 | } 165 | 166 | if ( ! $loaded ) { 167 | $locale = apply_filters( 'plugin_locale', get_locale(), 'cmb2' ); 168 | $mofile = dirname( __FILE__ ) . '/languages/cmb2-' . $locale . '.mo'; 169 | load_textdomain( 'cmb2', $mofile ); 170 | } 171 | } 172 | 173 | } 174 | 175 | // Make it so... 176 | CMB2_Bootstrap_208::initiate(); 177 | 178 | } 179 | -------------------------------------------------------------------------------- /includes/commons-booking-helpers.php: -------------------------------------------------------------------------------- 1 | 13 | * @license GPL-2.0+ 14 | * @link http://www.wielebenwir.de 15 | * @copyright 2015 wielebenwir 16 | */ 17 | 18 | 19 | /** 20 | * Get a List of all wordpress pages for use in dropdown selects. 21 | * 22 | * @return Array of wordpress pages as [pagedID][title] 23 | */ 24 | 25 | function cb_pages_dropdown() { 26 | // dropdown for page select 27 | $pages = get_pages(); 28 | $dropdown = array(); 29 | 30 | foreach ( $pages as $page ) { 31 | $dropdown[$page->ID] = $page->post_title; 32 | } 33 | return $dropdown; 34 | } 35 | 36 | /** 37 | * Get a List of all wordpress pages for use in dropdown selects. 38 | * 39 | * @return Array of Sub-Folders 40 | */ 41 | 42 | function cb_theme_select() { 43 | 44 | $themes_dir = Commons_Booking::get_plugin_dir() . 'assets/css/themes'; 45 | $themes_url = Commons_Booking::get_plugin_url() . 'assets/css/themes'; 46 | $directories = glob( $themes_dir . '/*' , GLOB_ONLYDIR); 47 | 48 | $dropdown = array(); 49 | 50 | foreach ( $directories as $dir ) { 51 | $theme_name = basename( $dir ); 52 | $dropdown[ $theme_name ] = $theme_name; 53 | } 54 | return $dropdown; 55 | } 56 | 57 | 58 | /** 59 | * Replace template tags – {MYTAG} with tags array 60 | * 61 | *@param string to replace 62 | *@param array of tags 63 | * 64 | *@return string 65 | */ 66 | function cb_replace_template_tags( $string, $tags_array ) { 67 | foreach($tags_array as $key => $value){ 68 | $string = str_replace('{{'.strtoupper($key).'}}', $value, $string); 69 | } 70 | return $string; 71 | } 72 | 73 | /** 74 | * Format message 75 | * 76 | *@param $string, 77 | * 78 | *@return html 79 | */ 80 | function cb_display_message( $string, $replace = null, $success = TRUE ) { 81 | 82 | if ( ! $replace ) { 83 | $replace = array(); 84 | } 85 | 86 | $msg = cb_replace_template_tags( $string, $replace ); 87 | $class = $success ? 'success' : 'error'; 88 | return sprintf ('

    %s

    ', $class , $msg ); 89 | } 90 | 91 | /** 92 | * Get a list of all dates within the defind range. 93 | * 94 | * @return array dates 95 | */ 96 | function cb_get_dates_between( $date_start, $date_end ) { 97 | $dates = array ( $date_start ); 98 | while(end($dates) < $date_end){ 99 | $dates[] = date('Y-m-d', strtotime(end($dates).' +1 day')); 100 | } 101 | return $dates; 102 | } 103 | 104 | /** 105 | * Helper: search a 2-dim array for key, return value 106 | * 107 | */ 108 | function cb_search_array($value, $key, $array) { 109 | foreach ($array as $k => $val) { 110 | if ($val[$key] == $value) { 111 | return $k; 112 | } 113 | } 114 | return null; 115 | } 116 | /** 117 | * Helper: Convert object to array. 118 | * 119 | */ 120 | 121 | function cb_object_to_array($object) { 122 | $array = json_decode(json_encode($object), true); 123 | return $array; 124 | // if (is_array($data) || is_object($data)) 125 | // { 126 | // $result = array(); 127 | // foreach ($data as $key => $value) 128 | // { 129 | // $result[$key] = cb_object_to_array($value); 130 | // } 131 | // return $result; 132 | // } 133 | // return $data; 134 | } 135 | /** 136 | * Helper: Check if Thumbmail exists, if so, return it. 137 | * 138 | */ 139 | function cb_get_thumb( $post_id ) { 140 | if ( has_post_thumbnail( $post_id ) ) { 141 | $thumb = get_the_post_thumbnail( $post_id, 'thumbnail' ); 142 | } else { 143 | $thumb = ""; 144 | } 145 | return $thumb; 146 | } 147 | /** 148 | * Convert to timestamp. 149 | * 150 | */ 151 | function cb_convert_to_timestamp( $date ) { 152 | return strtotime($date); 153 | } 154 | /** 155 | * Check if string is valid date. 156 | * 157 | * @since 0.3 158 | * 159 | * @param $string string to check 160 | * @param Bool 161 | */ 162 | function cb_is_valid_date( $string ) { 163 | return (bool)strtotime( $string ); 164 | } 165 | /** 166 | * Create page. 167 | * 168 | * @since 0.2 169 | * 170 | * @param $title page title 171 | * @param $option_name the name of the option in the settings-pages array 172 | * @return Page ID 173 | */ 174 | function cb_create_page( $title, $option_name ) { 175 | 176 | $option_page = get_option ( 'commons-booking-settings-pages' ); 177 | $option = $option_page[ $option_name ]; 178 | 179 | if ( !empty ( $option ) ) { 180 | 181 | return $option; 182 | 183 | } else { 184 | 185 | $my_page = array( 186 | 'post_title' => $title, 187 | 'post_content' => '', 188 | 'post_status' => 'publish', 189 | 'post_type' => 'page', 190 | 'post_author' => 1 191 | ); 192 | // Insert the post into the database 193 | $id = wp_insert_post( $my_page ); 194 | return $id; 195 | 196 | } 197 | 198 | } 199 | /** 200 | * Get WP Custom field 201 | * 202 | * @since 0.9.2.1 203 | * 204 | * @param $key 205 | * @param $echo 206 | * @return Meta field 207 | */ 208 | function cb_get_custom_field( $key, $echo = FALSE ) { 209 | global $post; 210 | $custom_field = get_post_meta($post->ID, $key, true); 211 | 212 | if (! $custom_field ) { 213 | $custom_field = ""; 214 | } 215 | 216 | if ($echo == FALSE) return $custom_field; 217 | echo $custom_field; 218 | } 219 | 220 | 221 | ?> -------------------------------------------------------------------------------- /admin/includes/CMB2/includes/CMB2_JS.php: -------------------------------------------------------------------------------- 1 | 'jquery' ); 33 | 34 | /** 35 | * Add a dependency to the array of CMB2 JS dependencies 36 | * @since 2.0.7 37 | * @param array|string $dependencies Array (or string) of dependencies to add 38 | */ 39 | public static function add_dependencies( $dependencies ) { 40 | foreach ( (array) $dependencies as $dependency ) { 41 | self::$dependencies[ $dependency ] = $dependency; 42 | } 43 | } 44 | 45 | /** 46 | * Enqueue the CMB2 JS 47 | * @since 2.0.7 48 | */ 49 | public static function enqueue() { 50 | // Filter required script dependencies 51 | $dependencies = apply_filters( 'cmb2_script_dependencies', self::$dependencies ); 52 | 53 | // if colorpicker 54 | if ( ! is_admin() && isset( $dependencies['wp-color-picker'] ) ) { 55 | self::colorpicker_frontend(); 56 | } 57 | 58 | // if file/file_list 59 | if ( isset( $dependencies['media-editor'] ) ) { 60 | wp_enqueue_media(); 61 | } 62 | 63 | // if timepicker 64 | if ( isset( $dependencies['jquery-ui-datetimepicker'] ) ) { 65 | wp_register_script( 'jquery-ui-datetimepicker', cmb2_utils()->url( 'js/jquery-ui-timepicker-addon.min.js' ), array( 'jquery-ui-slider' ), CMB2_VERSION ); 66 | } 67 | 68 | // Only use minified files if SCRIPT_DEBUG is off 69 | $debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; 70 | $min = $debug ? '' : '.min'; 71 | 72 | // Register cmb JS 73 | wp_enqueue_script( self::$handle, cmb2_utils()->url( "js/cmb2{$min}.js" ), $dependencies, CMB2_VERSION, true ); 74 | 75 | self::localize( $debug ); 76 | } 77 | 78 | /** 79 | * We need to register colorpicker on the front-end 80 | * @since 2.0.7 81 | */ 82 | protected static function colorpicker_frontend() { 83 | wp_register_script( 'iris', admin_url( 'js/iris.min.js' ), array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), CMB2_VERSION ); 84 | wp_register_script( 'wp-color-picker', admin_url( 'js/color-picker.min.js' ), array( 'iris' ), CMB2_VERSION ); 85 | wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', array( 86 | 'clear' => __( 'Clear', 'cmb2' ), 87 | 'defaultString' => __( 'Default', 'cmb2' ), 88 | 'pick' => __( 'Select Color', 'cmb2' ), 89 | 'current' => __( 'Current Color', 'cmb2' ), 90 | ) ); 91 | } 92 | 93 | /** 94 | * Localize the php variables for CMB2 JS 95 | * @since 2.0.7 96 | */ 97 | protected static function localize( $debug ) { 98 | $l10n = array( 99 | 'ajax_nonce' => wp_create_nonce( 'ajax_nonce' ), 100 | 'ajaxurl' => admin_url( '/admin-ajax.php' ), 101 | 'script_debug' => $debug, 102 | 'up_arrow_class' => 'dashicons dashicons-arrow-up-alt2', 103 | 'down_arrow_class' => 'dashicons dashicons-arrow-down-alt2', 104 | 'defaults' => array( 105 | 'color_picker' => false, 106 | 'date_picker' => array( 107 | 'changeMonth' => true, 108 | 'changeYear' => true, 109 | 'dateFormat' => _x( 'mm/dd/yy', 'Valid formatDate string for jquery-ui datepicker', 'cmb2' ), 110 | 'dayNames' => explode( ',', __( 'Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday', 'cmb2' ) ), 111 | 'dayNamesMin' => explode( ',', __( 'Su, Mo, Tu, We, Th, Fr, Sa', 'cmb2' ) ), 112 | 'dayNamesShort' => explode( ',', __( 'Sun, Mon, Tue, Wed, Thu, Fri, Sat', 'cmb2' ) ), 113 | 'monthNames' => explode( ',', __( 'January, February, March, April, May, June, July, August, September, October, November, December', 'cmb2' ) ), 114 | 'monthNamesShort' => explode( ',', __( 'Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec', 'cmb2' ) ), 115 | 'nextText' => __( 'Next', 'cmb2' ), 116 | 'prevText' => __( 'Prev', 'cmb2' ), 117 | 'currentText' => __( 'Today', 'cmb2' ), 118 | 'closeText' => __( 'Done', 'cmb2' ), 119 | 'clearText' => __( 'Clear', 'cmb2' ), 120 | ), 121 | 'time_picker' => array( 122 | 'timeOnlyTitle' => __( 'Choose Time', 'cmb2' ), 123 | 'timeText' => __( 'Time', 'cmb2' ), 124 | 'hourText' => __( 'Hour', 'cmb2' ), 125 | 'minuteText' => __( 'Minute', 'cmb2' ), 126 | 'secondText' => __( 'Second', 'cmb2' ), 127 | 'currentText' => __( 'Now', 'cmb2' ), 128 | 'closeText' => __( 'Done', 'cmb2' ), 129 | 'timeFormat' => _x( 'hh:mm TT', 'Valid formatting string, as per http://trentrichardson.com/examples/timepicker/', 'cmb2' ), 130 | 'controlType' => 'select', 131 | 'stepMinute' => 5, 132 | ), 133 | ), 134 | 'strings' => array( 135 | 'upload_file' => __( 'Use this file', 'cmb2' ), 136 | 'remove_image' => __( 'Remove Image', 'cmb2' ), 137 | 'remove_file' => __( 'Remove', 'cmb2' ), 138 | 'file' => __( 'File:', 'cmb2' ), 139 | 'download' => __( 'Download', 'cmb2' ), 140 | 'check_toggle' => __( 'Select / Deselect All', 'cmb2' ), 141 | ), 142 | ); 143 | 144 | wp_localize_script( self::$handle, self::$js_variable, apply_filters( 'cmb2_localized_data', $l10n ) ); 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /includes/Widgets-Helper/widget-sample.php: -------------------------------------------------------------------------------- 1 | __( 'My Recent Posts', 'mv-my-recente-posts' ), 33 | // Widget Backend Description 34 | 'description' => __( 'My Recent Posts Widget Description', 'mv-my-recente-posts' ), 35 | ); 36 | 37 | // Configure the widget fields 38 | // Example for: Title ( text ) and Amount of posts to show ( select box ) 39 | 40 | // fields array 41 | $args['fields'] = array( 42 | 43 | // Title field 44 | array( 45 | // field name/label 46 | 'name' => __( 'Title', 'mv-my-recente-posts' ), 47 | // field description 48 | 'desc' => __( 'Enter the widget title.', 'mv-my-recente-posts' ), 49 | // field id 50 | 'id' => 'title', 51 | // field type ( text, checkbox, textarea, select, select-group ) 52 | 'type'=>'text', 53 | // class, rows, cols 54 | 'class' => 'widefat', 55 | // default value 56 | 'std' => __( 'Recent Posts', 'mv-my-recente-posts' ), 57 | 58 | /* 59 | Set the field validation type/s 60 | /////////////////////////////// 61 | 62 | 'alpha_dash' 63 | Returns FALSE if the value contains anything other than alpha-numeric characters, underscores or dashes. 64 | 65 | 'alpha' 66 | Returns FALSE if the value contains anything other than alphabetical characters. 67 | 68 | 'alpha_numeric' 69 | Returns FALSE if the value contains anything other than alpha-numeric characters. 70 | 71 | 'numeric' 72 | Returns FALSE if the value contains anything other than numeric characters. 73 | 74 | 'boolean' 75 | Returns FALSE if the value contains anything other than a boolean value ( true or false ). 76 | 77 | ---------- 78 | 79 | You can define custom validation methods. Make sure to return a boolean ( TRUE/FALSE ). 80 | Example: 81 | 82 | 'validate' => 'my_custom_validation', 83 | 84 | Will call for: $this->my_custom_validation( $value_to_validate ); 85 | 86 | */ 87 | 88 | 'validate' => 'alpha_dash', 89 | 90 | /* 91 | 92 | Filter data before entering the DB 93 | ////////////////////////////////// 94 | 95 | strip_tags ( default ) 96 | wp_strip_all_tags 97 | esc_attr 98 | esc_url 99 | esc_textarea 100 | 101 | */ 102 | 103 | 'filter' => 'strip_tags|esc_attr' 104 | ), 105 | 106 | // Amount Field 107 | array( 108 | 'name' => __( 'Amount' ), 109 | 'desc' => __( 'Select how many posts to show.', 'mv-my-recente-posts' ), 110 | 'id' => 'amount', 111 | 'type'=>'select', 112 | // selectbox fields 113 | 'fields' => array( 114 | array( 115 | // option name 116 | 'name' => __( '1 Post', 'mv-my-recente-posts' ), 117 | // option value 118 | 'value' => '1' 119 | ), 120 | array( 121 | 'name' => __( '2 Posts', 'mv-my-recente-posts' ), 122 | 'value' => '2' 123 | ), 124 | array( 125 | 'name' => __( '3 Posts', 'mv-my-recente-posts' ), 126 | 'value' => '3' 127 | ) 128 | 129 | // add more options 130 | ), 131 | 'validate' => 'my_custom_validation', 132 | 'filter' => 'strip_tags|esc_attr', 133 | ), 134 | 135 | // Output type checkbox 136 | array( 137 | 'name' => __( 'Output as list', 'mv-my-recente-posts' ), 138 | 'desc' => __( 'Wraps posts with the
  • tag.', 'mv-my-recente-posts' ), 139 | 'id' => 'list', 140 | 'type'=>'checkbox', 141 | // checked by default: 142 | 'std' => 1, // 0 or 1 143 | 'filter' => 'strip_tags|esc_attr', 144 | ), 145 | 146 | // add more fields 147 | 148 | ); // fields array 149 | 150 | // create widget 151 | $this->create_widget( $args ); 152 | } 153 | 154 | // Custom validation for this widget 155 | 156 | function my_custom_validation( $value ) 157 | { 158 | if ( strlen( $value ) > 1 ) 159 | return false; 160 | else 161 | return true; 162 | } 163 | 164 | // Output function 165 | 166 | function widget( $args, $instance ) 167 | { 168 | 169 | // And here do whatever you want 170 | 171 | $out = $args['before_title']; 172 | $out .= $instance['title']; 173 | $out .= $args['after_title']; 174 | 175 | // here you would get the most recent posts based on the selected amount: $instance['amount'] 176 | // Then return those posts on the $out variable ready for the output 177 | 178 | $out .= '

    Hey There!

    '; 179 | 180 | echo apply_filters('widget_text', $out); 181 | } 182 | 183 | } // class 184 | 185 | // Register widget 186 | if ( ! function_exists( 'mv_my_register_widget' ) ) 187 | { 188 | function mv_my_register_widget() 189 | { 190 | register_widget( 'MV_My_Recent_Posts_Widget' ); 191 | } 192 | 193 | add_action( 'widgets_init', 'mv_my_register_widget', 1 ); 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /admin/includes/CMB2/includes/CMB2_Options.php: -------------------------------------------------------------------------------- 1 | key = ! empty( $option_key ) ? $option_key : ''; 65 | } 66 | 67 | /** 68 | * Delete the option from the db 69 | * @since 2.0.0 70 | * @return bool Delete success or failure 71 | */ 72 | public function delete_option() { 73 | $deleted = $this->key ? delete_option( $this->key ) : true; 74 | $this->options = $deleted ? array() : $this->options; 75 | return $this->options; 76 | } 77 | 78 | /** 79 | * Removes an option from an option array 80 | * @since 1.0.1 81 | * @param string $field_id Option array field key 82 | * @return array Modified options 83 | */ 84 | public function remove( $field_id, $resave = false ) { 85 | 86 | $this->get_options(); 87 | 88 | if ( isset( $this->options[ $field_id ] ) ) { 89 | unset( $this->options[ $field_id ] ); 90 | } 91 | 92 | if ( $resave ) { 93 | $this->set(); 94 | } 95 | 96 | return $this->options; 97 | } 98 | 99 | /** 100 | * Retrieves an option from an option array 101 | * @since 1.0.1 102 | * @param string $field_id Option array field key 103 | * @param mixed $default Fallback value for the option 104 | * @return array Requested field or default 105 | */ 106 | public function get( $field_id, $default = false ) { 107 | $opts = $this->get_options(); 108 | 109 | if ( 'all' == $field_id ) { 110 | return $opts; 111 | } elseif ( array_key_exists( $field_id, $opts ) ) { 112 | return false !== $opts[ $field_id ] ? $opts[ $field_id ] : $default; 113 | } 114 | 115 | return $default; 116 | } 117 | 118 | /** 119 | * Updates Option data 120 | * @since 1.0.1 121 | * @param string $field_id Option array field key 122 | * @param mixed $value Value to update data with 123 | * @param bool $resave Whether to re-save the data 124 | * @param bool $single Whether data should not be an array 125 | * @return boolean Return status of update 126 | */ 127 | public function update( $field_id, $value = '', $resave = false, $single = true ) { 128 | $this->get_options(); 129 | 130 | if ( true !== $field_id ) { 131 | 132 | if ( ! $single ) { 133 | // If multiple, add to array 134 | $this->options[ $field_id ][] = $value; 135 | } else { 136 | $this->options[ $field_id ] = $value; 137 | } 138 | 139 | } 140 | 141 | if ( $resave || true === $field_id ) { 142 | return $this->set(); 143 | } 144 | 145 | return true; 146 | } 147 | 148 | /** 149 | * Saves the option array 150 | * Needs to be run after finished using remove/update_option 151 | * @uses apply_filters() Calls 'cmb2_override_option_save_{$this->key}' hook 152 | * to allow overwriting the option value to be stored. 153 | * 154 | * @since 1.0.1 155 | * @param array $options Optional options to override 156 | * @return bool Success/Failure 157 | */ 158 | public function set( $options = array() ) { 159 | $this->options = ! empty( $options ) || empty( $options ) && empty( $this->key ) 160 | ? $options 161 | : $this->options; 162 | 163 | if ( empty( $this->key ) ) { 164 | return false; 165 | } 166 | 167 | $test_save = apply_filters( "cmb2_override_option_save_{$this->key}", 'cmb2_no_override_option_save', $this->options, $this ); 168 | 169 | if ( 'cmb2_no_override_option_save' !== $test_save ) { 170 | return $test_save; 171 | } 172 | 173 | // If no override, update the option 174 | return update_option( $this->key, $this->options ); 175 | } 176 | 177 | /** 178 | * Retrieve option value based on name of option. 179 | * @uses apply_filters() Calls 'cmb2_override_option_get_{$this->key}' hook to allow 180 | * overwriting the option value to be retrieved. 181 | * 182 | * @since 1.0.1 183 | * @param mixed $default Optional. Default value to return if the option does not exist. 184 | * @return mixed Value set for the option. 185 | */ 186 | public function get_options( $default = null ) { 187 | if ( empty( $this->options ) && ! empty( $this->key ) ) { 188 | 189 | $test_get = apply_filters( "cmb2_override_option_get_{$this->key}", 'cmb2_no_override_option_get', $default, $this ); 190 | 191 | if ( 'cmb2_no_override_option_get' !== $test_get ) { 192 | $this->options = $test_get; 193 | } else { 194 | // If no override, get the option 195 | $this->options = get_option( $this->key, $default ); 196 | } 197 | } 198 | 199 | return (array) $this->options; 200 | } 201 | 202 | } 203 | -------------------------------------------------------------------------------- /admin/includes/CMB2/includes/CMB2_Utils.php: -------------------------------------------------------------------------------- 1 | get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid LIKE '%%%s%%' LIMIT 1;", $img_url ) ); 40 | 41 | // If we found an attachement ID, return it 42 | if ( ! empty( $attachment ) && is_array( $attachment ) ) { 43 | return $attachment[0]; 44 | } 45 | 46 | // No luck 47 | return false; 48 | } 49 | 50 | /** 51 | * Utility method that returns time string offset by timezone 52 | * @since 1.0.0 53 | * @param string $tzstring Time string 54 | * @return string Offset time string 55 | */ 56 | public function timezone_offset( $tzstring ) { 57 | if ( ! empty( $tzstring ) && is_string( $tzstring ) ) { 58 | if ( 'UTC' === substr( $tzstring, 0, 3 ) ) { 59 | $tzstring = str_replace( array( ':15', ':30', ':45' ), array( '.25', '.5', '.75' ), $tzstring ); 60 | return intval( floatval( substr( $tzstring, 3 ) ) * HOUR_IN_SECONDS ); 61 | } 62 | 63 | $date_time_zone_selected = new DateTimeZone( $tzstring ); 64 | $tz_offset = timezone_offset_get( $date_time_zone_selected, date_create() ); 65 | 66 | return $tz_offset; 67 | } 68 | 69 | return 0; 70 | } 71 | 72 | /** 73 | * Utility method that returns a timezone string representing the default timezone for the site. 74 | * 75 | * Roughly copied from WordPress, as get_option('timezone_string') will return 76 | * an empty string if no value has been set on the options page. 77 | * A timezone string is required by the wp_timezone_choice() used by the 78 | * select_timezone field. 79 | * 80 | * @since 1.0.0 81 | * @return string Timezone string 82 | */ 83 | public function timezone_string() { 84 | $current_offset = get_option( 'gmt_offset' ); 85 | $tzstring = get_option( 'timezone_string' ); 86 | 87 | if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists 88 | if ( 0 == $current_offset ) { 89 | $tzstring = 'UTC+0'; 90 | } elseif ( $current_offset < 0 ) { 91 | $tzstring = 'UTC' . $current_offset; 92 | } else { 93 | $tzstring = 'UTC+' . $current_offset; 94 | } 95 | } 96 | 97 | return $tzstring; 98 | } 99 | 100 | /** 101 | * Returns a timestamp, first checking if value already is a timestamp. 102 | * @since 2.0.0 103 | * @param string|int $string Possible timestamp string 104 | * @return int Time stamp 105 | */ 106 | public function make_valid_time_stamp( $string ) { 107 | if ( ! $string ) { 108 | return 0; 109 | } 110 | 111 | return $this->is_valid_time_stamp( $string ) 112 | ? (int) $string : 113 | strtotime( $string ); 114 | } 115 | 116 | /** 117 | * Determine if a value is a valid timestamp 118 | * @since 2.0.0 119 | * @param mixed $timestamp Value to check 120 | * @return boolean Whether value is a valid timestamp 121 | */ 122 | public function is_valid_time_stamp( $timestamp ) { 123 | return (string) (int) $timestamp === (string) $timestamp 124 | && $timestamp <= PHP_INT_MAX 125 | && $timestamp >= ~PHP_INT_MAX; 126 | } 127 | 128 | /** 129 | * Checks if a value is 'empty'. Still accepts 0. 130 | * @since 2.0.0 131 | * @param mixed $value Value to check 132 | * @return bool True or false 133 | */ 134 | public function isempty( $value ) { 135 | return null === $value || '' === $value || false === $value; 136 | } 137 | 138 | /** 139 | * Insert a single array item inside another array at a set position 140 | * @since 2.0.2 141 | * @param array &$array Array to modify. Is passed by reference, and no return is needed. 142 | * @param array $new New array to insert 143 | * @param int $position Position in the main array to insert the new array 144 | */ 145 | public function array_insert( &$array, $new, $position ) { 146 | $before = array_slice( $array, 0, $position - 1 ); 147 | $after = array_diff_key( $array, $before ); 148 | $array = array_merge( $before, $new, $after ); 149 | } 150 | 151 | /** 152 | * Defines the url which is used to load local resources. 153 | * This may need to be filtered for local Window installations. 154 | * If resources do not load, please check the wiki for details. 155 | * @since 1.0.1 156 | * @return string URL to CMB2 resources 157 | */ 158 | public function url( $path = '' ) { 159 | if ( $this->url ) { 160 | return $this->url . $path; 161 | } 162 | 163 | if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) { 164 | // Windows 165 | $content_dir = str_replace( '/', DIRECTORY_SEPARATOR, WP_CONTENT_DIR ); 166 | $content_url = str_replace( $content_dir, WP_CONTENT_URL, cmb2_dir() ); 167 | $cmb2_url = str_replace( DIRECTORY_SEPARATOR, '/', $content_url ); 168 | 169 | } else { 170 | $cmb2_url = str_replace( 171 | array( WP_CONTENT_DIR, WP_PLUGIN_DIR ), 172 | array( WP_CONTENT_URL, WP_PLUGIN_URL ), 173 | cmb2_dir() 174 | ); 175 | } 176 | 177 | /** 178 | * Filter the CMB location url 179 | * 180 | * @param string $cmb2_url Currently registered url 181 | */ 182 | $this->url = trailingslashit( apply_filters( 'cmb2_meta_box_url', set_url_scheme( $cmb2_url ), CMB2_VERSION ) ); 183 | 184 | return $this->url . $path; 185 | } 186 | 187 | } 188 | -------------------------------------------------------------------------------- /admin/cb-timeframes/includes/class-cb-timeframes-list.php: -------------------------------------------------------------------------------- 1 | 6 | * @license GPL-2.0+ 7 | * @link http://www.wielebenwir.de 8 | * @copyright 2015 wielebenwir 9 | */ 10 | 11 | /** 12 | * Display the list of configured Timeframes in a metabox on the item edit screen. 13 | * 14 | * @package Commons_Booking_Timeframes_List 15 | * @author Florian Egermann 16 | */ 17 | class Commons_Booking_Timeframes_List { 18 | 19 | private $postID; 20 | private $colDefinition; 21 | private $rows; 22 | public $prefix; 23 | 24 | /** 25 | * 26 | * @since 0.0.1 27 | */ 28 | public function __construct( $postID ) { 29 | $this->postID = $postID; 30 | $this->prefix = "commons-booking"; 31 | } 32 | 33 | /** 34 | * Set up col definitions and get Data from DB 35 | * 36 | */ 37 | public function prepare() { 38 | $this->colDefinition = $this->set_Columns(); 39 | $this->rows = $this->get_Items(); 40 | } 41 | 42 | /** 43 | * Sets the columns 44 | * 45 | * @return array names of the col headers 46 | */ 47 | private function set_Columns() { 48 | $this->columns = array( 49 | 'location_id' => __( 'Location', 'commons-booking' ), 50 | 'date_start' => __( 'Start Date', 'commons-booking'), 51 | 'date_end' => __( 'End Date', 'commons-booking'), 52 | 'timeframe_title' => __('Note', 'commons-booking'), 53 | 'edit' => __( 'Edit', 'commons-booking' ) 54 | ); 55 | return $this->columns; 56 | } 57 | /** 58 | * Renders the header 59 | * 60 | * @return mixed html 61 | */ 62 | private function table_header() { 63 | $colheader = ''; 64 | foreach ($this->colDefinition as $key => $value) { 65 | $colheader .= (' ' . $value . ''); 66 | } 67 | return ($colheader .= ''); 68 | } 69 | /** 70 | * Handle Columns 71 | * 72 | * @return mixed html 73 | */ 74 | private function table_columns() { 75 | 76 | $columns = ""; 77 | 78 | if ( ($this->rows) ) { 79 | 80 | foreach ($this->rows as $row => $cols) { 81 | 82 | foreach ($this->colDefinition as $headerkey => $headerval) { // loop through defined fields 83 | if ( isset($cols[$headerkey])) { // check if col is in defined fields OR edit 84 | $columns .= $this->table_fields ($headerkey, $cols[$headerkey]); // get table fields 85 | } elseif ($headerkey = "edit") { 86 | $columns .= $this->table_fields ($headerkey, $cols['id']); 87 | } 88 | } 89 | $columns = '' .$columns . ''; 90 | } 91 | return ($columns); 92 | } else { 93 | return '

    ' . __( 'No timeframes set up yet.', 'commons-booking' ) . '

    '; 94 | } 95 | } 96 | 97 | /** 98 | * Handle field display 99 | * 100 | * @return mixed html 101 | */ 102 | public function table_fields( $key, $value ) { 103 | 104 | if (array_key_exists($key, $this->colDefinition)) { 105 | switch ($key) { // Handle different field display 106 | case 'item_id': 107 | $field = ( '' . $this->table_fields_get_link( $value ) . '' ); 108 | break; 109 | case 'location_id': 110 | $field = ( '' . $this->table_fields_get_link( $value ) . '' ); 111 | break; 112 | case 'edit': 113 | $field = $this->table_fields_edit_button( $value ) . ' ' . $this->table_fields_delete_button( $value ) ; 114 | break; 115 | default: 116 | $field = $value; 117 | } 118 | return ' ' . $field . ''; 119 | } 120 | } 121 | 122 | /** 123 | * Button to jump to timeframe table for editing //@TODO set path correctly 124 | * 125 | * @return html 126 | */ 127 | private function table_fields_edit_button( $itemID ) { 128 | return ''. __('Edit', 'commons-booking') . ''; 129 | 130 | } 131 | /** 132 | * Button to jump to timeframe table for delete 133 | * 134 | * @return html 135 | */ 136 | private function table_fields_delete_button( $itemID ) { 137 | return ''. __('Delete', 'commons-booking') . ''; 138 | 139 | } 140 | 141 | /** 142 | * Button to jump to post type for editing 143 | * 144 | * @param $itemID 145 | * 146 | * @return html 147 | */ 148 | private function table_fields_get_link( $itemID ) { 149 | return '' . get_the_title( $itemID ) . ''; 150 | 151 | } 152 | /** 153 | * Jump to timeframe editing screen 154 | * 155 | * 156 | * @return html 157 | */ 158 | private function jump_to_timeframes_link() { 159 | return ( '' . __('Add new Timeframe', 'commons-booking') . '' ); 160 | } 161 | 162 | 163 | /** 164 | * Gets objects from DB and displays message on fail 165 | * 166 | */ 167 | private function get_Items() { 168 | 169 | $return = ''; 170 | 171 | if ($this->postID) { 172 | global $wpdb; 173 | 174 | $table_name = $wpdb->prefix . 'cb_timeframes'; 175 | $today = date('Y-m-d'); 176 | $sql = $wpdb->prepare( "SELECT * FROM ". $table_name ." WHERE item_id = %d AND date_end > %s ORDER BY date_start ASC", $this->postID, $today ); 177 | 178 | $this->items = $wpdb->get_results($sql, ARRAY_A); 179 | 180 | if ( $this->items ) { 181 | return $this->items; 182 | } else { 183 | return FALSE; 184 | } 185 | } else { 186 | return __('Post id not found.', 'commons-booking' ); 187 | } 188 | } 189 | 190 | public function render_timeframes() { 191 | // $colDefinition = $this->set_Columns(); 192 | $this->prepare(); 193 | echo $this->jump_to_timeframes_link(); 194 | $tableheader = $this->table_header(); 195 | $tablecolumns = $this->table_columns(); 196 | echo ('' . $tableheader . $tablecolumns . '
    '); 197 | } 198 | 199 | } 200 | --------------------------------------------------------------------------------