1627 | | if ( ! $get_posts->post_count ) |
1628 | | return false; |
1629 | | |
1630 | | // Build results. |
1631 | | $results = array(); |
1632 | | foreach ( $posts as $post ) { |
1633 | | if ( 'post' == $post->post_type ) |
1634 | | $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); |
1635 | | else |
1636 | | $info = $pts[ $post->post_type ]->labels->singular_name; |
1637 | | |
1638 | | $results[] = array( |
1639 | | 'ID' => $post->ID, |
1640 | | 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), |
1641 | | 'permalink' => get_permalink( $post->ID ), |
1642 | | 'info' => $info, |
1643 | | ); |
1644 | | } |
1645 | | |
1646 | | /** |
1647 | | * Filters the link query results. |
1648 | | * |
1649 | | * Allows modification of the returned link query results. |
1650 | | * |
1651 | | * @since 3.7.0 |
1652 | | * |
1653 | | * @see 'wp_link_query_args' filter |
1654 | | * |
1655 | | * @param array $results { |
1656 | | * An associative array of query results. |
1657 | | * |
1658 | | * @type array { |
1659 | | * @type int $ID Post ID. |
1660 | | * @type string $title The trimmed, escaped post title. |
1661 | | * @type string $permalink Post permalink. |
1662 | | * @type string $info A 'Y/m/d'-formatted date for 'post' post type, |
1663 | | * the 'singular_name' post type label otherwise. |
1664 | | * } |
1665 | | * } |
1666 | | * @param array $query An array of WP_Query arguments. |
1667 | | */ |
| 1627 | if ( ! $get_posts->post_count ) { |
| 1628 | /** |
| 1629 | * Filters the link query results. |
| 1630 | * |
| 1631 | * Allows modification of the returned link query results. |
| 1632 | * |
| 1633 | * @since 3.7.0 |
| 1634 | * |
| 1635 | * @see 'wp_link_query_args' filter |
| 1636 | * |
| 1637 | * @param array $results { |
| 1638 | * An associative array of query results. |
| 1639 | * |
| 1640 | * @type array { |
| 1641 | * @type int $ID Post ID. |
| 1642 | * @type string $title The trimmed, escaped post title. |
| 1643 | * @type string $permalink Post permalink. |
| 1644 | * @type string $info A 'Y/m/d'-formatted date for 'post' post type, |
| 1645 | * the 'singular_name' post type label otherwise. |
| 1646 | * } |
| 1647 | * } |
| 1648 | * @param array $query An array of WP_Query arguments. |
| 1649 | */ |
| 1650 | $results = apply_filters( 'wp_link_query', $results, $query ); |
| 1651 | return !empty( $results ) ? $results : false; |
| 1652 | } |
| 1653 | |
| 1654 | // Build results. |
| 1655 | $results = array(); |
| 1656 | foreach ( $posts as $post ) { |
| 1657 | if ( 'post' == $post->post_type ) |
| 1658 | $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); |
| 1659 | else |
| 1660 | $info = $pts[ $post->post_type ]->labels->singular_name; |
| 1661 | |
| 1662 | $results[] = array( |
| 1663 | 'ID' => $post->ID, |
| 1664 | 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), |
| 1665 | 'permalink' => get_permalink( $post->ID ), |
| 1666 | 'info' => $info, |
| 1667 | ); |
| 1668 | } |
| 1669 | |
| 1670 | /** This filter is documented at first usage above */ |