@@ -64,8 +64,11 @@ private function get_addable_query($args) {
6464 if ( !empty ( $ this ->args ['post__in ' ] ) ) {
6565 $ defaults ['post__in ' ] = $ this ->args ['post__in ' ];
6666 }
67-
67+ if ( isset ( $ this ->args ['post_per_page ' ] ) && ( $ this ->args ['post_per_page ' ] > 100 || $ this ->args ['post_per_page ' ] === -1 ) ) {
68+ $ this ->args ['post_per_page ' ] = 10 ;
69+ }
6870 $ query_args = wp_parse_args ($ args , $ defaults );
71+
6972 return new WP_Query ($ query_args );
7073 }
7174
@@ -83,30 +86,30 @@ public function render_addable_rows($wp_query) {
8386
8487 $ title = esc_html (get_the_title ($ post ->ID ));
8588
86- $ row_actions = '' ;
89+ $ safe_row_actions = '' ;
8790 $ post_type_object = get_post_type_object ( get_post_type ($ post ->ID ));
8891 $ can_edit = current_user_can ( $ post_type_object ->cap ->edit_post , $ post ->ID );
8992
9093 if ( $ can_edit ) {
91- $ row_actions .= sprintf ('<span class="edit"><a title="Edit this item" href="%s">Edit</a> | </span> ' , get_edit_post_link ( $ post ->ID ));
94+ $ safe_row_actions .= sprintf ('<span class="edit"><a title="Edit this item" href="%s">Edit</a> | </span> ' , esc_url ( get_edit_post_link ( $ post ->ID ) ));
9295 }
9396
9497 if ( $ post_type_object ->publicly_queryable ) {
9598 if ( ($ can_edit || !in_array ( $ post ->post_status , array ( 'pending ' , 'draft ' , 'future ' ) ) )
9699 && ( $ post ->post_status != 'trash ' ) ) {
97- $ row_actions .= sprintf ('<span class="view"><a rel="permalink" title="View %s" href="%s">View</a></span> ' , esc_attr (get_the_title ($ post ->ID )), esc_url (get_permalink ($ post ->ID )));
100+ $ safe_row_actions .= sprintf ('<span class="view"><a rel="permalink" title="View %s" href="%s">View</a></span> ' , esc_attr (get_the_title ($ post ->ID )), esc_url (get_permalink ($ post ->ID )));
98101 }
99102 }
100103
101- if ($ row_actions ) {
102- $ title .= '<div class="psu-row-actions"> ' .$ row_actions .'</div> ' ;
104+ if ($ safe_row_actions ) {
105+ $ title .= '<div class="psu-row-actions"> ' .$ safe_row_actions .'</div> ' ;
103106 }
104107
105108 $ title = apply_filters ('post-selection-ui-row-title ' , $ title , $ post ->ID , $ this ->name , $ this ->args );
106- $ output .= "<tr data-post_id=' {$ post ->ID }' data-title=' " . esc_attr (get_the_title ($ post ->ID )) ."' data-permalink=' " . get_permalink ($ post ->ID ) . "'> \n" .
109+ $ output .= "<tr data-post_id=' {$ post ->ID }' data-title=' " . esc_attr (get_the_title ($ post ->ID )) ."' data-permalink=' " . esc_url ( get_permalink (intval ( $ post ->ID )) ) . "'> \n" .
107110 "\t<td class='psu-col-create'><a href='#' title='Add'></a></td> " .
108111 "\t<td class='psu-col-title'> \n" ;
109- $ output .= $ title ;
112+ $ output .= wp_kses_post ( $ title ) ;
110113 $ output .= "\n\t</td> \n</tr> \n" ;
111114 }
112115 return $ output ;
@@ -128,23 +131,23 @@ private function render_selected_rows($post_ids) {
128131
129132 $ title = esc_html ( get_the_title ( $ post_id ) );
130133
131- $ row_actions = '' ;
134+ $ safe_row_actions = '' ;
132135 $ can_edit = current_user_can ( get_post_type_object ( get_post_type ($ post_id ) )->cap ->edit_post , $ post_id );
133136 $ post_type_object = get_post_type_object ( get_post_type ($ post_id ));
134137
135138 if ( $ can_edit ) {
136- $ row_actions .= sprintf ('<span class="edit"><a title="Edit this item" href="%s">Edit</a></span> ' , get_edit_post_link ( $ post_id ));
139+ $ safe_row_actions .= sprintf ('<span class="edit"><a title="Edit this item" href="%s">Edit</a></span> ' , esc_url ( get_edit_post_link ( $ post_id ) ));
137140 }
138141
139142 if ( $ post_type_object ->publicly_queryable ) {
140143 if ( ($ can_edit || !in_array ( get_post ($ post_id )->post_status , array ( 'pending ' , 'draft ' , 'future ' ) ) )
141144 && ( get_post ($ post_id )->post_status != 'trash ' ) ) {
142- $ row_actions .= sprintf ('| <span class="view"><a rel="permalink" title="View %s" href="%s">View</a></span> ' , esc_attr (get_the_title ($ post_id )), esc_url (get_permalink ($ post_id )));
145+ $ safe_row_actions .= sprintf ('| <span class="view"><a rel="permalink" title="View %s" href="%s">View</a></span> ' , esc_attr (get_the_title ($ post_id )), esc_url (get_permalink ($ post_id )));
143146 }
144147 }
145148
146- if ($ row_actions ) {
147- $ title .= '<div class="psu-row-actions"> ' .$ row_actions .'</div> ' ;
149+ if ($ safe_row_actions ) {
150+ $ title .= '<div class="psu-row-actions"> ' .$ safe_row_actions .'</div> ' ;
148151 }
149152
150153 $ title = apply_filters ('post-selection-ui-row-title ' , $ title , $ post_id , $ this ->name , $ this ->args );
@@ -173,9 +176,9 @@ public function render_results($args) {
173176 "<div class='psu-navigation'> \n" .
174177 "\t<div class='psu-prev button inactive' title='previous'>‹</div> " .
175178 "\t<div> \n" .
176- "\t\t<span class='psu-current' data-num=' " .$ cpage ."'> " .$ cpage ."</span> \n" .
179+ "\t\t<span class='psu-current' data-num=' " .esc_attr ( $ cpage ) ."'> " .esc_html ( $ cpage ) ."</span> \n" .
177180 "\t\tof \n" .
178- "\t\t<span class='psu-total' data-num=' " .$ max_pages ."'> " .$ max_pages ."</span> \n" .
181+ "\t\t<span class='psu-total' data-num=' " .esc_attr ( $ max_pages ) ."'> " .esc_html ( $ max_pages ) ."</span> \n" .
179182 "\t</div> \n" .
180183 "\t<div class='psu-next button ' title='next'>›</div> \n" .
181184 "</div> \n" ;
@@ -207,7 +210,7 @@ public function render() {
207210 <th class="psu-col-delete"><a href="#" title="<?php printf (__ ("Remove all %s " ), $ this ->args ['labels ' ]['name ' ]) ?> "></a></th>
208211 <th class="psu-col-title"><?php echo esc_html ($ this ->args ['labels ' ]['singular_name ' ]); ?> </th>
209212 <?php if ($ this ->args ['sortable ' ]) : ?>
210- <th class="psu-col-order"><?php _e ('Sort ' ); ?> </th>
213+ <th class="psu-col-order"><?php html_esc_e ('Sort ' ); ?> </th>
211214 <?php endif ; ?>
212215 </tr>
213216 </thead>
0 commit comments