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


PHP get_the_modified_author函数代码示例

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


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

示例1: nebula_admin_bar_menus

 function nebula_admin_bar_menus($wp_admin_bar)
 {
     $node_id = is_admin() ? 'view' : 'edit';
     $new_content_node = $wp_admin_bar->get_node($node_id);
     if ($new_content_node) {
         $new_content_node->title = ucfirst($node_id) . ' Page <span class="nebula-admin-light" style="font-size: 10px; color: #a0a5aa; color: rgba(240, 245, 250, .6);">(ID: ' . get_the_id() . ')</span>';
         $wp_admin_bar->add_node($new_content_node);
     }
     //Add created date under View/Edit node
     //@TODO "Nebula" 0: get_the_author() is not working when in Admin
     $wp_admin_bar->add_node(array('parent' => $node_id, 'id' => 'nebula-created', 'title' => '<i class="nebula-admin-fa fa fa-fw fa-calendar-o" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Created: ' . get_the_date() . ' <span class="nebula-admin-light" style="font-size: 10px; color: #a0a5aa; color: rgba(240, 245, 250, .6);">(' . get_the_author() . ')</span>', 'href' => get_edit_post_link(), 'meta' => array('target' => '_blank')));
     //Add modified date under View/Edit node
     if (get_the_modified_date() != get_the_date()) {
         //If the post has been modified
         $manage_author = get_the_modified_author() ? get_the_modified_author() : get_the_author();
         $wp_admin_bar->add_node(array('parent' => $node_id, 'id' => 'nebula-modified', 'title' => '<i class="nebula-admin-fa fa fa-fw fa-clock-o" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Modified: ' . get_the_modified_date() . ' <span class="nebula-admin-light" style="font-size: 10px; color: #a0a5aa; color: rgba(240, 245, 250, .6);">(' . $manage_author . ')</span>', 'href' => get_edit_post_link(), 'meta' => array('target' => '_blank')));
     }
     /* @TODO "Nebula" 0: Other information to consider under the View/Edit node:
     			- Status (Published, Draft, etc)
     			- Visibility (Public)
     			- Revisions (count)
     		*/
     $wp_admin_bar->add_node(array('id' => 'nebula', 'title' => '<i class="nebula-admin-fa fa fa-fw fa-star" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Nebula', 'href' => 'https://gearside.com/nebula/', 'meta' => array('target' => '_blank')));
     $scss_last_processed = get_option('nebula_scss_last_processed') ? date('l, F j, Y - g:i:sa', get_option('nebula_scss_last_processed')) : 'Never';
     $wp_admin_bar->add_node(array('parent' => 'nebula', 'id' => 'nebula-options-scss', 'title' => '<i class="nebula-admin-fa fa fa-fw fa-paint-brush" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Re-process All SCSS Files', 'href' => esc_url(add_query_arg('sass', 'true')), 'meta' => array('title' => 'Last: ' . $scss_last_processed)));
     $wp_admin_bar->add_node(array('parent' => 'nebula', 'id' => 'nebula-options', 'title' => '<i class="nebula-admin-fa fa fa-fw fa-cog" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Options', 'href' => get_admin_url() . 'themes.php?page=nebula_options'));
     $wp_admin_bar->add_node(array('parent' => 'nebula-options', 'id' => 'nebula-options-help', 'title' => '<i class="nebula-admin-fa fa fa-fw fa-question" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Help & Documentation', 'href' => 'https://gearside.com/nebula/documentation/options/', 'meta' => array('target' => '_blank')));
     $wp_admin_bar->add_node(array('parent' => 'nebula', 'id' => 'nebula-github', 'title' => '<i class="nebula-admin-fa fa fa-fw fa-github" style="font-family: \'FontAwesome\'; color: #a0a5aa; color: rgba(240, 245, 250, .6); margin-right: 5px;"></i> Nebula Github', 'href' => 'https://github.com/chrisblakley/Nebula', 'meta' => array('target' => '_blank')));
     $wp_admin_bar->add_node(array('parent' => 'nebula-github', 'id' => 'nebula-github-issues', 'title' => 'Issues', 'href' => 'https://github.com/chrisblakley/Nebula/issues', 'meta' => array('target' => '_blank')));
     $wp_admin_bar->add_node(array('parent' => 'nebula-github', 'id' => 'nebula-github-changelog', 'title' => 'Changelog', 'href' => 'https://github.com/chrisblakley/Nebula/commits/master', 'meta' => array('target' => '_blank')));
 }
