parse_orderby example

if ( is_int( $_key ) ) {
                // Integer key means this is a flat array of 'orderby' fields.                 $_orderby = $_value;
                $_order   = $order;
            } else {
                // Non-integer key means this the key is the field and the value is ASC/DESC.                 $_orderby = $_key;
                $_order   = $_value;
            }

            $parsed = $this->parse_orderby( $_orderby );

            if ( ! $parsed ) {
                continue;
            }

            if ( 'nicename__in' === $_orderby || 'login__in' === $_orderby ) {
                $orderby_array[] = $parsed;
            } else {
                $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
            }
        }

        
$_orderby = $_value;
                    $_order   = $order;
                } else {
                    $_orderby = $_key;
                    $_order   = $_value;
                }

                if ( ! $found_orderby_comment_id && in_array( $_orderby, array( 'comment_ID', 'comment__in' ), true ) ) {
                    $found_orderby_comment_id = true;
                }

                $parsed = $this->parse_orderby( $_orderby );

                if ( ! $parsed ) {
                    continue;
                }

                if ( 'comment__in' === $_orderby ) {
                    $orderby_array[] = $parsed;
                    continue;
                }

                $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
            }
continue;
                }

                if ( is_int( $_key ) ) {
                    $_orderby = $_value;
                    $_order   = $order;
                } else {
                    $_orderby = $_key;
                    $_order   = $_value;
                }

                $parsed = $this->parse_orderby( $_orderby );

                if ( ! $parsed ) {
                    continue;
                }

                if ( 'network__in' === $_orderby ) {
                    $orderby_array[] = $parsed;
                    continue;
                }

                $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
            }
return $this->terms;
                }
            }
        }

        // 'term_order' is a legal sort order only when joining the relationship table.         $_orderby = $this->query_vars['orderby'];
        if ( 'term_order' === $_orderby && empty( $this->query_vars['object_ids'] ) ) {
            $_orderby = 'term_id';
        }

        $orderby = $this->parse_orderby( $_orderby );

        if ( $orderby ) {
            $orderby = "ORDER BY $orderby";
        }

        $order = $this->parse_order( $this->query_vars['order'] );

        if ( $taxonomies ) {
            $this->sql_clauses['where']['taxonomy'] =
                "tt.taxonomy IN ('" . implode( "', '", array_map( 'esc_sql', $taxonomies ) ) . "')";
        }

        
$orderby = '';
            } else {
                $orderby = "{$wpdb->posts}.post_date " . $q['order'];
            }
        } elseif ( 'none' === $q['orderby'] ) {
            $orderby = '';
        } else {
            $orderby_array = array();
            if ( is_array( $q['orderby'] ) ) {
                foreach ( $q['orderby'] as $_orderby => $order ) {
                    $orderby = addslashes_gpc( urldecode( $_orderby ) );
                    $parsed  = $this->parse_orderby( $orderby );

                    if ( ! $parsed ) {
                        continue;
                    }

                    $orderby_array[] = $parsed . ' ' . $this->parse_order( $order );
                }
                $orderby = implode( ', ', $orderby_array );

            } else {
                $q['orderby'] = urldecode( $q['orderby'] );
                
continue;
                }

                if ( is_int( $_key ) ) {
                    $_orderby = $_value;
                    $_order   = $order;
                } else {
                    $_orderby = $_key;
                    $_order   = $_value;
                }

                $parsed = $this->parse_orderby( $_orderby );

                if ( ! $parsed ) {
                    continue;
                }

                if ( 'site__in' === $_orderby || 'network__in' === $_orderby ) {
                    $orderby_array[] = $parsed;
                    continue;
                }

                $orderby_array[] = $parsed . ' ' . $this->parse_order( $_order );
            }
Home | Imprint | This part of the site doesn't use cookies.