s the more descriptive, specific name for use within this method. $taxonomy = $object_subtype; /** * Filters the max number of pages for a taxonomy sitemap before it is generated. * * Passing a non-null value will short-circuit the generation, * returning that value instead. * * @since 5.5.0 * * @param int|null $max_num_pages The maximum number of pages. Default null. * @param string $taxonomy Taxonomy name. */ $max_num_pages = apply_filters( 'wp_sitemaps_taxonomies_pre_max_num_pages', null, $taxonomy ); if ( null !== $max_num_pages ) { return $max_num_pages; } $term_count = wp_count_terms( $this->get_taxonomies_query_args( $taxonomy ) ); return (int) ceil( $term_count / wp_sitemaps_get_max_urls( $this->object_type ) ); } /** * Returns the query args for retrieving taxonomy terms to list in the sitemap. * * @since 5.5.0 * * @param string $taxonomy Taxonomy name. * @return array Array of WP_Term_Query arguments. */ protected function get_taxonomies_query_args( $taxonomy ) { /** * Filters the taxonomy terms query arguments. * * Allows modification of the taxonomy query arguments before querying. * * @see WP_Term_Query for a full list of arguments * * @since 5.5.0 * * @param array $args Array of WP_Term_Query arguments. * @param string $taxonomy Taxonomy name. */ $args = apply_filters( 'wp_sitemaps_taxonomies_query_args', array( 'taxonomy' => $taxonomy, 'orderby' => 'term_order', 'number' => wp_sitemaps_get_max_urls( $this->object_type ), 'hide_empty' => true, 'hierarchical' => false, 'update_term_meta_cache' => false, ), $taxonomy ); return $args; } } t. * * @return string */ public function getFullUrl() { return get_site_url() . rtrim($_SERVER['REQUEST_URI'], '/'); } /** * Validate the request. * * @param string $key * @return mixed */ public function validate(array $rules, array $messages = []) { $instance = $this->app->make('validator'); $validator = $instance->make($data = $this->all(), $rules, $messages); if ($validator->validate()->fails()) { throw new ValidationException( 'Unprocessable Entity!', 422, null, $validator->errors() ); } $this->validated = $validator->validated(); return $data; } /** * Get the valid data after validation has been passed. * * @return array */ public function validated($data = []) { if ($data) { return $this->validated = $data; } return (array) $this->validated; } /** * Abort the request. * * @param integer $status * @param string $message * @return \WP_REST_Response */ public function abort($status = 403, $message = null) { if (is_object($status)) { if (method_exists($status, 'errors')) { throw new ValidationException( 'Unprocessable Entity!', 422, null, $status->errors() ); } } if (!$message && !is_numeric($status) && is_string($status)) { $message = $status; $status = 403; } $message = $message ?: 'Request has benn aborted.'; return new \WP_REST_Response( is_array($message) ? $message : ['message' => (string) $message], $status ); } /** * Get an input element from the request. * * @param string $key * @return mixed */ public function __get($key) { return $this->get($key); } /** * Retrieves the currently logged in user. * * @return \NinjaTables\Framework\Http\Request\WPUserProxy */ public function user() { return new WPUserProxy( new \WP_User(get_current_user_id()) ); } /** * Dynamyc method calls (specially for WP_rest_request) * @param string $method * @param array $params * @return mixed */ public function __call($method, $params = []) { if (static::hasMacro($method)) { return $this->macroCall($method, $params); } if ($method == 'route') { if ($params) { return $this->app->route->{$params[0]}; } return $this->app->route; } if ($this->app->bound('wprestrequest')) { if (!method_exists($this->app->wprestrequest, $method)) { $method = strtolower( preg_replace([ '/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/' ], '$1_$2', $method) ); } return call_user_func_array([ $this->app->wprestrequest, $method], $params ); } } }