├── .coveralls.yml
├── .distignore
├── .editorconfig
├── .env.dist
├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── .phpcs.ruleset.xml
├── .travis.yml
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── PULL_REQUEST_TEMPLATE.md
├── README.md
├── README.txt
├── bin
├── install-wp-tests.sh
└── testing-entrypoint.sh
├── class-inflect.php
├── codeception.dist.yml
├── composer.json
├── includes
├── class-core-schema-filters.php
├── class-ql-search.php
├── class-type-registry.php
├── connection
│ └── class-swp.php
├── data
│ ├── class-factory.php
│ ├── connection
│ │ └── class-swp-connection-resolver.php
│ └── cursor
│ │ └── class-swp-query-cursor.php
└── type
│ ├── enum
│ ├── class-meta-compare.php
│ ├── class-meta-type.php
│ ├── class-tax-query-field.php
│ └── class-tax-query-operator.php
│ └── input
│ ├── class-meta-array-input.php
│ ├── class-meta-query-input.php
│ ├── class-tax-array-input.php
│ └── class-tax-query-input.php
├── logo.svg
├── phpunit.xml.dist
├── ql-search.php
├── tests
├── _data
│ ├── .gitignore
│ ├── .gitkeep
│ └── config.php
├── _output
│ └── .gitignore
├── _support
│ ├── AcceptanceTester.php
│ ├── FunctionalTester.php
│ ├── Helper
│ │ ├── Acceptance.php
│ │ ├── Functional.php
│ │ └── Wpunit.php
│ ├── WpunitTester.php
│ └── _generated
│ │ └── .gitignore
├── acceptance.suite.dist.yml
├── functional.suite.dist.yml
├── wpunit.suite.dist.yml
└── wpunit
│ ├── SWPPaginationTest.php
│ ├── SWPQueriesTest.php
│ └── bootstrap.php
└── vendor
├── autoload.php
└── composer
├── ClassLoader.php
├── LICENSE
├── autoload_classmap.php
├── autoload_namespaces.php
├── autoload_psr4.php
├── autoload_real.php
└── autoload_static.php
/.coveralls.yml:
--------------------------------------------------------------------------------
1 | service_name: travis-ci
2 | coverage_clover: tests/_output/coverage.xml
3 | json_path: tests/_output/coverage.json
--------------------------------------------------------------------------------
/.distignore:
--------------------------------------------------------------------------------
1 | # A set of files you probably don't want in your WordPress.org distribution
2 | .distignore
3 | .editorconfig
4 | .git
5 | .gitignore
6 | .gitlab-ci.yml
7 | .travis.yml
8 | .DS_Store
9 | Thumbs.db
10 | behat.yml
11 | bitbucket-pipelines.yml
12 | bin
13 | .circleci/config.yml
14 | composer.json
15 | composer.lock
16 | Gruntfile.js
17 | package.json
18 | package-lock.json
19 | phpunit.xml
20 | phpunit.xml.dist
21 | multisite.xml
22 | multisite.xml.dist
23 | .phpcs.xml
24 | phpcs.xml
25 | .phpcs.xml.dist
26 | phpcs.xml.dist
27 | README.md
28 | wp-cli.local.yml
29 | yarn.lock
30 | tests
31 | vendor
32 | node_modules
33 | *.sql
34 | *.tar.gz
35 | *.zip
36 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # This file is for unifying the coding style for different editors and IDEs
2 | # editorconfig.org
3 |
4 | # WordPress Coding Standards
5 | # https://make.wordpress.org/core/handbook/coding-standards/
6 |
7 | root = true
8 |
9 | [*]
10 | charset = utf-8
11 | end_of_line = lf
12 | insert_final_newline = true
13 | trim_trailing_whitespace = true
14 | indent_style = tab
15 | indent_size = 4
16 |
17 | [{.jshintrc,*.json,*.yml}]
18 | indent_style = space
19 | indent_size = 2
20 |
21 | [{*.txt,wp-config-sample.php}]
22 | end_of_line = crlf
23 |
--------------------------------------------------------------------------------
/.env.dist:
--------------------------------------------------------------------------------
1 | TEST_DB_NAME="qlsearch_tests"
2 | TEST_DB_HOST="127.0.0.1"
3 | TEST_DB_USER="root"
4 | TEST_DB_PASSWORD=""
5 |
6 | # Install script
7 | WP_VERSION=latest
8 | SKIP_DB_CREATE=false
9 |
10 | # Codeception
11 | WP_ROOT_FOLDER="/tmp/ql-search/wordpress"
12 | WP_ADMIN_PATH="/wp-admin"
13 | DB_NAME="qlsearch_tests"
14 | DB_HOST=127.0.0.1
15 | DB_USER="root"
16 | DB_PASSWORD=""
17 | WP_TABLE_PREFIX="wp_"
18 | WP_URL="http://wp.test"
19 | WP_DOMAIN="wp.test"
20 | ADMIN_EMAIL="admin@wp.test"
21 | ADMIN_USERNAME="admin"
22 | ADMIN_PASSWORD="password"
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | phpcs.xml
3 | phpunit.xml
4 | Thumbs.db
5 | wp-cli.local.yml
6 | node_modules/
7 | *.sql
8 | *.tar.gz
9 | *.zip
10 | .env
11 | .env.*
12 | !.env.dist
13 | .idea
14 | .vscode
15 | .github_changelog_generator
16 | !vendor/
17 | vendor/*
18 | !vendor/autoload.php
19 | !vendor/composer
20 | vendor/composer/installed.json
21 | vendor/composer/*/
22 | !tests
23 | tests/*.suite.yml
24 | build/
25 | coverage/*
26 | schema.graphql
27 | phpunit.xml
28 | docker-output
29 | composer.lock
30 | c3.php
31 | .log/
32 | php-coveralls.phar
33 | codeception.yml
34 |
--------------------------------------------------------------------------------
/.phpcs.ruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Generally-applicable sniffs for WordPress plugins.
4 |
5 |
6 | .
7 | /vendor/
8 | /node_modules/
9 | /tests/
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | dist: trusty
3 |
4 | language: php
5 |
6 | notifications:
7 | email:
8 | on_success: never
9 | on_failure: change
10 |
11 | branches:
12 | only:
13 | - master
14 |
15 | cache:
16 | directories:
17 | - vendor
18 | - $HOME/.composer/cache
19 |
20 | matrix:
21 | include:
22 | - php: 7.3
23 | env: PHP_VERSION=7.3 WP_VERSION=latest
24 | - php: 7.2
25 | env: PHP_VERSION=7.2 WP_VERSION=latest
26 | - php: 7.2
27 | env: PHP_VERSION=7.2 WP_TRAVISCI=phpcs
28 | - php: 7.1
29 | env: PHP_VERSION=7.1 WP_VERSION=latest
30 | - php: 7.0
31 | env: PHP_VERSION=7.0 WP_VERSION=latest
32 | - php: 7.0
33 | env: PHP_VERSION=7.0 WP_VERSION=trunk
34 | - php: 5.6
35 | env: PHP_VERSION=5.6 WP_VERSION=5.0
36 | - php: 5.6
37 | env: PHP_VERSION=5.6 WP_VERSION=4.9
38 | allow_failures:
39 | - env: PHP_VERSION=5.6 WP_VERSION=5.0
40 | - env: PHP_VERSION=5.6 WP_VERSION=4.9
41 |
42 |
43 | install:
44 | - |
45 | cd $TRAVIS_BUILD_DIR
46 | curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
47 | chmod +x wp-cli.phar
48 | sudo mv wp-cli.phar /usr/local/bin/wp
49 |
50 | before_script:
51 | - export PATH="$HOME/.composer/vendor/bin:$PATH"
52 | - |
53 | if [[ ! -z "$WP_VERSION" ]]; then
54 | cp .env.dist .env
55 | composer install-wp-tests
56 | COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --prefer-source --no-interaction
57 | fi
58 | - |
59 | if [[ "$WP_TRAVISCI" == "phpcs" ]]; then
60 | COMPOSER_MEMORY_LIMIT=-1 travis_retry composer require \
61 | squizlabs/php_codesniffer \
62 | phpcompatibility/phpcompatibility-wp wp-coding-standards/wpcs \
63 | dealerdirect/phpcodesniffer-composer-installer
64 | COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --no-dev
65 | fi
66 |
67 | script:
68 | - |
69 | if [[ ! -z "$WP_VERSION" ]]; then
70 | vendor/bin/codecept run wpunit
71 | fi
72 | - |
73 | if [[ "$WP_TRAVISCI" == "phpcs" ]]; then
74 | vendor/bin/phpcs \
75 | ql-search.php \
76 | includes/*.php --standard=WordPress
77 | fi
78 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## [v0.3.0-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.3.0-beta) (2019-10-25)
4 |
5 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.2.2-beta...v0.3.0-beta)
6 |
7 | **Merged pull requests:**
8 |
9 | - Release-v0.2.2 [\#154](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/154) ([kidunot89](https://github.com/kidunot89))
10 |
11 | ## [v0.2.2-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.2.2-beta) (2019-10-24)
12 |
13 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.2.1-beta...v0.2.2-beta)
14 |
15 | **Enhancements:**
16 |
17 | - Sorting of products, Categories etc [\#138](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/138)
18 | - Accessing meta\_data product property? [\#121](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/121)
19 | - Improved ordering for some connections [\#145](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/145) ([kidunot89](https://github.com/kidunot89))
20 | - "product\_connection\_catalog\_visibility" hook implemented. [\#142](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/142) ([kidunot89](https://github.com/kidunot89))
21 | - "format" arg added to Product description fields [\#139](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/139) ([kidunot89](https://github.com/kidunot89))
22 |
23 | **Fixed:**
24 |
25 | - Ajax call /?wc-ajax=get\_refreshed\_fragments clears cart when plugin installed [\#143](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/143)
26 | - subcategory shows empty when image field is present [\#140](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/140)
27 | - Extension breaks the hierarchy between pages [\#122](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/122)
28 | - Order id undefined [\#119](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/119)
29 | - categoryNameIn not filtering [\#116](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/116)
30 | - Fixes product taxonomy hierachy resolution [\#150](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/150) ([kidunot89](https://github.com/kidunot89))
31 | - Adds WPGraphQL JWT Auth fields to Customer type and mutations [\#148](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/148) ([kidunot89](https://github.com/kidunot89))
32 | - Escape hatch added on non-GraphQL requests. [\#146](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/146) ([kidunot89](https://github.com/kidunot89))
33 | - Release v0.2.1 [\#114](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/114) ([kidunot89](https://github.com/kidunot89))
34 |
35 | **Closed issues:**
36 |
37 | - Order Creation directly [\#149](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/149)
38 | - Customer checkout and order mutations are not working [\#147](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/147)
39 | - Price Type, and name not showing up for product as Typed values [\#137](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/137)
40 | - Add AND and OR statement to where clause. [\#120](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/120)
41 |
42 | **Merged pull requests:**
43 |
44 | - FUNDING.yml added. [\#151](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/151) ([kidunot89](https://github.com/kidunot89))
45 | - CONTRIBUTING.md added [\#144](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/144) ([kidunot89](https://github.com/kidunot89))
46 | - v0.2.1 hotfix to develop [\#135](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/135) ([kidunot89](https://github.com/kidunot89))
47 |
48 | ## [v0.2.1-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.2.1-beta) (2019-08-27)
49 |
50 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.2.0-beta...v0.2.1-beta)
51 |
52 | **Breaking changes:**
53 |
54 | - Release v0.2.0 [\#96](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/96) ([kidunot89](https://github.com/kidunot89))
55 |
56 | **Enhancements:**
57 |
58 | - Hooks for mutations [\#108](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/108)
59 | - productBy query should support querying by slug [\#95](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/95)
60 | - Support update of multiple quantities in cart in a single mutation [\#94](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/94)
61 | - Other mutations [\#19](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/19)
62 | - Order mutations [\#16](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/16)
63 |
64 | **Fixed:**
65 |
66 | - customerRegister mutation resolves wrong object for `viewer` field [\#111](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/111)
67 | - I cant see the category thumbnail [\#93](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/93)
68 | - Session header bugfix [\#113](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/113) ([kidunot89](https://github.com/kidunot89))
69 |
70 | ## [v0.2.0-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.2.0-beta) (2019-07-11)
71 |
72 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.1.2-beta...v0.2.0-beta)
73 |
74 | **Fixed:**
75 |
76 | - Custom attributes of variable products cannot be queried. [\#87](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/87)
77 | - Release v0.1.2 [\#86](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/86) ([kidunot89](https://github.com/kidunot89))
78 |
79 | **Closed issues:**
80 |
81 | - Customer id doesn't match user id [\#90](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/90)
82 |
83 | **Merged pull requests:**
84 |
85 | - CHANGELOG updated [\#92](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/92) ([kidunot89](https://github.com/kidunot89))
86 |
87 | ## [v0.1.2-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.1.2-beta) (2019-06-23)
88 |
89 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.1.1-beta...v0.1.2-beta)
90 |
91 | **Fixed:**
92 |
93 | - Release v0.1.1 [\#81](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/81) ([kidunot89](https://github.com/kidunot89))
94 |
95 | **Closed issues:**
96 |
97 | - Tests needed [\#46](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/46)
98 |
99 | ## [v0.1.1-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.1.1-beta) (2019-06-06)
100 |
101 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.1.0-beta...v0.1.1-beta)
102 |
103 | **Breaking changes:**
104 |
105 | - Release v0.1.0 [\#54](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/54) ([kidunot89](https://github.com/kidunot89))
106 |
107 | **Enhancements:**
108 |
109 | - Add format argument to product pricing fields [\#75](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/75)
110 | - Customer mutations [\#48](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/48)
111 | - Cart mutations [\#18](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/18)
112 |
113 | **Fixed:**
114 |
115 | - Provide guest user authentication [\#79](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/79)
116 | - Codeception versioning problem in Travis-CI build [\#77](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/77) ([kidunot89](https://github.com/kidunot89))
117 |
118 | **Closed issues:**
119 |
120 | - Release v0.1.0 Summary [\#74](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/74)
121 |
122 | ## [v0.1.0-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.1.0-beta) (2019-05-11)
123 |
124 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.0.4-beta...v0.1.0-beta)
125 |
126 | **Closed issues:**
127 |
128 | - Release v0.0.4 Summary [\#66](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/66)
129 |
130 | **Merged pull requests:**
131 |
132 | - Release v0.0.4 [\#65](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/65) ([kidunot89](https://github.com/kidunot89))
133 |
134 | ## [v0.0.4-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.0.4-beta) (2019-05-10)
135 |
136 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.0.3-beta...v0.0.4-beta)
137 |
138 | **Enhancements:**
139 |
140 | - Add filter for restricted\_cap in models [\#51](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/51)
141 | - Add name to ProductVariation [\#41](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/41)
142 | - Cart type and queries [\#12](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/12)
143 | - Adds "\*\_restricted\_cap" filters [\#53](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/53) ([kidunot89](https://github.com/kidunot89))
144 | - ProductAttribute completion [\#50](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/50) ([kidunot89](https://github.com/kidunot89))
145 |
146 | **Fixed:**
147 |
148 | - Query products by categories returns an empty array. [\#44](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/44)
149 | - More ProductVariation fields [\#49](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/49) ([kidunot89](https://github.com/kidunot89))
150 | - Bugfix/\#44 [\#45](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/45) ([kidunot89](https://github.com/kidunot89))
151 |
152 | **Merged pull requests:**
153 |
154 | - to v0.0.3 [\#43](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/43) ([kidunot89](https://github.com/kidunot89))
155 |
156 | ## [v0.0.3-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.0.3-beta) (2019-04-25)
157 |
158 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/v0.0.2-beta...v0.0.3-beta)
159 |
160 | **Enhancements:**
161 |
162 | - Cart-type and queries and customer query [\#30](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/30) ([kidunot89](https://github.com/kidunot89))
163 |
164 | **Fixed:**
165 |
166 | - Pagination broken [\#29](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/29)
167 | - Pagination fix for CPT-backed CRUD objects connections [\#36](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/36) ([kidunot89](https://github.com/kidunot89))
168 |
169 | **Closed issues:**
170 |
171 | - Unsetting "object\_ids" on all connections [\#39](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/39)
172 |
173 | **Merged pull requests:**
174 |
175 | - Master [\#35](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/35) ([kidunot89](https://github.com/kidunot89))
176 |
177 | ## [v0.0.2-beta](https://github.com/wp-graphql/wp-graphql-woocommerce/tree/v0.0.2-beta) (2019-04-22)
178 |
179 | [Full Changelog](https://github.com/wp-graphql/wp-graphql-woocommerce/compare/0db77c26ab463e6203df99eed2679f79ce3e4d60...v0.0.2-beta)
180 |
181 | **Enhancements:**
182 |
183 | - TaxClass type [\#27](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/27)
184 | - Order-Item type queries [\#13](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/13)
185 | - Order items, TaxRate, and ShippingMethod [\#28](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/28) ([kidunot89](https://github.com/kidunot89))
186 | - Where args for Coupon, Order, and Refund connections [\#24](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/24) ([kidunot89](https://github.com/kidunot89))
187 | - Testing and CI renovation [\#21](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/21) ([kidunot89](https://github.com/kidunot89))
188 | - WPGraphQL v0.3.0 migration [\#9](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/9) ([kidunot89](https://github.com/kidunot89))
189 |
190 | **Fixed:**
191 |
192 | - no queries work [\#31](https://github.com/wp-graphql/wp-graphql-woocommerce/issues/31)
193 | - after\_success script added [\#32](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/32) ([kidunot89](https://github.com/kidunot89))
194 | - Polishing Product types and connections [\#22](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/22) ([kidunot89](https://github.com/kidunot89))
195 |
196 | **Merged pull requests:**
197 |
198 | - Formatting code to WordPress Coding Standards [\#8](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/8) ([kidunot89](https://github.com/kidunot89))
199 | - Feature/Product type [\#7](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/7) ([kidunot89](https://github.com/kidunot89))
200 | - Feature/coupon type [\#6](https://github.com/wp-graphql/wp-graphql-woocommerce/pull/6) ([kidunot89](https://github.com/kidunot89))
201 |
202 |
203 |
204 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at geoffrey.taylor@outlook.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contribute to WPGraphQL WooCommerce
2 |
3 | QLSearch welcomes community contributions, bug reports and other constructive feedback.
4 |
5 | When contributing please ensure you follow the guidelines below so that we can keep on top of things.
6 |
7 | ## Getting Started
8 |
9 | * __Do not report potential security vulnerabilities here. Email them privately to our security team at
10 | [team-email](mailto:team-email)__
11 | * Before submitting a ticket, please be sure to replicate the behavior with no other plugins active and on a base theme like Twenty Seventeen.
12 | * Submit a ticket for your issue, assuming one does not already exist.
13 | * Raise it on our [Issue Tracker](https://github.com/funkhaus/ql-search/issues)
14 | * Clearly describe the issue including steps to reproduce the bug.
15 | * Make sure you fill in the earliest version that you know has the issue as well as the version of WordPress you're using.
16 |
17 | ## Making Changes
18 |
19 | * Fork the repository on GitHub
20 | * Make the changes to your forked repository
21 | * Ensure you stick to the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards)
22 | * When committing, reference your issue (if present) and include a note about the fix
23 | * If possible, and if applicable, please also add/update unit tests for your changes
24 | * Push the changes to your fork and submit a pull request to the 'develop' branch of this repository
25 |
26 | ## Code Documentation
27 |
28 | * We strive for full doc coverage and follow the standards set by phpDoc
29 | * Please make sure that every function is documented so that when we update our API Documentation things don't go awry!
30 | * If you're adding/editing a function in a class, make sure to add `@access {private|public|protected}`
31 | * Finally, please use tabs and not spaces.
32 |
33 | At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary.
34 |
35 | > **NOTE:** This CONTRIBUTING.md file was forked from [WPGraphQL](https://github.com/wp-graphql/wp-graphql/blob/master/CONTRIBUTING.md)
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Your checklist for this pull request
2 | Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.
3 |
4 | 🚨Please review the [guidelines for contributing](./CONTRIBUTING.md) to this repository.
5 |
6 | - [ ] Make sure you are making a pull request against the **develop branch** (left side). Also you should start *your branch* off *our develop*.
7 | - [ ] Make sure you are requesting to pull request from a **topic/feature/bugfix branch** (right side). Don't pull request from your master!
8 |
9 | What does this implement/fix? Explain your changes.
10 | ---------------------------------------------------
11 | …
12 |
13 |
14 | Does this close any currently open issues?
15 | ------------------------------------------
16 | …
17 |
18 |
19 | Any relevant logs, error output, GraphiQL screenshots, etc?
20 | -------------------------------------
21 | (If it’s long, please paste to https://ghostbin.com/ and insert the link here.)
22 |
23 |
24 | Any other comments?
25 | -------------------
26 | …
27 |
28 |
29 | Where has this been tested?
30 | ---------------------------
31 | **Operating System:** …
32 |
33 | **WordPress Version:** …
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QL Search
2 | [](https://travis-ci.org/funkhaus/ql-search)
3 |
4 | ## What is QL Search?
5 | An extension that integrates [SearchWP](https://searchwp.com) into [WPGraphQL](https://www.wpgraphql.com).
6 |
7 | ## Quick Install
8 | 1. Install & activate [SearchWP *v3.1.9+*](https://searchwp.com)
9 | 2. Install & activate [WPGraphQL *v0.5.0+*](https://www.wpgraphql.com)
10 | 3. Clone or download the zip of this repository into your WordPress plugin directory & activate the plugin.
11 |
12 | ## Features
13 | - Search across multiple post-types.
14 | - Filter taxonomy, meta, date, and more...
15 |
16 | ## Some Examples
17 | ### Query multiple types with a single `input`.
18 | ```
19 | query {
20 | searchWP(first: 5, where: { input: "Hello World" }) {
21 | nodes {
22 | ... on Post {
23 | id
24 | }
25 | ... on Page {
26 | id
27 | }
28 | }
29 | }
30 | }
31 | ```
32 | The `input` parameter is the base search field, and request on all `searchWP` queries.
33 |
34 | ### Query with an alternative `engine`.
35 | ```
36 | query {
37 | searchWP(first: 5, where: { input: "Hello World", engine: "other-engine-slug" }) {
38 | nodes {
39 | ... on Post {
40 | id
41 | ... more post fields
42 | }
43 | ... on Page {
44 | id
45 | ... more page fields
46 | }
47 | }
48 | }
49 | }
50 | ```
51 | The `engine` parameter by default is set to *default*. An important thing to remember is that in order for a post-type to be returned as an `searchWP` result be enable on the **SearchWP** engine, Find out more about SearchWP's engine configuration [here](https://searchwp.com/docs/configuration/), and it must have `exclude_from_search` set to `false` and `show_in_graphql` set to `true` in it's **Post-type** configurations.
52 |
53 | ### Query by `taxonomies`.
54 | ```
55 | query {
56 | searchWP(first: 5, where: { input: "Hello World", taxonomies: { taxArray: [{ taxonomy: TAG, field: SLUG, terms: "test_tag" }] } }) {
57 | nodes {
58 | ... on Post {
59 | id
60 | ... more post fields
61 | }
62 | ... on Page {
63 | id
64 | ... more page fields
65 | }
66 | }
67 | }
68 | }
69 | ```
70 | The `taxonomies` parameter is designed to be identical to the enhanced `taxQuery` parameter used by **[WPGraphQL Tax Query](https://github.com/wp-graphql/wp-graphql-tax-query)**. Another important thing to remember about **SearchWP** and by relation **QL Search**, is that in order to query a specific taxonomy, that taxonomy must be given a weight on the *engine* being used. In the cause of the query above that is the default engine. Find out more about SearchWP's engine configuration [here](https://searchwp.com/docs/configuration/).
71 |
72 | ### Query by `meta`.
73 | ```
74 | query {
75 | searchWP(first: 5, where: { input: "Hello World", meta: { metaArray: [{ key: "test_meta", value: "meta value", compare: EQUAL_TO }] } }) {
76 | nodes {
77 | ... on Post {
78 | id
79 | ... more post fields
80 | }
81 | ... on Page {
82 | id
83 | ... more page fields
84 | }
85 | }
86 | }
87 | }
88 | ```
89 | The `meta` parameter is designed to be identical to the enhanced `metaQuery` parameter used by **[WPGraphQL Meta Query](https://github.com/wp-graphql/wp-graphql-meta-query)**.
90 |
91 | ### Query by `date`.
92 | ```
93 | query {
94 | searchWP(first: 5, where: { input: "Hello World", date: [{ year: 1970, month: 1, day: 1 }] }) {
95 | nodes {
96 | ... on Post {
97 | id
98 | ... more post fields
99 | }
100 | ... on Page {
101 | id
102 | ... more page fields
103 | }
104 | }
105 | }
106 | }
107 | ```
108 | The `date` parameter is designed to be identical to the `date` parameter on the core [WPGraphQL](https://github.com/wp-graphql/wp-graphql) post object connection.
109 |
--------------------------------------------------------------------------------
/README.txt:
--------------------------------------------------------------------------------
1 | === WP GraphQL WooCommerce ===
2 | Contributors: kidunot89
3 | Tags: GraphQL, WPGraphQL, SearchWP
4 | Requires at least: 4.9
5 | Tested up to: 5.2
6 | Requires SearchWP: 3.1.8
7 | Requires PHP: 7.0
8 | License: GPL-3
9 | License URI: https://www.gnu.org/licenses/gpl-3.0.html
10 | Maintained at: https://github.com/funkhaus/ql-search
11 |
12 | == Description ==
13 | Allows you to executes search using SearchWP in WPGraphQL.
14 |
--------------------------------------------------------------------------------
/bin/install-wp-tests.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | source .env
4 |
5 | print_usage_instruction() {
6 | echo "Ensure that .env file exist in project root directory exists."
7 | echo "And run the following 'composer install-wp-tests' in the project root directory"
8 | exit 1
9 | }
10 |
11 | if [[ -z "$TEST_DB_NAME" ]]; then
12 | echo "TEST_DB_NAME not found"
13 | print_usage_instruction
14 | else
15 | DB_NAME=$TEST_DB_NAME
16 | fi
17 | if [[ -z "$TEST_DB_USER" ]]; then
18 | echo "TEST_DB_USER not found"
19 | print_usage_instruction
20 | else
21 | DB_USER=$TEST_DB_USER
22 | fi
23 | if [[ -z "$TEST_DB_PASSWORD" ]]; then
24 | DB_PASS=""
25 | else
26 | DB_PASS=$TEST_DB_PASSWORD
27 | fi
28 | if [[ -z "$TEST_DB_HOST" ]]; then
29 | DB_HOST=localhost
30 | else
31 | DB_HOST=$TEST_DB_HOST
32 | fi
33 | if [ -z "$SKIP_DB_CREATE" ]; then
34 | SKIP_DB_CREATE=false
35 | fi
36 |
37 | WP_VERSION=${WP_VERSION-latest}
38 | TMPDIR=${TMPDIR-/tmp}
39 | TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//")
40 | WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/ql-search/wordpress-tests-lib}
41 | WP_CORE_DIR=${WP_CORE_DIR-/tmp/ql-search/wordpress/}
42 | PLUGIN_DIR=$(pwd)
43 | DB_SERVE_NAME=${DB_SERVE_NAME-woographql_serve}
44 |
45 | download() {
46 | if [ `which curl` ]; then
47 | curl -s "$1" > "$2";
48 | elif [ `which wget` ]; then
49 | wget -nv -O "$2" "$1"
50 | fi
51 | }
52 |
53 | if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then
54 | WP_BRANCH=${WP_VERSION%\-*}
55 | WP_TESTS_TAG="branches/$WP_BRANCH"
56 |
57 | elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then
58 | WP_TESTS_TAG="branches/$WP_VERSION"
59 | elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
60 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
61 | # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
62 | WP_TESTS_TAG="tags/${WP_VERSION%??}"
63 | else
64 | WP_TESTS_TAG="tags/$WP_VERSION"
65 | fi
66 | elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
67 | WP_TESTS_TAG="trunk"
68 | else
69 | # http serves a single offer, whereas https serves multiple. we only want one
70 | download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json
71 | grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json
72 | LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//')
73 | if [[ -z "$LATEST_VERSION" ]]; then
74 | echo "Latest WordPress version could not be found"
75 | exit 1
76 | fi
77 | WP_TESTS_TAG="tags/$LATEST_VERSION"
78 | fi
79 | set -ex
80 |
81 | install_wp() {
82 |
83 | if [ -d $WP_CORE_DIR ]; then
84 | return;
85 | fi
86 |
87 | mkdir -p $WP_CORE_DIR
88 |
89 | if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
90 | mkdir -p $TMPDIR/wordpress-nightly
91 | download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip
92 | unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/
93 | mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR
94 | else
95 | if [ $WP_VERSION == 'latest' ]; then
96 | local ARCHIVE_NAME='latest'
97 | elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then
98 | # https serves multiple offers, whereas http serves single.
99 | download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json
100 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then
101 | # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x
102 | LATEST_VERSION=${WP_VERSION%??}
103 | else
104 | # otherwise, scan the releases and get the most up to date minor version of the major release
105 | local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'`
106 | LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1)
107 | fi
108 | if [[ -z "$LATEST_VERSION" ]]; then
109 | local ARCHIVE_NAME="wordpress-$WP_VERSION"
110 | else
111 | local ARCHIVE_NAME="wordpress-$LATEST_VERSION"
112 | fi
113 | else
114 | local ARCHIVE_NAME="wordpress-$WP_VERSION"
115 | fi
116 | download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz
117 | tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR
118 | fi
119 |
120 | download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php
121 | }
122 |
123 | install_test_suite() {
124 | # portable in-place argument for both GNU sed and Mac OSX sed
125 | if [[ $(uname -s) == 'Darwin' ]]; then
126 | local ioption='-i.bak'
127 | else
128 | local ioption='-i'
129 | fi
130 |
131 | # set up testing suite if it doesn't yet exist
132 | if [ ! -d $WP_TESTS_DIR ]; then
133 | # set up testing suite
134 | mkdir -p $WP_TESTS_DIR
135 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
136 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
137 | fi
138 |
139 | if [ ! -f wp-tests-config.php ]; then
140 | download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php
141 | # remove all forward slashes in the end
142 | WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::")
143 | sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php
144 | sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php
145 | sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php
146 | sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php
147 | sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php
148 | fi
149 |
150 | }
151 |
152 | install_db() {
153 |
154 | if [ ${SKIP_DB_CREATE} = "true" ]; then
155 | return 0
156 | fi
157 |
158 | # parse DB_HOST for port or socket references
159 | local PARTS=(${DB_HOST//\:/ })
160 | local DB_HOSTNAME=${PARTS[0]};
161 | local DB_SOCK_OR_PORT=${PARTS[1]};
162 | local EXTRA=""
163 |
164 | if ! [ -z $DB_HOSTNAME ] ; then
165 | if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then
166 | EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
167 | elif ! [ -z $DB_SOCK_OR_PORT ] ; then
168 | EXTRA=" --socket=$DB_SOCK_OR_PORT"
169 | elif ! [ -z $DB_HOSTNAME ] ; then
170 | EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
171 | fi
172 | fi
173 |
174 | # create database
175 | RESULT=`mysql -u $DB_USER --password="$DB_PASS" --skip-column-names -e "SHOW DATABASES LIKE '$DB_NAME'"$EXTRA`
176 | if [ "$RESULT" != $DB_NAME ]; then
177 | mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
178 | fi
179 | }
180 |
181 | configure_wordpress() {
182 | cd $WP_CORE_DIR
183 | wp config create --dbname="$DB_NAME" --dbuser="$DB_USER" --dbpass="$DB_PASS" --dbhost="$DB_HOST" --skip-check --force=true
184 | wp core install --url=wp.test --title="QL Search Tests" --admin_user=admin --admin_password=password --admin_email=admin@wp.test
185 | wp rewrite structure '/%year%/%monthnum%/%postname%/'
186 | }
187 |
188 | setup_search_wp() {
189 | if [ ! -d $WP_CORE_DIR/wp-content/plugins/searchwp ]; then
190 | echo "Installing SearchWP"
191 | wp plugin install https://demo.axistaylor.com/searchwp.zip
192 | fi
193 | echo "Activating SearchWP"
194 | wp plugin activate searchwp
195 | }
196 |
197 | setup_wpgraphql() {
198 | if [ ! -d $WP_CORE_DIR/wp-content/plugins/wp-graphql ]; then
199 | echo "Installing WPGraphQL"
200 | wp plugin install https://github.com/wp-graphql/wp-graphql/archive/master.zip
201 | fi
202 | echo "Activating WPGraphQL"
203 | wp plugin activate wp-graphql
204 |
205 | if [ ! -d $WP_CORE_DIR/wp-content/plugins/wp-graphql-jwt-authentication ]; then
206 | echo "Installing WPGraphQL-JWT-Authentication"
207 | wp plugin install https://github.com/wp-graphql/wp-graphql-jwt-authentication/archive/master.zip
208 | fi
209 | echo "Activating WPGraphQL-JWT-Authentication"
210 | wp plugin activate wp-graphql-jwt-authentication
211 | }
212 |
213 | setup_plugin() {
214 | # Add this repo as a plugin to the repo
215 | if [ ! -d $WP_CORE_DIR/wp-content/plugins/ql-search ]; then
216 | ln -s $PLUGIN_DIR $WP_CORE_DIR/wp-content/plugins/ql-search
217 | fi
218 |
219 | cd $WP_CORE_DIR
220 |
221 | # activate the plugin
222 | wp plugin activate ql-search
223 |
224 | # Flush the permalinks
225 | wp rewrite flush
226 |
227 | # Export the db for codeception to use
228 | wp db export $PLUGIN_DIR/tests/_data/dump.sql
229 | }
230 |
231 | install_wp
232 | install_test_suite
233 | install_db
234 | configure_wordpress
235 | setup_search_wp
236 | setup_wpgraphql
237 | setup_plugin
238 |
--------------------------------------------------------------------------------
/bin/testing-entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Move to WordPress root folder
4 | workdir="$PWD"
5 | echo "Moving to WordPress root directory."
6 | cd ${WP_ROOT_FOLDER}
7 |
8 | # Run app entrypoint script.
9 | . app-entrypoint.sh
10 |
11 | # Return to PWD.
12 | echo "Moving back to project working directory."
13 | cd ${workdir}
14 |
15 | # Ensure Apache is running
16 | service apache2 start
17 |
18 | # Ensure everything is loaded
19 | dockerize \
20 | -wait tcp://${DB_HOST}:${DB_HOST_PORT:-3306} \
21 | -wait ${WP_URL} \
22 | -timeout 1m
23 |
24 | # Download c3 for testing.
25 | if [ ! -f "${PROJECT_DIR}/c3.php" ]; then
26 | echo 'Downloading c3.php'
27 | curl -L 'https://raw.github.com/Codeception/c3/2.0/c3.php' > "${PROJECT_DIR}/c3.php"
28 | fi
29 |
30 | # Install dependencies
31 | COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-source --no-interaction
32 |
33 | # Set output permission
34 | echo "Setting Codeception output directory permissions"
35 | chmod 777 ${TESTS_OUTPUT}
36 |
37 | if [[ -z "$SUITES" ]]; then
38 | echo 'A target testing suite(s) must be selected.'
39 | echo 'Using the environment variable "$SUITES" set on the "testing" service.'
40 | exit 1
41 | fi
42 |
43 | IFS=';' read -ra target_suites <<< "$SUITES"
44 | for suite in "${target_suites[@]}"; do
45 | if [ "$COVERAGE" == "1" -a "$DEBUG" == "1" ]; then
46 | vendor/bin/codecept run ${suite} --debug --coverage --coverage-xml
47 | elif [ "$COVERAGE" == "1" ]; then
48 | vendor/bin/codecept run ${suite} --coverage --coverage-xml
49 | elif [ "$DEBUG" == "1" ]; then
50 | vendor/bin/codecept run ${suite} --debug
51 | else
52 | vendor/bin/codecept run ${suite}
53 | fi
54 | done
55 |
56 | if [ -f "${TESTS_OUTPUT}" ]; then
57 | echo 'Setting "coverage.xml" permissions'.
58 | chmod 777 -R ${TESTS_OUTPUT}/coverage.xml
59 | fi
--------------------------------------------------------------------------------
/class-inflect.php:
--------------------------------------------------------------------------------
1 | '$1zes',
26 | '/^(ox)$/i' => '$1en',
27 | '/([m|l])ouse$/i' => '$1ice',
28 | '/(matr|vert|ind)ix|ex$/i' => '$1ices',
29 | '/(x|ch|ss|sh)$/i' => '$1es',
30 | '/([^aeiouy]|qu)y$/i' => '$1ies',
31 | '/(hive)$/i' => '$1s',
32 | '/(?:([^f])fe|([lr])f)$/i' => '$1$2ves',
33 | '/(shea|lea|loa|thie)f$/i' => '$1ves',
34 | '/sis$/i' => 'ses',
35 | '/([ti])um$/i' => '$1a',
36 | '/(tomat|potat|ech|her|vet)o$/i' => '$1oes',
37 | '/(bu)s$/i' => '$1ses',
38 | '/(alias)$/i' => '$1es',
39 | '/(octop)us$/i' => '$1i',
40 | '/(ax|test)is$/i' => '$1es',
41 | '/(us)$/i' => '$1es',
42 | '/s$/i' => 's',
43 | '/$/' => 's',
44 | );
45 |
46 | /**
47 | * Stores singular suffixes
48 | *
49 | * @var array $singular
50 | */
51 | private static $singular = array(
52 | '/(quiz)zes$/i' => '$1',
53 | '/(matr)ices$/i' => '$1ix',
54 | '/(vert|ind)ices$/i' => '$1ex',
55 | '/^(ox)en$/i' => '$1',
56 | '/(alias)es$/i' => '$1',
57 | '/(octop|vir)i$/i' => '$1us',
58 | '/(cris|ax|test)es$/i' => '$1is',
59 | '/(shoe)s$/i' => '$1',
60 | '/(o)es$/i' => '$1',
61 | '/(bus)es$/i' => '$1',
62 | '/([m|l])ice$/i' => '$1ouse',
63 | '/(x|ch|ss|sh)es$/i' => '$1',
64 | '/(m)ovies$/i' => '$1ovie',
65 | '/(s)eries$/i' => '$1eries',
66 | '/([^aeiouy]|qu)ies$/i' => '$1y',
67 | '/([lr])ves$/i' => '$1f',
68 | '/(tive)s$/i' => '$1',
69 | '/(hive)s$/i' => '$1',
70 | '/(li|wi|kni)ves$/i' => '$1fe',
71 | '/(shea|loa|lea|thie)ves$/i' => '$1f',
72 | '/(^analy)ses$/i' => '$1sis',
73 | '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '$1$2sis',
74 | '/([ti])a$/i' => '$1um',
75 | '/(n)ews$/i' => '$1ews',
76 | '/(h|bl)ouses$/i' => '$1ouse',
77 | '/(corpse)s$/i' => '$1',
78 | '/(us)es$/i' => '$1',
79 | '/s$/i' => '',
80 | );
81 |
82 | /**
83 | * Stores irregular words
84 | *
85 | * @var array $irregular
86 | */
87 | private static $irregular = array(
88 | 'move' => 'moves',
89 | 'foot' => 'feet',
90 | 'goose' => 'geese',
91 | 'sex' => 'sexes',
92 | 'child' => 'children',
93 | 'man' => 'men',
94 | 'tooth' => 'teeth',
95 | 'person' => 'people',
96 | 'valve' => 'valves',
97 | );
98 |
99 | /**
100 | * Stores words without plural tenses
101 | *
102 | * @var array $uncountable
103 | */
104 | private static $uncountable = array(
105 | 'sheep',
106 | 'fish',
107 | 'deer',
108 | 'series',
109 | 'species',
110 | 'money',
111 | 'rice',
112 | 'information',
113 | 'equipment',
114 | );
115 |
116 | /**
117 | * Return plural tense of provide string
118 | *
119 | * @param string $string - word to be pluralized.
120 | * @return string
121 | */
122 | public static function pluralize( $string ) {
123 | // save some time in the case that singular and plural are the same.
124 | if ( in_array( strtolower( $string ), self::$uncountable, true ) ) {
125 | return $string;
126 | }
127 |
128 | // check for irregular singular forms.
129 | foreach ( self::$irregular as $pattern => $result ) {
130 | $pattern = '/' . $pattern . '$/i';
131 |
132 | if ( preg_match( $pattern, $string ) ) {
133 | return preg_replace( $pattern, $result, $string );
134 | }
135 | }
136 |
137 | // check for matches using regular expressions.
138 | foreach ( self::$plural as $pattern => $result ) {
139 | if ( preg_match( $pattern, $string ) ) {
140 | return preg_replace( $pattern, $result, $string );
141 | }
142 | }
143 |
144 | return $string;
145 | }
146 |
147 | /**
148 | * Return singular tense of provided string
149 | *
150 | * @param string $string String to be singularized.
151 | * @return string
152 | */
153 | public static function singularize( $string ) {
154 | // save some time in the case that singular and plural are the same.
155 | if ( in_array( strtolower( $string ), self::$uncountable, true ) ) {
156 | return $string;
157 | }
158 |
159 | // check for irregular plural forms.
160 | foreach ( self::$irregular as $result => $pattern ) {
161 | $pattern = '/' . $pattern . '$/i';
162 |
163 | if ( preg_match( $pattern, $string ) ) {
164 | return preg_replace( $pattern, $result, $string );
165 | }
166 | }
167 |
168 | // check for matches using regular expressions.
169 | foreach ( self::$singular as $pattern => $result ) {
170 | if ( preg_match( $pattern, $string ) ) {
171 | return preg_replace( $pattern, $result, $string );
172 | }
173 | }
174 |
175 | return $string;
176 | }
177 |
178 | /**
179 | * Return plural tense if provided count is greater than 1
180 | *
181 | * @param int $count Count to be evaluated.
182 | * @param string $string String potentially pluralized.
183 | */
184 | public static function pluralize_if( $count, $string ) {
185 | if ( 1 === $count ) {
186 | return '1 $string';
187 | }
188 |
189 | return $count . ' ' . self::pluralize( $string );
190 | }
191 |
192 | /**
193 | * Converts a camel case formatted string to a underscore formatted string.
194 | *
195 | * @param string $string String to be formatted.
196 | * @param boolean $capitalize Capitalize first letter of string.
197 | *
198 | * @return string
199 | */
200 | public static function underscore_to_camel_case( $string, $capitalize = false ) {
201 | $str = str_replace( ' ', '', ucwords( str_replace( '-', ' ', $string ) ) );
202 |
203 | if ( ! $capitalize ) {
204 | $str[0] = strtolower( $str[0] );
205 | }
206 |
207 | return $str;
208 | }
209 |
210 | /**
211 | * Converts a camel case formatted string to a underscore formatted string.
212 | *
213 | * @param string $string String to be formatted.
214 | *
215 | * @return string
216 | */
217 | public static function camel_case_to_underscore( $string ) {
218 | preg_match_all(
219 | '!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!',
220 | $string,
221 | $matches
222 | );
223 |
224 | $ret = $matches[0];
225 |
226 | foreach ( $ret as &$match ) {
227 | $match = strtoupper( $match ) === $match ? strtolower( $match ) : lcfirst( $match );
228 | }
229 |
230 | return implode( '_', $ret );
231 | }
232 | }
233 | endif;
234 |
--------------------------------------------------------------------------------
/codeception.dist.yml:
--------------------------------------------------------------------------------
1 | paths:
2 | tests: tests
3 | output: tests/_output
4 | data: tests/_data
5 | support: tests/_support
6 | envs: tests/_envs
7 | actor_suffix: Tester
8 | settings:
9 | colors: true
10 | memory_limit: 1024M
11 | coverage:
12 | enabled: true
13 | whitelist:
14 | include:
15 | - ql-search.php
16 | - class-inflect.php
17 | - includes/*.php
18 | params:
19 | - .env
20 | extensions:
21 | enabled:
22 | - Codeception\Extension\RunFailed
23 | commands:
24 | - Codeception\Command\GenerateWPUnit
25 | - Codeception\Command\GenerateWPRestApi
26 | - Codeception\Command\GenerateWPRestController
27 | - Codeception\Command\GenerateWPRestPostTypeController
28 | - Codeception\Command\GenerateWPAjax
29 | - Codeception\Command\GenerateWPCanonical
30 | - Codeception\Command\GenerateWPXMLRPC
31 | modules:
32 | config:
33 | WPDb:
34 | dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%'
35 | user: '%DB_USER%'
36 | password: '%DB_PASSWORD%'
37 | populator: 'mysql -u $user -p$password -h $host $dbname < $dump'
38 | dump: 'tests/_data/dump.sql'
39 | populate: true
40 | cleanup: true
41 | waitlock: 0
42 | url: '%WP_URL%'
43 | urlReplacement: true
44 | tablePrefix: '%WP_TABLE_PREFIX%'
45 | WPBrowser:
46 | url: '%WP_URL%'
47 | wpRootFolder: '%WP_ROOT_FOLDER%'
48 | adminUsername: '%ADMIN_USERNAME%'
49 | adminPassword: '%ADMIN_PASSWORD%'
50 | adminPath: '/wp-admin'
51 | REST:
52 | depends: WPBrowser
53 | url: '%WP_URL%'
54 | WPFilesystem:
55 | wpRootFolder: '%WP_ROOT_FOLDER%'
56 | plugins: '/wp-content/plugins'
57 | mu-plugins: '/wp-content/mu-plugins'
58 | themes: '/wp-content/themes'
59 | uploads: '/wp-content/uploads'
60 | WPLoader:
61 | wpRootFolder: '%WP_ROOT_FOLDER%'
62 | dbName: '%DB_NAME%'
63 | dbHost: '%DB_HOST%'
64 | dbUser: '%DB_USER%'
65 | dbPassword: '%DB_PASSWORD%'
66 | tablePrefix: '%WP_TABLE_PREFIX%'
67 | domain: '%WP_DOMAIN%'
68 | adminEmail: '%ADMIN_EMAIL%'
69 | title: 'Test'
70 | plugins:
71 | - searchwp/index.php
72 | - wp-graphql/wp-graphql.php
73 | - ql-search/ql-search.php
74 | activatePlugins:
75 | - searchwp/index.php
76 | - wp-graphql/wp-graphql.php
77 | - ql-search/ql-search.php
78 | configFile: 'tests/_data/config.php'
79 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "funkhaus/ql-search",
3 | "description": "Allows you to executes search using SearchWP in WPGraphQL",
4 | "version": "1.0.0",
5 | "type": "wordpress-plugin",
6 | "keywords": [
7 | "wordpress",
8 | "search-wp",
9 | "graphql",
10 | "wp-graphql",
11 | "wp-graphql-extension",
12 | "search-wp-extension",
13 | "api",
14 | "ql-search"
15 | ],
16 | "license": "GPL-3.0",
17 | "authors": [
18 | {
19 | "name": "Geoff Taylor",
20 | "email": "kidunot89@gmail.com",
21 | "role": "Lead developer"
22 | }
23 | ],
24 | "require": {
25 | "php": ">=5.6.0"
26 | },
27 | "require-dev": {
28 | "lucatume/wp-browser": ">=2.2.1 <2.2.8"
29 | },
30 | "config": {
31 | "optimize-autoloader": true
32 | },
33 | "autoload": {
34 | "psr-4": {
35 | "WPGraphQL\\SearchWP\\": "includes/"
36 | },
37 | "classmap": [
38 | "includes/"
39 | ]
40 | },
41 | "scripts": {
42 | "install-wp-tests": "bash bin/install-wp-tests.sh",
43 | "test": "vendor/bin/codecept run",
44 | "functional": "vendor/bin/codecept run functional",
45 | "acceptance": "vendor/bin/codecept run acceptance",
46 | "wpunit": "vendor/bin/codecept run wpunit"
47 | },
48 | "support" : {
49 | "issues": "https://github.com/funkhaus/ql-search/issues",
50 | "source": "https://github.com/funkhaus/ql-search"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/includes/class-core-schema-filters.php:
--------------------------------------------------------------------------------
1 | includes();
46 | $this->setup();
47 |
48 | /**
49 | * Fire off init action
50 | *
51 | * @param QL_Search $instance The instance of the QL_Search class
52 | */
53 | do_action( 'ql_search_init', $this );
54 | }
55 |
56 | /**
57 | * Throw error on object clone.
58 | * The whole idea of the singleton design pattern is that there is a single object
59 | * therefore, we don't want the object to be cloned.
60 | *
61 | * @since 0.0.1
62 | * @access public
63 | * @return void
64 | */
65 | public function __clone() {
66 | // Cloning instances of the class is forbidden.
67 | _doing_it_wrong( __FUNCTION__, esc_html__( 'QL_Search class should not be cloned.', 'ql-search' ), '0.0.1' );
68 | }
69 |
70 | /**
71 | * Disable unserializing of the class.
72 | *
73 | * @since 0.0.1
74 | * @access protected
75 | * @return void
76 | */
77 | public function __wakeup() {
78 | // De-serializing instances of the class is forbidden.
79 | _doing_it_wrong( __FUNCTION__, esc_html__( 'De-serializing instances of the QL_Search class is not allowed', 'ql-search' ), '0.0.1' );
80 | }
81 |
82 | /**
83 | * Include required files.
84 | * Uses composer's autoload
85 | *
86 | * @access private
87 | * @since 0.0.1
88 | * @return void
89 | */
90 | private function includes() {
91 | /**
92 | * Autoload Required Classes
93 | */
94 | if ( defined( 'QL_SEARCH_AUTOLOAD' ) && false !== QL_SEARCH_AUTOLOAD ) {
95 | require_once QL_SEARCH_PLUGIN_DIR . 'vendor/autoload.php';
96 | }
97 | }
98 |
99 | /**
100 | * Sets up WooGraphQL schema.
101 | */
102 | private function setup() {
103 | // Register WPGraphQL core filters.
104 | \WPGraphQL\SearchWP\Core_Schema_Filters::add_filters();
105 |
106 | $registry = new \WPGraphQL\SearchWP\Type_Registry();
107 | add_action( 'graphql_register_types', array( $registry, 'init' ), 10, 1 );
108 | }
109 | }
110 | endif;
111 |
--------------------------------------------------------------------------------
/includes/class-type-registry.php:
--------------------------------------------------------------------------------
1 | 'RootQuery',
37 | 'toType' => 'ContentNode',
38 | 'fromFieldName' => 'searchWP',
39 | 'connectionTypeName' => 'SearchWP',
40 | 'connectionArgs' => self::get_connection_args(),
41 | 'edgeFields' => self::get_edge_fields(),
42 | 'resolve' => function ( $source, $args, $context, $info ) {
43 | return Factory::resolve_swp_connection( $source, $args, $context, $info );
44 | },
45 | );
46 | return array_merge( $defaults, $args );
47 | }
48 |
49 | /**
50 | * Returns array of where args
51 | *
52 | * @return array
53 | */
54 | public static function get_connection_args() {
55 | return array(
56 | 'input' => array(
57 | 'type' => array( 'non_null' => 'String' ),
58 | 'description' => __( 'The search query', 'ql-search' ),
59 | ),
60 | 'engine' => array(
61 | 'type' => 'String',
62 | 'description' => __( 'The SearchWP engine to use (default: default)', 'ql-search' ),
63 | ),
64 | 'postType' => array(
65 | 'type' => array( 'list_of' => 'ContentTypeEnum' ),
66 | 'description' => __( 'Override the engine configuration with an array of post types', 'ql-search' ),
67 | ),
68 | 'nopaging' => array(
69 | 'type' => 'Boolean',
70 | 'description' => __( 'Disable pagination and return all posts', 'ql-search' ),
71 | ),
72 | 'postIn' => array(
73 | 'type' => array( 'list_of' => 'Int' ),
74 | 'description' => __( 'Array of post IDs to limit results to', 'ql-search' ),
75 | ),
76 | 'postNotIn' => array(
77 | 'type' => array( 'list_of' => 'Int' ),
78 | 'description' => __( 'Array of post IDs to exclude from results', 'ql-search' ),
79 | ),
80 | 'taxonomies' => array(
81 | 'type' => 'SearchWPTaxQueryInput',
82 | 'description' => __( 'Filter results by taxonomy', 'ql-search' ),
83 | ),
84 | 'meta' => array(
85 | 'type' => 'SearchWPMetaQueryInput',
86 | 'description' => __( 'Filter results by meta', 'ql-search' ),
87 | ),
88 | 'date' => array(
89 | 'type' => array( 'list_of' => 'DateInput' ),
90 | 'description' => __( 'Filter results by date', 'ql-search' ),
91 | ),
92 | );
93 | }
94 |
95 | public static function get_edge_fields() {
96 | $fields = array(
97 | 'source' => array(
98 | 'type' => 'String',
99 | 'description' => __( 'Result source type', 'ql-search' ),
100 | 'resolve' => function( $source ) {
101 | return ! empty( $source['source'] ) ? $source['source'] : null;
102 | }
103 | ),
104 | 'relevance' => array(
105 | 'type' => 'Int',
106 | 'description' => __( 'Result relevance.', 'ql-search' ),
107 | 'resolve' => function( $source ) {
108 | return absint( $source['relevance'] );
109 | }
110 | ),
111 | );
112 |
113 | if ( is_multisite() ) {
114 | $fields = array_merge(
115 | $fields,
116 | array(
117 | 'site' => array(
118 | 'type' => 'String',
119 | 'description' => __( 'Name of site result being to.', 'ql-search' ),
120 | 'resolve' => function( $source ) {
121 | $site = \get_blog_details( $source['site'] );
122 | return ! empty( $site->blogname ) ? $site->blogname : null;
123 | }
124 | ),
125 | )
126 | );
127 | }
128 |
129 | return $fields;
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/includes/data/class-factory.php:
--------------------------------------------------------------------------------
1 | get_connection();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/includes/data/connection/class-swp-connection-resolver.php:
--------------------------------------------------------------------------------
1 | post_types = ! empty( $args['where'] ) && ! empty( $args['where']['postType'] )
51 | ? $args['where']['postType']
52 | : get_post_types(
53 | array(
54 | 'exclude_from_search' => false,
55 | 'show_in_graphql' => true,
56 | )
57 | );
58 |
59 | $this->init_mods();
60 |
61 | /**
62 | * Call the parent construct to setup class data
63 | */
64 | parent::__construct( $source, $args, $context, $info );
65 | }
66 |
67 | private function init_mods() {
68 | $this->mods = array( new \SearchWP\Mod() );
69 | foreach( $this->post_types as $post_type ) {
70 | $source = \SearchWP\Utils::get_post_type_source_name( $post_type );
71 | $this->mods[ $post_type ] = new \SearchWP\Mod( $source );
72 | }
73 | }
74 |
75 | /**
76 | * Confirms the uses has the privileges to query Products
77 | *
78 | * @return bool
79 | */
80 | public function should_execute() {
81 | return true;
82 | }
83 |
84 | /**
85 | * Creates query arguments array
86 | */
87 | public function get_query_args() {
88 | global $wpdb;
89 |
90 | // Prepare for later use.
91 | $last = ! empty( $this->args['last'] ) ? $this->args['last'] : null;
92 | $first = ! empty( $this->args['first'] ) ? $this->args['first'] : null;
93 |
94 | // Set the $query_args based on various defaults and primary input $args.
95 | $query_args = array(
96 | 'fields' => 'default',
97 | 'per_page' => min( max( absint( $first ), absint( $last ), 10 ), $this->query_amount ) + 1,
98 | );
99 |
100 | /**
101 | * Collect the input_fields and sanitize them to prepare them for sending to the WP_Query
102 | */
103 | $input_fields = array();
104 | if ( ! empty( $this->args['where'] ) ) {
105 | $input_fields = $this->sanitize_input_fields( $this->args['where'] );
106 | }
107 |
108 | if ( ! empty( $input_fields ) ) {
109 | $query_args = array_merge( $query_args, $input_fields );
110 | }
111 |
112 | /**
113 | * Set the graphql_cursor_offset which is used by Config::graphql_wp_query_cursor_pagination_support
114 | * to filter the WP_Query to support cursor pagination
115 | */
116 | $cursor_offset = $this->get_offset();
117 | $compare = ( ! empty( $last ) ) ? '>' : '<';
118 |
119 | /**
120 | * If the starting offset is not 0 sticky posts will not be queried as the automatic checks in wp-query don't
121 | * trigger due to the page parameter not being set in the query_vars, fixes #732
122 | */
123 | if ( 0 !== $cursor_offset ) {
124 | $query_args['ignore_sticky_posts'] = true;
125 | }
126 |
127 | // Don't order search results by title (causes funky issues with cursors).
128 | $this->set_direction( isset( $last ) ? 'ASC' : 'DESC' );
129 | if ( $cursor_offset ) {
130 | $this->set_cursor( $cursor_offset, $compare );
131 | }
132 |
133 | /**
134 | * Pass the graphql $args to the WP_Query
135 | */
136 | $query_args['graphql_args'] = $this->args;
137 |
138 | /**
139 | * Filter the $query_args to allow folks to customize queries programmatically.
140 | *
141 | * @param array $query_args The args that will be passed to the WP_Query.
142 | * @param mixed $source The source that's passed down the GraphQL queries.
143 | * @param array $args The inputArgs on the field.
144 | * @param AppContext $context The AppContext passed down the GraphQL tree.
145 | * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree.
146 | */
147 | $query_args = apply_filters( 'graphql_swp_connection_query_args', $query_args, $this->source, $this->args, $this->context, $this->info );
148 |
149 | //wp_send_json( $query_args );
150 |
151 | return $query_args;
152 | }
153 |
154 | /**
155 | * Return the name of the loader
156 | *
157 | * @return string
158 | */
159 | public function get_loader_name() {
160 | return 'post';
161 | }
162 |
163 | /**
164 | * Executes query
165 | *
166 | * @return \SWP_Query
167 | */
168 | public function get_query() {
169 | $args = array_merge( $this->query_args, array( 'mods' => $this->get_mods() ) );
170 | //wp_send_json( $args );
171 | $query = new Query( $this->search_input, $args );
172 |
173 | return $query;
174 | }
175 |
176 | private function get_mods() {
177 | return array_values( $this->mods );
178 | }
179 |
180 | public function add_weight( $sql, $post_types = array() ) {
181 | if ( empty( $post_types ) ) {
182 | $this->mods[0]->weight( $sql );
183 | return;
184 | }
185 |
186 | foreach( $post_types as $post_type ) {
187 | $this->mods[ $post_type ]->weight( $sql );
188 | }
189 | }
190 |
191 | public function set_direction( $direction ) {
192 | $this->mods[0]->order_by( 's.relevance', $direction, 1 );
193 | $this->mods[0]->order_by( 's.id', $direction, 2 );
194 | }
195 |
196 | public function set_cursor( $cursor, $compare ) {
197 | $mod = new \SearchWP\Mod();
198 | $mod->set_where(
199 | array(
200 | array(
201 | 'column' => 'id',
202 | 'value' => $cursor,
203 | 'compare' => $compare,
204 | 'type' => 'NUMERIC',
205 | ),
206 | ),
207 | );
208 |
209 | $this->mods[] = $mod;
210 | }
211 |
212 | /**
213 | * Return an array of items from the query
214 | *
215 | * @return array
216 | */
217 | public function get_ids() {
218 | if ( empty( $this->results ) ) {
219 | $this->results = array_map(
220 | function( $result ) {
221 | return (array) $result;
222 | },
223 | $this->query->get_results()
224 | );
225 | }
226 |
227 | return array_column( $this->results, 'id' );
228 | }
229 |
230 | /**
231 | * Get_edges
232 | *
233 | * This iterates over the nodes and returns edges
234 | *
235 | * @return array
236 | */
237 | public function get_edges() {
238 | $edges = parent::get_edges();
239 |
240 | foreach( $edges as $i => $edge ) {
241 | $edge_id = $edge['node']->ID;
242 | $result = array_filter(
243 | $this->results,
244 | function( $result ) use ( $edge_id ) {
245 | return absint( $result['id'] ) === absint( $edge_id );
246 | }
247 | );
248 |
249 | if ( empty( $result ) ) {
250 | continue;
251 | }
252 |
253 | $result = array_pop( $result );
254 | $edges[ $i ] = array_merge(
255 | $edge,
256 | array(
257 | 'site' => $result['site'],
258 | 'source' => $result['source'],
259 | 'relevance' => $result['relevance'],
260 | )
261 | );
262 | }
263 |
264 | return $edges;
265 | }
266 |
267 | /**
268 | * This sets up the "allowed" args, and translates the GraphQL-friendly keys to WP_Query
269 | * friendly keys. There's probably a cleaner/more dynamic way to approach this, but
270 | * this was quick. I'd be down to explore more dynamic ways to map this, but for
271 | * now this gets the job done.
272 | *
273 | * @param array $where_args - arguments being used to filter query.
274 | *
275 | * @return array
276 | */
277 | public function sanitize_input_fields( array $where_args ) {
278 | global $wpdb;
279 |
280 | $args = array();
281 |
282 | $args['engine'] = ! empty( $where_args['engine'] ) ? $where_args['engine'] : 'default';
283 | $args['engine'] = new \SearchWP\Engine( $args['engine'] );
284 |
285 | $this->search_input = ! empty( $where_args['input'] ) ? $where_args['input'] : '';
286 |
287 | $post_types = $this->post_types;
288 | if ( ! empty( $where_args['postType'] ) ) {
289 | $post_types = $where_args['postType'];
290 |
291 | foreach ( array_keys( $args['engine']->get_sources() ) as $engine_source ) {
292 | if (
293 | // Not a WP_Post Source.
294 | 'post' . SEARCHWP_SEPARATOR !== substr( $engine_source, 0, strlen( 'post' . SEARCHWP_SEPARATOR ) )
295 | || (
296 | // Not in the post_type arg.
297 | ! empty( $post_types )
298 | && ! in_array( substr( $engine_source, strlen( 'post' . SEARCHWP_SEPARATOR ) ), $post_types )
299 | )
300 | ) {
301 | $args['engine']->remove_source( $engine_source );
302 |
303 | continue;
304 | }
305 | }
306 | }
307 |
308 |
309 | if ( ! empty( $where_args['postIn'] ) ) {
310 | $mod = new \SearchWP\Mod();
311 | $mod->set_where(
312 | array(
313 | array(
314 | 'column' => 'id',
315 | 'value' => $where_args['postIn'],
316 | 'compare' => 'IN',
317 | 'type' => 'NUMERIC',
318 | )
319 | )
320 | );
321 |
322 | $this->mods[] = $mod;
323 | }
324 |
325 | if ( ! empty( $where_args['postNotIn'] ) ) {
326 | $mod = new \SearchWP\Mod();
327 | $mod->set_where(
328 | array(
329 | array(
330 | 'column' => 'id',
331 | 'value' => $where_args['postNotIn'],
332 | 'compare' => 'NOT IN',
333 | 'type' => 'NUMERIC',
334 | )
335 | )
336 | );
337 |
338 | $this->mods[] = $mod;
339 | }
340 |
341 | if ( ! empty( $where_args['taxonomies'] ) ) {
342 | $tax_query = $where_args['taxonomies']['taxArray']; // WPCS: slow query ok.
343 | if ( ! empty( $where_args['taxonomies']['relation'] ) && count( $where_args['taxonomies']['taxArray'] ) > 1 ) {
344 | $tax_query['relation'] = $where_args['taxonomies']['relation'];
345 | }
346 |
347 | // We need to do a bit of detective work depending on the tax_query.
348 | $alias = 'swpquerytax';
349 | $tax_query = new \WP_Tax_Query( $tax_query );
350 | $tq_sql = $tax_query->get_sql( $alias, 'ID' );
351 | $mod = new \SearchWP\Mod();
352 |
353 | // If the JOIN is empty, WP_Tax_Query assumes we have a JOIN with wp_posts, so let's make that.
354 | if ( ! empty( $tq_sql['join'] ) ) {
355 | // Queue the assumed wp_posts JOIN using our alias.
356 | $mod->raw_join_sql( function( $runtime ) use ( $wpdb, $alias ) {
357 | return "LEFT JOIN {$wpdb->posts} {$alias} ON {$alias}.ID = {$runtime->get_foreign_alias()}.id";
358 | } );
359 |
360 | // Queue the WP_Tax_Query JOIN which already has our alias.
361 | $mod->raw_join_sql( $tq_sql['join'] );
362 |
363 | // Queue the WP_Tax_Query WHERE which already has our alias.
364 | $mod->raw_where_sql( '1=1 ' . $tq_sql['where'] );
365 | } else {
366 | // There's no JOIN here because WP_Tax_Query assumes a JOIN with wp_posts already
367 | // exists. We need to rebuild the tax_query SQL to use a functioning alias. The Mod
368 | // will ensure the JOIN, and we can use that Mod's alias to rebuild our tax_query.
369 | $mod->set_local_table( $wpdb->posts );
370 | $mod->on( 'ID', [ 'column' => 'id' ] );
371 |
372 | $mod->raw_where_sql( function( $runtime ) use ( $tax_query ) {
373 | $tq_sql = $tax_query->get_sql( $runtime->get_local_table_alias(), 'ID' );
374 |
375 | return '1=1 ' . $tq_sql['where'];
376 | } );
377 | }
378 |
379 | $this->mods[] = $mod;
380 | }
381 |
382 | if ( ! empty( $where_args['meta'] ) ) {
383 | $meta_query = $where_args['meta']['metaArray']; // WPCS: slow query ok.
384 | if ( ! empty( $where_args['meta']['relation'] ) && count( $where_args['meta']['metaArray'] ) > 1 ) {
385 | $meta_query['relation'] = $where_args['meta']['relation'];
386 | }
387 |
388 | $alias = 'swpquerymeta';
389 | $meta_query = new \WP_Meta_Query( $meta_query );
390 | $mq_sql = $meta_query->get_sql( 'post', $alias, 'ID', null );
391 |
392 | $mod = new \SearchWP\Mod();
393 | $mod->set_local_table( $wpdb->posts );
394 | $mod->on( 'ID', [ 'column' => 'id' ] );
395 |
396 | $mod->raw_join_sql( function( $runtime ) use ( $mq_sql, $alias ) {
397 | return str_replace( $alias, $runtime->get_local_table_alias(), $mq_sql['join'] );
398 | } );
399 |
400 | $mod->raw_where_sql( function( $runtime ) use ( $mq_sql, $alias ) {
401 | return '1=1 ' . str_replace( $alias, $runtime->get_local_table_alias(), $mq_sql['where'] );
402 | } );
403 |
404 | $this->mods[] = $mod;
405 | }
406 |
407 | if ( ! empty( $where_args['date'] ) ) {
408 | $date_query = $where_args['date'];
409 |
410 | $date_query = new \WP_Date_Query( (array) $date_query );
411 | $dq_sql = $date_query->get_sql();
412 |
413 | $mod = new \SearchWP\Mod();
414 | $mod->set_local_table( $wpdb->posts );
415 | $mod->on( 'ID', [ 'column' => 'id' ] );
416 |
417 | $mod->raw_where_sql( function( $runtime ) use ( $dq_sql ) {
418 | global $wpdb;
419 |
420 | return '1=1 ' . str_replace( $wpdb->posts . '.', $runtime->get_local_table_alias() . '.', $dq_sql );
421 | } );
422 |
423 | $this->mods[] = $mod;
424 | }
425 |
426 | /**
427 | * Filter the input fields
428 | * This allows plugins/themes to hook in and alter what $args should be allowed to be passed
429 | * from a GraphQL Query to the WP_Query
430 | *
431 | * @param array $args The mapped query arguments
432 | * @param array $where_args Query "where" args
433 | * @param mixed $source The query results for a query calling this
434 | * @param array $all_args All of the arguments for the query (not just the "where" args)
435 | * @param AppContext $context The AppContext object
436 | * @param ResolveInfo $info The ResolveInfo object
437 | * @param mixed|string|array $post_type The post type for the query
438 | */
439 | $args = apply_filters(
440 | 'graphql_map_input_fields_to_swp_query',
441 | $args,
442 | $where_args,
443 | $this->source,
444 | $this->args,
445 | $this->context,
446 | $this->info,
447 | $this->post_types
448 | );
449 |
450 | return $args;
451 | }
452 |
453 | /**
454 | * Determine whether or not the the offset is valid, i.e the post corresponding to the offset exists.
455 | * Offset is equivalent to post_id. So this function is equivalent
456 | * to checking if the post with the given ID exists.
457 | *
458 | * @param integer $offset Post ID.
459 | *
460 | * @return bool
461 | */
462 | public function is_valid_offset( $offset ) {
463 | global $wpdb;
464 |
465 | if ( ! empty( wp_cache_get( $offset, 'posts' ) ) ) {
466 | return true;
467 | }
468 |
469 | return $wpdb->get_var( $wpdb->prepare( "SELECT EXISTS (SELECT 1 FROM $wpdb->posts WHERE ID = %d)", $offset ) );
470 | }
471 | }
472 |
--------------------------------------------------------------------------------
/includes/data/cursor/class-swp-query-cursor.php:
--------------------------------------------------------------------------------
1 | wpdb = $wpdb;
62 | $this->query = $query;
63 | $this->query_args = $query_args;
64 |
65 | /**
66 | * Get the cursor offset if any
67 | */
68 | $offset = $query_args['graphql_cursor_offset'];
69 | $this->cursor_offset = ! empty( $offset ) ? $offset : 0;
70 |
71 | /**
72 | * Get the direction for the query builder
73 | */
74 | $compare = ! empty( $query_args['graphql_cursor_compare'] ) ? $query_args['graphql_cursor_compare'] : '>';
75 | $this->compare = in_array( $compare, array( '>', '<' ), true ) ? $compare : '>';
76 |
77 | $this->builder = new CursorBuilder( $compare );
78 | }
79 |
80 | /**
81 | * Getter for return commonly reused SQL statements.
82 | *
83 | * @param string $name Alias for desired SQL statement.
84 | *
85 | * @return string
86 | */
87 | public function __get( $name ) {
88 | $output_sql = '';
89 | switch ( $name ) {
90 | case 'posts_weight':
91 | // Sum our final weights per post type.
92 | foreach ( $this->query->engineSettings as $post_type => $post_type_weights ) {
93 | if ( isset( $post_type_weights['enabled'] ) && true === $post_type_weights['enabled'] ) {
94 | $term_counter = 1;
95 | if ( empty( $post_type_weights['options']['attribute_to'] ) ) {
96 | foreach ( $this->query->terms as $term ) {
97 | $output_sql .= "COALESCE(term{$term_counter}.`{$post_type}weight`,0) + ";
98 | $term_counter++;
99 | }
100 | } else {
101 | foreach ( $this->query->terms as $term ) {
102 | $output_sql .= "COALESCE(term{$term_counter}.`{$post_type}attr`,0) + ";
103 | $term_counter++;
104 | }
105 | }
106 | }
107 | }
108 |
109 | // Trim off the extra +.
110 | $this->trim_end( $output_sql );
111 | break;
112 | case 'cursor_post_weight':
113 | $output_sql = $this->wpdb->get_results( $this->get_cursor_post_weight() )[0]->cursorWeight; // WPCS: unprepared SQL OK.
114 | break;
115 | }
116 |
117 | return $output_sql;
118 | }
119 |
120 | /**
121 | * Trims last two character of the provided SQL string.
122 | *
123 | * @param string $sql String to be trimmed.
124 | */
125 | public function trim_end( &$sql ) {
126 | $sql = substr( $sql, 0, strlen( $sql ) - 2 );
127 | }
128 |
129 | /**
130 | * Cache the final term(s) after filtering to prevent redundant queries
131 | *
132 | * @param string $term Term being cached.
133 | *
134 | * @since 2.3
135 | */
136 | private function cache_term_final( $term ) {
137 | // $term has been prepared already
138 | $this->terms_final = array_merge( $this->terms_final, $term );
139 | $this->terms_final = array_filter( $this->terms_final, 'strlen' );
140 | $this->terms_final = array_unique( $this->terms_final );
141 | }
142 |
143 | /**
144 | * Generate the SQL used to open the per-post type sub-query.
145 | *
146 | * @param array $args Arguments for the post type.
147 | * @param string $extra_sql_join Extra SQL table joins statements.
148 | *
149 | * @return string
150 | */
151 | public function query_post_type_open( $args, $extra_sql_join = '' ) {
152 | $defaults = array(
153 | 'post_type' => 'post',
154 | 'post_column' => 'ID',
155 | 'title_weight' => function_exists( 'searchwp_get_engine_weight' ) ? searchwp_get_engine_weight( 'title' ) : 20,
156 | 'slug_weight' => function_exists( 'searchwp_get_engine_weight' ) ? searchwp_get_engine_weight( 'slug' ) : 10,
157 | 'content_weight' => function_exists( 'searchwp_get_engine_weight' ) ? searchwp_get_engine_weight( 'content' ) : 2,
158 | 'comment_weight' => function_exists( 'searchwp_get_engine_weight' ) ? searchwp_get_engine_weight( 'comment' ) : 1,
159 | 'excerpt_weight' => function_exists( 'searchwp_get_engine_weight' ) ? searchwp_get_engine_weight( 'excerpt' ) : 6,
160 | 'custom_fields' => 0,
161 | 'taxonomies' => 0,
162 | 'attributed_to' => false,
163 | );
164 |
165 | // Process our arguments.
166 | $args = wp_parse_args( $args, $defaults );
167 |
168 | if ( ! post_type_exists( $args['post_type'] ) ) {
169 | wp_die( 'Invalid request', 'searchwp' );
170 | }
171 |
172 | $post_type = $args['post_type'];
173 |
174 | $post_column = $args['post_column'];
175 | if ( ! in_array( $post_column, array( 'post_parent', 'ID' ), true ) ) {
176 | $post_column = 'ID';
177 | }
178 |
179 | $title_weight = absint( $args['title_weight'] );
180 | $slug_weight = absint( $args['slug_weight'] );
181 | $content_weight = absint( $args['content_weight'] );
182 | $comment_weight = absint( $args['comment_weight'] );
183 | $excerpt_weight = absint( $args['excerpt_weight'] );
184 |
185 | $wrap_core_weights = apply_filters( 'searchwp_weight_mods_wrap_core_weights', false );
186 | $core_weight_prefix = $wrap_core_weights ? '(' : '';
187 | $core_weight_suffix = $wrap_core_weights ? ')' : '';
188 |
189 | $sql = "
190 | LEFT JOIN (
191 | SELECT {$this->wpdb->prefix}posts.{$post_column} AS post_id,
192 | {$core_weight_prefix}( SUM( {$this->query->db_prefix}index.title ) * {$title_weight} ) +
193 | ( SUM( {$this->query->db_prefix}index.slug ) * {$slug_weight} ) +
194 | ( SUM( {$this->query->db_prefix}index.content ) * {$content_weight} ) +
195 | ( SUM( {$this->query->db_prefix}index.comment ) * {$comment_weight} ) +
196 | ( SUM( {$this->query->db_prefix}index.excerpt ) * {$excerpt_weight} ) +
197 | {$args['custom_fields']} + {$args['taxonomies']}{$core_weight_suffix}";
198 |
199 | // Allow developers to inject their own weight modifications.
200 | $sql .= apply_filters( 'searchwp_weight_mods', '', array( 'engine' => $this->query->engine ) );
201 |
202 | // The identifier is different if we're attributing.
203 | $sql .= ! empty( $args['attributed_to'] ) ? " AS `{$post_type}attr` " : " AS `{$post_type}weight` ";
204 |
205 | $sql .= "
206 | FROM {$this->query->db_prefix}terms
207 | LEFT JOIN {$this->query->db_prefix}index ON {$this->query->db_prefix}terms.id = {$this->query->db_prefix}index.term
208 | LEFT JOIN {$this->wpdb->prefix}posts ON {$this->query->db_prefix}index.post_id = {$this->wpdb->prefix}posts.ID
209 | {$extra_sql_join}
210 | ";
211 |
212 | return $sql;
213 | }
214 |
215 | /**
216 | * Generate the SQL that extracts Custom Field weights
217 | *
218 | * @param string $post_type The post type.
219 | * @param array $weights Custom Field weights from SearchWP Settings.
220 | * @param string $sql_term_where SQL Where statement.
221 | * @param string $sql_status SQL posts status statement.
222 | * @param string $extra_sql_join Extra SQL table joins statements.
223 | * @param string $sql_conditions Extra SQL conditions.
224 | * @return string
225 | */
226 | public function query_post_type_custom_field_weights( $post_type, $weights, $sql_term_where, $sql_status, $extra_sql_join = '', $sql_conditions = '' ) {
227 | // First we'll try to merge any matching weight meta_keys so as to save as many JOINs as possible.
228 | $optimized_weights = array();
229 | $like_weights = array();
230 | foreach ( $weights as $post_type_meta_guid => $post_type_custom_field ) {
231 |
232 | $custom_field_weight = $post_type_custom_field['weight'];
233 | $post_type_custom_field_key = $post_type_custom_field['metakey'];
234 |
235 | if ( false !== strpos( $custom_field_weight, '.' ) ) {
236 | $custom_field_weight = (string) abs( floatval( $custom_field_weight ) );
237 | } else {
238 | $custom_field_weight = (string) absint( $custom_field_weight );
239 | }
240 |
241 | // Allow developers to implement LIKE matching on custom field keys.
242 | if ( false === strpos( $post_type_custom_field_key, '%' ) ) {
243 | $optimized_weights[ $custom_field_weight ][] = $post_type_custom_field_key;
244 | } else {
245 | $like_weights[] = array(
246 | 'metakey' => $post_type_custom_field_key,
247 | 'weight' => $custom_field_weight,
248 | );
249 | }
250 | }
251 |
252 | $column = 'ID';
253 |
254 | /**
255 | * Our custom fields are now keyed by their weight, allowing us to group Custom Fields with the
256 | * same weight together in the same LEFT JOIN
257 | */
258 | $sql = '';
259 | $i = 0;
260 | foreach ( $optimized_weights as $weight_key => $meta_keys_for_weight ) {
261 | $post_meta_clause = '';
262 | if ( ! in_array( 'searchwpcfdefault', str_ireplace( ' ', '', $meta_keys_for_weight ), true ) ) {
263 |
264 | if ( is_array( $meta_keys_for_weight ) ) {
265 | foreach ( $meta_keys_for_weight as $key => $val ) {
266 | $meta_keys_for_weight[ $key ] = $this->wpdb->prepare( '%s', $val );
267 | }
268 | }
269 |
270 | $post_meta_clause = ' AND ' . $this->query->db_prefix . 'cf.metakey IN (' . implode( ',', $meta_keys_for_weight ) . ')';
271 | }
272 | $weight_key = floatval( $weight_key );
273 | $sql .= "
274 | LEFT JOIN (
275 | SELECT {$this->wpdb->prefix}posts.{$column} as post_id, ( SUM( COALESCE(`{$this->query->db_prefix}cf`.`count`, 0) ) * {$weight_key} ) AS cfweight{$i}
276 | FROM {$this->query->db_prefix}terms
277 | LEFT JOIN {$this->query->db_prefix}cf ON {$this->query->db_prefix}terms.id = {$this->query->db_prefix}cf.term
278 | LEFT JOIN {$this->wpdb->prefix}posts ON {$this->query->db_prefix}cf.post_id = {$this->wpdb->prefix}posts.ID
279 | {$extra_sql_join}
280 | WHERE {$sql_term_where}
281 | {$sql_status}
282 | AND {$this->wpdb->prefix}posts.post_type = '{$post_type}'
283 | {$this->query->sql_exclude}
284 | {$this->query->sql_include}
285 | {$post_meta_clause}
286 | {$sql_conditions}
287 | GROUP BY post_id
288 | ) AS cfweights{$i} ON cfweights{$i}.post_id = {$this->wpdb->prefix}posts.ID";
289 | $i++;
290 | }
291 |
292 | // There also may be LIKE weights, though, so we need to build out that SQL as well.
293 | if ( ! empty( $like_weights ) ) {
294 | foreach ( $like_weights as $like_weight ) {
295 | $like_weight['metakey'] = $wpdb->prepare( '%s', $like_weight['metakey'] );
296 | $like_weight['weight'] = floatval( $like_weight['weight'] );
297 | $post_meta_clause = ' AND ' . $this->query->db_prefix . 'cf.metakey LIKE ' . $like_weight['metakey'];
298 | $sql .= "
299 | LEFT JOIN (
300 | SELECT {$this->wpdb->prefix}posts.{$column} as post_id, ( SUM( COALESCE(`{$this->query->db_prefix}cf`.`count`, 0) ) * {$like_weight['weight']} ) AS cfweight{$i}
301 | FROM {$this->query->db_prefix}terms
302 | LEFT JOIN {$this->query->db_prefix}cf ON {$this->query->db_prefix}terms.id = {$this->query->db_prefix}cf.term
303 | LEFT JOIN {$this->wpdb->prefix}posts ON {$this->query->db_prefix}cf.post_id = {$this->wpdb->prefix}posts.ID
304 | {$extra_sql_join}
305 | WHERE {$sql_term_where}
306 | {$sql_status}
307 | AND {$this->wpdb->prefix}posts.post_type = '{$post_type}'
308 | {$this->query->sql_exclude}
309 | {$this->query->sql_include}
310 | {$post_meta_clause}
311 | {$sql_conditions}
312 | GROUP BY post_id
313 | ) AS cfweights{$i} ON cfweights{$i}.post_id = {$wpdb->prefix}posts.ID";
314 | $i++;
315 | }
316 | }
317 |
318 | return $sql;
319 | }
320 |
321 | /**
322 | * Generate the SQL that extracts taxonomy weights
323 | *
324 | * @param string $post_type The post type.
325 | * @param array $weights Taxonomy weights from SearchWP Settings.
326 | * @param string $sql_term_where SQL Where statement.
327 | * @param string $sql_status SQL posts status statement.
328 | * @param string $extra_sql_join Extra SQL table joins statements.
329 | * @param string $sql_conditions Extra SQL conditions.
330 | * @return string
331 | */
332 | public function query_post_type_taxonomy_weights( $post_type, $weights, $sql_term_where, $sql_status, $extra_sql_join = '', $sql_conditions = '' ) {
333 | $i = 0;
334 |
335 | // First we'll try to merge any matching weight taxonomies so as to save as many JOINs as possible.
336 | $optimized_weights = array();
337 | foreach ( $weights as $taxonomy_name => $taxonomy_weight ) {
338 | $taxonomy_weight = absint( $taxonomy_weight );
339 | $optimized_weights[ $taxonomy_weight ][] = $taxonomy_name;
340 | }
341 |
342 | $sql = '';
343 | foreach ( $optimized_weights as $post_type_tax_weight => $post_type_taxonomies ) {
344 | $post_type_tax_weight = absint( $post_type_tax_weight );
345 |
346 | if ( is_array( $post_type_taxonomies ) ) {
347 | foreach ( $post_type_taxonomies as $key => $val ) {
348 | $post_type_taxonomies[ $key ] = $this->wpdb->prepare( '%s', $val );
349 | }
350 | }
351 |
352 | $sql .= "
353 | LEFT JOIN (
354 | SELECT {$this->query->db_prefix}tax.post_id, ( SUM( {$this->query->db_prefix}tax.count ) * {$post_type_tax_weight} ) AS taxweight{$i}
355 | FROM {$this->query->db_prefix}terms
356 | LEFT JOIN {$this->query->db_prefix}tax ON {$this->query->db_prefix}terms.id = {$this->query->db_prefix}tax.term
357 | LEFT JOIN {$this->wpdb->prefix}posts ON {$this->query->db_prefix}tax.post_id = {$this->wpdb->prefix}posts.ID
358 | {$extra_sql_join}
359 | WHERE {$sql_term_where}
360 | {$sql_status}
361 | AND {$this->wpdb->prefix}posts.post_type = '{$post_type}'
362 | {$this->query->sql_exclude}
363 | {$this->query->sql_include}
364 | AND {$this->query->db_prefix}tax.taxonomy IN (" . implode( ',', $post_type_taxonomies ) . ")
365 | {$sql_conditions}
366 | GROUP BY {$this->query->db_prefix}tax.post_id
367 | ) AS taxweights{$i} ON taxweights{$i}.post_id = {$this->wpdb->prefix}posts.ID";
368 | $i++;
369 | }
370 |
371 | return $sql;
372 | }
373 |
374 | /**
375 | * Generate the SQL that closes the per-post type sub-query
376 | *
377 | * @param string $post_type The post type.
378 | * @param bool|int $attribute_to The attribution target post ID (if applicable).
379 | * @param string $sql_term_where SQL Where statement.
380 | * @param string $sql_status SQL posts status statement.
381 | * @param string $sql_conditions Extra SQL conditions.
382 | * @return string
383 | */
384 | public function query_post_type_close( $post_type, $attribute_to = false, $sql_term_where, $sql_status, $sql_conditions = '' ) {
385 | if ( ! post_type_exists( $post_type ) ) {
386 | wp_die( 'Invalid request', 'searchwp' );
387 | }
388 |
389 | $post_type_group_by = apply_filters( 'searchwp_post_type_group_by_clause', array( "{$this->wpdb->prefix}posts.ID" ) );
390 | $post_type_group_by = array_map( 'esc_sql', $post_type_group_by );
391 | $post_type_group_by = implode( ', ', $post_type_group_by );
392 |
393 | // Cap off each enabled post type subquery.
394 | $sql = "
395 | WHERE {$sql_term_where}
396 | {$sql_status}
397 | AND {$this->wpdb->prefix}posts.post_type = '{$post_type}'
398 | {$this->query->sql_exclude}
399 | {$this->query->sql_include}
400 | {$sql_conditions}
401 | GROUP BY {$post_type_group_by}";
402 |
403 | // @since 2.9.0
404 | $sql .= $this->query->only_full_group_by_fix_for_post_type();
405 |
406 | if ( isset( $attribute_to ) && ! empty( $attribute_to ) ) {
407 | // $attributedTo was defined in the initial conditional
408 | $attributed_to = absint( $attribute_to );
409 | $sql .= ") `attributed{$post_type}` ON $attributed_to = {$this->wpdb->prefix}posts.ID";
410 | } else {
411 | $sql .= ") AS `{$post_type}weights` ON `{$post_type}weights`.post_id = {$this->wpdb->prefix}posts.ID";
412 | }
413 |
414 | return $sql;
415 | }
416 |
417 | /**
418 | * Generate the SQL that limits search results to a specific minimum weight per post type
419 | *
420 | * @return string
421 | */
422 | public function query_limit_post_type_to_weight() {
423 | $sql = '';
424 | foreach ( $this->query->engineSettings as $post_type => $post_type_weights ) {
425 | if ( isset( $post_type_weights['enabled'] ) && true === $post_type_weights['enabled'] && empty( $post_type_weights['options']['attribute_to'] ) ) {
426 | $sql .= " COALESCE(`{$post_type}weight`,0) +";
427 | }
428 | }
429 |
430 | foreach ( $this->query->engineSettings as $post_type => $post_type_weights ) {
431 | if ( isset( $post_type_weights['enabled'] ) && true === $post_type_weights['enabled'] && ! empty( $post_type_weights['options']['attribute_to'] ) ) {
432 | $attributed_to = absint( $post_type_weights['options']['attribute_to'] );
433 | // Make sure we're not excluding the attributed post id.
434 | if ( ! in_array( $attributed_to, $this->query->excluded, true ) ) {
435 | $sql .= " COALESCE(`{$post_type}attr`,0) +";
436 | }
437 | }
438 | }
439 |
440 | $this->trim_end( $sql ); // trim off the extra +.
441 | $sql .= ' > ' . absint( apply_filters( 'searchwp_weight_threshold', 0 ) ) . ' ';
442 |
443 | return $sql;
444 | }
445 |
446 | /**
447 | * Get post instance for the cursor.
448 | *
449 | * This is cached internally so it does not generate extra queries
450 | *
451 | * @return mixed WP_Post|null
452 | */
453 | public function get_cursor_post() {
454 | if ( ! $this->cursor_offset ) {
455 | return null;
456 | }
457 |
458 | return \WP_Post::get_instance( $this->cursor_offset );
459 | }
460 |
461 | /**
462 | * Returns the cursor post's finalweight
463 | *
464 | * @return integer
465 | */
466 | public function get_cursor_post_weight() {
467 | $sql = "SELECT SUM({$this->posts_weight}) AS `cursorWeight` FROM {$this->wpdb->prefix}posts ";
468 |
469 | $term_counter = 1;
470 | foreach ( $this->query->terms as $term ) {
471 | $sql .= "LEFT JOIN ( SELECT {$this->wpdb->prefix}posts.ID AS post_id";
472 |
473 | $post_type_weight_sql = '';
474 | $attribute_weight_sql = '';
475 | $final_weight_sql = '';
476 | $attribute_final_weight_sql = '';
477 | foreach ( $this->query->engineSettings as $post_type => $post_type_weights ) {
478 | if ( isset( $post_type_weights['enabled'] ) && true === $post_type_weights['enabled'] ) {
479 | if ( ! empty( $post_type_weights['options']['attribute_to'] ) ) {
480 | $attributed_to = absint( $post_type_weights['options']['attribute_to'] );
481 |
482 | // make sure we're not excluding the attributed post id.
483 | if ( ! in_array( $attributed_to, $this->query->excluded, true ) ) {
484 | $attribute_weight_sql .= ", COALESCE(`{$post_type}attr`,0) as `{$post_type}attr` ";
485 | $attribute_final_weight_sql .= " COALESCE(`{$post_type}attr`,0) +";
486 | }
487 | } else {
488 | $post_type_weight_sql .= ", COALESCE(`{$post_type}weight`,0) AS `{$post_type}weight` ";
489 | $final_weight_sql .= " COALESCE(`{$post_type}weight`,0) +";
490 | }
491 | }
492 | }
493 |
494 | $sql .= $post_type_weight_sql . $attribute_weight_sql . ', ' . $final_weight_sql . $attribute_final_weight_sql;
495 |
496 | $this->trim_end( $sql );
497 | $sql .= ' AS weight ';
498 | $sql .= " FROM {$this->wpdb->prefix}posts ";
499 |
500 | foreach ( $this->query->engineSettings as $post_type => $post_type_weights ) {
501 | if ( isset( $post_type_weights['enabled'] ) && true === $post_type_weights['enabled'] ) {
502 | $prepped_term = $this->query->prep_term( $term, $post_type_weights );
503 | $term = $prepped_term['term'];
504 | $term_or_stem = $prepped_term['term_or_stem'];
505 | $original_prepped_term = $prepped_term['original_prepped_term'];
506 | $this->cache_term_final( $term );
507 |
508 | $collate_override = $this->query->get_collate_override();
509 | $sql_term_where = " {$this->query->db_prefix}terms." . $term_or_stem . $collate_override . ' IN (' . implode( ',', $term ) . ')';
510 |
511 | // If it's an attachment we need to force 'inherit'.
512 | $post_statuses = ( 'attachment' === $post_type ) ? array( 'inherit' ) : $this->query->post_statuses;
513 | if ( is_array( $post_statuses ) ) {
514 | foreach ( $post_statuses as $key => $val ) {
515 | $post_statuses[ $key ] = $this->wpdb->prepare( '%s', $val );
516 | }
517 | }
518 | $sql_status = "AND {$this->wpdb->prefix}posts.post_status IN ( " . implode( ',', $post_statuses ) . ' ) ';
519 |
520 | // Determine whether we need to limit to a mime type.
521 | if ( isset( $post_type_weights['options']['mimes'] ) && '' !== $post_type_weights['options']['mimes'] ) {
522 |
523 | // Stored as an array of integers that correlate to mime type groups.
524 | $mimes = explode( ',', $post_type_weights['options']['mimes'] );
525 | $mimes = array_map( 'absint', $mimes );
526 |
527 | $targeted_mimes = \SWP()->get_mimes_from_settings_ids( $mimes );
528 |
529 | if ( empty( $targeted_mimes ) ) {
530 | return;
531 | }
532 |
533 | if ( is_array( $targeted_mimes ) ) {
534 | foreach ( $targeted_mimes as $key => $val ) {
535 | $targeted_mimes[ $key ] = $this->wpdb->prepare( '%s', $val );
536 | }
537 | }
538 |
539 | // We have an array of keys that match MIME types (not subtypes) that we can limit to by appending this condition.
540 | $sql_status .= " AND {$this->wpdb->prefix}posts.post_type = 'attachment' AND {$this->wpdb->prefix}posts.post_mime_type IN ( " . implode( ',', $targeted_mimes ) . ' ) ';
541 | }
542 |
543 | // Take into consideration the engine limiter rules FOR THIS POST TYPE.
544 | $limited_ids = $this->query->get_included_ids_from_taxonomies_for_post_type( $post_type );
545 | $limiter_column = 'ID';
546 |
547 | // If parent attribution is in play we need to transfer the inclusion/exclusion rules.
548 | if (
549 | 'attachment' === $post_type
550 | && isset( $post_type_weights['options']['parent'] )
551 | && ! empty( $post_type_weights['options']['parent'] )
552 | ) {
553 | $limiter_column = 'post_parent';
554 | $global_limited_ids = array();
555 |
556 | // This isn't ideal because the post_parent can be _any_ post type, so we need to limit to them all...
557 | foreach ( $this->query->engineSettings as $limiter_post_type => $limiter_post_type_weights ) {
558 | if ( ! isset( $limiter_post_type_weights['enabled'] ) || empty( $limiter_post_type_weights['enabled'] ) ) {
559 | continue;
560 | }
561 |
562 | $these_limited_ids = $this->query->get_included_ids_from_taxonomies_for_post_type( $limiter_post_type );
563 |
564 | if ( ! empty( $these_limited_ids ) ) {
565 | $global_limited_ids = array_merge( $global_limited_ids, $these_limited_ids );
566 | }
567 | }
568 |
569 | $limited_ids = array_unique( $global_limited_ids );
570 | }
571 |
572 | // Function returns false if not applicable.
573 | if ( is_array( $limited_ids ) && ! empty( $limited_ids ) ) {
574 | $limited_ids = array_map( 'absint', $limited_ids );
575 | $limited_ids = array_unique( $limited_ids );
576 | $sql_status .= " AND {$this->wpdb->prefix}posts.post_type = '{$post_type}' AND {$this->wpdb->prefix}posts." . $limiter_column . ' IN ( ' . implode( ',', $limited_ids ) . ' ) ';
577 | }
578 |
579 | // Reset back to our original term.
580 | $term = $original_prepped_term;
581 |
582 | // We need to use absint because if a weight was set to -1 for exclusion, it was already forcefully excluded.
583 | $title_weight = isset( $post_type_weights['weights']['title'] ) ? absint( $post_type_weights['weights']['title'] ) : 0;
584 | $slug_weight = isset( $post_type_weights['weights']['slug'] ) ? absint( $post_type_weights['weights']['slug'] ) : 0;
585 | $content_weight = isset( $post_type_weights['weights']['content'] ) ? absint( $post_type_weights['weights']['content'] ) : 0;
586 | $excerpt_weight = isset( $post_type_weights['weights']['excerpt'] ) ? absint( $post_type_weights['weights']['excerpt'] ) : 0;
587 |
588 | if ( apply_filters( 'searchwp_index_comments', true ) ) {
589 | $comment_weight = isset( $post_type_weights['weights']['comment'] ) ? absint( $post_type_weights['weights']['comment'] ) : 0;
590 | } else {
591 | $comment_weight = 0;
592 | }
593 |
594 | // Build the SQL to accommodate Custom Fields.
595 | $custom_field_weights = isset( $post_type_weights['weights']['cf'] ) ? $post_type_weights['weights']['cf'] : 0;
596 | $coalesce_custom_fields = $this->query->query_coalesce_custom_fields( $custom_field_weights );
597 |
598 | // Build the SQL to accommodate Taxonomies.
599 | $taxonomy_weights = isset( $post_type_weights['weights']['tax'] ) ? $post_type_weights['weights']['tax'] : 0;
600 | $coalesce_taxonomies = $this->query->query_coalesce_taxonomies( $taxonomy_weights );
601 |
602 | // Allow additional tables to be joined.
603 | $sql_join = apply_filters( 'searchwp_query_join', '', $post_type, $this->query->engine );
604 | if ( ! is_string( $sql_join ) ) {
605 | $sql_join = '';
606 | }
607 |
608 | // Allow additional conditions.
609 | $sql_conditions = apply_filters( 'searchwp_query_conditions', '', $post_type, $this->query->engine );
610 | if ( ! is_string( $sql_conditions ) ) {
611 | $sql_conditions = '';
612 | }
613 |
614 | // If we're dealing with attributed weight we need to make sure that the attribution target was not excluded.
615 | $excluded_by_attribution = false;
616 | $attributed_to = false;
617 | if ( isset( $post_type_weights['options']['attribute_to'] ) && ! empty( $post_type_weights['options']['attribute_to'] ) ) {
618 | $post_column = 'ID';
619 | $attributed_to = absint( $post_type_weights['options']['attribute_to'] );
620 | if ( in_array( $attributed_to, $this->query->excluded, true ) ) {
621 | $excluded_by_attribution = true;
622 | }
623 | } else {
624 | // If it's an attachment and we want to attribute to the parent, we need to set that here.
625 | $post_column = ! empty( $post_type_weights['options']['parent'] ) ? 'post_parent' : 'ID';
626 | }
627 |
628 | // Open up the post type subquery if not excluded by attribution.
629 | if ( ! $excluded_by_attribution ) {
630 | $post_type_params = array(
631 | 'post_type' => $post_type,
632 | 'post_column' => $post_column,
633 | 'title_weight' => $title_weight,
634 | 'slug_weight' => $slug_weight,
635 | 'content_weight' => $content_weight,
636 | 'comment_weight' => $comment_weight,
637 | 'excerpt_weight' => $excerpt_weight,
638 | 'custom_fields' => isset( $coalesce_custom_fields ) ? $coalesce_custom_fields : '',
639 | 'taxonomies' => isset( $coalesce_taxonomies ) ? $coalesce_taxonomies : '',
640 | 'attributed_to' => $attributed_to,
641 | );
642 | $sql .= $this->query_post_type_open( $post_type_params, $sql_join );
643 |
644 | // Handle custom field weights.
645 | if ( isset( $post_type_weights['weights']['cf'] )
646 | && is_array( $post_type_weights['weights']['cf'] )
647 | && ! empty( $post_type_weights['weights']['cf'] ) ) {
648 | $sql .= $this->query_post_type_custom_field_weights(
649 | $post_type,
650 | $post_type_weights['weights']['cf'],
651 | $sql_term_where,
652 | $sql_status,
653 | $sql_join,
654 | $sql_conditions
655 | );
656 | }
657 |
658 | // Handle taxonomy weights.
659 | if ( isset( $post_type_weights['weights']['tax'] )
660 | && is_array( $post_type_weights['weights']['tax'] )
661 | && ! empty( $post_type_weights['weights']['tax'] ) ) {
662 | $sql .= $this->query_post_type_taxonomy_weights(
663 | $post_type,
664 | $post_type_weights['weights']['tax'],
665 | $sql_term_where,
666 | $sql_status,
667 | $sql_join,
668 | $sql_conditions
669 | );
670 | }
671 |
672 | // Close out the per-post type sub-query.
673 | $attribute_to = isset( $post_type_weights['options']['attribute_to'] ) ? absint( $post_type_weights['options']['attribute_to'] ) : false;
674 | $sql .= $this->query_post_type_close(
675 | $post_type,
676 | $attribute_to,
677 | $sql_term_where,
678 | $sql_status,
679 | $sql_conditions
680 | );
681 | }
682 | }
683 | }
684 |
685 | $sql .= " LEFT JOIN {$this->query->db_prefix}index ON {$this->query->db_prefix}index.post_id = {$this->wpdb->prefix}posts.ID ";
686 | $sql .= " LEFT JOIN {$this->query->db_prefix}terms ON {$this->query->db_prefix}terms.id = {$this->query->db_prefix}index.term ";
687 | $sql .= ' WHERE ';
688 | $sql .= $this->query_limit_post_type_to_weight();
689 |
690 | /**
691 | * SearchWP hotfix.
692 | */
693 | $old_query_sql = $this->query->sql;
694 | $sql .= $this->query->query_limit_pool_by_stem();
695 |
696 | if ( $this->query->sql !== $old_query_sql ) {
697 | $sql .= substr( $this->query->sql, strlen( $old_query_sql ) );
698 | $this->query->sql = $old_query_sql;
699 | }
700 | $sql .= $this->query->post_status_limiter_sql( $this->query->engineSettings );
701 | $sql .= ' GROUP BY post_id';
702 | $sql .= $this->query->only_full_group_by_fix_for_term();
703 | $sql .= " ) AS term{$term_counter} ON term{$term_counter}.post_id = {$this->wpdb->prefix}posts.ID ";
704 |
705 | $term_counter++;
706 | }
707 |
708 | $cursor_id = $this->get_cursor_post()->ID;
709 |
710 | $sql .= "WHERE {$this->wpdb->prefix}posts.ID = {$cursor_id}";
711 | return $sql;
712 | }
713 |
714 | /**
715 | * Wrapper function query args
716 | *
717 | * @param string $name Name of desired query arg.
718 | *
719 | * @return null|mixed
720 | */
721 | public function get_query_arg( $name ) {
722 | return empty( $this->query_args[ $name ] ) ? null : $this->query_args[ $name ];
723 | }
724 |
725 | /**
726 | * Returns the SQL statement created by the CursorBuilder.
727 | *
728 | * @return string
729 | */
730 | public function to_sql() {
731 | return ' AND ' . $this->builder->to_sql();
732 | }
733 |
734 | /**
735 | * Use post date based comparison
736 | */
737 | private function compare_with_date() {
738 | $this->builder->add_field( "{$this->wpdb->posts}.post_date", $this->get_cursor_post()->post_date, 'DATETIME' );
739 | }
740 |
741 | /**
742 | * Use post weight based comparison
743 | */
744 | private function compare_with_weight() {
745 | $this->builder->add_field( $this->posts_weight, $this->cursor_post_weight );
746 | }
747 |
748 | /**
749 | * Return the additional AND operators for the where statement
750 | *
751 | * @return string|null
752 | */
753 | public function get_where() {
754 |
755 | /**
756 | * Ensure the cursor_offset is a positive integer
757 | */
758 | if ( ! is_integer( $this->cursor_offset ) || 0 >= $this->cursor_offset ) {
759 | return '';
760 | }
761 |
762 | /**
763 | * If we have bad cursor just skip...
764 | */
765 | if ( ! $this->get_cursor_post() ) {
766 | return '';
767 | }
768 |
769 | $this->compare_with_weight();
770 | $this->compare_with_date();
771 | $this->builder->add_field( "{$this->wpdb->posts}.ID", $this->cursor_offset, 'ID' );
772 |
773 | return $this->to_sql();
774 | }
775 |
776 | /**
777 | * Returns the ORDER BY statement for the SWP Query.
778 | *
779 | * @return string
780 | */
781 | public function get_orderby() {
782 | $order = $this->get_query_arg( 'order' );
783 | return "ORDER BY finalweight {$order}, post_date {$order}, post_id DESC ";
784 | }
785 | }
786 |
--------------------------------------------------------------------------------
/includes/type/enum/class-meta-compare.php:
--------------------------------------------------------------------------------
1 | register_enum_type(
22 | 'SearchWPMetaCompare',
23 | array(
24 | 'values' => array(
25 | 'EQUAL_TO' => array(
26 | 'name' => 'EQUAL_TO',
27 | 'value' => '=',
28 | ),
29 | 'NOT_EQUAL_TO' => array(
30 | 'name' => 'NOT_EQUAL_TO',
31 | 'value' => '!=',
32 | ),
33 | 'GREATER_THAN' => array(
34 | 'name' => 'GREATER_THAN',
35 | 'value' => '>',
36 | ),
37 | 'GREATER_THAN_OR_EQUAL_TO' => array(
38 | 'name' => 'GREATER_THAN_OR_EQUAL_TO',
39 | 'value' => '>=',
40 | ),
41 | 'LESS_THAN' => array(
42 | 'name' => 'LESS_THAN',
43 | 'value' => '<',
44 | ),
45 | 'LESS_THAN_OR_EQUAL_TO' => array(
46 | 'name' => 'LESS_THAN_OR_EQUAL_TO',
47 | 'value' => '<=',
48 | ),
49 | 'LIKE' => array(
50 | 'name' => 'LIKE',
51 | 'value' => 'LIKE',
52 | ),
53 | 'NOT_LIKE' => array(
54 | 'name' => 'NOT_LIKE',
55 | 'value' => 'NOT LIKE',
56 | ),
57 | 'IN' => array(
58 | 'name' => 'IN',
59 | 'value' => 'IN',
60 | ),
61 | 'NOT_IN' => array(
62 | 'name' => 'NOT_IN',
63 | 'value' => 'NOT IN',
64 | ),
65 | 'BETWEEN' => array(
66 | 'name' => 'BETWEEN',
67 | 'value' => 'BETWEEN',
68 | ),
69 | 'NOT_BETWEEN' => array(
70 | 'name' => 'NOT_BETWEEN',
71 | 'value' => 'NOT BETWEEN',
72 | ),
73 | 'EXISTS' => array(
74 | 'name' => 'EXISTS',
75 | 'value' => 'EXISTS',
76 | ),
77 | 'NOT_EXISTS' => array(
78 | 'name' => 'NOT_EXISTS',
79 | 'value' => 'NOT EXISTS',
80 | ),
81 | ),
82 | )
83 | );
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/includes/type/enum/class-meta-type.php:
--------------------------------------------------------------------------------
1 | register_enum_type(
22 | 'SearchWPMetaType',
23 | array(
24 | 'values' => array(
25 | 'NUMERIC' => array(
26 | 'name' => 'NUMERIC',
27 | 'value' => 'NUMERIC',
28 | ),
29 | 'BINARY' => array(
30 | 'name' => 'BINARY',
31 | 'value' => 'BINARY',
32 | ),
33 | 'CHAR' => array(
34 | 'name' => 'CHAR',
35 | 'value' => 'CHAR',
36 | ),
37 | 'DATE' => array(
38 | 'name' => 'DATE',
39 | 'value' => 'DATE',
40 | ),
41 | 'DATETIME' => array(
42 | 'name' => 'DATETIME',
43 | 'value' => 'DATETIME',
44 | ),
45 | 'DECIMAL' => array(
46 | 'name' => 'DECIMAL',
47 | 'value' => 'DECIMAL',
48 | ),
49 | 'SIGNED' => array(
50 | 'name' => 'SIGNED',
51 | 'value' => 'SIGNED',
52 | ),
53 | 'TIME' => array(
54 | 'name' => 'TIME',
55 | 'value' => 'TIME',
56 | ),
57 | 'UNSIGNED' => array(
58 | 'name' => 'UNSIGNED',
59 | 'value' => 'UNSIGNED',
60 | ),
61 | ),
62 | )
63 | );
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/includes/type/enum/class-tax-query-field.php:
--------------------------------------------------------------------------------
1 | register_enum_type(
22 | 'SearchWPTaxQueryField',
23 | array(
24 | 'description' => __( 'Which field to select taxonomy term by. Default value is "term_id"', 'ql-search' ),
25 | 'values' => array(
26 | 'ID' => array(
27 | 'name' => 'ID',
28 | 'value' => 'term_id',
29 | ),
30 | 'NAME' => array(
31 | 'name' => 'NAME',
32 | 'value' => 'name',
33 | ),
34 | 'SLUG' => array(
35 | 'name' => 'SLUG',
36 | 'value' => 'slug',
37 | ),
38 | 'TAXONOMY_ID' => array(
39 | 'name' => 'TAXONOMY_ID',
40 | 'value' => 'term_taxonomy_id',
41 | ),
42 | ),
43 | )
44 | );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/includes/type/enum/class-tax-query-operator.php:
--------------------------------------------------------------------------------
1 | register_enum_type(
22 | 'SearchWPTaxQueryOperator',
23 | array(
24 | 'values' => array(
25 | 'IN' => array(
26 | 'name' => 'IN',
27 | 'value' => 'IN',
28 | ),
29 | 'NOT_IN' => array(
30 | 'name' => 'NOT_IN',
31 | 'value' => 'NOT IN',
32 | ),
33 | 'AND' => array(
34 | 'name' => 'AND',
35 | 'value' => 'AND',
36 | ),
37 | 'EXISTS' => array(
38 | 'name' => 'EXISTS',
39 | 'value' => 'EXISTS',
40 | ),
41 | 'NOT_EXISTS' => array(
42 | 'name' => 'NOT_EXISTS',
43 | 'value' => 'NOT EXISTS',
44 | ),
45 | ),
46 | )
47 | );
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/includes/type/input/class-meta-array-input.php:
--------------------------------------------------------------------------------
1 | register_input_type(
22 | 'SearchWPMetaArrayInput',
23 | array(
24 | 'fields' => array(
25 | 'key' => array(
26 | 'type' => 'String',
27 | 'description' => __( 'Custom field key', 'ql-search' ),
28 | ),
29 | 'value' => array(
30 | 'type' => 'String',
31 | 'description' => __( 'Custom field value', 'ql-search' ),
32 | ),
33 | 'compare' => array(
34 | 'type' => 'SearchWPMetaCompare',
35 | 'description' => __( 'Custom field value', 'ql-search' ),
36 | ),
37 | 'type' => array(
38 | 'type' => 'SearchWPMetaType',
39 | 'description' => __( 'Custom field value', 'ql-search' ),
40 | ),
41 | ),
42 | )
43 | );
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/includes/type/input/class-meta-query-input.php:
--------------------------------------------------------------------------------
1 | register_input_type(
22 | 'SearchWPMetaQueryInput',
23 | array(
24 | 'fields' => array(
25 | 'relation' => array(
26 | 'type' => 'RelationEnum',
27 | ),
28 | 'metaArray' => array(
29 | 'type' => array( 'list_of' => 'SearchWPMetaArrayInput' ),
30 | ),
31 | ),
32 | )
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/includes/type/input/class-tax-array-input.php:
--------------------------------------------------------------------------------
1 | register_input_type(
22 | 'SearchWPTaxArrayInput',
23 | array(
24 | 'fields' => array(
25 | 'taxonomy' => array(
26 | 'type' => 'TaxonomyEnum',
27 | ),
28 | 'field' => array(
29 | 'type' => 'SearchWPTaxQueryField',
30 | ),
31 | 'terms' => array(
32 | 'type' => array( 'list_of' => 'String' ),
33 | 'description' => __( 'A list of term slugs', 'ql-search' ),
34 | ),
35 | 'includeChildren' => array(
36 | 'type' => 'Boolean',
37 | 'description' => __( 'Whether or not to include children for hierarchical taxonomies. Defaults to false to improve performance (note that this is opposite of the default for WP_Query).', 'ql-search' ),
38 | ),
39 | 'operator' => array(
40 | 'type' => 'SearchWPTaxQueryOperator',
41 | ),
42 | ),
43 | )
44 | );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/includes/type/input/class-tax-query-input.php:
--------------------------------------------------------------------------------
1 | register_input_type(
22 | 'SearchWPTaxQueryInput',
23 | array(
24 | 'description' => __( 'Query objects based on taxonomy parameters', 'ql-search' ),
25 | 'fields' => array(
26 | 'relation' => array(
27 | 'type' => 'RelationEnum',
28 | ),
29 | 'taxArray' => array(
30 | 'type' => array(
31 | 'list_of' => 'SearchWPTaxArrayInput',
32 | ),
33 | ),
34 | ),
35 | )
36 | );
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 | ./tests/
13 | ./tests/test-sample.php
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ql-search.php:
--------------------------------------------------------------------------------
1 |
80 |
91 | user->create( array( 'role' => 'admin' ) );
10 | self::$post_objects = self::create_post_objects( $factory );
11 |
12 | // Initialize SearchWP Indexer.
13 | swp_index_test_posts( self::$post_objects );
14 | }
15 |
16 | public static function wpTearDownAfterClass() {
17 | swp_purge_index();
18 | }
19 |
20 | public function setUp() {
21 | // before
22 | parent::setUp();
23 |
24 | // your set up methods here
25 | }
26 |
27 | public function tearDown() {
28 | // your tear down methods here
29 |
30 | // then
31 | parent::tearDown();
32 | }
33 |
34 | private static function create_post_objects( $factory ) {
35 | $posts = array();
36 | $to_post_date = function( $time ) {
37 | $post_date = date( 'Y-m-d H:i:s', strtotime( $time ) );
38 | return $post_date;
39 | };
40 |
41 |
42 |
43 | $post_args = array(
44 | array(
45 | 'post_title' => 'Post One',
46 | 'post_content' => 'some hubbub',
47 | 'post_date' => $to_post_date( '-1 week' ),
48 | ),
49 | array(
50 | 'post_title' => 'Post Two',
51 | 'post_content' => 'some more hubbub',
52 | 'post_date' => $to_post_date( '-2 week' ),
53 | ),
54 | array(
55 | 'post_title' => 'Page One',
56 | 'post_content' => 'some more hubbub',
57 | 'post_date' => $to_post_date( '-3 week' ),
58 | 'post_type' => 'page'
59 | ),
60 | array(
61 | 'post_title' => 'Page Two',
62 | 'post_content' => 'some hubbub',
63 | 'post_date' => $to_post_date( '-4 week' ),
64 | 'post_type' => 'page'
65 | ),
66 | array(
67 | 'post_title' => 'Post Three',
68 | 'post_content' => 'some hubbub',
69 | 'post_date' => $to_post_date( '-5 week' ),
70 | ),
71 | array(
72 | 'post_title' => 'Post Four',
73 | 'post_content' => 'some more hubbub',
74 | 'post_date' => $to_post_date( '-6 week' ),
75 | ),
76 | array(
77 | 'post_title' => 'Page Three',
78 | 'post_content' => 'some more hubbub',
79 | 'post_date' => $to_post_date( '-7 week' ),
80 | 'post_type' => 'page'
81 | ),
82 | array(
83 | 'post_title' => 'Page Four',
84 | 'post_content' => 'some hubbub',
85 | 'post_date' => $to_post_date( '-8 week' ),
86 | 'post_type' => 'page'
87 | ),
88 | );
89 |
90 | foreach ( $post_args as $new_post ) {
91 | $args = array_merge(
92 | array(
93 | 'post_author' => self::$admin,
94 | 'post_status' => 'publish',
95 | 'post_type' => 'post',
96 | ),
97 | $new_post
98 | );
99 | $post_id = $factory->post->create_object( $args );
100 | $posts[] = get_post( $post_id );
101 | }
102 |
103 | return $posts;
104 | }
105 |
106 | private function expected_post_object( $index ) {
107 | $post = ! empty( self::$post_objects[ $index ] ) ? self::$post_objects[ $index ] : null;
108 | if ( ! $post ) {
109 | return null;
110 | }
111 |
112 | return array( 'id' => \GraphQLRelay\Relay::toGlobalId( $post->post_type, $post->ID ) );
113 | }
114 |
115 | // tests
116 | public function testSWPPaginationDESC() {
117 | $query = '
118 | query( $first: Int, $after: String, $where: RootQueryToSWPResultConnectionWhereArgs ) {
119 | searchWP(first: $first, after: $after, where: $where) {
120 | nodes {
121 | ... on Post {
122 | id
123 | }
124 | ... on Page {
125 | id
126 | }
127 | }
128 | pageInfo {
129 | hasNextPage
130 | endCursor
131 | }
132 | }
133 | }
134 | ';
135 |
136 | /**
137 | * Assertion One
138 | *
139 | * Get first four results
140 | */
141 | $variables = array(
142 | 'first' => 4,
143 | 'where' => array( 'input' => 'hubbub' )
144 | );
145 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
146 |
147 | // use --debug flag to view
148 | codecept_debug( $actual );
149 |
150 | // Test search info
151 | $this->assertNotEmpty( $actual['data'] );
152 | $this->assertNotEmpty( $actual['data']['searchWP'] );
153 | $this->assertNotEmpty( $actual['data']['searchWP']['pageInfo'] );
154 | $this->assertTrue( $actual['data']['searchWP']['pageInfo']['hasNextPage'] );
155 | $end_cursor = $actual['data']['searchWP']['pageInfo']['endCursor'];
156 |
157 | // Test search results
158 | $expected = array(
159 | $this->expected_post_object(0),
160 | $this->expected_post_object(1),
161 | $this->expected_post_object(2),
162 | $this->expected_post_object(3),
163 | );
164 | $this->assertNotEmpty( $actual['data']['searchWP']['nodes'] );
165 | $this->assertEquals( $expected, $actual['data']['searchWP']['nodes'] );
166 |
167 | /**
168 | * Assertion Two
169 | *
170 | * Get last two results after previous query end cursor
171 | */
172 | $variables = array(
173 | 'first' => 4,
174 | 'after' => $end_cursor,
175 | 'where' => array( 'input' => 'hubbub' )
176 | );
177 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
178 |
179 | // use --debug flag to view
180 | codecept_debug( $actual );
181 |
182 | // Test search info
183 | $this->assertNotEmpty( $actual['data'] );
184 | $this->assertNotEmpty( $actual['data']['searchWP'] );
185 | $this->assertNotEmpty( $actual['data']['searchWP']['pageInfo'] );
186 | $this->assertFalse( $actual['data']['searchWP']['pageInfo']['hasNextPage'] );
187 | $end_cursor = $actual['data']['searchWP']['pageInfo']['endCursor'];
188 |
189 | // Test search results
190 | $expected = array(
191 | $this->expected_post_object(4),
192 | $this->expected_post_object(5),
193 | $this->expected_post_object(6),
194 | $this->expected_post_object(7),
195 | );
196 | $this->assertNotEmpty( $actual['data']['searchWP']['nodes'] );
197 | $this->assertEquals( $expected, $actual['data']['searchWP']['nodes'] );
198 | }
199 |
200 | // tests
201 | public function testSWPPaginationASC() {
202 | $query = '
203 | query( $last: Int, $before: String, $where: RootQueryToSWPResultConnectionWhereArgs ) {
204 | searchWP(last: $last, before: $before, where: $where) {
205 | nodes {
206 | ... on Post {
207 | id
208 | }
209 | ... on Page {
210 | id
211 | }
212 | }
213 | pageInfo {
214 | hasPreviousPage
215 | startCursor
216 | }
217 | }
218 | }
219 | ';
220 |
221 | /**
222 | * Assertion One
223 | *
224 | * Get last four results
225 | */
226 | $variables = array(
227 | 'last' => 4,
228 | 'where' => array( 'input' => 'hubbub' )
229 | );
230 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
231 |
232 | // use --debug flag to view
233 | codecept_debug( $actual );
234 |
235 | // Test search info
236 | $this->assertNotEmpty( $actual['data'] );
237 | $this->assertNotEmpty( $actual['data']['searchWP'] );
238 | $this->assertNotEmpty( $actual['data']['searchWP']['pageInfo'] );
239 | $this->assertTrue( $actual['data']['searchWP']['pageInfo']['hasPreviousPage'] );
240 | $start_cursor = $actual['data']['searchWP']['pageInfo']['startCursor'];
241 |
242 | // Test search results
243 | $expected = array(
244 | $this->expected_post_object(4),
245 | $this->expected_post_object(5),
246 | $this->expected_post_object(6),
247 | $this->expected_post_object(7),
248 | );
249 | $this->assertNotEmpty( $actual['data']['searchWP']['nodes'] );
250 | $this->assertEquals( $expected, $actual['data']['searchWP']['nodes'] );
251 |
252 | /**
253 | * Assertion Two
254 | *
255 | * Get first two results before previous query start cursor
256 | */
257 | $variables = array(
258 | 'last' => 4,
259 | 'before' => $start_cursor,
260 | 'where' => array( 'input' => 'hubbub' )
261 | );
262 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
263 |
264 | // use --debug flag to view
265 | codecept_debug( $actual );
266 |
267 | // Test search info
268 | $this->assertNotEmpty( $actual['data'] );
269 | $this->assertNotEmpty( $actual['data']['searchWP'] );
270 | $this->assertNotEmpty( $actual['data']['searchWP']['pageInfo'] );
271 | $this->assertFalse( $actual['data']['searchWP']['pageInfo']['hasPreviousPage'] );
272 |
273 | // Test search results
274 | $expected = array(
275 | $this->expected_post_object(0),
276 | $this->expected_post_object(1),
277 | $this->expected_post_object(2),
278 | $this->expected_post_object(3)
279 | );
280 | $this->assertNotEmpty( $actual['data']['searchWP']['nodes'] );
281 | $this->assertEquals( $expected, $actual['data']['searchWP']['nodes'] );
282 | }
283 | }
--------------------------------------------------------------------------------
/tests/wpunit/SWPQueriesTest.php:
--------------------------------------------------------------------------------
1 | user->create( array( 'role' => 'admin' ) );
10 | self::$post_objects = self::create_post_objects( $factory );
11 |
12 | // Initialize SearchWP Indexer.
13 | swp_index_test_posts( self::$post_objects );
14 | }
15 |
16 | public function wpTearDownAfterClass() {
17 | swp_purge_index();
18 | }
19 |
20 | public function setUp() {
21 | // before
22 | parent::setUp();
23 |
24 | // your set up methods here
25 | }
26 |
27 | public function tearDown() {
28 | // your tear down methods here
29 |
30 | // then
31 | parent::tearDown();
32 | }
33 |
34 | private static function create_post_objects( $factory ) {
35 | $posts = array();
36 |
37 | $a_day_ago = date( 'Y-m-d H:i:s', strtotime( '-1 day' ) );
38 | $category_id = $factory->term->create(
39 | array(
40 | 'name' => 'Test category',
41 | 'slug' => 'test_category',
42 | 'taxonomy' => 'category',
43 | )
44 | );
45 | $tag_id = $factory->term->create(
46 | array(
47 | 'name' => 'Test tag',
48 | 'slug' => 'test_tag',
49 | 'taxonomy' => 'post_tag',
50 | )
51 | );
52 |
53 | $post_args = array(
54 | array(
55 | 'post_title' => 'Post One',
56 | 'post_content' => 'some content platform',
57 | ),
58 | array(
59 | 'post_title' => 'Post Two',
60 | 'post_content' => 'some more content',
61 | 'post_date' => $a_day_ago
62 | ),
63 | array(
64 | 'post_title' => 'Page One',
65 | 'post_content' => 'some more content platform',
66 | 'post_type' => 'page'
67 | ),
68 | array(
69 | 'post_title' => 'Page Two',
70 | 'post_content' => 'some content',
71 | 'post_type' => 'page'
72 | ),
73 | );
74 |
75 | foreach ( $post_args as $new_post ) {
76 | $args = array_merge(
77 | array(
78 | 'post_author' => self::$admin,
79 | 'post_status' => 'publish',
80 | 'post_type' => 'post',
81 | ),
82 | $new_post
83 | );
84 | $post_id = $factory->post->create_object( $args );
85 | update_post_meta( $post_id, 'test_meta', "key-{$post_id}" );
86 | $posts[] = get_post( $post_id );
87 | }
88 |
89 | wp_set_object_terms( $posts[0]->ID, $category_id, 'category' );
90 | wp_set_object_terms( $posts[1]->ID, $category_id, 'category' );
91 | wp_set_object_terms( $posts[2]->ID, $tag_id, 'post_tag' );
92 |
93 | return $posts;
94 | }
95 |
96 | private function expected_post_object( $index ) {
97 | $post = ! empty( self::$post_objects[ $index ] ) ? self::$post_objects[ $index ] : null;
98 | if ( ! $post ) {
99 | return null;
100 | }
101 |
102 | return array( 'id' => \GraphQLRelay\Relay::toGlobalId( $post->post_type, $post->ID ) );
103 | }
104 |
105 | // tests
106 | public function testSWPQuery() {
107 | $query = '
108 | query( $where: RootQueryToSWPResultConnectionWhereArgs ) {
109 | searchWP(where: $where) {
110 | nodes {
111 | ... on Post {
112 | id
113 | }
114 | ... on Page {
115 | id
116 | }
117 | }
118 | }
119 | }
120 | ';
121 |
122 | /**
123 | * Assertion One
124 | *
125 | * Tests basic search with "input".
126 | */
127 | $variables = array(
128 | 'where' => array(
129 | 'input' => 'platform',
130 | 'postType' => 'PAGE',
131 | )
132 | );
133 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
134 |
135 | // use --debug flag to view
136 | codecept_debug( $actual );
137 |
138 | $expected = array(
139 | 'data' => array(
140 | 'searchWP' => array(
141 | 'nodes' => array(
142 | $this->expected_post_object(2),
143 | )
144 | )
145 | )
146 | );
147 |
148 | $this->assertEquals( $expected, $actual );
149 |
150 | /**
151 | * Assertion Two
152 | *
153 | * Tests "postIn" parameter.
154 | */
155 | $variables = array(
156 | 'where' => array(
157 | 'input' => 'One',
158 | 'postIn' => array( self::$post_objects[2]->ID ),
159 | ),
160 | );
161 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
162 |
163 | // use --debug flag to view
164 | codecept_debug( $actual );
165 |
166 | $expected = array(
167 | 'data' => array(
168 | 'searchWP' => array(
169 | 'nodes' => array(
170 | $this->expected_post_object(2),
171 | )
172 | )
173 | )
174 | );
175 |
176 | $this->assertEquals( $expected, $actual );
177 |
178 | /**
179 | * Assertion Three
180 | *
181 | * Tests "postNotIn" parameter.
182 | */
183 | $variables = array(
184 | 'where' => array(
185 | 'input' => 'platform',
186 | 'postNotIn' => array( self::$post_objects[2]->ID, ),
187 | ),
188 | );
189 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
190 |
191 | // use --debug flag to view
192 | codecept_debug( $actual );
193 |
194 | $expected = array(
195 | 'data' => array(
196 | 'searchWP' => array(
197 | 'nodes' => array(
198 | $this->expected_post_object(0),
199 | )
200 | )
201 | )
202 | );
203 |
204 | $this->assertEquals( $expected, $actual );
205 |
206 | /**
207 | * Assertion Four
208 | *
209 | * Tests "taxonomies" parameter.
210 | */
211 | $variables = array(
212 | 'where' => array(
213 | 'input' => 'content',
214 | 'taxonomies' => array(
215 | 'relation' => 'OR',
216 | 'taxArray' => array(
217 | array(
218 | 'taxonomy' => 'TAG',
219 | 'field' => 'SLUG',
220 | 'terms' => 'test_tag'
221 | ),
222 | array(
223 | 'taxonomy' => 'CATEGORY',
224 | 'field' => 'SLUG',
225 | 'terms' => 'test_category'
226 | )
227 | )
228 | ),
229 | ),
230 | );
231 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
232 |
233 | // use --debug flag to view
234 | codecept_debug( $actual );
235 |
236 | $expected = array(
237 | 'data' => array(
238 | 'searchWP' => array(
239 | 'nodes' => array(
240 | $this->expected_post_object(2),
241 | $this->expected_post_object(0),
242 | $this->expected_post_object(1),
243 | )
244 | )
245 | )
246 | );
247 |
248 | $this->assertEquals( $expected, $actual );
249 |
250 | /**
251 | * Assertion Five
252 | *
253 | * Tests "meta" parameter.
254 | */
255 | $variables = array(
256 | 'where' => array(
257 | 'input' => 'some content',
258 | 'meta' => array(
259 | 'relation' => 'OR',
260 | 'metaArray' => array(
261 | array(
262 | 'key' => 'test_meta',
263 | 'value' => 'key-' . self::$post_objects[0]->ID,
264 | 'compare' => 'EQUAL_TO',
265 | ),
266 | array(
267 | 'key' => 'test_meta',
268 | 'value' => 'key-' . self::$post_objects[2]->ID,
269 | 'compare' => 'EQUAL_TO',
270 | ),
271 | ),
272 | ),
273 | ),
274 | );
275 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
276 |
277 | // use --debug flag to view
278 | codecept_debug( $actual );
279 |
280 | $expected = array(
281 | 'data' => array(
282 | 'searchWP' => array(
283 | 'nodes' => array(
284 | $this->expected_post_object(2),
285 | $this->expected_post_object(0),
286 | )
287 | )
288 | )
289 | );
290 |
291 | $this->assertEquals( $expected, $actual );
292 |
293 | /**
294 | * Assertion Six
295 | *
296 | * Tests "date" parameter.
297 | */
298 | $variables = array(
299 | 'where' => array(
300 | 'input' => 'some content',
301 | 'date' => array(
302 | array(
303 | 'year' => absint( date( 'Y', strtotime( '-1 day' ) ) ),
304 | 'month' => absint( date( 'm', strtotime( '-1 day' ) ) ),
305 | 'day' => absint( date( 'd', strtotime( '-1 day' ) ) ),
306 | ),
307 | ),
308 | ),
309 | );
310 | $actual = graphql( array( 'query' => $query, 'variables' => $variables ) );
311 |
312 | // use --debug flag to view
313 | codecept_debug( $actual );
314 |
315 | $expected = array(
316 | 'data' => array(
317 | 'searchWP' => array(
318 | 'nodes' => array(
319 | $this->expected_post_object(1),
320 | )
321 | )
322 | )
323 | );
324 |
325 | $this->assertEquals( $expected, $actual );
326 | }
327 | }
328 |
--------------------------------------------------------------------------------
/tests/wpunit/bootstrap.php:
--------------------------------------------------------------------------------
1 | \SearchWP\Utils::normalize_engine_config( $engine_model ),
19 | ] );
20 |
21 | foreach ( $post_objects as $post ) {
22 | $post_type = 'post.' . get_post_type( $post );
23 | $index->add( new \SearchWP\Entry( $post_type, $post->ID ) );
24 | }
25 | }
26 |
27 | /**
28 | * Purges default engines index.
29 | */
30 | function swp_purge_index() {
31 | $index = \SearchWP::$index;
32 | $index->reset();
33 |
34 | \SearchWP\Settings::update_engines_config( [] );
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/autoload.php:
--------------------------------------------------------------------------------
1 |
7 | * Jordi Boggiano
8 | *
9 | * For the full copyright and license information, please view the LICENSE
10 | * file that was distributed with this source code.
11 | */
12 |
13 | namespace Composer\Autoload;
14 |
15 | /**
16 | * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17 | *
18 | * $loader = new \Composer\Autoload\ClassLoader();
19 | *
20 | * // register classes with namespaces
21 | * $loader->add('Symfony\Component', __DIR__.'/component');
22 | * $loader->add('Symfony', __DIR__.'/framework');
23 | *
24 | * // activate the autoloader
25 | * $loader->register();
26 | *
27 | * // to enable searching the include path (eg. for PEAR packages)
28 | * $loader->setUseIncludePath(true);
29 | *
30 | * In this example, if you try to use a class in the Symfony\Component
31 | * namespace or one of its children (Symfony\Component\Console for instance),
32 | * the autoloader will first look for the class under the component/
33 | * directory, and it will then fallback to the framework/ directory if not
34 | * found before giving up.
35 | *
36 | * This class is loosely based on the Symfony UniversalClassLoader.
37 | *
38 | * @author Fabien Potencier
39 | * @author Jordi Boggiano
40 | * @see http://www.php-fig.org/psr/psr-0/
41 | * @see http://www.php-fig.org/psr/psr-4/
42 | */
43 | class ClassLoader
44 | {
45 | // PSR-4
46 | private $prefixLengthsPsr4 = array();
47 | private $prefixDirsPsr4 = array();
48 | private $fallbackDirsPsr4 = array();
49 |
50 | // PSR-0
51 | private $prefixesPsr0 = array();
52 | private $fallbackDirsPsr0 = array();
53 |
54 | private $useIncludePath = false;
55 | private $classMap = array();
56 | private $classMapAuthoritative = false;
57 | private $missingClasses = array();
58 | private $apcuPrefix;
59 |
60 | public function getPrefixes()
61 | {
62 | if (!empty($this->prefixesPsr0)) {
63 | return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
64 | }
65 |
66 | return array();
67 | }
68 |
69 | public function getPrefixesPsr4()
70 | {
71 | return $this->prefixDirsPsr4;
72 | }
73 |
74 | public function getFallbackDirs()
75 | {
76 | return $this->fallbackDirsPsr0;
77 | }
78 |
79 | public function getFallbackDirsPsr4()
80 | {
81 | return $this->fallbackDirsPsr4;
82 | }
83 |
84 | public function getClassMap()
85 | {
86 | return $this->classMap;
87 | }
88 |
89 | /**
90 | * @param array $classMap Class to filename map
91 | */
92 | public function addClassMap(array $classMap)
93 | {
94 | if ($this->classMap) {
95 | $this->classMap = array_merge($this->classMap, $classMap);
96 | } else {
97 | $this->classMap = $classMap;
98 | }
99 | }
100 |
101 | /**
102 | * Registers a set of PSR-0 directories for a given prefix, either
103 | * appending or prepending to the ones previously set for this prefix.
104 | *
105 | * @param string $prefix The prefix
106 | * @param array|string $paths The PSR-0 root directories
107 | * @param bool $prepend Whether to prepend the directories
108 | */
109 | public function add($prefix, $paths, $prepend = false)
110 | {
111 | if (!$prefix) {
112 | if ($prepend) {
113 | $this->fallbackDirsPsr0 = array_merge(
114 | (array) $paths,
115 | $this->fallbackDirsPsr0
116 | );
117 | } else {
118 | $this->fallbackDirsPsr0 = array_merge(
119 | $this->fallbackDirsPsr0,
120 | (array) $paths
121 | );
122 | }
123 |
124 | return;
125 | }
126 |
127 | $first = $prefix[0];
128 | if (!isset($this->prefixesPsr0[$first][$prefix])) {
129 | $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130 |
131 | return;
132 | }
133 | if ($prepend) {
134 | $this->prefixesPsr0[$first][$prefix] = array_merge(
135 | (array) $paths,
136 | $this->prefixesPsr0[$first][$prefix]
137 | );
138 | } else {
139 | $this->prefixesPsr0[$first][$prefix] = array_merge(
140 | $this->prefixesPsr0[$first][$prefix],
141 | (array) $paths
142 | );
143 | }
144 | }
145 |
146 | /**
147 | * Registers a set of PSR-4 directories for a given namespace, either
148 | * appending or prepending to the ones previously set for this namespace.
149 | *
150 | * @param string $prefix The prefix/namespace, with trailing '\\'
151 | * @param array|string $paths The PSR-4 base directories
152 | * @param bool $prepend Whether to prepend the directories
153 | *
154 | * @throws \InvalidArgumentException
155 | */
156 | public function addPsr4($prefix, $paths, $prepend = false)
157 | {
158 | if (!$prefix) {
159 | // Register directories for the root namespace.
160 | if ($prepend) {
161 | $this->fallbackDirsPsr4 = array_merge(
162 | (array) $paths,
163 | $this->fallbackDirsPsr4
164 | );
165 | } else {
166 | $this->fallbackDirsPsr4 = array_merge(
167 | $this->fallbackDirsPsr4,
168 | (array) $paths
169 | );
170 | }
171 | } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172 | // Register directories for a new namespace.
173 | $length = strlen($prefix);
174 | if ('\\' !== $prefix[$length - 1]) {
175 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176 | }
177 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178 | $this->prefixDirsPsr4[$prefix] = (array) $paths;
179 | } elseif ($prepend) {
180 | // Prepend directories for an already registered namespace.
181 | $this->prefixDirsPsr4[$prefix] = array_merge(
182 | (array) $paths,
183 | $this->prefixDirsPsr4[$prefix]
184 | );
185 | } else {
186 | // Append directories for an already registered namespace.
187 | $this->prefixDirsPsr4[$prefix] = array_merge(
188 | $this->prefixDirsPsr4[$prefix],
189 | (array) $paths
190 | );
191 | }
192 | }
193 |
194 | /**
195 | * Registers a set of PSR-0 directories for a given prefix,
196 | * replacing any others previously set for this prefix.
197 | *
198 | * @param string $prefix The prefix
199 | * @param array|string $paths The PSR-0 base directories
200 | */
201 | public function set($prefix, $paths)
202 | {
203 | if (!$prefix) {
204 | $this->fallbackDirsPsr0 = (array) $paths;
205 | } else {
206 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207 | }
208 | }
209 |
210 | /**
211 | * Registers a set of PSR-4 directories for a given namespace,
212 | * replacing any others previously set for this namespace.
213 | *
214 | * @param string $prefix The prefix/namespace, with trailing '\\'
215 | * @param array|string $paths The PSR-4 base directories
216 | *
217 | * @throws \InvalidArgumentException
218 | */
219 | public function setPsr4($prefix, $paths)
220 | {
221 | if (!$prefix) {
222 | $this->fallbackDirsPsr4 = (array) $paths;
223 | } else {
224 | $length = strlen($prefix);
225 | if ('\\' !== $prefix[$length - 1]) {
226 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227 | }
228 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229 | $this->prefixDirsPsr4[$prefix] = (array) $paths;
230 | }
231 | }
232 |
233 | /**
234 | * Turns on searching the include path for class files.
235 | *
236 | * @param bool $useIncludePath
237 | */
238 | public function setUseIncludePath($useIncludePath)
239 | {
240 | $this->useIncludePath = $useIncludePath;
241 | }
242 |
243 | /**
244 | * Can be used to check if the autoloader uses the include path to check
245 | * for classes.
246 | *
247 | * @return bool
248 | */
249 | public function getUseIncludePath()
250 | {
251 | return $this->useIncludePath;
252 | }
253 |
254 | /**
255 | * Turns off searching the prefix and fallback directories for classes
256 | * that have not been registered with the class map.
257 | *
258 | * @param bool $classMapAuthoritative
259 | */
260 | public function setClassMapAuthoritative($classMapAuthoritative)
261 | {
262 | $this->classMapAuthoritative = $classMapAuthoritative;
263 | }
264 |
265 | /**
266 | * Should class lookup fail if not found in the current class map?
267 | *
268 | * @return bool
269 | */
270 | public function isClassMapAuthoritative()
271 | {
272 | return $this->classMapAuthoritative;
273 | }
274 |
275 | /**
276 | * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277 | *
278 | * @param string|null $apcuPrefix
279 | */
280 | public function setApcuPrefix($apcuPrefix)
281 | {
282 | $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283 | }
284 |
285 | /**
286 | * The APCu prefix in use, or null if APCu caching is not enabled.
287 | *
288 | * @return string|null
289 | */
290 | public function getApcuPrefix()
291 | {
292 | return $this->apcuPrefix;
293 | }
294 |
295 | /**
296 | * Registers this instance as an autoloader.
297 | *
298 | * @param bool $prepend Whether to prepend the autoloader or not
299 | */
300 | public function register($prepend = false)
301 | {
302 | spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303 | }
304 |
305 | /**
306 | * Unregisters this instance as an autoloader.
307 | */
308 | public function unregister()
309 | {
310 | spl_autoload_unregister(array($this, 'loadClass'));
311 | }
312 |
313 | /**
314 | * Loads the given class or interface.
315 | *
316 | * @param string $class The name of the class
317 | * @return bool|null True if loaded, null otherwise
318 | */
319 | public function loadClass($class)
320 | {
321 | if ($file = $this->findFile($class)) {
322 | includeFile($file);
323 |
324 | return true;
325 | }
326 | }
327 |
328 | /**
329 | * Finds the path to the file where the class is defined.
330 | *
331 | * @param string $class The name of the class
332 | *
333 | * @return string|false The path if found, false otherwise
334 | */
335 | public function findFile($class)
336 | {
337 | // class map lookup
338 | if (isset($this->classMap[$class])) {
339 | return $this->classMap[$class];
340 | }
341 | if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342 | return false;
343 | }
344 | if (null !== $this->apcuPrefix) {
345 | $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346 | if ($hit) {
347 | return $file;
348 | }
349 | }
350 |
351 | $file = $this->findFileWithExtension($class, '.php');
352 |
353 | // Search for Hack files if we are running on HHVM
354 | if (false === $file && defined('HHVM_VERSION')) {
355 | $file = $this->findFileWithExtension($class, '.hh');
356 | }
357 |
358 | if (null !== $this->apcuPrefix) {
359 | apcu_add($this->apcuPrefix.$class, $file);
360 | }
361 |
362 | if (false === $file) {
363 | // Remember that this class does not exist.
364 | $this->missingClasses[$class] = true;
365 | }
366 |
367 | return $file;
368 | }
369 |
370 | private function findFileWithExtension($class, $ext)
371 | {
372 | // PSR-4 lookup
373 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374 |
375 | $first = $class[0];
376 | if (isset($this->prefixLengthsPsr4[$first])) {
377 | $subPath = $class;
378 | while (false !== $lastPos = strrpos($subPath, '\\')) {
379 | $subPath = substr($subPath, 0, $lastPos);
380 | $search = $subPath . '\\';
381 | if (isset($this->prefixDirsPsr4[$search])) {
382 | $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383 | foreach ($this->prefixDirsPsr4[$search] as $dir) {
384 | if (file_exists($file = $dir . $pathEnd)) {
385 | return $file;
386 | }
387 | }
388 | }
389 | }
390 | }
391 |
392 | // PSR-4 fallback dirs
393 | foreach ($this->fallbackDirsPsr4 as $dir) {
394 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395 | return $file;
396 | }
397 | }
398 |
399 | // PSR-0 lookup
400 | if (false !== $pos = strrpos($class, '\\')) {
401 | // namespaced class name
402 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404 | } else {
405 | // PEAR-like class name
406 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407 | }
408 |
409 | if (isset($this->prefixesPsr0[$first])) {
410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411 | if (0 === strpos($class, $prefix)) {
412 | foreach ($dirs as $dir) {
413 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414 | return $file;
415 | }
416 | }
417 | }
418 | }
419 | }
420 |
421 | // PSR-0 fallback dirs
422 | foreach ($this->fallbackDirsPsr0 as $dir) {
423 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424 | return $file;
425 | }
426 | }
427 |
428 | // PSR-0 include paths.
429 | if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430 | return $file;
431 | }
432 |
433 | return false;
434 | }
435 | }
436 |
437 | /**
438 | * Scope isolated include.
439 | *
440 | * Prevents access to $this/self from included files.
441 | */
442 | function includeFile($file)
443 | {
444 | include $file;
445 | }
446 |
--------------------------------------------------------------------------------
/vendor/composer/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Copyright (c) Nils Adermann, Jordi Boggiano
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is furnished
9 | to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
22 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_classmap.php:
--------------------------------------------------------------------------------
1 | $baseDir . '/includes/class-ql-search.php',
10 | 'WPGraphQL\\SearchWP\\Connection\\SWP' => $baseDir . '/includes/connection/class-swp.php',
11 | 'WPGraphQL\\SearchWP\\Core_Schema_Filters' => $baseDir . '/includes/class-core-schema-filters.php',
12 | 'WPGraphQL\\SearchWP\\Data\\Config' => $baseDir . '/includes/data/class-config.php',
13 | 'WPGraphQL\\SearchWP\\Data\\Connection\\SWP_Connection_Resolver' => $baseDir . '/includes/data/connection/class-swp-connection-resolver.php',
14 | 'WPGraphQL\\SearchWP\\Data\\Cursor\\SWP_Query_Cursor' => $baseDir . '/includes/data/cursor/class-swp-query-cursor.php',
15 | 'WPGraphQL\\SearchWP\\Data\\Factory' => $baseDir . '/includes/data/class-factory.php',
16 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Meta_Compare' => $baseDir . '/includes/type/enum/class-meta-compare.php',
17 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Meta_Type' => $baseDir . '/includes/type/enum/class-meta-type.php',
18 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Tax_Query_Field' => $baseDir . '/includes/type/enum/class-tax-query-field.php',
19 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Tax_Query_Operator' => $baseDir . '/includes/type/enum/class-tax-query-operator.php',
20 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Meta_Array_Input' => $baseDir . '/includes/type/input/class-meta-array-input.php',
21 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Meta_Query_Input' => $baseDir . '/includes/type/input/class-meta-query-input.php',
22 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Tax_Array_Input' => $baseDir . '/includes/type/input/class-tax-array-input.php',
23 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Tax_Query_Input' => $baseDir . '/includes/type/input/class-tax-query-input.php',
24 | 'WPGraphQL\\SearchWP\\Type\\WPUnion\\SWP_Result' => $baseDir . '/includes/type/union/class-swp-result.php',
25 | 'WPGraphQL\\SearchWP\\Type_Registry' => $baseDir . '/includes/class-type-registry.php',
26 | );
27 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_namespaces.php:
--------------------------------------------------------------------------------
1 | array($baseDir . '/includes'),
10 | );
11 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_real.php:
--------------------------------------------------------------------------------
1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
30 | if ($useStaticLoader) {
31 | require_once __DIR__ . '/autoload_static.php';
32 |
33 | call_user_func(\Composer\Autoload\ComposerStaticInitf9b62910251909e390541b18e98a3d63::getInitializer($loader));
34 | } else {
35 | $map = require __DIR__ . '/autoload_namespaces.php';
36 | foreach ($map as $namespace => $path) {
37 | $loader->set($namespace, $path);
38 | }
39 |
40 | $map = require __DIR__ . '/autoload_psr4.php';
41 | foreach ($map as $namespace => $path) {
42 | $loader->setPsr4($namespace, $path);
43 | }
44 |
45 | $classMap = require __DIR__ . '/autoload_classmap.php';
46 | if ($classMap) {
47 | $loader->addClassMap($classMap);
48 | }
49 | }
50 |
51 | $loader->register(true);
52 |
53 | return $loader;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/composer/autoload_static.php:
--------------------------------------------------------------------------------
1 |
11 | array (
12 | 'WPGraphQL\\SearchWP\\' => 19,
13 | ),
14 | );
15 |
16 | public static $prefixDirsPsr4 = array (
17 | 'WPGraphQL\\SearchWP\\' =>
18 | array (
19 | 0 => __DIR__ . '/../..' . '/includes',
20 | ),
21 | );
22 |
23 | public static $classMap = array (
24 | 'QL_Search' => __DIR__ . '/../..' . '/includes/class-ql-search.php',
25 | 'WPGraphQL\\SearchWP\\Connection\\SWP' => __DIR__ . '/../..' . '/includes/connection/class-swp.php',
26 | 'WPGraphQL\\SearchWP\\Core_Schema_Filters' => __DIR__ . '/../..' . '/includes/class-core-schema-filters.php',
27 | 'WPGraphQL\\SearchWP\\Data\\Config' => __DIR__ . '/../..' . '/includes/data/class-config.php',
28 | 'WPGraphQL\\SearchWP\\Data\\Connection\\SWP_Connection_Resolver' => __DIR__ . '/../..' . '/includes/data/connection/class-swp-connection-resolver.php',
29 | 'WPGraphQL\\SearchWP\\Data\\Cursor\\SWP_Query_Cursor' => __DIR__ . '/../..' . '/includes/data/cursor/class-swp-query-cursor.php',
30 | 'WPGraphQL\\SearchWP\\Data\\Factory' => __DIR__ . '/../..' . '/includes/data/class-factory.php',
31 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Meta_Compare' => __DIR__ . '/../..' . '/includes/type/enum/class-meta-compare.php',
32 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Meta_Type' => __DIR__ . '/../..' . '/includes/type/enum/class-meta-type.php',
33 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Tax_Query_Field' => __DIR__ . '/../..' . '/includes/type/enum/class-tax-query-field.php',
34 | 'WPGraphQL\\SearchWP\\Type\\WPEnum\\Tax_Query_Operator' => __DIR__ . '/../..' . '/includes/type/enum/class-tax-query-operator.php',
35 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Meta_Array_Input' => __DIR__ . '/../..' . '/includes/type/input/class-meta-array-input.php',
36 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Meta_Query_Input' => __DIR__ . '/../..' . '/includes/type/input/class-meta-query-input.php',
37 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Tax_Array_Input' => __DIR__ . '/../..' . '/includes/type/input/class-tax-array-input.php',
38 | 'WPGraphQL\\SearchWP\\Type\\WPInputObject\\Tax_Query_Input' => __DIR__ . '/../..' . '/includes/type/input/class-tax-query-input.php',
39 | 'WPGraphQL\\SearchWP\\Type\\WPUnion\\SWP_Result' => __DIR__ . '/../..' . '/includes/type/union/class-swp-result.php',
40 | 'WPGraphQL\\SearchWP\\Type_Registry' => __DIR__ . '/../..' . '/includes/class-type-registry.php',
41 | );
42 |
43 | public static function getInitializer(ClassLoader $loader)
44 | {
45 | return \Closure::bind(function () use ($loader) {
46 | $loader->prefixLengthsPsr4 = ComposerStaticInitf9b62910251909e390541b18e98a3d63::$prefixLengthsPsr4;
47 | $loader->prefixDirsPsr4 = ComposerStaticInitf9b62910251909e390541b18e98a3d63::$prefixDirsPsr4;
48 | $loader->classMap = ComposerStaticInitf9b62910251909e390541b18e98a3d63::$classMap;
49 |
50 | }, null, ClassLoader::class);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------