Пример #1
0
 function column($column)
 {
     parent::column($column);
     global $post;
     switch (str_replace('conferencer_speaker_', '', $column)) {
         case 'title':
             echo $post->title;
             break;
         case 'company':
             if ($post->company) {
                 echo "<a href='post.php?action=edit&post={$post->company}'>" . get_the_title($post->company) . "</a>";
             }
             break;
         case 'sessions':
             $links = array();
             foreach (Conferencer::get_sessions($post->ID) as $session) {
                 $links[] = "<a href='post.php?action=edit&post={$session->ID}'>" . get_the_title($session->ID) . "</a>";
             }
             echo implode(', ', $links);
             break;
     }
 }
Пример #2
0
 function detail_trash($post_id)
 {
     parent::detail_trash($post_id);
     $post_type = get_post_type($post_id);
     $detached = array();
     foreach (Conferencer::get_sessions($post_id) as $session) {
         Conferencer::add_meta($session);
         if (in_array($post_type, array('speaker', 'sponsor'))) {
             $type = $post_type . 's';
             if (in_array($post_id, $session->{$type})) {
                 update_post_meta($session->ID, "_conferencer_{$type}", array_diff($session->{$type}, array($post_id)));
                 $detached[] = $session;
             }
         } else {
             if ($session->{$post_type} == $post_id) {
                 update_post_meta($session->ID, "_conferencer_{$post_type}", false);
                 $detached[] = $session;
             }
         }
     }
     foreach ($detached as $session) {
         Conferencer::add_admin_notice("Removed " . get_the_title($post_id) . " from <a href='post.php?post={$session->ID}&action=edit' target='_blank'>{$session->post_title}</a>.");
     }
 }
 function column($column)
 {
     global $post;
     Conferencer::add_meta($post);
     switch (str_replace('conferencer_' . $this->slug . '_', '', $column)) {
         case 'session_count':
             echo $post->non_session ? "not allowed" : count(Conferencer::get_sessions($post->ID));
             break;
     }
 }
Пример #4
0
        function content()
        {
            extract($this->options);
            $errors = array();
            if (empty($post_ids)) {
                $errors[] = "No posts ID provided";
            }
            foreach ($post_ids as $post_id) {
                $post = get_post($post_id);
                if (!$post) {
                    $errors[] = "{$post_id} is not a valid post ID";
                } else {
                    if (!in_array(get_post_type($post), self::$post_types_with_sessions)) {
                        $errors[] = "<a href='" . get_permalink($post->ID) . "'>{$post->post_title}</a> is not the correct type of post";
                    }
                }
            }
            if (count($errors)) {
                return "[Shortcode errors (sessions): " . implode(', ', $errors) . "]";
            }
            $sessions = Conferencer::get_sessions($post_ids);
            ob_start();
            if (!empty($sessions) || !empty($no_sessions_message)) {
                ?>

			<div class="session-list">
				<<?php 
                echo $title_tag;
                ?>
>
					<?php 
                if (!$title) {
                    ?>
						Sessions for
						<?php 
                    $titles = array();
                    foreach ($post_ids as $post_id) {
                        $html = get_the_title($post_id);
                        if ($link_post) {
                            $html = "<a href='" . get_permalink($post_id) . "'>{$html}</a>";
                        }
                        $titles[] = $html;
                    }
                    echo implode_with_serial_and($titles);
                    ?>
					<?php 
                } else {
                    echo $title;
                }
                ?>
				</<?php 
                echo $title_tag;
                ?>
>

				<?php 
                if (empty($sessions)) {
                    ?>
					<p><?php 
                    echo $no_sessions_message;
                    ?>
</p>
				<?php 
                } else {
                    ?>
					<ul>
						<?php 
                    foreach ($sessions as $session) {
                        ?>
							<li>
								<?php 
                        $html = $session->post_title;
                        if ($link_sessions) {
                            $html = "<a href='" . get_permalink($session->ID) . "'>{$html}</a>";
                        }
                        echo $html;
                        ?>
							</li>
						<?php 
                    }
                    ?>
					</ul>
				<?php 
                }
                ?>
			</div>

		<?php 
            }
            return ob_get_clean();
        }