开发者ID:CloouCom,项目名称:Nebula,代码行数:31,代码来源:nebula_admin.php

示例2: bhr_append_last_author

function bhr_append_last_author($content)
{
    global $post, $pp;
    $html = "<div class=\"post-author\">";
    $html .= sprintf(__("Last edited by %s on %s at %s", "bhr"), get_the_modified_author(), get_the_modified_date(), get_the_modified_time());
    $html .= "</div>";
    return $content . $html;
}
开发者ID:khamer71,项目名称:blueheronsresistance.com,代码行数:8,代码来源:functions.php

示例3: budget_modified_user

function budget_modified_user()
{
    global $post;
    if ($user = get_post_meta($post->ID, '_last_modified_name', true)) {
        $user = $user;
    } else {
        $user = get_the_modified_author();
    }
    echo $user;
}
开发者ID:bangordailynews,项目名称:Newsroom-Tools,代码行数:10,代码来源:functions.php

示例4: suffusion_sc_the_author

function suffusion_sc_the_author($attr)
{
    global $suffusion_social_networks;
    $id = get_the_author_meta('ID');
    if ($id) {
        if (isset($attr['display'])) {
            $display = $attr['display'];
            switch ($display) {
                case 'author':
                    return get_the_author();
                case 'modified-author':
                    return get_the_modified_author();
                case 'description':
                    return get_the_author_meta('description', $id);
                case 'login':
                    return get_the_author_meta('user_login', $id);
                case 'first-name':
                    return get_the_author_meta('first_name', $id);
                case 'last-name':
                    return get_the_author_meta('last_name', $id);
                case 'nickname':
                    return get_the_author_meta('nickname', $id);
                case 'id':
                    return $id;
                case 'url':
                    return get_the_author_meta('user_url', $id);
                case 'email':
                    return get_the_author_meta('user_email', $id);
                case 'link':
                    if (get_the_author_meta('user_url', $id)) {
                        return '<a href="' . get_the_author_meta('user_url', $id) . '" title="' . esc_attr(get_the_author()) . '" rel="external">' . get_the_author() . '</a>';
                    } else {
                        return get_the_author();
                    }
                case 'aim':
                    return get_the_author_meta('aim', $id);
                case 'yim':
                    return get_the_author_meta('yim', $id);
                case 'posts':
                    return get_the_author_posts();
                case 'posts-url':
                    return get_author_posts_url(get_the_author_meta('ID'));
            }
            if (isset($suffusion_social_networks) && isset($suffusion_social_networks[$display]) && $suffusion_social_networks[$display]) {
                return get_the_author_meta($display, $id);
            }
        } else {
            return get_the_author();
        }
    }
}
开发者ID:kevinaxu,项目名称:99boulders,代码行数:51,代码来源:shortcodes.php

示例5: the_modified_author

/**
 * Display the name of the author who last edited the current post.
 *
 * @since 2.8
 * @see get_the_author()
 * @return string The author's display name, from get_the_modified_author().
 */
function the_modified_author()
{
    echo get_the_modified_author();
}
开发者ID:radman,项目名称:noobyo-blog,代码行数:11,代码来源:author-template.php

示例6: get_the_modified_time

        $mod_datetime = get_the_modified_time('Y-m-d');
        $time = get_the_time();
        $mod_time = get_the_modified_time();
        $now = date('Y');
        $then = get_the_time('Y');
        if ($now != $then) {
            $date = get_the_date();
            $mod_date = get_the_modified_date();
        } else {
            $date = get_the_date('F j');
            $mod_date = get_the_modified_date('F j');
        }
        if ($time > $mod_time) {
            echo 'Written <time datetime="' . $datetime . '">' . $date . '</time> by ' . get_the_author();
        } else {
            echo 'Edited <time datetime="' . $mod_datetime . '">' . $mod_date . '</time> by ' . get_the_modified_author();
        }
        ?>
</span></h2>
					<?php 
        the_content(__('More...'));
        ?>
					<?php 
        edit_post_link(__('Edit'), '', '');
        ?>
 <?php 
        if (comments_open() || get_comments_number()) {
            comments_template();
        }
        ?>
				</article>
开发者ID:codysaylor,项目名称:wordpress-barebones-boilerplate,代码行数:31,代码来源:single.php

示例7: shortcode_the_modified_author

