/**
 * Updated!
 *
 * @package Rendez Vous
 * @subpackage Activity
 *
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_updated_activity($id = 0, $args = array(), $notify = false, $activity = false)
{
    if (empty($id) || empty($activity)) {
        return;
    }
    $rdv = rendez_vous();
    if (empty($rdv->item->id)) {
        $rendez_vous = rendez_vous_get_item($id);
    } else {
        $rendez_vous = $rdv->item;
    }
    $rendez_vous_url = rendez_vous_get_single_link($id, $rendez_vous->organizer);
    $rendez_vous_link = '<a href="' . esc_url($rendez_vous_url) . '">' . esc_html($rendez_vous->title) . '</a>';
    $user_link = bp_core_get_userlink($rendez_vous->organizer);
    $action_part = __('updated a', 'rendez-vous');
    $action = sprintf(__('%1$s %2$s rendez-vous, %3$s', 'rendez-vous'), $user_link, $action_part, $rendez_vous_link);
    $activity_id = bp_activity_add(apply_filters('rendez_vous_updated_activity_args', array('action' => $action, 'component' => buddypress()->rendez_vous->id, 'type' => 'updated_rendez_vous', 'primary_link' => $rendez_vous_url, 'user_id' => $rendez_vous->organizer, 'item_id' => $rendez_vous->id, 'secondary_item_id' => $rendez_vous->organizer)));
    if (!empty($activity_id)) {
        bp_activity_update_meta($activity_id, 'rendez_vous_title', $rendez_vous->title);
    }
    return true;
}
 /**
  * Perform actions about rendez-vous (insert/edit/delete/save prefs)
  *
  * @package Rendez Vous
  * @subpackage Groups
  *
  * @since Rendez Vous (1.1.0)
  *
  * @uses  Rendez_Vous_Group->is_rendez_vous()   Checks whether we're on a rendez-vous page of a group
  * @uses  rendez_vous()                         to get the plugin's instance
  * @uses  rendez_vous_handle_actions()          to insert/edit/delete/save prefs about a rendez-vous
  * @uses  bp_get_current_group_id()             to get the group id
  * @uses  Rendez_Vous_Group::group_get_option() to get the needed group metas.
  * @uses  groups_is_user_member()               to check the organizer is still a member of the group
  * @uses  delete_post_meta()                    to remove a rendez-vous from a group
  * @uses  rendez_vous_get_single_link()         to get the rendez-vous link
  * @uses  bp_core_add_message()                 to give a feedback to the user
  * @uses  do_action()                           call 'rendez_vous_groups_component_deactivated' or
  *                                                   'rendez_vous_groups_member_removed' to perform custom actions
  * @uses  bp_core_redirect()                    to safely redirect the user
  * @uses  bp_is_current_component()             to check for a BuddyPress component
  * @uses  bp_current_item()                     to make sure a group item is requested
  * @uses  bp_do_404()                           to set the WP Query to a 404.
  */
 public function group_handle_screens()
 {
     if ($this->is_rendez_vous()) {
         $rendez_vous = rendez_vous();
         $this->screen = rendez_vous_handle_actions();
         $rendez_vous->screens->screen = $this->screen;
         $group_id = bp_get_current_group_id();
         /**
          * Should we remove the rendez-vous from the group ?
          *
          * Although, this is already handled in Rendez_Vous_Group->group_rendez_vous_link()
          * an invited user can click on an email he received where the link is a group rendez-vous link.
          * @see rendez_vous_published_notification()
          *
          * Not checking if notifications are active, because there's also an edge case when the activity
          * has not been deleted yet and the user clicks on the activity link.
          */
         if ('single' == $this->screen && !empty($rendez_vous->item->id)) {
             $message = $action = false;
             // The group doesn't support rendez-vous anymore
             if (!self::group_get_option($group_id, '_rendez_vous_group_activate', false)) {
                 $message = __('The Group, the rendez-vous was attached to, does not support rendez-vous anymore', 'rendez-vous');
                 $action = 'rendez_vous_groups_component_deactivated';
                 // The organizer was removed or left the group
             } else {
                 if (!groups_is_user_member($rendez_vous->item->organizer, $group_id)) {
                     $message = sprintf(__('%s is not a member of the group, the rendez-vous was attached to, anymore. As a result, the rendez-vous was removed from the group.', 'rendez-vous'), bp_core_get_user_displayname($rendez_vous->item->organizer));
                     $action = 'rendez_vous_groups_member_removed';
                 }
             }
             // Bail if everything is ok.
             if (empty($message)) {
                 return;
             }
             // Delete the rendez-vous group id meta
             delete_post_meta($rendez_vous->item->id, '_rendez_vous_group_id');
             $redirect = rendez_vous_get_single_link($rendez_vous->item->id, $rendez_vous->item->organizer);
             bp_core_add_message($message, 'error');
             // fire an action to deal with group activities
             do_action($action, $rendez_vous->item->id, $rendez_vous->item);
             // Redirect to organizer's rendez-vous page
             bp_core_redirect($redirect);
         }
     } else {
         if (bp_is_current_component('groups') && bp_is_current_action($this->slug) && bp_current_item()) {
             bp_do_404();
             return;
         }
     }
 }
 /**
  * Set up the component entries in the WordPress Admin Bar.
  *
  * @package Rendez_Vous
  * @subpackage Component
  *
  * @since Rendez Vous (1.0.0)
  */
 public function setup_admin_bar($wp_admin_nav = array())
 {
     $bp = buddypress();
     // Menus for logged in user
     if (is_user_logged_in()) {
         // Setup the logged in user variables
         $user_domain = bp_loggedin_user_domain();
         $rendez_vous_link = trailingslashit($user_domain . $this->slug);
         // Add the "Example" sub menu
         $wp_admin_nav[0] = array('parent' => $bp->my_account_menu_id, 'id' => 'my-account-' . $this->id, 'title' => __('Rendez-vous', 'rendez-vous'), 'href' => trailingslashit($rendez_vous_link));
         // Personal
         $wp_admin_nav[$this->subnav_position['schedule']] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-schedule', 'title' => __('Schedule', 'rendez-vous'), 'href' => trailingslashit($rendez_vous_link . rendez_vous()->get_schedule_slug()));
         // Screen two
         $wp_admin_nav[$this->subnav_position['attend']] = array('parent' => 'my-account-' . $this->id, 'id' => 'my-account-' . $this->id . '-attend', 'title' => __('Attend', 'rendez-vous'), 'href' => trailingslashit($rendez_vous_link . rendez_vous()->get_attend_slug()));
         // Sort WP Admin Nav
         ksort($wp_admin_nav);
     }
     parent::setup_admin_bar($wp_admin_nav);
 }
