Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Kudos-Website
Commits
0599915e
Commit
0599915e
authored
Oct 06, 2020
by
Michael Iseard
Browse files
Rename to match class
parent
8de0aa9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/Ajax.php
0 → 100644
View file @
0599915e
<?php
namespace
App
;
use
App\Controllers\TemplateFaq
;
class
Ajax
{
public
function
__construct
()
{
add_action
(
'wp_ajax_get_questions'
,
[
$this
,
'get_questions'
]
);
add_action
(
'wp_ajax_nopriv_get_questions'
,
[
$this
,
'get_questions'
]
);
}
public
function
get_questions
()
{
// Check for nonce security
if
(
!
wp_verify_nonce
(
$_POST
[
'nonce'
],
'ajax-nonce'
)
)
{
die
(
'Nonce verification failed!'
);
}
$category
=
isset
(
$_POST
[
'category'
]
)
?
$_POST
[
'category'
]
:
null
;
$keywords
=
isset
(
$_POST
[
'keywords'
]
)
?
$_POST
[
'keywords'
]
:
null
;
$out
=
'<p>'
.
__
(
'Sorry, no results were found.'
,
'kudos-website'
)
.
'</p>'
;
$templateFaq
=
new
TemplateFaq
();
$questions
=
$templateFaq
->
questions
(
$category
,
$keywords
);
if
(
$questions
->
have_posts
()
)
:
$out
=
''
;
while
(
$questions
->
have_posts
()
)
:
$questions
->
the_post
();
$out
.
=
template
(
"partials.content-faq"
);
endwhile
;
endif
;
wp_send_json
(
$out
);
wp_die
();
}
}
new
Ajax
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment