Plugin Directory

Changeset 2144937


Ignore:
Timestamp:
08/24/2019 07:33:04 PM (6 years ago)
Author:
zaheer01
Message:

Latest Version 1.1.0

Location:
bp-event-manager/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bp-event-manager/trunk/bp-event-manager.php

    r2128012 r2144937  
     1<?php
     2
     3/*
     4
     5Plugin Name: BP Event Manager
     6
     7Plugin URI: http://wordpresswithzaheer.blogspot.com/p/plugin.html
     8
     9Description: Plug and Play Plugin Development. A person can create events for buddypress groups.
     10
     11Version: 1.0.0
     12
     13Author: Zaheer Abbas Aghani
     14
     15Author URI: https://profiles.wordpress.org/zaheer01/
     16
     17License: GPLv3 or later
     18
     19Text Domain: bp-event-manager
     20
     21Domain Path: /languages
     22
     23 */
     24
     25defined("ABSPATH") or die('You can\t access!');
     26
     27class BPEventManager {
     28
     29// check if buddypress is installed
     30
     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();
     40
     41        }
     42
     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++;
     218
     219        }
     220
     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>',
     234
     235        );
     236
     237        if (array_key_exists('deactivate', $links)) {
     238
     239            $links['deactivate'] = str_replace('<a', '<a class="bpem-deactivate-link"', $links['deactivate']);
     240
     241        }
     242
     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        }
     276
     277        $reasons = $this->bepm_get_uninstall_comments();
     278
     279        ?>
     280
     281
     282
     283<div class="bpem-review-box" id="bpem-review-boxx">
     284
     285
     286
     287    <div class="bpem-modal-wrap">
     288
     289
     290
     291        <div class="bpem-modal-header">
     292
     293
     294
     295            <h3><?php _e('Help Us:', 'bp-event-manager');?></h3>
     296
     297
     298
     299        </div>
     300
     301
     302
     303        <div class="bpem-modal-body">
     304
     305
     306
     307            <ul class="reasons">
     308
     309
     310
     311                <?php foreach ($reasons as $reason) {?>
     312
     313
     314
     315                    <li data-type="<?php echo esc_attr($reason['type']); ?>" data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>">
     316
     317
     318
     319                        <label><input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> <?php echo $reason['text']; ?></label>
     320
     321
     322
     323                    </li>
     324
     325
     326
     327                <?php }?>
     328
     329
     330
     331            </ul>
     332
     333
     334
     335        </div>
     336
     337
     338
     339        <div class="bpem-modal-footer">
     340
     341
     342
     343            <button class="button-primary bpem-model-submit"><?php _e('No Deactivate', 'bp-event-manager');?></button>
     344
     345
     346
     347            <button class="button-secondary bpem-model-cancel"><?php _e('Cancel', 'bp-event-manager');?></button>
     348
     349
     350
     351        </div>
     352
     353
     354
     355    </div>
     356
     357
     358
     359</div>
     360
     361
     362
     363
     364
     365
     366
     367<script type="text/javascript">
     368
     369
     370
     371    (function ($) {
     372        $(function () {
     373        var modal = $('#bpem-review-boxx');
     374        var deactivateLink = '';
     375
     376        $('#the-list').on('click', 'a.bpem-deactivate-link', function (e) {
     377            e.preventDefault();
     378            modal.addClass('modal-active');
     379            deactivateLink = $(this).attr('href');
     380            modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left');
     381        });
     382
     383    $('#bpem-review-boxx').on('click', 'a.review-and-deactivate', function (e) {
     384        e.preventDefault();
     385            window.open("https://wordpress.org/support/plugin/bp-event-manager/reviews/#new-post");
     386        window.location.href = deactivateLink;
     387    });
     388
     389
     390
     391            modal.on('click', 'button.bpem-model-cancel', function (e) {
     392
     393
     394
     395                e.preventDefault();
     396
     397
     398
     399                modal.removeClass('modal-active');
     400
     401
     402
     403            });
     404
     405
     406
     407            modal.on('click', 'input[type="radio"]', function () {
     408
     409
     410
     411                var parent = $(this).parents('li:first');
     412
     413
     414
     415                modal.find('.reason-input').remove();
     416
     417
     418
     419                var inputType = parent.data('type'),
     420
     421
     422
     423                        inputPlaceholder = parent.data('placeholder');
     424
     425
     426
     427                if ('reviewhtml' === inputType) {
     428
     429
     430
     431                    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"> &#9733;&#9733;&#9733;&#9733;&#9733; </span></a></div>';
     432
     433
     434
     435                } else {
     436
     437
     438
     439                    var reasonInputHtml = '<div class="reason-input">' + (('text' === inputType) ? '<input type="text" class="input-text" size="40" />' : '<textarea rows="5" cols="45"></textarea>') + '</div>';
     440
     441
     442
     443                }
     444
     445
     446
     447                if (inputType !== '') {
     448
     449
     450
     451                    parent.append($(reasonInputHtml));
     452
     453
     454
     455                    parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
     456
     457
     458
     459                }
     460
     461
     462
     463            });
     464
     465
     466
     467
     468
     469
     470
     471            modal.on('click', 'button.bpem-model-submit', function (e) {
     472
     473
     474
     475                e.preventDefault();
     476
     477
     478
     479                var button = $(this);
     480
     481
     482
     483                if (button.hasClass('disabled')) {
     484
     485
     486
     487                    return;
     488
     489
     490
     491                }
     492
     493
     494
     495                var $radio = $('input[type="radio"]:checked', modal);
     496
     497
     498
     499                var $selected_reason = $radio.parents('li:first'),
     500
     501
     502
     503                $input = $selected_reason.find('textarea, input[type="text"]');
     504
     505
     506
     507                button.addClass('disabled');
     508
     509
     510
     511                button.text('Processing...');
     512
     513
     514
     515                window.location.href = deactivateLink;
     516
     517
     518
     519
     520
     521
     522
     523
     524
     525
     526
     527            });
     528
     529
     530
     531        });
     532
     533
     534
     535    }(jQuery));
     536
     537
     538
     539</script>
     540
     541
     542
     543<?php
     544
     545    }
     546
     547// register All Events widget
     548
     549    function bpem_all_events_in_calendar() {
     550
     551        register_widget('ALLEVENTS');
     552
     553    }
     554
     555} // class ends
     556
     557// CHECK WETHER CLASS EXISTS OR NOT.
     558
     559if (class_exists('BPEventManager')) {
     560
     561    $obj = new BPEventManager();
     562
     563    require_once plugin_dir_path(__FILE__) . 'bpem-dash/bpem_showing_all_events.php';
     564
     565}
     566
     567//activate plugin hook
     568
     569register_activation_hook(__FILE__, array($obj, 'bpem_activate'));
  • bp-event-manager/trunk/readme.txt

    r2118402 r2144937  
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     9Stable tag: 1.1.0
    910
    1011
Note: See TracChangeset for help on using the changeset viewer.