appointment-booking-calendar
Last commit date
TDE_AppCalendar
1 week ago
captcha
1 week ago
controllers
1 week ago
images
1 week ago
inc
1 week ago
js
1 week ago
languages
1 week ago
mv
1 week ago
README.txt
1 week ago
changelog.txt
1 week ago
cpabc_appointments.php
1 week ago
cpabc_appointments.php
264 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: Appointment Booking Calendar |
| 4 | Plugin URI: https://abc.dwbooster.com |
| 5 | Description: This plugin allows you to easily insert appointments forms into your WP website. |
| 6 | Version: 1.4.03 |
| 7 | Author URI: https://abc.dwbooster.com |
| 8 | License: GPLv2 |
| 9 | Text Domain: appointment-booking-calendar |
| 10 | */ |
| 11 | |
| 12 | /* initialization / install / uninstall functions */ |
| 13 | |
| 14 | |
| 15 | define('CPABC_APPOINTMENTS_DEFAULT_ON_CANCEL_REDIRECT_TO', '/'); |
| 16 | define('CPABC_APPOINTMENTS_AUTO_FILL_LOGGED_USER_DATA', true); |
| 17 | define('CPABC_APPOINTMENTS_ENABLE_QUANTITY_FIELD', 0); |
| 18 | define('CPABC_APPOINTMENTS_IDENTIFY_PRICES', false); |
| 19 | |
| 20 | define('CPABC_APPOINTMENTS_DEFAULT_DEFER_SCRIPTS_LOADING', (get_option('CPABC_APPOINTMENTS_LOAD_SCRIPTS',"1") == "1"?true:false)); |
| 21 | |
| 22 | define('CPABC_APPOINTMENTS_DEFAULT_CURRENCY_SYMBOL','$'); |
| 23 | define('CPABC_APPOINTMENTS_GBP_CURRENCY_SYMBOL',chr(163)); |
| 24 | define('CPABC_APPOINTMENTS_EUR_CURRENCY_SYMBOL_A','EUR '); |
| 25 | define('CPABC_APPOINTMENTS_EUR_CURRENCY_SYMBOL_B',chr(128)); |
| 26 | |
| 27 | define('CPABC_APPOINTMENTS_DEFAULT_form_structure', '[[{"name":"email","index":0,"title":"Email","ftype":"femail","userhelp":"","csslayout":"","required":true,"predefined":"","size":"medium"},{"name":"subject","index":1,"title":"Subject","required":true,"ftype":"ftext","userhelp":"","csslayout":"","predefined":"","size":"medium"},{"name":"message","index":2,"size":"large","required":true,"title":"Message","ftype":"ftextarea","userhelp":"","csslayout":"","predefined":""}],[{"title":"","description":"","formlayout":"top_aligned"}]]'); |
| 28 | |
| 29 | define('CPABC_APPOINTMENTS_DEFAULT_CALENDAR_LANGUAGE', '-'); |
| 30 | define('CPABC_APPOINTMENTS_DEFAULT_CALENDAR_DATEFORMAT', '0'); |
| 31 | define('CPABC_APPOINTMENTS_DEFAULT_CALENDAR_MILITARYTIME', '1'); |
| 32 | define('CPABC_APPOINTMENTS_DEFAULT_CALENDAR_WEEKDAY', '0'); |
| 33 | define('CPABC_APPOINTMENTS_DEFAULT_CALENDAR_MINDATE', 'today'); |
| 34 | define('CPABC_APPOINTMENTS_DEFAULT_CALENDAR_MAXDATE', ''); |
| 35 | define('CPABC_APPOINTMENTS_DEFAULT_CALENDAR_PAGES', 1); |
| 36 | |
| 37 | define('CPABC_APPOINTMENTS_DEFAULT_cu_user_email_field', 'email'); |
| 38 | define('CPABC_APPOINTMENTS_DEFAULT_email_format', 'text'); |
| 39 | define('CPABC_APPOINTMENTS_DEFAULT_ENABLE_PAYPAL', 1); |
| 40 | define('CPABC_APPOINTMENTS_DEFAULT_PAYPAL_EMAIL','sample@email.com'); |
| 41 | define('CPABC_APPOINTMENTS_DEFAULT_PRODUCT_NAME','Appointment'); |
| 42 | define('CPABC_APPOINTMENTS_DEFAULT_COST','25'); |
| 43 | define('CPABC_APPOINTMENTS_DEFAULT_OK_URL',get_site_url()); |
| 44 | define('CPABC_APPOINTMENTS_DEFAULT_CANCEL_URL',get_site_url()); |
| 45 | define('CPABC_APPOINTMENTS_DEFAULT_CURRENCY','USD'); |
| 46 | define('CPABC_APPOINTMENTS_DEFAULT_PAYPAL_LANGUAGE','EN'); |
| 47 | |
| 48 | define('CPABC_APPOINTMENTS_DEFAULT_ENABLE_REMINDER', 0); |
| 49 | define('CPABC_APPOINTMENTS_DEFAULT_REMINDER_HOURS', 48); |
| 50 | define('CPABC_APPOINTMENTS_DEFAULT_REMINDER_SUBJECT', 'Appointment reminder...'); |
| 51 | define('CPABC_APPOINTMENTS_DEFAULT_REMINDER_CONTENT', "This is a reminder for your appointment with the following information:\n\n%INFORMATION%\n\nThank you.\n\nBest regards."); |
| 52 | |
| 53 | define('CPABC_APPOINTMENTS_DEFAULT_SUBJECT_CONFIRMATION_EMAIL', 'Thank you for your request...'); |
| 54 | define('CPABC_APPOINTMENTS_DEFAULT_CONFIRMATION_EMAIL', "We have received your request with the following information:\n\n%INFORMATION%\n\nThank you.\n\nBest regards."); |
| 55 | define('CPABC_APPOINTMENTS_DEFAULT_SUBJECT_NOTIFICATION_EMAIL','New appointment requested...'); |
| 56 | define('CPABC_APPOINTMENTS_DEFAULT_NOTIFICATION_EMAIL', "New appointment made with the following information:\n\n%INFORMATION%\n\nBest regards."); |
| 57 | |
| 58 | define('CPABC_APPOINTMENTS_DEFAULT_CP_CAL_CHECKBOXES',""); |
| 59 | define('CPABC_APPOINTMENTS_DEFAULT_EXPLAIN_CP_CAL_CHECKBOXES',"1.00 | Service 1 for us$1.00\n5.00 | Service 2 for us$5.00\n10.00 | Service 3 for us$10.00"); |
| 60 | |
| 61 | |
| 62 | // tables |
| 63 | |
| 64 | define('CPABC_APPOINTMENTS_TABLE_NAME_NO_PREFIX', "cpabc_appointments"); |
| 65 | define('CPABC_APPOINTMENTS_TABLE_NAME', @$wpdb->prefix . CPABC_APPOINTMENTS_TABLE_NAME_NO_PREFIX); |
| 66 | |
| 67 | define('CPABC_APPOINTMENTS_CALENDARS_TABLE_NAME_NO_PREFIX', "cpabc_appointment_calendars_data"); |
| 68 | define('CPABC_APPOINTMENTS_CALENDARS_TABLE_NAME', @$wpdb->prefix ."cpabc_appointment_calendars_data"); |
| 69 | |
| 70 | define('CPABC_APPOINTMENTS_CONFIG_TABLE_NAME_NO_PREFIX', "cpabc_appointment_calendars"); |
| 71 | define('CPABC_APPOINTMENTS_CONFIG_TABLE_NAME', @$wpdb->prefix ."cpabc_appointment_calendars"); |
| 72 | |
| 73 | define('CPABC_APPOINTMENTS_DISCOUNT_CODES_TABLE_NAME_NO_PREFIX', "cpabc_appointments_discount_codes"); |
| 74 | define('CPABC_APPOINTMENTS_DISCOUNT_CODES_TABLE_NAME', @$wpdb->prefix ."cpabc_appointments_discount_codes"); |
| 75 | |
| 76 | // calendar constants |
| 77 | |
| 78 | define("CPABC_TDEAPP_DEFAULT_CALENDAR_ID","1"); |
| 79 | define("CPABC_TDEAPP_DEFAULT_CALENDAR_LANGUAGE","EN"); |
| 80 | |
| 81 | define("CPABC_TDEAPP_CAL_PREFIX", "cal"); |
| 82 | define("CPABC_TDEAPP_CONFIG",CPABC_APPOINTMENTS_CONFIG_TABLE_NAME); |
| 83 | define("CPABC_TDEAPP_CONFIG_ID","id"); |
| 84 | define("CPABC_TDEAPP_CONFIG_TITLE","title"); |
| 85 | define("CPABC_TDEAPP_CONFIG_USER","uname"); |
| 86 | define("CPABC_TDEAPP_CONFIG_PASS","passwd"); |
| 87 | define("CPABC_TDEAPP_CONFIG_LANG","lang"); |
| 88 | define("CPABC_TDEAPP_CONFIG_CPAGES","cpages"); |
| 89 | define("CPABC_TDEAPP_CONFIG_TYPE","ctype"); |
| 90 | define("CPABC_TDEAPP_CONFIG_MSG","msg"); |
| 91 | define("CPABC_TDEAPP_CONFIG_WORKINGDATES","workingDates"); |
| 92 | define("CPABC_TDEAPP_CONFIG_RESTRICTEDDATES","restrictedDates"); |
| 93 | define("CPABC_TDEAPP_CONFIG_TIMEWORKINGDATES0","timeWorkingDates0"); |
| 94 | define("CPABC_TDEAPP_CONFIG_TIMEWORKINGDATES1","timeWorkingDates1"); |
| 95 | define("CPABC_TDEAPP_CONFIG_TIMEWORKINGDATES2","timeWorkingDates2"); |
| 96 | define("CPABC_TDEAPP_CONFIG_TIMEWORKINGDATES3","timeWorkingDates3"); |
| 97 | define("CPABC_TDEAPP_CONFIG_TIMEWORKINGDATES4","timeWorkingDates4"); |
| 98 | define("CPABC_TDEAPP_CONFIG_TIMEWORKINGDATES5","timeWorkingDates5"); |
| 99 | define("CPABC_TDEAPP_CONFIG_TIMEWORKINGDATES6","timeWorkingDates6"); |
| 100 | define("CPABC_TDEAPP_CALDELETED_FIELD","caldeleted"); |
| 101 | |
| 102 | define('CPABC_TDEAPP_CALENDAR_STEP2_VRFY', true); |
| 103 | |
| 104 | define("CPABC_TDEAPP_CALENDAR_DATA_TABLE",CPABC_APPOINTMENTS_CALENDARS_TABLE_NAME); |
| 105 | define("CPABC_TDEAPP_DATA_ID","id"); |
| 106 | define("CPABC_TDEAPP_DATA_IDCALENDAR","appointment_calendar_id"); |
| 107 | define("CPABC_TDEAPP_DATA_DATETIME","datatime"); |
| 108 | define("CPABC_TDEAPP_DATA_TITLE","title"); |
| 109 | define("CPABC_TDEAPP_DATA_DESCRIPTION","description"); |
| 110 | // end calendar constants |
| 111 | |
| 112 | define('CPABC_TDEAPP_DEFAULT_dexcv_enable_captcha', 'true'); |
| 113 | define('CPABC_TDEAPP_DEFAULT_dexcv_width', '180'); |
| 114 | define('CPABC_TDEAPP_DEFAULT_dexcv_height', '60'); |
| 115 | define('CPABC_TDEAPP_DEFAULT_dexcv_chars', '5'); |
| 116 | define('CPABC_TDEAPP_DEFAULT_dexcv_font', 'font1'); |
| 117 | define('CPABC_TDEAPP_DEFAULT_dexcv_min_font_size', '25'); |
| 118 | define('CPABC_TDEAPP_DEFAULT_dexcv_max_font_size', '35'); |
| 119 | define('CPABC_TDEAPP_DEFAULT_dexcv_noise', '200'); |
| 120 | define('CPABC_TDEAPP_DEFAULT_dexcv_noise_length', '4'); |
| 121 | define('CPABC_TDEAPP_DEFAULT_dexcv_background', 'ffffff'); |
| 122 | define('CPABC_TDEAPP_DEFAULT_dexcv_border', 'ffffff'); |
| 123 | define('CPABC_TDEAPP_DEFAULT_dexcv_text_enter_valid_captcha', 'Please enter a valid captcha code.'); |
| 124 | |
| 125 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_is_required', 'This field is required.'); |
| 126 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_is_email', 'Please enter a valid email address.'); |
| 127 | |
| 128 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_datemmddyyyy', 'Please enter a valid date with this format(mm/dd/yyyy)'); |
| 129 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_dateddmmyyyy', 'Please enter a valid date with this format(dd/mm/yyyy)'); |
| 130 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_number', 'Please enter a valid number.'); |
| 131 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_digits', 'Please enter only digits.'); |
| 132 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_max', 'Please enter a value less than or equal to {0}.'); |
| 133 | define('CPABC_APPOINTMENTS_DEFAULT_vs_text_min', 'Please enter a value greater than or equal to {0}.'); |
| 134 | |
| 135 | include_once dirname( __FILE__ ) . '/inc/cpabc_apps_on.inc.php'; |
| 136 | |
| 137 | register_activation_hook(__FILE__,'cpabc_appointments_install'); |
| 138 | |
| 139 | add_action( 'init', 'cpabc_plugin_init'); |
| 140 | add_action( 'init', 'cpabc_appointments_main_initialization', 11 ); |
| 141 | add_action( 'plugins_loaded', 'cpabc_appointments_calendar_load', 11 ); |
| 142 | add_action( 'plugins_loaded', 'cpabc_appointments_calendar_load2', 11 ); |
| 143 | add_action( 'plugins_loaded', 'cpabc_appointments_calendar_update', 11 ); |
| 144 | add_action( 'plugins_loaded', 'cpabc_appointments_calendar_update2', 11 ); |
| 145 | |
| 146 | //START: activation redirection |
| 147 | function cpabc_activation_redirect( $plugin ) { |
| 148 | if( |
| 149 | $plugin == plugin_basename( __FILE__ ) && |
| 150 | (!isset($_POST["action"]) || $_POST["action"] != 'activate-selected') && |
| 151 | (!isset($_POST["action2"]) || $_POST["action2"] != 'activate-selected') |
| 152 | ) |
| 153 | { |
| 154 | exit( wp_redirect( admin_url( 'admin.php?page=cpabc_appointments.php' ) ) ); |
| 155 | } |
| 156 | } |
| 157 | //add_action( 'activated_plugin', 'cpabc_activation_redirect' ); |
| 158 | //END: activation redirection |
| 159 | |
| 160 | if ( is_admin() ) { |
| 161 | add_action('media_buttons', 'set_cpabc_apps_insert_button', 100); |
| 162 | add_action('admin_enqueue_scripts', 'set_cpabc_apps_insert_adminScripts', 1); |
| 163 | add_action('admin_menu', 'cpabc_appointments_admin_menu'); |
| 164 | add_action('enqueue_block_editor_assets', 'cpabc_appointments_gutenberg_block' ); |
| 165 | add_action('wp_loaded', 'cpabc_data_management_loaded' ); |
| 166 | |
| 167 | $plugin = plugin_basename(__FILE__); |
| 168 | add_filter("plugin_action_links_".$plugin, 'cpabc_customAdjustmentsLink'); |
| 169 | add_filter("plugin_action_links_".$plugin, 'cpabc_settingsLink'); |
| 170 | add_filter("plugin_action_links_".$plugin, 'cpabc_helpLink'); |
| 171 | |
| 172 | function cpabc_appointments_admin_menu() { |
| 173 | add_options_page('Appointment Booking Calendar Options', 'Appointment Booking Calendar', 'manage_options', 'cpabc_appointments.php', 'cpabc_appointments_html_post_page' ); |
| 174 | add_menu_page( 'Appointment Booking Calendar Options', 'Appointment Booking Calendar', 'read', 'cpabc_appointments.php', 'cpabc_appointments_html_post_page' ); |
| 175 | |
| 176 | add_submenu_page( 'cpabc_appointments.php', 'Manage Calendars', 'Manage Calendars', 'read', "cpabc_appointments", 'cpabc_appointments_html_post_page' ); |
| 177 | add_submenu_page( 'cpabc_appointments.php', 'Help: Online demo', 'Help: Online demo', 'read', "cpabc_appointments_demo", 'cpabc_appointments_html_post_page' ); |
| 178 | add_submenu_page( 'cpabc_appointments.php', 'I Need Help', 'I Need Help', 'read', "cpabc_appointments_support", 'cpabc_appointments_html_post_page' ); |
| 179 | add_submenu_page( 'cpabc_appointments.php', 'Upgrade', 'Upgrade', 'read', "cpabc_appointments_upgrade", 'cpabc_appointments_html_post_page' ); |
| 180 | |
| 181 | } |
| 182 | } |
| 183 | else |
| 184 | { |
| 185 | add_shortcode( 'CPABC_APPOINTMENT_CALENDAR', 'cpabc_appointments_filter_content' ); |
| 186 | add_shortcode( 'CPABC_EDIT_CALENDAR', 'cpabc_appointments_filter_edit' ); |
| 187 | add_shortcode( 'CPABC_APPOINTMENT_LIST', 'cpabc_appointments_filter_list' ); |
| 188 | } |
| 189 | |
| 190 | |
| 191 | function cpabc_appointments_gutenberg_block() { |
| 192 | wp_enqueue_script( 'cpabc_gutenberg_editor', plugins_url('/js/block.js', __FILE__)); |
| 193 | } |
| 194 | |
| 195 | |
| 196 | function cpabc_plugin_init() { |
| 197 | load_plugin_textdomain( 'appointment-booking-calendar', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 198 | } |
| 199 | |
| 200 | |
| 201 | function cpabc_appointments_install($networkwide) { |
| 202 | global $wpdb; |
| 203 | |
| 204 | if (function_exists('is_multisite') && is_multisite()) { |
| 205 | // check if it is a network activation - if so, run the activation function for each blog id |
| 206 | if ($networkwide) { |
| 207 | $old_blog = $wpdb->blogid; |
| 208 | // Get all blog ids |
| 209 | $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); |
| 210 | foreach ($blogids as $blog_id) { |
| 211 | switch_to_blog($blog_id); |
| 212 | _cpabc_appointments_install(); |
| 213 | } |
| 214 | switch_to_blog($old_blog); |
| 215 | return; |
| 216 | } |
| 217 | } |
| 218 | _cpabc_appointments_install(); |
| 219 | } |
| 220 | |
| 221 | |
| 222 | $cpabc_pcode = base64_decode(get_option('CPABC_PCODE',"")); |
| 223 | if ($cpabc_pcode == '') |
| 224 | { |
| 225 | if (function_exists('openssl_random_pseudo_bytes')) |
| 226 | $cpabc_pcode = openssl_random_pseudo_bytes(16); |
| 227 | else |
| 228 | $cpabc_pcode = uniqid('cpabc'); |
| 229 | update_option( 'CPABC_PCODE', base64_encode($cpabc_pcode)); |
| 230 | } |
| 231 | |
| 232 | |
| 233 | // this filter has been applied to avoid problems with WP Rocket Optimizations |
| 234 | add_filter( 'rocket_exclude_js', 'cpabc_wprockert_exclude_js_minify' ); |
| 235 | function cpabc_wprockert_exclude_js_minify( $js_files ) { |
| 236 | $js_files[] = plugins_url('/TDE_AppCalendar/all-scripts.js', __FILE__); |
| 237 | $js_files[] = plugins_url('/TDE_AppCalendar/all-scripts.min.js', __FILE__); |
| 238 | $js_files[] = plugins_url('/js/(.*).js', __FILE__); |
| 239 | return $js_files; |
| 240 | } |
| 241 | |
| 242 | // optional opt-in deactivation feedback |
| 243 | require_once 'inc/cp-feedback.php'; |
| 244 | |
| 245 | // elementor integration |
| 246 | include_once dirname( __FILE__ ) . '/controllers/elementor/cp-elementor-widget.inc.php'; |
| 247 | |
| 248 | |
| 249 | // prevent non-admin users from using the list shortcode |
| 250 | add_filter( 'content_save_pre', function ( $content ) { |
| 251 | |
| 252 | if ( current_user_can( 'manage_options' ) ) { |
| 253 | return $content; |
| 254 | } |
| 255 | |
| 256 | // Remove only NEW instances |
| 257 | $content = preg_replace( |
| 258 | '/\[CPABC_APPOINTMENT_LIST[^\]]*\]/', |
| 259 | '', |
| 260 | $content |
| 261 | ); |
| 262 | |
| 263 | return $content; |
| 264 | }); |