示例#1
0
文件: functions.php 项目: vrxm/htdocs
/**
 * Displays the HTML used in admin area to display the manually
 * selected mixed posts.
 * 
 * @param int/obj $post
 */
function fa_slide_panel($post, $slider_id)
{
    if (is_numeric($post)) {
        $post = get_post($post);
    }
    if (!$post) {
        return;
    }
    $options = fa_get_slide_options($post->ID);
    $slide_title = $post->post_title;
    $slide_content = $post->post_content;
    if (!empty($options['title']) && $post->post_title != $options['title']) {
        $slide_title = $options['title'];
        $post_title = $post->post_title;
    }
    if (!empty($options['content'])) {
        $slide_content = $options['content'];
    }
    ?>
<div class="fa-slide <?php 
    echo esc_attr($post->post_status);
    ?>
" id="post-<?php 
    echo $post->ID;
    ?>
" data-post_id="<?php 
    echo $post->ID;
    ?>
">
	<a href="<?php 
    fa_iframe_admin_page_url('fa-post-slide-edit', array('post_id' => $post->ID, 'slider_id' => $slider_id));
    ?>
" id="fa-slide-edit-<?php 
    echo $post->ID;
    ?>
" class="fapro-modal-trigger fa-slide-edit" data-target="fapro-modal" data-slide_id="<?php 
    echo $post->ID;
    ?>
" data-slider_id="<?php 
    echo $slider_id;
    ?>
" data-type="mixed"><i class="dashicons dashicons-admin-generic"></i></a>
	<a href="#" id="fa-slide-remove-<?php 
    echo $post->ID;
    ?>
" class="fa-slide-remove"><i class="dashicons dashicons-dismiss"></i></a>
	<div class="slide-inside">
		<h3>
			<a href="<?php 
    echo get_edit_post_link($post->ID, '');
    ?>
" target="_blank"><?php 
    echo wp_trim_words($slide_title, 6, '...');
    ?>
</a>
		</h3>
		<div class="slide-details">
			<ul>
				<?php 
    if (isset($post_title)) {
        ?>
				<li><strong><?php 
        _e('Post title', 'fapro');
        ?>
:</strong> <?php 
        echo wp_trim_words($post_title, 3, '...');
        ?>
</li>
				<?php 
    }
    ?>
				<li><strong><?php 
    _e('Post status', 'fapro');
    ?>
:</strong> <?php 
    fa_output_post_status($post->post_status);
    ?>
</li>
				<li><strong><?php 
    _e('Post date', 'fapro');
    ?>
:</strong> <?php 
    fa_output_post_date($post->post_date);
    ?>
</li>
				<li><strong><?php 
    _e('Post type', 'fapro');
    ?>
:</strong> <?php 
    fa_output_post_type($post->post_type);
    ?>
</li>
				<li>
					<strong><?php 
    _e('Image', 'fapro');
    ?>
:</strong>
					<?php 
    require_once fa_get_path('includes/templating.php');
    $image_id = get_the_fa_image_id($post->ID);
    if (!$image_id) {
        if (!empty($options['temp_image_url'])) {
            $image_url = $options['temp_image_url'];
        }
    } else {
        $image = wp_get_attachment_image_src($image_id, 'thumbnail');
        if ($image) {
            $image_url = $image[0];
        }
    }
    if (isset($image_url) && $image_url) {
        ?>
					<img src="<?php 
        echo $image_url;
        ?>
" />
					<?php 
    } else {
        ?>
					<?php 
        _e('none', 'fapro');
        ?>
	
					<?php 
    }
    ?>
				</li>
				<?php 
    fa_post_status_message($post, '<li class="warning">', '</li>');
    ?>
			
			</ul>
			<input type="hidden" name="slides[posts][]" value="<?php 
    echo $post->ID;
    ?>
" />
		</div>	
	</div>		
</div>
<?php 
}
示例#2
0
    function single_row($post, $level = 0)
    {
        global $mode;
        static $alternate;
        $global_post = get_post();
        $GLOBALS['post'] = $post;
        setup_postdata($post);
        $edit_link = get_edit_post_link($post->ID);
        $title = _draft_or_post_title();
        $post_type_object = get_post_type_object($post->post_type);
        $can_edit_post = current_user_can('edit_post', $post->ID);
        $alternate = 'alternate' == $alternate ? '' : 'alternate';
        $classes = $alternate . ' iedit author-' . (get_current_user_id() == $post->post_author ? 'self' : 'other');
        $lock_holder = wp_check_post_lock($post->ID);
        if ($lock_holder) {
            $classes .= ' wp-locked';
            $lock_holder = get_userdata($lock_holder);
        }
        if ($post->post_parent) {
            $count = count(get_post_ancestors($post->ID));
            $classes .= ' level-' . $count;
        } else {
            $classes .= ' level-0';
        }
        ?>
		<tr id="post-<?php 
        echo $post->ID;
        ?>
" class="<?php 
        echo implode(' ', get_post_class($classes, $post->ID));
        ?>
">
	<?php 
        list($columns, $hidden) = $this->get_column_info();
        foreach ($columns as $column_name => $column_display_name) {
            $class = "class=\"{$column_name} column-{$column_name}\"";
            $style = '';
            if (in_array($column_name, $hidden)) {
                $style = ' style="display:none;"';
            }
            $attributes = "{$class}{$style}";
            switch ($column_name) {
                case 'cb':
                    ?>
			<th scope="row" class="check-column">
				<label class="screen-reader-text" for="cb-select-<?php 
                    the_ID();
                    ?>
"><?php 
                    printf(__('Select %s'), $title);
                    ?>
</label>
				<input id="cb-select-<?php 
                    the_ID();
                    ?>
" type="checkbox" name="select_posts[]" value="<?php 
                    the_ID();
                    ?>
" data-post_id="<?php 
                    the_ID();
                    ?>
" data-post_type="<?php 
                    echo $post->post_type;
                    ?>
" />
				<?php 
                    if ($can_edit_post) {
                        ?>
				<div class="locked-indicator"></div>
				<?php 
                    }
                    ?>
			</th>
			<?php 
                    break;
                case 'title':
                    $attributes = 'class="post-title page-title column-title"' . $style;
                    if ($this->hierarchical_display) {
                        if (0 == $level && (int) $post->post_parent > 0) {
                            //sent level 0 by accident, by default, or because we don't know the actual level
                            $find_main_page = (int) $post->post_parent;
                            while ($find_main_page > 0) {
                                $parent = get_post($find_main_page);
                                if (is_null($parent)) {
                                    break;
                                }
                                $level++;
                                $find_main_page = (int) $parent->post_parent;
                                if (!isset($parent_name)) {
                                    /** This filter is documented in wp-includes/post-template.php */
                                    $parent_name = apply_filters('the_title', $parent->post_title, $parent->ID);
                                }
                            }
                        }
                    }
                    $pad = str_repeat('&#8212; ', $level);
                    echo "<td {$attributes}><strong>";
                    // post format filtering
                    if ($format = get_post_format($post->ID)) {
                        $label = get_post_format_string($format);
                        echo '<a href="' . fa_iframe_admin_page_url('fa-mixed-content-modal', array('post_format' => $format, 'post_type' => $post->post_type), false) . '" class="post-state-format post-format-icon post-format-' . $format . '" title="' . $label . '">' . $label . ":</a> ";
                    }
                    // Post title with edit link
                    if ($can_edit_post && $post->post_status != 'trash') {
                        echo '<a target="_blank" class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)) . '">' . $pad . '<span id="fa-name-' . $post->ID . '">' . $title . '</span></a>';
                    } else {
                        echo $pad . '<span id="fa-name-' . $post->ID . '">' . $title . '</span>';
                    }
                    _post_states($post);
                    if (isset($parent_name)) {
                        echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html($parent_name);
                    }
                    echo "</strong>\n";
                    if ($can_edit_post && $post->post_status != 'trash') {
                        if ($lock_holder) {
                            $locked_avatar = get_avatar($lock_holder->ID, 18);
                            $locked_text = esc_html(sprintf(__('%s is currently editing'), $lock_holder->display_name));
                        } else {
                            $locked_avatar = $locked_text = '';
                        }
                        echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
                    }
                    if (!$this->hierarchical_display && 'excerpt' == $mode && current_user_can('read_post', $post->ID)) {
                        the_excerpt();
                    }
                    // actions
                    $actions = array();
                    // edit link
                    if ($can_edit_post && 'trash' != $post->post_status) {
                        $actions['edit'] = '<a target="_blank" href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
                    }
                    // View/Preview links
                    if ($post_type_object->public) {
                        if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
                            if ($can_edit_post) {
                                /** This filter is documented in wp-admin/includes/meta-boxes.php */
                                $actions['view'] = '<a target="_blank" href="' . esc_url(apply_filters('preview_post_link', set_url_scheme(add_query_arg('preview', 'true', get_permalink($post->ID))))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
                            }
                        } elseif ('trash' != $post->post_status) {
                            $actions['view'] = '<a target="_blank" href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
                        }
                    }
                    if (is_post_type_hierarchical($post->post_type)) {
                        /**
                         * Filter the array of row action links on the Pages list table.
                         *
                         * The filter is evaluated only for hierarchical post types.
                         *
                         * @since 2.8.0
                         *
                         * @param array   $actions An array of row action links. Defaults are
                         *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
                         *                         'Delete Permanently', 'Preview', and 'View'.
                         * @param WP_Post $post    The post object.
                         */
                        $actions = apply_filters('fa_page_row_actions', $actions, $post);
                    } else {
                        /**
                         * Filter the array of row action links on the Posts list table.
                         *
                         * The filter is evaluated only for non-hierarchical post types.
                         *
                         * @since 2.8.0
                         *
                         * @param array   $actions An array of row action links. Defaults are
                         *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
                         *                         'Delete Permanently', 'Preview', and 'View'.
                         * @param WP_Post $post    The post object.
                         */
                        $actions = apply_filters('fa_post_row_actions', $actions, $post);
                    }
                    echo $this->row_actions($actions);
                    get_inline_data($post);
                    echo '</td>';
                    break;
                case 'slide_title':
                    $fa_slide = fa_get_slide_options($post->ID);
                    if (isset($fa_slide['title'])) {
                        echo '<td ' . $attributes . '>';
                        if ($post->post_title != $fa_slide['title']) {
                            echo '<strong>' . $fa_slide['title'] . '</strong>';
                        } else {
                            echo '<i>' . $fa_slide['title'] . '</i>';
                        }
                        echo '</td>';
                    }
                    break;
                case 'date':
                    if ('0000-00-00 00:00:00' == $post->post_date) {
                        $t_time = $h_time = __('Unpublished');
                        $time_diff = 0;
                    } else {
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $post->post_date;
                        $time = get_post_time('G', true, $post);
                        $time_diff = time() - $time;
                        if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
                            $h_time = sprintf(__('%s ago'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                    }
                    echo '<td ' . $attributes . '>';
                    if ('excerpt' == $mode) {
                        /**
                         * Filter the published time of the post.
                         *
                         * If $mode equals 'excerpt', the published time and date are both displayed.
                         * If $mode equals 'list' (default), the publish date is displayed, with the
                         * time and date together available as an abbreviation definition.
                         *
                         * @since 2.5.1
                         *
                         * @param array   $t_time      The published time.
                         * @param WP_Post $post        Post object.
                         * @param string  $column_name The column name.
                         * @param string  $mode        The list display mode ('excerpt' or 'list').
                         */
                        echo apply_filters('fa_post_date_column_time', $t_time, $post, $column_name, $mode);
                    } else {
                        /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
                        echo '<abbr title="' . $t_time . '">' . apply_filters('fa_post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
                    }
                    echo '<br />';
                    if ('publish' == $post->post_status) {
                        _e('Published');
                    } elseif ('future' == $post->post_status) {
                        if ($time_diff > 0) {
                            echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
                        } else {
                            _e('Scheduled');
                        }
                    } else {
                        _e('Last Modified');
                    }
                    echo '</td>';
                    break;
                case 'comments':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><div class="post-com-count-wrapper">
			<?php 
                    $pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0;
                    ?>
				<strong class="post-com-count"><span><?php 
                    echo $pending_comments;
                    ?>
</span></strong>
			</div></td>
			<?php 
                    break;
                case 'author':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    printf('<a href="%s">%s</a>', fa_iframe_admin_page_url('fa-mixed-content-modal', array('post_type' => $post->post_type, 'author' => get_the_author_meta('ID')), false), get_the_author());
                    ?>
</td>
			<?php 
                    break;
                default:
                    if ('categories' == $column_name) {
                        $taxonomy = 'category';
                    } elseif ('tags' == $column_name) {
                        $taxonomy = 'post_tag';
                    } elseif (0 === strpos($column_name, 'taxonomy-')) {
                        $taxonomy = substr($column_name, 9);
                    } else {
                        $taxonomy = false;
                    }
                    if ($taxonomy) {
                        $taxonomy_object = get_taxonomy($taxonomy);
                        echo '<td ' . $attributes . '>';
                        if ($terms = get_the_terms($post->ID, $taxonomy)) {
                            $out = array();
                            foreach ($terms as $t) {
                                $posts_in_term_qv = array();
                                $posts_in_term_qv['post_type'] = $post->post_type;
                                if ($taxonomy_object->query_var) {
                                    $posts_in_term_qv[$taxonomy_object->query_var] = $t->slug;
                                } else {
                                    $posts_in_term_qv['taxonomy'] = $taxonomy;
                                    $posts_in_term_qv['term'] = $t->slug;
                                }
                                $out[] = sprintf('<a href="%s">%s</a>', fa_iframe_admin_page_url('fa-mixed-content-modal', $posts_in_term_qv, false), esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')));
                            }
                            /* translators: used between list items, there is a space after the comma */
                            echo join(__(', '), $out);
                        } else {
                            echo '&#8212;';
                        }
                        echo '</td>';
                        break;
                    }
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    if (is_post_type_hierarchical($post->post_type)) {
                        /**
                         * Fires in each custom column on the Posts list table.
                         *
                         * This hook only fires if the current post type is hierarchical,
                         * such as pages.
                         *
                         * @since 2.5.0
                         *
                         * @param string $column_name The name of the column to display.
                         * @param int    $post_id     The current post ID.
                         */
                        do_action('fa_manage_pages_custom_column', $column_name, $post->ID);
                    } else {
                        /**
                         * Fires in each custom column in the Posts list table.
                         *
                         * This hook only fires if the current post type is non-hierarchical,
                         * such as posts.
                         *
                         * @since 1.5.0
                         *
                         * @param string $column_name The name of the column to display.
                         * @param int    $post_id     The current post ID.
                         */
                        do_action('fa_manage_posts_custom_column', $column_name, $post->ID);
                    }
                    /**
                     * Fires for each custom column of a specific post type in the Posts list table.
                     *
                     * The dynamic portion of the hook name, $post->post_type, refers to the post type.
                     *
                     * @since 3.1.0
                     *
                     * @param string $column_name The name of the column to display.
                     * @param int    $post_id     The current post ID.
                     */
                    do_action("fa_manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID);
                    ?>
</td>
			<?php 
                    break;
            }
        }
        ?>
		</tr>
	<?php 
        $GLOBALS['post'] = $global_post;
    }
					</td>
				</tr>
				<?php 
$publish_categories = $publish_everywhere ? $publish_everywhere : $options['display']['all_categories'];
?>
				<tr class="publish-settings publish-categories"<?php 
fa_hide($publish_categories);
?>
>
					<th>
						<label for="display-tax"><?php 
_e('Display on categories', 'fapro');
?>
:</label><br />
						(<a id="fa-display-posts-categories" class="fapro-modal-trigger" data-target="fapro-modal" href="<?php 
fa_iframe_admin_page_url('fa-tax-modal', array('show_all' => 'true'));
?>
"><?php 
_e('click to select', 'fapro');
?>
</a>)
					</th>
					<td>
						<div id="fa-selected-display-categories">
							<?php 
$tax = fa_get_registered_taxonomies();
$selected = false;
$first = true;
foreach ($tax as $post_type => $taxonomies) {
    foreach ($taxonomies as $taxonomy) {
        $tax = $taxonomy['taxonomy'];
示例#4
0
						</td>
					</tr>		
				</tbody>
			</table>
		</div><!-- #fapro-content-posts -->
		
		<!-- Settings for sliders made from mixed content -->
		<div id="fapro-content-mixed"<?php 
if ('mixed' != $options['slides']['type']) {
    ?>
 style="display:none;"<?php 
}
?>
>
			<a id="fa-select-mixed-content" class="button button-primary fapro-modal-trigger" data-target="fapro-modal" href="<?php 
fa_iframe_admin_page_url('fa-mixed-content-modal');
?>
"><?php 
_e('Select slides', 'fapro');
?>
</a>
			<a id="" class="button button-secondary" href="#"><?php 
_e('Create custom slide', 'fapro');
?>
 <?php 
fa_option_not_available(' ');
?>
</a>
			
			<div id="fa-selected-posts">		
				<?php 
<div id="wpbody">
	<div id="wpbody-content">	
		<div class="wrap">
			<form method="post" action="<?php 
fa_iframe_admin_page_url('fa-post-slide-edit', array('post_id' => $post->ID, 'slider_id' => $slider_id));
?>
" id="fa-slide-edit-form">
				<?php 
wp_nonce_field('fa-slide-modal-options-save', 'fa-slide-modal-settings-nonce');
?>
				<input type="hidden" id="post_ID" name="post_ID" value="<?php 
echo $post->ID;
?>
" />
				<input type="hidden" id="slider_id" name="slider_ID" value="<?php 
echo $slider_id;
?>
" />
				<div id="poststuff">
					<div id="post-body" class="metabox-holder columns-2">
						<div id="post-body-content">
							<div id="titlediv">
								<div id="titlewrap">
									<label class="screen-reader-text" id="title-prompt-text" for="title"><?php 
_e('Enter slide title', 'fapro');
?>
</label>
									<input id="title" type="text" autocomplete="off" value="<?php 
echo $options['title'];
?>
" size="30" name="fa_slide[title]" />