/**
 * Output the submits for the Rendez Vous.
 *
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_single_the_submit($view = 'single')
{
    if (!bp_loggedin_user_id()) {
        return;
    }
    if ('edit' == $view) {
        $caption = 'draft' == rendez_vous()->item->status ? __('Publish Rendez-vous', 'rendez-vous') : __('Edit Rendez-vous', 'rendez-vous');
        if (current_user_can('delete_rendez_vous', rendez_vous()->item->id)) {
            $delete_link = rendez_vous_get_delete_link(rendez_vous()->item->id, rendez_vous()->item->organizer);
            if (!empty($delete_link)) {
                ?>

			<a href="<?php 
                echo esc_url($delete_link);
                ?>
" class="button delete-rendez-vous bp-secondary-action" id="delete-rendez-vous-<?php 
                echo rendez_vous()->item->id;
                ?>
"><?php 
                esc_html_e('Cancel Rendez-vous', 'rendez-vous');
                ?>
</a>

			<?php 
            }
        }
        if (current_user_can('edit_rendez_vous', rendez_vous()->item->id)) {
            ?>
			<input type="submit" name="_rendez_vous_edit[submit]" id="rendez-vous-edit-submit" value="<?php 
            echo esc_attr($caption);
            ?>
" class="bp-primary-action"/>
		<?php 
        }
    } else {
        if (current_user_can('subscribe_rendez_vous')) {
            if ('publish' != rendez_vous()->item->status && !in_array(bp_loggedin_user_id(), rendez_vous()->item->attendees) && bp_loggedin_user_id() != rendez_vous()->item->organizer) {
                return;
            }
            ?>
		<input type="submit" name="_rendez_vous_prefs[submit]" id="rendez-vous-prefs-submit" value="<?php 
            echo esc_attr(__('Save preferences', 'rendez-vous'));
            ?>
" class="bp-primary-action"/>
		<?php 
            if ('edit' != $view && current_user_can('edit_rendez_vous', rendez_vous()->item->id) && empty(rendez_vous()->item->def_date)) {
                ?>
			<a href="<?php 
                echo esc_url(rendez_vous_get_edit_link(rendez_vous()->item->id, rendez_vous()->item->organizer));
                ?>
#rendez-vous-set" class="button bp-secondary-action last"><?php 
                esc_html_e('Set the date', 'rendez-vous');
                ?>
</a>
			<div class="clear"/>
			<?php 
            }
        }
    }
}
 /**
  * Filter template part (not used)
  *
  * @package Rendez Vous
  * @subpackage Screens
  *
  * @since Rendez Vous (1.0.0)
  */
 public static function template_part($templates, $slug, $name)
 {
     if ($slug != 'members/single/plugins') {
         return $templates;
     }
     return array(rendez_vous()->screens->template . '.php');
 }
 /**
  * Enqueue script
  *
  * @package Rendez Vous
  * @subpackage Admin
  *
  * @since Rendez Vous (1.2.0)
  */
 public function enqueue_script()
 {
     $current_screen = get_current_screen();
     // Bail if we're not on the rendez-vous page
     if (empty($current_screen->id) || strpos($current_screen->id, 'rendez-vous') === false) {
         return;
     }
     $suffix = SCRIPT_DEBUG ? '' : '.min';
     $rdv = rendez_vous();
     wp_enqueue_style('rendez-vous-admin-style', $rdv->plugin_css . "rendezvous-admin{$suffix}.css", array('dashicons'), $rdv->version);
     wp_enqueue_script('rendez-vous-admin-backbone', $rdv->plugin_js . "rendez-vous-admin-backbone{$suffix}.js", array('wp-backbone'), $rdv->version, true);
     wp_localize_script('rendez-vous-admin-backbone', 'rendez_vous_admin_vars', array('nonce' => wp_create_nonce('rendez-vous-admin'), 'placeholder_default' => esc_html__('Name of your rendez-vous type.', 'rendez-vous'), 'placeholder_saving' => esc_html__('Saving the rendez-vous type...', 'rendez-vous'), 'placeholder_success' => esc_html__('Success: type saved.', 'rendez-vous'), 'placeholder_error' => esc_html__('Error: type not saved', 'rendez-vous'), 'alert_notdeleted' => esc_html__('Error: type not deleted', 'rendez-vous'), 'current_edited_type' => esc_html__('Editing: %s', 'rendez-vous')));
 }