/**
 * Shortcode function for showing the last author to modify the post
 * Uses the get_the_modified_author() function
 * @link http://codex.wordpress.org/Template_Tags/the_modified_author
 *
 * Only for use with WP 2.8+
 *
 * @since 0.1
 */
function shortcode_the_modified_author()
{
    return get_the_modified_author();
}
开发者ID:jfitzsimmons,项目名称:soundtrackforspace,代码行数:13,代码来源:template-tag-shortcodes.php

示例8: property_author_column_content

 function property_author_column_content($column_name, $post_id)
 {
     switch ($column_name) {
         case 'author':
             echo get_the_modified_author($post_id);
             break;
         case 'featured':
             $featured_box = get_post_meta($post_id, 'imic_featured_property', true);
             echo $featured_box == 0 ? 'No' : 'Yes';
             break;
         case 'pid':
             $property_id = get_post_meta($post_id, 'imic_property_site_id', true);
             if ($property_id == '') {
                 $new_id = 1648 + $post_id;
                 update_post_meta($post_id, 'imic_property_site_id', imicPropertyIdWording() . $new_id);
             }
             echo $property_id;
             break;
     }
 }
开发者ID:AbleLincoln,项目名称:Avaant_Real-Spaces_wp_theme,代码行数:20,代码来源:imic-theme-functions.php

示例9: fly_excerptlist_func

function fly_excerptlist_func($atts)
{
    extract(shortcode_atts(array('titleonly' => 'n', 'cat' => '', 'num' => 5), $atts));
    $args = array('posts_per_page' => $num);
    $id = get_cat_id($cat);
    $args['cat'] = $id;
    $loop = new WP_Query($args);
    $posts = array();
    foreach ($loop->posts as $p) {
        $posts[] = $p;
    }
    global $post;
    $opost = $post;
    ob_start();
    ob_start();
    $ret = apply_filters('excerptlist', $posts);
    if (is_array($ret) || $ret == "" || $ret == " ") {
        $ret = ob_get_contents();
    }
    ob_end_clean();
    if (!is_array($ret) && $ret != "") {
    } else {
        if (strtolower($titleonly) != "y") {
            $ret = '
   <div class="excerptlist"> ';
            foreach ($posts as $post) {
                setup_postdata($post);
                $ret .= ' <div class="articleexcerpt"> 


       <div class="thumb">';
                if (has_post_thumbnail()) {
                    $ret .= ' <a href="' . get_permalink($post->ID) . '">' . get_the_post_thumbnail($post->ID, array(125, 125), array('class' => 'articleimg')) . '</a>';
                } else {
                    if (get_theme_option('art-thumb')) {
                        $ret .= '<a href="' . get_permalink($post->ID) . '"><img class="articleimg" src="' . get_theme_option('art-thumb') . '" alt="' . get_the_title($post->ID) . '" width="125" height="125" /></a>';
                    }
                }
                $ret .= '</div>
		<h3 class="title"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . get_the_title($post->ID) . '</a></h3>';
                if (!get_theme_option('bylines-hide-all')) {
                    $ret .= ' <div class="bylines"> 

               ' . (!get_theme_option("bylines-hide-date") ? get_the_time('F j, Y') : "") . ' 
               ' . (!get_theme_option("bylines-hide-author") ? "by" : "") . ' 
               ' . (!get_theme_option("bylines-hide-author") ? "<a href=\"" . get_author_posts_url(get_the_author_meta('ID')) . "\">" . get_the_modified_author() . " </a>" : "") . ' 

 ' . (!get_theme_option("bylines-hide-category") ? "posted in " : "") . ' 
            ' . (!get_theme_option("bylines-hide-category") ? get_the_category_list(', ', '', $post->ID) : "") . '

' . (!get_theme_option("bylines-hide-comment") ? '&bull; <a href="' . get_permalink($post->ID) . '#comments">  ' . get_comments_number() . ' comments </a>' : "") . '
 
			
		</div>';
                }
                $ret .= '  <p>' . get_the_excerpt() . '</p>

		

            </div><!-- End of articleexcerpt  --> ';
            }
            $post = $opost;
            $ret .= '</div><!-- End of excerptlist  --> ';
        } else {
            $ret = '<ul> ';
            foreach ($posts as $post) {
                setup_postdata($post);
                $ret .= '<li class="exelist"><a href="' . get_permalink($post->ID) . '" rel="bookmark">' . get_the_title($post->ID) . '</a></li>';
            }
            $post = $opost;
            $ret .= '</ul>';
        }
    }
    return $ret;
}
开发者ID:christocmp,项目名称:bingopaws,代码行数:75,代码来源:excerpt-shortcode.php

