Changeset 2160513
- Timestamp:
- 09/21/2019 08:24:52 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
bp-event-manager/trunk/bp-event-manager.php
r2144937 r2160513 1 1 <?php 2 2 3 4 3 5 /* 4 6 7 8 5 9 Plugin Name: BP Event Manager 6 10 11 12 7 13 Plugin URI: http://wordpresswithzaheer.blogspot.com/p/plugin.html 8 14 15 16 9 17 Description: Plug and Play Plugin Development. A person can create events for buddypress groups. 10 18 19 20 11 21 Version: 1.0.0 12 22 23 24 13 25 Author: Zaheer Abbas Aghani 14 26 27 28 15 29 Author URI: https://profiles.wordpress.org/zaheer01/ 16 30 31 32 17 33 License: GPLv3 or later 18 34 35 36 19 37 Text Domain: bp-event-manager 20 38 39 40 21 41 Domain Path: /languages 22 42 43 44 23 45 */ 24 46 47 48 25 49 defined("ABSPATH") or die('You can\t access!'); 26 50 51 52 27 53 class BPEventManager { 28 54 55 56 29 57 // check if buddypress is installed 30 58 31 function bpem_if_buddypress_not_active($message) { 32 33 if (!is_plugin_active('buddypress/bp-loader.php')) { 34 35 echo $message .= "<div class='notice notice-error is-dismissible'><h4> Buddypress Plugin Activation Required for BP Event Manager Plugin.</h4></div>"; 36 37 deactivate_plugins('/bp-event-manager/bp-event-manager.php'); 38 39 wp_die(); 59 60 61 function bpem_if_buddypress_not_active($message) { 62 if (!is_plugin_active('buddypress/bp-loader.php')) { 63 echo $message .= "<div class='notice notice-error is-dismissible'><h4> Buddypress Plugin Activation Required for BP Event Manager Plugin.</h4> 64 <a href='".get_site_url().'/wp-admin/plugins.php'."'> Go Back</a> 65 </div>"; 66 deactivate_plugins('/bp-event-manager/bp-event-manager.php'); 67 wp_die(); 68 } 69 } 70 71 72 73 function __construct() { 74 75 76 77 add_action('init', array($this, 'bpem_enqueue_script_front')); 78 79 80 81 add_action('init', array($this, 'bpem_start_from_here')); 82 83 84 85 add_action('init', array($this, 'bpem_register_dashboard_post_page')); 86 87 88 89 add_action('admin_enqueue_scripts', array($this, 'bpem_admin_enqueue_scripts')); 90 91 92 93 add_action('admin_menu', array($this, 'bpem_cpt_ui_for_admin_only')); 94 95 96 97 add_action('add_meta_boxes', array($this, 'bpem_attendees_add_meta_boxes')); 98 99 100 101 add_action('plugins_loaded', array($this, 'load_textdomain')); 102 103 add_action( 'admin_init', array($this,'bpem_if_buddypress_not_active' )); 104 105 add_action('admin_footer', array($this, 'bpem_deactivate_scripts')); 106 107 108 109 add_action('widgets_init', array($this, 'bpem_all_events_in_calendar')); 110 111 112 113 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'bpem_plugin_action_links')); 114 115 116 117 /*add_filter('bp_blogs_record_post_post_types', array($this, 'activity_publish_custom_post_types'), 1, 1); 118 119 120 121 add_filter('bp_blogs_activity_new_post_action', array($this, 'record_cpt_activity_action'), 1, 3);*/ 122 123 124 125 } 126 127 128 129 // Activate plugin 130 131 132 133 function bpem_activate() { 134 135 136 137 flush_rewrite_rules(); 138 139 add_post_type_support('bpem_event', 'buddypress-activity'); 140 141 } 142 143 144 145 public function load_textdomain() { 146 147 148 149 load_plugin_textdomain('bpem-plugin', false, basename(dirname(__FILE__)) . '/languages/'); 150 151 152 153 } 154 155 156 157 //All Plugin files 158 159 160 161 function bpem_start_from_here() { 162 163 164 165 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-form.php'; 166 167 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-form-response.php'; 168 169 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_persons_who_attend_event.php'; 170 171 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-list-of-attendees.php'; 172 173 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-calendar.php'; 174 175 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-further-details.php'; 176 177 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_leave_event.php'; 178 179 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-list-events.php'; 180 181 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_event_update_response.php'; 182 183 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_event_delete_response.php'; 184 185 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_event_info.php'; 186 187 188 189 } 190 191 192 193 // Enqueue Style and Scripts 194 195 196 197 function bpem_enqueue_script_front() { 198 199 200 201 //Style 202 203 204 205 wp_enqueue_style('bpem-style', plugins_url('inc/css/bpem-style.css', __FILE__), '1.0.0', 'all'); 206 207 208 209 wp_enqueue_style('bpem-jquery-ui', plugins_url('inc/css/jquery-ui.css', __FILE__), false, "1.9.0", false); 210 211 212 213 wp_enqueue_style('bpem-timepicker', plugins_url('inc/css/jquery.timepicker.min.css', __FILE__), '1.14.11', 'all'); 214 215 216 217 wp_enqueue_style('font-awesome', plugins_url('inc/css/font-awesome-4.7.0/css/font-awesome.min.css', __FILE__), '4.7.0', 'all'); 218 219 220 221 wp_enqueue_style('bpem-fc', plugins_url('inc/css/fullcalendar.min.css', __FILE__), '2.3.2', 'all'); 222 223 224 225 wp_enqueue_style('bpem-pagination', plugins_url('inc/css/simplePagination.min.css', __FILE__), '1.6', 'all'); 226 227 228 229 // JS Scripts 230 231 232 233 wp_enqueue_script('fd-validate', 'https://cdn.jsdelivr.net/npm/jquery-validation@1.19.0/dist/jquery.validate.min.js', array('jquery'), '', true); 234 235 236 237 wp_enqueue_script('bpem-timepicker', plugins_url('inc/js/jquery.timepicker.min.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'), '1.11.14', true); 238 239 240 241 wp_enqueue_script('bpem-script', plugins_url('inc/js/bpem_script.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'), '1.0.0', true); 242 243 244 245 wp_localize_script('bpem-script', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php'))); 246 247 248 249 wp_enqueue_style('jquery-ui-datepicker'); 250 251 252 253 wp_enqueue_style('wp-color-picker'); 254 255 256 257 wp_enqueue_script('wp-color-picker'); 258 259 260 261 wp_enqueue_media(); 262 263 264 265 wp_enqueue_script('moments', plugins_url('inc/js/moment.min.js', __FILE__), array('jquery'), '2.10.6', true); 266 267 268 269 wp_enqueue_script('bpem-clndr', plugins_url('inc/js/fullcalendar.min.js', __FILE__), array('jquery'), '2.3.2', true); 270 271 272 273 wp_enqueue_script('bpem-pagination', plugins_url('inc/js/jquery.simplePagination.js', __FILE__), array('jquery'), '1.6', true); 274 275 276 277 } 278 279 280 281 //Enqueue style and script for admin 282 283 284 285 function bpem_admin_enqueue_scripts() { 286 287 288 289 wp_enqueue_style('bpem-admin', plugins_url('inc/css/admin-style.css', __FILE__), '1.0.0', 'all'); 290 291 292 293 } 294 295 296 297 // Register post type 298 299 300 301 function bpem_register_dashboard_post_page() { 302 303 304 305 require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem-post-type.php'; 306 307 308 309 require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem-admin-settings-page.php'; 310 311 312 313 require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem_remove_attendy.php'; 314 315 316 317 } 318 319 320 321 // Remove events tab if user is not admin 322 323 324 325 function bpem_cpt_ui_for_admin_only() { 326 327 328 329 if (!current_user_can('administrator')): 330 331 332 333 remove_menu_page('edit.php?post_type=bpem_event'); 334 335 336 337 endif; 338 339 340 341 } 342 343 344 345 //List of attendees in dashboard 346 347 348 349 function bpem_attendees_add_meta_boxes() { 350 351 352 353 add_meta_box('bpem_meta_box_attendees', 'Event Attendees', array($this, 'bpem_list_display_attendees'), 'bpem_event', 'side', 'low'); 354 355 356 357 } //bpem_attendees_add_meta_boxes 358 359 360 361 //List of attendees in dashboard 362 363 364 365 function bpem_list_display_attendees() { 366 367 368 369 global $post; 370 371 372 373 $user_ids = get_post_meta($post->ID, 'event_attend_id'); 374 375 376 377 $count = count(array_filter($user_ids)); 378 379 380 381 echo "<h4 class='attandees'> Attandees(" . $count . ")</h4> "; 382 383 384 385 sprintf(__('You can visit the page by clicking <a href="%s">here</a>.', 'bp-event-manager'), 'http://www.google.com'); 386 387 388 389 $i = 0; 390 391 392 393 echo "<div class='wrap_bx'>"; 394 395 396 397 foreach ($user_ids as $user_id) { 398 399 400 401 $avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'width' => 100, 'height' => 100, 'class' => 'avatar', 'html' => false)); 402 403 404 405 echo "<div class='box'><a href='#' class='remove_attendy' user-id='" . $user_id . "' event-id='" . $post->ID . "'>x</a > <a href='" . bp_core_get_user_domain($user_id) . "' class='box_attendee' target='_blank'>"; 406 407 408 409 echo "<img src='" . $avatar . "' alt=" . bp_core_get_username($user_id) . " title=" . bp_core_get_username($user_id) . ">"; 410 411 412 413 echo "</a></div>"; 414 415 416 417 $i++; 418 419 40 420 41 421 } 42 422 43 } 44 45 function __construct() { 46 47 add_action('init', array($this, 'bpem_enqueue_script_front')); 48 49 add_action('init', array($this, 'bpem_start_from_here')); 50 51 add_action('init', array($this, 'bpem_register_dashboard_post_page')); 52 53 add_action('admin_enqueue_scripts', array($this, 'bpem_admin_enqueue_scripts')); 54 55 add_action('admin_menu', array($this, 'bpem_cpt_ui_for_admin_only')); 56 57 add_action('add_meta_boxes', array($this, 'bpem_attendees_add_meta_boxes')); 58 59 add_action('plugins_loaded', array($this, 'load_textdomain')); 60 61 add_action('admin_footer', array($this, 'bpem_deactivate_scripts')); 62 63 add_action('widgets_init', array($this, 'bpem_all_events_in_calendar')); 64 65 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'bpem_plugin_action_links')); 66 67 /*add_filter('bp_blogs_record_post_post_types', array($this, 'activity_publish_custom_post_types'), 1, 1); 68 69 add_filter('bp_blogs_activity_new_post_action', array($this, 'record_cpt_activity_action'), 1, 3);*/ 70 71 } 72 73 // Activate plugin 74 75 function bpem_activate() { 76 77 flush_rewrite_rules(); 78 add_post_type_support('bpem_event', 'buddypress-activity'); 79 } 80 81 public function load_textdomain() { 82 83 load_plugin_textdomain('bpem-plugin', false, basename(dirname(__FILE__)) . '/languages/'); 84 85 } 86 87 //All Plugin files 88 89 function bpem_start_from_here() { 90 91 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-form.php'; 92 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-form-response.php'; 93 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_persons_who_attend_event.php'; 94 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-list-of-attendees.php'; 95 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-calendar.php'; 96 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-event-further-details.php'; 97 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_leave_event.php'; 98 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem-list-events.php'; 99 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_event_update_response.php'; 100 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_event_delete_response.php'; 101 require_once plugin_dir_path(__FILE__) . 'bpem-front/bpem_event_info.php'; 102 103 } 104 105 // Enqueue Style and Scripts 106 107 function bpem_enqueue_script_front() { 108 109 //Style 110 111 wp_enqueue_style('bpem-style', plugins_url('inc/css/bpem-style.css', __FILE__), '1.0.0', 'all'); 112 113 wp_enqueue_style('bpem-jquery-ui', plugins_url('inc/css/jquery-ui.css', __FILE__), false, "1.9.0", false); 114 115 wp_enqueue_style('bpem-timepicker', plugins_url('inc/css/jquery.timepicker.min.css', __FILE__), '1.14.11', 'all'); 116 117 wp_enqueue_style('font-awesome', plugins_url('inc/css/font-awesome-4.7.0/css/font-awesome.min.css', __FILE__), '4.7.0', 'all'); 118 119 wp_enqueue_style('bpem-fc', plugins_url('inc/css/fullcalendar.min.css', __FILE__), '2.3.2', 'all'); 120 121 wp_enqueue_style('bpem-pagination', plugins_url('inc/css/simplePagination.min.css', __FILE__), '1.6', 'all'); 122 123 // JS Scripts 124 125 wp_enqueue_script('fd-validate', 'https://cdn.jsdelivr.net/npm/jquery-validation@1.19.0/dist/jquery.validate.min.js', array('jquery'), '', true); 126 127 wp_enqueue_script('bpem-timepicker', plugins_url('inc/js/jquery.timepicker.min.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'), '1.11.14', true); 128 129 wp_enqueue_script('bpem-script', plugins_url('inc/js/bpem_script.js', __FILE__), array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker'), '1.0.0', true); 130 131 wp_localize_script('bpem-script', 'ajax_object', array('ajax_url' => admin_url('admin-ajax.php'))); 132 133 wp_enqueue_style('jquery-ui-datepicker'); 134 135 wp_enqueue_style('wp-color-picker'); 136 137 wp_enqueue_script('wp-color-picker'); 138 139 wp_enqueue_media(); 140 141 wp_enqueue_script('moments', plugins_url('inc/js/moment.min.js', __FILE__), array('jquery'), '2.10.6', true); 142 143 wp_enqueue_script('bpem-clndr', plugins_url('inc/js/fullcalendar.min.js', __FILE__), array('jquery'), '2.3.2', true); 144 145 wp_enqueue_script('bpem-pagination', plugins_url('inc/js/jquery.simplePagination.js', __FILE__), array('jquery'), '1.6', true); 146 147 } 148 149 //Enqueue style and script for admin 150 151 function bpem_admin_enqueue_scripts() { 152 153 wp_enqueue_style('bpem-admin', plugins_url('inc/css/admin-style.css', __FILE__), '1.0.0', 'all'); 154 155 } 156 157 // Register post type 158 159 function bpem_register_dashboard_post_page() { 160 161 require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem-post-type.php'; 162 163 require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem-admin-settings-page.php'; 164 165 require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem_remove_attendy.php'; 166 167 } 168 169 // Remove events tab if user is not admin 170 171 function bpem_cpt_ui_for_admin_only() { 172 173 if (!current_user_can('administrator')): 174 175 remove_menu_page('edit.php?post_type=bpem_event'); 176 177 endif; 178 179 } 180 181 //List of attendees in dashboard 182 183 function bpem_attendees_add_meta_boxes() { 184 185 add_meta_box('bpem_meta_box_attendees', 'Event Attendees', array($this, 'bpem_list_display_attendees'), 'bpem_event', 'side', 'low'); 186 187 } //bpem_attendees_add_meta_boxes 188 189 //List of attendees in dashboard 190 191 function bpem_list_display_attendees() { 192 193 global $post; 194 195 $user_ids = get_post_meta($post->ID, 'event_attend_id'); 196 197 $count = count(array_filter($user_ids)); 198 199 echo "<h4 class='attandees'> Attandees(" . $count . ")</h4> "; 200 201 sprintf(__('You can visit the page by clicking <a href="%s">here</a>.', 'bp-event-manager'), 'http://www.google.com'); 202 203 $i = 0; 204 205 echo "<div class='wrap_bx'>"; 206 207 foreach ($user_ids as $user_id) { 208 209 $avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'width' => 100, 'height' => 100, 'class' => 'avatar', 'html' => false)); 210 211 echo "<div class='box'><a href='#' class='remove_attendy' user-id='" . $user_id . "' event-id='" . $post->ID . "'>x</a > <a href='" . bp_core_get_user_domain($user_id) . "' class='box_attendee' target='_blank'>"; 212 213 echo "<img src='" . $avatar . "' alt=" . bp_core_get_username($user_id) . " title=" . bp_core_get_username($user_id) . ">"; 214 215 echo "</a></div>"; 216 217 $i++; 423 424 425 echo "</div>"; 426 427 428 429 } 430 431 432 433 //bpem_list_display_attendees 434 435 436 437 public function bpem_plugin_action_links($links) { 438 439 440 441 $plugin_links = array( 442 443 444 445 '<a href="' . admin_url('edit.php?post_type=bpem_event&page=bp_event_manager_settings') . '">' . __('Settings', 'bp-event-manager') . '</a>', 446 447 448 449 '<a target="_blank" href="https://wordpress.org/support/plugin/bp-event-manager/">' . __('Support', 'bp-event-manager') . '</a>', 450 451 452 453 ); 454 455 456 457 if (array_key_exists('deactivate', $links)) { 458 459 460 461 $links['deactivate'] = str_replace('<a', '<a class="bpem-deactivate-link"', $links['deactivate']); 462 463 218 464 219 465 } 220 466 221 echo "</div>"; 222 223 } 224 225 //bpem_list_display_attendees 226 227 public function bpem_plugin_action_links($links) { 228 229 $plugin_links = array( 230 231 '<a href="' . admin_url('edit.php?post_type=bpem_event&page=bp_event_manager_settings') . '">' . __('Settings', 'bp-event-manager') . '</a>', 232 233 '<a target="_blank" href="https://wordpress.org/support/plugin/bp-event-manager/">' . __('Support', 'bp-event-manager') . '</a>', 467 468 469 return array_merge($plugin_links, $links); 470 471 472 473 } 474 475 476 477 private function bepm_get_uninstall_comments() { 478 479 480 481 $reasons = array( 482 483 484 485 array( 486 487 488 489 'id' => 'used-it', 490 491 492 493 'text' => __('Can You Please Review ? because we want to improve our plugin.', 'bp-event-manager'), 494 495 496 497 'type' => 'reviewhtml', 498 499 500 501 ), 502 503 234 504 235 505 ); 236 506 237 if (array_key_exists('deactivate', $links)) { 238 239 $links['deactivate'] = str_replace('<a', '<a class="bpem-deactivate-link"', $links['deactivate']); 507 508 509 return $reasons; 510 511 512 513 } 514 515 516 517 public function bpem_deactivate_scripts() { 518 519 520 521 global $pagenow; 522 523 524 525 if ('plugins.php' != $pagenow) { 526 527 528 529 return; 530 531 240 532 241 533 } 242 534 243 return array_merge($plugin_links, $links); 244 245 } 246 247 private function bepm_get_uninstall_comments() { 248 249 $reasons = array( 250 251 array( 252 253 'id' => 'used-it', 254 255 'text' => __('Can You Please Review ? because we want to improve our plugin.', 'bp-event-manager'), 256 257 'type' => 'reviewhtml', 258 259 ), 260 261 ); 262 263 return $reasons; 264 265 } 266 267 public function bpem_deactivate_scripts() { 268 269 global $pagenow; 270 271 if ('plugins.php' != $pagenow) { 272 273 return; 274 275 } 535 276 536 277 537 $reasons = $this->bepm_get_uninstall_comments(); 278 538 539 540 279 541 ?> 280 542 281 543 282 544 545 546 547 548 283 549 <div class="bpem-review-box" id="bpem-review-boxx"> 284 550 285 551 286 552 553 554 555 556 287 557 <div class="bpem-modal-wrap"> 288 558 289 559 290 560 561 562 563 564 291 565 <div class="bpem-modal-header"> 292 566 293 567 294 568 569 570 571 572 295 573 <h3><?php _e('Help Us:', 'bp-event-manager');?></h3> 296 574 297 575 298 576 577 578 579 580 299 581 </div> 300 582 301 583 302 584 585 586 587 588 303 589 <div class="bpem-modal-body"> 304 590 305 591 306 592 593 594 �� 595 596 307 597 <ul class="reasons"> 308 598 309 599 310 600 601 602 603 604 311 605 <?php foreach ($reasons as $reason) {?> 312 606 313 607 314 608 609 610 611 612 315 613 <li data-type="<?php echo esc_attr($reason['type']); ?>" data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>"> 316 614 317 615 318 616 617 618 619 620 319 621 <label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label> 320 622 321 623 322 624 625 626 627 628 323 629 </li> 324 630 325 631 326 632 633 634 635 636 327 637 <?php }?> 328 638 329 639 330 640 641 642 643 644 331 645 </ul> 332 646 333 647 334 648 649 650 651 652 335 653 </div> 336 654 337 655 338 656 657 658 659 660 339 661 <div class="bpem-modal-footer"> 340 662 341 663 342 664 665 666 667 668 343 669 <button class="button-primary bpem-model-submit"><?php _e('No Deactivate', 'bp-event-manager');?></button> 344 670 345 671 346 672 673 674 675 676 347 677 <button class="button-secondary bpem-model-cancel"><?php _e('Cancel', 'bp-event-manager');?></button> 348 678 349 679 350 680 681 682 683 684 351 685 </div> 352 686 353 687 354 688 689 690 691 692 355 693 </div> 356 694 357 695 358 696 697 698 699 700 359 701 </div> 360 702 … … 365 707 366 708 709 710 711 712 713 714 715 716 367 717 <script type="text/javascript"> 368 718 369 719 370 720 721 722 723 724 371 725 (function ($) { 726 372 727 $(function () { 728 373 729 var modal = $('#bpem-review-boxx'); 730 374 731 var deactivateLink = ''; 375 732 733 734 376 735 $('#the-list').on('click', 'a.bpem-deactivate-link', function (e) { 736 377 737 e.preventDefault(); 738 378 739 modal.addClass('modal-active'); 740 379 741 deactivateLink = $(this).attr('href'); 742 380 743 modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left'); 744 381 745 }); 382 746 747 748 383 749 $('#bpem-review-boxx').on('click', 'a.review-and-deactivate', function (e) { 750 384 751 e.preventDefault(); 752 385 753 window.open("https://wordpress.org/support/plugin/bp-event-manager/reviews/#new-post"); 754 386 755 window.location.href = deactivateLink; 756 387 757 }); 388 758 389 759 390 760 761 762 763 764 391 765 modal.on('click', 'button.bpem-model-cancel', function (e) { 392 766 393 767 394 768 769 770 771 772 395 773 e.preventDefault(); 396 774 397 775 398 776 777 778 779 780 399 781 modal.removeClass('modal-active'); 400 782 401 783 402 784 785 786 787 788 403 789 }); 404 790 405 791 406 792 793 794 795 796 407 797 modal.on('click', 'input[type="radio"]', function () { 408 798 409 799 410 800 801 802 803 804 411 805 var parent = $(this).parents('li:first'); 412 806 413 807 414 808 809 810 811 812 415 813 modal.find('.reason-input').remove(); 416 814 417 815 418 816 817 818 819 820 419 821 var inputType = parent.data('type'), 420 822 421 823 422 824 825 826 827 828 423 829 inputPlaceholder = parent.data('placeholder'); 424 830 425 831 426 832 833 834 835 836 427 837 if ('reviewhtml' === inputType) { 428 838 429 839 430 840 841 842 843 844 431 845 var reasonInputHtml = '<div class="reviewlink"><a href="#" target="_blank" class="review-and-deactivate"><?php _e('Deactivate and leave a review', 'bp-event-manager');?> <span class="xa-bpem-rating-link"> ★★★★★ </span></a></div>'; 432 846 433 847 434 848 849 850 851 852 435 853 } else { 436 854 437 855 438 856 857 858 859 860 439 861 var reasonInputHtml = '<div class="reason-input">' + (('text' === inputType) ? '<input type="text" class="input-text" size="40" />' : '<textarea rows="5" cols="45"></textarea>') + '</div>'; 440 862 441 863 442 864 865 866 867 868 443 869 } 444 870 445 871 446 872 873 874 875 876 447 877 if (inputType !== '') { 448 878 449 879 450 880 881 882 883 884 451 885 parent.append($(reasonInputHtml)); 452 886 453 887 454 888 889 890 891 892 455 893 parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus(); 456 894 457 895 458 896 897 898 899 900 459 901 } 460 902 461 903 462 904 905 906 907 908 463 909 }); 464 910 … … 469 915 470 916 917 918 919 920 921 922 923 924 471 925 modal.on('click', 'button.bpem-model-submit', function (e) { 472 926 473 927 474 928 929 930 931 932 475 933 e.preventDefault(); 476 934 477 935 478 936 937 938 939 940 479 941 var button = $(this); 480 942 481 943 482 944 945 946 947 948 483 949 if (button.hasClass('disabled')) { 484 950 485 951 486 952 953 954 955 956 487 957 return; 488 958 489 959 490 960 961 962 963 964 491 965 } 492 966 493 967 494 968 969 970 971 972 495 973 var $radio = $('input[type="radio"]:checked', modal); 496 974 497 975 498 976 977 978 979 980 499 981 var $selected_reason = $radio.parents('li:first'), 500 982 501 983 502 984 985 986 987 988 503 989 $input = $selected_reason.find('textarea, input[type="text"]'); 504 990 505 991 506 992 993 994 995 996 507 997 button.addClass('disabled'); 508 998 509 999 510 1000 1001 1002 1003 1004 511 1005 button.text('Processing...'); 512 1006 513 1007 514 1008 1009 1010 1011 1012 515 1013 window.location.href = deactivateLink; 516 1014 … … 525 1023 526 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 527 1037 }); 528 1038 529 1039 530 1040 1041 1042 1043 1044 531 1045 }); 532 1046 533 1047 534 1048 1049 1050 1051 1052 535 1053 }(jQuery)); 536 1054 537 1055 538 1056 1057 1058 1059 1060 539 1061 </script> 540 1062 541 1063 542 1064 1065 1066 1067 1068 543 1069 <?php 544 1070 545 } 1071 1072 1073 } 1074 1075 546 1076 547 1077 // register All Events widget 548 1078 1079 1080 549 1081 function bpem_all_events_in_calendar() { 550 1082 1083 1084 551 1085 register_widget('ALLEVENTS'); 552 1086 553 } 1087 1088 1089 } 1090 1091 554 1092 555 1093 } // class ends 556 1094 1095 1096 557 1097 // CHECK WETHER CLASS EXISTS OR NOT. 558 1098 1099 1100 559 1101 if (class_exists('BPEventManager')) { 560 1102 1103 1104 561 1105 $obj = new BPEventManager(); 562 1106 1107 1108 563 1109 require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem_showing_all_events.php'; 564 1110 1111 1112 565 1113 } 566 1114 1115 1116 567 1117 //activate plugin hook 568 1118 1119 1120 569 1121 register_activation_hook(__FILE__, array($obj, 'bpem_activate'));
Note: See TracChangeset
for help on using the changeset viewer.