Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* #### Nieuw filter #### */
- /* Filteren op gearchiveerde producten (back-end)*/
- add_action( 'restrict_manage_posts', 'filter002_admin_posts_filter_restrict_manage_posts' );
- function filter002_admin_posts_filter_restrict_manage_posts(){
- $type = 'product';
- if (isset($_GET['post_type'])) {
- $type = $_GET['post_type'];
- }
- if ('product' == $type){
- $values = array(
- 'Zichtbaar' => 'visible',
- 'Gearchiveerd' => 'hidden',
- );
- ?>
- <select name="Stock">
- <option value=""><?php _e('Archief', 'filter002'); ?></option>
- <?php
- $current_v = isset($_GET['Stock'])? $_GET['Stock']:'';
- foreach ($values as $label => $value) {
- printf
- (
- '<option value="%s"%s>%s</option>',
- $value,
- $value == $current_v? ' selected="selected"':'',
- $label
- );
- }
- ?>
- </select>
- <?php
- }
- }
- add_filter( 'parse_query', 'filter002_posts_filter' );
- function filter002_posts_filter( $query ){
- global $pagenow;
- $type = 'product';
- if (isset($_GET['post_type'])) {
- $type = $_GET['post_type'];
- }
- if ( 'product' == $type && is_admin() && $pagenow=='edit.php' && isset($_GET['Stock']) && $_GET['Stock'] != '') {
- $query->query_vars['meta_key'] = '_visibility';
- $query->query_vars['meta_value'] = $_GET['Stock'];
- }
- }
- /* #### Nieuw filter #### */
- /* Add In/Out of Stock Filter to Admin *aanvulling op WooCommerce Sort By Stock* */
- add_action( 'restrict_manage_posts', 'filter001_admin_posts_filter_restrict_manage_posts' );
- function filter001_admin_posts_filter_restrict_manage_posts(){
- $type = 'product';
- if (isset($_GET['post_type'])) {
- $type = $_GET['post_type'];
- }
- if ('product' == $type){
- //change this to the list of values you want to show
- //in 'label' => 'value' format
- $values = array(
- 'Uitverkocht' => 'outofstock',
- 'Op voorraad' => 'instock',
- );
- ?>
- <select name="Stock">
- <option value=""><?php _e('Voorraad', 'filter001'); ?></option>
- <?php
- $current_v = isset($_GET['Stock'])? $_GET['Stock']:'';
- foreach ($values as $label => $value) {
- printf
- (
- '<option value="%s"%s>%s</option>',
- $value,
- $value == $current_v? ' selected="selected"':'',
- $label
- );
- }
- ?>
- </select>
- <?php
- }
- }
- add_filter( 'parse_query', 'filter001_posts_filter' );
- function filter001_posts_filter( $query ){
- global $pagenow;
- $type = 'product';
- if (isset($_GET['post_type'])) {
- $type = $_GET['post_type'];
- }
- if ( 'product' == $type && is_admin() && $pagenow=='edit.php' && isset($_GET['Stock']) && $_GET['Stock'] != '') {
- $query->query_vars['meta_key'] = '_stock_status';
- $query->query_vars['meta_value'] = $_GET['Stock'];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment