PluginProbe
Edit Flow / 0.10.2
Edit Flow v0.10.2
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.10.2, at common/php/util.php

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