示例10: nebula_manage

function nebula_manage($data)
{
    $override = apply_filters('pre_nebula_manage', false, $data);
    if ($override !== false) {
        echo $override;
        return;
    }
    if ($data == 'edit' || $data == 'admin') {
        echo '<span class="nebula-manage-edit"><span class="post-admin"><i class="fa fa-wrench"></i> <a href="' . get_admin_url() . '" target="_blank">Admin</a></span> <span class="post-edit"><i class="fa fa-pencil"></i> <a href="' . get_edit_post_link() . '">Edit</a></span></span>';
    } elseif ($data == 'modified' || $data == 'mod') {
        $manage_author = get_the_modified_author() ? get_the_modified_author() : get_the_author();
        echo '<span class="post-modified">Last Modified: <strong>' . get_the_modified_date() . '</strong> by <strong>' . $manage_author . '</strong></span>';
    } elseif ($data == 'info') {
        if (wp_attachment_is_image()) {
            $metadata = wp_get_attachment_metadata();
            echo '';
            //@TODO "Nebula" 0: In progress
        }
    }
}
开发者ID:KevinFairbanks,项目名称:Nebula,代码行数:20,代码来源:nebula_functions.php

示例11: cms_tpv_print_childs

/**
 * Output JSON for the children of a node
 * $arrOpenChilds = array with id of pages to open children on
 */
