Allow only preset options for number of posts per page
-
Dear author,
currently you can set any number of posts per page via a request and/or cookie which can be used to overload big sites with the parameter set to -1. The solution would be to check if $per_page in loop_shop_per_page is in $products_per_page_options array.
Example solution (needs testing & review):
public function loop_shop_per_page( $per_page ) { $per_page_default = intval( get_option( 'wppp_default_ppp', '12' ) ); $products_per_page_options = explode( ' ', apply_filters( 'wppp_products_per_page', get_option( 'wppp_dropdown_options' ) ) ); if ( isset( $_REQUEST['wppp_ppp'] ) ) : $per_page = intval( $_REQUEST['wppp_ppp'] ); elseif ( isset( $_REQUEST['ppp'] ) ) : $per_page = intval( $_REQUEST['ppp'] ); elseif ( isset( $_COOKIE['woocommerce_products_per_page'] ) ) : $per_page = intval( $_COOKIE['woocommerce_products_per_page'] ); else : $per_page = $per_page_default; endif; if (!in_array($per_page, $products_per_page_options) ) : $per_page = $per_page_default; endif; return $per_page; }
Please consider implementing this limitation.
Best regards,
Andrej
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Allow only preset options for number of posts per page’ is closed to new replies.