[wp-trac] [WordPress Trac] #21033: Add filter hook for internal linking of custom post type in wordpress editor

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 21 08:12:17 UTC 2012


#21033: Add filter hook for internal linking of custom post type in wordpress
editor
-----------------------------+-----------------------------
 Reporter:  caseydipesh      |      Owner:  Dipesh KC
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Editor           |    Version:  3.4
 Severity:  normal           |   Keywords:
-----------------------------+-----------------------------
 Currently wordpress displays all public post types at the time of
 selecting internal links through insert/edit link button in the wordpress
 tinymce editor.
 By providing a filter for the custom post types  can be a good feature for
 a good CMS.

 In file wp-includes/class-wp-editor-php
 line no 711

 {{{
 public static function wp_link_query( $args = array() ) {
     $pts = get_post_types( array( 'public' => true ), 'objects' );
     $pt_names = array_keys( $pts );

     $query = array(
                         'post_type' => $pt_names,
                         'suppress_filters' => true,
                         'update_post_term_cache' => false,
                         'update_post_meta_cache' => false,
                         'post_status' => 'publish',
                         'order' => 'DESC',
                         'orderby' => 'post_date',
                         'posts_per_page' => 20,
                 );

 }}}
 eg solution


 {{{
 $pts = get_post_types( array( 'public' => true ), 'objects' );

 $pt_names =
 apply_filters('custom_insert_link_suggestion_filter',array_keys( $pts ));
                 $query = array(...
 }}}

  we can add some sort of filter say
 wp_custom_post_type_link_suggest_filter

 so that we can allow only certain post types.
 Eventually in our theme function

 function my_filter_function($allowed_post_types)
 {


         if( <condition chek>)
         {

         return array('page','<CPT>');
         }


 }
 add_filter('custom_insert_link_suggestion_filter','my_filter_function',10,1);

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21033>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list