function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $post_type)
{
    $arrPages = cms_tpv_get_pages("parent={$pageID}&view={$view}&post_type={$post_type}");
    if ($arrPages) {
        global $current_screen;
        $screen = convert_to_screen("edit");
        $screen->post_type = null;
        ob_start();
        // some plugins, for example magic fields, return javascript and things here. we're not compatible with that, so just swallow any output
        $posts_columns = get_column_headers($screen);
        ob_get_clean();
        unset($posts_columns["cb"], $posts_columns["title"], $posts_columns["author"], $posts_columns["categories"], $posts_columns["tags"], $posts_columns["date"]);
        global $post;
        #cms_tpv_firedebug(timer_stop());
        ?>
[<?php 
        for ($i = 0, $pagesCount = sizeof($arrPages); $i < $pagesCount; $i++) {
            #cms_tpv_firedebug(timer_stop());
            $onePage = $arrPages[$i];
            $tmpPost = $post;
            $post = $onePage;
            $page_id = $onePage->ID;
            $arrChildPages = NULL;
            $editLink = get_edit_post_link($onePage->ID, 'notDisplay');
            $content = esc_html($onePage->post_content);
            $content = str_replace(array("\n", "\r"), "", $content);
            $hasChildren = false;
            // if viewing trash, don't get children. we watch them "flat" instead
            if ($view == "trash") {
            } else {
                $arrChildPages = cms_tpv_get_pages("parent={$onePage->ID}&view={$view}&post_type={$post_type}");
            }
            if (!empty($arrChildPages)) {
                $hasChildren = true;
            }
            // if no children, output no state
            $strState = '"state": "closed",';
            if (!$hasChildren) {
                $strState = '';
            }
            // type of node
            $rel = $onePage->post_status;
            if ($onePage->post_password) {
                $rel = "password";
            }
            // modified time
            $post_modified_time = strtotime($onePage->post_modified);
            $post_modified_time = date_i18n(get_option('date_format'), $post_modified_time, false);
            // last edited by
            setup_postdata($post);
            $post_author = get_the_modified_author();
            if (empty($post_author)) {
                $post_author = __("Unknown user", 'cms-tree-page-view');
            }
            $title = get_the_title($onePage->ID);
            // so hooks and stuff will do their work
            if (empty($title)) {
                $title = __("<Untitled page>", 'cms-tree-page-view');
            }
            $title = esc_html($title);
            #$title = html_entity_decode($title, ENT_COMPAT, "UTF-8");
            #$title = html_entity_decode($title, ENT_COMPAT);
            // can edit?
            if (current_user_can('edit_page', $page_id)) {
                $user_can_edit_page = true;
                $user_can_edit_page_css = "cms_tpv_user_can_edit_page_yes";
            } else {
                $user_can_edit_page = false;
                $user_can_edit_page_css = "cms_tpv_user_can_edit_page_no";
            }
            // fetch columns
            $str_columns = "";
            foreach ($posts_columns as $column_name => $column_display_name) {
                $col_name = $column_display_name;
                if ($column_name == "comments") {
                    $col_name = __("Comments");
                }
                $str_columns .= "<dt>{$col_name}</dt>";
                $str_columns .= "<dd>";
                if ($column_name == "comments") {
                    $str_columns .= '<div class="post-com-count-wrapper">';
                    $left = get_pending_comments_num($onePage->ID);
                    $pending_phrase = sprintf(__('%s pending'), number_format($left));
                    $pending_phrase2 = "";
                    if ($left) {
                        $pending_phrase2 = " + {$left} " . __("pending");
                    }
                    if ($left) {
                        $str_columns .= '<strong>';
                    }
                    ob_start();
                    comments_number("<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}'><span>" . _x('0', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('1', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('%', 'comment count') . "{$pending_phrase2}</span></a>");
                    $str_columns .= ob_get_clean();
                    if ($left) {
                        $str_columns .= '</strong>';
                    }
//.........这里部分代码省略.........
开发者ID:Savantos,项目名称:cow-theme,代码行数:101,代码来源:functions.php

示例12: add_author_to_cat

function add_author_to_cat($content)
{
    $content_org = $content;
    $options = get_option('Post_Author_Options');
    //    $post_author_modify_link_name = '';
    $post_id = get_the_ID();
    $author_exception = get_post_meta($post_id, 'hide_author_value', TRUE);
    if ($options['post_author_link_name'] == '') {
        $options['post_author_link_name'] = get_author_posts_url(get_the_author_ID());
        $post_author_modify_link_name = get_author_posts_url(get_post_meta($post_id, '_edit_last', true));
    }
    //$post_date = get_the_time(get_option('date_format'));
    $post_date = get_the_date();
    // Edit 2011/11/21 by Christophe Serra <christophe[at]glanum.com>
    $author = get_the_author();
    $modified_date = get_the_modified_time(get_option('date_format'));
    $modified_author = get_the_modified_author();
    if ((is_home() && !($options['post_author_cat_home'] == 'on') || is_category()) && $options['post_author_type_cat'] == 'on') {
        if ($author_exception != 'on') {
            $content = '<div class="post_author_plugin_cat"><span class="post_author_author">' . $options['post_author_txt_before'] . ' ';
            // Author link
            if ($options['post_author_author_link'] == 'on') {
                // Avatar on cat
                if ($options['post_author_author_avatar_on_cat'] == 'on') {
                    $content .= '<div class="post_author_avatar">';
                    $content .= $author_link_start;
                    $content .= get_avatar(get_the_author_meta('user_email'), $options['post_author_author_avatar_size_on_cat'], '', $moreabout, $options['post_author_author_avatar_float_on_cat']);
                    $content .= $author_link_end;
                    $content .= '</div>';
                }
                if (function_exists('esc_attr')) {
                    // personal URL on profile
                    if ($options['post_author_author_link_to_url'] == 'on' && get_the_author_meta('user_url', $author->ID) != NULL) {
                        $content .= '<a href="' . esc_attr(get_the_author_meta('user_url', $author->ID)) . '" target="_blank" title="' . $moreabout . ' ">';
                    } else {
                        $content .= '<a href="' . esc_attr($options['post_author_link_name']) . '" title="' . $moreabout . ' ">';
                    }
                } else {
                    // personal URL on profile
                    if ($options['post_author_author_link_to_url'] == 'on' && get_the_author_meta('user_url', $author->ID) != NULL) {
                        $content .= '<a href="' . attribute_escape(get_the_author_meta('user_url', $author->ID)) . '" target="_blank" title="' . $moreabout . ' ">';
                    } else {
                        $content .= '<a href="' . attribute_escape($options['post_author_link_name']) . '" title="' . $moreabout . ' ">';
                    }
                }
            }
            $content .= $author;
            if ($options['post_author_author_link'] == 'on') {
                $content .= '</a>';
            }
            $content .= $options['post_author_txt_after'] . '</span>';
            // ADD OPTIONAL DATE
            if ($options['post_author_create_dat'] == 'on') {
                $content .= '<span class="post_author_create">' . $options['post_author_dat_before'] . $post_date . $options['post_author_dat_after'] . '</span>';
            }
            $content .= '</div>';
            // Place before or after excerpt
            if ($options['post_author_cat_top'] == 'on') {
                $content .= $content_org;
            } else {
                $content = $content_org . $content;
            }
        }
    }
    return $content;
}
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:66,代码来源:post_author.php

示例13: the_title

    the_title('<h1 class="entry-title">', '</h1>');
    ?>
 
<div class="customfav"><?php 
    echo do_shortcode('[favorite_button post_id="" site_id=""]');
    ?>
</div>
 <div class="sp-wrap sp-wrap-default">
<div title="Expand" class="sp-head sp-zmi">
<span>Паспорт ЗМІ  </span> 
</div>
<div class="sp-body folded" style="display: none;">
<table id="zmi-card-table" width="85%" border="1" cellspacing="5" cellpadding="5">
  <tr><td width="35%">Останє оновлення:</td><td><?php 
    echo get_the_modified_date('d/m/Y  -  H:i:s, ');
    echo get_the_modified_author();
    ?>
 </td></tr>
  <tr><td>Дата створення:</td><td><?php 
    echo get_the_date();
    ?>
 </td></tr>
  <tr><td>Тип ЗМІ:</td><td><?php 
    the_field('zmi-type');
    ?>
</td></tr>
  <tr><td>Покриття:</td><td><?php 
    the_field('zmi-national-regional');
    ?>
</td></tr>
  <tr><td>Уточнення покриття:</td><td><?php 
开发者ID:andyUA,项目名称:kabmin-new,代码行数:31,代码来源:content-zmi.php

示例14: notify_on_post_update

 function notify_on_post_update($new_status, $old_status, $post_id)
 {
     // Not a post revision
     if (wp_is_post_revision($post_id)) {
         return;
     }
     // And only if it's published
     if (get_post_status($post_id) == 'publish') {
         // Only look for the author if it's not an attachment, and only
         // tell us about the author if he has a name.
         if (get_post_type($post_id) != 'attachment') {
             if (get_the_modified_author($post_id) != null) {
                 $author = " by " . get_the_modified_author($post_id);
             }
         } else {
             $author = null;
         }
         // Some useful variables for building our messages.
         $post_title = get_the_title($post_id);
         $post_url = get_permalink($post_id);
         $post_type = ucwords(get_post_type($post_id));
         // Building the subject and body depending on whether this is a new post or not.
         if (is_new_post($new_status, $old_status)) {
             $title = "New " . $post_type;
             $short_message = "New " . $post_type . " Added" . ucwords($author);
             $email_body = "A new " . strtolower($post_type) . ", '" . $post_title . "' (" . $post_url . "), has been published" . $author . ".";
         } else {
             $title = "Updated " . $post_type;
             $short_message = $post_type . " Updated" . ucwords($author);
             $email_body = "The " . strtolower($post_type) . " '" . $post_title . "' (" . $post_url . ") has been updated" . $author . ".";
         }
         $subject = get_bloginfo('name') . ': ' . $short_message;
         // Check if it's a Slack Webhook URL
         if (strpos(WPLT_NOTIFY, 'hooks.slack.com') !== false) {
             // Check if we've defined a Slack channel
             $bot_args = array('attachments' => array(0 => array('fallback' => $short_message, 'color' => '#F40101', 'author_name' => $short_message, 'author_link' => $post_url, 'title' => $post_title, 'title_link' => $post_url, 'text' => $post_url)), 'icon_emoji' => ':triangular_flag_on_post:', 'username' => get_bloginfo('name'), 'unfurl_links' => true);
             // Check if we've defined a Slack channel. If we have, slip the
             // channel into our Slack payload.
             if (defined('WPLT_NOTIFY_CHANNEL') && WPLT_NOTIFY_CHANNEL) {
                 $bot_args['channel'] = WPLT_NOTIFY_CHANNEL;
             }
             $payload = array('payload' => json_encode($bot_args));
             // Send the payload to Slack.
             $posting = wp_remote_post(WPLT_NOTIFY, array('body' => $payload));
             // If it's not a Slack Webhook URL, send an email instead.
         } else {
             wp_mail(WPLT_NOTIFY, $subject, $email_body);
         }
     }
     // end if (get_post_status($post_id) == 'publish')
 }
开发者ID:nishar23,项目名称:wordpress,代码行数:51,代码来源:wp-local-toolbox.php


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