/**
 * Send a screen notifications & email one when a rendez vous is updated
 *
 * Date set or report created
 *
 * @package Rendez Vous
 * @subpackage Notifications
 *
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_updated_notification($id = 0, $args = array(), $notify = 0)
{
    $bp = buddypress();
    $rdv = rendez_vous();
    if (empty($id) || empty($notify) || empty($rdv->item) || $id != $rdv->item->id || empty($args['message'])) {
        return;
    }
    $has_updated = !empty($rdv->item->date_fixed) || !empty($rdv->item->report_created) ? true : false;
    if (empty($has_updated) && empty($args['message'])) {
        return;
    }
    // Only allow 1 message per day.
    if (empty($has_updated) && 1 == get_transient('rendez_vous_last_message_' . $id)) {
        return;
    }
    $rendez_vous = $rdv->item;
    $attendees = $rendez_vous->attendees;
    if (empty($attendees)) {
        return;
    }
    // Remove the organizer
    if (in_array($rendez_vous->organizer, $attendees)) {
        $attendees = array_diff($attendees, array($rendez_vous->organizer));
    }
    $organizer_name = bp_core_get_user_displayname($rendez_vous->organizer);
    $rendez_vous_link = rendez_vous_get_single_link($id, $rendez_vous->organizer);
    $rendez_vous_content = stripslashes($rendez_vous->title);
    $rdv_updated_action = false;
    $component_action = false;
    if (!empty($rdv->item->date_fixed)) {
        if (is_numeric($rdv->item->date_fixed)) {
            $rendez_vous_content .= "\n\n" . sprintf(__('Date fixed to %1$s at %2$s', 'rendez-vous'), date_i18n(get_option('date_format'), $rdv->item->date_fixed), date_i18n(get_option('time_format'), $rdv->item->date_fixed));
            $rendez_vous_content .= "\n\n" . sprintf(__('Download the Calendar file %s', 'rendez-vous'), rendez_vous_get_ical_link($id, $rendez_vous->organizer));
        } else {
            $rendez_vous_content .= "\n\n" . sprintf(__('Date fixed to %s', 'rendez-vous'), esc_html($rdv->item->date_fixed));
        }
        $rdv_updated_action = __('fixed the date', 'rendez-vous');
        $component_action = 'rendez_vous_fixed';
    } else {
        if (!empty($rdv->item->report_created)) {
            $rdv_updated_action = __('created the report', 'rendez-vous');
            $component_action = 'rendez_vous_report';
        } else {
            if (!empty($args['message'])) {
                $rdv_updated_action = __('sent a message', 'rendez-vous');
                $component_action = 'rendez_vous_message';
                set_transient('rendez_vous_last_message_' . $id, 1, 24 * HOUR_IN_SECONDS);
            }
        }
    }
    $organizer_name = stripslashes($organizer_name);
    // Append the custom message, if any
    if (!empty($args['message'])) {
        $rendez_vous_content .= "\n\n" . $args['message'];
    }
    $rendez_vous_content = wp_kses($rendez_vous_content, array());
    $message = sprintf(__("%s %s for the rendez-vous: %s\n\nTo view details, log in and visit: %s\n\n---------------------\n", 'rendez-vous'), $organizer_name, $rdv_updated_action, $rendez_vous_content, esc_url($rendez_vous_link));
    $subject = bp_get_email_subject(array('text' => sprintf(__('%s updated a rendez-vous', 'rendez-vous'), $organizer_name)));
    // This way we'll have all needed users data at one and we will avoid spam users
    $users = bp_core_get_users(array('type' => 'alphabetical', 'include' => implode(',', $attendees)));
    foreach ($users['users'] as $attendee) {
        $mail_content = $message;
        if ('rendez_vous_message' != $component_action) {
            // Screen Notification
            bp_notifications_add_notification(array('user_id' => $attendee->ID, 'item_id' => $id, 'secondary_item_id' => $rendez_vous->organizer, 'component_name' => $bp->rendez_vous->id, 'component_action' => $component_action));
        }
        // Sending Emails
        if ('no' == get_user_meta($attendee->ID, 'notification_rendez_vous_attend', true)) {
            continue;
        }
        $user_settings = false;
        $user_fullname = !empty($attendee->fullname) ? $attendee->fullname : $attendee->display_name;
        $user_profile = bp_core_get_user_domain($attendee->ID, $attendee->user_nicename, $attendee->user_login);
        $user_email = $attendee->user_email;
        // Set up and send the message
        $to = $attendee->user_email;
        // Only show the disable notifications line if the settings component is enabled
        if (bp_is_active('settings')) {
            $user_settings = trailingslashit($user_profile . bp_get_settings_slug() . '/notifications');
            $mail_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'rendez-vous'), esc_url($user_settings));
        }
        /* Send the message */
        $to = apply_filters('rendez_vous_updated_notify_attendee', $to);
        $subject = apply_filters('rendez_vous_updated_notify_subject', $subject, $organizer_name);
        $mail_content = apply_filters('rendez_vous_updated_notify_message', $mail_content, $rendez_vous, $organizer_name, $rendez_vous_content, $rendez_vous_link, $user_settings);
        wp_mail($to, $subject, $mail_content);
    }
}
/**
 * Check whether types have been created.
 *
 * @package Rendez Vous
 * @subpackage Functions
 *
 * @since Rendez Vous (1.2.0)
 *
 * @param int|Rendez_Vous_Item $rendez_vous_id ID or object for the rendez-vous
 * @uses rendez_vous_get_terms()
 * @return bool Whether the taxonomy exists.
 */
