PluginProbe
WPGraphQL / trunk
WPGraphQL vtrunk
2.22.3 2.22.2 2.22.1 2.22.0 2.21.1 2.21.0 2.20.0 2.19.0 2.18.0 2.17.0 2.16.0 2.15.1 2.15.0 2.14.1 2.14.0 2.13.0 2.2.0 2.3.0 2.3.3 2.3.6 2.3.8 2.5.0 2.5.1 2.5.2 2.5.3 All 177 releases
wp-graphql / src / Data / Connection / ThemeConnectionResolver.php

ThemeConnectionResolver.php in WPGraphQL trunk, at src/Data/Connection/ThemeConnectionResolver.php

65 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WPGraphQL\Data\Connection;
3
4 /**
5 * Class ThemeConnectionResolver
6 *
7 * @package WPGraphQL\Data\Resolvers
8 * @since 0.5.0
9 * @extends \WPGraphQL\Data\Connection\AbstractConnectionResolver<string[]>
10 */
11 class ThemeConnectionResolver extends AbstractConnectionResolver {
12 /**
13 * {@inheritDoc}
14 */
15 public function get_ids_from_query() {
16 /**
17 * @todo This is for b/c. We can just use $this->get_query().
18 */
19 $queried = isset( $this->query ) ? $this->query : $this->get_query();
20
21 $ids = [];
22
23 if ( empty( $queried ) ) {
24 return $ids;
25 }
26
27 foreach ( $queried as $key => $item ) {
28 $ids[ $key ] = $item;
29 }
30
31 return $ids;
32 }
33
34 /**
35 * {@inheritDoc}
36 */
37 protected function prepare_query_args( array $args ): array {
38 return [
39 'allowed' => null,
40 ];
41 }
42
43 /**
44 * {@inheritDoc}
45 */
46 protected function query( array $query_args ) {
47 return array_keys( wp_get_themes( $query_args ) );
48 }
49
50 /**
51 * {@inheritDoc}
52 */
53 protected function loader_name(): string {
54 return 'theme';
55 }
56
57 /**
58 * {@inheritDoc}
59 */
60 public function is_valid_offset( $offset ) {
61 $theme = wp_get_theme( $offset );
62 return $theme->exists();
63 }
64 }
65