PluginProbe
Edit Flow / 0.9.3
Edit Flow v0.9.3
0.11.1 0.11.0 0.7.2 0.7.3 0.7.4 0.7.5 0.7.6 0.8 0.8.1 0.8.2 0.9 0.9.1 0.9.2 0.9.3 0.9.4 0.9.5 0.9.6 0.9.7 0.9.8 0.9.9 trunk 0.1.5 0.10.0 0.10.1 0.10.2 All 44 releases
edit-flow / common / php / util.php

util.php in Edit Flow 0.9.3, at common/php/util.php

66 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if( ! function_exists( 'ef_draft_or_post_title' ) ) :
4 /**
5 * Copy of core's _draft_or_post_title without the filters
6 *
7 * The post title is fetched and if it is blank then a default string is
8 * returned.
9 * @param int $post_id The post id. If not supplied the global $post is used.
10 * @return string The post title if set
11 */
12 function ef_draft_or_post_title( $post_id = 0 ) {
13 $post = get_post( $post_id );
14 return ! empty( $post->post_title ) ? $post->post_title : __( '(no title)', 'edit-flow' );
15 }
16 endif;
17
18 /**
19 * This function is necessary to make post preview pagination work with custom post statuses
20 * @see _wp_link_page()
21 * @modified WordPress 4.9.2
22 *
23 * Original Comments:
24 *
25 * Helper function for wp_link_pages()
26 *
27 * @since 3.1.0
28 * @access private
29 *
30 * @global WP_Rewrite $wp_rewrite
31 *
32 * @param int $i Page number.
33 * @return string Link.
34 */
35 if ( ! function_exists( '_ef_wp_link_page' ) ) {
36 function _ef_wp_link_page( $i, $custom_statuses ) {
37 global $wp_rewrite;
38 $post = get_post();
39 $query_args = array();
40
41 if ( 1 == $i ) {
42 $url = get_permalink();
43 } else {
44 // Check for all custom post statuses, not just draft & pending
45 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array_merge( $custom_statuses, array( 'pending' ) ) ) )
46 $url = add_query_arg( 'page', $i, get_permalink() );
47 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )
48 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');
49 else
50 $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');
51 }
52
53 if ( is_preview() ) {
54
55 // Check for all custom post statuses, no just the draft
56 if ( ( ! in_array($post->post_status, $custom_statuses ) ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
57 $query_args['preview_id'] = wp_unslash( $_GET['preview_id'] );
58 $query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
59 }
60
61 $url = get_preview_post_link( $post, $query_args, $url );
62 }
63
64 return '<a href="' . esc_url( $url ) . '">';
65 }
66 }