function rendez_vous_has_types($rendez_vous = null)
{
    $rdv = rendez_vous();
    if (empty($rdv->types)) {
        $types = rendez_vous_get_terms(array('hide_empty' => false));
        $rdv->types = $types;
    } else {
        $types = $rdv->types;
    }
    if (empty($types)) {
        return false;
    }
    $retval = true;
    if (!empty($rendez_vous)) {
        if (!is_a($rendez_vous, 'Rendez_Vous_Item')) {
            $rendez_vous = rendez_vous_get_item($rendez_vous);
        }
        $retval = !empty($rendez_vous->type);
    }
    return $retval;
}
/**
 * Enqueues the Rendez Vous editor scripts, css, settings and strings
 *
 * Inspired by wp_enqueue_media()
 *
 * @package Rendez Vous
 * @subpackage Editor
 * @since Rendez Vous (1.0.0)
 */
function rendez_vous_enqueue_editor($args = array())
{
    // Enqueue me just once per page, please.
    if (did_action('rendez_vous_enqueue_editor')) {
        return;
    }
    $defaults = array('post' => null, 'user_id' => bp_loggedin_user_id(), 'callback' => null, 'group_id' => null);
    $args = wp_parse_args($args, $defaults);
    // We're going to pass the old thickbox media tabs to `media_upload_tabs`
    // to ensure plugins will work. We will then unset those tabs.
    $tabs = array('type' => '', 'type_url' => '', 'gallery' => '', 'library' => '');
    $tabs = apply_filters('media_upload_tabs', $tabs);
    unset($tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library']);
    $props = array('link' => bp_get_option('image_default_link_type'), 'align' => bp_get_option('image_default_align'), 'size' => bp_get_option('image_default_size'));
    $settings = array('tabs' => $tabs, 'tabUrl' => esc_url(add_query_arg(array('chromeless' => true), admin_url('admin-ajax.php'))), 'mimeTypes' => false, 'captions' => !apply_filters('disable_captions', ''), 'nonce' => array('sendToEditor' => wp_create_nonce('media-send-to-editor'), 'rendezvous' => wp_create_nonce('rendez-vous-editor')), 'post' => array('id' => 0), 'defaultProps' => $props, 'embedExts' => false);
    $post = $hier = null;
    $settings['user'] = intval($args['user_id']);
    $settings['group_id'] = intval($args['group_id']);
    if (!empty($args['callback'])) {
        $settings['callback'] = esc_url($args['callback']);
    }
    // Do we have member types ?
    $rendez_vous_member_types = array();
    $member_types = bp_get_member_types(array(), 'objects');
    if (!empty($member_types) && is_array($member_types)) {
        $rendez_vous_member_types['rdvMemberTypesAll'] = esc_html__('All member types', 'rendez-vous');
        foreach ($member_types as $type_key => $type) {
            $rendez_vous_member_types['rdvMemberTypes'][] = array('type' => $type_key, 'text' => esc_html($type->labels['singular_name']));
        }
    }
    if (!empty($rendez_vous_member_types)) {
        $settings = array_merge($settings, $rendez_vous_member_types);
    }
    $strings = array('url' => __('URL', 'rendez-vous'), 'addMedia' => __('Add Media', 'rendez-vous'), 'search' => __('Search', 'rendez-vous'), 'select' => __('Select', 'rendez-vous'), 'cancel' => __('Cancel', 'rendez-vous'), 'selected' => __('%d selected', 'rendez-vous'), 'dragInfo' => __('Drag and drop to reorder images.', 'rendez-vous'), 'uploadFilesTitle' => __('Upload Files', 'rendez-vous'), 'uploadImagesTitle' => __('Upload Images', 'rendez-vous'), 'mediaLibraryTitle' => __('Media Library', 'rendez-vous'), 'insertMediaTitle' => __('Insert Media', 'rendez-vous'), 'createNewGallery' => __('Create a new gallery', 'rendez-vous'), 'returnToLibrary' => __('&#8592; Return to library', 'rendez-vous'), 'allMediaItems' => __('All media items', 'rendez-vous'), 'noItemsFound' => __('No items found.', 'rendez-vous'), 'insertIntoPost' => $hier ? __('Insert into page', 'rendez-vous') : __('Insert into post', 'rendez-vous'), 'uploadedToThisPost' => $hier ? __('Uploaded to this page', 'rendez-vous') : __('Uploaded to this post', 'rendez-vous'), 'warnDelete' => __("You are about to permanently delete this item.\n  'Cancel' to stop, 'OK' to delete.", 'rendez-vous'), 'insertFromUrlTitle' => __('Insert from URL', 'rendez-vous'), 'setFeaturedImageTitle' => __('Set Featured Image', 'rendez-vous'), 'setFeaturedImage' => __('Set featured image', 'rendez-vous'), 'createGalleryTitle' => __('Create Gallery', 'rendez-vous'), 'editGalleryTitle' => __('Edit Gallery', 'rendez-vous'), 'cancelGalleryTitle' => __('&#8592; Cancel Gallery', 'rendez-vous'), 'insertGallery' => __('Insert gallery', 'rendez-vous'), 'updateGallery' => __('Update gallery', 'rendez-vous'), 'addToGallery' => __('Add to gallery', 'rendez-vous'), 'addToGalleryTitle' => __('Add to Gallery', 'rendez-vous'), 'reverseOrder' => __('Reverse order', 'rendez-vous'));
    $rendez_vous_strings = apply_filters('rendez_vous_view_strings', array('rdvMainTitle' => _x('Rendez-vous', 'RendezVous editor main title', 'rendez-vous'), 'whatTab' => _x('What?', 'RendezVous editor tab what name', 'rendez-vous'), 'whenTab' => _x('When?', 'RendezVous editor tab when name', 'rendez-vous'), 'whoTab' => _x('Who?', 'RendezVous editor tab who name', 'rendez-vous'), 'rdvInsertBtn' => __('Add to invites', 'rendez-vous'), 'rdvNextBtn' => __('Next', 'rendez-vous'), 'rdvPrevBtn' => __('Prev', 'rendez-vous'), 'rdvSrcPlaceHolder' => __('Search', 'rendez-vous'), 'invited' => __('%d to invite', 'rendez-vous'), 'removeInviteBtn' => __('Remove Invite', 'rendez-vous'), 'saveButton' => __('Save Rendez-Vous', 'rendez-vous')));
    // Use the filter at your own risks!
    $rendez_vous_fields = array('what' => apply_filters('rendez_vous_editor_core_fields', array(array('id' => 'title', 'order' => 0, 'type' => 'text', 'placeholder' => esc_html__('What is this about ?', 'rendez-vous'), 'label' => esc_html__('Title', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => 'required'), array('id' => 'venue', 'order' => 10, 'type' => 'text', 'placeholder' => esc_html__('Where ?', 'rendez-vous'), 'label' => esc_html__('Venue', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => ''), array('id' => 'description', 'order' => 20, 'type' => 'textarea', 'placeholder' => esc_html__('Some details about this rendez-vous ?', 'rendez-vous'), 'label' => esc_html__('Description', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => ''), array('id' => 'duration', 'order' => 30, 'type' => 'duree', 'placeholder' => '00:00', 'label' => esc_html__('Duration', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => 'required'), array('id' => 'privacy', 'order' => 40, 'type' => 'checkbox', 'placeholder' => esc_html__('Restrict to the selected members of the Who? tab', 'rendez-vous'), 'label' => esc_html__('Access', 'rendez-vous'), 'value' => '0', 'tab' => 'what', 'class' => ''), array('id' => 'utcoffset', 'order' => 50, 'type' => 'timezone', 'placeholder' => '', 'label' => '', 'value' => '', 'tab' => 'what', 'class' => ''))));
    // Do we have rendez-vous types ?
    if (rendez_vous_has_types()) {
        $rendez_vous_types_choices = array();
        $rendez_vous_types_placeholder = array();
        foreach (rendez_vous()->types as $rendez_vous_type) {
            $rendez_vous_types_choices[] = $rendez_vous_type->term_id;
            $rendez_vous_types_placeholder[] = $rendez_vous_type->name;
        }
        // Set the rendez-voys types field arg
        $rendez_vous_types_args = array('id' => 'type', 'order' => 15, 'type' => 'selectbox', 'placeholder' => $rendez_vous_types_placeholder, 'label' => esc_html__('Type', 'rendez-vous'), 'value' => '', 'tab' => 'what', 'class' => '', 'choices' => $rendez_vous_types_choices);
        // Merge with other rendez-vous fields
        $rendez_vous_fields['what'] = array_merge($rendez_vous_fields['what'], array($rendez_vous_types_args));
    }
    /**
     * Use 'rendez_vous_editor_extra_fields' to add custom fields, you should be able
     * to save them using the 'rendez_vous_after_saved' action.
     */
    $rendez_vous_extra_fields = apply_filters('rendez_vous_editor_extra_fields', array());
    $rendez_vous_add_fields = array();
    if (!empty($rendez_vous_extra_fields) && is_array($rendez_vous_extra_fields)) {
        // Some id are restricted to the plugin usage
        $restricted = array('title' => true, 'venue' => true, 'type' => true, 'description' => true, 'duration' => true, 'privacy' => true, 'utcoffset' => true);
        foreach ($rendez_vous_extra_fields as $rendez_vous_extra_field) {
            // The id is required and some ids are restricted.
            if (empty($rendez_vous_extra_field['id']) || !empty($restricted[$rendez_vous_extra_field['id']])) {
                continue;
            }
            // Make sure all needed arguments have default values
            $rendez_vous_add_fields[] = wp_parse_args($rendez_vous_extra_field, array('id' => '', 'order' => 60, 'type' => 'text', 'placeholder' => '', 'label' => '', 'value' => '', 'tab' => 'what', 'class' => ''));
        }
    }
    if (!empty($rendez_vous_add_fields)) {
        $rendez_vous_fields['what'] = array_merge($rendez_vous_fields['what'], $rendez_vous_add_fields);
    }
    // Sort by the order key
    $rendez_vous_fields['what'] = bp_sort_by_key($rendez_vous_fields['what'], 'order', 'num');
    $rendez_vous_date_strings = array('daynames' => array(esc_html__('Sunday', 'rendez-vous'), esc_html__('Monday', 'rendez-vous'), esc_html__('Tuesday', 'rendez-vous'), esc_html__('Wednesday', 'rendez-vous'), esc_html__('Thursday', 'rendez-vous'), esc_html__('Friday', 'rendez-vous'), esc_html__('Saturday', 'rendez-vous')), 'daynamesmin' => array(esc_html__('Su', 'rendez-vous'), esc_html__('Mo', 'rendez-vous'), esc_html__('Tu', 'rendez-vous'), esc_html__('We', 'rendez-vous'), esc_html__('Th', 'rendez-vous'), esc_html__('Fr', 'rendez-vous'), esc_html__('Sa', 'rendez-vous')), 'monthnames' => array(esc_html__('January', 'rendez-vous'), esc_html__('February', 'rendez-vous'), esc_html__('March', 'rendez-vous'), esc_html__('April', 'rendez-vous'), esc_html__('May', 'rendez-vous'), esc_html__('June', 'rendez-vous'), esc_html__('July', 'rendez-vous'), esc_html__('August', 'rendez-vous'), esc_html__('September', 'rendez-vous'), esc_html__('October', 'rendez-vous'), esc_html__('November', 'rendez-vous'), esc_html__('December', 'rendez-vous')), 'format' => _x('mm/dd/yy', 'rendez-vous date format', 'rendez-vous'), 'firstday' => intval(bp_get_option('start_of_week', 0)), 'alert' => esc_html__('You already selected this date', 'rendez-vous'));
    $settings = apply_filters('media_view_settings', $settings, $post);
    $strings = apply_filters('media_view_strings', $strings, $post);
    $strings = array_merge($strings, array('rendez_vous_strings' => $rendez_vous_strings, 'rendez_vous_fields' => $rendez_vous_fields, 'rendez_vous_date_strings' => $rendez_vous_date_strings));
    $strings['settings'] = $settings;
    wp_localize_script('rendez-vous-media-views', '_wpMediaViewsL10n', $strings);
    wp_enqueue_script('rendez-vous-modal');
    wp_enqueue_style('rendez-vous-modal-style');
    rendez_vous_plupload_settings();
    require_once ABSPATH . WPINC . '/media-template.php';
    add_action('admin_footer', 'wp_print_media_templates');
    add_action('wp_footer', 'wp_print_media_templates');
    do_action('rendez_vous_enqueue_editor');
}