当前位置: 首页>>代码示例>>PHP>>正文


PHP em_get_attributes函数代码示例

本文整理汇总了PHP中em_get_attributes函数的典型用法代码示例。如果您正苦于以下问题:PHP em_get_attributes函数的具体用法?PHP em_get_attributes怎么用?PHP em_get_attributes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了em_get_attributes函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: output

 /**
  * Will output a event in the format passed in $format by replacing placeholders within the format.
  * @param string $format
  * @param string $target
  * @return string
  */
 function output($format, $target = "html")
 {
     $event_string = $format;
     //Time place holder that doesn't show if empty.
     //TODO add filter here too
     preg_match_all('/#@?_\\{[^}]+\\}/', $format, $results);
     foreach ($results[0] as $result) {
         if (substr($result, 0, 3) == "#@_") {
             $date = 'end_date';
             $offset = 4;
         } else {
             $date = 'start_date';
             $offset = 3;
         }
         if ($date == 'end_date' && $this->event_end_date == $this->event_start_date) {
             $replace = __(apply_filters('em_event_output_placeholder', '', $this, $result, $target));
         } else {
             $replace = __(apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $this->{$date}), $this, $result, $target));
         }
         $event_string = str_replace($result, $replace, $event_string);
     }
     //This is for the custom attributes
     preg_match_all('/#_ATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $event_string, $results);
     $attributes = em_get_attributes();
     foreach ($results[0] as $resultKey => $result) {
         //Strip string of placeholder and just leave the reference
         $attRef = substr(substr($result, 0, strpos($result, '}')), 6);
         $attString = '';
         if (is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes)) {
             $attString = $this->event_attributes[$attRef];
         } elseif (!empty($results[3][$resultKey])) {
             //Check to see if we have a second set of braces;
             $attString = $results[3][$resultKey];
         } elseif (!empty($attributes['values'][$attRef][0])) {
             $attString = $attributes['values'][$attRef][0];
         }
         $attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
         $event_string = str_replace($result, $attString, $event_string);
     }
     //First let's do some conditional placeholder removals
     for ($i = 0; $i < EM_CONDITIONAL_RECURSIONS; $i++) {
         //you can add nested recursions by modifying this setting in your wp_options table
         preg_match_all('/\\{([a-zA-Z0-9_\\-]+)\\}(.+?)\\{\\/\\1\\}/s', $event_string, $conditionals);
         if (count($conditionals[0]) > 0) {
             //Check if the language we want exists, if not we take the first language there
             foreach ($conditionals[1] as $key => $condition) {
                 $show_condition = false;
                 if ($condition == 'has_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = $this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = !$this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_location') {
                     //does this event have a valid location?
                     $show_condition = empty($this->location_id) || !$this->get_location()->location_status;
                 } elseif ($condition == 'has_location') {
                     //does this event have a valid location?
                     $show_condition = !empty($this->location_id) && $this->get_location()->location_status;
                 } elseif ($condition == 'has_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() != '';
                 } elseif ($condition == 'no_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() == '';
                 } elseif ($condition == 'has_time') {
                     //are the booking times different and not an all-day event
                     $show_condition = $this->event_start_time != $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'no_time') {
                     //are the booking times exactly the same and it's not an all-day event.
                     $show_condition = $this->event_start_time == $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'all_day') {
                     //is it an all day event
                     $show_condition = !empty($this->event_all_day);
                 } elseif ($condition == 'logged_in') {
                     //user is logged in
                     $show_condition = is_user_logged_in();
                 } elseif ($condition == 'not_logged_in') {
                     //not logged in
                     $show_condition = !is_user_logged_in();
                 } elseif ($condition == 'has_spaces') {
                     //there are still empty spaces
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
                 } elseif ($condition == 'fully_booked') {
                     //event is fully booked
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
                 } elseif ($condition == 'bookings_open') {
                     //bookings are still open
                     $show_condition = $this->event_rsvp && $this->get_bookings()->is_open();
                 } elseif ($condition == 'bookings_closed') {
                     //bookings are still closed
                     $show_condition = $this->event_rsvp && !$this->get_bookings()->is_open();
                 } elseif ($condition == 'is_free' || $condition == 'is_free_now') {
                     //is it a free day event, if _now then free right now
//.........这里部分代码省略.........
开发者ID:javipaur,项目名称:TiendaVirtual,代码行数:101,代码来源:em-event.php

示例2: em_get_attributes

<?php

global $EM_Location;
$attributes = em_get_attributes(true);
//get Lattributes
$has_deprecated = false;
?>
<div id="location-attributes">
	<?php 
if (!empty($attributes['names']) && count($attributes['names']) > 0) {
    ?>
		<table class="form-table">
			<thead>
				<tr valign="top">
					<td><strong>Attribute Name</strong></td>
					<td><strong>Value</strong></td>
				</tr>
			</thead> 
			<tbody id="mtm_body">
				<?php 
    $count = 1;
    foreach ($attributes['names'] as $name) {
        ?>
					<tr valign="top" id="em_attribute_<?php 
        echo $count;
        ?>
">
						<td scope="row"><?php 
        echo $name;
        ?>
</td>
开发者ID:interfisch,项目名称:lm,代码行数:31,代码来源:attributes.php

示例3: get_post

 /**
  * Retrieve event, location and recurring information via POST
  * @return boolean
  */
 function get_post()
 {
     //Build Event Array
     do_action('em_event_get_post_pre', $this);
     $this->name = !empty($_POST['event_name']) ? stripslashes($_POST['event_name']) : '';
     $this->slug = !empty($_POST['event_slug']) ? $_POST['event_slug'] : '';
     $this->start_date = !empty($_POST['event_start_date']) ? $_POST['event_start_date'] : '';
     $this->end_date = !empty($_POST['event_end_date']) ? $_POST['event_end_date'] : $this->start_date;
     $this->rsvp = !empty($_POST['event_rsvp']) ? 1 : 0;
     //$this->spaces = ( !empty($_POST['event_spaces']) && is_numeric($_POST['event_spaces']) ) ? $_POST['event_spaces']:0;
     $this->notes = !empty($_POST['content']) ? stripslashes($_POST['content']) : '';
     //WP TinyMCE field
     //Sort out time
     //TODO make time handling less painful
     $match = array();
     if (!empty($_POST['event_start_time']) && preg_match('/^([01]\\d|2[0-3]):([0-5]\\d)(AM|PM)?$/', $_POST['event_start_time'], $match)) {
         if ($match[3] == 'PM' && $match[1] != 12) {
             $match[1] = 12 + $match[1];
         } elseif ($match[3] == 'AM' && $match[1] == 12) {
             $match[1] = '00';
         }
         $this->start_time = $match[1] . ":" . $match[2] . ":00";
     } else {
         $this->start_time = "00:00:00";
     }
     if (!empty($_POST['event_end_time']) && preg_match('/^([01]\\d|2[0-3]):([0-5]\\d)(AM|PM)?$/', $_POST['event_end_time'], $match)) {
         if ($match[3] == 'PM' && $match[1] != 12) {
             $match[1] = 12 + $match[1];
         } elseif ($match[3] == 'AM' && $match[1] == 12) {
             $match[1] = '00';
         }
         $this->end_time = $match[1] . ":" . $match[2] . ":00";
     } else {
         $this->end_time = $this->start_time;
     }
     //Start/End times should be available as timestamp
     $this->start = strtotime($this->start_date . " " . $this->start_time);
     $this->end = strtotime($this->end_date . " " . $this->end_time);
     //owner
     if (!empty($_REQUEST['event_owner']) && is_numeric($_REQUEST['event_owner'])) {
         $this->owner = current_user_can('edit_others_events') ? $_REQUEST['event_owner'] : get_current_user_id();
     }
     //categories
     if (!empty($_POST['event_categories']) && is_array($_POST['event_categories'])) {
         $this->categories = new EM_Categories($_POST['event_categories']);
     }
     //Attributes
     $event_attributes = array();
     $post = $_POST;
     $event_available_attributes = em_get_attributes();
     if (!empty($_POST['em_attributes']) && is_array($_POST['em_attributes'])) {
         foreach ($_POST['em_attributes'] as $att_key => $att_value) {
             if ((in_array($att_key, $event_available_attributes['names']) || array_key_exists($att_key, $this->attributes)) && trim($att_value) != '') {
                 $att_vals = count($event_available_attributes['values'][$att_key]);
                 if ($att_vals == 0 || $att_vals > 0 && in_array($att_value, $event_available_attributes['values'][$att_key])) {
                     $event_attributes[$att_key] = $att_value;
                 } elseif ($att_vals > 0) {
                     $event_attributes[$att_key] = $event_available_attributes['values'][$att_key][0];
                 }
             }
         }
     }
     $this->attributes = $event_attributes;
     //Recurrence data
     $this->recurrence_id = !empty($_POST['recurrence_id']) && is_numeric($_POST['recurrence_id']) ? $_POST['recurrence_id'] : 0;
     if (!empty($_POST['repeated_event'])) {
         $this->recurrence = 1;
         $this->freq = !empty($_POST['recurrence_freq']) && in_array($_POST['recurrence_freq'], array('daily', 'weekly', 'monthly')) ? $_POST['recurrence_freq'] : 'daily';
         if (!empty($_POST['recurrence_bydays']) && $this->freq == 'weekly' && self::array_is_numeric($_POST['recurrence_bydays'])) {
             $this->byday = implode(",", $_POST['recurrence_bydays']);
         } elseif (!empty($_POST['recurrence_byday']) && $this->freq == 'monthly') {
             $this->byday = $_POST['recurrence_byday'];
         }
         $this->interval = !empty($_POST['recurrence_interval']) ? $_POST['recurrence_interval'] : 1;
         $this->byweekno = !empty($_POST['recurrence_byweekno']) ? $_POST['recurrence_byweekno'] : '';
     }
     //Add location information, or just link to previous location, this is a requirement...
     if (!empty($_POST['location_id']) && is_numeric($_POST['location_id'])) {
         $this->location_id = $_POST['location_id'];
         $this->location = new EM_Location($_POST['location_id']);
     } else {
         $this->location = new EM_Location();
         $this->location->get_post();
     }
     if (!$this->get_bookings()->get_tickets()->get_post()) {
         $EM_Tickets = $this->get_bookings()->get_tickets();
         array_merge($this->errors, $this->get_bookings()->get_tickets()->errors);
     }
     return apply_filters('em_event_get_post', $this->validate(), $this);
 }
开发者ID:hypenotic,项目名称:slowfood,代码行数:94,代码来源:em-event.php

示例4: get_post_meta

 /**
  * Retrieve event post meta information via POST, which should be always be called when saving the event custom post via WP.
  * @param boolean $validate whether or not to run validation, default is true
  * @return mixed
  */
 function get_post_meta($validate = true)
 {
     //We are getting the values via POST or GET
     do_action('em_location_get_post_meta_pre', $this);
     $this->location_address = !empty($_POST['location_address']) ? wp_kses(stripslashes($_POST['location_address']), array()) : '';
     $this->location_town = !empty($_POST['location_town']) ? wp_kses(stripslashes($_POST['location_town']), array()) : '';
     $this->location_state = !empty($_POST['location_state']) ? wp_kses(stripslashes($_POST['location_state']), array()) : '';
     $this->location_postcode = !empty($_POST['location_postcode']) ? wp_kses(stripslashes($_POST['location_postcode']), array()) : '';
     $this->location_region = !empty($_POST['location_region']) ? wp_kses(stripslashes($_POST['location_region']), array()) : '';
     $this->location_country = !empty($_POST['location_country']) ? wp_kses(stripslashes($_POST['location_country']), array()) : '';
     $this->location_latitude = !empty($_POST['location_latitude']) && is_numeric($_POST['location_latitude']) ? $_POST['location_latitude'] : '';
     $this->location_longitude = !empty($_POST['location_longitude']) && is_numeric($_POST['location_longitude']) ? $_POST['location_longitude'] : '';
     //Sort out event attributes - note that custom post meta now also gets inserted here automatically (and is overwritten by these attributes)
     if (get_option('dbem_location_attributes_enabled')) {
         global $allowedtags;
         if (!is_array($this->location_attributes)) {
             $this->location_attributes = array();
         }
         $location_available_attributes = em_get_attributes(true);
         //lattributes only
         if (!empty($_POST['em_attributes']) && is_array($_POST['em_attributes'])) {
             foreach ($_POST['em_attributes'] as $att_key => $att_value) {
                 if (in_array($att_key, $location_available_attributes['names']) || array_key_exists($att_key, $this->location_attributes)) {
                     $att_vals = count($location_available_attributes['values'][$att_key]);
                     if ($att_vals == 0 || $att_vals > 0 && in_array($att_value, $location_available_attributes['values'][$att_key])) {
                         $this->location_attributes[$att_key] = stripslashes($att_value);
                     } elseif ($att_vals > 0) {
                         $this->location_attributes[$att_key] = stripslashes(wp_kses($location_available_attributes['values'][$att_key][0], $allowedtags));
                     }
                 }
             }
         }
     }
     $result = $validate ? $this->validate_meta() : true;
     //post returns null
     $this->compat_keys();
     return apply_filters('em_location_get_post_meta', $result, $this);
 }
开发者ID:javipaur,项目名称:TiendaVirtual,代码行数:43,代码来源:em-location.php

示例5: em_get_attributes

<?php

/*
 * This file is called by templates/forms/event-editor.php to display attribute fields on your event form on your website.
* You can override this file by copying it to /wp-content/themes/yourtheme/plugins/events-manager/forms/event/ and editing it there.
*/
global $EM_Event;
/* @var $EM_Event EM_Event */
$attributes = em_get_attributes();
$has_depreciated = false;
if (count($attributes['names']) > 0) {
    ?>
	<?php 
    foreach ($attributes['names'] as $name) {
        ?>
	<div class="event-attributes">
		<label for="em_attributes[<?php 
        echo $name;
        ?>
]"><?php 
        echo $name;
        ?>
</label>
		<?php 
        if (count($attributes['values'][$name]) > 1) {
            ?>
		<select name="em_attributes[<?php 
            echo $name;
            ?>
]">
			<?php 
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:31,代码来源:attributes-public.php

示例6: em_admin_event_page


//.........这里部分代码省略.........
															</td>
														</tr>
														<?php 
                $count++;
            }
            if (!empty($delete_temp_ticket)) {
                array_pop($EM_Tickets->tickets);
            }
            ?>
											</tbody>
										</table>
										<?php 
        }
        ?>
								</div>
							</div>
						</div>
					</div>
					<?php 
    }
    ?>
					
					<?php 
    if (get_option('dbem_attributes_enabled')) {
        ?>
						<div id="event-attributes" class="stuffbox">
							<h3>
								<?php 
        _e('Attributes', 'dbem');
        ?>
							</h3>
							<div class="inside">
								<?php 
        $attributes = em_get_attributes();
        $has_depreciated = false;
        ?>
								<div class="wrap">
									<?php 
        if (!empty($attributes['names']) && count($attributes['names']) > 0) {
            ?>
										<table class="form-table">
											<thead>
												<tr valign="top">
													<td><strong>Attribute Name</strong></td>
													<td><strong>Value</strong></td>
												</tr>
											</thead> 
											<tbody id="mtm_body">
												<?php 
            $count = 1;
            foreach ($attributes['names'] as $name) {
                ?>
													<tr valign="top" id="em_attribute_<?php 
                echo $count;
                ?>
">
														<td scope="row"><?php 
                echo $name;
                ?>
</td>
														<td>
															<?php 
                if (count($attributes['values'][$name]) > 0) {
                    ?>
															<select name="em_attributes[<?php 
                    echo $name;
开发者ID:hypenotic,项目名称:slowfood,代码行数:67,代码来源:em-event.php

示例7: get_post_meta

 /**
  * Retrieve event post meta information via POST, which should be always be called when saving the event custom post via WP.
  * @param boolean $validate whether or not to run validation, default is true
  * @return boolean
  */
 function get_post_meta($validate = true)
 {
     //Grab POST data
     $this->event_start_date = !empty($_POST['event_start_date']) ? $_POST['event_start_date'] : '';
     $this->event_end_date = !empty($_POST['event_end_date']) ? $_POST['event_end_date'] : $this->event_start_date;
     //check if this is recurring or not
     if (!empty($_POST['recurring'])) {
         $this->recurrence = 1;
         $this->post_type = 'event-recurring';
     }
     //Get Location info
     if (!get_option('dbem_locations_enabled') || !empty($_POST['no_location']) && !get_option('dbem_require_location', true) || empty($_POST['location_id']) && !get_option('dbem_require_location', true) && get_option('dbem_use_select_for_locations')) {
         $this->location_id = 0;
     } elseif (!empty($_POST['location_id']) && is_numeric($_POST['location_id'])) {
         $this->location_id = $_POST['location_id'];
     } else {
         //we're adding a new location, so create an empty location and populate
         $this->location_id = null;
         $this->get_location()->get_post(false);
         $this->get_location()->post_content = '';
         //reset post content, as it'll grab the event description otherwise
     }
     //Sort out time
     $this->event_all_day = !empty($_POST['event_all_day']) ? 1 : 0;
     if (!$this->event_all_day) {
         $match = array();
         foreach (array('event_start_time', 'event_end_time', 'event_rsvp_time') as $timeName) {
             if (!empty($_POST[$timeName]) && preg_match('/^([01]\\d|2[0-3]):([0-5]\\d) ?(AM|PM)?$/', $_POST[$timeName], $match)) {
                 if (!empty($match[3]) && $match[3] == 'PM' && $match[1] != 12) {
                     $match[1] = 12 + $match[1];
                 } elseif (!empty($match[3]) && $match[3] == 'AM' && $match[1] == 12) {
                     $match[1] = '00';
                 }
                 $this->{$timeName} = $match[1] . ":" . $match[2] . ":00";
             } else {
                 $this->{$timeName} = $timeName == 'event_start_time' ? "00:00:00" : $this->event_start_time;
             }
         }
     } else {
         $this->event_start_time = $this->event_end_time = '00:00:00';
     }
     //Start/End times should be available as timestamp
     $this->start = strtotime($this->event_start_date . " " . $this->event_start_time);
     $this->end = strtotime($this->event_end_date . " " . $this->event_end_time);
     //Bookings
     if (!empty($_POST['event_rsvp']) && $_POST['event_rsvp']) {
         $this->get_bookings()->get_tickets()->get_post();
         $this->event_rsvp = 1;
         //RSVP cuttoff TIME is set up above where start/end times are as well
         $this->event_rsvp_date = isset($_POST['event_rsvp_date']) ? $_POST['event_rsvp_date'] : $this->event_start_date;
         if (empty($this->event_rsvp_date)) {
             $this->event_rsvp_time = '00:00:00';
         }
         $this->event_spaces = isset($_POST['event_spaces']) ? absint($_POST['event_spaces']) : 0;
     } else {
         $this->event_rsvp = 0;
         $this->event_rsvp_time = '00:00:00';
     }
     //Sort out event attributes - note that custom post meta now also gets inserted here automatically (and is overwritten by these attributes)
     if (get_option('dbem_attributes_enabled')) {
         global $allowedtags;
         if (!is_array($this->event_attributes)) {
             $this->event_attributes = array();
         }
         $event_available_attributes = em_get_attributes();
         if (!empty($_POST['em_attributes']) && is_array($_POST['em_attributes'])) {
             foreach ($_POST['em_attributes'] as $att_key => $att_value) {
                 if (in_array($att_key, $event_available_attributes['names']) || array_key_exists($att_key, $this->event_attributes)) {
                     if (!empty($att_value)) {
                         $att_vals = count($event_available_attributes['values'][$att_key]);
                         if ($att_vals == 0 || $att_vals > 0 && in_array($att_value, $event_available_attributes['values'][$att_key])) {
                             $this->event_attributes[$att_key] = stripslashes($att_value);
                         } elseif ($att_vals > 0) {
                             $this->event_attributes[$att_key] = stripslashes(wp_kses($event_available_attributes['values'][$att_key][0], $allowedtags));
                         }
                     } else {
                         $this->event_attributes[$att_key] = '';
                     }
                 }
             }
         }
     }
     //Set Blog ID
     if (is_multisite()) {
         $this->blog_id = get_current_blog_id();
     }
     //group id
     $this->group_id = !empty($_POST['group_id']) && is_numeric($_POST['group_id']) ? $_POST['group_id'] : 0;
     //Recurrence data
     if ($this->is_recurring()) {
         $this->recurrence = 1;
         //just in case
         $this->recurrence_freq = !empty($_POST['recurrence_freq']) && in_array($_POST['recurrence_freq'], array('daily', 'weekly', 'monthly', 'yearly')) ? $_POST['recurrence_freq'] : 'daily';
         if (!empty($_POST['recurrence_bydays']) && $this->recurrence_freq == 'weekly' && self::array_is_numeric($_POST['recurrence_bydays'])) {
             $this->recurrence_byday = implode(",", $_POST['recurrence_bydays']);
//.........这里部分代码省略.........
开发者ID:rajankz,项目名称:webspace,代码行数:101,代码来源:em-event.php

示例8: output

    /**
     * Will output a event in the format passed in $format by replacing placeholders within the format.
     * @param string $format
     * @param string $target
     * @return string
     */
    function output($format, $target = "html")
    {
        $event_string = $format;
        //Time place holder that doesn't show if empty.
        //TODO add filter here too
        preg_match_all('/#@?_\\{[^}]+\\}/', $format, $results);
        foreach ($results[0] as $result) {
            if (substr($result, 0, 3) == "#@_") {
                $date = 'end_date';
                $offset = 4;
            } else {
                $date = 'start_date';
                $offset = 3;
            }
            if ($date == 'end_date' && $this->event_end_date == $this->event_start_date) {
                $replace = __(apply_filters('em_event_output_placeholder', '', $this, $result, $target));
            } else {
                $replace = __(apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $this->{$date}), $this, $result, $target));
            }
            $event_string = str_replace($result, $replace, $event_string);
        }
        //This is for the custom attributes
        preg_match_all('/#_ATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $format, $results);
        $attributes = em_get_attributes();
        foreach ($results[0] as $resultKey => $result) {
            //Strip string of placeholder and just leave the reference
            $attRef = substr(substr($result, 0, strpos($result, '}')), 6);
            $attString = '';
            if (is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes)) {
                $attString = $this->event_attributes[$attRef];
            } elseif (!empty($results[3][$resultKey])) {
                //Check to see if we have a second set of braces;
                $attString = $results[3][$resultKey];
            } elseif (!empty($attributes['values'][$attRef][0])) {
                $attString = $attributes['values'][$attRef][0];
            }
            $attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
            $event_string = str_replace($result, $attString, $event_string);
        }
        //First let's do some conditional placeholder removals
        for ($i = 0; $i < get_option('dbem_conditional_recursions', 1); $i++) {
            //you can add nested recursions by modifying this setting in your wp_options table
            preg_match_all('/\\{([a-zA-Z0-9_]+)\\}(.+?)\\{\\/\\1\\}/s', $event_string, $conditionals);
            if (count($conditionals[0]) > 0) {
                //Check if the language we want exists, if not we take the first language there
                foreach ($conditionals[1] as $key => $condition) {
                    $show_condition = false;
                    if ($condition == 'has_bookings') {
                        //check if there's a booking, if not, remove this section of code.
                        $show_condition = $this->event_rsvp && get_option('dbem_rsvp_enabled');
                    } elseif ($condition == 'no_bookings') {
                        //check if there's a booking, if not, remove this section of code.
                        $show_condition = !$this->event_rsvp && get_option('dbem_rsvp_enabled');
                    } elseif ($condition == 'no_location') {
                        //does this event have a valid location?
                        $show_condition = empty($this->location_id) || !$this->get_location()->location_status;
                    } elseif ($condition == 'has_location') {
                        //does this event have a valid location?
                        $show_condition = !empty($this->location_id) && $this->get_location()->location_status;
                    } elseif ($condition == 'has_image') {
                        //does this event have an image?
                        $show_condition = $this->get_image_url() != '';
                    } elseif ($condition == 'no_image') {
                        //does this event have an image?
                        $show_condition = $this->get_image_url() == '';
                    } elseif ($condition == 'has_time') {
                        //are the booking times different and not an all-day event
                        $show_condition = $this->event_start_time != $this->event_end_time && !$this->event_all_day;
                    } elseif ($condition == 'no_time') {
                        //are the booking times exactly the same and it's not an all-day event.
                        $show_condition = $this->event_start_time == $this->event_end_time && !$this->event_all_day;
                    } elseif ($condition == 'all_day') {
                        //is it an all day event
                        $show_condition = !empty($this->event_all_day);
                    } elseif ($condition == 'logged_in') {
                        //user is logged in
                        $show_condition = is_user_logged_in();
                    } elseif ($condition == 'not_logged_in') {
                        //not logged in
                        $show_condition = !is_user_logged_in();
                    } elseif ($condition == 'has_spaces') {
                        //is it an all day event
                        $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
                    } elseif ($condition == 'fully_booked') {
                        //is it an all day event
                        $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
                    } elseif ($condition == 'is_long') {
                        //is it an all day event
                        $show_condition = $this->event_start_date != $this->event_end_date;
                    } elseif ($condition == 'not_long') {
                        //is it an all day event
                        $show_condition = $this->event_start_date == $this->event_end_date;
                    } elseif ($condition == 'is_past') {
                        //if event is past
//.........这里部分代码省略.........
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:em-event.php

示例9: get_post_meta

 /**
  * Retrieve event post meta information via POST, which should be always be called when saving the event custom post via WP.
  * @param boolean $validate whether or not to run validation, default is true
  * @return mixed
  */
 function get_post_meta($validate = true)
 {
     //We are getting the values via POST or GET
     do_action('em_location_get_post_meta_pre', $this);
     $this->location_address = !empty($_POST['location_address']) ? wp_kses(wp_unslash($_POST['location_address']), array()) : '';
     $this->location_town = !empty($_POST['location_town']) ? wp_kses(wp_unslash($_POST['location_town']), array()) : '';
     $this->location_state = !empty($_POST['location_state']) ? wp_kses(wp_unslash($_POST['location_state']), array()) : '';
     $this->location_postcode = !empty($_POST['location_postcode']) ? wp_kses(wp_unslash($_POST['location_postcode']), array()) : '';
     $this->location_region = !empty($_POST['location_region']) ? wp_kses(wp_unslash($_POST['location_region']), array()) : '';
     $this->location_country = !empty($_POST['location_country']) ? wp_kses(wp_unslash($_POST['location_country']), array()) : '';
     $this->location_latitude = !empty($_POST['location_latitude']) && is_numeric($_POST['location_latitude']) ? $_POST['location_latitude'] : '';
     $this->location_longitude = !empty($_POST['location_longitude']) && is_numeric($_POST['location_longitude']) ? $_POST['location_longitude'] : '';
     //Sort out event attributes - note that custom post meta now also gets inserted here automatically (and is overwritten by these attributes)
     if (get_option('dbem_location_attributes_enabled')) {
         global $allowedtags;
         if (!is_array($this->location_attributes)) {
             $this->location_attributes = array();
         }
         $location_available_attributes = em_get_attributes(true);
         //lattributes only
         if (!empty($_POST['em_attributes']) && is_array($_POST['em_attributes'])) {
             foreach ($_POST['em_attributes'] as $att_key => $att_value) {
                 if (in_array($att_key, $location_available_attributes['names']) || array_key_exists($att_key, $this->location_attributes)) {
                     $att_vals = count($location_available_attributes['values'][$att_key]);
                     if ($att_vals == 0 || $att_vals > 0 && in_array($att_value, $location_available_attributes['values'][$att_key])) {
                         $this->location_attributes[$att_key] = wp_unslash($att_value);
                     } elseif ($att_vals > 0) {
                         $this->location_attributes[$att_key] = wp_unslash(wp_kses($location_available_attributes['values'][$att_key][0], $allowedtags));
                     }
                 }
             }
         }
     }
     //the line below should be deleted one day and we move validation out of this function, when that happens check otherfunctions like EM_ML_IO::get_post_meta function which force validation again
     $result = $validate ? $this->validate_meta() : true;
     //post returns null
     $this->compat_keys();
     return apply_filters('em_location_get_post_meta', $result, $this, $validate);
     //if making a hook, assume that eventually $validate won't be passed on
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:45,代码来源:em-location.php


注:本文中的em_get_attributes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。