| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/the-post-grid/lib/classes/ |
Upload File : |
<?php
if (!class_exists('rtTPGAjaxResponse')):
class rtTPGAjaxResponse
{
function __construct() {
add_action('wp_ajax_rtTPGSettings', array($this, 'rtTPGSaveSettings'));
add_action('wp_ajax_rtTPGShortCodeList', array($this, 'shortCodeList'));
add_action('wp_ajax_rtTPGTaxonomyListByPostType', array($this, 'rtTPGTaxonomyListByPostType'));
add_action('wp_ajax_rtTPGIsotopeFilter', array($this, 'rtTPGIsotopeFilter'));
add_action('wp_ajax_rtTPGTermListByTaxonomy', array($this, 'rtTPGTermListByTaxonomy'));
}
function rtTPGSaveSettings() {
global $rtTPG;
$rtTPG->rtTPGSettingFields();
$error = true;
$msg = null;
if ($rtTPG->verifyNonce()) {
unset($_REQUEST['action']);
unset($_REQUEST[$rtTPG->nonceId()]);
unset($_REQUEST['_wp_http_referer']);
update_option($rtTPG->options['settings'], $_REQUEST);
$error = false;
$msg = __('Settings successfully updated', 'the-post-grid');
} else {
$msg = __('Security Error !!', 'the-post-grid');
}
wp_send_json(array(
'error' => $error,
'msg' => $msg
));
die();
}
function rtTPGTaxonomyListByPostType() {
global $rtTPG;
$error = true;
$msg = $data = null;
if ($rtTPG->verifyNonce()) {
$error = false;
$taxonomies = $rtTPG->rt_get_all_taxonomy_by_post_type(isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : null);
if (is_array($taxonomies) && !empty($taxonomies)) {
$data .= $rtTPG->rtFieldGenerator(
array(
'type' => 'checkbox',
'name' => 'tpg_taxonomy',
'label' => 'Taxonomy',
'id' => 'post-taxonomy',
"multiple" => true,
'options' => $taxonomies
)
);
} else {
$data = '<div class="rt-field-wrapper">' . __('No Taxonomy found', 'the-post-grid') . '</div>';
}
} else {
$msg = __('Security error', 'the-post-grid');
}
wp_send_json(array('error' => $error, 'msg' => $msg, 'data' => $data));
die();
}
function rtTPGIsotopeFilter() {
global $rtTPG;
$error = true;
$msg = $data = null;
if ($rtTPG->verifyNonce()) {
$error = false;
$taxonomies = $rtTPG->rt_get_taxonomy_for_isotope_filter(isset($_REQUEST['post_type']) ? $_REQUEST['post_type'] : null);
if (is_array($taxonomies) && !empty($taxonomies)) {
foreach ($taxonomies as $tKey => $tax) {
$data .= "<option value='{$tKey}'>{$tax}</option>";
}
}
} else {
$msg = __('Security error', 'the-post-grid');
}
wp_send_json(array('error' => $error, 'msg' => $msg, 'data' => $data));
die();
}
function rtTPGTermListByTaxonomy() {
global $rtTPG;
$error = true;
$msg = $data = null;
if ($rtTPG->verifyNonce()) {
$error = false;
$taxonomy = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : null;
$data .= "<div class='term-filter-item-container {$taxonomy}'>";
$data .= $rtTPG->rtFieldGenerator(
array(
'type' => 'select',
'name' => 'term_' . $taxonomy,
'label' => ucfirst(str_replace('_', ' ', $taxonomy)),
'class' => 'rt-select2 full',
'id' => 'term-' . mt_rand(),
'holderClass' => "term-filter-item {$taxonomy}",
'value' => null,
"multiple" => true,
'options' => $rtTPG->rt_get_all_term_by_taxonomy($taxonomy)
)
);
$data .= $rtTPG->rtFieldGenerator(
array(
'type' => 'select',
'name' => 'term_operator_' . $taxonomy,
'label' => 'Operator',
'class' => 'rt-select2 full',
'holderClass' => "term-filter-item-operator {$taxonomy}",
'options' => $rtTPG->rtTermOperators()
)
);
$data .= "</div>";
} else {
$msg = __('Security error', 'the-post-grid');
}
wp_send_json(array('error' => $error, 'msg' => $msg, 'data' => $data));
die();
}
function shortCodeList() {
global $rtTPG;
$html = null;
$scQ = new WP_Query(array('post_type' => $rtTPG->post_type,
'order_by' => 'title',
'order' => 'DESC',
'post_status' => 'publish',
'posts_per_page' => -1
));
if ($scQ->have_posts()) {
$html .= "<div class='mce-container mce-form'>";
$html .= "<div class='mce-container-body'>";
$html .= '<label class="mce-widget mce-label" style="padding: 20px;font-weight: bold;" for="scid">' . __('Select Short code', 'the-post-grid') . '</label>';
$html .= "<select name='id' id='scid' style='width: 150px;margin: 15px;'>";
$html .= "<option value=''>" . __('Default', 'the-post-grid') . "</option>";
while ($scQ->have_posts()) {
$scQ->the_post();
$html .= "<option value='" . get_the_ID() . "'>" . get_the_title() . "</option>";
}
$html .= "</select>";
$html .= "</div>";
$html .= "</div>";
} else {
$html .= "<div>" . __('No shortCode found.', 'the-post-grid') . "</div>";
}
echo $html;
die();
}
}
endif;