コード例 #1
0
ファイル: functions.php プロジェクト: proudchild/sdmblog
/**
 * Returns the image URL for a given slide ID ( $post_id ) that belongs to
 * a given slider id( $slider_id ). Will do all size checking and will return
 * an array with the image details or false if image isn't found.
 * 
 * @param int $post_id - ID of slide
 * @param int $slider_id - ID of slider
 * @return array( 'url' => URL of image, 'width' => image width, 'height' => image height, 'id' => image ID if found in media gallery )
 */
function get_the_fa_slide_image_url($post_id = false, $slider_id = false)
{
    // set the post ID
    if (!$post_id) {
        global $post;
        if ($post) {
            $post_id = $post->ID;
        } else {
            _doing_it_wrong('get_the_fa_image_url()', __('Use this function inside a slide loop or pass the slide (post) ID to the function.', 'fapro'), '3.0');
        }
    } else {
        $post = get_post($post_id);
    }
    // get the slider ID
    if (!$slider_id) {
        global $fa_slider;
        if ($fa_slider) {
            $slider_id = $fa_slider->ID;
        } else {
            _doing_it_wrong('get_the_fa_image_url()', __('Use this function inside a slide loop or pass the slider ID to the function.', 'fapro'), '3.0');
        }
    }
    if (!$post || !$post_id || !$slider_id) {
        return false;
    }
    // get slider options and check if image is visible
    $slider_options = fa_get_slider_options($slider_id, 'content_image');
    if (!$slider_options['show']) {
        return;
    }
    // slide options
    $options = fa_get_slide_options($post_id);
    // get the attached image ID
    $image_id = get_the_fa_image_id($post_id);
    // try to make the image url
    $image_url = false;
    if ('wp' == $slider_options['sizing'] && $image_id) {
        $wp_attachment = wp_get_attachment_image_src($image_id, $slider_options['wp_size']);
        if ($wp_attachment) {
            $image_url = $wp_attachment[0];
        }
    } else {
        if ('custom' == $slider_options['sizing'] && $image_id) {
            $image_url = fa_get_custom_image_size($image_id, $slider_options['width'], $slider_options['height']);
        }
    }
    // last options, check on slide settings if an image URL is set
    if (!$image_url) {
        if (isset($options['temp_image_url']) && !empty($options['temp_image_url'])) {
            $image_url = $options['temp_image_url'];
        }
    }
    // if no image URL was detected, stop
    if (!$image_url) {
        return false;
    }
    $width = $height = false;
    // get the image size
    if ('custom' == $slider_options['sizing']) {
        $width = absint($slider_options['width']);
        $height = absint($slider_options['height']);
    } elseif ('wp' == $slider_options['sizing']) {
        if (isset($wp_attachment) && $wp_attachment) {
            $width = $wp_attachment[1];
            $height = $wp_attachment[2];
        }
    }
    // create the response
    return array('url' => $image_url, 'width' => $width, 'height' => $height, 'id' => $image_id);
}
コード例 #2
0
ファイル: templating.php プロジェクト: vrxm/htdocs
/**
 * Outputs the background color for the current slide in loop
 * @param string $before
 * @param string $after
 */
function the_fa_background_color($echo = true, $before = ' ', $after = ';')
{
    $post = get_current_slide();
    $options = fa_get_slide_options($post->ID);
    $output = '';
    if (!empty($options['background'])) {
        $output = $before . 'background-color:' . $options['background'] . $after;
    }
    if ($echo) {
        echo $output;
    }
    return $output;
}
コード例 #3
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;
    }
コード例 #4
0
ファイル: functions.php プロジェクト: vrxm/htdocs
/**
 * Output the image attached to a slide
 * @param int $post_id
 */
function the_fa_slide_image($post_id)
{
    $post_id = absint($post_id);
    $options = fa_get_slide_options($post_id);
    $image = false;
    if ($options['image']) {
        $image = wp_get_attachment_image($options['image'], 'thumbnail');
    }
    // always enqueue the media gallery scripts
    wp_enqueue_media();
    fa_load_admin_script('media-gallery');
    ?>
	
<div id="fa-selected-images">
<?php 
    if ($image) {
        ?>
	<div class="fa-slide-image" data-post_id="<?php 
        echo $options['image'];
        ?>
">		
		<?php 
        $args = array('page_title' => __('Select image to use in slide', 'fapro'), 'button_text' => $image, 'select_multiple' => false, 'class' => 'fa-img');
        fa_media_gallery($args);
        ?>
			
	</div>
	<a href="#" id="fa-remove-slide-image" data-post_id=<?php 
        echo $post_id;
        ?>
><?php 
        _e('Remove image', 'fapro');
        ?>
</a>	
<?php 
    } else {
        // show the image select button
        ?>
	<?php 
        $args = array('page_title' => __('Select image to use in slide', 'fapro'), 'button_text' => __('Select image', 'fapro'), 'select_multiple' => false);
        fa_media_gallery($args);
    }
    // if($image)
    ?>
</div>
<?php 
}
コード例 #5
0
ファイル: class-fa-admin.php プロジェクト: proudchild/sdmblog
 /**
  * Mixed content slide edit details modal
  */
 public function modal_mixed_slide_edit()
 {
     if (defined('FAPRO_IFRAME')) {
         iframe_header();
     }
     $post_id = absint($_GET['post_id']);
     $post = get_post($post_id);
     if (!$post) {
         wp_die(__('Post not found.', 'fapro'));
     }
     $slider_id = absint($_GET['slider_id']);
     $slider = get_post($slider_id);
     if (!$slider) {
         wp_die(__('Slider not found.', 'fapro'));
     }
     $options = fa_get_slide_options($post_id);
     if ('auto-draft' == $post->post_status) {
         $post->post_title = '';
         $options['title'] = '';
     }
     $screen = get_current_screen();
     $screen_id = $screen->id;
     $this->remove_meta_boxes(null, false);
     $modal = fa_modal_path('slide-settings');
     include_once $modal;
     if (defined('FAPRO_IFRAME')) {
         iframe_footer();
         exit;
     }
 }