getMainClass(); return $mainClass->getClassPrefix() . '_product_info'; } public function process() { /** * @var AffiliateImporterAbstract $mainClass */ $mainClass = $this->getMainClass(); $result = ["state" => "ok", "data" => ""]; $postId = isset($_POST['id']) ? sanitize_text_field($_POST['id']) : false; if (!$postId) { $result['state'] = 'error'; echo json_encode($result); wp_die(); } $externalId = get_post_meta($postId, "external_id", true); $timeValue = get_post_meta($postId, 'price_last_update', true); $timeValue = $timeValue ? date("Y-m-d H:i:s", $timeValue) : 'not updated'; $productUrl = get_post_meta($postId, 'product_url', true); $sellerUrl = get_post_meta($postId, 'seller_url', true); $content = array(); list($source, $externalId) = explode('#', $externalId); $content[] = "Source: " . $source . ""; $content[] = "Product url: here"; if ($sellerUrl) { $content[] = "Seller url: here"; } $content[] = "External ID: " . $externalId . ""; $content[] = "Last auto-update: " . $timeValue . ""; $content = apply_filters( $mainClass->getClassPrefix() . '_ajax_product_info', $content, $postId, $externalId, $source ); $result['data'] = array('content' => $content, 'id' => $postId); echo json_encode($result); wp_die(); } public function onlyForAdmin() { return true; } }