示例#1
0
 /**
  * This function determines which image to be used as the slider image based on user
  * settings, and returns the <img> tag of the the slider image.
  *
  * It requires the post's ID to be passed in as argument so that the user settings in
  * individual post / page can be retrieved.
 */
 function graphene_get_slider_image($post_id = NULL, $size = 'thumbnail', $urlonly = false, $default = '')
 {
     global $graphene_settings;
     // Throw an error message if no post ID supplied
     if ($post_id == NULL) {
         echo '<strong>ERROR:</strong> Post ID must be passed as an input argument to call the function <code>graphene_get_slider_image()</code>.';
         return;
     }
     // First get the settings
     $global_setting = $graphene_settings['slider_img'] ? $graphene_settings['slider_img'] : 'featured_image';
     $local_setting = graphene_get_post_meta($post_id, 'slider_img');
     $local_setting = $local_setting ? $local_setting : '';
     // Determine which image should be displayed
     $final_setting = $local_setting == '' ? $global_setting : $local_setting;
     // Build the html based on the final setting
     $html = '';
     if ($final_setting == 'disabled') {
         // image disabled
         return false;
     } elseif ($final_setting == 'featured_image') {
         // Featured Image
         if (has_post_thumbnail($post_id)) {
             if ($urlonly) {
                 $html = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $size);
             } else {
                 $html .= get_the_post_thumbnail($post_id, $size);
             }
         }
     } elseif ($final_setting == 'post_image') {
         // First image in post
         $html = graphene_get_post_image($post_id, $size, '', $urlonly);
     } elseif ($final_setting == 'custom_url') {
         // Custom URL
         if (!$urlonly) {
             $html .= '';
             if ($local_setting != '') {
                 $html .= '<img src="' . esc_url(graphene_get_post_meta($post_id, 'slider_imgurl')) . '" alt="" />';
             } else {
                 $html .= '<img src="' . esc_url($graphene_settings['slider_imgurl']) . '" alt="" />';
             }
         } else {
             if ($local_setting != '') {
                 $html .= esc_url(graphene_get_post_meta($post_id, 'slider_imgurl'));
             } else {
                 $html .= esc_url($graphene_settings['slider_imgurl']);
             }
         }
     }
     if (!$html) {
         $html = $default;
     }
     // Returns the html
     return $html;
 }
示例#2
0
/**
 * Get the post date display type for each post
 *
 * @package Graphene
 * @since 1.8.3
 */
function graphene_post_date_setting($id)
{
    $post_setting = graphene_get_post_meta($id, 'post_date_display');
    if ($post_setting) {
        return $post_setting;
    }
    global $graphene_settings;
    return $graphene_settings['post_date_display'];
}
示例#3
0
 /**
  * Code exact copied from: wp-includes\post-template.php >> Walker_Page::start_el() 
  * @since 2.1.0
  */
 function start_el(&$output, $page, $depth = 0, $args = array(), $current_page = 0)
 {
     global $graphene_settings;
     if ($depth) {
         $indent = str_repeat("\t", $depth);
     } else {
         $indent = '';
     }
     extract($args, EXTR_SKIP);
     $css_class = array('page_item', 'page-item-' . $page->ID);
     if (!empty($current_page)) {
         $_current_page = get_post($current_page);
         if (in_array($page->ID, $_current_page->ancestors)) {
             $css_class[] = 'current_page_ancestor';
         }
         if ($page->ID == $current_page) {
             $css_class[] = 'current_page_item';
         } elseif ($_current_page && $page->ID == $_current_page->post_parent) {
             $css_class[] = 'current_page_parent';
         }
     } elseif ($page->ID == get_option('page_for_posts')) {
         $css_class[] = 'current_page_parent';
     }
     $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page, $depth, $args, $current_page));
     $title = apply_filters('the_title', $page->post_title, $page->ID);
     if (!$depth && !$graphene_settings['disable_menu_desc']) {
         $title = '<strong>' . $title . '</strong>';
         $nav_desc = graphene_get_post_meta($page->ID, 'nav_description');
         $title .= $nav_desc ? '<span class="desc">' . $nav_desc . '</span>' : '';
     }
     $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_permalink($page->ID) . '">' . $link_before . $title . $link_after . '</a>';
     if (!empty($show_date)) {
         if ('modified' == $show_date) {
             $time = $page->post_modified;
         } else {
             $time = $page->post_date;
         }
         $output .= " " . mysql2date($date_format, $time);
     }
     $output = apply_filters('graphene_page_description_walker_output', $output, $page, $depth, $args, $current_page);
 }