remove bs one.com
4
admin_credentials.txt
Normal file
@ -0,0 +1,4 @@
|
||||
WordPress Admin Credentials:
|
||||
URL: http://localhost/wp-admin
|
||||
Username: admin
|
||||
Password: c59u3v2geHuIQMRP
|
||||
493
ai/LocalAIApi.php
Normal file
@ -0,0 +1,493 @@
|
||||
<?php
|
||||
// LocalAIApi — proxy client for the Responses API.
|
||||
// Usage (async: auto-polls status until ready):
|
||||
// require_once __DIR__ . '/ai/LocalAIApi.php';
|
||||
// $response = LocalAIApi::createResponse([
|
||||
// 'input' => [
|
||||
// ['role' => 'system', 'content' => 'You are a helpful assistant.'],
|
||||
// ['role' => 'user', 'content' => 'Tell me a bedtime story.'],
|
||||
// ],
|
||||
// ]);
|
||||
// if (!empty($response['success'])) {
|
||||
// // response['data'] contains full payload, e.g.:
|
||||
// // {
|
||||
// // "id": "resp_xxx",
|
||||
// // "status": "completed",
|
||||
// // "output": [
|
||||
// // {"type": "reasoning", "summary": []},
|
||||
// // {"type": "message", "content": [{"type": "output_text", "text": "Your final answer here."}]}
|
||||
// // ]
|
||||
// // }
|
||||
// $decoded = LocalAIApi::decodeJsonFromResponse($response); // or inspect $response['data'] / extractText(...)
|
||||
// }
|
||||
// Poll settings override:
|
||||
// LocalAIApi::createResponse($payload, ['poll_interval' => 5, 'poll_timeout' => 300]);
|
||||
|
||||
class LocalAIApi
|
||||
{
|
||||
/** @var array<string,mixed>|null */
|
||||
private static ?array $configCache = null;
|
||||
|
||||
/**
|
||||
* Signature compatible with the OpenAI Responses API.
|
||||
*
|
||||
* @param array<string,mixed> $params Request body (model, input, text, reasoning, metadata, etc.).
|
||||
* @param array<string,mixed> $options Extra options (timeout, verify_tls, headers, path, project_uuid).
|
||||
* @return array{
|
||||
* success:bool,
|
||||
* status?:int,
|
||||
* data?:mixed,
|
||||
* error?:string,
|
||||
* response?:mixed,
|
||||
* message?:string
|
||||
* }
|
||||
*/
|
||||
public static function createResponse(array $params, array $options = []): array
|
||||
{
|
||||
$cfg = self::config();
|
||||
$payload = $params;
|
||||
|
||||
if (empty($payload['input']) || !is_array($payload['input'])) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'input_missing',
|
||||
'message' => 'Parameter "input" is required and must be an array.',
|
||||
];
|
||||
}
|
||||
|
||||
if (!isset($payload['model']) || $payload['model'] === '') {
|
||||
$payload['model'] = $cfg['default_model'];
|
||||
}
|
||||
|
||||
$initial = self::request($options['path'] ?? null, $payload, $options);
|
||||
if (empty($initial['success'])) {
|
||||
return $initial;
|
||||
}
|
||||
|
||||
// Async flow: if backend returns ai_request_id, poll status until ready
|
||||
$data = $initial['data'] ?? null;
|
||||
if (is_array($data) && isset($data['ai_request_id'])) {
|
||||
$aiRequestId = $data['ai_request_id'];
|
||||
$pollTimeout = isset($options['poll_timeout']) ? (int) $options['poll_timeout'] : 300; // seconds
|
||||
$pollInterval = isset($options['poll_interval']) ? (int) $options['poll_interval'] : 5; // seconds
|
||||
return self::awaitResponse($aiRequestId, [
|
||||
'timeout' => $pollTimeout,
|
||||
'interval' => $pollInterval,
|
||||
'headers' => $options['headers'] ?? [],
|
||||
'timeout_per_call' => $options['timeout'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
return $initial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Snake_case alias for createResponse (matches the provided example).
|
||||
*
|
||||
* @param array<string,mixed> $params
|
||||
* @param array<string,mixed> $options
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function create_response(array $params, array $options = []): array
|
||||
{
|
||||
return self::createResponse($params, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a raw request to the AI proxy.
|
||||
*
|
||||
* @param string $path Endpoint (may be an absolute URL).
|
||||
* @param array<string,mixed> $payload JSON payload.
|
||||
* @param array<string,mixed> $options Additional request options.
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function request(?string $path = null, array $payload = [], array $options = []): array
|
||||
{
|
||||
$cfg = self::config();
|
||||
|
||||
$projectUuid = $cfg['project_uuid'];
|
||||
if (empty($projectUuid)) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'project_uuid_missing',
|
||||
'message' => 'PROJECT_UUID is not defined; aborting AI request.',
|
||||
];
|
||||
}
|
||||
|
||||
$defaultPath = $cfg['responses_path'] ?? null;
|
||||
$resolvedPath = $path ?? ($options['path'] ?? $defaultPath);
|
||||
if (empty($resolvedPath)) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'project_id_missing',
|
||||
'message' => 'PROJECT_ID is not defined; cannot resolve AI proxy endpoint.',
|
||||
];
|
||||
}
|
||||
|
||||
$url = self::buildUrl($resolvedPath, $cfg['base_url']);
|
||||
$baseTimeout = isset($cfg['timeout']) ? (int) $cfg['timeout'] : 30;
|
||||
$timeout = isset($options['timeout']) ? (int) $options['timeout'] : $baseTimeout;
|
||||
if ($timeout <= 0) {
|
||||
$timeout = 30;
|
||||
}
|
||||
|
||||
$baseVerifyTls = array_key_exists('verify_tls', $cfg) ? (bool) $cfg['verify_tls'] : true;
|
||||
$verifyTls = array_key_exists('verify_tls', $options)
|
||||
? (bool) $options['verify_tls']
|
||||
: $baseVerifyTls;
|
||||
|
||||
$projectHeader = $cfg['project_header'];
|
||||
|
||||
$headers = [
|
||||
'Content-Type: application/json',
|
||||
'Accept: application/json',
|
||||
];
|
||||
$headers[] = $projectHeader . ': ' . $projectUuid;
|
||||
if (!empty($options['headers']) && is_array($options['headers'])) {
|
||||
foreach ($options['headers'] as $header) {
|
||||
if (is_string($header) && $header !== '') {
|
||||
$headers[] = $header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($projectUuid) && !array_key_exists('project_uuid', $payload)) {
|
||||
$payload['project_uuid'] = $projectUuid;
|
||||
}
|
||||
|
||||
$body = json_encode($payload, JSON_UNESCAPED_UNICODE);
|
||||
if ($body === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'json_encode_failed',
|
||||
'message' => 'Failed to encode request body to JSON.',
|
||||
];
|
||||
}
|
||||
|
||||
return self::sendCurl($url, 'POST', $body, $headers, $timeout, $verifyTls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Poll AI request status until ready or timeout.
|
||||
*
|
||||
* @param int|string $aiRequestId
|
||||
* @param array<string,mixed> $options
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function awaitResponse($aiRequestId, array $options = []): array
|
||||
{
|
||||
$cfg = self::config();
|
||||
|
||||
$timeout = isset($options['timeout']) ? (int) $options['timeout'] : 300; // seconds
|
||||
$interval = isset($options['interval']) ? (int) $options['interval'] : 5; // seconds
|
||||
if ($interval <= 0) {
|
||||
$interval = 5;
|
||||
}
|
||||
$perCallTimeout = isset($options['timeout_per_call']) ? (int) $options['timeout_per_call'] : null;
|
||||
|
||||
$deadline = time() + max($timeout, $interval);
|
||||
$headers = $options['headers'] ?? [];
|
||||
|
||||
while (true) {
|
||||
$statusResp = self::fetchStatus($aiRequestId, [
|
||||
'headers' => $headers,
|
||||
'timeout' => $perCallTimeout,
|
||||
]);
|
||||
if (!empty($statusResp['success'])) {
|
||||
$data = $statusResp['data'] ?? [];
|
||||
if (is_array($data)) {
|
||||
$statusValue = $data['status'] ?? null;
|
||||
if ($statusValue === 'success') {
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200,
|
||||
'data' => $data['response'] ?? $data,
|
||||
];
|
||||
}
|
||||
if ($statusValue === 'failed') {
|
||||
return [
|
||||
'success' => false,
|
||||
'status' => 500,
|
||||
'error' => isset($data['error']) ? (string)$data['error'] : 'AI request failed',
|
||||
'data' => $data,
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $statusResp;
|
||||
}
|
||||
|
||||
if (time() >= $deadline) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'timeout',
|
||||
'message' => 'Timed out waiting for AI response.',
|
||||
];
|
||||
}
|
||||
sleep($interval);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch status for queued AI request.
|
||||
*
|
||||
* @param int|string $aiRequestId
|
||||
* @param array<string,mixed> $options
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function fetchStatus($aiRequestId, array $options = []): array
|
||||
{
|
||||
$cfg = self::config();
|
||||
$projectUuid = $cfg['project_uuid'];
|
||||
if (empty($projectUuid)) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'project_uuid_missing',
|
||||
'message' => 'PROJECT_UUID is not defined; aborting status check.',
|
||||
];
|
||||
}
|
||||
|
||||
$statusPath = self::resolveStatusPath($aiRequestId, $cfg);
|
||||
$url = self::buildUrl($statusPath, $cfg['base_url']);
|
||||
|
||||
$baseTimeout = isset($cfg['timeout']) ? (int) $cfg['timeout'] : 30;
|
||||
$timeout = isset($options['timeout']) ? (int) $options['timeout'] : $baseTimeout;
|
||||
if ($timeout <= 0) {
|
||||
$timeout = 30;
|
||||
}
|
||||
|
||||
$baseVerifyTls = array_key_exists('verify_tls', $cfg) ? (bool) $cfg['verify_tls'] : true;
|
||||
$verifyTls = array_key_exists('verify_tls', $options)
|
||||
? (bool) $options['verify_tls']
|
||||
: $baseVerifyTls;
|
||||
|
||||
$projectHeader = $cfg['project_header'];
|
||||
$headers = [
|
||||
'Accept: application/json',
|
||||
$projectHeader . ': ' . $projectUuid,
|
||||
];
|
||||
if (!empty($options['headers']) && is_array($options['headers'])) {
|
||||
foreach ($options['headers'] as $header) {
|
||||
if (is_string($header) && $header !== '') {
|
||||
$headers[] = $header;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self::sendCurl($url, 'GET', null, $headers, $timeout, $verifyTls);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract plain text from a Responses API payload.
|
||||
*
|
||||
* @param array<string,mixed> $response Result of LocalAIApi::createResponse|request.
|
||||
* @return string
|
||||
*/
|
||||
public static function extractText(array $response): string
|
||||
{
|
||||
$payload = $response['data'] ?? $response;
|
||||
if (!is_array($payload)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!empty($payload['output']) && is_array($payload['output'])) {
|
||||
$combined = '';
|
||||
foreach ($payload['output'] as $item) {
|
||||
if (!isset($item['content']) || !is_array($item['content'])) {
|
||||
continue;
|
||||
}
|
||||
foreach ($item['content'] as $block) {
|
||||
if (is_array($block) && ($block['type'] ?? '') === 'output_text' && !empty($block['text'])) {
|
||||
$combined .= $block['text'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($combined !== '') {
|
||||
return $combined;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($payload['choices'][0]['message']['content'])) {
|
||||
return (string) $payload['choices'][0]['message']['content'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to decode JSON emitted by the model (handles markdown fences).
|
||||
*
|
||||
* @param array<string,mixed> $response
|
||||
* @return array<string,mixed>|null
|
||||
*/
|
||||
public static function decodeJsonFromResponse(array $response): ?array
|
||||
{
|
||||
$text = self::extractText($response);
|
||||
if ($text === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$decoded = json_decode($text, true);
|
||||
if (is_array($decoded)) {
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
$stripped = preg_replace('/^```json|```$/m', '', trim($text));
|
||||
if ($stripped !== null && $stripped !== $text) {
|
||||
$decoded = json_decode($stripped, true);
|
||||
if (is_array($decoded)) {
|
||||
return $decoded;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configuration from ai/config.php.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
private static function config(): array
|
||||
{
|
||||
if (self::$configCache === null) {
|
||||
$configPath = __DIR__ . '/config.php';
|
||||
if (!file_exists($configPath)) {
|
||||
throw new RuntimeException('AI config file not found: ai/config.php');
|
||||
}
|
||||
$cfg = require $configPath;
|
||||
if (!is_array($cfg)) {
|
||||
throw new RuntimeException('Invalid AI config format: expected array');
|
||||
}
|
||||
self::$configCache = $cfg;
|
||||
}
|
||||
|
||||
return self::$configCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an absolute URL from base_url and a path.
|
||||
*/
|
||||
private static function buildUrl(string $path, string $baseUrl): string
|
||||
{
|
||||
$trimmed = trim($path);
|
||||
if ($trimmed === '') {
|
||||
return $baseUrl;
|
||||
}
|
||||
if (str_starts_with($trimmed, 'http://') || str_starts_with($trimmed, 'https://')) {
|
||||
return $trimmed;
|
||||
}
|
||||
if ($trimmed[0] === '/') {
|
||||
return $baseUrl . $trimmed;
|
||||
}
|
||||
return $baseUrl . '/' . $trimmed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve status path based on configured responses_path and ai_request_id.
|
||||
*
|
||||
* @param int|string $aiRequestId
|
||||
* @param array<string,mixed> $cfg
|
||||
* @return string
|
||||
*/
|
||||
private static function resolveStatusPath($aiRequestId, array $cfg): string
|
||||
{
|
||||
$basePath = $cfg['responses_path'] ?? '';
|
||||
$trimmed = rtrim($basePath, '/');
|
||||
if ($trimmed === '') {
|
||||
return '/ai-request/' . rawurlencode((string)$aiRequestId) . '/status';
|
||||
}
|
||||
if (substr($trimmed, -11) !== '/ai-request') {
|
||||
$trimmed .= '/ai-request';
|
||||
}
|
||||
return $trimmed . '/' . rawurlencode((string)$aiRequestId) . '/status';
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared CURL sender for GET/POST requests.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $method
|
||||
* @param string|null $body
|
||||
* @param array<int,string> $headers
|
||||
* @param int $timeout
|
||||
* @param bool $verifyTls
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
private static function sendCurl(string $url, string $method, ?string $body, array $headers, int $timeout, bool $verifyTls): array
|
||||
{
|
||||
if (!function_exists('curl_init')) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'curl_missing',
|
||||
'message' => 'PHP cURL extension is missing. Install or enable it on the VM.',
|
||||
];
|
||||
}
|
||||
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verifyTls);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $verifyTls ? 2 : 0);
|
||||
curl_setopt($ch, CURLOPT_FAILONERROR, false);
|
||||
|
||||
$upper = strtoupper($method);
|
||||
if ($upper === 'POST') {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $body ?? '');
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_HTTPGET, true);
|
||||
}
|
||||
|
||||
$responseBody = curl_exec($ch);
|
||||
if ($responseBody === false) {
|
||||
$error = curl_error($ch) ?: 'Unknown cURL error';
|
||||
curl_close($ch);
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'curl_error',
|
||||
'message' => $error,
|
||||
];
|
||||
}
|
||||
|
||||
$status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
$decoded = null;
|
||||
if ($responseBody !== '' && $responseBody !== null) {
|
||||
$decoded = json_decode($responseBody, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
$decoded = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($status >= 200 && $status < 300) {
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => $status,
|
||||
'data' => $decoded ?? $responseBody,
|
||||
];
|
||||
}
|
||||
|
||||
$errorMessage = 'AI proxy request failed';
|
||||
if (is_array($decoded)) {
|
||||
$errorMessage = $decoded['error'] ?? $decoded['message'] ?? $errorMessage;
|
||||
} elseif (is_string($responseBody) && $responseBody !== '') {
|
||||
$errorMessage = $responseBody;
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'status' => $status,
|
||||
'error' => $errorMessage,
|
||||
'response' => $decoded ?? $responseBody,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy alias for backward compatibility with the previous class name.
|
||||
if (!class_exists('OpenAIService')) {
|
||||
class_alias(LocalAIApi::class, 'OpenAIService');
|
||||
}
|
||||
52
ai/config.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
// OpenAI proxy configuration (workspace scope).
|
||||
// Reads values from environment variables or executor/.env.
|
||||
|
||||
$projectUuid = getenv('PROJECT_UUID');
|
||||
$projectId = getenv('PROJECT_ID');
|
||||
|
||||
if (
|
||||
($projectUuid === false || $projectUuid === null || $projectUuid === '') ||
|
||||
($projectId === false || $projectId === null || $projectId === '')
|
||||
) {
|
||||
$envPath = realpath(__DIR__ . '/../../.env'); // executor/.env
|
||||
if ($envPath && is_readable($envPath)) {
|
||||
$lines = @file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [];
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
if ($line === '' || $line[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
if (!str_contains($line, '=')) {
|
||||
continue;
|
||||
}
|
||||
[$key, $value] = array_map('trim', explode('=', $line, 2));
|
||||
if ($key === '') {
|
||||
continue;
|
||||
}
|
||||
$value = trim($value, "\"' ");
|
||||
if (getenv($key) === false || getenv($key) === '') {
|
||||
putenv("{$key}={$value}");
|
||||
}
|
||||
}
|
||||
$projectUuid = getenv('PROJECT_UUID');
|
||||
$projectId = getenv('PROJECT_ID');
|
||||
}
|
||||
}
|
||||
|
||||
$projectUuid = ($projectUuid === false) ? null : $projectUuid;
|
||||
$projectId = ($projectId === false) ? null : $projectId;
|
||||
|
||||
$baseUrl = 'https://flatlogic.com';
|
||||
$responsesPath = $projectId ? "/projects/{$projectId}/ai-request" : null;
|
||||
|
||||
return [
|
||||
'base_url' => $baseUrl,
|
||||
'responses_path' => $responsesPath,
|
||||
'project_id' => $projectId,
|
||||
'project_uuid' => $projectUuid,
|
||||
'project_header' => 'project-uuid',
|
||||
'default_model' => 'gpt-5-mini',
|
||||
'timeout' => 30,
|
||||
'verify_tls' => true,
|
||||
];
|
||||
BIN
assets/pasted-20260116-075543-79e9cb27.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
assets/pasted-20260123-104436-58c7865f.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
assets/pasted-20260702-102621-0321ab15.png
Normal file
|
After Width: | Height: | Size: 396 KiB |
BIN
assets/vm-shot-2026-01-26T11-35-05-786Z.jpg
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
assets/vm-shot-2026-01-26T11-35-21-768Z.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/vm-shot-2026-01-26T11-35-30-801Z.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/vm-shot-2026-01-26T11-39-15-260Z.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/vm-shot-2026-01-26T11-54-24-787Z.jpg
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
assets/vm-shot-2026-01-26T11-54-38-389Z.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/vm-shot-2026-01-26T11-56-16-929Z.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/vm-shot-2026-01-26T13-33-13-586Z.jpg
Normal file
|
After Width: | Height: | Size: 51 KiB |
BIN
assets/vm-shot-2026-01-26T13-41-42-697Z.jpg
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
assets/vm-shot-2026-01-26T13-43-33-368Z.jpg
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/vm-shot-2026-01-26T14-46-07-412Z.jpg
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
assets/vm-shot-2026-01-26T14-58-14-516Z.jpg
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
assets/vm-shot-2026-01-26T14-58-25-621Z.jpg
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
assets/vm-shot-2026-01-26T14-58-42-937Z.jpg
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
assets/vm-shot-2026-01-26T15-04-37-249Z.jpg
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
assets/vm-shot-2026-01-26T15-04-49-828Z.jpg
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
assets/vm-shot-2026-01-26T15-20-42-350Z.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
assets/vm-shot-2026-01-26T15-20-58-875Z.jpg
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
assets/vm-shot-2026-01-26T15-21-19-157Z.jpg
Normal file
|
After Width: | Height: | Size: 49 KiB |
BIN
assets/vm-shot-2026-01-26T15-21-45-883Z.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
assets/vm-shot-2026-01-27T08-23-41-822Z.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
assets/vm-shot-2026-01-27T08-23-57-939Z.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
assets/vm-shot-2026-01-27T08-24-19-323Z.jpg
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
assets/vm-shot-2026-01-27T08-24-32-288Z.jpg
Normal file
|
After Width: | Height: | Size: 49 KiB |
235
mail/MailService.php
Normal file
@ -0,0 +1,235 @@
|
||||
<?php
|
||||
// Minimal mail service for the workspace app (VM).
|
||||
// Usage:
|
||||
// require_once __DIR__ . '/MailService.php';
|
||||
// // Generic:
|
||||
// MailService::sendMail($to, $subject, $htmlBody, $textBody = null, $opts = []);
|
||||
// // Contact form helper:
|
||||
// MailService::sendContactMessage($name, $email, $message, $to = null, $subject = 'New contact form');
|
||||
|
||||
class MailService
|
||||
{
|
||||
// Universal mail sender (no attachments by design)
|
||||
public static function sendMail($to, string $subject, string $htmlBody, ?string $textBody = null, array $opts = [])
|
||||
{
|
||||
$cfg = self::loadConfig();
|
||||
|
||||
$autoload = __DIR__ . '/../vendor/autoload.php';
|
||||
if (file_exists($autoload)) {
|
||||
require_once $autoload;
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'libphp-phpmailer/autoload.php';
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'libphp-phpmailer/src/Exception.php';
|
||||
@require_once 'libphp-phpmailer/src/SMTP.php';
|
||||
@require_once 'libphp-phpmailer/src/PHPMailer.php';
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/src/Exception.php';
|
||||
@require_once 'PHPMailer/src/SMTP.php';
|
||||
@require_once 'PHPMailer/src/PHPMailer.php';
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/Exception.php';
|
||||
@require_once 'PHPMailer/SMTP.php';
|
||||
@require_once 'PHPMailer/PHPMailer.php';
|
||||
}
|
||||
}
|
||||
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
return [ 'success' => false, 'error' => 'PHPMailer not available' ];
|
||||
}
|
||||
|
||||
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
|
||||
try {
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $cfg['smtp_host'] ?? '';
|
||||
$mail->Port = (int)($cfg['smtp_port'] ?? 587);
|
||||
$secure = $cfg['smtp_secure'] ?? 'tls';
|
||||
if ($secure === 'ssl') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS;
|
||||
elseif ($secure === 'tls') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
|
||||
else $mail->SMTPSecure = false;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $cfg['smtp_user'] ?? '';
|
||||
$mail->Password = $cfg['smtp_pass'] ?? '';
|
||||
|
||||
$fromEmail = $opts['from_email'] ?? ($cfg['from_email'] ?? 'no-reply@localhost');
|
||||
$fromName = $opts['from_name'] ?? ($cfg['from_name'] ?? 'App');
|
||||
$mail->setFrom($fromEmail, $fromName);
|
||||
if (!empty($opts['reply_to']) && filter_var($opts['reply_to'], FILTER_VALIDATE_EMAIL)) {
|
||||
$mail->addReplyTo($opts['reply_to']);
|
||||
} elseif (!empty($cfg['reply_to'])) {
|
||||
$mail->addReplyTo($cfg['reply_to']);
|
||||
}
|
||||
|
||||
// Recipients
|
||||
$toList = [];
|
||||
if ($to) {
|
||||
if (is_string($to)) $toList = array_map('trim', explode(',', $to));
|
||||
elseif (is_array($to)) $toList = $to;
|
||||
} elseif (!empty(getenv('MAIL_TO'))) {
|
||||
$toList = array_map('trim', explode(',', getenv('MAIL_TO')));
|
||||
}
|
||||
$added = 0;
|
||||
foreach ($toList as $addr) {
|
||||
if (filter_var($addr, FILTER_VALIDATE_EMAIL)) { $mail->addAddress($addr); $added++; }
|
||||
}
|
||||
if ($added === 0) {
|
||||
return [ 'success' => false, 'error' => 'No recipients defined (set MAIL_TO or pass $to)' ];
|
||||
}
|
||||
|
||||
foreach ((array)($opts['cc'] ?? []) as $cc) { if (filter_var($cc, FILTER_VALIDATE_EMAIL)) $mail->addCC($cc); }
|
||||
foreach ((array)($opts['bcc'] ?? []) as $bcc){ if (filter_var($bcc, FILTER_VALIDATE_EMAIL)) $mail->addBCC($bcc); }
|
||||
|
||||
// Optional DKIM
|
||||
if (!empty($cfg['dkim_domain']) && !empty($cfg['dkim_selector']) && !empty($cfg['dkim_private_key_path'])) {
|
||||
$mail->DKIM_domain = $cfg['dkim_domain'];
|
||||
$mail->DKIM_selector = $cfg['dkim_selector'];
|
||||
$mail->DKIM_private = $cfg['dkim_private_key_path'];
|
||||
}
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = $subject;
|
||||
$mail->Body = $htmlBody;
|
||||
$mail->AltBody = $textBody ?? strip_tags($htmlBody);
|
||||
$ok = $mail->send();
|
||||
return [ 'success' => $ok ];
|
||||
} catch (\Throwable $e) {
|
||||
return [ 'success' => false, 'error' => 'PHPMailer error: ' . $e->getMessage() ];
|
||||
}
|
||||
}
|
||||
private static function loadConfig(): array
|
||||
{
|
||||
$configPath = __DIR__ . '/config.php';
|
||||
if (!file_exists($configPath)) {
|
||||
throw new \RuntimeException('Mail config not found. Copy mail/config.sample.php to mail/config.php and fill in credentials.');
|
||||
}
|
||||
$cfg = require $configPath;
|
||||
if (!is_array($cfg)) {
|
||||
throw new \RuntimeException('Invalid mail config format: expected array');
|
||||
}
|
||||
return $cfg;
|
||||
}
|
||||
|
||||
// Send a contact message
|
||||
// $to can be: a single email string, a comma-separated list, an array of emails, or null (fallback to MAIL_TO/MAIL_FROM)
|
||||
public static function sendContactMessage(string $name, string $email, string $message, $to = null, string $subject = 'New contact form')
|
||||
{
|
||||
$cfg = self::loadConfig();
|
||||
|
||||
// Try Composer autoload if available (for PHPMailer)
|
||||
$autoload = __DIR__ . '/../vendor/autoload.php';
|
||||
if (file_exists($autoload)) {
|
||||
require_once $autoload;
|
||||
}
|
||||
// Fallback to system-wide PHPMailer (installed via apt: libphp-phpmailer)
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
// Debian/Ubuntu package layout (libphp-phpmailer)
|
||||
@require_once 'libphp-phpmailer/autoload.php';
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'libphp-phpmailer/src/Exception.php';
|
||||
@require_once 'libphp-phpmailer/src/SMTP.php';
|
||||
@require_once 'libphp-phpmailer/src/PHPMailer.php';
|
||||
}
|
||||
// Alternative layout (older PHPMailer package names)
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/src/Exception.php';
|
||||
@require_once 'PHPMailer/src/SMTP.php';
|
||||
@require_once 'PHPMailer/src/PHPMailer.php';
|
||||
}
|
||||
if (!class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
@require_once 'PHPMailer/Exception.php';
|
||||
@require_once 'PHPMailer/SMTP.php';
|
||||
@require_once 'PHPMailer/PHPMailer.php';
|
||||
}
|
||||
}
|
||||
|
||||
$transport = $cfg['transport'] ?? 'smtp';
|
||||
if ($transport === 'smtp' && class_exists('PHPMailer\\PHPMailer\\PHPMailer')) {
|
||||
return self::sendViaPHPMailer($cfg, $name, $email, $message, $to, $subject);
|
||||
}
|
||||
|
||||
// Fallback: attempt native mail() — works only if MTA is configured on the VM
|
||||
return self::sendViaNativeMail($cfg, $name, $email, $message, $to, $subject);
|
||||
}
|
||||
|
||||
private static function sendViaPHPMailer(array $cfg, string $name, string $email, string $body, $to, string $subject)
|
||||
{
|
||||
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
|
||||
try {
|
||||
$mail->isSMTP();
|
||||
$mail->Host = $cfg['smtp_host'] ?? '';
|
||||
$mail->Port = (int)($cfg['smtp_port'] ?? 587);
|
||||
$secure = $cfg['smtp_secure'] ?? 'tls';
|
||||
if ($secure === 'ssl') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_SMTPS;
|
||||
elseif ($secure === 'tls') $mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
|
||||
else $mail->SMTPSecure = false;
|
||||
$mail->SMTPAuth = true;
|
||||
$mail->Username = $cfg['smtp_user'] ?? '';
|
||||
$mail->Password = $cfg['smtp_pass'] ?? '';
|
||||
|
||||
$fromEmail = $cfg['from_email'] ?? 'no-reply@localhost';
|
||||
$fromName = $cfg['from_name'] ?? 'App';
|
||||
$mail->setFrom($fromEmail, $fromName);
|
||||
|
||||
// Use Reply-To for the user's email to avoid spoofing From
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
$mail->addReplyTo($email, $name ?: $email);
|
||||
}
|
||||
if (!empty($cfg['reply_to'])) {
|
||||
$mail->addReplyTo($cfg['reply_to']);
|
||||
}
|
||||
|
||||
// Destination: prefer dynamic recipients ($to), fallback to MAIL_TO; no silent FROM fallback
|
||||
$toList = [];
|
||||
if ($to) {
|
||||
if (is_string($to)) {
|
||||
// allow comma-separated list
|
||||
$toList = array_map('trim', explode(',', $to));
|
||||
} elseif (is_array($to)) {
|
||||
$toList = $to;
|
||||
}
|
||||
} elseif (!empty(getenv('MAIL_TO'))) {
|
||||
$toList = array_map('trim', explode(',', getenv('MAIL_TO')));
|
||||
}
|
||||
$added = 0;
|
||||
foreach ($toList as $addr) {
|
||||
if (filter_var($addr, FILTER_VALIDATE_EMAIL)) {
|
||||
$mail->addAddress($addr);
|
||||
$added++;
|
||||
}
|
||||
}
|
||||
if ($added === 0) {
|
||||
return [ 'success' => false, 'error' => 'No recipients defined (set MAIL_TO or pass $to)' ];
|
||||
}
|
||||
|
||||
// DKIM (optional)
|
||||
if (!empty($cfg['dkim_domain']) && !empty($cfg['dkim_selector']) && !empty($cfg['dkim_private_key_path'])) {
|
||||
$mail->DKIM_domain = $cfg['dkim_domain'];
|
||||
$mail->DKIM_selector = $cfg['dkim_selector'];
|
||||
$mail->DKIM_private = $cfg['dkim_private_key_path'];
|
||||
}
|
||||
|
||||
$mail->isHTML(true);
|
||||
$mail->Subject = $subject;
|
||||
$safeName = htmlspecialchars($name, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
$safeEmail = htmlspecialchars($email, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
$safeBody = nl2br(htmlspecialchars($body, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'));
|
||||
$mail->Body = "<p><strong>Name:</strong> {$safeName}</p><p><strong>Email:</strong> {$safeEmail}</p><hr>{$safeBody}";
|
||||
$mail->AltBody = "Name: {$name}\nEmail: {$email}\n\n{$body}";
|
||||
|
||||
$ok = $mail->send();
|
||||
return [ 'success' => $ok ];
|
||||
} catch (\Throwable $e) {
|
||||
return [ 'success' => false, 'error' => 'PHPMailer error: ' . $e->getMessage() ];
|
||||
}
|
||||
}
|
||||
|
||||
private static function sendViaNativeMail(array $cfg, string $name, string $email, string $body, $to, string $subject)
|
||||
{
|
||||
$opts = ['reply_to' => $email];
|
||||
$html = nl2br(htmlspecialchars($body, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'));
|
||||
return self::sendMail($to, $subject, $html, $body, $opts);
|
||||
}
|
||||
}
|
||||
44
mail/config.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
// Mail configuration sourced from environment variables.
|
||||
// No secrets are stored here; the file just maps env -> config array for MailService.
|
||||
|
||||
function env_val(string $key, $default = null) {
|
||||
$v = getenv($key);
|
||||
return ($v === false || $v === null || $v === '') ? $default : $v;
|
||||
}
|
||||
|
||||
$transport = env_val('MAIL_TRANSPORT', 'smtp');
|
||||
$smtp_host = env_val('SMTP_HOST');
|
||||
$smtp_port = (int) env_val('SMTP_PORT', 587);
|
||||
$smtp_secure = env_val('SMTP_SECURE', 'tls'); // tls | ssl | null
|
||||
$smtp_user = env_val('SMTP_USER');
|
||||
$smtp_pass = env_val('SMTP_PASS');
|
||||
|
||||
$from_email = env_val('MAIL_FROM', 'no-reply@localhost');
|
||||
$from_name = env_val('MAIL_FROM_NAME', 'App');
|
||||
$reply_to = env_val('MAIL_REPLY_TO');
|
||||
|
||||
$dkim_domain = env_val('DKIM_DOMAIN');
|
||||
$dkim_selector = env_val('DKIM_SELECTOR');
|
||||
$dkim_private_key_path = env_val('DKIM_PRIVATE_KEY_PATH');
|
||||
|
||||
return [
|
||||
'transport' => $transport,
|
||||
|
||||
// SMTP
|
||||
'smtp_host' => $smtp_host,
|
||||
'smtp_port' => $smtp_port,
|
||||
'smtp_secure' => $smtp_secure,
|
||||
'smtp_user' => $smtp_user,
|
||||
'smtp_pass' => $smtp_pass,
|
||||
|
||||
// From / Reply-To
|
||||
'from_email' => $from_email,
|
||||
'from_name' => $from_name,
|
||||
'reply_to' => $reply_to,
|
||||
|
||||
// DKIM (optional)
|
||||
'dkim_domain' => $dkim_domain,
|
||||
'dkim_selector' => $dkim_selector,
|
||||
'dkim_private_key_path' => $dkim_private_key_path,
|
||||
];
|
||||
147
wp-config.php.bak-20260701205205
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $_SERVER['HTTPS'] = 'on'; }
|
||||
/**
|
||||
* The base configuration for WordPress
|
||||
*
|
||||
* The wp-config.php creation script uses this file during the installation.
|
||||
* You don't have to use the website, you can copy this file to "wp-config.php"
|
||||
* and fill in the values.
|
||||
*
|
||||
* This file contains the following configurations:
|
||||
*
|
||||
* * Database settings
|
||||
* * Secret keys
|
||||
* * Database table prefix
|
||||
* * ABSPATH
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
|
||||
*
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
// ** Database settings - You can get this info from your web host ** //
|
||||
/** The name of the database for WordPress */
|
||||
define('WP_CACHE', false);
|
||||
define( 'DB_NAME', 'app_37828' );
|
||||
|
||||
/** Database username */
|
||||
define( 'DB_USER', 'app_38217' );
|
||||
|
||||
/** Database password */
|
||||
define( 'DB_PASSWORD', '4134fddc-2388-4207-886c-16d7ca4eb430' );
|
||||
|
||||
/** Database hostname */
|
||||
define( 'DB_HOST', '127.0.0.1' );
|
||||
|
||||
/** Database charset to use in creating database tables. */
|
||||
define( 'DB_CHARSET', 'utf8' );
|
||||
|
||||
/** The database collate type. Don't change this if in doubt. */
|
||||
define( 'DB_COLLATE', '' );
|
||||
|
||||
/**#@+
|
||||
* Authentication unique keys and salts.
|
||||
*
|
||||
* Change these to different unique phrases! You can generate these using
|
||||
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
|
||||
*
|
||||
* You can change these at any point in time to invalidate all existing cookies.
|
||||
* This will force all users to have to log in again.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
define( 'AUTH_KEY', '8PnG1Lf2Ez_JaVprdcq4kcAK-7QSTV8orhLi0kFl0mo=' );
|
||||
define( 'SECURE_AUTH_KEY', 'iQJoTEBPxjvq_t85TDh5Jm-S-M9OXpCTwIVe4MxSonM=' );
|
||||
define( 'LOGGED_IN_KEY', 'ngNJX1LDjbWEexgJp8xl2T21AsnEEe_4hwthkxsnXHc=' );
|
||||
define( 'NONCE_KEY', '_3gFUqcPtq4XPmCePj--9CuHgOA-p7NHvd5NJlxGZo0=' );
|
||||
define( 'AUTH_SALT', 'Bpq-HxxV1fs-E2NQ6TLeaQ_eEYIqqGz0PPGlBCmye1A=' );
|
||||
define( 'SECURE_AUTH_SALT', 'YMmsnQroEjlr6uABVGx6Kb1BEvLAvLjKlxaMXqQUXc0=' );
|
||||
define( 'LOGGED_IN_SALT', 'N62EK-IHBeIiQElaH1CFTTIEgVgBtxzRzNrpVLCTZMA=' );
|
||||
define( 'NONCE_SALT', 'MgiPOSaGPD_lq5Z1Q4zvUuLdHPCGPVqbTaRroo917mQ=' );
|
||||
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* WordPress database table prefix.
|
||||
*
|
||||
* You can have multiple installations in one database if you give each
|
||||
* a unique prefix. Only numbers, letters, and underscores please!
|
||||
*
|
||||
* At the installation time, database tables are created with the specified prefix.
|
||||
* Changing this value after WordPress is installed will make your site think
|
||||
* it has not been installed.
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix
|
||||
*/
|
||||
$table_prefix = 'stg_59466_';
|
||||
|
||||
/**
|
||||
* For developers: WordPress debugging mode.
|
||||
*
|
||||
* Change this to true to enable the display of notices during development.
|
||||
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
||||
* in their development environments.
|
||||
*
|
||||
* For information on other constants that can be used for debugging,
|
||||
* visit the documentation.
|
||||
*
|
||||
* @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/
|
||||
*/
|
||||
define( 'WP_DEBUG', true );
|
||||
|
||||
/* Add any custom values between this line and the "stop editing" line. */
|
||||
define('OCI_DOMAIN', 'medcore.one');
|
||||
define('OCI_SUBDOMAIN', 'www');
|
||||
|
||||
|
||||
/**
|
||||
* WordPress Localized Language, defaults to English.
|
||||
*
|
||||
* Change this to localize WordPress. A corresponding MO file for the chosen
|
||||
* language must be installed to wp-content/languages. For example, install
|
||||
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
|
||||
* language support.
|
||||
*/
|
||||
define( 'WPLANG', 'en_GB' );
|
||||
|
||||
/**
|
||||
* Get email from control email
|
||||
*
|
||||
* Just set to default email fields during 1-click installation
|
||||
*/
|
||||
define( 'WPEMAIL', 'mslipay@gmail.com' );
|
||||
|
||||
/**
|
||||
* Prevent file editing from WP admin.
|
||||
* Just set to false if you want to edit templates and plugins from WP admin.
|
||||
*/
|
||||
define('DISALLOW_FILE_EDIT', true);
|
||||
|
||||
/**
|
||||
* API for One.com wordpress themes and plugins
|
||||
*/
|
||||
define('ONECOM_WP_ADDONS_API', 'https://wpapi.one.com');
|
||||
|
||||
/**
|
||||
* Client IP for One.com logs
|
||||
*/
|
||||
if (getenv('HTTP_CLIENT_IP')){$_SERVER['ONECOM_CLIENT_IP'] = @getenv('HTTP_CLIENT_IP');}
|
||||
else if(getenv('REMOTE_ADDR')){$_SERVER['ONECOM_CLIENT_IP'] = @getenv('REMOTE_ADDR');}
|
||||
else{$_SERVER['ONECOM_CLIENT_IP']='0.0.0.0';}
|
||||
|
||||
define( 'WP_DISABLE_FATAL_ERROR_HANDLER', false );
|
||||
define( 'DISABLE_WP_CRON', true );
|
||||
/* That's all, stop editing! Happy publishing. */
|
||||
|
||||
/** Absolute path to the WordPress directory. */
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
define( 'ABSPATH', __DIR__ . '/' );
|
||||
}
|
||||
|
||||
/** Sets up WordPress vars and included files. */
|
||||
if ( isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] !== '' ) {
|
||||
$wp_scheme = ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] !== 'off' ) || ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) ? 'https' : 'http';
|
||||
define( 'WP_HOME', $wp_scheme . '://' . $_SERVER['HTTP_HOST'] );
|
||||
define( 'WP_SITEURL', $wp_scheme . '://' . $_SERVER['HTTP_HOST'] );
|
||||
}
|
||||
require_once ABSPATH . 'wp-settings.php';
|
||||
2
wp-content/index.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
61
wp-content/mu-plugins/flatlogic-homepage-layout.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Flatlogic Homepage Layout
|
||||
*/
|
||||
|
||||
add_action("wp_enqueue_scripts", function () {
|
||||
wp_register_style("flatlogic-homepage-layout", false);
|
||||
wp_enqueue_style("flatlogic-homepage-layout");
|
||||
wp_add_inline_style("flatlogic-homepage-layout", <<<'CSS'
|
||||
body.home .wp-block-post-title {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
body.home .entry-content.alignfull.wp-block-post-content.has-global-padding.is-layout-constrained {
|
||||
width: min(1320px, calc(100vw - 3rem)) !important;
|
||||
max-width: min(1320px, calc(100vw - 3rem)) !important;
|
||||
margin-left: auto !important;
|
||||
margin-right: auto !important;
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
body.home .entry-content.alignfull.wp-block-post-content.has-global-padding.is-layout-constrained > .docs-hero,
|
||||
body.home .entry-content.alignfull.wp-block-post-content.has-global-padding.is-layout-constrained > .docs-section {
|
||||
width: 100% !important;
|
||||
max-width: none !important;
|
||||
margin-left: 0 !important;
|
||||
margin-right: 0 !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
body.home .entry-content.alignfull.wp-block-post-content.has-global-padding.is-layout-constrained > .docs-hero {
|
||||
padding-left: clamp(1.5rem, 4vw, 4rem) !important;
|
||||
padding-right: clamp(1.5rem, 4vw, 4rem) !important;
|
||||
}
|
||||
|
||||
body.home .docs-hero > * {
|
||||
max-width: 980px !important;
|
||||
}
|
||||
|
||||
body.home .docs-hero h1,
|
||||
body.home .docs-section h2,
|
||||
body.home .docs-section h3 {
|
||||
max-width: none !important;
|
||||
}
|
||||
|
||||
body.home .docs-hero p.is-style-lead,
|
||||
body.home .docs-lead {
|
||||
max-width: 72ch !important;
|
||||
}
|
||||
|
||||
body.home .fl-docs-card-grid,
|
||||
body.home .fl-docs-article-grid,
|
||||
body.home .fl-support-grid,
|
||||
body.home .fl-docs-related__grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
|
||||
}
|
||||
CSS
|
||||
);
|
||||
}, 20);
|
||||
34
wp-content/plugins/akismet/.htaccess
Normal file
@ -0,0 +1,34 @@
|
||||
# Only allow direct access to specific Web-available files.
|
||||
|
||||
# Apache 2.2
|
||||
<IfModule !mod_authz_core.c>
|
||||
Order Deny,Allow
|
||||
Deny from all
|
||||
</IfModule>
|
||||
|
||||
# Apache 2.4
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
|
||||
# Akismet CSS and JS
|
||||
<FilesMatch "^(form\.js|akismet(-frontend|-admin)?\.js|akismet(-admin)?(-rtl)?\.css|inter\.css)$">
|
||||
<IfModule !mod_authz_core.c>
|
||||
Allow from all
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all granted
|
||||
</IfModule>
|
||||
</FilesMatch>
|
||||
|
||||
# Akismet images
|
||||
<FilesMatch "^(logo-a-2x\.png|akismet-refresh-logo\.svg|akismet-refresh-logo@2x\.png|arrow-left\.svg|akismet-activation-banner-elements\.png)$">
|
||||
<IfModule !mod_authz_core.c>
|
||||
Allow from all
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all granted
|
||||
</IfModule>
|
||||
</FilesMatch>
|
||||
716
wp-content/plugins/akismet/_inc/akismet-admin.css
Normal file
@ -0,0 +1,716 @@
|
||||
body {
|
||||
--akismet-color-charcoal: #272635;
|
||||
--akismet-color-light-grey: #f6f7f7;
|
||||
--akismet-color-mid-grey: #a7aaad;
|
||||
--akismet-color-dark-grey: #646970;
|
||||
--akismet-color-grey-80: #2c3338;
|
||||
--akismet-color-grey-100: #101517;
|
||||
--akismet-color-grey-border: #dcdcde;
|
||||
--akismet-color-white: #fff;
|
||||
--akismet-color-dark-green: #2d6a40;
|
||||
--akismet-color-mid-green: #357b49;
|
||||
--akismet-color-light-green: #4eb26a;
|
||||
--akismet-color-mid-red: #e82c3f;
|
||||
--akismet-color-light-blue: #256eff;
|
||||
--akismet-color-notice-light-green: #dbf0e1;
|
||||
--akismet-color-notice-dark-green: #69bf82;
|
||||
--akismet-color-notice-light-red: #ffdbde;
|
||||
--akismet-color-notice-dark-red: #ff6676;
|
||||
--akismet-color-notice-yellow: #e5c133;
|
||||
}
|
||||
|
||||
/* UI components */
|
||||
.akismet-new-feature {
|
||||
background-color: var(--akismet-color-mid-green);
|
||||
border-radius: 4px;
|
||||
color: var(--akismet-color-white);
|
||||
font-size: 10px;
|
||||
padding: 4px 6px;
|
||||
text-transform: uppercase;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#akismet-plugin-container {
|
||||
background-color: var(--akismet-color-light-grey);
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
#akismet-plugin-container a {
|
||||
color: var(--akismet-color-mid-green);
|
||||
}
|
||||
|
||||
#akismet-plugin-container a.akismet-button {
|
||||
background-color: var(--akismet-color-mid-green);
|
||||
color: var(--akismet-color-white);
|
||||
}
|
||||
|
||||
#akismet-plugin-container button:focus-visible,
|
||||
#akismet-plugin-container input:focus-visible,
|
||||
#akismet-plugin-container a:focus-visible {
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
outline: 2px solid var(--akismet-color-light-blue);
|
||||
}
|
||||
|
||||
.akismet-masthead {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.akismet-masthead__logo {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.akismet-section-header {
|
||||
box-shadow: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.akismet-section-header__label {
|
||||
color: var(--akismet-color-charcoal);
|
||||
font-weight: 600;
|
||||
padding-left: 0.2em;
|
||||
}
|
||||
|
||||
.akismet-button,
|
||||
.akismet-button:hover {
|
||||
border: 0;
|
||||
color: var(--akismet-color-white);
|
||||
}
|
||||
|
||||
.akismet-button {
|
||||
background-color: var(--akismet-color-mid-green);
|
||||
}
|
||||
|
||||
.akismet-button:hover {
|
||||
background-color: var(--akismet-color-dark-green);
|
||||
}
|
||||
|
||||
.akismet-external-link::after {
|
||||
content: "↗";
|
||||
display: inline-block;
|
||||
padding-left: 2px;
|
||||
text-decoration: none;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
/* Need this specificity to override the existing header rule */
|
||||
.akismet-new-snapshot h3.akismet-new-snapshot__header {
|
||||
background: none;
|
||||
font-size: 13px;
|
||||
color: var(--akismet-color-charcoal);
|
||||
text-align: left;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__number {
|
||||
color: var(--akismet-color-charcoal);
|
||||
display: block;
|
||||
font-size: 32px;
|
||||
font-weight: 400;
|
||||
letter-spacing: -1px;
|
||||
line-height: 1.5em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot li.akismet-new-snapshot__item {
|
||||
color: var(--akismet-color-dark-grey);
|
||||
font-size: 13px;
|
||||
text-align: left;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
.akismet-masthead__logo-link {
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.akismet-masthead__back-link-container {
|
||||
margin-top: 16px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
/* Need this specificity to override the existing link rule */
|
||||
#akismet-plugin-container a.akismet-masthead__back-link {
|
||||
background-image: url(img/arrow-left.svg);
|
||||
background-position: left;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 16px;
|
||||
color: var(--akismet-color-charcoal);
|
||||
font-weight: 400;
|
||||
padding-left: 20px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#akismet-plugin-container a.akismet-masthead__back-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__item {
|
||||
border-top: 1px solid var(--akismet-color-light-grey);
|
||||
border-left: 1px solid var(--akismet-color-light-grey);
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot li:first-child {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__list {
|
||||
display: flex;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__item {
|
||||
flex: 1 0 33.33%;
|
||||
margin-bottom: 0;
|
||||
padding-left: 1.5em;
|
||||
padding-right: 1.5em;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__chart {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.akismet-box {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.akismet-box:not(:first-child) {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.akismet-box,
|
||||
.akismet-card {
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.akismet-card {
|
||||
margin: 32px auto 0 auto;
|
||||
}
|
||||
|
||||
.akismet-lower {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.akismet-lower .inside {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.akismet-section-header__label {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-settings__row {
|
||||
border-bottom: 1px solid var(--akismet-color-light-grey);
|
||||
display: block;
|
||||
padding: 1em 1.5em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-input {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.akismet-settings__row-title {
|
||||
font-weight: 500;
|
||||
font-size: 1em;
|
||||
margin: 0;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-description {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.akismet-card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.akismet-card-actions__secondary-action {
|
||||
align-self: center;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.akismet-settings__row label {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-note {
|
||||
font-size: 0.9em;
|
||||
margin-top: 0.4em;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"],
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
accent-color: var(--akismet-color-mid-green);
|
||||
box-shadow: none;
|
||||
flex-shrink: 0;
|
||||
margin: 2px 0 0 0;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"] {
|
||||
margin-top: 1px;
|
||||
vertical-align: top;
|
||||
-webkit-appearance: checkbox;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
-webkit-appearance: radio;
|
||||
}
|
||||
|
||||
/* Fix up misbehaving wp-admin styles in Chrome (from forms and colors stylesheets) */
|
||||
.akismet-settings__row input[type="checkbox"]:checked:before {
|
||||
content: '';
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="radio"]:checked:before {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"]:checked:hover,
|
||||
.akismet-settings__row input[type="radio"]:checked:hover {
|
||||
accent-color: var(--akismet-color-mid-green);
|
||||
}
|
||||
|
||||
.akismet-button:disabled {
|
||||
background-color: var(--akismet-color-mid-grey);
|
||||
color: var(--akismet-color-white);
|
||||
cursor: arrow;
|
||||
}
|
||||
|
||||
.akismet-awaiting-stats,
|
||||
.akismet-account {
|
||||
padding: 0 1rem 1rem 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-account {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.akismet-account th {
|
||||
font-weight: 500;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.akismet-account th, .akismet-account td {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-input-label {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-settings__row-label-text {
|
||||
padding-left: 0.5em;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.akismet-alert {
|
||||
border-left: 8px solid;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
padding: 0.2em 1em;
|
||||
}
|
||||
|
||||
.akismet-alert__heading {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.akismet-alert.is-good {
|
||||
background-color: var(--akismet-color-notice-light-green);
|
||||
border-left-color: var(--akismet-color-notice-dark-green);
|
||||
}
|
||||
|
||||
.akismet-alert.is-neutral {
|
||||
background-color: var(--akismet-color-white);
|
||||
border-left-color: var(--akismet-color-dark-grey);
|
||||
}
|
||||
|
||||
.akismet-alert.is-bad {
|
||||
background-color: var(--akismet-color-notice-light-red);
|
||||
border-left-color: var(--akismet-color-notice-dark-red);
|
||||
}
|
||||
|
||||
.akismet-alert.is-commercial {
|
||||
background-color: var(--akismet-color-white);
|
||||
border-color: var(--akismet-color-mid-grey);
|
||||
border-bottom-width: 1px;
|
||||
border-left-color: var(--akismet-color-notice-yellow);
|
||||
display: flex;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
#akismet-plugin-container .akismet-alert.is-good a,
|
||||
#akismet-plugin-container .akismet-alert.is-bad a {
|
||||
/* For better contrast - green isn't great */
|
||||
color: var(--akismet-color-grey-80);
|
||||
}
|
||||
|
||||
.akismet-alert-header {
|
||||
font-size: 16px;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.akismet-alert-button-wrapper {
|
||||
align-self: center;
|
||||
margin-left: 2em;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.akismet-alert-info {
|
||||
text-wrap: pretty;
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
/* Setup */
|
||||
.akismet-setup-instructions__heading {
|
||||
font-size: 1.375rem;
|
||||
font-weight: 700;
|
||||
padding-block-end: 0;
|
||||
}
|
||||
|
||||
h3.akismet-setup-instructions__subheading {
|
||||
color: var(--akismet-color-dark-grey);
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
margin: 0 0 1.25rem;
|
||||
padding-block-start: 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__feature-list {
|
||||
list-style: none;
|
||||
margin: 1rem 0.5rem 1.5rem;
|
||||
max-width: 640px;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__feature {
|
||||
align-items: start;
|
||||
display: flex;
|
||||
margin-block-end: 1rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__icon {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__body {
|
||||
flex: 1;
|
||||
padding-inline-start: 0.5rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__title {
|
||||
color: #1d2327;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
p.akismet-setup-instructions__text {
|
||||
color: var(--akismet-color-grey-80);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
margin: 0.25rem 0 0;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__button,
|
||||
.akismet-setup-instructions__button:hover,
|
||||
.akismet-setup-instructions__button:visited {
|
||||
font-size: 1rem;
|
||||
margin-inline-start: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-setup__connection {
|
||||
background: var(--akismet-color-light-grey);
|
||||
border: 1px solid var(--akismet-color-grey-border);
|
||||
border-radius: 8px;
|
||||
margin: 1rem 1rem 2rem 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-action:not(:last-child) {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-user {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-avatar {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-avatar-image {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-account-name {
|
||||
color: var(--akismet-color-charcoal);
|
||||
font-size: 0.9rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-account-email {
|
||||
margin-top: 0.1rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-action {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-button {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
p.akismet-setup__connection-action-intro,
|
||||
p.akismet-setup__connection-action-description {
|
||||
color: var(--akismet-color-dark-grey);
|
||||
font-size: 0.875rem;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
p.akismet-setup__connection-action-intro {
|
||||
margin: 0 0 1rem 0;
|
||||
}
|
||||
|
||||
p.akismet-setup__connection-action-description {
|
||||
margin: 1rem 0 0;
|
||||
}
|
||||
|
||||
/* Setup - API key input */
|
||||
.akismet-enter-api-key-box {
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__reveal {
|
||||
background: none;
|
||||
border: 0;
|
||||
color: var(--akismet-color-mid-green);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__form-wrapper {
|
||||
display: none;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__input-wrapper {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
padding: 0 1.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__key-input {
|
||||
flex-grow: 1;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
h3.akismet-enter-api-key-box__header {
|
||||
padding-top: 0;
|
||||
padding-bottom: 1em;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* Notices > Activation (shown on edit-comments.php) */
|
||||
#akismet-setup-prompt {
|
||||
background: none;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.akismet-activate {
|
||||
align-items: center;
|
||||
/* background-image is defined via an inline style in class.akismet-admin.php */
|
||||
background-color: var(--akismet-color-light-grey);
|
||||
background-position: calc(100% - 1em) center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 140px;
|
||||
border: 1px solid var(--akismet-color-mid-green);
|
||||
border-left-width: 4px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 15px 0;
|
||||
min-height: 60px;
|
||||
overflow: hidden;
|
||||
padding: 5px 160px 5px 5px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.akismet-activate__button,
|
||||
.akismet-activate__button:hover,
|
||||
.akismet-activate__button:visited {
|
||||
margin: 0 1em;
|
||||
}
|
||||
|
||||
.akismet-activate__description {
|
||||
color: var(--akismet-color-charcoal);
|
||||
flex-grow: 1;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
text-wrap: pretty;
|
||||
}
|
||||
|
||||
/* Compatible plugins section */
|
||||
.akismet-compatible-plugins__content {
|
||||
padding: 0 1.5em 1.5em 1.5em;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__intro {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__section-header-label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__section-header-label-text {
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
|
||||
gap: 20px;
|
||||
margin: 1.5em 0 1em 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__card {
|
||||
border: 1px solid var(--akismet-color-light-grey);
|
||||
border-radius: 4px;
|
||||
flex: 1 1 calc(50% - 5px);
|
||||
padding: 1em;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__card-logo {
|
||||
padding: 0 1.5em 0 0;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__card-title {
|
||||
font-size: 1.2em;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__docs {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__show-more {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Generates the show/hide chevron */
|
||||
.akismet-compatible-plugins__show-more::after {
|
||||
align-self: center;
|
||||
border-bottom: 2px solid black;
|
||||
border-right: 2px solid black;
|
||||
content: "";
|
||||
height: 8px;
|
||||
transform: rotate(45deg);
|
||||
transition: transform 0.2s ease;
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__list.is-expanded + .akismet-compatible-plugins__show-more::after {
|
||||
align-self: end;
|
||||
transform: rotate(225deg);
|
||||
}
|
||||
|
||||
/* Gutenberg medium breakpoint */
|
||||
@media screen and (max-width: 782px) {
|
||||
.akismet-new-snapshot__list {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__number {
|
||||
float: right;
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
margin-top: -16px;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__header {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"],
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
.akismet-settings__row-label-text {
|
||||
padding-left: 0.8em;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"],
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.akismet-activate {
|
||||
background-size: 120px;
|
||||
padding-right: 134px;
|
||||
}
|
||||
|
||||
.akismet-activate__button {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.akismet-activate__description {
|
||||
font-size: 14px;
|
||||
margin-right: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
/* Gutenberg small breakpoint */
|
||||
@media screen and (max-width: 600px) {
|
||||
.akismet-compatible-plugins__list {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.akismet-activate__button,
|
||||
.akismet-activate__button:hover {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.akismet-activate__description {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
37
wp-content/plugins/akismet/_inc/akismet-admin.js
Normal file
@ -0,0 +1,37 @@
|
||||
document.addEventListener( 'DOMContentLoaded', function() {
|
||||
// Prevent aggressive iframe caching in Firefox
|
||||
var statsIframe = document.getElementById( 'stats-iframe' );
|
||||
if ( statsIframe ) {
|
||||
statsIframe.contentWindow.location.href = statsIframe.src;
|
||||
}
|
||||
|
||||
initCompatiblePluginsShowMoreToggle();
|
||||
} );
|
||||
|
||||
function initCompatiblePluginsShowMoreToggle() {
|
||||
const section = document.querySelector( '.akismet-compatible-plugins' );
|
||||
const list = document.querySelector( '.akismet-compatible-plugins__list' );
|
||||
const button = document.querySelector( '.akismet-compatible-plugins__show-more' );
|
||||
|
||||
if ( ! section || ! list || ! button ) {
|
||||
return;
|
||||
}
|
||||
|
||||
function isElementInViewport( element ) {
|
||||
const rect = element.getBoundingClientRect();
|
||||
return rect.top >= 0 && rect.bottom <= window.innerHeight;
|
||||
}
|
||||
|
||||
function toggleCards() {
|
||||
list.classList.toggle( 'is-expanded' );
|
||||
const isExpanded = list.classList.contains( 'is-expanded' );
|
||||
button.textContent = isExpanded ? button.dataset.labelOpen : button.dataset.labelClosed;
|
||||
button.setAttribute( 'aria-expanded', isExpanded.toString() );
|
||||
|
||||
if ( ! isExpanded && ! isElementInViewport( section ) ) {
|
||||
section.scrollIntoView( { block: 'start' } );
|
||||
}
|
||||
}
|
||||
|
||||
button.addEventListener( 'click', toggleCards );
|
||||
}
|
||||
376
wp-content/plugins/akismet/_inc/akismet-frontend.js
Normal file
@ -0,0 +1,376 @@
|
||||
/**
|
||||
* Observe how the user enters content into the comment form in order to determine whether it's a bot or not.
|
||||
*
|
||||
* Note that no actual input is being saved here, only counts and timings between events.
|
||||
*/
|
||||
|
||||
( function() {
|
||||
// Passive event listeners are guaranteed to never call e.preventDefault(),
|
||||
// but they're not supported in all browsers. Use this feature detection
|
||||
// to determine whether they're available for use.
|
||||
var supportsPassive = false;
|
||||
|
||||
try {
|
||||
var opts = Object.defineProperty( {}, 'passive', {
|
||||
get : function() {
|
||||
supportsPassive = true;
|
||||
}
|
||||
} );
|
||||
|
||||
window.addEventListener( 'testPassive', null, opts );
|
||||
window.removeEventListener( 'testPassive', null, opts );
|
||||
} catch ( e ) {}
|
||||
|
||||
function init() {
|
||||
var input_begin = '';
|
||||
|
||||
var keydowns = {};
|
||||
var lastKeyup = null;
|
||||
var lastKeydown = null;
|
||||
var keypresses = [];
|
||||
|
||||
var modifierKeys = [];
|
||||
var correctionKeys = [];
|
||||
|
||||
var lastMouseup = null;
|
||||
var lastMousedown = null;
|
||||
var mouseclicks = [];
|
||||
|
||||
var mousemoveTimer = null;
|
||||
var lastMousemoveX = null;
|
||||
var lastMousemoveY = null;
|
||||
var mousemoveStart = null;
|
||||
var mousemoves = [];
|
||||
|
||||
var touchmoveCountTimer = null;
|
||||
var touchmoveCount = 0;
|
||||
|
||||
var lastTouchEnd = null;
|
||||
var lastTouchStart = null;
|
||||
var touchEvents = [];
|
||||
|
||||
var scrollCountTimer = null;
|
||||
var scrollCount = 0;
|
||||
|
||||
var correctionKeyCodes = [ 'Backspace', 'Delete', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown' ];
|
||||
var modifierKeyCodes = [ 'Shift', 'CapsLock' ];
|
||||
|
||||
var forms = document.querySelectorAll( 'form[method=post]' );
|
||||
|
||||
for ( var i = 0; i < forms.length; i++ ) {
|
||||
var form = forms[i];
|
||||
|
||||
var formAction = form.getAttribute( 'action' );
|
||||
|
||||
// Ignore forms that POST directly to other domains; these could be things like payment forms.
|
||||
if ( formAction ) {
|
||||
// Check that the form is posting to an external URL, not a path.
|
||||
if ( formAction.indexOf( 'http://' ) == 0 || formAction.indexOf( 'https://' ) == 0 ) {
|
||||
if ( formAction.indexOf( 'http://' + window.location.hostname + '/' ) != 0 && formAction.indexOf( 'https://' + window.location.hostname + '/' ) != 0 ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
form.addEventListener( 'submit', function () {
|
||||
var ak_bkp = prepare_timestamp_array_for_request( keypresses );
|
||||
var ak_bmc = prepare_timestamp_array_for_request( mouseclicks );
|
||||
var ak_bte = prepare_timestamp_array_for_request( touchEvents );
|
||||
var ak_bmm = prepare_timestamp_array_for_request( mousemoves );
|
||||
|
||||
var input_fields = {
|
||||
// When did the user begin entering any input?
|
||||
'bib': input_begin,
|
||||
|
||||
// When was the form submitted?
|
||||
'bfs': Date.now(),
|
||||
|
||||
// How many keypresses did they make?
|
||||
'bkpc': keypresses.length,
|
||||
|
||||
// How quickly did they press a sample of keys, and how long between them?
|
||||
'bkp': ak_bkp,
|
||||
|
||||
// How quickly did they click the mouse, and how long between clicks?
|
||||
'bmc': ak_bmc,
|
||||
|
||||
// How many mouseclicks did they make?
|
||||
'bmcc': mouseclicks.length,
|
||||
|
||||
// When did they press modifier keys (like Shift or Capslock)?
|
||||
'bmk': modifierKeys.join( ';' ),
|
||||
|
||||
// When did they correct themselves? e.g., press Backspace, or use the arrow keys to move the cursor back
|
||||
'bck': correctionKeys.join( ';' ),
|
||||
|
||||
// How many times did they move the mouse?
|
||||
'bmmc': mousemoves.length,
|
||||
|
||||
// How many times did they move around using a touchscreen?
|
||||
'btmc': touchmoveCount,
|
||||
|
||||
// How many times did they scroll?
|
||||
'bsc': scrollCount,
|
||||
|
||||
// How quickly did they perform touch events, and how long between them?
|
||||
'bte': ak_bte,
|
||||
|
||||
// How many touch events were there?
|
||||
'btec' : touchEvents.length,
|
||||
|
||||
// How quickly did they move the mouse, and how long between moves?
|
||||
'bmm' : ak_bmm
|
||||
};
|
||||
|
||||
var akismet_field_prefix = 'ak_';
|
||||
|
||||
if ( this.getElementsByClassName ) {
|
||||
// Check to see if we've used an alternate field name prefix. We store this as an attribute of the container around some of the Akismet fields.
|
||||
var possible_akismet_containers = this.getElementsByClassName( 'akismet-fields-container' );
|
||||
|
||||
for ( var containerIndex = 0; containerIndex < possible_akismet_containers.length; containerIndex++ ) {
|
||||
var container = possible_akismet_containers.item( containerIndex );
|
||||
|
||||
if ( container.getAttribute( 'data-prefix' ) ) {
|
||||
akismet_field_prefix = container.getAttribute( 'data-prefix' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( var field_name in input_fields ) {
|
||||
var field = document.createElement( 'input' );
|
||||
field.setAttribute( 'type', 'hidden' );
|
||||
field.setAttribute( 'name', akismet_field_prefix + field_name );
|
||||
field.setAttribute( 'value', input_fields[ field_name ] );
|
||||
this.appendChild( field );
|
||||
}
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
form.addEventListener( 'keydown', function ( e ) {
|
||||
// If you hold a key down, some browsers send multiple keydown events in a row.
|
||||
// Ignore any keydown events for a key that hasn't come back up yet.
|
||||
if ( e.key in keydowns ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var keydownTime = ( new Date() ).getTime();
|
||||
keydowns[ e.key ] = [ keydownTime ];
|
||||
|
||||
if ( ! input_begin ) {
|
||||
input_begin = keydownTime;
|
||||
}
|
||||
|
||||
// In some situations, we don't want to record an interval since the last keypress -- for example,
|
||||
// on the first keypress, or on a keypress after focus has changed to another element. Normally,
|
||||
// we want to record the time between the last keyup and this keydown. But if they press a
|
||||
// key while already pressing a key, we want to record the time between the two keydowns.
|
||||
|
||||
var lastKeyEvent = Math.max( lastKeydown, lastKeyup );
|
||||
|
||||
if ( lastKeyEvent ) {
|
||||
keydowns[ e.key ].push( keydownTime - lastKeyEvent );
|
||||
}
|
||||
|
||||
lastKeydown = keydownTime;
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
form.addEventListener( 'keyup', function ( e ) {
|
||||
if ( ! ( e.key in keydowns ) ) {
|
||||
// This key was pressed before this script was loaded, or a mouseclick happened during the keypress, or...
|
||||
return;
|
||||
}
|
||||
|
||||
var keyupTime = ( new Date() ).getTime();
|
||||
|
||||
if ( 'TEXTAREA' === e.target.nodeName || 'INPUT' === e.target.nodeName ) {
|
||||
if ( -1 !== modifierKeyCodes.indexOf( e.key ) ) {
|
||||
modifierKeys.push( keypresses.length - 1 );
|
||||
} else if ( -1 !== correctionKeyCodes.indexOf( e.key ) ) {
|
||||
correctionKeys.push( keypresses.length - 1 );
|
||||
} else {
|
||||
// ^ Don't record timings for keys like Shift or backspace, since they
|
||||
// typically get held down for longer than regular typing.
|
||||
|
||||
var keydownTime = keydowns[ e.key ][0];
|
||||
|
||||
var keypress = [];
|
||||
|
||||
// Keypress duration.
|
||||
keypress.push( keyupTime - keydownTime );
|
||||
|
||||
// Amount of time between this keypress and the previous keypress.
|
||||
if ( keydowns[ e.key ].length > 1 ) {
|
||||
keypress.push( keydowns[ e.key ][1] );
|
||||
}
|
||||
|
||||
keypresses.push( keypress );
|
||||
}
|
||||
}
|
||||
|
||||
delete keydowns[ e.key ];
|
||||
|
||||
lastKeyup = keyupTime;
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
form.addEventListener( "focusin", function ( e ) {
|
||||
lastKeydown = null;
|
||||
lastKeyup = null;
|
||||
keydowns = {};
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
form.addEventListener( "focusout", function ( e ) {
|
||||
lastKeydown = null;
|
||||
lastKeyup = null;
|
||||
keydowns = {};
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
}
|
||||
|
||||
document.addEventListener( 'mousedown', function ( e ) {
|
||||
lastMousedown = ( new Date() ).getTime();
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
document.addEventListener( 'mouseup', function ( e ) {
|
||||
if ( ! lastMousedown ) {
|
||||
// If the mousedown happened before this script was loaded, but the mouseup happened after...
|
||||
return;
|
||||
}
|
||||
|
||||
var now = ( new Date() ).getTime();
|
||||
|
||||
var mouseclick = [];
|
||||
mouseclick.push( now - lastMousedown );
|
||||
|
||||
if ( lastMouseup ) {
|
||||
mouseclick.push( lastMousedown - lastMouseup );
|
||||
}
|
||||
|
||||
mouseclicks.push( mouseclick );
|
||||
|
||||
lastMouseup = now;
|
||||
|
||||
// If the mouse has been clicked, don't record this time as an interval between keypresses.
|
||||
lastKeydown = null;
|
||||
lastKeyup = null;
|
||||
keydowns = {};
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
document.addEventListener( 'mousemove', function ( e ) {
|
||||
if ( mousemoveTimer ) {
|
||||
clearTimeout( mousemoveTimer );
|
||||
mousemoveTimer = null;
|
||||
}
|
||||
else {
|
||||
mousemoveStart = ( new Date() ).getTime();
|
||||
lastMousemoveX = e.offsetX;
|
||||
lastMousemoveY = e.offsetY;
|
||||
}
|
||||
|
||||
mousemoveTimer = setTimeout( function ( theEvent, originalMousemoveStart ) {
|
||||
var now = ( new Date() ).getTime() - 500; // To account for the timer delay.
|
||||
|
||||
var mousemove = [];
|
||||
mousemove.push( now - originalMousemoveStart );
|
||||
mousemove.push(
|
||||
Math.round(
|
||||
Math.sqrt(
|
||||
Math.pow( theEvent.offsetX - lastMousemoveX, 2 ) +
|
||||
Math.pow( theEvent.offsetY - lastMousemoveY, 2 )
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ( mousemove[1] > 0 ) {
|
||||
// If there was no measurable distance, then it wasn't really a move.
|
||||
mousemoves.push( mousemove );
|
||||
}
|
||||
|
||||
mousemoveStart = null;
|
||||
mousemoveTimer = null;
|
||||
}, 500, e, mousemoveStart );
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
document.addEventListener( 'touchmove', function ( e ) {
|
||||
if ( touchmoveCountTimer ) {
|
||||
clearTimeout( touchmoveCountTimer );
|
||||
}
|
||||
|
||||
touchmoveCountTimer = setTimeout( function () {
|
||||
touchmoveCount++;
|
||||
}, 500 );
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
document.addEventListener( 'touchstart', function ( e ) {
|
||||
lastTouchStart = ( new Date() ).getTime();
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
document.addEventListener( 'touchend', function ( e ) {
|
||||
if ( ! lastTouchStart ) {
|
||||
// If the touchstart happened before this script was loaded, but the touchend happened after...
|
||||
return;
|
||||
}
|
||||
|
||||
var now = ( new Date() ).getTime();
|
||||
|
||||
var touchEvent = [];
|
||||
touchEvent.push( now - lastTouchStart );
|
||||
|
||||
if ( lastTouchEnd ) {
|
||||
touchEvent.push( lastTouchStart - lastTouchEnd );
|
||||
}
|
||||
|
||||
touchEvents.push( touchEvent );
|
||||
|
||||
lastTouchEnd = now;
|
||||
|
||||
// Don't record this time as an interval between keypresses.
|
||||
lastKeydown = null;
|
||||
lastKeyup = null;
|
||||
keydowns = {};
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
|
||||
document.addEventListener( 'scroll', function ( e ) {
|
||||
if ( scrollCountTimer ) {
|
||||
clearTimeout( scrollCountTimer );
|
||||
}
|
||||
|
||||
scrollCountTimer = setTimeout( function () {
|
||||
scrollCount++;
|
||||
}, 500 );
|
||||
}, supportsPassive ? { passive: true } : false );
|
||||
}
|
||||
|
||||
/**
|
||||
* For the timestamp data that is collected, don't send more than `limit` data points in the request.
|
||||
* Choose a random slice and send those.
|
||||
*/
|
||||
function prepare_timestamp_array_for_request( a, limit ) {
|
||||
if ( ! limit ) {
|
||||
limit = 100;
|
||||
}
|
||||
|
||||
var rv = '';
|
||||
|
||||
if ( a.length > 0 ) {
|
||||
var random_starting_point = Math.max( 0, Math.floor( Math.random() * a.length - limit ) );
|
||||
|
||||
for ( var i = 0; i < limit && i < a.length; i++ ) {
|
||||
rv += a[ random_starting_point + i ][0];
|
||||
|
||||
if ( a[ random_starting_point + i ].length >= 2 ) {
|
||||
rv += "," + a[ random_starting_point + i ][1];
|
||||
}
|
||||
|
||||
rv += ";";
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
if ( document.readyState !== 'loading' ) {
|
||||
init();
|
||||
} else {
|
||||
document.addEventListener( 'DOMContentLoaded', init );
|
||||
}
|
||||
})();
|
||||
462
wp-content/plugins/akismet/_inc/akismet.css
Normal file
@ -0,0 +1,462 @@
|
||||
.wp-admin.jetpack_page_akismet-key-config, .wp-admin.settings_page_akismet-key-config {
|
||||
background-color:#f3f6f8;
|
||||
}
|
||||
|
||||
#submitted-on {
|
||||
position: relative;
|
||||
}
|
||||
#the-comment-list .author .akismet-user-comment-count {
|
||||
display: inline;
|
||||
}
|
||||
#the-comment-list .author a span {
|
||||
text-decoration: none;
|
||||
color: #999;
|
||||
}
|
||||
#the-comment-list .author a span.akismet-span-link {
|
||||
text-decoration: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
#the-comment-list .akismet_remove_url {
|
||||
margin-left: 3px;
|
||||
color: #999;
|
||||
padding: 2px 3px 2px 0;
|
||||
}
|
||||
#the-comment-list .akismet_remove_url:hover {
|
||||
color: #A7301F;
|
||||
font-weight: bold;
|
||||
padding: 2px 2px 2px 0;
|
||||
}
|
||||
#dashboard_recent_comments .akismet-status {
|
||||
display: none;
|
||||
}
|
||||
.akismet-status {
|
||||
float: right;
|
||||
}
|
||||
.akismet-status a {
|
||||
color: #AAA;
|
||||
font-style: italic;
|
||||
}
|
||||
table.comments td.comment p a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
table.comments td.comment p a:after {
|
||||
content: attr(href);
|
||||
color: #aaa;
|
||||
display: inline-block; /* Show the URL without the link's underline extending under it. */
|
||||
padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */
|
||||
}
|
||||
.mshot-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 10px solid transparent;
|
||||
border-bottom: 10px solid transparent;
|
||||
border-right: 10px solid #5C5C5C;
|
||||
position: absolute;
|
||||
left: -6px;
|
||||
top: 91px;
|
||||
}
|
||||
.mshot-container {
|
||||
background: #5C5C5C;
|
||||
position: absolute;
|
||||
top: -94px;
|
||||
padding: 7px;
|
||||
width: 450px;
|
||||
height: 338px;
|
||||
z-index: 20000;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.akismet-mshot {
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
}
|
||||
.akismet-mshot .mshot-image {
|
||||
margin: 0;
|
||||
height: 338px;
|
||||
width: 450px;
|
||||
}
|
||||
.checkforspam {
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
.checkforspam-spinner {
|
||||
display: inline-block;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.akismet-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.akismet-card .akismet-right {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot {
|
||||
margin-top: 1em;
|
||||
text-align: center;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot h3 {
|
||||
background: #f5f5f5;
|
||||
color: #888;
|
||||
font-size: 11px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot ul li {
|
||||
color: #999;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
.akismet-settings th:first-child {
|
||||
vertical-align: top;
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
.akismet-settings th.akismet-api-key {
|
||||
vertical-align: middle;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.akismet-settings span.akismet-note {
|
||||
float: left;
|
||||
padding-left: 23px;
|
||||
font-size: 75%;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
.jetpack_page_akismet-key-config #wpcontent, .settings_page_akismet-key-config #wpcontent {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.akismet-masthead {
|
||||
background-color:#fff;
|
||||
text-align:center;
|
||||
box-shadow:0 1px 0 rgba(200,215,225,0.5),0 1px 2px #e9eff3
|
||||
}
|
||||
|
||||
@media (max-width: 45rem) {
|
||||
.akismet-masthead {
|
||||
padding:0 1.25rem
|
||||
}
|
||||
}
|
||||
|
||||
.akismet-masthead__inside-container {
|
||||
padding:.375rem 0;
|
||||
margin:0 auto;
|
||||
width:100%;
|
||||
max-width:45rem;
|
||||
text-align: left;
|
||||
}
|
||||
.akismet-masthead__logo-container {
|
||||
padding:.3125rem 0 0
|
||||
}
|
||||
.akismet-masthead__logo-link {
|
||||
display:inline-block;
|
||||
outline:none;
|
||||
vertical-align:middle
|
||||
}
|
||||
.akismet-masthead__logo-link:focus {
|
||||
line-height:0;
|
||||
box-shadow:0 0 0 2px #78dcfa
|
||||
}
|
||||
.akismet-masthead__logo-link+code {
|
||||
margin:0 10px;
|
||||
padding:5px 9px;
|
||||
border-radius:2px;
|
||||
background:#e6ecf1;
|
||||
color:#647a88
|
||||
}
|
||||
.akismet-masthead__links {
|
||||
display:flex;
|
||||
flex-flow:row wrap;
|
||||
flex:2 50%;
|
||||
justify-content:flex-end;
|
||||
margin:0
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.akismet-masthead__links {
|
||||
padding-right:.625rem
|
||||
}
|
||||
}
|
||||
.akismet-masthead__link-li {
|
||||
margin:0;
|
||||
padding:0
|
||||
}
|
||||
.akismet-masthead__link {
|
||||
font-style:normal;
|
||||
color:#0087be;
|
||||
padding:.625rem;
|
||||
display:inline-block
|
||||
}
|
||||
.akismet-masthead__link:visited {
|
||||
color:#0087be
|
||||
}
|
||||
.akismet-masthead__link:active,.akismet-masthead__link:hover {
|
||||
color:#00aadc
|
||||
}
|
||||
.akismet-masthead__link:hover {
|
||||
text-decoration:underline
|
||||
}
|
||||
.akismet-masthead__link .dashicons {
|
||||
display:none
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.akismet-masthead__link:hover,.akismet-masthead__link:active {
|
||||
text-decoration:none
|
||||
}
|
||||
.akismet-masthead__link .dashicons {
|
||||
display:block;
|
||||
font-size:1.75rem
|
||||
}
|
||||
.akismet-masthead__link span+span {
|
||||
display:none
|
||||
}
|
||||
}
|
||||
.akismet-masthead__link-li:last-of-type .akismet-masthead__link {
|
||||
padding-right:0
|
||||
}
|
||||
|
||||
.akismet-lower {
|
||||
margin: 0 auto;
|
||||
text-align: left;
|
||||
max-width: 45rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-lower .notice {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.akismet-card {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 0;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.akismet-card:after, .akismet-card .inside:after, .akismet-masthead__logo-container:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.akismet-card .inside {
|
||||
padding: 1.5rem;
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.akismet-card .akismet-card-actions {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.jetpack_page_akismet-key-config .update-nag, .settings_page_akismet-key-config .update-nag {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.akismet-masthead .akismet-right {
|
||||
line-height: 2.125rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.akismet-box {
|
||||
box-sizing: border-box;
|
||||
background: white;
|
||||
border: 1px solid rgba(200, 215, 225, 0.5);
|
||||
}
|
||||
|
||||
.akismet-box h2, .akismet-box h3 {
|
||||
padding: 1.5rem 1.5rem .5rem 1.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-box p {
|
||||
padding: 0 1.5rem 1.5rem 1.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-box p:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.akismet-box .akismet-right {
|
||||
padding-right: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-boxes .akismet-box {
|
||||
margin-bottom: 0;
|
||||
padding: 0;
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.akismet-boxes .akismet-box:last-child {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-boxes .akismet-box:first-child {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-box .centered {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.akismet-button, .akismet-button:hover, .akismet-button:visited {
|
||||
background: white;
|
||||
border-color: #c8d7e1;
|
||||
border-style: solid;
|
||||
border-width: 1px 1px 2px;
|
||||
color: #2e4453;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
outline: 0;
|
||||
overflow: hidden;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-overflow: ellipsis;
|
||||
text-decoration: none;
|
||||
vertical-align: top;
|
||||
box-sizing: border-box;
|
||||
line-height: 21px;
|
||||
border-radius: 4px;
|
||||
padding: 7px 14px 9px;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.akismet-button:hover {
|
||||
border-color: #a8bece;
|
||||
}
|
||||
|
||||
.akismet-button:active {
|
||||
border-width: 2px 1px 1px;
|
||||
}
|
||||
|
||||
.akismet-is-primary, .akismet-is-primary:hover, .akismet-is-primary:visited {
|
||||
background: #00aadc;
|
||||
border-color: #0087be;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.akismet-is-primary:hover, .akismet-is-primary:focus {
|
||||
border-color: #005082;
|
||||
}
|
||||
|
||||
.akismet-is-primary:hover {
|
||||
border-color: #005082;
|
||||
}
|
||||
|
||||
.akismet-section-header {
|
||||
position: relative;
|
||||
margin: 0 auto 0.625rem auto;
|
||||
padding: 1rem;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
background: #ffffff;
|
||||
width: 100%;
|
||||
padding-top: 0.6875rem;
|
||||
padding-bottom: 0.6875rem;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-section-header__label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
line-height: 1.75rem;
|
||||
position: relative;
|
||||
font-size: 0.875rem;
|
||||
color: #4f748e;
|
||||
}
|
||||
|
||||
.akismet-section-header__actions {
|
||||
line-height: 1.75rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions form {
|
||||
padding-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions > a.akismet-button {
|
||||
display: inline-block;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
div.error.akismet-usage-limit-alert {
|
||||
padding: 25px 45px 25px 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#akismet-plugin-container .akismet-usage-limit-alert {
|
||||
margin: 0 auto 0.625rem auto;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
border: none;
|
||||
border-left: 4px solid #d63638;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-logo {
|
||||
width: 38px;
|
||||
min-width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 20px;
|
||||
margin-right: 18px;
|
||||
background: black;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-logo img {
|
||||
position: absolute;
|
||||
width: 22px;
|
||||
left: 8px;
|
||||
top: 10px;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-text {
|
||||
flex-grow: 1;
|
||||
margin-right: 18px;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert h3 {
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-cta {
|
||||
border-color: none;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#akismet-plugin-container .akismet-usage-limit-cta a {
|
||||
color: #d63638;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
@media (max-width: 550px) {
|
||||
div.error.akismet-usage-limit-alert {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-logo,
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-text {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-cta {
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
397
wp-content/plugins/akismet/_inc/akismet.js
Normal file
@ -0,0 +1,397 @@
|
||||
jQuery( function ( $ ) {
|
||||
var mshotRemovalTimer = null;
|
||||
var mshotRetryTimer = null;
|
||||
var mshotTries = 0;
|
||||
var mshotRetryInterval = 1000;
|
||||
var mshotEnabledLinkSelector = 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a';
|
||||
|
||||
var preloadedMshotURLs = [];
|
||||
|
||||
$('.akismet-status').each(function () {
|
||||
var thisId = $(this).attr('commentid');
|
||||
$(this).prependTo('#comment-' + thisId + ' .column-comment');
|
||||
});
|
||||
$('.akismet-user-comment-count').each(function () {
|
||||
var thisId = $(this).attr('commentid');
|
||||
$(this).insertAfter('#comment-' + thisId + ' .author strong:first').show();
|
||||
});
|
||||
|
||||
akismet_enable_comment_author_url_removal();
|
||||
|
||||
$( '#the-comment-list' ).on( 'click', '.akismet_remove_url', function () {
|
||||
var thisId = $(this).attr('commentid');
|
||||
var data = {
|
||||
action: 'comment_author_deurl',
|
||||
_wpnonce: WPAkismet.comment_author_url_nonce,
|
||||
id: thisId
|
||||
};
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
beforeSend: function () {
|
||||
// Removes "x" link
|
||||
$("a[commentid='"+ thisId +"']").hide();
|
||||
// Show temp status
|
||||
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Removing...'] ) );
|
||||
},
|
||||
success: function (response) {
|
||||
if (response) {
|
||||
// Show status/undo link
|
||||
$("#author_comment_url_"+ thisId)
|
||||
.attr('cid', thisId)
|
||||
.addClass('akismet_undo_link_removal')
|
||||
.html(
|
||||
$( '<span/>' ).text( WPAkismet.strings['URL removed'] )
|
||||
)
|
||||
.append( ' ' )
|
||||
.append(
|
||||
$( '<span/>' )
|
||||
.text( WPAkismet.strings['(undo)'] )
|
||||
.addClass( 'akismet-span-link' )
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
}).on( 'click', '.akismet_undo_link_removal', function () {
|
||||
var thisId = $(this).attr('cid');
|
||||
var thisUrl = $(this).attr('href');
|
||||
var data = {
|
||||
action: 'comment_author_reurl',
|
||||
_wpnonce: WPAkismet.comment_author_url_nonce,
|
||||
id: thisId,
|
||||
url: thisUrl
|
||||
};
|
||||
$.ajax({
|
||||
url: ajaxurl,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
beforeSend: function () {
|
||||
// Show temp status
|
||||
$("#author_comment_url_"+ thisId).html( $( '<span/>' ).text( WPAkismet.strings['Re-adding...'] ) );
|
||||
},
|
||||
success: function (response) {
|
||||
if (response) {
|
||||
// Add "x" link
|
||||
$("a[commentid='"+ thisId +"']").show();
|
||||
// Show link. Core strips leading http://, so let's do that too.
|
||||
$("#author_comment_url_"+ thisId).removeClass('akismet_undo_link_removal').text( thisUrl.replace( /^http:\/\/(www\.)?/ig, '' ) );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Show a preview image of the hovered URL. Applies to author URLs and URLs inside the comments.
|
||||
if ( "enable_mshots" in WPAkismet && WPAkismet.enable_mshots ) {
|
||||
$( '#the-comment-list' ).on( 'mouseover', mshotEnabledLinkSelector, function () {
|
||||
clearTimeout( mshotRemovalTimer );
|
||||
|
||||
if ( $( '.akismet-mshot' ).length > 0 ) {
|
||||
if ( $( '.akismet-mshot:first' ).data( 'link' ) == this ) {
|
||||
// The preview is already showing for this link.
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// A new link is being hovered, so remove the old preview.
|
||||
$( '.akismet-mshot' ).remove();
|
||||
}
|
||||
}
|
||||
|
||||
clearTimeout( mshotRetryTimer );
|
||||
|
||||
var linkUrl = $( this ).attr( 'href' );
|
||||
|
||||
if ( preloadedMshotURLs.indexOf( linkUrl ) !== -1 ) {
|
||||
// This preview image was already preloaded, so begin with a retry URL so the user doesn't see the placeholder image for the first second.
|
||||
mshotTries = 2;
|
||||
}
|
||||
else {
|
||||
mshotTries = 1;
|
||||
}
|
||||
|
||||
var mShot = $( '<div class="akismet-mshot mshot-container"><div class="mshot-arrow"></div><img src="' + akismet_mshot_url( linkUrl, mshotTries ) + '" width="450" height="338" class="mshot-image" /></div>' );
|
||||
mShot.data( 'link', this );
|
||||
mShot.data( 'url', linkUrl );
|
||||
|
||||
mShot.find( 'img' ).on( 'load', function () {
|
||||
$( '.akismet-mshot' ).data( 'pending-request', false );
|
||||
} );
|
||||
|
||||
var offset = $( this ).offset();
|
||||
|
||||
mShot.offset( {
|
||||
left : Math.min( $( window ).width() - 475, offset.left + $( this ).width() + 10 ), // Keep it on the screen if the link is near the edge of the window.
|
||||
top: offset.top + ( $( this ).height() / 2 ) - 101 // 101 = top offset of the arrow plus the top border thickness
|
||||
} );
|
||||
|
||||
$( 'body' ).append( mShot );
|
||||
|
||||
mshotRetryTimer = setTimeout( retryMshotUntilLoaded, mshotRetryInterval );
|
||||
} ).on( 'mouseout', 'a[id^="author_comment_url"], tr.pingback td.column-author a:first-of-type, td.comment p a', function () {
|
||||
mshotRemovalTimer = setTimeout( function () {
|
||||
clearTimeout( mshotRetryTimer );
|
||||
|
||||
$( '.akismet-mshot' ).remove();
|
||||
}, 200 );
|
||||
} );
|
||||
|
||||
var preloadDelayTimer = null;
|
||||
|
||||
$( window ).on( 'scroll resize', function () {
|
||||
clearTimeout( preloadDelayTimer );
|
||||
|
||||
preloadDelayTimer = setTimeout( preloadMshotsInViewport, 500 );
|
||||
} );
|
||||
|
||||
preloadMshotsInViewport();
|
||||
}
|
||||
|
||||
/**
|
||||
* The way mShots works is if there was no screenshot already recently generated for the URL,
|
||||
* it returns a "loading..." image for the first request. Then, some subsequent request will
|
||||
* receive the actual screenshot, but it's unknown how long it will take. So, what we do here
|
||||
* is continually re-request the mShot, waiting a second after every response until we get the
|
||||
* actual screenshot.
|
||||
*/
|
||||
function retryMshotUntilLoaded() {
|
||||
clearTimeout( mshotRetryTimer );
|
||||
|
||||
var imageWidth = $( '.akismet-mshot img' ).get(0).naturalWidth;
|
||||
|
||||
if ( imageWidth == 0 ) {
|
||||
// It hasn't finished loading yet the first time. Check again shortly.
|
||||
setTimeout( retryMshotUntilLoaded, mshotRetryInterval );
|
||||
}
|
||||
else if ( imageWidth == 400 ) {
|
||||
// It loaded the preview image.
|
||||
|
||||
if ( mshotTries == 20 ) {
|
||||
// Give up if we've requested the mShot 20 times already.
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $( '.akismet-mshot' ).data( 'pending-request' ) ) {
|
||||
$( '.akismet-mshot' ).data( 'pending-request', true );
|
||||
|
||||
mshotTries++;
|
||||
|
||||
$( '.akismet-mshot .mshot-image' ).attr( 'src', akismet_mshot_url( $( '.akismet-mshot' ).data( 'url' ), mshotTries ) );
|
||||
}
|
||||
|
||||
mshotRetryTimer = setTimeout( retryMshotUntilLoaded, mshotRetryInterval );
|
||||
}
|
||||
else {
|
||||
// All done.
|
||||
}
|
||||
}
|
||||
|
||||
function preloadMshotsInViewport() {
|
||||
var windowWidth = $( window ).width();
|
||||
var windowHeight = $( window ).height();
|
||||
|
||||
$( '#the-comment-list' ).find( mshotEnabledLinkSelector ).each( function ( index, element ) {
|
||||
var linkUrl = $( this ).attr( 'href' );
|
||||
|
||||
// Don't attempt to preload an mshot for a single link twice.
|
||||
if ( preloadedMshotURLs.indexOf( linkUrl ) !== -1 ) {
|
||||
// The URL is already preloaded.
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( typeof element.getBoundingClientRect !== 'function' ) {
|
||||
// The browser is too old. Return false to stop this preloading entirely.
|
||||
return false;
|
||||
}
|
||||
|
||||
var rect = element.getBoundingClientRect();
|
||||
|
||||
if ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= windowHeight && rect.right <= windowWidth ) {
|
||||
akismet_preload_mshot( linkUrl );
|
||||
$( this ).data( 'akismet-mshot-preloaded', true );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
$( '.checkforspam.enable-on-load' ).on( 'click', function( e ) {
|
||||
if ( $( this ).hasClass( 'ajax-disabled' ) ) {
|
||||
// Akismet hasn't been configured yet. Allow the user to proceed to the button's link.
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if ( $( this ).hasClass( 'button-disabled' ) ) {
|
||||
window.location.href = $( this ).data( 'success-url' ).replace( '__recheck_count__', 0 ).replace( '__spam_count__', 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
$('.checkforspam').addClass('button-disabled').addClass( 'checking' );
|
||||
$('.checkforspam-spinner').addClass( 'spinner' ).addClass( 'is-active' );
|
||||
|
||||
akismet_check_for_spam(0, 100);
|
||||
}).removeClass( 'button-disabled' );
|
||||
|
||||
var spam_count = 0;
|
||||
var recheck_count = 0;
|
||||
|
||||
function akismet_check_for_spam(offset, limit) {
|
||||
var check_for_spam_buttons = $( '.checkforspam' );
|
||||
|
||||
var nonce = check_for_spam_buttons.data( 'nonce' );
|
||||
|
||||
// We show the percentage complete down to one decimal point so even queues with 100k
|
||||
// pending comments will show some progress pretty quickly.
|
||||
var percentage_complete = Math.round( ( recheck_count / check_for_spam_buttons.data( 'pending-comment-count' ) ) * 1000 ) / 10;
|
||||
|
||||
// Update the progress counter on the "Check for Spam" button.
|
||||
$( '.checkforspam' ).text( check_for_spam_buttons.data( 'progress-label' ).replace( '%1$s', percentage_complete ) );
|
||||
|
||||
$.post(
|
||||
ajaxurl,
|
||||
{
|
||||
'action': 'akismet_recheck_queue',
|
||||
'offset': offset,
|
||||
'limit': limit,
|
||||
'nonce': nonce
|
||||
},
|
||||
function(result) {
|
||||
if ( 'error' in result ) {
|
||||
// An error is only returned in the case of a missing nonce, so we don't need the actual error message.
|
||||
window.location.href = check_for_spam_buttons.data( 'failure-url' );
|
||||
return;
|
||||
}
|
||||
|
||||
recheck_count += result.counts.processed;
|
||||
spam_count += result.counts.spam;
|
||||
|
||||
if (result.counts.processed < limit) {
|
||||
window.location.href = check_for_spam_buttons.data( 'success-url' ).replace( '__recheck_count__', recheck_count ).replace( '__spam_count__', spam_count );
|
||||
}
|
||||
else {
|
||||
// Account for comments that were caught as spam and moved out of the queue.
|
||||
akismet_check_for_spam(offset + limit - result.counts.spam, limit);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if ( "start_recheck" in WPAkismet && WPAkismet.start_recheck ) {
|
||||
$( '.checkforspam:first' ).click();
|
||||
}
|
||||
|
||||
if ( typeof MutationObserver !== 'undefined' ) {
|
||||
// Dynamically add the "X" next the the author URL links when a comment is quick-edited.
|
||||
var comment_list_container = document.getElementById( 'the-comment-list' );
|
||||
|
||||
if ( comment_list_container ) {
|
||||
var observer = new MutationObserver( function ( mutations ) {
|
||||
for ( var i = 0, _len = mutations.length; i < _len; i++ ) {
|
||||
if ( mutations[i].addedNodes.length > 0 ) {
|
||||
akismet_enable_comment_author_url_removal();
|
||||
|
||||
// Once we know that we'll have to check for new author links, skip the rest of the mutations.
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
observer.observe( comment_list_container, { attributes: true, childList: true, characterData: true } );
|
||||
}
|
||||
}
|
||||
|
||||
function akismet_enable_comment_author_url_removal() {
|
||||
$( '#the-comment-list' )
|
||||
.find( 'tr.comment, tr[id ^= "comment-"]' )
|
||||
.find( '.column-author a[href^="http"]:first' ) // Ignore mailto: links, which would be the comment author's email.
|
||||
.each(function () {
|
||||
if ( $( this ).parent().find( '.akismet_remove_url' ).length > 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var linkHref = $(this).attr( 'href' );
|
||||
|
||||
// Ignore any links to the current domain, which are diagnostic tools, like the IP address link
|
||||
// or any other links another plugin might add.
|
||||
var currentHostParts = document.location.href.split( '/' );
|
||||
var currentHost = currentHostParts[0] + '//' + currentHostParts[2] + '/';
|
||||
|
||||
if ( linkHref.indexOf( currentHost ) != 0 ) {
|
||||
var thisCommentId = $(this).parents('tr:first').attr('id').split("-");
|
||||
|
||||
$(this)
|
||||
.attr("id", "author_comment_url_"+ thisCommentId[1])
|
||||
.after(
|
||||
$( '<a href="#" class="akismet_remove_url">x</a>' )
|
||||
.attr( 'commentid', thisCommentId[1] )
|
||||
.attr( 'title', WPAkismet.strings['Remove this URL'] )
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an mShot URL if given a link URL.
|
||||
*
|
||||
* @param string linkUrl
|
||||
* @param int retry If retrying a request, the number of the retry.
|
||||
* @return string The mShot URL;
|
||||
*/
|
||||
function akismet_mshot_url( linkUrl, retry ) {
|
||||
var mshotUrl = '//s0.wp.com/mshots/v1/' + encodeURIComponent( linkUrl ) + '?w=900';
|
||||
|
||||
if ( retry > 1 ) {
|
||||
mshotUrl += '&r=' + encodeURIComponent( retry );
|
||||
}
|
||||
|
||||
mshotUrl += '&source=akismet';
|
||||
|
||||
return mshotUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin loading an mShot preview of a link.
|
||||
*
|
||||
* @param string linkUrl
|
||||
*/
|
||||
function akismet_preload_mshot( linkUrl ) {
|
||||
var img = new Image();
|
||||
img.src = akismet_mshot_url( linkUrl );
|
||||
|
||||
preloadedMshotURLs.push( linkUrl );
|
||||
}
|
||||
|
||||
$( '.akismet-could-be-primary' ).each( function () {
|
||||
var form = $( this ).closest( 'form' );
|
||||
|
||||
form.data( 'initial-state', form.serialize() );
|
||||
|
||||
form.on( 'change keyup', function () {
|
||||
var self = $( this );
|
||||
var submit_button = self.find( '.akismet-could-be-primary' );
|
||||
|
||||
if ( self.serialize() != self.data( 'initial-state' ) ) {
|
||||
submit_button.addClass( 'akismet-is-primary' );
|
||||
}
|
||||
else {
|
||||
submit_button.removeClass( 'akismet-is-primary' );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
/**
|
||||
* Shows the Enter API key form
|
||||
*/
|
||||
$( '.akismet-enter-api-key-box__reveal' ).on( 'click', function ( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var div = $( '.akismet-enter-api-key-box__form-wrapper' );
|
||||
div.show( 500 );
|
||||
div.find( 'input[name=key]' ).focus();
|
||||
|
||||
$( this ).hide();
|
||||
} );
|
||||
});
|
||||
67
wp-content/plugins/akismet/_inc/fonts/inter.css
Normal file
@ -0,0 +1,67 @@
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-Regular.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-Regular.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-Italic.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-Italic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-Medium.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-Medium.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: italic;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-MediumItalic.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-MediumItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-SemiBold.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-SemiBold.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: italic;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-SemiBoldItalic.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-SemiBoldItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-Bold.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-Bold.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Inter';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
src: url("https://s0.wp.com/i/fonts/inter/Inter-BoldItalic.woff2?v=3.19") format("woff2"),
|
||||
url("https://s0.wp.com/i/fonts/inter/Inter-BoldItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
BIN
wp-content/plugins/akismet/_inc/img/akismet-refresh-logo@2x.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
1
wp-content/plugins/akismet/_inc/img/arrow-left.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"></path></svg>
|
||||
|
After Width: | Height: | Size: 199 B |
BIN
wp-content/plugins/akismet/_inc/img/logo-a-2x.png
Normal file
|
After Width: | Height: | Size: 904 B |
718
wp-content/plugins/akismet/_inc/rtl/akismet-admin-rtl.css
Normal file
@ -0,0 +1,718 @@
|
||||
/* This file was automatically generated on Oct 23 2025 00:26:05 */
|
||||
|
||||
body {
|
||||
--akismet-color-charcoal: #272635;
|
||||
--akismet-color-light-grey: #f6f7f7;
|
||||
--akismet-color-mid-grey: #a7aaad;
|
||||
--akismet-color-dark-grey: #646970;
|
||||
--akismet-color-grey-80: #2c3338;
|
||||
--akismet-color-grey-100: #101517;
|
||||
--akismet-color-grey-border: #dcdcde;
|
||||
--akismet-color-white: #fff;
|
||||
--akismet-color-dark-green: #2d6a40;
|
||||
--akismet-color-mid-green: #357b49;
|
||||
--akismet-color-light-green: #4eb26a;
|
||||
--akismet-color-mid-red: #e82c3f;
|
||||
--akismet-color-light-blue: #256eff;
|
||||
--akismet-color-notice-light-green: #dbf0e1;
|
||||
--akismet-color-notice-dark-green: #69bf82;
|
||||
--akismet-color-notice-light-red: #ffdbde;
|
||||
--akismet-color-notice-dark-red: #ff6676;
|
||||
--akismet-color-notice-yellow: #e5c133;
|
||||
}
|
||||
|
||||
/* UI components */
|
||||
.akismet-new-feature {
|
||||
background-color: var(--akismet-color-mid-green);
|
||||
border-radius: 4px;
|
||||
color: var(--akismet-color-white);
|
||||
font-size: 10px;
|
||||
padding: 4px 6px;
|
||||
text-transform: uppercase;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#akismet-plugin-container {
|
||||
background-color: var(--akismet-color-light-grey);
|
||||
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
#akismet-plugin-container a {
|
||||
color: var(--akismet-color-mid-green);
|
||||
}
|
||||
|
||||
#akismet-plugin-container a.akismet-button {
|
||||
background-color: var(--akismet-color-mid-green);
|
||||
color: var(--akismet-color-white);
|
||||
}
|
||||
|
||||
#akismet-plugin-container button:focus-visible,
|
||||
#akismet-plugin-container input:focus-visible,
|
||||
#akismet-plugin-container a:focus-visible {
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
outline: 2px solid var(--akismet-color-light-blue);
|
||||
}
|
||||
|
||||
.akismet-masthead {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.akismet-masthead__logo {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.akismet-section-header {
|
||||
box-shadow: none;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.akismet-section-header__label {
|
||||
color: var(--akismet-color-charcoal);
|
||||
font-weight: 600;
|
||||
padding-right: 0.2em;
|
||||
}
|
||||
|
||||
.akismet-button,
|
||||
.akismet-button:hover {
|
||||
border: 0;
|
||||
color: var(--akismet-color-white);
|
||||
}
|
||||
|
||||
.akismet-button {
|
||||
background-color: var(--akismet-color-mid-green);
|
||||
}
|
||||
|
||||
.akismet-button:hover {
|
||||
background-color: var(--akismet-color-dark-green);
|
||||
}
|
||||
|
||||
.akismet-external-link::after {
|
||||
content: "↗";
|
||||
display: inline-block;
|
||||
padding-right: 2px;
|
||||
text-decoration: none;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
/* Need this specificity to override the existing header rule */
|
||||
.akismet-new-snapshot h3.akismet-new-snapshot__header {
|
||||
background: none;
|
||||
font-size: 13px;
|
||||
color: var(--akismet-color-charcoal);
|
||||
text-align: right;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__number {
|
||||
color: var(--akismet-color-charcoal);
|
||||
display: block;
|
||||
font-size: 32px;
|
||||
font-weight: 400;
|
||||
letter-spacing: -1px;
|
||||
line-height: 1.5em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot li.akismet-new-snapshot__item {
|
||||
color: var(--akismet-color-dark-grey);
|
||||
font-size: 13px;
|
||||
text-align: right;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
.akismet-masthead__logo-link {
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.akismet-masthead__back-link-container {
|
||||
margin-top: 16px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
/* Need this specificity to override the existing link rule */
|
||||
#akismet-plugin-container a.akismet-masthead__back-link {
|
||||
background-image: url(../img/arrow-left.svg);
|
||||
background-position: right;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 16px;
|
||||
color: var(--akismet-color-charcoal);
|
||||
font-weight: 400;
|
||||
padding-right: 20px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#akismet-plugin-container a.akismet-masthead__back-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__item {
|
||||
border-top: 1px solid var(--akismet-color-light-grey);
|
||||
border-right: 1px solid var(--akismet-color-light-grey);
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot li:first-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__list {
|
||||
display: flex;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__item {
|
||||
flex: 1 0 33.33%;
|
||||
margin-bottom: 0;
|
||||
padding-right: 1.5em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__chart {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.akismet-box {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.akismet-box:not(:first-child) {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.akismet-box,
|
||||
.akismet-card {
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.akismet-card {
|
||||
margin: 32px auto 0 auto;
|
||||
}
|
||||
|
||||
.akismet-lower {
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.akismet-lower .inside {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.akismet-section-header__label {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-settings__row {
|
||||
border-bottom: 1px solid var(--akismet-color-light-grey);
|
||||
display: block;
|
||||
padding: 1em 1.5em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-input {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.akismet-settings__row-title {
|
||||
font-weight: 500;
|
||||
font-size: 1em;
|
||||
margin: 0;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-description {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
|
||||
.akismet-card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.akismet-card-actions__secondary-action {
|
||||
align-self: center;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.akismet-settings__row label {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-note {
|
||||
font-size: 0.9em;
|
||||
margin-top: 0.4em;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"],
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
accent-color: var(--akismet-color-mid-green);
|
||||
box-shadow: none;
|
||||
flex-shrink: 0;
|
||||
margin: 2px 0 0 0;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"] {
|
||||
margin-top: 1px;
|
||||
vertical-align: top;
|
||||
-webkit-appearance: checkbox;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
-webkit-appearance: radio;
|
||||
}
|
||||
|
||||
/* Fix up misbehaving wp-admin styles in Chrome (from forms and colors stylesheets) */
|
||||
.akismet-settings__row input[type="checkbox"]:checked:before {
|
||||
content: '';
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="radio"]:checked:before {
|
||||
background: none;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"]:checked:hover,
|
||||
.akismet-settings__row input[type="radio"]:checked:hover {
|
||||
accent-color: var(--akismet-color-mid-green);
|
||||
}
|
||||
|
||||
.akismet-button:disabled {
|
||||
background-color: var(--akismet-color-mid-grey);
|
||||
color: var(--akismet-color-white);
|
||||
cursor: arrow;
|
||||
}
|
||||
|
||||
.akismet-awaiting-stats,
|
||||
.akismet-account {
|
||||
padding: 0 1rem 1rem 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-account {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.akismet-account th {
|
||||
font-weight: 500;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.akismet-account th, .akismet-account td {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
.akismet-settings__row-input-label {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-settings__row-label-text {
|
||||
padding-right: 0.5em;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.akismet-alert {
|
||||
border-right: 8px solid;
|
||||
border-radius: 8px;
|
||||
margin: 20px 0;
|
||||
padding: 0.2em 1em;
|
||||
}
|
||||
|
||||
.akismet-alert__heading {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.akismet-alert.is-good {
|
||||
background-color: var(--akismet-color-notice-light-green);
|
||||
border-right-color: var(--akismet-color-notice-dark-green);
|
||||
}
|
||||
|
||||
.akismet-alert.is-neutral {
|
||||
background-color: var(--akismet-color-white);
|
||||
border-right-color: var(--akismet-color-dark-grey);
|
||||
}
|
||||
|
||||
.akismet-alert.is-bad {
|
||||
background-color: var(--akismet-color-notice-light-red);
|
||||
border-right-color: var(--akismet-color-notice-dark-red);
|
||||
}
|
||||
|
||||
.akismet-alert.is-commercial {
|
||||
background-color: var(--akismet-color-white);
|
||||
border-color: var(--akismet-color-mid-grey);
|
||||
border-bottom-width: 1px;
|
||||
border-right-color: var(--akismet-color-notice-yellow);
|
||||
display: flex;
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
|
||||
#akismet-plugin-container .akismet-alert.is-good a,
|
||||
#akismet-plugin-container .akismet-alert.is-bad a {
|
||||
/* For better contrast - green isn't great */
|
||||
color: var(--akismet-color-grey-80);
|
||||
}
|
||||
|
||||
.akismet-alert-header {
|
||||
font-size: 16px;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.akismet-alert-button-wrapper {
|
||||
align-self: center;
|
||||
margin-right: 2em;
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.akismet-alert-info {
|
||||
text-wrap: pretty;
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
/* Setup */
|
||||
.akismet-setup-instructions__heading {
|
||||
font-size: 1.375rem;
|
||||
font-weight: 700;
|
||||
padding-block-end: 0;
|
||||
}
|
||||
|
||||
h3.akismet-setup-instructions__subheading {
|
||||
color: var(--akismet-color-dark-grey);
|
||||
font-size: 1rem;
|
||||
font-weight: 400;
|
||||
line-height: 1.5;
|
||||
margin: 0 0 1.25rem;
|
||||
padding-block-start: 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__feature-list {
|
||||
list-style: none;
|
||||
margin: 1rem 0.5rem 1.5rem;
|
||||
max-width: 640px;
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__feature {
|
||||
align-items: start;
|
||||
display: flex;
|
||||
margin-block-end: 1rem;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__icon {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__body {
|
||||
flex: 1;
|
||||
padding-inline-start: 0.5rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__title {
|
||||
color: #1d2327;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
p.akismet-setup-instructions__text {
|
||||
color: var(--akismet-color-grey-80);
|
||||
font-size: 0.875rem;
|
||||
line-height: 1.5;
|
||||
margin: 0.25rem 0 0;
|
||||
padding: 0;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions__button,
|
||||
.akismet-setup-instructions__button:hover,
|
||||
.akismet-setup-instructions__button:visited {
|
||||
font-size: 1rem;
|
||||
margin-inline-start: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-setup__connection {
|
||||
background: var(--akismet-color-light-grey);
|
||||
border: 1px solid var(--akismet-color-grey-border);
|
||||
border-radius: 8px;
|
||||
margin: 1rem 1rem 2rem 1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-action:not(:last-child) {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-user {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-avatar {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-avatar-image {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-account-name {
|
||||
color: var(--akismet-color-charcoal);
|
||||
font-size: 0.9rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-account-email {
|
||||
margin-top: 0.1rem;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-action {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.akismet-setup__connection-button {
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
p.akismet-setup__connection-action-intro,
|
||||
p.akismet-setup__connection-action-description {
|
||||
color: var(--akismet-color-dark-grey);
|
||||
font-size: 0.875rem;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
p.akismet-setup__connection-action-intro {
|
||||
margin: 0 0 1rem 0;
|
||||
}
|
||||
|
||||
p.akismet-setup__connection-action-description {
|
||||
margin: 1rem 0 0;
|
||||
}
|
||||
|
||||
/* Setup - API key input */
|
||||
.akismet-enter-api-key-box {
|
||||
margin: 1.5rem 0;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__reveal {
|
||||
background: none;
|
||||
border: 0;
|
||||
color: var(--akismet-color-mid-green);
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__form-wrapper {
|
||||
display: none;
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__input-wrapper {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
padding: 0 1.5rem;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.akismet-enter-api-key-box__key-input {
|
||||
flex-grow: 1;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
h3.akismet-enter-api-key-box__header {
|
||||
padding-top: 0;
|
||||
padding-bottom: 1em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Notices > Activation (shown on edit-comments.php) */
|
||||
#akismet-setup-prompt {
|
||||
background: none;
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.akismet-activate {
|
||||
align-items: center;
|
||||
/* background-image is defined via an inline style in class.akismet-admin.php */
|
||||
background-color: var(--akismet-color-light-grey);
|
||||
background-position: calc(100% - (100% - 1em)) center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 140px;
|
||||
border: 1px solid var(--akismet-color-mid-green);
|
||||
border-right-width: 4px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin: 15px 0;
|
||||
min-height: 60px;
|
||||
overflow: hidden;
|
||||
padding: 5px 5px 5px 160px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.akismet-activate__button,
|
||||
.akismet-activate__button:hover,
|
||||
.akismet-activate__button:visited {
|
||||
margin: 0 1em;
|
||||
}
|
||||
|
||||
.akismet-activate__description {
|
||||
color: var(--akismet-color-charcoal);
|
||||
flex-grow: 1;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
text-wrap: pretty;
|
||||
}
|
||||
|
||||
/* Compatible plugins section */
|
||||
.akismet-compatible-plugins__content {
|
||||
padding: 0 1.5em 1.5em 1.5em;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__intro {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__section-header-label {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__section-header-label-text {
|
||||
padding-left: 0.5em;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__list {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
|
||||
gap: 20px;
|
||||
margin: 1.5em 0 1em 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__card {
|
||||
border: 1px solid var(--akismet-color-light-grey);
|
||||
border-radius: 4px;
|
||||
flex: 1 1 calc(50% - 5px);
|
||||
padding: 1em;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__card-logo {
|
||||
padding: 0 0 0 1.5em;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__card-title {
|
||||
font-size: 1.2em;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__docs {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__show-more {
|
||||
all: unset;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Generates the show/hide chevron */
|
||||
.akismet-compatible-plugins__show-more::after {
|
||||
align-self: center;
|
||||
border-bottom: 2px solid black;
|
||||
border-left: 2px solid black;
|
||||
content: "";
|
||||
height: 8px;
|
||||
transform: rotate(-45deg);
|
||||
transition: transform 0.2s ease;
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
.akismet-compatible-plugins__list.is-expanded + .akismet-compatible-plugins__show-more::after {
|
||||
align-self: end;
|
||||
transform: rotate(-225deg);
|
||||
}
|
||||
|
||||
/* Gutenberg medium breakpoint */
|
||||
@media screen and (max-width: 782px) {
|
||||
.akismet-new-snapshot__list {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__number {
|
||||
float: left;
|
||||
font-size: 20px;
|
||||
font-weight: 500;
|
||||
margin-top: -16px;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__header {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot__text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"],
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
}
|
||||
|
||||
.akismet-settings__row-label-text {
|
||||
padding-right: 0.8em;
|
||||
}
|
||||
|
||||
.akismet-settings__row input[type="checkbox"],
|
||||
.akismet-settings__row input[type="radio"] {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.akismet-activate {
|
||||
background-size: 120px;
|
||||
padding-left: 134px;
|
||||
}
|
||||
|
||||
.akismet-activate__button {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.akismet-activate__description {
|
||||
font-size: 14px;
|
||||
margin-left: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
/* Gutenberg small breakpoint */
|
||||
@media screen and (max-width: 600px) {
|
||||
.akismet-compatible-plugins__list {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.akismet-activate__button,
|
||||
.akismet-activate__button:hover {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.akismet-activate__description {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
464
wp-content/plugins/akismet/_inc/rtl/akismet-rtl.css
Normal file
@ -0,0 +1,464 @@
|
||||
/* This file was automatically generated on Oct 30 2025 21:26:42 */
|
||||
|
||||
.wp-admin.jetpack_page_akismet-key-config, .wp-admin.settings_page_akismet-key-config {
|
||||
background-color:#f3f6f8;
|
||||
}
|
||||
|
||||
#submitted-on {
|
||||
position: relative;
|
||||
}
|
||||
#the-comment-list .author .akismet-user-comment-count {
|
||||
display: inline;
|
||||
}
|
||||
#the-comment-list .author a span {
|
||||
text-decoration: none;
|
||||
color: #999;
|
||||
}
|
||||
#the-comment-list .author a span.akismet-span-link {
|
||||
text-decoration: inherit;
|
||||
color: inherit;
|
||||
}
|
||||
#the-comment-list .akismet_remove_url {
|
||||
margin-right: 3px;
|
||||
color: #999;
|
||||
padding: 2px 0 2px 3px;
|
||||
}
|
||||
#the-comment-list .akismet_remove_url:hover {
|
||||
color: #A7301F;
|
||||
font-weight: bold;
|
||||
padding: 2px 0 2px 2px;
|
||||
}
|
||||
#dashboard_recent_comments .akismet-status {
|
||||
display: none;
|
||||
}
|
||||
.akismet-status {
|
||||
float: left;
|
||||
}
|
||||
.akismet-status a {
|
||||
color: #AAA;
|
||||
font-style: italic;
|
||||
}
|
||||
table.comments td.comment p a {
|
||||
text-decoration: underline;
|
||||
}
|
||||
table.comments td.comment p a:after {
|
||||
content: attr(href);
|
||||
color: #aaa;
|
||||
display: inline-block; /* Show the URL without the link's underline extending under it. */
|
||||
padding: 0 1ex; /* Because it's inline block, we can't just use spaces in the content: attribute to separate it from the link text. */
|
||||
}
|
||||
.mshot-arrow {
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-top: 10px solid transparent;
|
||||
border-bottom: 10px solid transparent;
|
||||
border-left: 10px solid #5C5C5C;
|
||||
position: absolute;
|
||||
right: -6px;
|
||||
top: 91px;
|
||||
}
|
||||
.mshot-container {
|
||||
background: #5C5C5C;
|
||||
position: absolute;
|
||||
top: -94px;
|
||||
padding: 7px;
|
||||
width: 450px;
|
||||
height: 338px;
|
||||
z-index: 20000;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.akismet-mshot {
|
||||
position: absolute;
|
||||
z-index: 100;
|
||||
}
|
||||
.akismet-mshot .mshot-image {
|
||||
margin: 0;
|
||||
height: 338px;
|
||||
width: 450px;
|
||||
}
|
||||
.checkforspam {
|
||||
display: inline-block !important;
|
||||
}
|
||||
|
||||
.checkforspam-spinner {
|
||||
display: inline-block;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.akismet-right {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.akismet-card .akismet-right {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot {
|
||||
margin-top: 1em;
|
||||
text-align: center;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot h3 {
|
||||
background: #f5f5f5;
|
||||
color: #888;
|
||||
font-size: 11px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-new-snapshot ul li {
|
||||
color: #999;
|
||||
font-size: 11px;
|
||||
text-transform: uppercase;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
.akismet-settings th:first-child {
|
||||
vertical-align: top;
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
.akismet-settings th.akismet-api-key {
|
||||
vertical-align: middle;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.akismet-settings span.akismet-note {
|
||||
float: right;
|
||||
padding-right: 23px;
|
||||
font-size: 75%;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
.jetpack_page_akismet-key-config #wpcontent, .settings_page_akismet-key-config #wpcontent {
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.akismet-masthead {
|
||||
background-color:#fff;
|
||||
text-align:center;
|
||||
box-shadow:0 1px 0 rgba(200,215,225,0.5),0 1px 2px #e9eff3
|
||||
}
|
||||
|
||||
@media (max-width: 45rem) {
|
||||
.akismet-masthead {
|
||||
padding:0 1.25rem
|
||||
}
|
||||
}
|
||||
|
||||
.akismet-masthead__inside-container {
|
||||
padding:.375rem 0;
|
||||
margin:0 auto;
|
||||
width:100%;
|
||||
max-width:45rem;
|
||||
text-align: right;
|
||||
}
|
||||
.akismet-masthead__logo-container {
|
||||
padding:.3125rem 0 0
|
||||
}
|
||||
.akismet-masthead__logo-link {
|
||||
display:inline-block;
|
||||
outline:none;
|
||||
vertical-align:middle
|
||||
}
|
||||
.akismet-masthead__logo-link:focus {
|
||||
line-height:0;
|
||||
box-shadow:0 0 0 2px #78dcfa
|
||||
}
|
||||
.akismet-masthead__logo-link+code {
|
||||
margin:0 10px;
|
||||
padding:5px 9px;
|
||||
border-radius:2px;
|
||||
background:#e6ecf1;
|
||||
color:#647a88
|
||||
}
|
||||
.akismet-masthead__links {
|
||||
display:flex;
|
||||
flex-flow:row wrap;
|
||||
flex:2 50%;
|
||||
justify-content:flex-end;
|
||||
margin:0
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.akismet-masthead__links {
|
||||
padding-left:.625rem
|
||||
}
|
||||
}
|
||||
.akismet-masthead__link-li {
|
||||
margin:0;
|
||||
padding:0
|
||||
}
|
||||
.akismet-masthead__link {
|
||||
font-style:normal;
|
||||
color:#0087be;
|
||||
padding:.625rem;
|
||||
display:inline-block
|
||||
}
|
||||
.akismet-masthead__link:visited {
|
||||
color:#0087be
|
||||
}
|
||||
.akismet-masthead__link:active,.akismet-masthead__link:hover {
|
||||
color:#00aadc
|
||||
}
|
||||
.akismet-masthead__link:hover {
|
||||
text-decoration:underline
|
||||
}
|
||||
.akismet-masthead__link .dashicons {
|
||||
display:none
|
||||
}
|
||||
@media (max-width: 480px) {
|
||||
.akismet-masthead__link:hover,.akismet-masthead__link:active {
|
||||
text-decoration:none
|
||||
}
|
||||
.akismet-masthead__link .dashicons {
|
||||
display:block;
|
||||
font-size:1.75rem
|
||||
}
|
||||
.akismet-masthead__link span+span {
|
||||
display:none
|
||||
}
|
||||
}
|
||||
.akismet-masthead__link-li:last-of-type .akismet-masthead__link {
|
||||
padding-left:0
|
||||
}
|
||||
|
||||
.akismet-lower {
|
||||
margin: 0 auto;
|
||||
text-align: right;
|
||||
max-width: 45rem;
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-lower .notice {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.akismet-card {
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 0;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.akismet-card:after, .akismet-card .inside:after, .akismet-masthead__logo-container:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.akismet-card .inside {
|
||||
padding: 1.5rem;
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.akismet-card .akismet-card-actions {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.jetpack_page_akismet-key-config .update-nag, .settings_page_akismet-key-config .update-nag {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.akismet-masthead .akismet-right {
|
||||
line-height: 2.125rem;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.akismet-box {
|
||||
box-sizing: border-box;
|
||||
background: white;
|
||||
border: 1px solid rgba(200, 215, 225, 0.5);
|
||||
}
|
||||
|
||||
.akismet-box h2, .akismet-box h3 {
|
||||
padding: 1.5rem 1.5rem .5rem 1.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-box p {
|
||||
padding: 0 1.5rem 1.5rem 1.5rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-box p:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
height: 0;
|
||||
clear: both;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.akismet-box .akismet-right {
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-boxes .akismet-box {
|
||||
margin-bottom: 0;
|
||||
padding: 0;
|
||||
margin-top: -1px;
|
||||
}
|
||||
|
||||
.akismet-boxes .akismet-box:last-child {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-boxes .akismet-box:first-child {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-box .centered {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.akismet-button, .akismet-button:hover, .akismet-button:visited {
|
||||
background: white;
|
||||
border-color: #c8d7e1;
|
||||
border-style: solid;
|
||||
border-width: 1px 1px 2px;
|
||||
color: #2e4453;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
margin: 0;
|
||||
outline: 0;
|
||||
overflow: hidden;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-overflow: ellipsis;
|
||||
text-decoration: none;
|
||||
vertical-align: top;
|
||||
box-sizing: border-box;
|
||||
line-height: 21px;
|
||||
border-radius: 4px;
|
||||
padding: 7px 14px 9px;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
appearance: none;
|
||||
}
|
||||
|
||||
.akismet-button:hover {
|
||||
border-color: #a8bece;
|
||||
}
|
||||
|
||||
.akismet-button:active {
|
||||
border-width: 2px 1px 1px;
|
||||
}
|
||||
|
||||
.akismet-is-primary, .akismet-is-primary:hover, .akismet-is-primary:visited {
|
||||
background: #00aadc;
|
||||
border-color: #0087be;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.akismet-is-primary:hover, .akismet-is-primary:focus {
|
||||
border-color: #005082;
|
||||
}
|
||||
|
||||
.akismet-is-primary:hover {
|
||||
border-color: #005082;
|
||||
}
|
||||
|
||||
.akismet-section-header {
|
||||
position: relative;
|
||||
margin: 0 auto 0.625rem auto;
|
||||
padding: 1rem;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
background: #ffffff;
|
||||
width: 100%;
|
||||
padding-top: 0.6875rem;
|
||||
padding-bottom: 0.6875rem;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.akismet-section-header__label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
line-height: 1.75rem;
|
||||
position: relative;
|
||||
font-size: 0.875rem;
|
||||
color: #4f748e;
|
||||
}
|
||||
|
||||
.akismet-section-header__actions {
|
||||
line-height: 1.75rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions form {
|
||||
padding-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.akismet-setup-instructions > a.akismet-button {
|
||||
display: inline-block;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
div.error.akismet-usage-limit-alert {
|
||||
padding: 25px 15px 25px 45px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#akismet-plugin-container .akismet-usage-limit-alert {
|
||||
margin: 0 auto 0.625rem auto;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
border: none;
|
||||
border-right: 4px solid #d63638;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-logo {
|
||||
width: 38px;
|
||||
min-width: 38px;
|
||||
height: 38px;
|
||||
border-radius: 20px;
|
||||
margin-left: 18px;
|
||||
background: black;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-logo img {
|
||||
position: absolute;
|
||||
width: 22px;
|
||||
right: 8px;
|
||||
top: 10px;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-text {
|
||||
flex-grow: 1;
|
||||
margin-left: 18px;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert h3 {
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-cta {
|
||||
border-color: none;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#akismet-plugin-container .akismet-usage-limit-cta a {
|
||||
color: #d63638;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
@media (max-width: 550px) {
|
||||
div.error.akismet-usage-limit-alert {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-logo,
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-text {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.akismet-usage-limit-alert .akismet-usage-limit-cta {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
71
wp-content/plugins/akismet/akismet.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Akismet
|
||||
*/
|
||||
/*
|
||||
Plugin Name: Akismet Anti-spam: Spam Protection
|
||||
Plugin URI: https://akismet.com/
|
||||
Description: Used by millions, Akismet is quite possibly the best way in the world to <strong>protect your blog from spam</strong>. Akismet Anti-spam keeps your site protected even while you sleep. To get started: activate the Akismet plugin and then go to your Akismet Settings page to set up your API key.
|
||||
Version: 5.6
|
||||
Requires at least: 5.8
|
||||
Requires PHP: 7.2
|
||||
Author: Automattic - Anti-spam Team
|
||||
Author URI: https://automattic.com/wordpress-plugins/
|
||||
License: GPLv2 or later
|
||||
Text Domain: akismet
|
||||
*/
|
||||
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Copyright 2005-2025 Automattic, Inc.
|
||||
*/
|
||||
|
||||
// Make sure we don't expose any info if called directly
|
||||
if ( ! function_exists( 'add_action' ) ) {
|
||||
echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'AKISMET_VERSION', '5.6' );
|
||||
define( 'AKISMET__MINIMUM_WP_VERSION', '5.8' );
|
||||
define( 'AKISMET__PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
||||
define( 'AKISMET_DELETE_LIMIT', 10000 );
|
||||
|
||||
register_activation_hook( __FILE__, array( 'Akismet', 'plugin_activation' ) );
|
||||
register_deactivation_hook( __FILE__, array( 'Akismet', 'plugin_deactivation' ) );
|
||||
|
||||
require_once AKISMET__PLUGIN_DIR . 'class.akismet.php';
|
||||
require_once AKISMET__PLUGIN_DIR . 'class.akismet-widget.php';
|
||||
require_once AKISMET__PLUGIN_DIR . 'class.akismet-rest-api.php';
|
||||
require_once AKISMET__PLUGIN_DIR . 'class-akismet-compatible-plugins.php';
|
||||
|
||||
add_action( 'init', array( 'Akismet', 'init' ) );
|
||||
|
||||
add_action( 'rest_api_init', array( 'Akismet_REST_API', 'init' ) );
|
||||
|
||||
add_action( 'init', array( 'Akismet_Compatible_Plugins', 'init' ) );
|
||||
|
||||
if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
|
||||
require_once AKISMET__PLUGIN_DIR . 'class.akismet-admin.php';
|
||||
add_action( 'init', array( 'Akismet_Admin', 'init' ) );
|
||||
}
|
||||
|
||||
// add wrapper class around deprecated akismet functions that are referenced elsewhere
|
||||
require_once AKISMET__PLUGIN_DIR . 'wrapper.php';
|
||||
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
||||
require_once AKISMET__PLUGIN_DIR . 'class.akismet-cli.php';
|
||||
}
|
||||
550
wp-content/plugins/akismet/changelog.txt
Normal file
@ -0,0 +1,550 @@
|
||||
=== Akismet Anti-spam ===
|
||||
|
||||
== Archived Changelog Entries ==
|
||||
|
||||
This file contains older changelog entries, so we can keep the size of the standard WordPress readme.txt file reasonable.
|
||||
For the latest changes, please see the "Changelog" section of the [readme.txt file](https://plugins.svn.wordpress.org/akismet/trunk/readme.txt).
|
||||
|
||||
= 4.2.5 =
|
||||
*Release Date - 11 July 2022*
|
||||
|
||||
* Fixed a bug that added unnecessary comment history entries after comment rechecks.
|
||||
* Added a notice that displays when WP-Cron is disabled and might be affecting comment rechecks.
|
||||
|
||||
= 4.2.4 =
|
||||
*Release Date - 20 May 2022*
|
||||
|
||||
* Improved translator instructions for comment history.
|
||||
* Bumped the "Tested up to" tag to WP 6.0.
|
||||
|
||||
= 4.2.3 =
|
||||
*Release Date - 25 April 2022*
|
||||
|
||||
* Improved compatibility with Fluent Forms
|
||||
* Fixed missing translation domains
|
||||
* Updated stats URL.
|
||||
* Improved accessibility of elements on the config page.
|
||||
|
||||
= 4.2.2 =
|
||||
*Release Date - 24 January 2022*
|
||||
|
||||
* Improved compatibility with Formidable Forms
|
||||
* Fixed a bug that could cause issues when multiple contact forms appear on one page.
|
||||
* Updated delete_comment and deleted_comment actions to pass two arguments to match WordPress core since 4.9.0.
|
||||
* Added a filter that allows comment types to be excluded when counting users' approved comments.
|
||||
|
||||
= 4.2.1 =
|
||||
*Release Date - 1 October 2021*
|
||||
|
||||
* Fixed a bug causing AMP validation to fail on certain pages with forms.
|
||||
|
||||
= 4.2 =
|
||||
*Release Date - 30 September 2021*
|
||||
|
||||
* Added links to additional information on API usage notifications.
|
||||
* Reduced the number of network requests required for a comment page when running Akismet.
|
||||
* Improved compatibility with the most popular contact form plugins.
|
||||
* Improved API usage buttons for clarity on what upgrade is needed.
|
||||
|
||||
= 4.1.12 =
|
||||
*Release Date - 3 September 2021*
|
||||
|
||||
* Fixed "Use of undefined constant" notice.
|
||||
* Improved styling of alert notices.
|
||||
|
||||
= 4.1.11 =
|
||||
*Release Date - 23 August 2021*
|
||||
|
||||
* Added support for Akismet API usage notifications on Akismet settings and edit-comments admin pages.
|
||||
* Added support for the deleted_comment action when bulk-deleting comments from Spam.
|
||||
|
||||
= 4.1.10 =
|
||||
*Release Date - 6 July 2021*
|
||||
|
||||
* Simplified the code around checking comments in REST API and XML-RPC requests.
|
||||
* Updated Plus plan terminology in notices to match current subscription names.
|
||||
* Added `rel="noopener"` to the widget link to avoid warnings in Google Lighthouse.
|
||||
* Set the Akismet JavaScript as deferred instead of async to improve responsiveness.
|
||||
* Improved the preloading of screenshot popups on the edit comments admin page.
|
||||
|
||||
= 4.1.9 =
|
||||
*Release Date - 2 March 2021*
|
||||
|
||||
* Improved handling of pingbacks in XML-RPC multicalls
|
||||
|
||||
= 4.1.8 =
|
||||
*Release Date - 6 January 2021*
|
||||
|
||||
* Fixed missing fields in submit-spam and submit-ham calls that could lead to reduced accuracy.
|
||||
* Fixed usage of deprecated jQuery function.
|
||||
|
||||
= 4.1.7 =
|
||||
*Release Date - 22 October 2020*
|
||||
|
||||
* Show the "Set up your Akismet account" banner on the comments admin screen, where it's relevant to mention if Akismet hasn't been configured.
|
||||
* Don't use wp_blacklist_check when the new wp_check_comment_disallowed_list function is available.
|
||||
|
||||
= 4.1.6 =
|
||||
*Release Date - 4 June 2020*
|
||||
|
||||
* Disable "Check for Spam" button until the page is loaded to avoid errors with clicking through to queue recheck endpoint directly.
|
||||
* Added filter "akismet_enable_mshots" to allow disabling screenshot popups on the edit comments admin page.
|
||||
|
||||
= 4.1.5 =
|
||||
*Release Date - 29 April 2020*
|
||||
|
||||
* Based on user feedback, we have dropped the in-admin notice explaining the availability of the "privacy notice" option in the AKismet settings screen. The option itself is available, but after displaying the notice for the last 2 years, it is now considered a known fact.
|
||||
* Updated the "Requires at least" to WP 4.6, based on recommendations from https://wp-info.org/tools/checkplugini18n.php?slug=akismet
|
||||
* Moved older changelog entries to a separate file to keep the size of this readme reasonable, also based on recommendations from https://wp-info.org/tools/checkplugini18n.php?slug=akismet
|
||||
|
||||
= 4.1.4 =
|
||||
*Release Date - 17 March 2020*
|
||||
|
||||
* Only redirect to the Akismet setup screen upon plugin activation if the plugin was activated manually from within the plugin-related screens, to help users with non-standard install workflows, like WP-CLI.
|
||||
* Update the layout of the initial setup screen to be more readable on small screens.
|
||||
* If no API key has been entered, don't run code that expects an API key.
|
||||
* Improve the readability of the comment history entries.
|
||||
* Don't modify the comment form HTML if no API key has been set.
|
||||
|
||||
= 4.1.3 =
|
||||
*Release Date - 31 October 2019*
|
||||
|
||||
* Prevented an attacker from being able to cause a user to unknowingly recheck their Pending comments for spam.
|
||||
* Improved compatibility with Jetpack 7.7+.
|
||||
* Updated the plugin activation page to use consistent language and markup.
|
||||
* Redirecting users to the Akismet connnection/settings screen upon plugin activation, in an effort to make it easier for people to get setup.
|
||||
|
||||
= 4.1.2 =
|
||||
*Release Date - 14 May 2019*
|
||||
|
||||
* Fixed a conflict between the Akismet setup banner and other plugin notices.
|
||||
* Reduced the number of API requests made by the plugin when attempting to verify the API key.
|
||||
* Include additional data in the pingback pre-check API request to help make the stats more accurate.
|
||||
* Fixed a bug that was enabling the "Check for Spam" button when no comments were eligible to be checked.
|
||||
* Improved Akismet's AMP compatibility.
|
||||
|
||||
= 4.1.1 =
|
||||
*Release Date - 31 January 2019*
|
||||
|
||||
* Fixed the "Setup Akismet" notice so it resizes responsively.
|
||||
* Only highlight the "Save Changes" button in the Akismet config when changes have been made.
|
||||
* The count of comments in your spam queue shown on the dashboard show now always be up-to-date.
|
||||
|
||||
= 4.1 =
|
||||
*Release Date - 12 November 2018*
|
||||
|
||||
* Added a WP-CLI method for retrieving stats.
|
||||
* Hooked into the new "Personal Data Eraser" functionality from WordPress 4.9.6.
|
||||
* Added functionality to clear outdated alerts from Akismet.com.
|
||||
|
||||
= 4.0.8 =
|
||||
*Release Date - 19 June 2018*
|
||||
|
||||
* Improved the grammar and consistency of the in-admin privacy related notes (notice and config).
|
||||
* Revised in-admin explanation of the comment form privacy notice to make its usage clearer.
|
||||
* Added `rel="nofollow noopener"` to the comment form privacy notice to improve SEO and security.
|
||||
|
||||
= 4.0.7 =
|
||||
*Release Date - 28 May 2018*
|
||||
|
||||
* Based on user feedback, the link on "Learn how your comment data is processed." in the optional privacy notice now has a `target` of `_blank` and opens in a new tab/window.
|
||||
* Updated the in-admin privacy notice to use the term "comment" instead of "contact" in "Akismet can display a notice to your users under your comment forms."
|
||||
* Only show in-admin privacy notice if Akismet has an API Key configured
|
||||
|
||||
= 4.0.6 =
|
||||
*Release Date - 26 May 2018*
|
||||
|
||||
* Moved away from using `empty( get_option() )` to instantiating a variable to be compatible with older versions of PHP (5.3, 5.4, etc).
|
||||
|
||||
= 4.0.5 =
|
||||
*Release Date - 26 May 2018*
|
||||
|
||||
* Corrected version number after tagging. Sorry...
|
||||
|
||||
= 4.0.4 =
|
||||
*Release Date - 26 May 2018*
|
||||
|
||||
* Added a hook to provide Akismet-specific privacy information for a site's privacy policy.
|
||||
* Added tools to control the display of a privacy related notice under comment forms.
|
||||
* Fixed HTML in activation failure message to close META and HEAD tag properly.
|
||||
* Fixed a bug that would sometimes prevent Akismet from being correctly auto-configured.
|
||||
|
||||
= 4.0.3 =
|
||||
*Release Date - 19 February 2018*
|
||||
|
||||
* Added a scheduled task to remove entries in wp_commentmeta that no longer have corresponding comments in wp_comments.
|
||||
* Added a new `akismet_batch_delete_count` action to the batch delete methods for people who'd like to keep track of the numbers of records being processed by those methods.
|
||||
|
||||
= 4.0.2 =
|
||||
*Release Date - 18 December 2017*
|
||||
|
||||
* Fixed a bug that could cause Akismet to recheck a comment that has already been manually approved or marked as spam.
|
||||
* Fixed a bug that could cause Akismet to claim that some comments are still waiting to be checked when no comments are waiting to be checked.
|
||||
|
||||
= 4.0.1 =
|
||||
*Release Date - 6 November 2017*
|
||||
|
||||
* Fixed a bug that could prevent some users from connecting Akismet via their Jetpack connection.
|
||||
* Ensured that any pending Akismet-related events are unscheduled if the plugin is deactivated.
|
||||
* Allow some JavaScript to be run asynchronously to avoid affecting page render speeds.
|
||||
|
||||
= 4.0 =
|
||||
*Release Date - 19 September 2017*
|
||||
|
||||
* Added REST API endpoints for configuring Akismet and retrieving stats.
|
||||
* Increased the minimum supported WordPress version to 4.0.
|
||||
* Added compatibility with comments submitted via the REST API.
|
||||
* Improved the progress indicator on the "Check for Spam" button.
|
||||
|
||||
= 3.3.4 =
|
||||
*Release Date - 3 August 2017*
|
||||
|
||||
* Disabled Akismet's debug log output by default unless AKISMET_DEBUG is defined.
|
||||
* URL previews now begin preloading when the mouse moves near them in the comments section of wp-admin.
|
||||
* When a comment is caught by the Comment Blacklist, Akismet will always allow it to stay in the trash even if it is spam as well.
|
||||
* Fixed a bug that was preventing an error from being shown when a site can't reach Akismet's servers.
|
||||
|
||||
= 3.3.3 =
|
||||
*Release Date - 13 July 2017*
|
||||
|
||||
* Reduced amount of bandwidth used by the URL Preview feature.
|
||||
* Improved the admin UI when the API key is manually pre-defined for the site.
|
||||
* Removed a workaround for WordPress installations older than 3.3 that will improve Akismet's compatibility with other plugins.
|
||||
* The number of spam blocked that is displayed on the WordPress dashboard will now be more accurate and updated more frequently.
|
||||
* Fixed a bug in the Akismet widget that could cause PHP warnings.
|
||||
|
||||
= 3.3.2 =
|
||||
*Release Date - 10 May 2017*
|
||||
|
||||
* Fixed a bug causing JavaScript errors in some browsers.
|
||||
|
||||
= 3.3.1 =
|
||||
*Release Date - 2 May 2017*
|
||||
|
||||
* Improve performance by only requesting the akismet_comment_nonce option when absolutely necessary.
|
||||
* Fixed two bugs that could cause PHP warnings.
|
||||
* Fixed a bug that was preventing the "Remove author URL" feature from working after a comment was edited using "Quick Edit."
|
||||
* Fixed a bug that was preventing the URL preview feature from working after a comment was edited using "Quick Edit."
|
||||
|
||||
= 3.3 =
|
||||
*Release Date - 23 February 2017*
|
||||
|
||||
* Updated the Akismet admin pages with a new clean design.
|
||||
* Fixed bugs preventing the `akismet_add_comment_nonce` and `akismet_update_alert` wrapper functions from working properly.
|
||||
* Fixed bug preventing the loading indicator from appearing when re-checking all comments for spam.
|
||||
* Added a progress indicator to the "Check for Spam" button.
|
||||
* Added a success message after manually rechecking the Pending queue for spam.
|
||||
|
||||
= 3.2 =
|
||||
*Release Date - 6 September 2016*
|
||||
|
||||
* Added a WP-CLI module. You can now check comments and recheck the moderation queue from the command line.
|
||||
* Stopped using the deprecated jQuery function `.live()`.
|
||||
* Fixed a bug in `remove_comment_author_url()` and `add_comment_author_url()` that could generate PHP notices.
|
||||
* Fixed a bug that could cause an infinite loop for sites with very very very large comment IDs.
|
||||
* Fixed a bug that could cause the Akismet widget title to be blank.
|
||||
|
||||
= 3.1.11 =
|
||||
*Release Date - 12 May 2016*
|
||||
|
||||
* Fixed a bug that could cause the "Check for Spam" button to skip some comments.
|
||||
* Fixed a bug that could prevent some spam submissions from being sent to Akismet.
|
||||
* Updated all links to use https:// when possible.
|
||||
* Disabled Akismet debug logging unless WP_DEBUG and WP_DEBUG_LOG are both enabled.
|
||||
|
||||
= 3.1.10 =
|
||||
*Release Date - 1 April 2016*
|
||||
|
||||
* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
|
||||
* Fixed a bug that could have resulted in comments that were caught by the core WordPress comment blacklist not to have a corresponding History entry.
|
||||
* Fixed a bug that could have caused avoidable PHP warnings in the error log.
|
||||
|
||||
= 3.1.9 =
|
||||
*Release Date - 28 March 2016*
|
||||
|
||||
* Add compatibility with Jetpack so that Jetpack can automatically configure Akismet settings when appropriate.
|
||||
* Fixed a bug preventing some comment data from being sent to Akismet.
|
||||
|
||||
= 3.1.8 =
|
||||
*Release Date - 4 March 2016*
|
||||
|
||||
* Fixed a bug preventing Akismet from being used with some plugins that rewrite admin URLs.
|
||||
* Reduced the amount of bandwidth used on Akismet API calls
|
||||
* Reduced the amount of space Akismet uses in the database
|
||||
* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
|
||||
|
||||
= 3.1.7 =
|
||||
*Release Date - 4 January 2016*
|
||||
|
||||
* Added documentation for the 'akismet_comment_nonce' filter.
|
||||
* The post-install activation button is now accessible to screen readers and keyboard-only users.
|
||||
* Fixed a bug that was preventing the "Remove author URL" feature from working in WordPress 4.4
|
||||
|
||||
= 3.1.6 =
|
||||
*Release Date - 14 December 2015*
|
||||
|
||||
* Improve the notices shown after activating Akismet.
|
||||
* Update some strings to allow for the proper plural forms in all languages.
|
||||
|
||||
= 3.1.5 =
|
||||
*Release Date - 13 October 2015*
|
||||
|
||||
* Closes a potential XSS vulnerability.
|
||||
|
||||
= 3.1.4 =
|
||||
*Release Date - 24 September 2015*
|
||||
|
||||
* Fixed a bug that was preventing some users from automatically connecting using Jetpack if they didn't have a current Akismet subscription.
|
||||
* Fixed a bug that could cause comments caught as spam to be placed in the Pending queue.
|
||||
* Error messages and instructions have been simplified to be more understandable.
|
||||
* Link previews are enabled for all links inside comments, not just the author's website link.
|
||||
|
||||
= 3.1.3 =
|
||||
*Release Date - 6 July 2015*
|
||||
|
||||
* Notify users when their account status changes after previously being successfully set up. This should help any users who are seeing blank Akismet settings screens.
|
||||
|
||||
= 3.1.2 =
|
||||
*Release Date - 7 June 2015*
|
||||
|
||||
* Reduced the amount of space Akismet uses in the commentmeta table.
|
||||
* Fixed a bug where some comments with quotes in the author name weren't getting history entries
|
||||
* Pre-emptive security improvements to ensure that the Akismet plugin can't be used by attackers to compromise a WordPress installation.
|
||||
* Better UI for the key entry field: allow whitespace to be included at the beginning or end of the key and strip it out automatically when the form is submitted.
|
||||
* When deactivating the plugin, notify the Akismet API so the site can be marked as inactive.
|
||||
* Clearer error messages.
|
||||
|
||||
= 3.1.1 =
|
||||
*Release Date - 17th March, 2015*
|
||||
|
||||
* Improvements to the "Remove comment author URL" JavaScript
|
||||
* Include the pingback pre-check from the 2.6 branch.
|
||||
|
||||
= 3.1 =
|
||||
*Release Date - 11th March, 2015*
|
||||
|
||||
* Use HTTPS by default for all requests to Akismet.
|
||||
* Fix for a situation where Akismet might strip HTML from a comment.
|
||||
|
||||
= 3.0.4 =
|
||||
*Release Date - 11th December, 2014*
|
||||
|
||||
* Fix to make .htaccess compatible with Apache 2.4.
|
||||
* Fix to allow removal of https author URLs.
|
||||
* Fix to avoid stripping part of the author URL when removing and re-adding.
|
||||
* Removed the "Check for Spam" button from the "Trash" and "Approved" queues, where it would have no effect.
|
||||
* Allow automatic API key configuration when Jetpack is installed and connected to a WordPress.com account
|
||||
|
||||
= 3.0.3 =
|
||||
*Release Date - 3rd November, 2014*
|
||||
|
||||
* Fix for sending the wrong data to delete_comment action that could have prevented old spam comments from being deleted.
|
||||
* Added a filter to disable logging of Akismet debugging information.
|
||||
* Added a filter for the maximum comment age when deleting old spam comments.
|
||||
* Added a filter for the number per batch when deleting old spam comments.
|
||||
* Removed the "Check for Spam" button from the Spam folder.
|
||||
|
||||
= 3.0.2 =
|
||||
*Release Date - 18th August, 2014*
|
||||
|
||||
* Performance improvements.
|
||||
* Fixed a bug that could truncate the comment data being sent to Akismet for checking.
|
||||
|
||||
= 3.0.1 =
|
||||
*Release Date - 9th July, 2014*
|
||||
|
||||
* Removed dependency on PHP's fsockopen function
|
||||
* Fix spam/ham reports to work when reported outside of the WP dashboard, e.g., from Notifications or the WP app
|
||||
* Remove jQuery dependency for comment form JavaScript
|
||||
* Remove unnecessary data from some Akismet comment meta
|
||||
* Suspended keys will now result in all comments being put in moderation, not spam.
|
||||
|
||||
= 3.0.0 =
|
||||
*Release Date - 15th April, 2014*
|
||||
|
||||
* Move Akismet to Settings menu
|
||||
* Drop Akismet Stats menu
|
||||
* Add stats snapshot to Akismet settings
|
||||
* Add Akismet subscription details and status to Akismet settings
|
||||
* Add contextual help for each page
|
||||
* Improve Akismet setup to use Jetpack to automate plugin setup
|
||||
* Fix "Check for Spam" to use AJAX to avoid page timing out
|
||||
* Fix Akismet settings page to be responsive
|
||||
* Drop legacy code
|
||||
* Tidy up CSS and Javascript
|
||||
* Replace the old discard setting with a new "discard pervasive spam" feature.
|
||||
|
||||
= 2.6.0 =
|
||||
*Release Date - 18th March, 2014*
|
||||
|
||||
* Add ajax paging to the check for spam button to handle large volumes of comments
|
||||
* Optimize javascript and add localization support
|
||||
* Fix bug in link to spam comments from right now dashboard widget
|
||||
* Fix bug with deleting old comments to avoid timeouts dealing with large volumes of comments
|
||||
* Include X-Pingback-Forwarded-For header in outbound WordPress pingback verifications
|
||||
* Add pre-check for pingbacks, to stop spam before an outbound verification request is made
|
||||
|
||||
= 2.5.9 =
|
||||
*Release Date - 1st August, 2013*
|
||||
|
||||
* Update 'Already have a key' link to redirect page rather than depend on javascript
|
||||
* Fix some non-translatable strings to be translatable
|
||||
* Update Activation banner in plugins page to redirect user to Akismet config page
|
||||
|
||||
= 2.5.8 =
|
||||
*Release Date - 20th January, 2013*
|
||||
|
||||
* Simplify the activation process for new users
|
||||
* Remove the reporter_ip parameter
|
||||
* Minor preventative security improvements
|
||||
|
||||
= 2.5.7 =
|
||||
*Release Date - 13th December, 2012*
|
||||
|
||||
* FireFox Stats iframe preview bug
|
||||
* Fix mshots preview when using https
|
||||
* Add .htaccess to block direct access to files
|
||||
* Prevent some PHP notices
|
||||
* Fix Check For Spam return location when referrer is empty
|
||||
* Fix Settings links for network admins
|
||||
* Fix prepare() warnings in WP 3.5
|
||||
|
||||
= 2.5.6 =
|
||||
*Release Date - 26th April, 2012*
|
||||
|
||||
* Prevent retry scheduling problems on sites where wp_cron is misbehaving
|
||||
* Preload mshot previews
|
||||
* Modernize the widget code
|
||||
* Fix a bug where comments were not held for moderation during an error condition
|
||||
* Improve the UX and display when comments are temporarily held due to an error
|
||||
* Make the Check For Spam button force a retry when comments are held due to an error
|
||||
* Handle errors caused by an invalid key
|
||||
* Don't retry comments that are too old
|
||||
* Improve error messages when verifying an API key
|
||||
|
||||
= 2.5.5 =
|
||||
*Release Date - 11th January, 2012*
|
||||
|
||||
* Add nonce check for comment author URL remove action
|
||||
* Fix the settings link
|
||||
|
||||
= 2.5.4 =
|
||||
*Release Date - 5th January, 2012*
|
||||
|
||||
* Limit Akismet CSS and Javascript loading in wp-admin to just the pages that need it
|
||||
* Added author URL quick removal functionality
|
||||
* Added mShot preview on Author URL hover
|
||||
* Added empty index.php to prevent directory listing
|
||||
* Move wp-admin menu items under Jetpack, if it is installed
|
||||
* Purge old Akismet comment meta data, default of 15 days
|
||||
|
||||
= 2.5.3 =
|
||||
*Release Date - 8th Febuary, 2011*
|
||||
|
||||
* Specify the license is GPL v2 or later
|
||||
* Fix a bug that could result in orphaned commentmeta entries
|
||||
* Include hotfix for WordPress 3.0.5 filter issue
|
||||
|
||||
= 2.5.2 =
|
||||
*Release Date - 14th January, 2011*
|
||||
|
||||
* Properly format the comment count for author counts
|
||||
* Look for super admins on multisite installs when looking up user roles
|
||||
* Increase the HTTP request timeout
|
||||
* Removed padding for author approved count
|
||||
* Fix typo in function name
|
||||
* Set Akismet stats iframe height to fixed 2500px. Better to have one tall scroll bar than two side by side.
|
||||
|
||||
= 2.5.1 =
|
||||
*Release Date - 17th December, 2010*
|
||||
|
||||
* Fix a bug that caused the "Auto delete" option to fail to discard comments correctly
|
||||
* Remove the comment nonce form field from the 'Akismet Configuration' page in favor of using a filter, akismet_comment_nonce
|
||||
* Fixed padding bug in "author" column of posts screen
|
||||
* Added margin-top to "cleared by ..." badges on dashboard
|
||||
* Fix possible error when calling akismet_cron_recheck()
|
||||
* Fix more PHP warnings
|
||||
* Clean up XHTML warnings for comment nonce
|
||||
* Fix for possible condition where scheduled comment re-checks could get stuck
|
||||
* Clean up the comment meta details after deleting a comment
|
||||
* Only show the status badge if the comment status has been changed by someone/something other than Akismet
|
||||
* Show a 'History' link in the row-actions
|
||||
* Translation fixes
|
||||
* Reduced font-size on author name
|
||||
* Moved "flagged by..." notification to top right corner of comment container and removed heavy styling
|
||||
* Hid "flagged by..." notification while on dashboard
|
||||
|
||||
= 2.5.0 =
|
||||
*Release Date - 7th December, 2010*
|
||||
|
||||
* Track comment actions under 'Akismet Status' on the edit comment screen
|
||||
* Fix a few remaining deprecated function calls ( props Mike Glendinning )
|
||||
* Use HTTPS for the stats IFRAME when wp-admin is using HTTPS
|
||||
* Use the WordPress HTTP class if available
|
||||
* Move the admin UI code to a separate file, only loaded when needed
|
||||
* Add cron retry feature, to replace the old connectivity check
|
||||
* Display Akismet status badge beside each comment
|
||||
* Record history for each comment, and display it on the edit page
|
||||
* Record the complete comment as originally submitted in comment_meta, to use when reporting spam and ham
|
||||
* Highlight links in comment content
|
||||
* New option, "Show the number of comments you've approved beside each comment author."
|
||||
* New option, "Use a nonce on the comment form."
|
||||
|
||||
= 2.4.0 =
|
||||
*Release Date - 23rd August, 2010*
|
||||
|
||||
* Spell out that the license is GPLv2
|
||||
* Fix PHP warnings
|
||||
* Fix WordPress deprecated function calls
|
||||
* Fire the delete_comment action when deleting comments
|
||||
* Move code specific for older WP versions to legacy.php
|
||||
* General code clean up
|
||||
|
||||
= 2.3.0 =
|
||||
*Release Date - 5th June, 2010*
|
||||
|
||||
* Fix "Are you sure" nonce message on config screen in WPMU
|
||||
* Fix XHTML compliance issue in sidebar widget
|
||||
* Change author link; remove some old references to WordPress.com accounts
|
||||
* Localize the widget title (core ticket #13879)
|
||||
|
||||
= 2.2.9 =
|
||||
*Release Date - 2nd June, 2010*
|
||||
|
||||
* Eliminate a potential conflict with some plugins that may cause spurious reports
|
||||
|
||||
= 2.2.8 =
|
||||
*Release Date - 27th May, 2010*
|
||||
|
||||
* Fix bug in initial comment check for ipv6 addresses
|
||||
* Report comments as ham when they are moved from spam to moderation
|
||||
* Report comments as ham when clicking undo after spam
|
||||
* Use transition_comment_status action when available instead of older actions for spam/ham submissions
|
||||
* Better diagnostic messages when PHP network functions are unavailable
|
||||
* Better handling of comments by logged-in users
|
||||
|
||||
= 2.2.7 =
|
||||
*Release Date - 17th December, 2009*
|
||||
|
||||
* Add a new AKISMET_VERSION constant
|
||||
* Reduce the possibility of over-counting spam when another spam filter plugin is in use
|
||||
* Disable the connectivity check when the API key is hard-coded for WPMU
|
||||
|
||||
= 2.2.6 =
|
||||
*Release Date - 20th July, 2009*
|
||||
|
||||
* Fix a global warning introduced in 2.2.5
|
||||
* Add changelog and additional readme.txt tags
|
||||
* Fix an array conversion warning in some versions of PHP
|
||||
* Support a new WPCOM_API_KEY constant for easier use with WordPress MU
|
||||
|
||||
= 2.2.5 =
|
||||
*Release Date - 13th July, 2009*
|
||||
|
||||
* Include a new Server Connectivity diagnostic check, to detect problems caused by firewalls
|
||||
|
||||
= 2.2.4 =
|
||||
*Release Date - 3rd June, 2009*
|
||||
|
||||
* Fixed a key problem affecting the stats feature in WordPress MU
|
||||
* Provide additional blog information in Akismet API calls
|
||||
309
wp-content/plugins/akismet/class-akismet-compatible-plugins.php
Normal file
@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/**
|
||||
* Handles compatibility checks for Akismet with other plugins.
|
||||
*
|
||||
* @package Akismet
|
||||
* @since 5.4.0
|
||||
*/
|
||||
|
||||
declare( strict_types = 1 );
|
||||
|
||||
// Following existing Akismet convention for file naming.
|
||||
// phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase
|
||||
|
||||
/**
|
||||
* Class for managing compatibility checks for Akismet with other plugins.
|
||||
*
|
||||
* This class includes methods for determining whether specific plugins are
|
||||
* installed and active relative to the ability to work with Akismet.
|
||||
*/
|
||||
class Akismet_Compatible_Plugins {
|
||||
/**
|
||||
* The endpoint for the compatible plugins API.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected const COMPATIBLE_PLUGIN_ENDPOINT = 'https://rest.akismet.com/1.2/compatible-plugins';
|
||||
|
||||
/**
|
||||
* The error key for the compatible plugins API error.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected const COMPATIBLE_PLUGIN_API_ERROR = 'akismet_compatible_plugins_api_error';
|
||||
|
||||
/**
|
||||
* The valid fields for a compatible plugin object.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected const COMPATIBLE_PLUGIN_FIELDS = array(
|
||||
'slug',
|
||||
'name',
|
||||
'logo',
|
||||
'help_url',
|
||||
'path',
|
||||
);
|
||||
|
||||
/**
|
||||
* The cache key for the compatible plugins.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected const CACHE_KEY = 'akismet_compatible_plugin_list';
|
||||
|
||||
|
||||
/**
|
||||
* How many plugins should be visible by default?
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public const DEFAULT_VISIBLE_PLUGIN_COUNT = 2;
|
||||
|
||||
/**
|
||||
* Get the list of active, installed compatible plugins.
|
||||
*
|
||||
* @param bool $bypass_cache Whether to bypass the cache and fetch fresh data.
|
||||
* @return WP_Error|array {
|
||||
* Array of active, installed compatible plugins with their metadata.
|
||||
* @type string $name The display name of the plugin
|
||||
* @type string $help_url URL to the plugin's help documentation
|
||||
* @type string $logo URL or path to the plugin's logo
|
||||
* }
|
||||
*/
|
||||
public static function get_installed_compatible_plugins( bool $bypass_cache = false ) {
|
||||
// Retrieve and validate the full compatible plugins list.
|
||||
$compatible_plugins = static::get_compatible_plugins( $bypass_cache );
|
||||
|
||||
if ( empty( $compatible_plugins ) ) {
|
||||
return new WP_Error(
|
||||
self::COMPATIBLE_PLUGIN_API_ERROR,
|
||||
__( 'Error getting compatible plugins.', 'akismet' )
|
||||
);
|
||||
}
|
||||
|
||||
// Retrieve all installed plugins once.
|
||||
$all_plugins = get_plugins();
|
||||
|
||||
// Build list of compatible plugins that are both installed and active.
|
||||
$active_compatible_plugins = array();
|
||||
|
||||
foreach ( $compatible_plugins as $slug => $data ) {
|
||||
$path = $data['path'];
|
||||
// Skip if not installed.
|
||||
if ( ! isset( $all_plugins[ $path ] ) ) {
|
||||
continue;
|
||||
}
|
||||
// Check activation: per-site or network-wide (multisite).
|
||||
$site_active = is_plugin_active( $path );
|
||||
$network_active = is_multisite() && is_plugin_active_for_network( $path );
|
||||
if ( $site_active || $network_active ) {
|
||||
$active_compatible_plugins[ $slug ] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
return $active_compatible_plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes action hooks for the class.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function init(): void {
|
||||
add_action( 'activated_plugin', array( static::class, 'handle_plugin_change' ), true );
|
||||
add_action( 'deactivated_plugin', array( static::class, 'handle_plugin_change' ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles plugin activation and deactivation events.
|
||||
*
|
||||
* @param string $plugin The path to the main plugin file from plugins directory.
|
||||
* @return void
|
||||
*/
|
||||
public static function handle_plugin_change( string $plugin ): void {
|
||||
$cached_plugins = static::get_cached_plugins();
|
||||
|
||||
/**
|
||||
* Terminate if nothing's cached.
|
||||
*/
|
||||
if ( false === $cached_plugins ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$plugin_change_should_invalidate_cache = in_array( $plugin, array_column( $cached_plugins, 'path' ) );
|
||||
|
||||
/**
|
||||
* Purge the cache if the plugin is activated or deactivated.
|
||||
*/
|
||||
if ( $plugin_change_should_invalidate_cache ) {
|
||||
static::purge_cache();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets plugins that are compatible with Akismet from the Akismet API.
|
||||
*
|
||||
* @param bool $bypass_cache Whether to bypass the cache and fetch fresh data.
|
||||
* @return array
|
||||
*/
|
||||
private static function get_compatible_plugins( bool $bypass_cache = false ): array {
|
||||
// Return cached result if present (false => cache miss; empty array is valid).
|
||||
$cached_plugins = static::get_cached_plugins();
|
||||
|
||||
if ( false !== $cached_plugins && ! $bypass_cache ) {
|
||||
return $cached_plugins;
|
||||
}
|
||||
|
||||
$response = wp_remote_get(
|
||||
self::COMPATIBLE_PLUGIN_ENDPOINT
|
||||
);
|
||||
|
||||
$sanitized = static::validate_compatible_plugin_response( $response );
|
||||
|
||||
if ( false === $sanitized ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets local static associative array of plugin data keyed by plugin slug.
|
||||
*/
|
||||
$compatible_plugins = array();
|
||||
|
||||
foreach ( $sanitized as $plugin ) {
|
||||
$compatible_plugins[ $plugin['slug'] ] = $plugin;
|
||||
}
|
||||
|
||||
static::set_cached_plugins( $compatible_plugins );
|
||||
|
||||
return $compatible_plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a response object from the Compatible Plugins API.
|
||||
*
|
||||
* @param array|WP_Error $response
|
||||
* @return array|false
|
||||
*/
|
||||
private static function validate_compatible_plugin_response( $response ) {
|
||||
/**
|
||||
* Terminates the function if the response is a WP_Error object.
|
||||
*/
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The response returned is an array of header + body string data.
|
||||
* This pops off the body string for processing.
|
||||
*/
|
||||
$response_body = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( empty( $response_body ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$plugins = json_decode( $response_body, true );
|
||||
|
||||
if ( false === is_array( $plugins ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ( $plugins as $plugin ) {
|
||||
if ( ! is_array( $plugin ) ) {
|
||||
/**
|
||||
* Skips to the next iteration if for some reason the plugin is not an array.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ensure that the plugin config read in from the API has all the required fields.
|
||||
$plugin_key_count = count(
|
||||
array_intersect_key( $plugin, array_flip( static::COMPATIBLE_PLUGIN_FIELDS ) )
|
||||
);
|
||||
|
||||
$does_not_have_all_required_fields = ! (
|
||||
$plugin_key_count === count( static::COMPATIBLE_PLUGIN_FIELDS )
|
||||
);
|
||||
|
||||
if ( $does_not_have_all_required_fields ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( false === static::has_valid_plugin_path( $plugin['path'] ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return static::sanitize_compatible_plugin_response( $plugins );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a plugin path format.
|
||||
*
|
||||
* The path should be in the format of 'plugin-name/plugin-name.php'.
|
||||
* Allows alphanumeric characters, dashes, underscores, and optional dots in folder names.
|
||||
*
|
||||
* @param string $path
|
||||
* @return bool
|
||||
*/
|
||||
private static function has_valid_plugin_path( string $path ): bool {
|
||||
return preg_match( '/^[a-zA-Z0-9._-]+\/[a-zA-Z0-9_-]+\.php$/', $path ) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes a response object from the Compatible Plugins API.
|
||||
*
|
||||
* @param array $plugins
|
||||
* @return array
|
||||
*/
|
||||
private static function sanitize_compatible_plugin_response( array $plugins = array() ): array {
|
||||
foreach ( $plugins as $key => $plugin ) {
|
||||
$plugins[ $key ] = array_map( 'sanitize_text_field', $plugin );
|
||||
$plugins[ $key ]['help_url'] = sanitize_url( $plugins[ $key ]['help_url'] );
|
||||
$plugins[ $key ]['logo'] = sanitize_url( $plugins[ $key ]['logo'] );
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $plugins
|
||||
* @return bool
|
||||
*/
|
||||
private static function set_cached_plugins( array $plugins ): bool {
|
||||
$_blog_id = (int) get_current_blog_id();
|
||||
|
||||
return set_transient(
|
||||
static::CACHE_KEY . "_$_blog_id",
|
||||
$plugins,
|
||||
DAY_IN_SECONDS
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get cached compatible plugins.
|
||||
*
|
||||
* @return mixed|false
|
||||
*/
|
||||
private static function get_cached_plugins() {
|
||||
$_blog_id = (int) get_current_blog_id();
|
||||
|
||||
return get_transient(
|
||||
static::CACHE_KEY . "_$_blog_id"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purges the cache for the compatible plugins.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function purge_cache(): bool {
|
||||
$_blog_id = (int) get_current_blog_id();
|
||||
|
||||
return delete_transient(
|
||||
static::CACHE_KEY . "_$_blog_id"
|
||||
);
|
||||
}
|
||||
}
|
||||
1637
wp-content/plugins/akismet/class.akismet-admin.php
Normal file
186
wp-content/plugins/akismet/class.akismet-cli.php
Normal file
@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
WP_CLI::add_command( 'akismet', 'Akismet_CLI' );
|
||||
|
||||
/**
|
||||
* Filter spam comments.
|
||||
*/
|
||||
class Akismet_CLI extends WP_CLI_Command {
|
||||
/**
|
||||
* Checks one or more comments against the Akismet API.
|
||||
*
|
||||
* ## OPTIONS
|
||||
* <comment_id>...
|
||||
* : The ID(s) of the comment(s) to check.
|
||||
*
|
||||
* [--noaction]
|
||||
* : Don't change the status of the comment. Just report what Akismet thinks it is.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp akismet check 12345
|
||||
*
|
||||
* @alias comment-check
|
||||
*/
|
||||
public function check( $args, $assoc_args ) {
|
||||
foreach ( $args as $comment_id ) {
|
||||
if ( isset( $assoc_args['noaction'] ) ) {
|
||||
// Check the comment, but don't reclassify it.
|
||||
$api_response = Akismet::check_db_comment( $comment_id, 'wp-cli' );
|
||||
} else {
|
||||
$api_response = Akismet::recheck_comment( $comment_id, 'wp-cli' );
|
||||
}
|
||||
|
||||
if ( 'true' === $api_response ) {
|
||||
/* translators: %d: Comment ID. */
|
||||
WP_CLI::line( sprintf( __( 'Comment #%d is spam.', 'akismet' ), $comment_id ) );
|
||||
} elseif ( 'false' === $api_response ) {
|
||||
/* translators: %d: Comment ID. */
|
||||
WP_CLI::line( sprintf( __( 'Comment #%d is not spam.', 'akismet' ), $comment_id ) );
|
||||
} elseif ( false === $api_response ) {
|
||||
/* translators: %d: Comment ID. */
|
||||
WP_CLI::error( __( 'Failed to connect to Akismet.', 'akismet' ) );
|
||||
} elseif ( is_wp_error( $api_response ) ) {
|
||||
/* translators: %d: Comment ID. */
|
||||
WP_CLI::warning( sprintf( __( 'Comment #%d could not be checked.', 'akismet' ), $comment_id ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recheck all comments in the Pending queue.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp akismet recheck_queue
|
||||
*
|
||||
* @alias recheck-queue
|
||||
*/
|
||||
public function recheck_queue() {
|
||||
$batch_size = 100;
|
||||
$start = 0;
|
||||
|
||||
$total_counts = array();
|
||||
|
||||
do {
|
||||
$result_counts = Akismet_Admin::recheck_queue_portion( $start, $batch_size );
|
||||
|
||||
if ( $result_counts['processed'] > 0 ) {
|
||||
foreach ( $result_counts as $key => $count ) {
|
||||
if ( ! isset( $total_counts[ $key ] ) ) {
|
||||
$total_counts[ $key ] = $count;
|
||||
} else {
|
||||
$total_counts[ $key ] += $count;
|
||||
}
|
||||
}
|
||||
$start += $batch_size;
|
||||
$start -= $result_counts['spam']; // These comments will have been removed from the queue.
|
||||
}
|
||||
} while ( $result_counts['processed'] > 0 );
|
||||
|
||||
/* translators: %d: Number of comments. */
|
||||
WP_CLI::line( sprintf( _n( 'Processed %d comment.', 'Processed %d comments.', $total_counts['processed'], 'akismet' ), number_format( $total_counts['processed'] ) ) );
|
||||
|
||||
/* translators: %d: Number of comments. */
|
||||
WP_CLI::line( sprintf( _n( '%d comment moved to Spam.', '%d comments moved to Spam.', $total_counts['spam'], 'akismet' ), number_format( $total_counts['spam'] ) ) );
|
||||
|
||||
if ( $total_counts['error'] ) {
|
||||
/* translators: %d: Number of comments. */
|
||||
WP_CLI::line( sprintf( _n( '%d comment could not be checked.', '%d comments could not be checked.', $total_counts['error'], 'akismet' ), number_format( $total_counts['error'] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches stats from the Akismet API.
|
||||
*
|
||||
* ## OPTIONS
|
||||
*
|
||||
* [<interval>]
|
||||
* : The time period for which to retrieve stats.
|
||||
* ---
|
||||
* default: all
|
||||
* options:
|
||||
* - days
|
||||
* - months
|
||||
* - all
|
||||
* ---
|
||||
*
|
||||
* [--format=<format>]
|
||||
* : Allows overriding the output of the command when listing connections.
|
||||
* ---
|
||||
* default: table
|
||||
* options:
|
||||
* - table
|
||||
* - json
|
||||
* - csv
|
||||
* - yaml
|
||||
* - count
|
||||
* ---
|
||||
*
|
||||
* [--summary]
|
||||
* : When set, will display a summary of the stats.
|
||||
*
|
||||
* ## EXAMPLES
|
||||
*
|
||||
* wp akismet stats
|
||||
* wp akismet stats all
|
||||
* wp akismet stats days
|
||||
* wp akismet stats months
|
||||
* wp akismet stats all --summary
|
||||
*/
|
||||
public function stats( $args, $assoc_args ) {
|
||||
$api_key = Akismet::get_api_key();
|
||||
|
||||
if ( empty( $api_key ) ) {
|
||||
WP_CLI::error( __( 'API key must be set to fetch stats.', 'akismet' ) );
|
||||
}
|
||||
|
||||
switch ( $args[0] ) {
|
||||
case 'days':
|
||||
$interval = '60-days';
|
||||
break;
|
||||
case 'months':
|
||||
$interval = '6-months';
|
||||
break;
|
||||
default:
|
||||
$interval = 'all';
|
||||
break;
|
||||
}
|
||||
|
||||
$request_args = array(
|
||||
'blog' => get_option( 'home' ),
|
||||
'key' => $api_key,
|
||||
'from' => $interval,
|
||||
);
|
||||
|
||||
$request_args = apply_filters( 'akismet_request_args', $request_args, 'get-stats' );
|
||||
|
||||
$response = Akismet::http_post( Akismet::build_query( $request_args ), 'get-stats' );
|
||||
|
||||
if ( empty( $response[1] ) ) {
|
||||
WP_CLI::error( __( 'Currently unable to fetch stats. Please try again.', 'akismet' ) );
|
||||
}
|
||||
|
||||
$response_body = json_decode( $response[1], true );
|
||||
|
||||
if ( is_null( $response_body ) ) {
|
||||
WP_CLI::error( __( 'Stats response could not be decoded.', 'akismet' ) );
|
||||
}
|
||||
|
||||
if ( isset( $assoc_args['summary'] ) ) {
|
||||
$keys = array(
|
||||
'spam',
|
||||
'ham',
|
||||
'missed_spam',
|
||||
'false_positives',
|
||||
'accuracy',
|
||||
'time_saved',
|
||||
);
|
||||
|
||||
WP_CLI\Utils\format_items( $assoc_args['format'], array( $response_body ), $keys );
|
||||
} else {
|
||||
$stats = $response_body['breakdown'];
|
||||
WP_CLI\Utils\format_items( $assoc_args['format'], $stats, array_keys( end( $stats ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
616
wp-content/plugins/akismet/class.akismet-rest-api.php
Normal file
@ -0,0 +1,616 @@
|
||||
<?php
|
||||
|
||||
class Akismet_REST_API {
|
||||
/**
|
||||
* Register the REST API routes.
|
||||
*/
|
||||
public static function init() {
|
||||
if ( ! function_exists( 'register_rest_route' ) ) {
|
||||
// The REST API wasn't integrated into core until 4.4, and we support 4.0+ (for now).
|
||||
return false;
|
||||
}
|
||||
|
||||
register_rest_route(
|
||||
'akismet/v1',
|
||||
'/key',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_key' ),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'set_key' ),
|
||||
'args' => array(
|
||||
'key' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
|
||||
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/account', 'akismet' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::DELETABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'delete_key' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'akismet/v1',
|
||||
'/settings/',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_settings' ),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'set_boolean_settings' ),
|
||||
'args' => array(
|
||||
'akismet_strictness' => array(
|
||||
'required' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'If true, Akismet will automatically discard the worst spam automatically rather than putting it in the spam folder.', 'akismet' ),
|
||||
),
|
||||
'akismet_show_user_comments_approved' => array(
|
||||
'required' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'If true, show the number of approved comments beside each comment author in the comments list page.', 'akismet' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'akismet/v1',
|
||||
'/stats',
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_stats' ),
|
||||
'args' => array(
|
||||
'interval' => array(
|
||||
'required' => false,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_interval' ),
|
||||
'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ),
|
||||
'default' => 'all',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'akismet/v1',
|
||||
'/stats/(?P<interval>[\w+])',
|
||||
array(
|
||||
'args' => array(
|
||||
'interval' => array(
|
||||
'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_stats' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'akismet/v1',
|
||||
'/alert',
|
||||
array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_alert' ),
|
||||
'args' => array(
|
||||
'key' => array(
|
||||
'required' => false,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
|
||||
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/account', 'akismet' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'set_alert' ),
|
||||
'args' => array(
|
||||
'key' => array(
|
||||
'required' => false,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
|
||||
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/account', 'akismet' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::DELETABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'delete_alert' ),
|
||||
'args' => array(
|
||||
'key' => array(
|
||||
'required' => false,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
|
||||
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/account', 'akismet' ),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
'akismet/v1',
|
||||
'/webhook',
|
||||
array(
|
||||
'methods' => WP_REST_Server::CREATABLE,
|
||||
'callback' => array( 'Akismet_REST_API', 'receive_webhook' ),
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'remote_call_permission_callback' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current Akismet API key.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function get_key( $request = null ) {
|
||||
return rest_ensure_response( Akismet::get_api_key() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the API key, if possible.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function set_key( $request ) {
|
||||
if ( defined( 'WPCOM_API_KEY' ) ) {
|
||||
return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be changed via the API.', 'akismet' ), array( 'status' => 409 ) ) );
|
||||
}
|
||||
|
||||
$new_api_key = $request->get_param( 'key' );
|
||||
|
||||
if ( ! self::key_is_valid( $new_api_key ) ) {
|
||||
return rest_ensure_response( new WP_Error( 'invalid_key', __( 'The value provided is not a valid and registered API key.', 'akismet' ), array( 'status' => 400 ) ) );
|
||||
}
|
||||
|
||||
update_option( 'wordpress_api_key', $new_api_key );
|
||||
|
||||
return self::get_key();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the API key, if possible.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function delete_key( $request ) {
|
||||
if ( defined( 'WPCOM_API_KEY' ) ) {
|
||||
return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be deleted.', 'akismet' ), array( 'status' => 409 ) ) );
|
||||
}
|
||||
|
||||
delete_option( 'wordpress_api_key' );
|
||||
|
||||
return rest_ensure_response( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Akismet settings.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function get_settings( $request = null ) {
|
||||
return rest_ensure_response(
|
||||
array(
|
||||
'akismet_strictness' => ( get_option( 'akismet_strictness', '1' ) === '1' ),
|
||||
'akismet_show_user_comments_approved' => ( get_option( 'akismet_show_user_comments_approved', '1' ) === '1' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Akismet settings.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function set_boolean_settings( $request ) {
|
||||
foreach ( array(
|
||||
'akismet_strictness',
|
||||
'akismet_show_user_comments_approved',
|
||||
) as $setting_key ) {
|
||||
|
||||
$setting_value = $request->get_param( $setting_key );
|
||||
if ( is_null( $setting_value ) ) {
|
||||
// This setting was not specified.
|
||||
continue;
|
||||
}
|
||||
|
||||
// From 4.7+, WP core will ensure that these are always boolean
|
||||
// values because they are registered with 'type' => 'boolean',
|
||||
// but we need to do this ourselves for prior versions.
|
||||
$setting_value = self::parse_boolean( $setting_value );
|
||||
|
||||
update_option( $setting_key, $setting_value ? '1' : '0' );
|
||||
}
|
||||
|
||||
return self::get_settings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a numeric or string boolean value into a boolean.
|
||||
*
|
||||
* @param mixed $value The value to convert into a boolean.
|
||||
* @return bool The converted value.
|
||||
*/
|
||||
public static function parse_boolean( $value ) {
|
||||
switch ( $value ) {
|
||||
case true:
|
||||
case 'true':
|
||||
case '1':
|
||||
case 1:
|
||||
return true;
|
||||
|
||||
case false:
|
||||
case 'false':
|
||||
case '0':
|
||||
case 0:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return (bool) $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Akismet stats for a given time period.
|
||||
*
|
||||
* Possible `interval` values:
|
||||
* - all
|
||||
* - 60-days
|
||||
* - 6-months
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function get_stats( $request ) {
|
||||
$api_key = Akismet::get_api_key();
|
||||
|
||||
$interval = $request->get_param( 'interval' );
|
||||
|
||||
$stat_totals = array();
|
||||
|
||||
$request_args = array(
|
||||
'blog' => get_option( 'home' ),
|
||||
'key' => $api_key,
|
||||
'from' => $interval,
|
||||
);
|
||||
|
||||
$request_args = apply_filters( 'akismet_request_args', $request_args, 'get-stats' );
|
||||
|
||||
$response = Akismet::http_post( Akismet::build_query( $request_args ), 'get-stats' );
|
||||
|
||||
if ( ! empty( $response[1] ) ) {
|
||||
$stat_totals[ $interval ] = json_decode( $response[1] );
|
||||
}
|
||||
|
||||
return rest_ensure_response( $stat_totals );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current alert code and message. Alert codes are used to notify the site owner
|
||||
* if there's a problem, like a connection issue between their site and the Akismet API,
|
||||
* invalid requests being sent, etc.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function get_alert( $request ) {
|
||||
return rest_ensure_response(
|
||||
array(
|
||||
'code' => get_option( 'akismet_alert_code' ),
|
||||
'message' => get_option( 'akismet_alert_msg' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the current alert code and message by triggering a call to the Akismet server.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function set_alert( $request ) {
|
||||
delete_option( 'akismet_alert_code' );
|
||||
delete_option( 'akismet_alert_msg' );
|
||||
|
||||
// Make a request so the most recent alert code and message are retrieved.
|
||||
Akismet::verify_key( Akismet::get_api_key() );
|
||||
|
||||
return self::get_alert( $request );
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the current alert code and message.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function delete_alert( $request ) {
|
||||
delete_option( 'akismet_alert_code' );
|
||||
delete_option( 'akismet_alert_msg' );
|
||||
|
||||
return self::get_alert( $request );
|
||||
}
|
||||
|
||||
private static function key_is_valid( $key ) {
|
||||
$request_args = array(
|
||||
'key' => $key,
|
||||
'blog' => get_option( 'home' ),
|
||||
);
|
||||
|
||||
$request_args = apply_filters( 'akismet_request_args', $request_args, 'verify-key' );
|
||||
|
||||
$response = Akismet::http_post( Akismet::build_query( $request_args ), 'verify-key' );
|
||||
|
||||
if ( $response[1] == 'valid' ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function privileged_permission_callback() {
|
||||
return current_user_can( 'manage_options' );
|
||||
}
|
||||
|
||||
/**
|
||||
* For calls that Akismet.com makes to the site to clear outdated alert codes, use the API key for authorization.
|
||||
*/
|
||||
public static function remote_call_permission_callback( $request ) {
|
||||
$local_key = Akismet::get_api_key();
|
||||
|
||||
return $local_key && ( strtolower( $request->get_param( 'key' ) ?? '' ) === strtolower( $local_key ) );
|
||||
}
|
||||
|
||||
public static function sanitize_interval( $interval, $request, $param ) {
|
||||
$interval = trim( $interval );
|
||||
|
||||
$valid_intervals = array( '60-days', '6-months', 'all' );
|
||||
|
||||
if ( ! in_array( $interval, $valid_intervals ) ) {
|
||||
$interval = 'all';
|
||||
}
|
||||
|
||||
return $interval;
|
||||
}
|
||||
|
||||
public static function sanitize_key( $key, $request, $param ) {
|
||||
return trim( $key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a webhook request from the Akismet servers.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function receive_webhook( $request ) {
|
||||
Akismet::log( array( 'Webhook request received', $request->get_body() ) );
|
||||
|
||||
/**
|
||||
* The request body should look like this:
|
||||
* array(
|
||||
* 'key' => '1234567890abcd',
|
||||
* 'endpoint' => '[comment-check|submit-ham|submit-spam]',
|
||||
* 'comments' => array(
|
||||
* array(
|
||||
* 'guid' => '[...]',
|
||||
* 'result' => '[true|false]',
|
||||
* 'comment_author' => '[...]',
|
||||
* [...]
|
||||
* ),
|
||||
* array(
|
||||
* 'guid' => '[...]',
|
||||
* [...],
|
||||
* ),
|
||||
* [...]
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* Multiple comments can be included in each request, and the only truly required
|
||||
* field for each is the guid, although it would be friendly to include also
|
||||
* comment_post_ID, comment_parent, and comment_author_email, if possible to make
|
||||
* searching easier.
|
||||
*/
|
||||
|
||||
// The response will include statuses for the result of each comment that was supplied.
|
||||
$response = array(
|
||||
'comments' => array(),
|
||||
);
|
||||
|
||||
$endpoint = $request->get_param( 'endpoint' );
|
||||
|
||||
switch ( $endpoint ) {
|
||||
case 'comment-check':
|
||||
$webhook_comments = $request->get_param( 'comments' );
|
||||
|
||||
if ( ! is_array( $webhook_comments ) ) {
|
||||
return rest_ensure_response( new WP_Error( 'malformed_request', __( 'The \'comments\' parameter must be an array.', 'akismet' ), array( 'status' => 400 ) ) );
|
||||
}
|
||||
|
||||
foreach ( $webhook_comments as $webhook_comment ) {
|
||||
$guid = $webhook_comment['guid'];
|
||||
|
||||
if ( ! $guid ) {
|
||||
// Without the GUID, we can't be sure that we're matching the right comment.
|
||||
// We'll make it a rule that any comment without a GUID is ignored intentionally.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Search on the fields that are indexed in the comments table, plus the GUID.
|
||||
// The GUID is the only thing we really need to search on, but comment_meta
|
||||
// is not indexed in a useful way if there are many many comments. This
|
||||
// should help narrow it down first.
|
||||
$queryable_fields = array(
|
||||
'comment_post_ID' => 'post_id',
|
||||
'comment_parent' => 'parent',
|
||||
'comment_author_email' => 'author_email',
|
||||
);
|
||||
|
||||
$query_args = array();
|
||||
$query_args['status'] = 'any';
|
||||
$query_args['meta_key'] = 'akismet_guid';
|
||||
$query_args['meta_value'] = $guid;
|
||||
|
||||
foreach ( $queryable_fields as $queryable_field => $wp_comment_query_field ) {
|
||||
if ( isset( $webhook_comment[ $queryable_field ] ) ) {
|
||||
$query_args[ $wp_comment_query_field ] = $webhook_comment[ $queryable_field ];
|
||||
}
|
||||
}
|
||||
|
||||
$comments_query = new WP_Comment_Query( $query_args );
|
||||
$comments = $comments_query->comments;
|
||||
|
||||
if ( ! $comments ) {
|
||||
// Unexpected, although the comment could have been deleted since being submitted.
|
||||
Akismet::log( 'Webhook failed: no matching comment found.' );
|
||||
|
||||
$response['comments'][ $guid ] = array(
|
||||
'status' => 'error',
|
||||
'message' => __( 'Could not find matching comment.', 'akismet' ),
|
||||
);
|
||||
|
||||
continue;
|
||||
} if ( count( $comments ) > 1 ) {
|
||||
// Two comments shouldn't be able to match the same GUID.
|
||||
Akismet::log( 'Webhook failed: multiple matching comments found.', $comments );
|
||||
|
||||
$response['comments'][ $guid ] = array(
|
||||
'status' => 'error',
|
||||
'message' => __( 'Multiple comments matched request.', 'akismet' ),
|
||||
);
|
||||
|
||||
continue;
|
||||
} else {
|
||||
// We have one single match, as hoped for.
|
||||
Akismet::log( 'Found matching comment.', $comments );
|
||||
|
||||
$comment = $comments[0];
|
||||
|
||||
$current_status = wp_get_comment_status( $comment );
|
||||
|
||||
$result = $webhook_comment['result'];
|
||||
|
||||
if ( 'true' == $result ) {
|
||||
Akismet::log( 'Comment should be spam' );
|
||||
|
||||
// The comment should be classified as spam.
|
||||
if ( 'spam' != $current_status ) {
|
||||
// The comment is not classified as spam. If Akismet was the one to act on it, move it to spam.
|
||||
if ( Akismet::last_comment_status_change_came_from_akismet( $comment->comment_ID ) ) {
|
||||
Akismet::log( 'Comment is not spam; marking as spam.' );
|
||||
|
||||
wp_spam_comment( $comment );
|
||||
Akismet::update_comment_history( $comment->comment_ID, '', 'webhook-spam' );
|
||||
} else {
|
||||
Akismet::log( 'Comment is not spam, but it has already been manually handled by some other process.' );
|
||||
Akismet::update_comment_history( $comment->comment_ID, '', 'webhook-spam-noaction' );
|
||||
}
|
||||
}
|
||||
} elseif ( 'false' == $result ) {
|
||||
Akismet::log( 'Comment should be ham' );
|
||||
|
||||
// The comment should be classified as ham.
|
||||
if ( 'spam' == $current_status ) {
|
||||
Akismet::log( 'Comment is spam.' );
|
||||
|
||||
// The comment is classified as spam. If Akismet was the one to label it as spam, unspam it.
|
||||
if ( Akismet::last_comment_status_change_came_from_akismet( $comment->comment_ID ) ) {
|
||||
Akismet::log( 'Akismet marked it as spam; unspamming.' );
|
||||
|
||||
wp_unspam_comment( $comment );
|
||||
|
||||
akismet::update_comment_history( $comment->comment_ID, '', 'webhook-ham' );
|
||||
} else {
|
||||
Akismet::log( 'Comment is not spam, but it has already been manually handled by some other process.' );
|
||||
Akismet::update_comment_history( $comment->comment_ID, '', 'webhook-ham-noaction' );
|
||||
}
|
||||
} else if ( 'unapproved' == $current_status ) {
|
||||
Akismet::log( 'Comment is pending.' );
|
||||
|
||||
// The comment is in Pending. If Akismet was the one to put it there, approve it (but only if the site
|
||||
// settings dictate that).
|
||||
if ( Akismet::last_comment_status_change_came_from_akismet( $comment->comment_ID ) ) {
|
||||
Akismet::log( 'Akismet marked it as Pending; approving.' );
|
||||
|
||||
if ( check_comment( $comment->comment_author, $comment->comment_author_email, $comment->comment_author_url, $comment->comment_content, $comment->comment_author_IP, $comment->comment_agent, $comment->comment_type ) ) {
|
||||
wp_set_comment_status( $comment->comment_ID, 1 );
|
||||
}
|
||||
|
||||
akismet::update_comment_history( $comment->comment_ID, '', 'webhook-ham' );
|
||||
} else {
|
||||
Akismet::log( 'Comment is not spam, but it has already been manually handled by some other process.' );
|
||||
Akismet::update_comment_history( $comment->comment_ID, '', 'webhook-ham-noaction' );
|
||||
}
|
||||
}
|
||||
|
||||
$moderation_email_was_delayed = get_comment_meta( $comment->comment_ID, 'akismet_delayed_moderation_email', true );
|
||||
|
||||
if ( $moderation_email_was_delayed ) {
|
||||
Akismet::log( 'Moderation email was delayed for comment #' . $comment->comment_ID . '; sending now.' );
|
||||
|
||||
delete_comment_meta( $comment->comment_ID, 'akismet_delayed_moderation_email' );
|
||||
wp_new_comment_notify_moderator( $comment->comment_ID );
|
||||
wp_new_comment_notify_postauthor( $comment->comment_ID );
|
||||
}
|
||||
|
||||
delete_comment_meta( $comment->comment_ID, 'akismet_delay_moderation_email' );
|
||||
}
|
||||
|
||||
$response['comments'][ $guid ] = array( 'status' => 'success' );
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'submit-ham':
|
||||
case 'submit-spam':
|
||||
// Nothing to do for submit-ham or submit-spam.
|
||||
break;
|
||||
default:
|
||||
// Unsupported endpoint.
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow plugins to do things with a successfully processed webhook request, like logging.
|
||||
*
|
||||
* @since 5.3.2
|
||||
*
|
||||
* @param WP_REST_Request $request The REST request object.
|
||||
*/
|
||||
do_action( 'akismet_webhook_received', $request );
|
||||
|
||||
Akismet::log( 'Done processing webhook.' );
|
||||
|
||||
return rest_ensure_response( $response );
|
||||
}
|
||||
}
|
||||
177
wp-content/plugins/akismet/class.akismet-widget.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Akismet
|
||||
*/
|
||||
|
||||
// We plan to gradually remove all of the disabled lint rules below.
|
||||
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
|
||||
/**
|
||||
* Akismet Widget Class
|
||||
*/
|
||||
class Akismet_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
parent::__construct(
|
||||
'akismet_widget',
|
||||
__( 'Akismet Widget', 'akismet' ),
|
||||
array( 'description' => __( 'Display the number of spam comments Akismet has caught', 'akismet' ) )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget settings form
|
||||
*
|
||||
* @param array $instance The widget options
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
if ( $instance && isset( $instance['title'] ) ) {
|
||||
$title = $instance['title'];
|
||||
} else {
|
||||
$title = __( 'Spam Blocked', 'akismet' );
|
||||
}
|
||||
?>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'akismet' ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
|
||||
</p>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the widget settings
|
||||
*
|
||||
* @param array $new_instance New widget instance
|
||||
* @param array $old_instance Old widget instance
|
||||
* @return array Updated widget instance
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = array();
|
||||
$instance['title'] = sanitize_text_field( $new_instance['title'] );
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the widget content
|
||||
*
|
||||
* @param array $args Widget arguments
|
||||
* @param array $instance Widget instance
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
$count = get_option( 'akismet_spam_count' );
|
||||
|
||||
if ( ! isset( $instance['title'] ) ) {
|
||||
$instance['title'] = __( 'Spam Blocked', 'akismet' );
|
||||
}
|
||||
|
||||
echo $args['before_widget'];
|
||||
if ( ! empty( $instance['title'] ) ) {
|
||||
echo $args['before_title'];
|
||||
echo esc_html( $instance['title'] );
|
||||
echo $args['after_title'];
|
||||
}
|
||||
?>
|
||||
|
||||
<style>
|
||||
.a-stats {
|
||||
--akismet-color-mid-green: #357b49;
|
||||
--akismet-color-white: #fff;
|
||||
--akismet-color-light-grey: #f6f7f7;
|
||||
|
||||
max-width: 350px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.a-stats * {
|
||||
all: unset;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.a-stats strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.a-stats a.a-stats__link,
|
||||
.a-stats a.a-stats__link:visited,
|
||||
.a-stats a.a-stats__link:active {
|
||||
background: var(--akismet-color-mid-green);
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
border-radius: 8px;
|
||||
color: var(--akismet-color-white);
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen-Sans', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
|
||||
font-weight: 500;
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
/* Extra specificity to deal with TwentyTwentyOne focus style */
|
||||
.widget .a-stats a.a-stats__link:focus {
|
||||
background: var(--akismet-color-mid-green);
|
||||
color: var(--akismet-color-white);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.a-stats a.a-stats__link:hover {
|
||||
filter: brightness(110%);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 0 2px rgba(0, 0, 0, 0.16);
|
||||
}
|
||||
|
||||
.a-stats .count {
|
||||
color: var(--akismet-color-white);
|
||||
display: block;
|
||||
font-size: 1.5em;
|
||||
line-height: 1.4;
|
||||
padding: 0 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="a-stats">
|
||||
<a href="https://akismet.com?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=widget_stats" class="a-stats__link" target="_blank" rel="noopener" style="background-color: var(--akismet-color-mid-green); color: var(--akismet-color-white);">
|
||||
<?php
|
||||
|
||||
echo wp_kses(
|
||||
sprintf(
|
||||
/* translators: The placeholder is the number of pieces of spam blocked by Akismet. */
|
||||
_n(
|
||||
'<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
|
||||
'<strong class="count">%1$s spam</strong> blocked by <strong>Akismet</strong>',
|
||||
$count,
|
||||
'akismet'
|
||||
),
|
||||
number_format_i18n( $count )
|
||||
),
|
||||
array(
|
||||
'strong' => array(
|
||||
'class' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Akismet widget
|
||||
*/
|
||||
function akismet_register_widgets() {
|
||||
register_widget( 'Akismet_Widget' );
|
||||
}
|
||||
|
||||
add_action( 'widgets_init', 'akismet_register_widgets' );
|
||||
2242
wp-content/plugins/akismet/class.akismet.php
Normal file
4
wp-content/plugins/akismet/index.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
// Silence is golden.
|
||||
149
wp-content/plugins/akismet/readme.txt
Normal file
@ -0,0 +1,149 @@
|
||||
=== Akismet Anti-spam: Spam Protection ===
|
||||
Contributors: matt, ryan, andy, mdawaffe, tellyworth, josephscott, lessbloat, eoigal, cfinke, automattic, jgs, procifer, stephdau, kbrownkd, bluefuton, derekspringer, lschuyler, andyperdomo, akismetantispam
|
||||
Tags: comments, spam, antispam, anti-spam, contact form
|
||||
Requires at least: 5.8
|
||||
Tested up to: 6.9
|
||||
Stable tag: 5.6
|
||||
License: GPLv2 or later
|
||||
|
||||
The best anti-spam protection to block spam comments and spam in a contact form. The most trusted antispam solution for WordPress and WooCommerce.
|
||||
|
||||
== Description ==
|
||||
|
||||
The best anti-spam protection to block spam comments and spam in a contact form. The most trusted antispam solution for WordPress and WooCommerce.
|
||||
|
||||
Akismet checks your comments and contact form submissions against our global database of spam to prevent your site from publishing malicious content. You can review the comment spam it catches on your blog's "Comments" admin screen.
|
||||
|
||||
Major features in Akismet include:
|
||||
|
||||
* Automatically checks all comments and filters out the ones that look like spam.
|
||||
* Each comment has a status history, so you can easily see which comments were caught or cleared by Akismet and which were spammed or unspammed by a moderator.
|
||||
* URLs are shown in the comment body to reveal hidden or misleading links.
|
||||
* Moderators can see the number of approved comments for each user.
|
||||
* A discard feature that outright blocks the worst spam, saving you disk space and speeding up your site.
|
||||
|
||||
PS: You'll be prompted to get an Akismet.com API key to use it, once activated. Keys are free for personal blogs; paid subscriptions are available for businesses and commercial sites.
|
||||
|
||||
== Installation ==
|
||||
|
||||
Upload the Akismet plugin to your blog, activate it, and then enter your Akismet.com API key.
|
||||
|
||||
1, 2, 3: You're done!
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 5.6 =
|
||||
*Release Date - 12 November 2025*
|
||||
|
||||
* Improve caching of compatible plugins.
|
||||
* Explain the key features of Akismet more clearly on the setup page.
|
||||
* Improve the configuration process to better explain errors when they occur.
|
||||
* UI cleanup and refresh
|
||||
* Improve messaging related to usage limits.
|
||||
|
||||
= 5.5 =
|
||||
*Release Date - 15 July 2025*
|
||||
|
||||
* Enable webhooks so that Akismet can process comments asynchronously to detect more types of spam.
|
||||
* Only include the Akismet widget CSS when the Akismet widget is present
|
||||
* Improve contrast/readability for certain UI elements
|
||||
|
||||
= 5.4 =
|
||||
*Release Date - 7 May 2025*
|
||||
|
||||
* The stats pages now use the user's locale instead of the site's locale if they're different.
|
||||
* Adds a 'Compatible plugins' section that will show installed and active plugins that are compatible with Akismet.
|
||||
* Akismet now requires PHP version 7.2 or above.
|
||||
|
||||
= 5.3.7 =
|
||||
*Release Date - 14 February 2025*
|
||||
|
||||
* Simplify the logic used during a comment-check request to compare comments.
|
||||
|
||||
= 5.3.6 =
|
||||
*Release Date - 4 February 2025*
|
||||
|
||||
* Improve the utility of submit-spam and submit-ham requests.
|
||||
* Modernize styles for the Akismet classic widget.
|
||||
|
||||
= 5.3.5 =
|
||||
*Release Date - 18 November 2024*
|
||||
|
||||
* Address compatibility issues with < PHP 7.3 in v5.3.4 release.
|
||||
|
||||
= 5.3.4 =
|
||||
*Release Date - 18 November 2024*
|
||||
|
||||
* Improve activation notice on Comments for users who haven't set up their API key yet.
|
||||
* Improve notice about commercial site status.
|
||||
|
||||
= 5.3.3 =
|
||||
*Release Date - 10 July 2024*
|
||||
|
||||
* Make setup step clearer for new users.
|
||||
* Remove the stats section from the configuration page if the site has been revoked from the key.
|
||||
* Skip the Akismet comment check when the comment matches something in the disallowed list.
|
||||
* Prompt users on legacy plans to contact Akismet support for upgrades.
|
||||
|
||||
= 5.3.2 =
|
||||
*Release Date - 21 March 2024*
|
||||
|
||||
* Improve the empty state shown to new users when no spam has been caught yet.
|
||||
* Update the message shown to users without a current subscription.
|
||||
* Add foundations for future webhook support.
|
||||
|
||||
= 5.3.1 =
|
||||
*Release Date - 17 January 2024*
|
||||
|
||||
* Make the plugin more resilient when asset files are missing (as seen in WordPress Playground).
|
||||
* Add a link to the 'Account overview' page on akismet.com.
|
||||
* Fix a minor error that occurs when another plugin removes all comment actions from the dashboard.
|
||||
* Add the akismet_request_args filter to allow request args in Akismet API requests to be filtered.
|
||||
* Fix a bug that causes some contact forms to include unnecessary data in the comment_content parameter.
|
||||
|
||||
= 5.3 =
|
||||
*Release Date - 14 September 2023*
|
||||
|
||||
* Improve display of user notices.
|
||||
* Add stylesheets for RTL languages.
|
||||
* Remove initial disabled state from 'Save changes' button.
|
||||
* Improve accessibility of API key entry form.
|
||||
* Add new filter hooks for Fluent Forms.
|
||||
* Fix issue with PHP 8.1 compatibility.
|
||||
|
||||
= 5.2 =
|
||||
*Release Date - 21 June 2023*
|
||||
|
||||
* Visual refresh of Akismet stats.
|
||||
* Improve PHP 8.1 compatibility.
|
||||
* Improve appearance of plugin to match updated stats.
|
||||
* Change minimum supported PHP version to 5.6 to match WordPress.
|
||||
* Drop IE11 support and update minimum WordPress version to 5.8 (where IE11 support was removed from WP Core).
|
||||
|
||||
= 5.1 =
|
||||
*Release Date - 20 March 2023*
|
||||
|
||||
* Removed unnecessary limit notices from admin page.
|
||||
* Improved spam detection by including post taxonomies in the comment-check call.
|
||||
* Removed API keys from stats iframes to avoid possible inadvertent exposure.
|
||||
|
||||
= 5.0.2 =
|
||||
*Release Date - 1 December 2022*
|
||||
|
||||
* Improved compatibility with themes that hide or show UI elements based on mouse movements.
|
||||
* Increased security of API keys by sending them in request bodies instead of subdomains.
|
||||
|
||||
= 5.0.1 =
|
||||
*Release Date - 28 September 2022*
|
||||
|
||||
* Added an empty state for the Statistics section on the admin page.
|
||||
* Fixed a bug that broke some admin page links when Jetpack plugins are active.
|
||||
* Marked some event listeners as passive to improve performance in newer browsers.
|
||||
* Disabled interaction observation on forms that post to other domains.
|
||||
|
||||
= 5.0 =
|
||||
*Release Date - 26 July 2022*
|
||||
|
||||
* Added a new feature to catch spammers by observing how they interact with the page.
|
||||
|
||||
For older changelog entries, please see the [additional changelog.txt file](https://plugins.svn.wordpress.org/akismet/trunk/changelog.txt) delivered with the plugin.
|
||||
7
wp-content/plugins/akismet/views/activate.php
Normal file
@ -0,0 +1,7 @@
|
||||
<div class="akismet-box">
|
||||
<?php Akismet::view( 'setup' ); ?>
|
||||
</div>
|
||||
|
||||
<div class="akismet-box">
|
||||
<?php Akismet::view( 'enter' ); ?>
|
||||
</div>
|
||||
126
wp-content/plugins/akismet/views/compatible-plugins.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
/** @var array|WP_Error $compatible_plugins */
|
||||
$bypass_cache = ! empty( $_GET['akismet_refresh_compatible_plugins'] );
|
||||
$compatible_plugins = Akismet_Compatible_Plugins::get_installed_compatible_plugins( $bypass_cache );
|
||||
if ( is_array( $compatible_plugins ) ) :
|
||||
|
||||
$compatible_plugin_count = count( $compatible_plugins );
|
||||
?>
|
||||
<div class="akismet-card akismet-compatible-plugins">
|
||||
<div class="akismet-section-header">
|
||||
<h2 class="akismet-section-header__label akismet-compatible-plugins__section-header-label" aria-label="<?php esc_attr_e( 'Compatible plugins (new feature)', 'akismet' ); ?>">
|
||||
<span class="akismet-compatible-plugins__section-header-label-text"><?php esc_html_e( 'Compatible plugins', 'akismet' ); ?></span>
|
||||
<span class="akismet-new-feature"><?php esc_html_e( 'New', 'akismet' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="akismet-compatible-plugins__content">
|
||||
<?php
|
||||
|
||||
echo '<p>';
|
||||
echo esc_html( __( 'Akismet works with other plugins to keep spam away.', 'akismet' ) );
|
||||
echo '</p>';
|
||||
|
||||
echo '<p>';
|
||||
|
||||
if ( 0 === $compatible_plugin_count ) {
|
||||
echo '<a class="akismet-external-link" href="https://akismet.com/developers/plugins-and-libraries/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=compatible_plugins">';
|
||||
echo esc_html( __( 'See supported integrations', 'akismet' ) );
|
||||
echo '</a>';
|
||||
} else {
|
||||
echo esc_html(
|
||||
_n(
|
||||
"This plugin you've installed is compatible. Follow the documentation link to get started.",
|
||||
"These plugins you've installed are compatible. Follow the documentation links to get started.",
|
||||
$compatible_plugin_count,
|
||||
'akismet'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
echo '</p>';
|
||||
|
||||
?>
|
||||
|
||||
<?php if ( ! empty( $compatible_plugins ) ) : ?>
|
||||
<ul class="akismet-compatible-plugins__list" id="akismet-compatible-plugins__list">
|
||||
<?php
|
||||
|
||||
foreach ( $compatible_plugins as $compatible_plugin ) :
|
||||
if ( empty( $compatible_plugin['help_url'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
?>
|
||||
<li class="akismet-compatible-plugins__card">
|
||||
<?php if ( strlen( $compatible_plugin['logo'] ) > 0 ) : ?>
|
||||
<?php
|
||||
|
||||
$logo_alt = sprintf(
|
||||
/* translators: The placeholder is the name of a plugin, like "Jetpack" . */
|
||||
__( '%s logo', 'akismet' ),
|
||||
$compatible_plugin['name']
|
||||
);
|
||||
|
||||
?>
|
||||
<img
|
||||
src="<?php echo esc_url( $compatible_plugin['logo'] ); ?>"
|
||||
alt="<?php echo esc_attr( $logo_alt ); ?>"
|
||||
class="akismet-compatible-plugins__card-logo"
|
||||
width="55"
|
||||
height="55"
|
||||
/>
|
||||
<?php endif ?>
|
||||
<div class="akismet-compatible-plugins__card-detail">
|
||||
<h3 class="akismet-compatible-plugins__card-title"><?php echo esc_html( $compatible_plugin['name'] ); ?></h3>
|
||||
<div class="akismet-compatible-plugins__docs">
|
||||
<a
|
||||
class="akismet-external-link"
|
||||
href="<?php echo esc_url( $compatible_plugin['help_url'] ); ?>"
|
||||
aria-label="
|
||||
<?php
|
||||
|
||||
echo esc_attr(
|
||||
sprintf(
|
||||
/* translators: The placeholder is the name of a plugin, like "Jetpack" . */
|
||||
__( 'Documentation for %s', 'akismet' ),
|
||||
$compatible_plugin['name']
|
||||
)
|
||||
);
|
||||
|
||||
?>
|
||||
"><?php esc_html_e( 'View documentation', 'akismet' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<?php if ( $compatible_plugin_count > Akismet_Compatible_Plugins::DEFAULT_VISIBLE_PLUGIN_COUNT ) : ?>
|
||||
<button class="akismet-compatible-plugins__show-more"
|
||||
aria-expanded="false"
|
||||
aria-controls="akismet-compatible-plugins__list"
|
||||
data-label-closed="
|
||||
<?php
|
||||
|
||||
/* translators: %d: number of compatible plugins, which is guaranteed to be more than 1. */
|
||||
echo esc_attr( sprintf( __( 'Show all %d plugins', 'akismet' ), $compatible_plugin_count ) );
|
||||
|
||||
?>
|
||||
"
|
||||
data-label-open="<?php echo esc_attr( __( 'Show less', 'akismet' ) ); ?>">
|
||||
<?php
|
||||
|
||||
/* translators: %d: number of compatible plugins, which is guaranteed to be more than 1. */
|
||||
echo esc_html( sprintf( __( 'Show all %d plugins', 'akismet' ), $compatible_plugin_count ) );
|
||||
|
||||
?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
325
wp-content/plugins/akismet/views/config.php
Normal file
@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
$kses_allow_link_href = array(
|
||||
'a' => array(
|
||||
'href' => true,
|
||||
),
|
||||
);
|
||||
?>
|
||||
<div id="akismet-plugin-container">
|
||||
<div class="akismet-masthead">
|
||||
<div class="akismet-masthead__inside-container">
|
||||
<?php Akismet::view( 'logo' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="akismet-lower">
|
||||
<?php if ( Akismet::get_api_key() ) { ?>
|
||||
<?php Akismet_Admin::display_status(); ?>
|
||||
<?php } ?>
|
||||
<?php if ( ! empty( $notices ) ) { ?>
|
||||
<?php foreach ( $notices as $notice ) { ?>
|
||||
<?php Akismet::view( 'notice', array_merge( $notice, array( 'parent_view' => $name ) ) ); ?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ( isset( $stat_totals['all'] ) && isset( $stat_totals['6-months'] ) ) : ?>
|
||||
<div class="akismet-card">
|
||||
<div class="akismet-section-header">
|
||||
<h2 class="akismet-section-header__label">
|
||||
<span><?php esc_html_e( 'Statistics', 'akismet' ); ?></span>
|
||||
</h2>
|
||||
|
||||
<div class="akismet-section-header__actions">
|
||||
<a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>">
|
||||
<?php esc_html_e( 'Detailed stats', 'akismet' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div> <!-- close akismet-section-header -->
|
||||
|
||||
<div class="akismet-new-snapshot">
|
||||
<?php /* name attribute on iframe is used as a cache-buster here to force Firefox to load the new style charts: https://bugzilla.mozilla.org/show_bug.cgi?id=356558 */ ?>
|
||||
<div class="akismet-new-snapshot__chart">
|
||||
<iframe id="stats-iframe" allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 220px; overflow: hidden;" src="<?php echo esc_url( sprintf( 'https://tools.akismet.com/1.0/snapshot.php?blog=%s&token=%s&height=200&locale=%s&is_redecorated=1', rawurlencode( get_option( 'home' ) ), rawurlencode( Akismet::get_access_token() ), get_user_locale() ) ); ?>" name="<?php echo esc_attr( 'snapshot-' . filemtime( __FILE__ ) ); ?>" title="<?php echo esc_attr__( 'Akismet stats', 'akismet' ); ?>"></iframe>
|
||||
</div>
|
||||
|
||||
<ul class="akismet-new-snapshot__list">
|
||||
<li class="akismet-new-snapshot__item">
|
||||
<h3 class="akismet-new-snapshot__header"><?php esc_html_e( 'Past six months', 'akismet' ); ?></h3>
|
||||
<span class="akismet-new-snapshot__number"><?php echo number_format( $stat_totals['6-months']->spam ); ?></span>
|
||||
<span class="akismet-new-snapshot__text"><?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['6-months']->spam, 'akismet' ) ); ?></span>
|
||||
</li>
|
||||
<li class="akismet-new-snapshot__item">
|
||||
<h3 class="akismet-new-snapshot__header"><?php esc_html_e( 'All time', 'akismet' ); ?></h3>
|
||||
<span class="akismet-new-snapshot__number"><?php echo number_format( $stat_totals['all']->spam ); ?></span>
|
||||
<span class="akismet-new-snapshot__text"><?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['all']->spam, 'akismet' ) ); ?></span>
|
||||
</li>
|
||||
<li class="akismet-new-snapshot__item">
|
||||
<h3 class="akismet-new-snapshot__header"><?php esc_html_e( 'Accuracy', 'akismet' ); ?></h3>
|
||||
<span class="akismet-new-snapshot__number"><?php echo floatval( $stat_totals['all']->accuracy ); ?>%</span>
|
||||
<span class="akismet-new-snapshot__text">
|
||||
<?php
|
||||
/* translators: %s: number of spam missed by Akismet */
|
||||
echo esc_html( sprintf( _n( '%s missed spam', '%s missed spam', $stat_totals['all']->missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ) ) . ', ';
|
||||
/* translators: %s: number of false positive spam flagged by Akismet */
|
||||
echo esc_html( sprintf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ) );
|
||||
?>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div> <!-- close akismet-new-snapshot -->
|
||||
</div> <!-- close akismet-card -->
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( apply_filters( 'akismet_show_compatible_plugins', true ) ) : ?>
|
||||
<?php Akismet::view( 'compatible-plugins' ); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $akismet_user ) : ?>
|
||||
<div class="akismet-card">
|
||||
<div class="akismet-section-header">
|
||||
<h2 class="akismet-section-header__label">
|
||||
<span><?php esc_html_e( 'Settings', 'akismet' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="inside">
|
||||
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" autocomplete="off" method="POST" id="akismet-settings-form">
|
||||
|
||||
<div class="akismet-settings">
|
||||
<?php if ( ! Akismet::predefined_api_key() ) : ?>
|
||||
<div class="akismet-settings__row">
|
||||
<h3 class="akismet-settings__row-title">
|
||||
<label class="akismet-settings__row-label" for="key"><?php esc_html_e( 'API key', 'akismet' ); ?></label>
|
||||
</h3>
|
||||
<div class="akismet-settings__row-input">
|
||||
<span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option( 'wordpress_api_key' ) ); ?>" class="<?php echo esc_attr( 'regular-text code ' . $akismet_user->status ); ?>"></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
//phpcs:ignore WordPress.Security.NonceVerification.Recommended
|
||||
if ( isset( $_GET['ssl_status'] ) ) :
|
||||
?>
|
||||
<div class="akismet-settings__row">
|
||||
<div class="akismet-settings__row-text">
|
||||
<h3 class="akismet-settings__row-title"><?php esc_html_e( 'SSL status', 'akismet' ); ?></h3>
|
||||
<div class="akismet-settings__row-description">
|
||||
<?php if ( ! wp_http_supports( array( 'ssl' ) ) ) : ?>
|
||||
<strong><?php esc_html_e( 'Disabled.', 'akismet' ); ?></strong>
|
||||
<?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?>
|
||||
<?php else : ?>
|
||||
<?php $ssl_disabled = get_option( 'akismet_ssl_disabled' ); ?>
|
||||
|
||||
<?php if ( $ssl_disabled ) : ?>
|
||||
<strong><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></strong>
|
||||
<?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?>
|
||||
<?php else : ?>
|
||||
<strong><?php esc_html_e( 'Enabled.', 'akismet' ); ?></strong>
|
||||
<?php esc_html_e( 'All systems functional.', 'akismet' ); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="akismet-settings__row">
|
||||
<div class="akismet-settings__row-text">
|
||||
<h3 class="akismet-settings__row-title"><?php esc_html_e( 'Comments', 'akismet' ); ?></h3>
|
||||
</div>
|
||||
<div class="akismet-settings__row-input">
|
||||
<label class="akismet-settings__row-input-label" for="akismet_show_user_comments_approved">
|
||||
<input
|
||||
name="akismet_show_user_comments_approved"
|
||||
id="akismet_show_user_comments_approved"
|
||||
value="1"
|
||||
type="checkbox"
|
||||
<?php
|
||||
// If the option isn't set, or if it's enabled ('1'), or if it was enabled a long time ago ('true'), check the checkbox.
|
||||
checked( true, ( in_array( get_option( 'akismet_show_user_comments_approved' ), array( false, '1', 'true' ), true ) ) );
|
||||
?>
|
||||
/>
|
||||
<span class="akismet-settings__row-label-text">
|
||||
<?php esc_html_e( 'Show the number of approved comments beside each comment author.', 'akismet' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="akismet-settings__row is-radio">
|
||||
<div class="akismet-settings__row-text">
|
||||
<h3 class="akismet-settings__row-title"><?php esc_html_e( 'Spam filtering', 'akismet' ); ?></h3>
|
||||
</div>
|
||||
<div class="akismet-settings__row-input">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span><?php esc_html_e( 'Akismet Anti-spam strictness', 'akismet' ); ?></span>
|
||||
</legend>
|
||||
<div>
|
||||
<label class="akismet-settings__row-input-label" for="akismet_strictness_1">
|
||||
<input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked( '1', get_option( 'akismet_strictness' ) ); ?> />
|
||||
<span class="akismet-settings__row-label-text">
|
||||
<?php esc_html_e( 'Silently discard the worst and most pervasive spam so I never see it.', 'akismet' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="akismet-settings__row-input-label" for="akismet_strictness_0">
|
||||
<input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked( true, get_option( 'akismet_strictness' ) !== '1' ); ?> />
|
||||
<span class="akismet-settings__row-label-text">
|
||||
<?php esc_html_e( 'Always put spam in the Spam folder for review.', 'akismet' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="akismet-settings__row-note">
|
||||
<strong><?php esc_html_e( 'Note:', 'akismet' ); ?></strong>
|
||||
<?php
|
||||
$delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
|
||||
|
||||
$spam_folder_link = sprintf(
|
||||
'<a href="%s">%s</a>',
|
||||
esc_url( admin_url( 'edit-comments.php?comment_status=spam' ) ),
|
||||
esc_html__( 'spam folder', 'akismet' )
|
||||
);
|
||||
|
||||
// The _n() needs to be on one line so the i18n tooling can extract the translator comment.
|
||||
/* translators: %1$s: spam folder link, %2$d: delete interval in days */
|
||||
$delete_message = _n( 'Spam in the %1$s older than %2$d day is deleted automatically.', 'Spam in the %1$s older than %2$d days is deleted automatically.', $delete_interval, 'akismet' );
|
||||
|
||||
printf(
|
||||
wp_kses( $delete_message, $kses_allow_link_href ),
|
||||
wp_kses( $spam_folder_link, $kses_allow_link_href ),
|
||||
esc_html( $delete_interval )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="akismet-settings__row is-radio">
|
||||
<div class="akismet-settings__row-text">
|
||||
<h3 class="akismet-settings__row-title"><?php esc_html_e( 'Privacy', 'akismet' ); ?></h3>
|
||||
</div>
|
||||
<div class="akismet-settings__row-input">
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span><?php esc_html_e( 'Akismet privacy notice', 'akismet' ); ?></span>
|
||||
</legend>
|
||||
<div>
|
||||
<label class="akismet-settings__row-input-label" for="akismet_comment_form_privacy_notice_display">
|
||||
<input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_display" value="display" <?php checked( 'display', get_option( 'akismet_comment_form_privacy_notice' ) ); ?> />
|
||||
<span class="akismet-settings__row-label-text">
|
||||
<?php esc_html_e( 'Display a privacy notice under your comment forms.', 'akismet' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label class="akismet-settings__row-input-label" for="akismet_comment_form_privacy_notice_hide">
|
||||
<input type="radio" name="akismet_comment_form_privacy_notice" id="akismet_comment_form_privacy_notice_hide" value="hide" <?php echo in_array( get_option( 'akismet_comment_form_privacy_notice' ), array( 'display', 'hide' ), true ) ? checked( 'hide', get_option( 'akismet_comment_form_privacy_notice' ), false ) : 'checked="checked"'; ?> />
|
||||
<span class="akismet-settings__row-label-text">
|
||||
<?php esc_html_e( 'Do not display privacy notice.', 'akismet' ); ?>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="akismet-settings__row-note">
|
||||
<?php esc_html_e( 'To help your site with transparency under privacy laws like the GDPR, Akismet can display a notice to your users under your comment forms.', 'akismet' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="akismet-card-actions">
|
||||
<?php if ( ! Akismet::predefined_api_key() ) : ?>
|
||||
<div id="delete-action" class="akismet-card-actions__secondary-action">
|
||||
<a class="submitdelete deletion" href="<?php echo esc_url( Akismet_Admin::get_page_url( 'delete_key' ) ); ?>"><?php esc_html_e( 'Disconnect this account', 'akismet' ); ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ); ?>
|
||||
|
||||
<div id="publishing-action">
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<input type="submit" name="submit" id="submit" class="akismet-button akismet-could-be-primary" value="<?php esc_attr_e( 'Save changes', 'akismet' ); ?>">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( ! Akismet::predefined_api_key() ) : ?>
|
||||
<div class="akismet-card">
|
||||
<div class="akismet-section-header">
|
||||
<h2 class="akismet-section-header__label">
|
||||
<span><?php esc_html_e( 'Account', 'akismet' ); ?></span>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="inside">
|
||||
<table class="akismet-account">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Subscription type', 'akismet' ); ?></th>
|
||||
<td>
|
||||
<?php echo esc_html( $akismet_user->account_name ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Status', 'akismet' ); ?></th>
|
||||
<td>
|
||||
<?php
|
||||
if ( Akismet::USER_STATUS_CANCELLED === $akismet_user->status ) :
|
||||
esc_html_e( 'Cancelled', 'akismet' );
|
||||
elseif ( Akismet::USER_STATUS_SUSPENDED === $akismet_user->status ) :
|
||||
esc_html_e( 'Suspended', 'akismet' );
|
||||
elseif ( Akismet::USER_STATUS_MISSING === $akismet_user->status ) :
|
||||
esc_html_e( 'Missing', 'akismet' );
|
||||
elseif ( Akismet::USER_STATUS_NO_SUB === $akismet_user->status ) :
|
||||
esc_html_e( 'No subscription found', 'akismet' );
|
||||
else :
|
||||
esc_html_e( 'Active', 'akismet' );
|
||||
endif;
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $akismet_user->next_billing_date ) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Next billing date', 'akismet' ); ?></th>
|
||||
<td>
|
||||
<?php echo esc_html( gmdate( 'F j, Y', $akismet_user->next_billing_date ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="akismet-card-actions">
|
||||
<?php if ( $akismet_user->status === Akismet::USER_STATUS_ACTIVE ) : ?>
|
||||
<div class="akismet-card-actions__secondary-action">
|
||||
<a href="https://akismet.com/account?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=account_overview" class="akismet-external-link" aria-label="Account overview on akismet.com"><?php esc_html_e( 'Account overview', 'akismet' ); ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="publishing-action">
|
||||
<?php
|
||||
Akismet::view(
|
||||
'get',
|
||||
array(
|
||||
'text' => ( $akismet_user->account_type === 'free-api-key' && $akismet_user->status === Akismet::USER_STATUS_ACTIVE ? __( 'Upgrade', 'akismet' ) : __( 'Change', 'akismet' ) ),
|
||||
'redirect' => 'upgrade',
|
||||
'utm_content' => ( $akismet_user->account_type === 'free-api-key' && $akismet_user->status === Akismet::USER_STATUS_ACTIVE ? 'config_upgrade' : 'config_change' ),
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
14
wp-content/plugins/akismet/views/connect-jp.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
?>
|
||||
<div class="akismet-box">
|
||||
<?php Akismet::view( 'setup', array( 'use_jetpack_connection' => true ) ); ?>
|
||||
<?php Akismet::view( 'setup-jetpack', array( 'akismet_user' => $akismet_user ) ); ?>
|
||||
</div>
|
||||
|
||||
<div class="akismet-box">
|
||||
<?php Akismet::view( 'enter' ); ?>
|
||||
</div>
|
||||
14
wp-content/plugins/akismet/views/enter.php
Normal file
@ -0,0 +1,14 @@
|
||||
<div class="akismet-enter-api-key-box centered">
|
||||
<button class="akismet-enter-api-key-box__reveal"><?php esc_html_e( 'Manually enter an API key', 'akismet' ); ?></button>
|
||||
<div class="akismet-enter-api-key-box__form-wrapper">
|
||||
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ); ?>
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<h3 class="akismet-enter-api-key-box__header" id="akismet-enter-api-key-box__header"><?php esc_html_e( 'Enter your API key', 'akismet' ); ?></h3>
|
||||
<div class="akismet-enter-api-key-box__input-wrapper">
|
||||
<input id="key" name="key" type="text" size="15" value="" placeholder="<?php esc_attr_e( 'API key', 'akismet' ); ?>" class="akismet-enter-api-key-box__key-input regular-text code" aria-labelledby="akismet-enter-api-key-box__header">
|
||||
<input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' ); ?>">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
32
wp-content/plugins/akismet/views/get.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
|
||||
$submit_classes_attr = 'akismet-button';
|
||||
|
||||
if ( isset( $classes ) && ( is_countable( $classes ) ? count( $classes ) : 0 ) > 0 ) {
|
||||
$submit_classes_attr = implode( ' ', $classes );
|
||||
}
|
||||
|
||||
$query_args = array(
|
||||
'passback_url' => Akismet_Admin::get_page_url(),
|
||||
'redirect' => isset( $redirect ) ? $redirect : 'plugin-signup',
|
||||
);
|
||||
|
||||
// Set default UTM parameters, overriding with any provided values.
|
||||
$utm_args = array(
|
||||
'utm_source' => isset( $utm_source ) ? $utm_source : 'akismet_plugin',
|
||||
'utm_medium' => isset( $utm_medium ) ? $utm_medium : 'in_plugin',
|
||||
'utm_campaign' => isset( $utm_campaign ) ? $utm_campaign : 'plugin_static_link',
|
||||
'utm_content' => isset( $utm_content ) ? $utm_content : 'get_view_link',
|
||||
);
|
||||
|
||||
$query_args = array_merge( $query_args, $utm_args );
|
||||
|
||||
$url = add_query_arg( $query_args, 'https://akismet.com/get/' );
|
||||
?>
|
||||
<a href="<?php echo esc_url( $url ); ?>" class="<?php echo esc_attr( $submit_classes_attr ); ?>" target="_blank">
|
||||
<?php echo esc_html( is_string( $text ) ? $text : '' ); ?>
|
||||
<span class="screen-reader-text"><?php esc_html_e( '(opens in a new tab)', 'akismet' ); ?></span>
|
||||
</a>
|
||||
13
wp-content/plugins/akismet/views/logo.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
?>
|
||||
<div class="akismet-masthead__logo-container">
|
||||
<?php if ( isset( $include_logo_link ) && $include_logo_link === true ) : ?>
|
||||
<a href="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" class="akismet-masthead__logo-link">
|
||||
<?php endif; ?>
|
||||
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/akismet-refresh-logo@2x.png', __FILE__ ) ); ?>" srcset="<?php echo esc_url( plugins_url( '../_inc/img/akismet-refresh-logo.svg', __FILE__ ) ); ?>" alt="Akismet logo" />
|
||||
<?php if ( isset( $include_logo_link ) && $include_logo_link === true ) : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
379
wp-content/plugins/akismet/views/notice.php
Normal file
@ -0,0 +1,379 @@
|
||||
<?php
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
$kses_allow_link = array(
|
||||
'a' => array(
|
||||
'href' => true,
|
||||
'target' => true,
|
||||
'class' => true,
|
||||
),
|
||||
);
|
||||
$kses_allow_strong = array( 'strong' => true );
|
||||
|
||||
if ( ! isset( $type ) ) {
|
||||
$type = false; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||
}
|
||||
|
||||
/*
|
||||
* Some notices (plugin, spam-check, spam-check-cron-disabled, alert and usage-limit) are also shown elsewhere in wp-admin, so have different classes applied so that they match the standard WordPress notice format.
|
||||
*/
|
||||
?>
|
||||
<?php if ( $type === 'plugin' ) : ?>
|
||||
<?php // Displayed on edit-comments.php to users who have not set up Akismet yet. ?>
|
||||
<div class="updated" id="akismet-setup-prompt">
|
||||
<form name="akismet_activate" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
|
||||
<div class="akismet-activate">
|
||||
<input type="submit" class="akismet-activate__button akismet-button" value="<?php esc_attr_e( 'Set up your Akismet account', 'akismet' ); ?>" />
|
||||
<div class="akismet-activate__description">
|
||||
<?php esc_html_e( 'Almost done! Configure Akismet and say goodbye to spam', 'akismet' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<?php elseif ( $type === 'spam-check' ) : ?>
|
||||
<?php // This notice is only displayed on edit-comments.php. ?>
|
||||
<div class="notice notice-warning">
|
||||
<p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p>
|
||||
<p><?php esc_html_e( 'Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation and will automatically be rechecked later.', 'akismet' ); ?></p>
|
||||
<?php if ( ! empty( $link_text ) ) : ?>
|
||||
<p><?php echo wp_kses( $link_text, $kses_allow_link ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'spam-check-cron-disabled' ) : ?>
|
||||
<?php // This notice is only displayed on edit-comments.php. ?>
|
||||
<div class="notice notice-warning">
|
||||
<p><strong><?php esc_html_e( 'Akismet has detected a problem.', 'akismet' ); ?></strong></p>
|
||||
<p><?php esc_html_e( 'WP-Cron has been disabled using the DISABLE_WP_CRON constant. Comment rechecks may not work properly.', 'akismet' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'alert' && $code === Akismet::ALERT_CODE_COMMERCIAL && isset( $parent_view ) && $parent_view === 'config' ) : ?>
|
||||
<?php // Display a different commercial warning alert on the config page ?>
|
||||
<div class="akismet-card akismet-alert is-commercial">
|
||||
<div>
|
||||
<h3 class="akismet-alert-header"><?php esc_html_e( 'We detected commercial activity on your site', 'akismet' ); ?></h3>
|
||||
<p class="akismet-alert-info">
|
||||
<?php
|
||||
/* translators: The placeholder is a URL. */
|
||||
echo wp_kses( sprintf( __( 'Your current subscription is for <a class="akismet-external-link" href="%s">personal, non-commercial use</a>. Please upgrade your plan to continue using Akismet.', 'akismet' ), esc_url( 'https://akismet.com/support/getting-started/free-or-paid/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=commercial_support' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
<p class="akismet-alert-info">
|
||||
<?php
|
||||
/* translators: The placeholder is a URL to the contact form. */
|
||||
echo wp_kses( sprintf( __( 'If you believe your site should not be classified as commercial, <a class="akismet-external-link" href="%s">please get in touch</a>', 'akismet' ), esc_url( 'https://akismet.com/contact/?purpose=commercial&utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=commercial_contact' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="akismet-alert-button-wrapper">
|
||||
<?php
|
||||
Akismet::view(
|
||||
'get',
|
||||
array(
|
||||
'text' => __( 'Upgrade plan', 'akismet' ),
|
||||
'classes' => array( 'akismet-alert-button', 'akismet-button' ),
|
||||
'redirect' => 'upgrade',
|
||||
'utm_content' => 'commercial_upgrade',
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'alert' ) : ?>
|
||||
<div class="<?php echo isset( $parent_view ) && $parent_view === 'config' ? 'akismet-alert is-bad' : 'error'; ?>">
|
||||
<?php /* translators: The placeholder is an error code returned by Akismet. */ ?>
|
||||
<p><strong><?php printf( esc_html__( 'Akismet error code: %s', 'akismet' ), esc_html( $code ) ); ?></strong></p>
|
||||
<p><?php echo isset( $msg ) ? esc_html( $msg ) : ''; ?></p>
|
||||
<p>
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf(
|
||||
/* translators: the placeholder is a clickable URL that leads to more information regarding an error code. */
|
||||
__( 'For more information, see the <a class="akismet-external-link" href="%s">error documentation on akismet.com</a>', 'akismet' ),
|
||||
esc_url( 'https://akismet.com/developers/detailed-docs/errors/akismet-error-' . absint( $code ) . '?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=error_info' )
|
||||
),
|
||||
$kses_allow_link
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'notice' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php echo wp_kses( $notice_header, Akismet_Admin::get_notice_kses_allowed_elements() ); ?></h3>
|
||||
<p>
|
||||
<?php echo wp_kses( $notice_text, Akismet_Admin::get_notice_kses_allowed_elements() ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'missing-functions' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'Network functions are disabled.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
echo wp_kses( __( 'Your web host or server administrator has disabled PHP’s <code>gethostbynamel</code> function.', 'akismet' ), array_merge( $kses_allow_link, $kses_allow_strong, array( 'code' => true ) ) );
|
||||
?>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: The placeholder is a URL. */
|
||||
echo wp_kses( sprintf( __( 'Please contact your web host or firewall administrator and give them <a class="akismet-external-link" href="%s" target="_blank">this information about Akismet’s system requirements</a>', 'akismet' ), esc_url( 'https://akismet.com/akismet-hosting-faq/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=hosting_faq_php' ) ), array_merge( $kses_allow_link, $kses_allow_strong, array( 'code' => true ) ) );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'servers-be-down' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'Your site can’t connect to the Akismet servers.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: The placeholder is a URL. */
|
||||
echo wp_kses( sprintf( __( 'Your firewall may be blocking Akismet from connecting to its API. Please contact your host and refer to <a class="akismet-external-link" href="%s" target="_blank">our guide about firewalls</a>', 'akismet' ), esc_url( 'https://akismet.com/akismet-hosting-faq/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=hosting_faq_firewall' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'active-dunning' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'Please update your payment information.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: The placeholder is a URL. */
|
||||
echo wp_kses( sprintf( __( 'We cannot process your payment. Please <a class="akismet-external-link" href="%s" target="_blank">update your payment details</a>', 'akismet' ), esc_url( 'https://wordpress.com/me/purchases/payment-methods?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=payment_update' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'cancelled' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet plan has been cancelled.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: The placeholder is a URL. */
|
||||
echo wp_kses( sprintf( __( 'Please visit <a class="akismet-external-link" href="%s" target="_blank">Akismet.com</a> to purchase a new subscription.', 'akismet' ), esc_url( 'https://akismet.com/pricing/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=pricing_cancelled' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'suspended' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'Your Akismet subscription is suspended.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: The placeholder is a URL. */
|
||||
echo wp_kses( sprintf( __( 'Please contact <a class="akismet-external-link" href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet' ), esc_url( 'https://akismet.com/contact/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=support_suspended' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'active-notice' && $time_saved ) : ?>
|
||||
<div class="akismet-alert is-neutral">
|
||||
<h3 class="akismet-alert__heading"><?php echo esc_html( $time_saved ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: the placeholder is a clickable URL to the Akismet account upgrade page. */
|
||||
echo wp_kses( sprintf( __( 'You can help us fight spam and upgrade your account by <a class="akismet-external-link" href="%s" target="_blank">contributing a token amount</a>', 'akismet' ), esc_url( 'https://akismet.com/pricing?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=upgrade_contribution' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'missing' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'There is a problem with your API key.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: The placeholder is a URL to the Akismet contact form. */
|
||||
echo wp_kses( sprintf( __( 'Please contact <a class="akismet-external-link" href="%s" target="_blank">Akismet support</a> for assistance.', 'akismet' ), esc_url( 'https://akismet.com/contact/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=support_missing' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'no-sub' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'You don’t have an Akismet plan.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
/* translators: the placeholder is the URL to the Akismet pricing page. */
|
||||
echo wp_kses( sprintf( __( 'Please <a class="akismet-external-link" href="%s" target="_blank">choose a free or paid plan</a> so Akismet can protect your site from spam.', 'akismet' ), esc_url( 'https://akismet.com/pricing?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=choose_plan' ) ), $kses_allow_link );
|
||||
?>
|
||||
</p>
|
||||
<p><?php echo esc_html__( 'Once you\'ve chosen a plan, return here to complete your setup.', 'akismet' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'new-key-valid' ) : ?>
|
||||
<?php
|
||||
global $wpdb;
|
||||
|
||||
$check_pending_link = false;
|
||||
|
||||
$at_least_one_comment_in_moderation = ! ! $wpdb->get_var( "SELECT comment_ID FROM {$wpdb->comments} WHERE comment_approved = '0' LIMIT 1" );
|
||||
|
||||
if ( $at_least_one_comment_in_moderation ) {
|
||||
$check_pending_link = 'edit-comments.php?akismet_recheck=' . wp_create_nonce( 'akismet_recheck' );
|
||||
}
|
||||
?>
|
||||
<div class="akismet-alert is-good">
|
||||
<p><?php esc_html_e( 'Akismet is now protecting your site from spam.', 'akismet' ); ?></p>
|
||||
<?php if ( $check_pending_link ) : ?>
|
||||
<p>
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf(
|
||||
/* translators: The placeholder is a URL for checking pending comments. */
|
||||
__( 'Would you like to <a href="%s">check pending comments</a>?', 'akismet' ),
|
||||
esc_url( $check_pending_link )
|
||||
),
|
||||
$kses_allow_link
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'new-key-invalid' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<p><?php esc_html_e( 'The key you entered is invalid. Please double-check it.', 'akismet' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === Akismet_Admin::NOTICE_EXISTING_KEY_INVALID ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php echo esc_html( __( 'Your API key is no longer valid.', 'akismet' ) ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf(
|
||||
/* translators: The placeholder is a URL to the Akismet contact form. */
|
||||
__( 'Please enter a new key or <a class="akismet-external-link" href="%s" target="_blank">contact Akismet support</a>', 'akismet' ),
|
||||
'https://akismet.com/contact/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=support_invalid_key'
|
||||
),
|
||||
$kses_allow_link
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'new-key-failed' ) : ?>
|
||||
<div class="akismet-alert is-bad">
|
||||
<h3 class="akismet-alert__heading"><?php esc_html_e( 'The API key you entered could not be verified.', 'akismet' ); ?></h3>
|
||||
<p>
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf(
|
||||
/* translators: The placeholder is a URL. */
|
||||
__( 'The connection to akismet.com could not be established. Please refer to <a class="akismet-external-link" href="%s" target="_blank">our guide about firewalls</a> and check your server configuration.', 'akismet' ),
|
||||
'https://akismet.com/akismet-hosting-faq/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=hosting_faq'
|
||||
),
|
||||
$kses_allow_link
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php elseif ( $type === 'usage-limit' && isset( Akismet::$limit_notices[ $code ] ) ) : ?>
|
||||
<div class="error akismet-usage-limit-alert">
|
||||
<div class="akismet-usage-limit-logo">
|
||||
<img src="<?php echo esc_url( plugins_url( '../_inc/img/logo-a-2x.png', __FILE__ ) ); ?>" alt="Akismet logo" />
|
||||
</div>
|
||||
<div class="akismet-usage-limit-text">
|
||||
<h3>
|
||||
<?php
|
||||
switch ( Akismet::$limit_notices[ $code ] ) {
|
||||
case 'FIRST_MONTH_OVER_LIMIT':
|
||||
case 'SECOND_MONTH_OVER_LIMIT':
|
||||
esc_html_e( 'Your Akismet account usage is over your plan’s limit', 'akismet' );
|
||||
break;
|
||||
case 'THIRD_MONTH_APPROACHING_LIMIT':
|
||||
esc_html_e( 'Your Akismet account usage is approaching your plan’s limit', 'akismet' );
|
||||
break;
|
||||
case 'THIRD_MONTH_OVER_LIMIT':
|
||||
case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
|
||||
esc_html_e( 'Your account has been restricted', 'akismet' );
|
||||
break;
|
||||
default:
|
||||
}
|
||||
?>
|
||||
</h3>
|
||||
<p>
|
||||
<?php
|
||||
switch ( Akismet::$limit_notices[ $code ] ) {
|
||||
case 'FIRST_MONTH_OVER_LIMIT':
|
||||
echo esc_html(
|
||||
sprintf(
|
||||
/* translators: The first placeholder is a date, the second is a (formatted) number, the third is another formatted number. */
|
||||
__( 'Since %1$s, your account made %2$s API calls, compared to your plan’s limit of %3$s.', 'akismet' ),
|
||||
esc_html( gmdate( 'F' ) . ' 1' ),
|
||||
number_format( $api_calls ),
|
||||
number_format( $usage_limit )
|
||||
)
|
||||
);
|
||||
echo ' ';
|
||||
echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank">';
|
||||
echo esc_html( __( 'Learn more about usage limits', 'akismet' ) );
|
||||
echo '</a>';
|
||||
|
||||
break;
|
||||
case 'SECOND_MONTH_OVER_LIMIT':
|
||||
echo esc_html( __( 'Your Akismet usage has been over your plan’s limit for two consecutive months. Next month, we will restrict your account after you reach the limit. Increase your limit to make sure your site stays protected from spam.', 'akismet' ) );
|
||||
echo ' ';
|
||||
echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank">';
|
||||
echo esc_html( __( 'Learn more about usage limits', 'akismet' ) );
|
||||
echo '</a>';
|
||||
|
||||
break;
|
||||
case 'THIRD_MONTH_APPROACHING_LIMIT':
|
||||
echo esc_html( __( 'Your Akismet usage is nearing your plan’s limit for the third consecutive month. We will restrict your account after you reach the limit. Increase your limit to make sure your site stays protected from spam.', 'akismet' ) );
|
||||
echo ' ';
|
||||
echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank">';
|
||||
echo esc_html( __( 'Learn more about usage limits', 'akismet' ) );
|
||||
echo '</a>';
|
||||
|
||||
break;
|
||||
case 'THIRD_MONTH_OVER_LIMIT':
|
||||
case 'FOUR_PLUS_MONTHS_OVER_LIMIT':
|
||||
echo esc_html( __( 'Your Akismet usage has been over your plan’s limit for three consecutive months. We have restricted your account for the rest of the month. Increase your limit to make sure your site stays protected from spam.', 'akismet' ) );
|
||||
echo ' ';
|
||||
echo '<a class="akismet-external-link" href="https://akismet.com/support/general/akismet-api-usage-limits/?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_docs" target="_blank">';
|
||||
echo esc_html( __( 'Learn more about usage limits', 'akismet' ) );
|
||||
echo '</a>';
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="akismet-usage-limit-cta">
|
||||
<a href="<?php echo esc_attr( $upgrade_url . ( strpos( $upgrade_url, '?' ) !== false ? '&' : '?' ) . 'utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=usage_limit_upgrade' ); ?>" class="button" target="_blank">
|
||||
<?php
|
||||
if ( isset( $upgrade_via_support ) && $upgrade_via_support ) {
|
||||
// Direct user to contact support.
|
||||
esc_html_e( 'Contact Akismet support', 'akismet' );
|
||||
} elseif ( ! empty( $upgrade_type ) && 'qty' === $upgrade_type ) {
|
||||
// If a qty upgrade is required, use recommended plan name if available.
|
||||
if ( ! empty( $recommended_plan_name ) && is_string( $recommended_plan_name ) ) {
|
||||
echo esc_html(
|
||||
sprintf(
|
||||
/* translators: The placeholder is the name of an Akismet subscription plan, like "Akismet Pro" or "Akismet Business" . */
|
||||
__( 'Add an %s subscription', 'akismet' ),
|
||||
$recommended_plan_name
|
||||
)
|
||||
);
|
||||
} else {
|
||||
esc_html_e( 'Increase your limit', 'akismet' );
|
||||
}
|
||||
} else {
|
||||
echo esc_html(
|
||||
sprintf(
|
||||
/* translators: The placeholder is the name of a subscription level, like "Akismet Business" or "Akismet Enterprise" . */
|
||||
__( 'Upgrade to %s', 'akismet' ),
|
||||
$upgrade_plan
|
||||
)
|
||||
);
|
||||
}
|
||||
?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
11
wp-content/plugins/akismet/views/predefined.php
Normal file
@ -0,0 +1,11 @@
|
||||
<div class="akismet-box">
|
||||
<h2><?php esc_html_e( 'Manual Configuration', 'akismet' ); ?></h2>
|
||||
<p>
|
||||
<?php
|
||||
|
||||
/* translators: %s is the wp-config.php file */
|
||||
printf( esc_html__( 'An Akismet API key has been defined in the %s file for this site.', 'akismet' ), '<code>wp-config.php</code>' );
|
||||
|
||||
?>
|
||||
</p>
|
||||
</div>
|
||||
97
wp-content/plugins/akismet/views/setup-jetpack.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
|
||||
$user_status = $akismet_user->status ?? null;
|
||||
?>
|
||||
<div class="akismet-setup__connection">
|
||||
<?php if ( ! empty( $akismet_user->user_email ) && ! empty( $akismet_user->user_login ) ) : ?>
|
||||
<div class="akismet-setup__connection-user">
|
||||
<div class="akismet-setup__connection-avatar">
|
||||
<?php
|
||||
// Decorative avatar; empty alt for screen readers.
|
||||
echo get_avatar(
|
||||
$akismet_user->user_email,
|
||||
48,
|
||||
'',
|
||||
'',
|
||||
array(
|
||||
'class' => 'akismet-setup__connection-avatar-image',
|
||||
'alt' => '',
|
||||
)
|
||||
);
|
||||
?>
|
||||
<div class="akismet-setup__connection-account">
|
||||
<div class="akismet-setup__connection-account-name">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s is the WordPress.com username */
|
||||
esc_html__( 'Signed in as %s', 'akismet' ),
|
||||
'<strong>' . esc_html( $akismet_user->user_login ) . '</strong>'
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<div class="akismet-setup__connection-account-email"><?php echo esc_html( $akismet_user->user_email ); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="akismet-setup__connection-action">
|
||||
<?php if ( in_array( $user_status, array( Akismet::USER_STATUS_CANCELLED, Akismet::USER_STATUS_MISSING, Akismet::USER_STATUS_NO_SUB ) ) ) : ?>
|
||||
|
||||
<p class="akismet-setup__connection-action-intro">
|
||||
<?php esc_html_e( "Your Jetpack account is connected, but it doesn't have an active Akismet subscription yet. To continue, please choose a plan on Akismet.com.", 'akismet' ); ?>
|
||||
</p>
|
||||
|
||||
<a href="https://akismet.com/get?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=jetpack_flow_<?php echo esc_attr( str_replace( '-', '_', $user_status ) ); ?>" class="akismet-setup__connection-button akismet-button">
|
||||
<?php esc_html_e( 'Choose a plan on Akismet.com', 'akismet' ); ?>
|
||||
</a>
|
||||
|
||||
<p class="akismet-setup__connection-action-description">
|
||||
<?php esc_html_e( "Once you've chosen a plan, return here to complete your setup.", 'akismet' ); ?>
|
||||
</p>
|
||||
|
||||
<?php elseif ( $user_status === Akismet::USER_STATUS_SUSPENDED ) : ?>
|
||||
<p class="akismet-setup__connection-action-intro">
|
||||
<?php esc_html_e( "Your Akismet account appears to be suspended. This sometimes happens if there's a billing or verification issue. Please contact our support team so we can help you get it sorted.", 'akismet' ); ?>
|
||||
</p>
|
||||
|
||||
<a href="https://akismet.com/contact?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=jetpack_flow_suspended" class="akismet-setup__connection-button akismet-button">
|
||||
<?php esc_html_e( 'Contact support', 'akismet' ); ?>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate">
|
||||
<input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key ); ?>"/>
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ); ?>
|
||||
<input type="submit" class="akismet-setup__connection-button akismet-button" value="<?php esc_attr_e( 'Connect with Jetpack', 'akismet' ); ?>"/>
|
||||
</form>
|
||||
|
||||
<p class="akismet-setup__connection-action-description">
|
||||
<?php esc_html_e( "By connecting, we'll use your Jetpack account to activate Akismet on this site.", 'akismet' ); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! in_array( $user_status, array( Akismet::USER_STATUS_CANCELLED, Akismet::USER_STATUS_MISSING, Akismet::USER_STATUS_NO_SUB ) ) ) : ?>
|
||||
<p class="akismet-setup__connection-action-description">
|
||||
<?php
|
||||
echo wp_kses(
|
||||
sprintf(
|
||||
/* translators: The placeholder is a URL. */
|
||||
__( 'Want to use a different account? <a href="%s" class="akismet-external-link">Visit akismet.com</a> to set it up and get your API key.', 'akismet' ),
|
||||
esc_url( 'https://akismet.com/get?utm_source=akismet_plugin&utm_campaign=plugin_static_link&utm_medium=in_plugin&utm_content=jetpack_flow_different_account' )
|
||||
),
|
||||
array(
|
||||
'a' => array(
|
||||
'href' => array(),
|
||||
'class' => array(),
|
||||
),
|
||||
)
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
78
wp-content/plugins/akismet/views/setup.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
|
||||
$tick_icon = '<svg class="akismet-setup-instructions__icon" width="48" height="48" viewBox="0 0 48 48" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg">
|
||||
<circle cx="24" cy="24" r="22" fill="#2E7D32"/>
|
||||
<path d="M16 24l6 6 12-14" fill="none" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>';
|
||||
?>
|
||||
<section class="akismet-setup-instructions">
|
||||
<h2 class="akismet-setup-instructions__heading"><?php esc_html_e( 'Eliminate spam from your site', 'akismet' ); ?></h2>
|
||||
|
||||
<h3 class="akismet-setup-instructions__subheading">
|
||||
<?php echo esc_html__( 'Protect your site from comment spam and contact form spam — automatically.', 'akismet' ); ?>
|
||||
</h3>
|
||||
|
||||
<ul class="akismet-setup-instructions__feature-list">
|
||||
<li class="akismet-setup-instructions__feature">
|
||||
<?php echo $tick_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="akismet-setup-instructions__body">
|
||||
<h4 class="akismet-setup-instructions__title">
|
||||
<?php echo esc_html__( 'Machine learning accuracy', 'akismet' ); ?>
|
||||
</h4>
|
||||
<p class="akismet-setup-instructions__text">
|
||||
<?php echo esc_html__( 'Learns from billions of spam signals across the web to stop junk before it reaches you.', 'akismet' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
<li class="akismet-setup-instructions__feature">
|
||||
<?php echo $tick_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="akismet-setup-instructions__body">
|
||||
<h4 class="akismet-setup-instructions__title">
|
||||
<?php echo esc_html__( 'Zero effort', 'akismet' ); ?>
|
||||
</h4>
|
||||
<p class="akismet-setup-instructions__text">
|
||||
<?php echo esc_html__( 'Akismet runs quietly in the background, saving you hours of manual moderation.', 'akismet' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
<li class="akismet-setup-instructions__feature">
|
||||
<?php echo $tick_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="akismet-setup-instructions__body">
|
||||
<h4 class="akismet-setup-instructions__title">
|
||||
<?php echo esc_html__( 'Works with popular contact forms', 'akismet' ); ?>
|
||||
</h4>
|
||||
<p class="akismet-setup-instructions__text">
|
||||
<?php echo esc_html__( 'Seamlessly integrates with plugins like Elementor, Contact Form 7, Jetpack and WPForms.', 'akismet' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
<li class="akismet-setup-instructions__feature">
|
||||
<?php echo $tick_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
<div class="akismet-setup-instructions__body">
|
||||
<h4 class="akismet-setup-instructions__title">
|
||||
<?php echo esc_html__( 'Flexible pricing', 'akismet' ); ?>
|
||||
</h4>
|
||||
<p class="akismet-setup-instructions__text">
|
||||
<?php echo esc_html__( 'Name your own price for personal sites. Businesses start on a paid plan.', 'akismet' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
if ( empty( $use_jetpack_connection ) ) :
|
||||
Akismet::view(
|
||||
'get',
|
||||
array(
|
||||
'text' => __( 'Get started', 'akismet' ),
|
||||
'classes' => array( 'akismet-button', 'akismet-is-primary', 'akismet-setup-instructions__button' ),
|
||||
'utm_content' => 'setup_instructions',
|
||||
)
|
||||
);
|
||||
endif;
|
||||
?>
|
||||
</section>
|
||||
26
wp-content/plugins/akismet/views/start.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
//phpcs:disable VariableAnalysis
|
||||
// There are "undefined" variables here because they're defined in the code that includes this file as a template.
|
||||
?>
|
||||
<div id="akismet-plugin-container">
|
||||
<div class="akismet-masthead">
|
||||
<div class="akismet-masthead__inside-container">
|
||||
<?php Akismet::view( 'logo' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="akismet-lower">
|
||||
<?php Akismet_Admin::display_status(); ?>
|
||||
<div class="akismet-boxes">
|
||||
<?php
|
||||
if ( Akismet::predefined_api_key() ) {
|
||||
Akismet::view( 'predefined' );
|
||||
} elseif ( $akismet_user && in_array( $akismet_user->status, array( Akismet::USER_STATUS_ACTIVE, 'active-dunning', Akismet::USER_STATUS_NO_SUB, Akismet::USER_STATUS_MISSING, Akismet::USER_STATUS_CANCELLED, Akismet::USER_STATUS_SUSPENDED ) ) ) {
|
||||
Akismet::view( 'connect-jp', compact( 'akismet_user' ) );
|
||||
} else {
|
||||
Akismet::view( 'activate' );
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
12
wp-content/plugins/akismet/views/stats.php
Normal file
@ -0,0 +1,12 @@
|
||||
<div id="akismet-plugin-container">
|
||||
<div class="akismet-masthead">
|
||||
<div class="akismet-masthead__inside-container">
|
||||
<?php Akismet::view( 'logo', array( 'include_logo_link' => true ) ); ?>
|
||||
<div class="akismet-masthead__back-link-container">
|
||||
<a class="akismet-masthead__back-link" href="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"><?php esc_html_e( 'Back to settings', 'akismet' ); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php /* name attribute on iframe is used as a cache-buster here to force Firefox to load the new style charts: https://bugzilla.mozilla.org/show_bug.cgi?id=356558 */ ?>
|
||||
<iframe id="stats-iframe" src="<?php echo esc_url( sprintf( 'https://tools.akismet.com/1.0/user-stats.php?blog=%s&token=%s&locale=%s&is_redecorated=1', urlencode( get_option( 'home' ) ), urlencode( Akismet::get_access_token() ), esc_attr( get_user_locale() ) ) ); ?>" name="<?php echo esc_attr( 'user-stats- ' . filemtime( __FILE__ ) ); ?>" width="100%" height="2500px" frameborder="0" title="<?php echo esc_attr__( 'Akismet detailed stats', 'akismet' ); ?>"></iframe>
|
||||
</div>
|
||||
215
wp-content/plugins/akismet/wrapper.php
Normal file
@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
global $wpcom_api_key, $akismet_api_host, $akismet_api_port;
|
||||
|
||||
$wpcom_api_key = defined( 'WPCOM_API_KEY' ) ? constant( 'WPCOM_API_KEY' ) : '';
|
||||
$akismet_api_host = Akismet::get_api_key() . '.rest.akismet.com';
|
||||
$akismet_api_port = 80;
|
||||
|
||||
function akismet_test_mode() {
|
||||
return Akismet::is_test_mode();
|
||||
}
|
||||
|
||||
function akismet_http_post( $request, $host, $path, $port = 80, $ip = null ) {
|
||||
$path = str_replace( '/1.1/', '', $path );
|
||||
|
||||
return Akismet::http_post( $request, $path, $ip );
|
||||
}
|
||||
|
||||
function akismet_microtime() {
|
||||
return Akismet::_get_microtime();
|
||||
}
|
||||
|
||||
function akismet_delete_old() {
|
||||
return Akismet::delete_old_comments();
|
||||
}
|
||||
|
||||
function akismet_delete_old_metadata() {
|
||||
return Akismet::delete_old_comments_meta();
|
||||
}
|
||||
|
||||
function akismet_check_db_comment( $id, $recheck_reason = 'recheck_queue' ) {
|
||||
return Akismet::check_db_comment( $id, $recheck_reason );
|
||||
}
|
||||
|
||||
function akismet_rightnow() {
|
||||
if ( ! class_exists( 'Akismet_Admin' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Akismet_Admin::rightnow_stats();
|
||||
}
|
||||
|
||||
function akismet_admin_init() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_version_warning() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_load_js_and_css() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_nonce_field( $action = -1 ) {
|
||||
return wp_nonce_field( $action );
|
||||
}
|
||||
function akismet_plugin_action_links( $links, $file ) {
|
||||
return Akismet_Admin::plugin_action_links( $links, $file );
|
||||
}
|
||||
function akismet_conf() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_stats_display() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_stats() {
|
||||
return Akismet_Admin::dashboard_stats();
|
||||
}
|
||||
function akismet_admin_warnings() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_comment_row_action( $a, $comment ) {
|
||||
return Akismet_Admin::comment_row_actions( $a, $comment );
|
||||
}
|
||||
function akismet_comment_status_meta_box( $comment ) {
|
||||
return Akismet_Admin::comment_status_meta_box( $comment );
|
||||
}
|
||||
function akismet_comments_columns( $columns ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
|
||||
return $columns;
|
||||
}
|
||||
function akismet_comment_column_row( $column, $comment_id ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_text_add_link_callback( $m ) {
|
||||
return Akismet_Admin::text_add_link_callback( $m );
|
||||
}
|
||||
function akismet_text_add_link_class( $comment_text ) {
|
||||
return Akismet_Admin::text_add_link_class( $comment_text );
|
||||
}
|
||||
function akismet_check_for_spam_button( $comment_status ) {
|
||||
return Akismet_Admin::check_for_spam_button( $comment_status );
|
||||
}
|
||||
function akismet_submit_nonspam_comment( $comment_id ) {
|
||||
return Akismet::submit_nonspam_comment( $comment_id );
|
||||
}
|
||||
function akismet_submit_spam_comment( $comment_id ) {
|
||||
return Akismet::submit_spam_comment( $comment_id );
|
||||
}
|
||||
function akismet_transition_comment_status( $new_status, $old_status, $comment ) {
|
||||
return Akismet::transition_comment_status( $new_status, $old_status, $comment );
|
||||
}
|
||||
function akismet_spam_count( $type = false ) {
|
||||
return Akismet_Admin::get_spam_count( $type );
|
||||
}
|
||||
function akismet_recheck_queue() {
|
||||
return Akismet_Admin::recheck_queue();
|
||||
}
|
||||
function akismet_remove_comment_author_url() {
|
||||
return Akismet_Admin::remove_comment_author_url();
|
||||
}
|
||||
function akismet_add_comment_author_url() {
|
||||
return Akismet_Admin::add_comment_author_url();
|
||||
}
|
||||
function akismet_check_server_connectivity() {
|
||||
return Akismet_Admin::check_server_connectivity();
|
||||
}
|
||||
function akismet_get_server_connectivity( $cache_timeout = 86400 ) {
|
||||
return Akismet_Admin::get_server_connectivity( $cache_timeout );
|
||||
}
|
||||
function akismet_server_connectivity_ok() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
|
||||
return true;
|
||||
}
|
||||
function akismet_admin_menu() {
|
||||
return Akismet_Admin::admin_menu();
|
||||
}
|
||||
function akismet_load_menu() {
|
||||
return Akismet_Admin::load_menu();
|
||||
}
|
||||
function akismet_init() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_get_key() {
|
||||
return Akismet::get_api_key();
|
||||
}
|
||||
function akismet_check_key_status( $key, $ip = null ) {
|
||||
return Akismet::check_key_status( $key, $ip );
|
||||
}
|
||||
function akismet_update_alert( $response ) {
|
||||
return Akismet::update_alert( $response );
|
||||
}
|
||||
function akismet_verify_key( $key, $ip = null ) {
|
||||
return Akismet::verify_key( $key, $ip );
|
||||
}
|
||||
function akismet_get_user_roles( $user_id ) {
|
||||
return Akismet::get_user_roles( $user_id );
|
||||
}
|
||||
function akismet_result_spam( $approved ) {
|
||||
return Akismet::comment_is_spam( $approved );
|
||||
}
|
||||
function akismet_result_hold( $approved ) {
|
||||
return Akismet::comment_needs_moderation( $approved );
|
||||
}
|
||||
function akismet_get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url ) {
|
||||
return Akismet::get_user_comments_approved( $user_id, $comment_author_email, $comment_author, $comment_author_url );
|
||||
}
|
||||
function akismet_update_comment_history( $comment_id, $message, $event = null ) {
|
||||
return Akismet::update_comment_history( $comment_id, $message, $event );
|
||||
}
|
||||
function akismet_get_comment_history( $comment_id ) {
|
||||
return Akismet::get_comment_history( $comment_id );
|
||||
}
|
||||
function akismet_cmp_time( $a, $b ) {
|
||||
return Akismet::_cmp_time( $a, $b );
|
||||
}
|
||||
function akismet_auto_check_update_meta( $id, $comment ) {
|
||||
return Akismet::auto_check_update_meta( $id, $comment );
|
||||
}
|
||||
function akismet_auto_check_comment( $commentdata ) {
|
||||
return Akismet::auto_check_comment( $commentdata );
|
||||
}
|
||||
function akismet_get_ip_address() {
|
||||
return Akismet::get_ip_address();
|
||||
}
|
||||
function akismet_cron_recheck() {
|
||||
return Akismet::cron_recheck();
|
||||
}
|
||||
function akismet_add_comment_nonce( $post_id ) {
|
||||
return Akismet::add_comment_nonce( $post_id );
|
||||
}
|
||||
function akismet_fix_scheduled_recheck() {
|
||||
return Akismet::fix_scheduled_recheck();
|
||||
}
|
||||
function akismet_spam_comments() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
|
||||
return array();
|
||||
}
|
||||
function akismet_spam_totals() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
|
||||
return array();
|
||||
}
|
||||
function akismet_manage_page() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_caught() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function redirect_old_akismet_urls() {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
}
|
||||
function akismet_kill_proxy_check( $option ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0' );
|
||||
|
||||
return 0;
|
||||
}
|
||||
function akismet_pingback_forwarded_for( $r, $url ) {
|
||||
// This functionality is now in core.
|
||||
return false;
|
||||
}
|
||||
function akismet_pre_check_pingback( $method ) {
|
||||
return Akismet::pre_check_pingback( $method );
|
||||
}
|
||||
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Flatlogic URL Preserver
|
||||
* Description: Automatically attaches fl_project to all links on the page.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
// Function to fetch the ID once per request
|
||||
function fl_get_env_project_id() {
|
||||
static $cached_id = null;
|
||||
if ($cached_id !== null) return $cached_id;
|
||||
|
||||
$cached_id = getenv('PROJECT_ID');
|
||||
|
||||
if (!$cached_id) {
|
||||
$envPath = ABSPATH . '../.env';
|
||||
if (file_exists($envPath)) {
|
||||
$lines = file($envPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
foreach ($lines as $line) {
|
||||
if (strpos(trim($line), 'PROJECT_ID=') === 0) {
|
||||
$cached_id = trim(str_replace('PROJECT_ID=', '', $line), "\"' ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $cached_id;
|
||||
}
|
||||
|
||||
// The core function to modify the URL
|
||||
function fl_append_project_param( $url ) {
|
||||
$pid = fl_get_env_project_id();
|
||||
if ( ! $pid || empty( $url ) || strpos( $url, '#' ) === 0 ) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
// Only append if it's an internal link
|
||||
if ( strpos( $url, home_url() ) === 0 || ( strpos( $url, '/' ) === 0 && strpos( $url, '//' ) !== 0 ) ) {
|
||||
return add_query_arg( 'fl_project', $pid, $url );
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
// Apply to all link filters
|
||||
$filters = [
|
||||
'post_link', 'page_link', 'post_type_link',
|
||||
'term_link', 'attachment_link',
|
||||
'author_link', 'category_link', 'tag_link'
|
||||
];
|
||||
|
||||
foreach ( $filters as $f ) {
|
||||
add_filter( $f, 'fl_append_project_param' );
|
||||
}
|
||||
|
||||
// Special case: Navigation Menus
|
||||
add_filter( 'nav_menu_link_attributes', function( $atts ) {
|
||||
if ( isset( $atts['href'] ) ) {
|
||||
$atts['href'] = fl_append_project_param( $atts['href'] );
|
||||
}
|
||||
return $atts;
|
||||
}, 10, 1 );
|
||||
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Flatlogic SEO Metadata
|
||||
* Description: Automatically adds SEO and Social Media (Open Graph, Twitter) metadata to the site.
|
||||
* Version: 1.0.0
|
||||
*/
|
||||
|
||||
function fl_seo_metadata_head() {
|
||||
if (is_admin()) return;
|
||||
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
|
||||
$siteName = get_bloginfo('name');
|
||||
$siteDescription = get_bloginfo('description');
|
||||
|
||||
$metaDescription = !empty($projectDescription) ? $projectDescription : $siteDescription;
|
||||
$metaTitle = is_front_page() ? $siteName : get_the_title() . ' | ' . $siteName;
|
||||
|
||||
// Determine the current URL more accurately
|
||||
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
|
||||
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';
|
||||
$current_url = $protocol . $host . $_SERVER['REQUEST_URI'];
|
||||
?>
|
||||
<?php if ($metaDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content="<?php echo esc_attr($metaDescription); ?>" />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?php echo esc_attr($metaDescription); ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?php echo esc_attr($metaDescription); ?>" />
|
||||
<?php endif; ?>
|
||||
<meta property="og:title" content="<?php echo esc_attr($metaTitle); ?>" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:url" content="<?php echo esc_url($current_url); ?>" />
|
||||
<meta property="og:site_name" content="<?php echo esc_attr($siteName); ?>" />
|
||||
<meta property="twitter:card" content="summary_large_image" />
|
||||
<meta property="twitter:title" content="<?php echo esc_attr($metaTitle); ?>" />
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?php echo esc_url($projectImageUrl); ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?php echo esc_url($projectImageUrl); ?>" />
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
}
|
||||
add_action('wp_head', 'fl_seo_metadata_head', 1);
|
||||
106
wp-content/plugins/hello.php
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Hello_Dolly
|
||||
* @version 1.7.2
|
||||
*/
|
||||
/*
|
||||
Plugin Name: Hello Dolly
|
||||
Plugin URI: http://wordpress.org/plugins/hello-dolly/
|
||||
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page.
|
||||
Author: Matt Mullenweg
|
||||
Version: 1.7.2
|
||||
Author URI: http://ma.tt/
|
||||
Text Domain: hello-dolly
|
||||
*/
|
||||
|
||||
// Do not load directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
function hello_dolly_get_lyric() {
|
||||
/** These are the lyrics to Hello Dolly */
|
||||
$lyrics = "Hello, Dolly
|
||||
Well, hello, Dolly
|
||||
It's so nice to have you back where you belong
|
||||
You're lookin' swell, Dolly
|
||||
I can tell, Dolly
|
||||
You're still glowin', you're still crowin'
|
||||
You're still goin' strong
|
||||
I feel the room swayin'
|
||||
While the band's playin'
|
||||
One of our old favorite songs from way back when
|
||||
So, take her wrap, fellas
|
||||
Dolly, never go away again
|
||||
Hello, Dolly
|
||||
Well, hello, Dolly
|
||||
It's so nice to have you back where you belong
|
||||
You're lookin' swell, Dolly
|
||||
I can tell, Dolly
|
||||
You're still glowin', you're still crowin'
|
||||
You're still goin' strong
|
||||
I feel the room swayin'
|
||||
While the band's playin'
|
||||
One of our old favorite songs from way back when
|
||||
So, golly, gee, fellas
|
||||
Have a little faith in me, fellas
|
||||
Dolly, never go away
|
||||
Promise, you'll never go away
|
||||
Dolly'll never go away again";
|
||||
|
||||
// Here we split it into lines.
|
||||
$lyrics = explode( "\n", $lyrics );
|
||||
|
||||
// And then randomly choose a line.
|
||||
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
|
||||
}
|
||||
|
||||
// This just echoes the chosen line, we'll position it later.
|
||||
function hello_dolly() {
|
||||
$chosen = hello_dolly_get_lyric();
|
||||
$lang = '';
|
||||
if ( 'en_' !== substr( get_user_locale(), 0, 3 ) ) {
|
||||
$lang = ' lang="en"';
|
||||
}
|
||||
|
||||
printf(
|
||||
'<p id="dolly"><span class="screen-reader-text">%s </span><span dir="ltr"%s>%s</span></p>',
|
||||
__( 'Quote from Hello Dolly song, by Jerry Herman:' ),
|
||||
$lang,
|
||||
$chosen
|
||||
);
|
||||
}
|
||||
|
||||
// Now we set that function up to execute when the admin_notices action is called.
|
||||
add_action( 'admin_notices', 'hello_dolly' );
|
||||
|
||||
// We need some CSS to position the paragraph.
|
||||
function dolly_css() {
|
||||
echo "
|
||||
<style type='text/css'>
|
||||
#dolly {
|
||||
float: right;
|
||||
padding: 5px 10px;
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.6666;
|
||||
}
|
||||
.rtl #dolly {
|
||||
float: left;
|
||||
}
|
||||
.block-editor-page #dolly {
|
||||
display: none;
|
||||
}
|
||||
@media screen and (max-width: 782px) {
|
||||
#dolly,
|
||||
.rtl #dolly {
|
||||
float: none;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
";
|
||||
}
|
||||
|
||||
add_action( 'admin_head', 'dolly_css' );
|
||||
2
wp-content/plugins/index.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
@ -1,7 +0,0 @@
|
||||
# BEGIN MainWP
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteRule ^(.*)$ \./THIS_PLUGIN_DOES_NOT_EXIST [QSA,L]
|
||||
</IfModule>
|
||||
# END MainWP
|
||||
@ -1,161 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child AAM.
|
||||
*
|
||||
* MainWP AAM Extension handler.
|
||||
*
|
||||
* @link https://aamportal.com/integration/mainwp
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*
|
||||
* Credits
|
||||
*
|
||||
* Plugin-Name: Advanced Access Manager
|
||||
* Plugin URI: https://wordpress.org/plugins/advanced-access-manager/
|
||||
* Author: Vasyltech
|
||||
* Author URI: https://vasyltech.com/
|
||||
*
|
||||
* The code is used for the MainWP AAM Extension
|
||||
* Extension URL: https://aamportal.com/integration/mainwp
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
use AAM_Service_SecurityAudit;
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- Required to achieve desired results. Pull requests appreciated.
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Aam
|
||||
*
|
||||
* MainWP Staging Extension handler.
|
||||
*/
|
||||
class MainWP_Child_Aam {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Public variable to hold the information if the WP Staging plugin is installed on the child site.
|
||||
*
|
||||
* @var bool If WP Staging installed, return true, if not, return false.
|
||||
*/
|
||||
public $is_plugin_installed = false;
|
||||
|
||||
/**
|
||||
* Public variable to hold the information if the WP Staging plugin is installed on the child site.
|
||||
*
|
||||
* @var string version string.
|
||||
*/
|
||||
public $plugin_version = false;
|
||||
|
||||
/**
|
||||
* Create a public static instance of MainWP_Child_Aam.
|
||||
*
|
||||
* @return MainWP_Child_Aam
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize hooks
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function init() {
|
||||
add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_Aam constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*/
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // NOSONAR - WP compatible.
|
||||
|
||||
if ( is_plugin_active( 'advanced-access-manager/aam.php' ) && defined( 'AAM_KEY' ) ) {
|
||||
$this->is_plugin_installed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync others data.
|
||||
*
|
||||
* Get an array of available clones of this Child Sites.
|
||||
*
|
||||
* @param array $information Holder for available clones.
|
||||
* @param array $data Array of existing clones.
|
||||
*
|
||||
* @return array $information An array of available clones.
|
||||
*/
|
||||
public function sync_others_data( $information, $data = array() ) {
|
||||
if ( ! empty( $data['aam'] ) && class_exists( '\AAM_Service_SecurityAudit' ) ) {
|
||||
try {
|
||||
$aam_info = array();
|
||||
|
||||
// Get list of data point we would like to fetch.
|
||||
foreach ( $data['aam'] as $data_point ) {
|
||||
$method = 'fetch_' . $data_point;
|
||||
|
||||
if ( method_exists( $this, $method ) ) {
|
||||
$aam_info[ $data_point ] = $this->{$method}();
|
||||
}
|
||||
}
|
||||
|
||||
$information['aam'] = $aam_info;
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
// error!
|
||||
}
|
||||
}
|
||||
|
||||
return $information;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get security audit score
|
||||
*
|
||||
* @return int|null
|
||||
* @access protected
|
||||
*/
|
||||
protected function fetch_security_score() {
|
||||
return get_option( AAM_Service_SecurityAudit::DB_SCOPE_OPTION, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get report summary
|
||||
*
|
||||
* @return array
|
||||
* @access protected
|
||||
*/
|
||||
protected function fetch_issues_summary() {
|
||||
$result = array();
|
||||
$report = get_option( AAM_Service_SecurityAudit::DB_OPTION, array() );
|
||||
|
||||
if ( is_array( $report ) ) {
|
||||
$result = array(
|
||||
'error' => 0,
|
||||
'notice' => 0,
|
||||
'warning' => 0,
|
||||
'critical' => 0,
|
||||
);
|
||||
|
||||
foreach ( $report as $group ) {
|
||||
foreach ( $group['issues'] as $issue ) {
|
||||
++$result[ $issue['type'] ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@ -1,964 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child Actions.
|
||||
*
|
||||
* Handle MainWP Child Actions.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Actions
|
||||
*
|
||||
* Handle MainWP Child Actions.
|
||||
*/
|
||||
class MainWP_Child_Actions { //phpcs:ignore -- NOSONAR - multi method.
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Public static variable.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
protected $init_actions = array();
|
||||
|
||||
/**
|
||||
* Public static variable.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
protected static $actions_data = null;
|
||||
|
||||
/**
|
||||
* Public static variable.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
protected static $sending = null;
|
||||
|
||||
/**
|
||||
* Public static variable.
|
||||
*
|
||||
* @var mixed Default null.
|
||||
*/
|
||||
protected static $connected_admin = null;
|
||||
|
||||
|
||||
/**
|
||||
* Old plugins.
|
||||
*
|
||||
* @var array Old plugins array.
|
||||
* */
|
||||
public $current_plugins_info = array();
|
||||
|
||||
/**
|
||||
* Old themes.
|
||||
*
|
||||
* @var array Old themes array.
|
||||
* */
|
||||
public $current_themes_info = array();
|
||||
|
||||
|
||||
/**
|
||||
* Private variable to hold time start.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private static $exec_start = null;
|
||||
|
||||
/**
|
||||
* Method get_class_name()
|
||||
*
|
||||
* Get class name.
|
||||
*
|
||||
* @return string __CLASS__ Class name.
|
||||
*/
|
||||
public static function get_class_name() {
|
||||
return __CLASS__;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_Callable constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*/
|
||||
public function __construct() {
|
||||
static::$connected_admin = get_option( 'mainwp_child_connected_admin', '' );
|
||||
$this->init_actions = array(
|
||||
'upgrader_pre_install',
|
||||
'upgrader_process_complete',
|
||||
'activate_plugin',
|
||||
'deactivate_plugin',
|
||||
'switch_theme',
|
||||
'delete_site_transient_update_themes',
|
||||
'pre_option_uninstall_plugins',
|
||||
'deleted_plugin',
|
||||
'_core_updated_successfully',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method init_hooks().
|
||||
*
|
||||
* Init WP hooks.
|
||||
*/
|
||||
public function init_hooks() {
|
||||
// avoid actions.
|
||||
if ( MainWP_Helper::is_dashboard_request() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// not connected, avoid actions.
|
||||
if ( empty( static::$connected_admin ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pubkey = get_option( 'mainwp_child_pubkey' );
|
||||
// not connected, avoid actions.
|
||||
if ( empty( $pubkey ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $this->init_actions as $action ) {
|
||||
add_action( $action, array( $this, 'callback' ), 10, 99 );
|
||||
}
|
||||
|
||||
$this->init_exec_time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method init_custom_hooks().
|
||||
*
|
||||
* Init WP custom hooks.
|
||||
*
|
||||
* @param string $actions action name.
|
||||
*/
|
||||
public function init_custom_hooks( $actions ) {
|
||||
|
||||
if ( is_string( $actions ) ) {
|
||||
$actions = array( $actions );
|
||||
}
|
||||
|
||||
if ( ! is_array( $actions ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$allow_acts = array(
|
||||
'upgrader_pre_install',
|
||||
);
|
||||
foreach ( $actions as $action ) {
|
||||
if ( ! in_array( $action, $allow_acts ) ) {
|
||||
continue;
|
||||
}
|
||||
add_action( $action, array( $this, 'callback' ), 10, 99 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_current_plugins_info().
|
||||
*
|
||||
* Get current plugins info.
|
||||
*/
|
||||
public function get_current_plugins_info() {
|
||||
return $this->current_plugins_info;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method get_current_themes_info().
|
||||
*
|
||||
* Get current themes info.
|
||||
*/
|
||||
public function get_current_themes_info() {
|
||||
return $this->current_themes_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for all registered hooks.
|
||||
* Looks for a class method with the convention: "callback_{action name}"
|
||||
*/
|
||||
public function callback() {
|
||||
$current = current_filter();
|
||||
$callback = array( $this, 'callback_' . preg_replace( '/[^A-Za-z0-9_\-]/', '_', $current ) ); // to fix A-Z charater in callback name.
|
||||
|
||||
// Call the real function.
|
||||
if ( is_callable( $callback ) ) {
|
||||
return call_user_func_array( $callback, func_get_args() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get actions info.
|
||||
*/
|
||||
public static function get_actions_data() {
|
||||
if ( null === static::$actions_data ) {
|
||||
static::$actions_data = get_option( 'mainwp_child_actions_saved_data', array() );
|
||||
if ( ! is_array( static::$actions_data ) ) {
|
||||
static::$actions_data = array();
|
||||
}
|
||||
$username = get_option( 'mainwp_child_connected_admin', '' );
|
||||
if ( ! isset( static::$actions_data['connected_admin'] ) ) {
|
||||
static::$actions_data['connected_admin'] = $username;
|
||||
} elseif ( '' !== $username && $username !== static::$actions_data['connected_admin'] ) {
|
||||
static::$actions_data = array( 'connected_admin' => $username ); // if it is not same the connected user then clear the actions data.
|
||||
update_option( 'mainwp_child_actions_saved_data', static::$actions_data );
|
||||
}
|
||||
static::check_actions_data();
|
||||
}
|
||||
return static::$actions_data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to save actions info.
|
||||
*
|
||||
* @param int $index index.
|
||||
* @param array $data Action data .
|
||||
*
|
||||
* @return bool Return TRUE.
|
||||
*/
|
||||
private function update_actions_data( $index, $data ) {
|
||||
static::get_actions_data();
|
||||
$index = strval( $index );
|
||||
static::$actions_data[ $index ] = $data;
|
||||
update_option( 'mainwp_child_actions_saved_data', static::$actions_data );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to check actions data.
|
||||
* Clear old the action info.
|
||||
*/
|
||||
public static function check_actions_data() { //phpcs:ignore -- NOSONAR - complex.
|
||||
// NOSONAR - WP compatible.
|
||||
$checked = intval( get_option( 'mainwp_child_actions_data_checked', 0 ) );
|
||||
if ( empty( $checked ) ) {
|
||||
update_option( 'mainwp_child_actions_data_checked', time() );
|
||||
} else {
|
||||
$checked = date( 'Y-m-d', $checked ); // phpcs:ignore -- Use local time to achieve desired results, pull request solutions appreciated.
|
||||
if ( $checked !== date( 'Y-m-d' ) ) { // phpcs:ignore -- Use local time to achieve desired results, pull request solutions appreciated.
|
||||
$days_number = intval( get_option( 'mainwp_child_actions_saved_number_of_days', 30 ) );
|
||||
$days_number = apply_filters( 'mainwp_child_actions_saved_number_of_days', $days_number );
|
||||
$days_number = ( 3 > $days_number || 6 * 30 < $days_number ) ? 30 : $days_number;
|
||||
$check_time = $days_number * \DAY_IN_SECONDS;
|
||||
|
||||
$updated = false;
|
||||
foreach ( static::$actions_data as $index => $data ) {
|
||||
|
||||
if ( 'connected_admin' === strval( $index ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! is_array( $data ) || $check_time < time() - intval( $data['created'] ) || empty( $data['action_user'] ) ) {
|
||||
unset( static::$actions_data[ $index ] );
|
||||
$updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $updated ) {
|
||||
update_option( 'mainwp_child_actions_saved_data', static::$actions_data );
|
||||
}
|
||||
update_option( 'mainwp_child_actions_data_checked', time() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log plugin installations.
|
||||
*
|
||||
* @action transition_post_status.
|
||||
*
|
||||
* @param \WP_Upgrader $upgrader WP_Upgrader class object.
|
||||
* @param array $extra Extra attributes array.
|
||||
*
|
||||
* @return bool Return TRUE|FALSE.
|
||||
*/
|
||||
public function callback_upgrader_process_complete( $upgrader, $extra ) { // phpcs:ignore -- NOSONAR - required to achieve desired results, pull request solutions appreciated.
|
||||
$logs = array();
|
||||
$success = ! is_wp_error( $upgrader->skin->result );
|
||||
$error = null;
|
||||
|
||||
if ( ! $success ) {
|
||||
$errors = $upgrader->skin->result->errors;
|
||||
|
||||
list( $error ) = reset( $errors );
|
||||
}
|
||||
|
||||
// This would have failed down the road anyway.
|
||||
if ( ! isset( $extra['type'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$type = $extra['type'];
|
||||
$action = $extra['action'];
|
||||
|
||||
if ( ! in_array( $type, array( 'plugin', 'theme' ), true ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( 'install' === $action ) {
|
||||
if ( 'plugin' === $type ) {
|
||||
$path = $upgrader->plugin_info();
|
||||
|
||||
if ( ! $path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$data = get_plugin_data( $upgrader->skin->result['local_destination'] . '/' . $path );
|
||||
$slug = $upgrader->result['destination_name'];
|
||||
$name = $data['Name'];
|
||||
$version = $data['Version'];
|
||||
} else { // theme.
|
||||
$slug = $upgrader->theme_info();
|
||||
|
||||
if ( ! $slug ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wp_clean_themes_cache();
|
||||
|
||||
$theme = wp_get_theme( $slug );
|
||||
$name = $theme->name;
|
||||
$version = $theme->version;
|
||||
}
|
||||
|
||||
$action = 'installed';
|
||||
// translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2").
|
||||
$message = _x(
|
||||
'Installed %1$s: %2$s %3$s',
|
||||
'Plugin/theme installation. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
|
||||
'mainwp-child'
|
||||
);
|
||||
|
||||
$logs[] = compact( 'slug', 'name', 'version', 'message', 'action' );
|
||||
} elseif ( 'update' === $action ) {
|
||||
|
||||
if ( is_object( $upgrader ) && property_exists( $upgrader, 'skin' ) && 'Automatic_Upgrader_Skin' === get_class( $upgrader->skin ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$action = 'updated';
|
||||
// translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2").
|
||||
$message = _x(
|
||||
'Updated %1$s: %2$s %3$s',
|
||||
'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
|
||||
'mainwp-child'
|
||||
);
|
||||
|
||||
if ( 'plugin' === $type ) {
|
||||
if ( isset( $extra['bulk'] ) && true === $extra['bulk'] ) {
|
||||
$slugs = $extra['plugins'];
|
||||
} else {
|
||||
$slugs = array( $upgrader->skin->plugin );
|
||||
}
|
||||
|
||||
foreach ( $slugs as $slug ) {
|
||||
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $slug );
|
||||
$name = $plugin_data['Name'];
|
||||
$version = $plugin_data['Version'];
|
||||
// ( Net-Concept - Xavier NUEL ) : get old versions.
|
||||
if ( isset( $this->current_plugins_info[ $slug ] ) ) {
|
||||
$old_version = $this->current_plugins_info[ $slug ]['Version'];
|
||||
} else {
|
||||
$old_version = $upgrader->skin->plugin_info['Version']; // to fix old version.
|
||||
}
|
||||
|
||||
if ( version_compare( $version, $old_version, '>' ) ) {
|
||||
$logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
|
||||
}
|
||||
}
|
||||
} else { // theme.
|
||||
if ( isset( $extra['bulk'] ) && true === $extra['bulk'] ) {
|
||||
$slugs = $extra['themes'];
|
||||
} else {
|
||||
$slugs = array( $upgrader->skin->theme );
|
||||
}
|
||||
|
||||
foreach ( $slugs as $slug ) {
|
||||
$theme = wp_get_theme( $slug );
|
||||
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
|
||||
$theme_data = get_file_data(
|
||||
$stylesheet,
|
||||
array(
|
||||
'Version' => 'Version',
|
||||
)
|
||||
);
|
||||
$name = $theme['Name'];
|
||||
$version = $theme_data['Version'];
|
||||
|
||||
$old_version = '';
|
||||
|
||||
if ( isset( $this->current_themes_info[ $slug ] ) ) {
|
||||
$old_theme = $this->current_themes_info[ $slug ];
|
||||
|
||||
if ( isset( $old_theme['version'] ) ) {
|
||||
$old_version = $old_theme['version'];
|
||||
}
|
||||
} elseif ( ! empty( $upgrader->skin->theme_info ) ) {
|
||||
$old_version = $upgrader->skin->theme_info->get( 'Version' ); // to fix old version //$theme['Version'].
|
||||
}
|
||||
|
||||
$logs[] = compact( 'slug', 'name', 'old_version', 'version', 'message', 'action' );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
$context = $type . 's';
|
||||
|
||||
foreach ( $logs as $log ) {
|
||||
$name = isset( $log['name'] ) ? $log['name'] : null;
|
||||
$version = isset( $log['version'] ) ? $log['version'] : null;
|
||||
$slug = isset( $log['slug'] ) ? $log['slug'] : null;
|
||||
$old_version = isset( $log['old_version'] ) ? $log['old_version'] : null;
|
||||
$message = isset( $log['message'] ) ? $log['message'] : null;
|
||||
$action = isset( $log['action'] ) ? $log['action'] : null;
|
||||
|
||||
$this->save_actions(
|
||||
$message,
|
||||
compact( 'type', 'name', 'version', 'slug', 'success', 'error', 'old_version' ),
|
||||
$context,
|
||||
$action
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Activate plugin callback.
|
||||
*
|
||||
* @param string $slug Plugin slug.
|
||||
* @param bool $network_wide Check if network wide.
|
||||
*/
|
||||
public function callback_activate_plugin( $slug, $network_wide = false ) {
|
||||
$_plugins = $this->get_plugins();
|
||||
$name = $_plugins[ $slug ]['Name'];
|
||||
$network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child' ) : null;
|
||||
|
||||
if ( empty( $name ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->save_actions(
|
||||
_x(
|
||||
'"%1$s" plugin activated %2$s',
|
||||
'1: Plugin name, 2: Single site or network wide',
|
||||
'mainwp-child'
|
||||
),
|
||||
compact( 'name', 'network_wide', 'slug' ),
|
||||
'plugins',
|
||||
'activated'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decativate plugin callback.
|
||||
*
|
||||
* @param string $slug Plugin slug.
|
||||
* @param bool $network_wide Check if network wide.
|
||||
*/
|
||||
public function callback_deactivate_plugin( $slug, $network_wide = false ) {
|
||||
$_plugins = $this->get_plugins();
|
||||
$name = $_plugins[ $slug ]['Name'];
|
||||
$network_wide = $network_wide ? esc_html__( 'network wide', 'mainwp-child' ) : null;
|
||||
|
||||
$this->save_actions(
|
||||
_x(
|
||||
'"%1$s" plugin deactivated %2$s',
|
||||
'1: Plugin name, 2: Single site or network wide',
|
||||
'mainwp-child'
|
||||
),
|
||||
compact( 'name', 'network_wide', 'slug' ),
|
||||
'plugins',
|
||||
'deactivated'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch theme callback.
|
||||
*
|
||||
* @param string $name Theme name.
|
||||
* @param string $theme Theme slug.
|
||||
*/
|
||||
public function callback_switch_theme( $name, $theme ) {
|
||||
unset( $theme );
|
||||
$this->save_actions(
|
||||
esc_html__( '"%s" theme activated', 'mainwp-child' ),
|
||||
compact( 'name' ),
|
||||
'themes',
|
||||
'activated'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update theme & transient delete callback.
|
||||
*
|
||||
* @devtodo Core needs a delete_theme hook
|
||||
*/
|
||||
public function callback_delete_site_transient_update_themes() {
|
||||
$backtrace = debug_backtrace(); // @codingStandardsIgnoreLine This is used as a hack to determine a theme was deleted.
|
||||
$delete_theme_call = null;
|
||||
|
||||
foreach ( $backtrace as $call ) {
|
||||
if ( isset( $call['function'] ) && 'delete_theme' === $call['function'] ) {
|
||||
$delete_theme_call = $call;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( empty( $delete_theme_call ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$name = $delete_theme_call['args'][0];
|
||||
// @devtodo Can we get the name of the theme? Or has it already been eliminated
|
||||
|
||||
$this->save_actions(
|
||||
esc_html__( '"%s" theme deleted', 'mainwp-child' ),
|
||||
compact( 'name' ),
|
||||
'themes',
|
||||
'deleted'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall plugins callback.
|
||||
*/
|
||||
public function callback_pre_option_uninstall_plugins() {
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if ( ! isset( $_POST['action'] ) || 'delete-plugin' !== $_POST['action'] ) {
|
||||
return false;
|
||||
}
|
||||
$plugin = isset( $_POST['plugin'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) : '';
|
||||
// phpcs:enable
|
||||
$_plugins = $this->get_plugins();
|
||||
$plugins_to_delete = array();
|
||||
$plugins_to_delete[ $plugin ] = isset( $_plugins[ $plugin ] ) ? $_plugins[ $plugin ] : array();
|
||||
update_option( 'wp_mainwp_child_actions_plugins_to_delete', $plugins_to_delete );
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uninstall plugins callback.
|
||||
*
|
||||
* @param string $plugin_file plugin file name.
|
||||
* @param bool $deleted deleted or not.
|
||||
*/
|
||||
public function callback_deleted_plugin( $plugin_file, $deleted ) {
|
||||
if ( $deleted ) {
|
||||
|
||||
if ( ! isset( $_POST['action'] ) || 'delete-plugin' !== $_POST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
|
||||
return;
|
||||
}
|
||||
$plugins_to_delete = get_option( 'wp_mainwp_child_actions_plugins_to_delete' );
|
||||
if ( ! $plugins_to_delete ) {
|
||||
return;
|
||||
}
|
||||
foreach ( $plugins_to_delete as $plugin => $data ) {
|
||||
if ( $plugin_file === $plugin ) {
|
||||
$name = $data['Name'];
|
||||
$network_wide = $data['Network'] ? esc_html__( 'network wide', 'mainwp-child' ) : '';
|
||||
|
||||
$this->save_actions(
|
||||
esc_html__( '"%s" plugin deleted', 'mainwp-child' ),
|
||||
compact( 'name', 'plugin', 'network_wide' ),
|
||||
'plugins',
|
||||
'deleted'
|
||||
);
|
||||
}
|
||||
}
|
||||
delete_option( 'wp_mainwp_child_actions_plugins_to_delete' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs WordPress core upgrades
|
||||
*
|
||||
* @action automatic_updates_complete
|
||||
*
|
||||
* @param string $update_results Update results.
|
||||
* @return mixed bool|null.
|
||||
*/
|
||||
public function callback_automatic_updates_complete( $update_results ) {
|
||||
global $pagenow;
|
||||
|
||||
if ( ! is_array( $update_results ) || ! isset( $update_results['core'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$info = $update_results['core'][0];
|
||||
|
||||
$old_version = MainWP_Child_Server_Information_Base::get_wordpress_version();
|
||||
$new_version = $info->item->version;
|
||||
$auto_updated = true;
|
||||
|
||||
$message = esc_html__( 'WordPress auto-updated to %s', 'mainwp-child' );
|
||||
|
||||
$this->save_actions(
|
||||
$message,
|
||||
compact( 'new_version', 'old_version', 'auto_updated' ),
|
||||
'wordpress', // phpcs:ignore -- fix format text.
|
||||
'updated'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Core updated successfully callback.
|
||||
*
|
||||
* @param mixed $new_version New WordPress verison.
|
||||
*/
|
||||
public function callback__core_updated_successfully( $new_version = '' ) {
|
||||
|
||||
/**
|
||||
* Global variables.
|
||||
*
|
||||
* @global string $pagenow Current page.
|
||||
*/
|
||||
global $pagenow;
|
||||
|
||||
$old_version = MainWP_Child_Server_Information_Base::get_wordpress_version();
|
||||
$auto_updated = ( 'update-core.php' !== $pagenow );
|
||||
|
||||
if ( $auto_updated ) {
|
||||
// translators: Placeholder refers to a version number (e.g. "4.2").
|
||||
$message = esc_html__( 'WordPress auto-updated to %s', 'mainwp-child' );
|
||||
} else {
|
||||
// translators: Placeholder refers to a version number (e.g. "4.2").
|
||||
$message = esc_html__( 'WordPress updated to %s', 'mainwp-child' );
|
||||
}
|
||||
|
||||
$this->save_actions(
|
||||
$message,
|
||||
compact( 'new_version', 'old_version', 'auto_updated' ),
|
||||
'wordpress', // phpcs:ignore -- fix format text.
|
||||
'updated'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrader pre-instaler callback.
|
||||
*/
|
||||
public function callback_upgrader_pre_install() { //phpcs:ignore -- NOSONAR - complex.
|
||||
// NOSONAR - WP compatible.
|
||||
if ( empty( $this->current_plugins_info ) ) {
|
||||
$this->current_plugins_info = $this->get_plugins();
|
||||
}
|
||||
|
||||
if ( empty( $this->current_themes_info ) ) {
|
||||
$this->current_themes_info = array();
|
||||
|
||||
if ( ! function_exists( '\wp_get_themes' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/theme.php'; // NOSONAR - WP compatible.
|
||||
}
|
||||
|
||||
$themes = wp_get_themes();
|
||||
|
||||
if ( is_array( $themes ) ) {
|
||||
$theme_name = wp_get_theme()->get( 'Name' );
|
||||
$parent_name = '';
|
||||
$parent = wp_get_theme()->parent();
|
||||
if ( $parent ) {
|
||||
$parent_name = $parent->get( 'Name' );
|
||||
}
|
||||
foreach ( $themes as $theme ) {
|
||||
|
||||
$_slug = $theme->get_stylesheet();
|
||||
if ( isset( $this->current_themes_info[ $_slug ] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$out = array();
|
||||
$out['name'] = $theme->get( 'Name' );
|
||||
$out['title'] = $theme->display( 'Name', true, false );
|
||||
$out['version'] = $theme->display( 'Version', true, false );
|
||||
$out['active'] = ( $theme->get( 'Name' ) === $theme_name ) ? 1 : 0;
|
||||
$out['slug'] = $_slug;
|
||||
$out['parent_active'] = ( $parent_name === $out['name'] ) ? 1 : 0;
|
||||
|
||||
$this->current_themes_info[ $_slug ] = $out;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper method for calling get_plugins().
|
||||
*
|
||||
* @return array Installed plugins.
|
||||
*/
|
||||
public function get_plugins() {
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // NOSONAR - WP compatible.
|
||||
}
|
||||
|
||||
return get_plugins();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log handler.
|
||||
*
|
||||
* @param string $message sprintf-ready error message string.
|
||||
* @param array $args sprintf (and extra) arguments to use.
|
||||
* @param string $context Context of the event.
|
||||
* @param string $action Action of the event.
|
||||
*/
|
||||
public function save_actions( $message, $args, $context, $action ) { // phpcs:ignore -- NOSONAR - complex.
|
||||
|
||||
/**
|
||||
* Global variable.
|
||||
*
|
||||
* @global object $wp_roles WordPress user roles object.
|
||||
* */
|
||||
global $wp_roles;
|
||||
|
||||
if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$context_label = $this->get_valid_context( $context );
|
||||
if ( empty( $context_label ) ) { // not valid.
|
||||
return false;
|
||||
}
|
||||
|
||||
$action_label = $this->get_valid_action( $action );
|
||||
if ( empty( $action_label ) ) { // not valid.
|
||||
return false;
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$user = get_user_by( 'id', $user_id );
|
||||
|
||||
$connected_user = get_option( 'mainwp_child_connected_admin', '' );
|
||||
|
||||
if ( ! empty( $user->user_login ) && $connected_user === $user->user_login && MainWP_Helper::is_dashboard_request( true ) ) {
|
||||
return false; // not save action.
|
||||
}
|
||||
|
||||
$actions_save = apply_filters( 'mainwp_child_actions_save_data', true, $context, $action, $args, $message, $user_id );
|
||||
|
||||
if ( ! $actions_save ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$userlogin = (string) ( ! empty( $user->user_login ) ? $user->user_login : '' );
|
||||
|
||||
$user_role_label = '';
|
||||
$role = '';
|
||||
$roles = MainWP_Utility::instance()->get_roles();
|
||||
if ( ! empty( $user->roles ) ) {
|
||||
$user_roles = array_values( $user->roles );
|
||||
$role = $user_roles[0];
|
||||
$user_role_label = isset( $roles[ $role ] ) ? $roles[ $role ] : $role;
|
||||
}
|
||||
|
||||
$agent = $this->get_current_agent();
|
||||
$meta_data = array(
|
||||
'wp_user_id' => (int) $user_id,
|
||||
'display_name' => (string) $this->get_display_name( $user ),
|
||||
'role' => (string) $role,
|
||||
'user_role_label' => (string) $user_role_label,
|
||||
'agent' => (string) $agent,
|
||||
);
|
||||
|
||||
$system_user = '';
|
||||
if ( 'wp_cli' === $agent ) {
|
||||
$system_user = 'wp_cli';
|
||||
if ( is_callable( 'posix_getuid' ) && is_callable( 'posix_getpwuid' ) ) {
|
||||
$uid = posix_getuid();
|
||||
$user_info = posix_getpwuid( $uid );
|
||||
$meta_data['system_user_id'] = (int) $uid;
|
||||
$meta_data['system_user_name'] = (string) $user_info['name'];
|
||||
if ( ! empty( $meta_data['system_user_name'] ) ) {
|
||||
$system_user = $meta_data['system_user_name'];
|
||||
}
|
||||
}
|
||||
} elseif ( 'wp_cron' === $agent ) {
|
||||
$system_user = 'wp_cron';
|
||||
}
|
||||
|
||||
if ( empty( $userlogin ) && ! empty( $system_user ) ) {
|
||||
$userlogin = $system_user;
|
||||
}
|
||||
|
||||
$meta_data['action_user'] = (string) $userlogin;
|
||||
|
||||
// Prevent any meta with null values from being logged.
|
||||
$extra_info = array_filter(
|
||||
$args,
|
||||
function ( $val ) {
|
||||
return ! is_null( $val );
|
||||
}
|
||||
);
|
||||
|
||||
// Add user meta to Stream meta.
|
||||
$other_meta = array(
|
||||
'user_meta' => $meta_data,
|
||||
'extra_info' => $extra_info,
|
||||
);
|
||||
|
||||
$created = time();
|
||||
|
||||
$action = (string) $action;
|
||||
|
||||
$recordarr = array(
|
||||
'context' => $context,
|
||||
'action' => $action,
|
||||
'action_user' => $userlogin,
|
||||
'created' => $created,
|
||||
'summary' => (string) vsprintf( $message, $args ),
|
||||
'meta_data' => $other_meta,
|
||||
'duration' => $this->get_exec_time(),
|
||||
);
|
||||
$index = time() . rand( 1000, 9999 ); // phpcs:ignore -- ok for index.
|
||||
$this->update_actions_data( $index, $recordarr );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method init_exec_time().
|
||||
*
|
||||
* Init execution time start value.
|
||||
*/
|
||||
public function init_exec_time() {
|
||||
if ( null === static::$exec_start ) {
|
||||
static::$exec_start = microtime( true );
|
||||
}
|
||||
return static::$exec_start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_exec_time().
|
||||
*
|
||||
* Get execution time start value.
|
||||
*/
|
||||
public function get_exec_time() {
|
||||
if ( null === static::$exec_start ) {
|
||||
static::$exec_start = microtime( true );
|
||||
}
|
||||
|
||||
return microtime( true ) - static::$exec_start; // seconds.
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete actions logs.
|
||||
*/
|
||||
public function delete_actions() {
|
||||
delete_option( 'mainwp_child_actions_saved_data' );
|
||||
MainWP_Helper::write( array( 'success' => 'ok' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get valid context.
|
||||
*
|
||||
* @param string $context Context.
|
||||
*
|
||||
* @return string Context label.
|
||||
*/
|
||||
public function get_valid_context( $context ) {
|
||||
$context = (string) $context;
|
||||
$valid = array(
|
||||
'plugins' => 'Plugins',
|
||||
'themes' => 'Themes',
|
||||
'wordpress' => 'WordPress' // phpcs:ignore -- fix format text.
|
||||
);
|
||||
return isset( $valid[ $context ] ) ? $valid[ $context ] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get valid action.
|
||||
*
|
||||
* @param string $action action.
|
||||
*
|
||||
* @return string action label.
|
||||
*/
|
||||
public function get_valid_action( $action ) {
|
||||
$action = (string) $action;
|
||||
$valid = array(
|
||||
'updated' => 'updated',
|
||||
'deleted' => 'deleted',
|
||||
'activated' => 'activated',
|
||||
'deactivated' => 'deactivated',
|
||||
'installed' => 'installed',
|
||||
);
|
||||
return isset( $valid[ $action ] ) ? $valid[ $action ] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the display name of the user
|
||||
*
|
||||
* @param mixed $user User object.
|
||||
*
|
||||
* @return string Return User Login or Display Names.
|
||||
*/
|
||||
public function get_display_name( $user ) {
|
||||
if ( empty( $user->ID ) ) {
|
||||
if ( 'wp_cli' === $this->get_current_agent() ) {
|
||||
return 'WP-CLI';
|
||||
}
|
||||
$title = esc_html__( 'N/A', 'mainwp-child' );
|
||||
} elseif ( ! empty( $user->display_name ) ) {
|
||||
$title = $user->display_name;
|
||||
} else {
|
||||
$title = $user->user_login;
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agent.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_current_agent() {
|
||||
$agent = '';
|
||||
if ( defined( '\WP_CLI' ) && \WP_CLI ) {
|
||||
$agent = 'wp_cli';
|
||||
} elseif ( $this->is_doing_wp_cron() ) {
|
||||
$agent = 'wp_cron';
|
||||
}
|
||||
return $agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if doing WP Cron, otherwise false.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_doing_wp_cron() {
|
||||
return $this->is_cron_enabled() && defined( 'DOING_CRON' ) && DOING_CRON;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if native WP Cron is enabled, otherwise false.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_cron_enabled() {
|
||||
return ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ? false : true;
|
||||
}
|
||||
}
|
||||
@ -1,119 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child Site Api Backups
|
||||
*
|
||||
* Manages MainWP API Backups child site actions when needed.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Api_Backups
|
||||
*
|
||||
* This class handles all the MainWP API Backups child site actions when needed.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
class MainWP_Child_Api_Backups {
|
||||
|
||||
/**
|
||||
* Public variable to state if supported plugin is installed on the child site.
|
||||
*
|
||||
* @var bool If supported plugin is installed, return true, if not, return false.
|
||||
*/
|
||||
public $is_plugin_installed = false;
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_Api_Backups constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*/
|
||||
public function __construct() {
|
||||
// Constructor.
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a backup of the database for the given child site.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function api_backups_mysqldump() {
|
||||
|
||||
// WordPress DB credentials.
|
||||
$database_name = DB_NAME;
|
||||
$user = DB_USER;
|
||||
$pass = DB_PASSWORD;
|
||||
|
||||
// Remove ":" & all numbers from "Localhost:3306".
|
||||
$host = str_replace( ':', '', preg_replace( '/\d/', '', DB_HOST ) );
|
||||
|
||||
// Get Site URL.
|
||||
$site_url = str_replace( '/', '.', preg_replace( '#^https?://#i', '', get_bloginfo( 'url' ) ) );
|
||||
|
||||
// Create a timestamp.
|
||||
$current_date_time = current_datetime();
|
||||
$current_date_time = $current_date_time->format( 'm-d-Y_H.i.s.A' );
|
||||
|
||||
// Build the uploads directory.
|
||||
$wp_get_upload_dir = wp_get_upload_dir();
|
||||
$wp_upload_dir = $wp_get_upload_dir['basedir'] . '/mainwp/api_db_backups/';
|
||||
|
||||
// Build the full path to the backup file.
|
||||
$gzip_full_path = $wp_upload_dir . $database_name . '_' . $site_url . '_' . $current_date_time . '.sql.gz';
|
||||
|
||||
// Create the directory if it doesn't exist.
|
||||
if ( ! file_exists( $wp_upload_dir ) ) { //phpcs:ignore
|
||||
mkdir( $wp_upload_dir, 0755, true ); //phpcs:ignore
|
||||
}
|
||||
|
||||
if ( function_exists( 'exec' ) ) {
|
||||
// Create the backup file. hide from logs ( password ).
|
||||
exec( "mysqldump --user={$user} --password='{$pass}' --host={$host} {$database_name} | gzip > {$gzip_full_path}", $output, $result ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.system_calls_exec
|
||||
}
|
||||
|
||||
// Check if the backup was successful.
|
||||
if ( 0 === $result ) {
|
||||
// Success.
|
||||
MainWP_Helper::write(
|
||||
array(
|
||||
'result' => 'GOOD',
|
||||
'output' => $output,
|
||||
'res' => $result,
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Error.
|
||||
MainWP_Helper::write(
|
||||
array(
|
||||
'result' => 'ERROR',
|
||||
'output' => $output,
|
||||
'res' => $result,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,339 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Render Branding
|
||||
*
|
||||
* This file handles rendering the Child Branding settings.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Branding_Render
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
class MainWP_Child_Branding_Render {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Class Name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_class_name() {
|
||||
return __CLASS__;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_Branding_Render constructor.
|
||||
*
|
||||
* Run any time the class is called.
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method admin_head_hide_elements().
|
||||
*/
|
||||
public static function admin_head_hide_elements() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener( "DOMContentLoaded", function( event ) {
|
||||
document.getElementById( "wp-admin-bar-updates" ).outerHTML = '';
|
||||
document.getElementById( "menu-plugins" ).outerHTML = '';
|
||||
var els_core = document.querySelectorAll( "a[href='update-core.php']" );
|
||||
for ( var i = 0, l = els_core.length; i < l; i++ ) {
|
||||
var el = els_core[i];
|
||||
el.parentElement.innerHTML = '';
|
||||
}
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Contact Support.
|
||||
*
|
||||
* @return string Contact Support form html.
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Child_Branding::$child_branding_options
|
||||
*/
|
||||
public function contact_support() { // phpcs:ignore -- NOSONAR - complex.
|
||||
|
||||
/**
|
||||
* Current user global.
|
||||
*
|
||||
* @global string
|
||||
*/
|
||||
global $current_user;
|
||||
|
||||
?>
|
||||
<style>
|
||||
.mainwp_info-box-yellow {
|
||||
margin: 5px 0 15px;
|
||||
padding: .6em;
|
||||
background: #ffffe0;
|
||||
border: 1px solid #e6db55;
|
||||
border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
clear: both;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
$opts = MainWP_Child_Branding::instance()->child_branding_options;
|
||||
|
||||
if ( isset( $_POST['submit'] ) ) {
|
||||
if ( ! isset( $_POST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), '_contactNonce' ) ) {
|
||||
return false;
|
||||
}
|
||||
$this->render_submit_message( $opts );
|
||||
return;
|
||||
}
|
||||
|
||||
$from_page = '';
|
||||
if ( isset( $_GET['from_page'] ) ) {
|
||||
$from_page = isset( $_GET['from_page'] ) ? rawurldecode( wp_unslash( $_GET['from_page'] ) ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
} else {
|
||||
$protocol = isset( $_SERVER['HTTPS'] ) && strcasecmp( sanitize_text_field( wp_unslash( $_SERVER['HTTPS'] ) ), 'off' ) ? 'https://' : 'http://';
|
||||
$fullurl = isset( $_SERVER['HTTP_HOST'] ) && isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['HTTP_HOST'] ) ) . sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
|
||||
$fullurl = $protocol . str_replace( array( 'https://', 'http://' ), '', $fullurl );
|
||||
$from_page = rawurldecode( $fullurl );
|
||||
}
|
||||
|
||||
$support_message = $opts['support_message'];
|
||||
$support_message = nl2br( stripslashes( $support_message ) );
|
||||
$from_email = $current_user ? $current_user->user_email : '';
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<div style="width: 99%;" class="whlb-support-form">
|
||||
<h2><?php echo esc_html( $opts['contact_label'] ); ?></h2>
|
||||
<div style="height: auto; margin-bottom: 10px; text-align: left">
|
||||
<p class="whlb-support-form"><?php echo wp_kses_post( $support_message ); ?></p>
|
||||
<p class="whlb-support-form">
|
||||
<label for="mainwp_branding_contact_message_subject"><?php esc_html_e( 'Subject:', 'mainwp-child' ); ?></label>
|
||||
<br>
|
||||
<input type="text" id="mainwp_branding_contact_message_subject" name="mainwp_branding_contact_message_subject" style="width: 650px;">
|
||||
</p>
|
||||
<p class="whlb-support-form">
|
||||
<label for="mainwp_branding_contact_send_from"><?php esc_html_e( 'From:', 'mainwp-child' ); ?></label>
|
||||
<br>
|
||||
<input type="text" id="mainwp_branding_contact_send_from" name="mainwp_branding_contact_send_from" style="width: 650px;" value="<?php echo esc_attr( $from_email ); ?>">
|
||||
</p>
|
||||
<div style="max-width: 650px;" class="whlb-support-form">
|
||||
<label for="mainwp_branding_contact_message_content"><?php esc_html_e( 'Your message:', 'mainwp-child' ); ?></label>
|
||||
<br>
|
||||
<?php
|
||||
remove_editor_styles(); // stop custom theme styling interfering with the editor.
|
||||
wp_editor(
|
||||
'',
|
||||
'mainwp_branding_contact_message_content',
|
||||
array(
|
||||
'textarea_name' => 'mainwp_branding_contact_message_content',
|
||||
'textarea_rows' => 10,
|
||||
'teeny' => true,
|
||||
'wpautop' => true,
|
||||
'media_buttons' => false,
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<?php
|
||||
$button_title = $opts['submit_button_title'];
|
||||
$button_title = ! empty( $button_title ) ? $button_title : esc_html__( 'Submit', 'mainwp-child' );
|
||||
?>
|
||||
<div class="whlb-support-field">
|
||||
<input id="mainwp-branding-contact-support-submit" type="submit" name="submit" value="<?php echo esc_attr( $button_title ); ?>" class="button-primary button" style="float: left"/>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="mainwp_branding_send_from_page" value="<?php echo esc_url( $from_page ); ?>"/>
|
||||
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( '_contactNonce' ) ); ?>"/>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render contact support submit message.
|
||||
*
|
||||
* @param array $opts An array containg message options.
|
||||
*/
|
||||
private function render_submit_message( $opts ) {
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
$from_page = isset( $_POST['mainwp_branding_send_from_page'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_branding_send_from_page'] ) ) : '';
|
||||
$back_link = $opts['message_return_sender'];
|
||||
$back_link = ! empty( $back_link ) ? $back_link : 'Go Back';
|
||||
$back_link = ! empty( $from_page ) ? '<a href="' . esc_url( $from_page ) . '" title="' . esc_attr( $back_link ) . '">' . esc_html( $back_link ) . '</a>' : '';
|
||||
|
||||
if ( MainWP_Utility::instance()->send_support_mail() ) {
|
||||
$send_email_message = isset( $opts['send_email_message'] ) ? $opts['send_email_message'] : '';
|
||||
if ( ! empty( $send_email_message ) ) {
|
||||
$send_email_message = stripslashes( $send_email_message );
|
||||
} else {
|
||||
$send_email_message = esc_html__( 'Message has been submitted successfully.', 'mainwp-child' );
|
||||
}
|
||||
} else {
|
||||
$send_email_message = esc_html__( 'Sending email failed!', 'mainwp-child' );
|
||||
}
|
||||
?>
|
||||
<div class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . '  ' . $back_link; // phpcs:ignore WordPress.Security.EscapeOutput -- black_link is trusted. ?></div>
|
||||
<?php
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* After admin bar render.
|
||||
*/
|
||||
public function after_admin_bar_render() {
|
||||
$hide_slugs = apply_filters( 'mainwp_child_hide_update_notice', array() );
|
||||
|
||||
if ( ! is_array( $hide_slugs ) ) {
|
||||
$hide_slugs = array();
|
||||
}
|
||||
|
||||
if ( 0 === count( $hide_slugs ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists( '\get_plugin_updates' ) ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/update.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
|
||||
$count_hide = 0;
|
||||
|
||||
$updates = get_plugin_updates();
|
||||
if ( is_array( $updates ) ) {
|
||||
foreach ( $updates as $slug => $data ) {
|
||||
if ( in_array( $slug, $hide_slugs ) ) {
|
||||
++$count_hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 0 === $count_hide ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var mainwpCountHide = <?php echo esc_attr( $count_hide ); ?>;
|
||||
document.addEventListener( "DOMContentLoaded", function( event ) {
|
||||
var $adminBarUpdates = document.querySelector( '#wp-admin-bar-updates .ab-label' ),
|
||||
itemCount;
|
||||
|
||||
if ( typeof( $adminBarUpdates ) !== 'undefined' && $adminBarUpdates !== null ) {
|
||||
itemCount = $adminBarUpdates.textContent;
|
||||
itemCount = parseInt( itemCount );
|
||||
|
||||
itemCount -= mainwpCountHide;
|
||||
if ( itemCount < 0 )
|
||||
itemCount = 0;
|
||||
|
||||
$adminBarUpdates.textContent = itemCount;
|
||||
}
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin footer text.
|
||||
*/
|
||||
public function in_admin_footer() {
|
||||
$hide_slugs = apply_filters( 'mainwp_child_hide_update_notice', array() );
|
||||
|
||||
if ( ! is_array( $hide_slugs ) ) {
|
||||
$hide_slugs = array();
|
||||
}
|
||||
|
||||
$count_hide = 0;
|
||||
|
||||
$updates = get_plugin_updates();
|
||||
if ( is_array( $updates ) ) {
|
||||
foreach ( $updates as $slug => $data ) {
|
||||
if ( in_array( $slug, $hide_slugs ) ) {
|
||||
++$count_hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 0 === $count_hide ) {
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var mainwpCountHide = <?php echo esc_attr( $count_hide ); ?>;
|
||||
document.addEventListener( "DOMContentLoaded", function( event ) {
|
||||
if ( typeof( pagenow ) !== 'undefined' && pagenow === 'plugins' ) {
|
||||
<?php
|
||||
// hide update notice row.
|
||||
if ( in_array( 'mainwp-child/mainwp-child.php', $hide_slugs ) ) {
|
||||
?>
|
||||
var el = document.querySelector( 'tr#mainwp-child-update' );
|
||||
if ( typeof( el ) !== 'undefined' && el !== null ) {
|
||||
el.style.display = 'none';
|
||||
}
|
||||
<?php
|
||||
}
|
||||
// hide update notice row.
|
||||
if ( in_array( 'mainwp-child-reports/mainwp-child-reports.php', $hide_slugs ) ) {
|
||||
?>
|
||||
var el = document.querySelector( 'tr#mainwp-child-reports-update' );
|
||||
if ( typeof( el ) !== 'undefined' && el !== null ) {
|
||||
el.style.display = 'none';
|
||||
}
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
||||
if ( mainwpCountHide > 0 ) {
|
||||
jQuery( document ).ready( function () {
|
||||
|
||||
var $adminBarUpdates = jQuery( '#wp-admin-bar-updates' ),
|
||||
$pluginsNavMenuUpdateCount = jQuery( 'a[href="plugins.php"] .update-plugins' ),
|
||||
itemCount;
|
||||
itemCount = $adminBarUpdates.find( '.ab-label' ).text();
|
||||
itemCount -= mainwpCountHide;
|
||||
if ( itemCount < 0 )
|
||||
itemCount = 0;
|
||||
|
||||
itemPCount = $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text();
|
||||
itemPCount -= mainwpCountHide;
|
||||
|
||||
if ( itemPCount < 0 )
|
||||
itemPCount = 0;
|
||||
|
||||
$adminBarUpdates.find( '.ab-label' ).text( itemCount );
|
||||
$pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( itemPCount );
|
||||
|
||||
} );
|
||||
}
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@ -1,329 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child Bulk Settings Manager
|
||||
*
|
||||
* This file handles connecting to the child site as a browser in order performs an HTTP request using the POST method and returns its response.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Bulk_Settings_Manager
|
||||
*
|
||||
* Handles connecting to the child site as a browser in order performs an HTTP request using the POST method and returns its response.
|
||||
*/
|
||||
class MainWP_Child_Bulk_Settings_Manager {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Public statis variable containing the synchronization information.
|
||||
*
|
||||
* @var array Synchronization information.
|
||||
*/
|
||||
public static $information = array();
|
||||
|
||||
/**
|
||||
* Public variable to hold the information about the language domain.
|
||||
*
|
||||
* @var string 'mainwp-child' languge domain.
|
||||
*/
|
||||
public $plugin_translate = 'mainwp-child';
|
||||
|
||||
/**
|
||||
* Create public static instance for MainWP_Child_Bulk_Settings_Manager.
|
||||
*
|
||||
* @return MainWP_Child_Bulk_Settings_Manager|null
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save Settings & Visit Site as Browser actions.
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function action() {
|
||||
|
||||
/**
|
||||
* MainWP bulk settings manager fatal error handler.
|
||||
*/
|
||||
function mainwp_bulk_settings_manager_handle_fatal_error() {
|
||||
$error = error_get_last();
|
||||
if ( isset( $error['type'] ) && in_array( $error['type'], array( 1, 4, 16, 64, 256 ) ) && isset( $error['message'] ) ) {
|
||||
MainWP_Helper::write( array( 'error' => 'MainWP_Child fatal error : ' . $error['message'] . ' Line: ' . $error['line'] . ' File: ' . $error['file'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
register_shutdown_function( '\MainWP\Child\mainwp_bulk_settings_manager_handle_fatal_error' );
|
||||
|
||||
$mwp_action = MainWP_System::instance()->validate_params( 'action' );
|
||||
switch ( $mwp_action ) {
|
||||
case 'skeleton_key_visit_site_as_browser': // deprecated.
|
||||
$information = $this->visit_site_as_browser();
|
||||
break;
|
||||
case 'bulk_settings_manager_visit_site_as_browser':
|
||||
$information = $this->visit_site_as_browser();
|
||||
break;
|
||||
case 'save_settings':
|
||||
$information = $this->save_settings();
|
||||
break;
|
||||
default:
|
||||
$information = array( 'error' => 'Unknown action' );
|
||||
}
|
||||
|
||||
MainWP_Helper::write( $information );
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit site as a browser.
|
||||
*
|
||||
* @return array|string[] Response array or Error message string within an array.
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Helper::get_class_name()
|
||||
*/
|
||||
protected function visit_site_as_browser() { // phpcs:ignore -- NOSONAR - ignore complex method notice.
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if ( ! isset( $_POST['url'] ) || ! is_string( wp_unslash( $_POST['url'] ) ) || strlen( wp_unslash( $_POST['url'] ) ) < 2 ) { //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
return array( 'error' => 'Missing url' );
|
||||
}
|
||||
|
||||
if ( ! isset( $_POST['args'] ) || ! is_array( $_POST['args'] ) ) {
|
||||
return array( 'error' => 'Missing args' );
|
||||
}
|
||||
|
||||
$_POST = stripslashes_deep( wp_unslash( $_POST ) );
|
||||
|
||||
$args = isset( $_POST['args'] ) ? wp_unslash( $_POST['args'] ) : array(); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
|
||||
$url = isset( $_POST['url'] ) ? '/' . sanitize_text_field( wp_unslash( $_POST['url'] ) ) : '';
|
||||
|
||||
$expiration = time() + 600;
|
||||
$manager = \WP_Session_Tokens::get_instance( $current_user->ID );
|
||||
$token = $manager->create( $expiration );
|
||||
|
||||
$secure = is_ssl();
|
||||
if ( $secure ) {
|
||||
$auth_cookie_name = SECURE_AUTH_COOKIE;
|
||||
$scheme = 'secure_auth';
|
||||
} else {
|
||||
$auth_cookie_name = AUTH_COOKIE;
|
||||
$scheme = 'auth';
|
||||
}
|
||||
$auth_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, $scheme, $token );
|
||||
$logged_in_cookie = wp_generate_auth_cookie( $current_user->ID, $expiration, 'logged_in', $token );
|
||||
$_COOKIE[ $auth_cookie_name ] = $auth_cookie;
|
||||
$_COOKIE[ LOGGED_IN_COOKIE ] = $logged_in_cookie;
|
||||
$post_args = array();
|
||||
$post_args['body'] = array();
|
||||
$post_args['redirection'] = 5;
|
||||
$post_args['decompress'] = false;
|
||||
$post_args['cookies'] = array(
|
||||
new \WP_Http_Cookie(
|
||||
array(
|
||||
'name' => $auth_cookie_name,
|
||||
'value' => $auth_cookie,
|
||||
)
|
||||
),
|
||||
new \WP_Http_Cookie(
|
||||
array(
|
||||
'name' => LOGGED_IN_COOKIE,
|
||||
'value' => $logged_in_cookie,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
$skip_invalid_nonce = false;
|
||||
if ( isset( $_REQUEST['skip_invalid_nonce'] ) && ! empty( $_REQUEST['skip_invalid_nonce'] ) ) {
|
||||
$skip_invalid_nonce = true;
|
||||
}
|
||||
|
||||
// phpcs:enable
|
||||
|
||||
if ( isset( $args['get'] ) ) {
|
||||
$get_args = $args['get'];
|
||||
parse_str( $args['get'], $get_args );
|
||||
}
|
||||
|
||||
if ( ! isset( $get_args ) || ! is_array( $get_args ) ) {
|
||||
$get_args = array();
|
||||
}
|
||||
|
||||
$get_args['bulk_settings_manageruse_nonce_key'] = intval( time() );
|
||||
$get_args['bulk_settings_manageruse_nonce_hmac'] = hash_hmac( 'sha256', $get_args['bulk_settings_manageruse_nonce_key'], NONCE_KEY );
|
||||
|
||||
if ( true === $skip_invalid_nonce ) {
|
||||
$get_args['bulk_settings_skip_invalid_nonce'] = $skip_invalid_nonce;
|
||||
}
|
||||
|
||||
$good_nonce = null;
|
||||
if ( isset( $args['nonce'] ) && ! empty( $args['nonce'] ) ) {
|
||||
parse_str( $args['nonce'], $temp_nonce );
|
||||
$good_nonce = $this->wp_create_nonce_recursive( $temp_nonce );
|
||||
$get_args = array_merge( $get_args, $good_nonce );
|
||||
}
|
||||
|
||||
if ( isset( $args['post'] ) ) {
|
||||
parse_str( $args['post'], $temp_post );
|
||||
if ( ! isset( $temp_post ) || ! is_array( $temp_post ) ) {
|
||||
$temp_post = array();
|
||||
}
|
||||
|
||||
if ( ! empty( $good_nonce ) ) {
|
||||
$temp_post = array_merge( $temp_post, $good_nonce );
|
||||
}
|
||||
|
||||
if ( true === $skip_invalid_nonce ) {
|
||||
$temp_post['bulk_settings_skip_invalid_nonce'] = $skip_invalid_nonce;
|
||||
}
|
||||
|
||||
$post_args['body'] = $temp_post;
|
||||
}
|
||||
|
||||
$post_args['timeout'] = 25;
|
||||
|
||||
$full_url = add_query_arg( $get_args, get_site_url() . $url );
|
||||
|
||||
add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'reject_unsafe_urls' ), 99, 2 );
|
||||
|
||||
$response = wp_remote_post( $full_url, $post_args );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return array( 'error' => 'wp_remote_post error: ' . $response->get_error_message() );
|
||||
}
|
||||
|
||||
$received_content = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( preg_match( '/<mainwp>(.*)<\/mainwp>/', $received_content, $received_result ) > 0 ) {
|
||||
$received_content_mainwp = json_decode( base64_decode( $received_result[1] ), true ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for http encode compatible..
|
||||
if ( isset( $received_content_mainwp['error'] ) ) {
|
||||
return array( 'error' => $received_content_mainwp['error'] );
|
||||
}
|
||||
}
|
||||
|
||||
$search_ok_counter = 0;
|
||||
$search_fail_counter = 0;
|
||||
|
||||
if ( isset( $args['search']['ok'] ) ) {
|
||||
foreach ( $args['search']['ok'] as $search ) {
|
||||
if ( preg_match( '/' . preg_quote( $search, '/' ) . '/i', $received_content ) ) {
|
||||
++$search_ok_counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $args['search']['fail'] ) ) {
|
||||
foreach ( $args['search']['fail'] as $search ) {
|
||||
if ( preg_match( '/' . preg_quote( $search, '/' ) . '/i', $received_content ) ) {
|
||||
++$search_fail_counter;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset( $get_args['bulk_settings_manageruse_nonce_key'] );
|
||||
unset( $get_args['bulk_settings_manageruse_nonce_hmac'] );
|
||||
|
||||
return array(
|
||||
'success' => 1,
|
||||
'content' => $received_content,
|
||||
'url' => $full_url,
|
||||
'get' => $get_args,
|
||||
'post' => $post_args['body'],
|
||||
'search_ok_counter' => $search_ok_counter,
|
||||
'search_fail_counter' => $search_fail_counter,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create WP nonce.
|
||||
*
|
||||
* @param array $arr An array containing the nonce.
|
||||
*
|
||||
* @return array An array containing the nonce.
|
||||
*/
|
||||
private function wp_create_nonce_recursive( $arr ) {
|
||||
foreach ( $arr as $key => $value ) {
|
||||
if ( is_array( $arr[ $key ] ) ) {
|
||||
$arr[ $key ] = $this->wp_create_nonce_recursive( $arr[ $key ] );
|
||||
} else {
|
||||
$arr[ $key ] = wp_create_nonce( $arr[ $key ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save site settings.
|
||||
*
|
||||
* @return array|bool|string[] Result array ok|error or FALSE or $whitelist_options[].
|
||||
*/
|
||||
public function save_settings() { //phpcs:ignore -- NOSONAR - complex.
|
||||
$settings = isset( $_POST['settings'] ) ? wp_unslash( $_POST['settings'] ) : array(); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
|
||||
if ( ! is_array( $settings ) || empty( $settings ) ) {
|
||||
return array( 'error' => esc_html__( 'Invalid data. Please check and try again.', 'mainwp-child' ) );
|
||||
}
|
||||
|
||||
$whitelist_options = array(
|
||||
'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
|
||||
);
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
if ( ! defined( 'WP_SITEURL' ) ) {
|
||||
$whitelist_options['general'][] = 'siteurl';
|
||||
}
|
||||
if ( ! defined( 'WP_HOME' ) ) {
|
||||
$whitelist_options['general'][] = 'home';
|
||||
}
|
||||
|
||||
$whitelist_options['general'][] = 'admin_email';
|
||||
$whitelist_options['general'][] = 'users_can_register';
|
||||
$whitelist_options['general'][] = 'default_role';
|
||||
}
|
||||
|
||||
$whitelist_general = $whitelist_options['general'];
|
||||
|
||||
if ( ! empty( $settings['WPLANG'] ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/translation-install.php'; // NOSONAR - WP compatible.
|
||||
if ( wp_can_install_language_pack() ) {
|
||||
$language = wp_download_language_pack( $settings['WPLANG'] );
|
||||
if ( $language ) {
|
||||
$settings['WPLANG'] = $language;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$updated = false;
|
||||
foreach ( $settings as $option => $value ) {
|
||||
if ( in_array( $option, $whitelist_general ) ) {
|
||||
if ( ! is_array( $value ) ) {
|
||||
$value = trim( $value );
|
||||
}
|
||||
$value = wp_unslash( $value );
|
||||
update_option( $option, $value );
|
||||
$updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $updated ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array( 'result' => 'ok' );
|
||||
}
|
||||
}
|
||||
@ -1,242 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child Comments
|
||||
*
|
||||
* This file handles all Child Site comment actions.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Comments
|
||||
*
|
||||
* Handles all Child Site comment actions.
|
||||
*/
|
||||
class MainWP_Child_Comments {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Comments and clauses.
|
||||
*
|
||||
* @var string Comments and clauses.
|
||||
*/
|
||||
private $comments_and_clauses;
|
||||
|
||||
/**
|
||||
* Get Class Name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_class_name() {
|
||||
return __CLASS__;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_Comments constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->comments_and_clauses = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a public static instance of ainWP_Child_Comments.
|
||||
*
|
||||
* @return MainWP_Child_Comments|null
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP Child Comment actions: approve, unapprove, spam, unspam, trash, restore, delete.
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Child_Links_Checker::get_class_name()
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function comment_action() {
|
||||
$action = MainWP_System::instance()->validate_params( 'action' );
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
$commentId = isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '';
|
||||
|
||||
if ( 'approve' === $action ) {
|
||||
wp_set_comment_status( $commentId, 'approve' );
|
||||
} elseif ( 'unapprove' === $action ) {
|
||||
wp_set_comment_status( $commentId, 'hold' );
|
||||
} elseif ( 'spam' === $action ) {
|
||||
wp_spam_comment( $commentId );
|
||||
} elseif ( 'unspam' === $action ) {
|
||||
wp_unspam_comment( $commentId );
|
||||
} elseif ( 'trash' === $action ) {
|
||||
add_action( 'trashed_comment', array( MainWP_Child_Links_Checker::get_class_name(), 'hook_trashed_comment' ), 10, 1 );
|
||||
wp_trash_comment( $commentId );
|
||||
} elseif ( 'restore' === $action ) {
|
||||
wp_untrash_comment( $commentId );
|
||||
} elseif ( 'delete' === $action ) {
|
||||
wp_delete_comment( $commentId, true );
|
||||
} else {
|
||||
$information['status'] = 'FAIL';
|
||||
}
|
||||
|
||||
if ( ! isset( $information['status'] ) ) {
|
||||
$information['status'] = 'SUCCESS';
|
||||
}
|
||||
// phpcs:enable
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP Child Bulk Comment actions: approve, unapprove, spam, unspam, trash, restore, delete.
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function comment_bulk_action() {
|
||||
$action = MainWP_System::instance()->validate_params( 'action' );
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
$commentIds = isset( $_POST['ids'] ) ? explode( ',', sanitize_text_field( wp_unslash( $_POST['ids'] ) ) ) : array();
|
||||
// phpcs:enable
|
||||
$information['success'] = 0;
|
||||
foreach ( $commentIds as $commentId ) {
|
||||
if ( $commentId ) {
|
||||
++$information['success'];
|
||||
if ( 'approve' === $action ) {
|
||||
wp_set_comment_status( $commentId, 'approve' );
|
||||
} elseif ( 'unapprove' === $action ) {
|
||||
wp_set_comment_status( $commentId, 'hold' );
|
||||
} elseif ( 'spam' === $action ) {
|
||||
wp_spam_comment( $commentId );
|
||||
} elseif ( 'unspam' === $action ) {
|
||||
wp_unspam_comment( $commentId );
|
||||
} elseif ( 'trash' === $action ) {
|
||||
wp_trash_comment( $commentId );
|
||||
} elseif ( 'restore' === $action ) {
|
||||
wp_untrash_comment( $commentId );
|
||||
} elseif ( 'delete' === $action ) {
|
||||
wp_delete_comment( $commentId, true );
|
||||
} else {
|
||||
--$information['success'];
|
||||
}
|
||||
}
|
||||
}
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment WHERE Clauses.
|
||||
*
|
||||
* @param array $clauses MySQL WHERE Clause.
|
||||
*
|
||||
* @return array $clauses, Array of MySQL WHERE Clauses.
|
||||
*/
|
||||
public function comments_clauses( $clauses ) {
|
||||
if ( $this->comments_and_clauses ) {
|
||||
$clauses['where'] .= ' ' . $this->comments_and_clauses;
|
||||
}
|
||||
|
||||
return $clauses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all comments.
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function get_all_comments() { //phpcs:ignore -- NOSONAR - complex.
|
||||
|
||||
/**
|
||||
* WordPress Database instance.
|
||||
*
|
||||
* @global object $wpdb
|
||||
*/
|
||||
global $wpdb;
|
||||
|
||||
add_filter( 'comments_clauses', array( &$this, 'comments_clauses' ) );
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if ( isset( $_POST['postId'] ) ) {
|
||||
$this->comments_and_clauses .= $wpdb->prepare( " AND $wpdb->comments.comment_post_ID = %d ", sanitize_text_field( wp_unslash( $_POST['postId'] ) ) );
|
||||
} else {
|
||||
if ( isset( $_POST['keyword'] ) && '' !== $_POST['keyword'] ) {
|
||||
$this->comments_and_clauses .= $wpdb->prepare( " AND $wpdb->comments.comment_content LIKE %s ", '%' . $wpdb->esc_like( sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) ) . '%' );
|
||||
}
|
||||
if ( isset( $_POST['dtsstart'] ) && '' !== $_POST['dtsstart'] ) {
|
||||
$this->comments_and_clauses .= $wpdb->prepare( " AND $wpdb->comments.comment_date > %s ", $wpdb->esc_like( sanitize_text_field( wp_unslash( $_POST['dtsstart'] ) ) ) );
|
||||
}
|
||||
if ( isset( $_POST['dtsstop'] ) && '' !== $_POST['dtsstop'] ) {
|
||||
$this->comments_and_clauses .= $wpdb->prepare( " AND $wpdb->comments.comment_date < %s ", $wpdb->esc_like( sanitize_text_field( wp_unslash( $_POST['dtsstop'] ) ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
$maxComments = 50;
|
||||
if ( defined( 'MAINWP_CHILD_NR_OF_COMMENTS' ) ) {
|
||||
$maxComments = MAINWP_CHILD_NR_OF_COMMENTS; // to compatible.
|
||||
}
|
||||
|
||||
if ( isset( $_POST['maxRecords'] ) ) {
|
||||
$maxComments = ! empty( $_POST['maxRecords'] ) ? intval( $_POST['maxRecords'] ) : 0;
|
||||
}
|
||||
|
||||
if ( 0 === $maxComments ) {
|
||||
$maxComments = 99999;
|
||||
}
|
||||
$status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : '';
|
||||
$rslt = $this->get_recent_comments( explode( ',', $status ), $maxComments );
|
||||
$this->comments_and_clauses = '';
|
||||
// phpcs:enable
|
||||
MainWP_Helper::write( $rslt );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recent comments.
|
||||
*
|
||||
* @param array $pAllowedStatuses An array containing allowed comment statuses.
|
||||
* @param int $pCount Number of comments to return.
|
||||
*
|
||||
* @return array $allComments Array of all comments found.
|
||||
*/
|
||||
public function get_recent_comments( $pAllowedStatuses, $pCount ) {
|
||||
if ( ! function_exists( '\get_comment_author_url' ) ) {
|
||||
include_once WPINC . '/comment-template.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
$allComments = array();
|
||||
|
||||
foreach ( $pAllowedStatuses as $status ) {
|
||||
$params = array( 'status' => $status );
|
||||
if ( 0 !== $pCount ) {
|
||||
$params['number'] = $pCount;
|
||||
}
|
||||
$comments = get_comments( $params );
|
||||
if ( is_array( $comments ) ) {
|
||||
foreach ( $comments as $comment ) {
|
||||
$post = get_post( $comment->comment_post_ID );
|
||||
$outComment = array();
|
||||
$outComment['id'] = $comment->comment_ID;
|
||||
$outComment['status'] = wp_get_comment_status( $comment->comment_ID );
|
||||
$outComment['author'] = $comment->comment_author;
|
||||
$outComment['author_url'] = get_comment_author_url( $comment->comment_ID );
|
||||
$outComment['author_ip'] = get_comment_author_IP( $comment->comment_ID );
|
||||
$outComment['author_email'] = apply_filters( 'comment_email', $comment->comment_author_email );
|
||||
$outComment['postId'] = $comment->comment_post_ID;
|
||||
$outComment['postName'] = $post->post_title;
|
||||
$outComment['comment_count'] = $post->comment_count;
|
||||
$outComment['content'] = $comment->comment_content;
|
||||
$outComment['dts'] = strtotime( $comment->comment_date_gmt );
|
||||
$allComments[] = $outComment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allComments;
|
||||
}
|
||||
}
|
||||
@ -1,313 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Database Updater Elementor.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_DB_Updater_Elementor.
|
||||
*
|
||||
* MainWP Database Updater extension handler.
|
||||
*/
|
||||
class MainWP_Child_DB_Updater_Elementor {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Public variable to hold the infomration if the WooCommerce plugin is installed on the child site.
|
||||
*
|
||||
* @var bool If WooCommerce intalled, return true, if not, return false.
|
||||
*/
|
||||
public static $is_plugin_elementor_installed = false;
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // NOSONAR - WP compatible.
|
||||
if ( defined( 'ELEMENTOR_VERSION' ) && is_plugin_active( 'elementor/elementor.php' ) ) {
|
||||
static::$is_plugin_elementor_installed = true;
|
||||
}
|
||||
if ( static::$is_plugin_elementor_installed ) {
|
||||
add_filter( 'mainwp_child_db_updater_sync_data', array( $this, 'hook_db_updater_sync_data' ), 10, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get sync data.
|
||||
*
|
||||
* @param array $db_upgrades Input sync data.
|
||||
*
|
||||
* @return array $db_upgrades Return data array.
|
||||
*/
|
||||
public function hook_db_updater_sync_data( $db_upgrades ) {
|
||||
|
||||
if ( ! static::$is_plugin_elementor_installed ) {
|
||||
return $db_upgrades;
|
||||
}
|
||||
|
||||
if ( ! is_array( $db_upgrades ) ) {
|
||||
$db_upgrades = array();
|
||||
}
|
||||
|
||||
if ( $this->should_upgrade() ) {
|
||||
$db_upgrades['elementor/elementor.php'] = array(
|
||||
'update' => $this->get_needs_db_update(),
|
||||
'Name' => 'Elementor',
|
||||
'db_version' => $this->get_current_version(),
|
||||
);
|
||||
}
|
||||
|
||||
if ( static::has_pro() && $this->should_upgrade( true ) ) {
|
||||
$db_upgrades['elementor-pro/elementor-pro.php'] = array(
|
||||
'update' => $this->get_needs_db_update( true ),
|
||||
'Name' => 'Elementor Pro',
|
||||
'db_version' => $this->get_current_version( true ),
|
||||
);
|
||||
}
|
||||
return $db_upgrades;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is a DB update needed?
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return boolean
|
||||
*/
|
||||
public function get_needs_db_update( $pro = false ) {
|
||||
if ( $pro ) {
|
||||
$db_versions = array(
|
||||
'new_db_version' => '',
|
||||
'slug' => 'elementor-pro/elementor-pro.php',
|
||||
);
|
||||
$new_db_version = $this->get_new_version( true );
|
||||
if ( $this->should_upgrade( true ) ) {
|
||||
$db_versions['new_db_version'] = $new_db_version;
|
||||
}
|
||||
} else {
|
||||
$db_versions = array(
|
||||
'new_db_version' => '',
|
||||
'slug' => 'elementor/elementor.php',
|
||||
);
|
||||
$new_db_version = $this->get_new_version();
|
||||
if ( $this->should_upgrade() ) {
|
||||
$db_versions['new_db_version'] = $new_db_version;
|
||||
}
|
||||
}
|
||||
return $db_versions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method should_upgrade().
|
||||
*
|
||||
* Get should upgrade.
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @return bool version compare result.
|
||||
*/
|
||||
public function should_upgrade( $pro = false ) {
|
||||
$current_version = $this->get_current_version( $pro );
|
||||
// It's a new install.
|
||||
if ( ! $current_version ) {
|
||||
return false;
|
||||
}
|
||||
return version_compare( $this->get_new_version( $pro ), $current_version, '>' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method has_pro().
|
||||
*
|
||||
* Has pro version.
|
||||
*/
|
||||
public static function has_pro() {
|
||||
return defined( 'ELEMENTOR_PRO_VERSION' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method get_current_version().
|
||||
*
|
||||
* Get current version.
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @return string version result.
|
||||
*/
|
||||
public function get_current_version( $pro = false ) {
|
||||
return get_option( $this->get_version_option_name( $pro ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method get_new_version().
|
||||
*
|
||||
* Get new elementor version.
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @return string version result.
|
||||
*/
|
||||
public function get_new_version( $pro = false ) {
|
||||
return $pro ? ELEMENTOR_PRO_VERSION : ELEMENTOR_VERSION;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method get_version_option_name().
|
||||
*
|
||||
* Get version option name.
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @return string option name.
|
||||
*/
|
||||
public function get_version_option_name( $pro = false ) {
|
||||
return $pro ? 'elementor_pro_version' : 'elementor_version';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method update_db()
|
||||
*
|
||||
* Update Elementor DB.
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @return array Action result.
|
||||
*/
|
||||
public function update_db( $pro = false ) {
|
||||
if ( ! static::$is_plugin_elementor_installed ) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return $this->do_db_upgrade( $pro );
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
error_log( $e->getMessage() ); // phpcs:ignore
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_update_db_manager_class()
|
||||
*
|
||||
* Get update db manager class.
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @return array Action result.
|
||||
*/
|
||||
protected function get_update_db_manager_class( $pro = false ) {
|
||||
if ( $pro ) {
|
||||
return '\ElementorPro\Core\Upgrade\Manager';
|
||||
}
|
||||
return '\Elementor\Core\Upgrade\Manager';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method do_db_upgrade()
|
||||
*
|
||||
* Do DB upgrade.
|
||||
*
|
||||
* @param bool $pro Pro version or not.
|
||||
*
|
||||
* @return array Action result.
|
||||
*/
|
||||
protected function do_db_upgrade( $pro = false ) { // phpcs:ignore -- NOSONAR - multi return.
|
||||
$manager_class = $this->get_update_db_manager_class( $pro );
|
||||
|
||||
MainWP_Helper::instance()->check_classes_exists( array( $manager_class, '\Elementor\Plugin' ) );
|
||||
|
||||
// core\upgrade\manager.php.
|
||||
// var \Elementor\Core\Upgrade\Manager $manager.
|
||||
$manager = new $manager_class();
|
||||
|
||||
if ( ! $this->check_parent_method( $manager, 'get_task_runner' ) || ! $this->check_parent_method( $manager, 'should_upgrade' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$updater = $manager->get_task_runner();
|
||||
|
||||
if ( ! $manager->should_upgrade() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ! $this->check_parent_method( $updater, 'handle_immediately' ) || ! $this->check_parent_method( $manager, 'get_upgrade_callbacks' ) || ! $this->check_parent_method( $manager, 'get_plugin_label' ) || ! $this->check_parent_method( $manager, 'get_current_version' ) || ! $this->check_parent_method( $manager, 'get_new_version' ) || ! $this->check_parent_method( $manager, 'on_runner_complete' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$callbacks = $manager->get_upgrade_callbacks();
|
||||
$did_tasks = false;
|
||||
|
||||
if ( ! empty( $callbacks ) ) {
|
||||
\Elementor\Plugin::$instance->logger->get_logger()->info(
|
||||
'Update DB has been started',
|
||||
array(
|
||||
'meta' => array(
|
||||
'plugin' => $manager->get_plugin_label(),
|
||||
'from' => $manager->get_current_version(),
|
||||
'to' => $manager->get_new_version(),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$updater->handle_immediately( $callbacks );
|
||||
|
||||
$did_tasks = true;
|
||||
}
|
||||
$manager->on_runner_complete( $did_tasks );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method check_parent_method().
|
||||
*
|
||||
* Check parent method.
|
||||
*
|
||||
* @param mixed $obj Object to check.
|
||||
* @param string $func Function to check.
|
||||
*
|
||||
* @return array Action result.
|
||||
*/
|
||||
public function check_parent_method( $obj, $func ) {
|
||||
if ( method_exists( $obj, $func ) ) {
|
||||
return true;
|
||||
}
|
||||
$parent_cls = get_parent_class( $obj );
|
||||
if ( empty( $parent_cls ) || ! method_exists( $parent_cls, $func ) ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,232 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Database Updater WC.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_DB_Updater_WC.
|
||||
*
|
||||
* MainWP Database Updater extension handler.
|
||||
*/
|
||||
class MainWP_Child_DB_Updater_WC {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Public variable to hold the infomration if the WooCommerce plugin is installed on the child site.
|
||||
*
|
||||
* @var bool If WooCommerce intalled, return true, if not, return false.
|
||||
*/
|
||||
public static $is_plugin_woocom_installed = false;
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // NOSONAR - WP compatible.
|
||||
|
||||
if ( function_exists( 'WC' ) && is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
||||
$supported = true;
|
||||
if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '3.3', '<' ) ) {
|
||||
$supported = false;
|
||||
}
|
||||
if ( $supported ) {
|
||||
static::$is_plugin_woocom_installed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( static::$is_plugin_woocom_installed ) {
|
||||
add_filter( 'mainwp_child_db_updater_sync_data', array( $this, 'hook_db_updater_sync_data' ), 10, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires WC files.
|
||||
*
|
||||
* @return mixed Results.
|
||||
*/
|
||||
public function requires_files() {
|
||||
if ( ! static::$is_plugin_woocom_installed ) {
|
||||
return;
|
||||
}
|
||||
if ( file_exists( WC_ABSPATH . 'includes/class-wc-install.php' ) ) {
|
||||
include_once WC_ABSPATH . 'includes/class-wc-install.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
if ( file_exists( WC_ABSPATH . 'includes/wc-update-functions.php' ) ) {
|
||||
include_once WC_ABSPATH . 'includes/wc-update-functions.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get db updater sync data.
|
||||
*
|
||||
* @param array $db_upgrades Input sync data.
|
||||
*
|
||||
* @return array $db_upgrades Return data array.
|
||||
* @throws MainWP_Exception Error message.
|
||||
*/
|
||||
public function hook_db_updater_sync_data( $db_upgrades ) {
|
||||
if ( ! static::$is_plugin_woocom_installed ) {
|
||||
return $db_upgrades;
|
||||
}
|
||||
|
||||
if ( ! is_array( $db_upgrades ) ) {
|
||||
$db_upgrades = array();
|
||||
}
|
||||
|
||||
$this->requires_files();
|
||||
try {
|
||||
|
||||
MainWP_Helper::instance()->check_classes_exists( array( '\WC_Install' ) );
|
||||
MainWP_Helper::instance()->check_methods( '\WC_Install', array( 'needs_db_update' ) );
|
||||
|
||||
if ( \WC_Install::needs_db_update() ) {
|
||||
$next_scheduled_date = \WC()->queue()->get_next( 'woocommerce_run_update_callback', null, 'woocommerce-db-updates' );
|
||||
if ( ! $next_scheduled_date ) {
|
||||
$current_db_version = get_option( 'woocommerce_db_version', null );
|
||||
// need.
|
||||
$db_upgrades['woocommerce/woocommerce.php'] = array(
|
||||
'update' => $this->get_needs_db_update(),
|
||||
'Name' => 'WooCommerce',
|
||||
'db_version' => $current_db_version ? $current_db_version : '',
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
// not exit here!
|
||||
error_log( $e->getMessage() ); //phpcs:ignore -- for debug.
|
||||
}
|
||||
return $db_upgrades;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is a DB update needed?
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return boolean
|
||||
*/
|
||||
public static function get_needs_db_update() {
|
||||
$db_versions = array(
|
||||
'new_db_version' => '',
|
||||
'slug' => 'woocommerce/woocommerce.php',
|
||||
);
|
||||
|
||||
$updates = \WC_Install::get_db_update_callbacks();
|
||||
$update_versions = array_keys( $updates );
|
||||
usort( $update_versions, 'version_compare' );
|
||||
|
||||
if ( ! empty( $update_versions ) ) {
|
||||
$db_versions['new_db_version'] = end( $update_versions );
|
||||
}
|
||||
|
||||
return $db_versions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method update_db()
|
||||
*
|
||||
* Update WC DB.
|
||||
*
|
||||
* @return array Action result.
|
||||
*/
|
||||
public function update_db() {
|
||||
if ( ! static::$is_plugin_woocom_installed ) {
|
||||
return false;
|
||||
}
|
||||
$success = false;
|
||||
try {
|
||||
MainWP_Helper::instance()->check_classes_exists( array( '\WC_Install' ) );
|
||||
MainWP_Helper::instance()->check_methods( '\WC_Install', array( 'needs_db_update' ) );
|
||||
$this->update_wc_db();
|
||||
$success = true;
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
error_log( $e->getMessage() ); //phpcs:ignore -- for debug.
|
||||
}
|
||||
try {
|
||||
MainWP_Helper::instance()->check_classes_exists( array( '\WC_Admin_Notices' ) );
|
||||
MainWP_Helper::instance()->check_methods( '\WC_Admin_Notices', array( 'remove_notice' ) );
|
||||
static::hide_notice( 'update' );
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
error_log( $e->getMessage() ); //phpcs:ignore -- for debug.
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push all needed DB updates to the queue for processing.
|
||||
*/
|
||||
private static function update_wc_db() {
|
||||
MainWP_Helper::instance()->check_methods( '\WC_Install', array( 'get_db_update_callbacks' ) );
|
||||
$current_db_version = get_option( 'woocommerce_db_version' );
|
||||
$loop = 0;
|
||||
foreach ( \WC_Install::get_db_update_callbacks() as $version => $update_callbacks ) {
|
||||
if ( version_compare( $current_db_version, $version, '<' ) ) {
|
||||
foreach ( $update_callbacks as $update_callback ) {
|
||||
\WC()->queue()->schedule_single(
|
||||
time() + $loop,
|
||||
'woocommerce_run_update_callback',
|
||||
array(
|
||||
'update_callback' => $update_callback,
|
||||
),
|
||||
'woocommerce-db-updates'
|
||||
);
|
||||
++$loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// After the callbacks finish, update the db version to the current WC version.
|
||||
$current_wc_version = WC()->version;
|
||||
if ( version_compare( $current_db_version, $current_wc_version, '<' ) &&
|
||||
! \WC()->queue()->get_next( 'woocommerce_update_db_to_current_version' ) ) {
|
||||
\WC()->queue()->schedule_single(
|
||||
time() + $loop,
|
||||
'woocommerce_update_db_to_current_version',
|
||||
array(
|
||||
'version' => $current_wc_version,
|
||||
),
|
||||
'woocommerce-db-updates'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide a single notice.
|
||||
*
|
||||
* @param string $name Notice name.
|
||||
*/
|
||||
private static function hide_notice( $name ) {
|
||||
\WC_Admin_Notices::remove_notice( $name );
|
||||
update_user_meta( get_current_user_id(), 'dismissed_' . $name . '_notice', true );
|
||||
do_action( 'woocommerce_hide_' . $name . '_notice' );
|
||||
}
|
||||
}
|
||||
@ -1,143 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Database Updater
|
||||
*
|
||||
* MainWP MainWP Database Updater extension handler.
|
||||
* Extension URL: https://mainwp.com/extension/databaseupdater/
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_DB_Updater
|
||||
*
|
||||
* MainWP Database Updater extension handler.
|
||||
*/
|
||||
class MainWP_Child_DB_Updater {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
|
||||
MainWP_Child_DB_Updater_WC::instance();
|
||||
MainWP_Child_DB_Updater_Elementor::instance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sync_others_data()
|
||||
*
|
||||
* Sync data to & from the MainWP Dashboard.
|
||||
*
|
||||
* @param array $information Array containing the data to be sent to the Dashboard.
|
||||
* @param array $data Array containing the data sent from the Dashboard; to be saved to the Child Site.
|
||||
*
|
||||
* @return array $information Array containing the data to be sent to the Dashboard.
|
||||
*/
|
||||
public function sync_others_data( $information, $data = array() ) {
|
||||
if ( isset( $data['syncDBUpdater'] ) && $data['syncDBUpdater'] ) {
|
||||
try {
|
||||
$information['syncDBUpdaterResponse'] = array(
|
||||
'plugin_db_upgrades' => $this->get_sync_data(),
|
||||
);
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
// ok!
|
||||
}
|
||||
}
|
||||
return $information;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method action()
|
||||
*
|
||||
* Fire off certain branding actions.
|
||||
*
|
||||
* @uses MainWP_Child_Branding::update_branding() Update custom branding settings.
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function action() {
|
||||
$information = array();
|
||||
MainWP_Child_DB_Updater_WC::instance()->requires_files();
|
||||
try {
|
||||
$mwp_action = MainWP_System::instance()->validate_params( 'mwp_action' );
|
||||
if ( 'update_db' === $mwp_action ) {
|
||||
$information = $this->update_db();
|
||||
}
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
$information['error'] = $e->getMessage();
|
||||
}
|
||||
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sync data.
|
||||
*/
|
||||
public function get_sync_data() {
|
||||
return apply_filters( 'mainwp_child_db_updater_sync_data', array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method update_db()
|
||||
*
|
||||
* Update DB.
|
||||
*
|
||||
* @return array Action result.
|
||||
*/
|
||||
public function update_db() {
|
||||
$information = array();
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
$plugins = isset( $_POST['list'] ) ? explode( ',', urldecode( wp_unslash( $_POST['list'] ) ) ) : array(); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
// phpcs:enable
|
||||
$upgrades = array();
|
||||
foreach ( $plugins as $slug ) {
|
||||
$success = false;
|
||||
switch ( $slug ) {
|
||||
case 'woocommerce/woocommerce.php':
|
||||
$success = MainWP_Child_DB_Updater_WC::instance()->update_db();
|
||||
break;
|
||||
case 'elementor/elementor.php':
|
||||
$success = MainWP_Child_DB_Updater_Elementor::instance()->update_db();
|
||||
break;
|
||||
case 'elementor-pro/elementor-pro.php':
|
||||
$success = MainWP_Child_DB_Updater_Elementor::instance()->update_db( true );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ( $success ) {
|
||||
$upgrades[ $slug ] = 1;
|
||||
}
|
||||
}
|
||||
$information['upgrades'] = $upgrades;
|
||||
$information['plugin_db_upgrades'] = $this->get_sync_data();
|
||||
return $information;
|
||||
}
|
||||
}
|
||||
@ -1,210 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child DB
|
||||
*
|
||||
* This file handles all of the Child Plugin's DB functions.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_DB
|
||||
*
|
||||
* Handles all of the Child Plugin's DB functions.
|
||||
*/
|
||||
class MainWP_Child_DB {
|
||||
|
||||
// phpcs:disable WordPress.DB.RestrictedFunctions, WordPress.DB.PreparedSQL.NotPrepared -- unprepared SQL ok, accessing the database directly to custom database functions.
|
||||
|
||||
/**
|
||||
* Support old & new versions of WordPress (3.9+).
|
||||
*
|
||||
* @return bool|object Instantiated object of \mysqli.
|
||||
*/
|
||||
public static function use_mysqli() {
|
||||
if ( ! function_exists( '\mysqli_connect' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* WordPress Database instance.
|
||||
*
|
||||
* @global object $wpdb
|
||||
*/
|
||||
global $wpdb;
|
||||
|
||||
return $wpdb->dbh instanceof \mysqli;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a mysqli query & get a result.
|
||||
*
|
||||
* @param string $query An SQL query.
|
||||
* @param string $link A link identifier.
|
||||
*
|
||||
* @return bool|\mysqli_result|resource For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries, mysqli_query()
|
||||
* will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.
|
||||
* Returns FALSE on failure.
|
||||
*/
|
||||
public static function to_query( $query, $link ) {
|
||||
if ( static::use_mysqli() ) {
|
||||
return \mysqli_query( $link, $query );
|
||||
} else {
|
||||
return \mysql_query( $query, $link );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch an array.
|
||||
*
|
||||
* @param array $result A result set identifier.
|
||||
*
|
||||
* @return array|false|null Returns an array of strings that corresponds to the fetched row, or false if there are no more rows.
|
||||
*/
|
||||
public static function fetch_array( $result ) {
|
||||
if ( static::use_mysqli() ) {
|
||||
return \mysqli_fetch_array( $result, MYSQLI_ASSOC );
|
||||
} else {
|
||||
return \mysql_fetch_array( $result, MYSQL_ASSOC );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the number of rows.
|
||||
*
|
||||
* @param array $result A result set identifier returned.
|
||||
*
|
||||
* @return false|int Returns number of rows in the result set.
|
||||
*/
|
||||
public static function num_rows( $result ) {
|
||||
if ( static::use_mysqli() ) {
|
||||
return \mysqli_num_rows( $result );
|
||||
} else {
|
||||
return \mysql_num_rows( $result );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to Child Site Database.
|
||||
*
|
||||
* @param string $host Can be either a host name or an IP address.
|
||||
* @param string $user The MySQL user name.
|
||||
* @param string $pass The MySQL user password.
|
||||
*
|
||||
* @return false|\mysqli|resource object which represents the connection to a MySQL Server or false if an error occurred.
|
||||
*/
|
||||
public static function connect( $host, $user, $pass ) {
|
||||
if ( static::use_mysqli() ) {
|
||||
return \mysqli_connect( $host, $user, $pass );
|
||||
} else {
|
||||
return \mysql_connect( $host, $user, $pass );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Select Child Site DB.
|
||||
*
|
||||
* @param string $db Database name.
|
||||
*
|
||||
* @return bool true on success or false on failure.
|
||||
*/
|
||||
public static function select_db( $db ) {
|
||||
if ( static::use_mysqli() ) {
|
||||
|
||||
/**
|
||||
* WordPress Database instance.
|
||||
*
|
||||
* @global object $wpdb
|
||||
*/
|
||||
global $wpdb;
|
||||
|
||||
return \mysqli_select_db( $wpdb->dbh, $db );
|
||||
} else {
|
||||
return \mysql_select_db( $db );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any mysqli errors.
|
||||
*
|
||||
* @return string the error text from the last MySQL function, or '' (empty string) if no error occurred.
|
||||
*/
|
||||
public static function error() {
|
||||
if ( static::use_mysqli() ) {
|
||||
|
||||
/**
|
||||
* WordPress Database instance.
|
||||
*
|
||||
* @global object $wpdb
|
||||
*/
|
||||
global $wpdb;
|
||||
|
||||
return \mysqli_error( $wpdb->dbh );
|
||||
} else {
|
||||
return \mysql_error();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape a given string.
|
||||
*
|
||||
* @param string $value The string to be escaped. Characters encoded are NUL (ASCII 0), \n, \r, \, ', ", and Control-Z.
|
||||
*
|
||||
* @return false|string the escaped string, or false on error.
|
||||
*/
|
||||
public static function real_escape_string( $value ) {
|
||||
|
||||
/**
|
||||
* WordPress Database instance.
|
||||
*
|
||||
* @global object $wpdb
|
||||
*/
|
||||
global $wpdb;
|
||||
|
||||
if ( static::use_mysqli() ) {
|
||||
return \mysqli_real_escape_string( $wpdb->dbh, $value );
|
||||
} else {
|
||||
return \mysql_real_escape_string( $value, $wpdb->dbh );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if $result is an Instantiated object of \mysqli.
|
||||
*
|
||||
* @param resource $result Instantiated object of \mysqli.
|
||||
*
|
||||
* @return resource|bool Instantiated object of \mysqli, true if var is a resource, false otherwise.
|
||||
*/
|
||||
public static function is_result( $result ) {
|
||||
if ( static::use_mysqli() ) {
|
||||
return $result instanceof \mysqli_result;
|
||||
} else {
|
||||
return is_resource( $result );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the DB.
|
||||
*
|
||||
* @return int|mixed Size of the DB or false on failure.
|
||||
*/
|
||||
public static function get_size() {
|
||||
|
||||
/**
|
||||
* WordPress Database instance.
|
||||
*
|
||||
* @global object $wpdb
|
||||
*/
|
||||
global $wpdb;
|
||||
|
||||
$rows = static::to_query( 'SHOW table STATUS', $wpdb->dbh );
|
||||
$size = 0;
|
||||
while ( $row = static::fetch_array( $rows ) ) {
|
||||
$size += $row['Data_length'];
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
@ -1,116 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child Format
|
||||
*
|
||||
* @package MainWP/Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Format
|
||||
*
|
||||
* MainWP Child Format
|
||||
*/
|
||||
class MainWP_Child_Format {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Method get_class_name()
|
||||
*
|
||||
* Get class name.
|
||||
*
|
||||
* @return string __CLASS__ Class name.
|
||||
*/
|
||||
public static function get_class_name() {
|
||||
return __CLASS__;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method format_email()
|
||||
*
|
||||
* Format emails.
|
||||
*
|
||||
* @param string $body Contains the email content.
|
||||
*
|
||||
* @return string Return formatted email.
|
||||
*/
|
||||
public static function format_email( $body ) {
|
||||
return '<br>
|
||||
<div>
|
||||
<br>
|
||||
<div style="background:#ffffff;padding:0 1.618em;font:13px/20px Helvetica,Arial,Sans-serif;padding-bottom:50px!important">
|
||||
<div style="width:600px;background:#fff;margin-left:auto;margin-right:auto;margin-top:10px;margin-bottom:25px;padding:0!important;border:10px Solid #fff;border-radius:10px;overflow:hidden">
|
||||
<div style="display: block; width: 100%;border-bottom: 2px Solid #7fb100 ; overflow: hidden;">
|
||||
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
|
||||
<div style="float: left;font-size:45px;"><a href="https://mainwp.com">MainWP</a></div>
|
||||
<div style="float: right; margin-top: .6em ;">
|
||||
<span style="display: inline-block; margin-right: .8em;"><a href="https://mainwp.com/mainwp-extensions/" style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;">Extensions</a></span>
|
||||
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://managers.mainwp.com/">Community</a></span>
|
||||
<span style="display: inline-block; margin-right: .8em;"><a style="font-family: Helvetica, Sans; color: #7fb100; text-transform: uppercase; font-size: 14px;" href="https://kb.mainwp.com/">Knowledgebase</a></span>
|
||||
</div><div style="clear: both;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>Hello MainWP User!<br></p>
|
||||
' . $body . '
|
||||
<div></div>
|
||||
<br />
|
||||
<div>MainWP</div>
|
||||
<div><a href="https://www.MainWP.com" target="_blank">www.MainWP.com</a></div>
|
||||
<p></p>
|
||||
</div>
|
||||
|
||||
<div style="display: block; width: 100% ; background: #1c1d1b;">
|
||||
<div style="display: block; width: 95% ; margin-left: auto ; margin-right: auto ; padding: .5em 0 ;">
|
||||
<div style="padding: .5em 0 ; float: left;"><p style="color: #fff; font-family: Helvetica, Sans; font-size: 12px ;">© 2013 MainWP. All Rights Reserved.</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<center>
|
||||
<br><br><br><br><br><br>
|
||||
<table style="border:0;padding:0;border-spacing:0;width:100%;background-color:#ffffff;border-top:1px solid #e5e5e5">
|
||||
<tbody><tr>
|
||||
<td align="center" valign="top" style="padding-top:20px;padding-bottom:20px">
|
||||
<table style="border:0;padding:0;border-spacing:0;">
|
||||
<tbody><tr>
|
||||
<td align="center" valign="top" style="color:#606060;font-family:Helvetica,Arial,sans-serif;font-size:11px;line-height:150%;padding-right:20px;padding-bottom:5px;padding-left:20px;text-align:center">
|
||||
This email is sent from your MainWP Dashboard.
|
||||
<br>
|
||||
If you do not wish to receive these notices please re-check your preferences in the MainWP Settings page.
|
||||
<br>
|
||||
<br>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<br>';
|
||||
}
|
||||
}
|
||||
@ -1,335 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP HTML Regression
|
||||
*
|
||||
* MainWP HTML Regression extension handler.
|
||||
* Extension URL: https://mainwp.com/extension/html-regression/
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
// phpcs:disable PSR1.Classes.ClassDeclaration, WordPress.WP.AlternativeFunctions -- required to achieve desired results, pull request solutions appreciated.
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_HTML_Regression
|
||||
*
|
||||
* MainWP HTML Regression extension handler.
|
||||
*/
|
||||
class MainWP_Child_HTML_Regression { //phpcs:ignore -- NOSONAR - multi methods.
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of the class.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
public static $instance = null;
|
||||
|
||||
/**
|
||||
* Public variable to hold the information if the HTML Regression plugin is installed on the child site.
|
||||
*
|
||||
* @var bool If HTML Regression installed, return true, if not, return false.
|
||||
*/
|
||||
public $is_plugin_installed = true;
|
||||
|
||||
/**
|
||||
* Public variable to hold the information about the language domain.
|
||||
*
|
||||
* @var string 'mainwp-child' languge domain.
|
||||
*/
|
||||
public $plugin_translate = 'mainwp-child';
|
||||
|
||||
/**
|
||||
* Method instance()
|
||||
*
|
||||
* Create a public static instance.
|
||||
*
|
||||
* @return mixed Class instance.
|
||||
*/
|
||||
public static function instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_HTML_Regression constructor.
|
||||
*
|
||||
* Run any time class is called.
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method init()
|
||||
*
|
||||
* Initiate action hooks.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
if ( ! $this->is_plugin_installed ) {
|
||||
return;
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'track_admin_assets' ), 999 );
|
||||
add_filter( 'mainwp_site_sync_others_data', array( $this, 'sync_others_data' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method sync_others_data()
|
||||
*
|
||||
* Sync the HTML Regression plugin settings.
|
||||
*
|
||||
* @param array $information Array containing the sync information.
|
||||
* @param array $data Array containing the HTML Regression plugin data to be synced.
|
||||
*
|
||||
* @uses MainWP_Child_HTML_Regression::get_active_assets()
|
||||
* @uses MainWP_Child_HTML_Regression::get_frontend_assets_only()
|
||||
* @uses MainWP_Child_HTML_Regression::get_theme_css_js_files()
|
||||
*
|
||||
* @return array $information Array containing the sync information.
|
||||
*/
|
||||
public function sync_others_data( $information, $data = array() ) {
|
||||
|
||||
if ( isset( $data['sync_html_regression_data'] ) && ( 'yes' === $data['sync_html_regression_data'] ) ) {
|
||||
try {
|
||||
$data = array(
|
||||
'files' => $this->get_active_assets(),
|
||||
'plugins' => $this->get_frontend_assets_only(),
|
||||
'themes' => $this->get_theme_css_js_files(),
|
||||
);
|
||||
$information['sync_html_regression_data'] = $data;
|
||||
} catch ( MainWP_Exception $e ) {
|
||||
// ok!
|
||||
}
|
||||
}
|
||||
return $information;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_active_assets()
|
||||
*
|
||||
* Get plugin and theme files
|
||||
*
|
||||
* @uses MainWP_Child_HTML_Regression::get_css_js_files()
|
||||
* @uses MainWP_Child_HTML_Regression::get_theme_css_js_files()
|
||||
*
|
||||
* @return array List Folder files CSS, JS of Plugins and Theme.
|
||||
*/
|
||||
public function get_active_assets() {
|
||||
$result = array(
|
||||
'plugins' => array(),
|
||||
'theme' => array(),
|
||||
);
|
||||
|
||||
// Get a list of active plugins.
|
||||
$active_plugins = get_option( 'active_plugins', array() );
|
||||
$plugin_dir = WP_PLUGIN_DIR;
|
||||
|
||||
foreach ( $active_plugins as $plugin ) {
|
||||
$plugin_path = $plugin_dir . '/' . dirname( $plugin );
|
||||
$result['plugins'][ dirname( $plugin ) ] = $this->get_css_js_files( $plugin_path );
|
||||
}
|
||||
|
||||
// Get a list of CSS and JS files of the currently selected theme.
|
||||
$result['theme'] = $this->get_theme_css_js_files();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_css_js_files()
|
||||
*
|
||||
* Get css and js files from folder.
|
||||
*
|
||||
* @param string $directory directory path.
|
||||
*
|
||||
* @uses RecursiveDirectoryIterator
|
||||
* @uses RecursiveIteratorIterator
|
||||
* @return array List of CSS and JS files.
|
||||
*/
|
||||
public function get_css_js_files( $directory ) {
|
||||
$files = array();
|
||||
|
||||
// Check if directory exists.
|
||||
if ( ! is_dir( $directory ) ) {
|
||||
return $files;
|
||||
}
|
||||
|
||||
// Browse all files in the directory.
|
||||
$iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $directory ) );
|
||||
|
||||
foreach ( $iterator as $file ) {
|
||||
// Get the file extension.
|
||||
$extension = pathinfo( $file, PATHINFO_EXTENSION );
|
||||
|
||||
// Check if it is a .css or .js file.
|
||||
if ( in_array( $extension, array( 'css', 'js' ), true ) ) {
|
||||
// Save file path.
|
||||
$files[] = str_replace( ABSPATH, '', $file->getPathname() );
|
||||
}
|
||||
}
|
||||
// Rest value files.
|
||||
return array_values( $files );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_frontend_assets_only()
|
||||
*
|
||||
* Get a list of enqueued CSS and JS files and only get them from the frontend
|
||||
*
|
||||
* @uses MainWP_Child_HTML_Regression::is_asset_in_admin()
|
||||
* @uses MainWP_Child_HTML_Regression::get_plugin_name_from_path()
|
||||
*
|
||||
* @return array List of CSS and JS files.
|
||||
*/
|
||||
public function get_frontend_assets_only() {
|
||||
global $wp_styles, $wp_scripts;
|
||||
|
||||
$plugin_assets = array();
|
||||
|
||||
// Helper function to process assets.
|
||||
$process_assets = function ( $assets, $type ) use ( &$plugin_assets ) {
|
||||
foreach ( $assets as $handle => $asset ) {
|
||||
if ( isset( $asset->src ) && strpos( $asset->src, 'wp-content/plugins/' ) !== false && ! $this->is_asset_in_admin( $handle, $type ) ) {
|
||||
$plugin_info = $this->get_plugin_name_from_path( $asset->src );
|
||||
if ( empty( $plugin_info ) ) {
|
||||
continue;
|
||||
}
|
||||
$plugin_assets[ $plugin_info['path'] ]['name'] = $plugin_info['name'];
|
||||
$plugin_assets[ $plugin_info['path'] ][ $type . 's' ][] = array(
|
||||
'handle' => $handle,
|
||||
'src' => $asset->src,
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Process styles.
|
||||
if ( isset( $wp_styles->registered ) && is_array( $wp_styles->registered ) ) {
|
||||
$process_assets( $wp_styles->registered, 'style' );
|
||||
}
|
||||
|
||||
// Process scripts.
|
||||
if ( isset( $wp_scripts->registered ) && is_array( $wp_scripts->registered ) ) {
|
||||
$process_assets( $wp_scripts->registered, 'script' );
|
||||
}
|
||||
|
||||
return $plugin_assets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method is_asset_in_admin()
|
||||
*
|
||||
* Check if the CSS/JS file is loaded in admin or not.
|
||||
*
|
||||
* @param string $handle Asset name (CSS/JS).
|
||||
* @param string $type 'style' or 'script' to identify the asset type.
|
||||
* @return bool True if the asset is loaded in admin, false otherwise.
|
||||
*/
|
||||
public function is_asset_in_admin( $handle, $type ) {
|
||||
// Variable that checks whether the asset appears in admin or not.
|
||||
$is_in_admin = false;
|
||||
$admin_assets = get_option( 'html-regression-track-admin-assets', array() );
|
||||
if ( empty( $admin_assets ) ) {
|
||||
do_action( 'admin_enqueue_scripts' );
|
||||
$admin_assets = get_option( 'html-regression-track-admin-assets' );
|
||||
}
|
||||
|
||||
if ( 'style' === $type ) {
|
||||
// Check if the style is in the admin's enqueue list.
|
||||
if ( in_array( $handle, $admin_assets['styles'], true ) ) {
|
||||
$is_in_admin = true;
|
||||
}
|
||||
} elseif ( 'script' === $type ) {
|
||||
// Check if the script is in the admin's enqueue list.
|
||||
if ( in_array( $handle, $admin_assets['scripts'], true ) ) {
|
||||
$is_in_admin = true;
|
||||
}
|
||||
}
|
||||
|
||||
// If the asset is in admin, return true, otherwise false.
|
||||
return $is_in_admin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method track_admin_assets()
|
||||
*
|
||||
* Track admin assets files.
|
||||
*
|
||||
* @return void update option tracking admin assets plugins.
|
||||
*/
|
||||
public function track_admin_assets() {
|
||||
global $wp_styles, $wp_scripts;
|
||||
$admin_assets = array(
|
||||
'styles' => array(),
|
||||
'scripts' => array(),
|
||||
);
|
||||
|
||||
// save list styles.
|
||||
if ( isset( $wp_styles->queue ) && is_array( $wp_styles->queue ) ) {
|
||||
$admin_assets['styles'] = $wp_styles->queue;
|
||||
}
|
||||
|
||||
// Save the list of scripts.
|
||||
if ( isset( $wp_scripts->queue ) && is_array( $wp_scripts->queue ) ) {
|
||||
$admin_assets['scripts'] = $wp_scripts->queue;
|
||||
}
|
||||
|
||||
update_option( 'html-regression-track-admin-assets', $admin_assets, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_plugin_name_from_path()
|
||||
*
|
||||
* Get plugin name from file path.
|
||||
*
|
||||
* @param string $path CSS/JS file path.
|
||||
* @return mixed Name and path of plugin.
|
||||
*/
|
||||
private function get_plugin_name_from_path( $path ) {
|
||||
// Find the location of 'wp-content/plugins/' in the path.
|
||||
$plugin_path = strpos( $path, 'wp-content/plugins/' );
|
||||
if ( false !== $plugin_path ) {
|
||||
// Trim the string to get the plugin name.
|
||||
$relative_path = substr( $path, $plugin_path + strlen( 'wp-content/plugins/' ) );
|
||||
$parts = explode( '/', $relative_path );
|
||||
if ( ! empty( $parts[0] ) ) {
|
||||
// Get a list of all installed plugins.
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // NOSONAR - ok.
|
||||
}
|
||||
$all_plugins = get_plugins();
|
||||
|
||||
// Browse the plugin list to find the plugin name.
|
||||
foreach ( $all_plugins as $plugin_file => $plugin_data ) {
|
||||
if ( strpos( $plugin_file, $parts[0] ) === 0 ) {
|
||||
return array(
|
||||
'name' => $plugin_data['Name'],
|
||||
'path' => 'wp-content/plugins/' . $parts[0],
|
||||
); // Returns the exact plugin name.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null; // Returns the default name if unknown.
|
||||
}
|
||||
|
||||
/**
|
||||
* Method get_theme_css_js_files()
|
||||
*
|
||||
* Get theme css js files
|
||||
*
|
||||
* @uses MainWP_Child_HTML_Regression::get_css_js_files()
|
||||
* @return array theme css and js files.
|
||||
*/
|
||||
public function get_theme_css_js_files() {
|
||||
$theme = wp_get_theme();
|
||||
$theme_dir = get_template_directory();
|
||||
return array( $theme->get( 'Name' ) => $this->get_css_js_files( $theme_dir ) );
|
||||
}
|
||||
}
|
||||
@ -1,615 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* MainWP Child Install
|
||||
*
|
||||
* This file handles Plugins and Themes Activate, Deactivate and Delete process.
|
||||
*
|
||||
* @package MainWP\Child
|
||||
*/
|
||||
|
||||
namespace MainWP\Child;
|
||||
|
||||
/**
|
||||
* Class MainWP_Child_Install
|
||||
*
|
||||
* Handles Plugins and Themes Activate, Deactivate and Delete process.
|
||||
*/
|
||||
class MainWP_Child_Install {
|
||||
|
||||
/**
|
||||
* Public static variable to hold the single instance of MainWP_Child_Install.
|
||||
*
|
||||
* @var mixed Default null
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Get class name.
|
||||
*
|
||||
* @return string __CLASS__ Class name.
|
||||
*/
|
||||
public static function get_class_name() {
|
||||
return __CLASS__;
|
||||
}
|
||||
|
||||
/**
|
||||
* MainWP_Child_Install constructor
|
||||
*
|
||||
* Run any time class is called.
|
||||
*/
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a public static instance of MainWP_Child_Install.
|
||||
*
|
||||
* @return MainWP_Child_Install|mixed|null
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( null === static::$instance ) {
|
||||
static::$instance = new self();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method plugin_action()
|
||||
*
|
||||
* Plugin Activate, Deactivate & Delete actions.
|
||||
*
|
||||
* @uses get_plugin_data() Parses the plugin contents to retrieve plugin’s metadata.
|
||||
* @see https://developer.wordpress.org/reference/functions/get_plugin_data/
|
||||
*
|
||||
* @uses activate_plugin() Attempts activation of plugin in a “sandbox” and redirects on success.
|
||||
* @see https://developer.wordpress.org/reference/functions/activate_plugin/
|
||||
*
|
||||
* @uses deactivate_plugin() Deactivate a single plugin or multiple plugins.
|
||||
* @see https://developer.wordpress.org/reference/functions/deactivate_plugin/
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Child_Install::delete_plugins() Delete a plugin from the Child Site.
|
||||
* @uses \MainWP\Child\MainWP_Child_Stats::get_site_stats()
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function plugin_action() { //phpcs:ignore -- NOSONAR - complex.
|
||||
|
||||
/**
|
||||
* MainWP Child instance.
|
||||
*
|
||||
* @global object
|
||||
*/
|
||||
global $mainWPChild;
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
$action = MainWP_System::instance()->validate_params( 'action' );
|
||||
$plugins = isset( $_POST['plugin'] ) ? explode( '||', sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) ) : '';
|
||||
|
||||
$action_items = array();
|
||||
|
||||
include_once ABSPATH . '/wp-admin/includes/plugin.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . 'wp-admin/includes/file.php'; // NOSONAR -- WP compatible get_home_path().
|
||||
include_once ABSPATH . 'wp-admin/includes/misc.php'; // NOSONAR -- WP compatible extract_from_markers().
|
||||
|
||||
if ( 'activate' === $action ) {
|
||||
foreach ( $plugins as $plugin ) {
|
||||
if ( $plugin !== $mainWPChild->plugin_slug ) {
|
||||
$thePlugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||
if ( 'quotes-collection/quotes-collection.php' === $plugin ) {
|
||||
activate_plugin( $plugin, '', false, true );
|
||||
} else {
|
||||
activate_plugin( $plugin );
|
||||
}
|
||||
$action_items[ $plugin ] = array(
|
||||
'name' => $thePlugin['Name'],
|
||||
'version' => $thePlugin['Version'],
|
||||
'slug' => $plugin,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ( 'deactivate' === $action ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/plugin.php'; // NOSONAR -- WP compatible.
|
||||
|
||||
foreach ( $plugins as $plugin ) {
|
||||
if ( $plugin !== $mainWPChild->plugin_slug ) {
|
||||
$thePlugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||
deactivate_plugins( $plugin );
|
||||
$action_items[ $plugin ] = array(
|
||||
'name' => $thePlugin['Name'],
|
||||
'version' => $thePlugin['Version'],
|
||||
'slug' => $plugin,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ( 'delete' === $action ) {
|
||||
$this->delete_plugins( $plugins, $output );
|
||||
if ( ! empty( $output ) ) {
|
||||
$action_items = $output;
|
||||
}
|
||||
} elseif ( 'changelog_info' === $action ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; // NOSONAR -- WP compatible.
|
||||
$_slug = isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '';
|
||||
$api = plugins_api(
|
||||
'plugin_information',
|
||||
array(
|
||||
'slug' => $_slug,
|
||||
)
|
||||
);
|
||||
$information['update'] = $api;
|
||||
} else {
|
||||
$information['status'] = 'FAIL';
|
||||
}
|
||||
// phpcs:enable
|
||||
|
||||
if ( ! isset( $information['status'] ) ) {
|
||||
$information['status'] = 'SUCCESS';
|
||||
}
|
||||
if ( 'changelog_info' !== $action ) {
|
||||
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
|
||||
}
|
||||
$information['other_data'] = array(
|
||||
'plugin_action_data' => $action_items,
|
||||
);
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method delete_plugins()
|
||||
*
|
||||
* Delete a plugin from the Child Site.
|
||||
*
|
||||
* @param array $plugins An array of plugins to delete.
|
||||
* @param array $output An array output data.
|
||||
*
|
||||
* @uses get_plugin_data() Parses the plugin contents to retrieve plugin’s metadata.
|
||||
* @see https://developer.wordpress.org/reference/functions/get_plugin_data/
|
||||
*
|
||||
* @uses deactivate_plugin() Deactivate a single plugin or multiple plugins.
|
||||
* @see https://developer.wordpress.org/reference/functions/deactivate_plugin/
|
||||
*
|
||||
* @uses is_plugin_active() Determines whether a plugin is active.
|
||||
* @see https://developer.wordpress.org/reference/functions/is_plugin_active/
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Helper::check_wp_filesystem()
|
||||
*
|
||||
* @used-by \MainWP\Child\MainWP_Child_Install::plugin_action() Plugin Activate, Deactivate & Delete actions.
|
||||
*/
|
||||
private function delete_plugins( $plugins, &$output = array() ) { //phpcs:ignore -- NOSONAR - complex.
|
||||
|
||||
/**
|
||||
* MainWP Child instance.
|
||||
*
|
||||
* @global object
|
||||
*/
|
||||
global $mainWPChild;
|
||||
|
||||
include_once ABSPATH . '/wp-admin/includes/plugin.php'; // NOSONAR -- WP compatible.
|
||||
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/screen.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
include_once ABSPATH . '/wp-admin/includes/file.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/template.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; // NOSONAR -- WP compatible.
|
||||
|
||||
MainWP_Helper::check_wp_filesystem();
|
||||
|
||||
$pluginUpgrader = new \Plugin_Upgrader();
|
||||
|
||||
$all_plugins = get_plugins();
|
||||
foreach ( $plugins as $plugin ) {
|
||||
if ( $plugin !== $mainWPChild->plugin_slug && isset( $all_plugins[ $plugin ] ) ) {
|
||||
$old_plugin = $all_plugins[ $plugin ];
|
||||
if ( is_plugin_active( $plugin ) ) {
|
||||
$thePlugin = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin ) {
|
||||
deactivate_plugins( $plugin );
|
||||
}
|
||||
}
|
||||
$tmp['plugin'] = $plugin;
|
||||
if ( true === $pluginUpgrader->delete_old_plugin( null, null, null, $tmp ) ) {
|
||||
$args = array(
|
||||
'action' => 'delete',
|
||||
'Name' => $old_plugin['Name'],
|
||||
);
|
||||
do_action( 'mainwp_child_plugin_action', $args );
|
||||
$output[ $plugin ] = array(
|
||||
'name' => $old_plugin['Name'],
|
||||
'version' => $old_plugin['Version'],
|
||||
'slug' => $plugin,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method theme_action()
|
||||
*
|
||||
* Theme Activate, Deactivate & Delete actions.
|
||||
*
|
||||
* @uses wp_get_theme() Gets a WP_Theme object for a theme.
|
||||
* @see https://developer.wordpress.org/reference/functions/wp_get_theme/
|
||||
*
|
||||
* @uses switch_theme() Switches the theme.
|
||||
* @see https://developer.wordpress.org/reference/functions/switch_theme/
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Child_Stats::get_site_stats()
|
||||
* @uses \MainWP\Child\MainWP_Helper::check_wp_filesystem()
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function theme_action() { // phpcs:ignore -- NOSONAR - Current complexity is the only way to achieve desired results, pull request solutions appreciated.
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
$action = MainWP_System::instance()->validate_params( 'action' );
|
||||
$theme = isset( $_POST['theme'] ) ? sanitize_text_field( wp_unslash( $_POST['theme'] ) ) : '';
|
||||
$action_items = array();
|
||||
$deactivate_theme = array();
|
||||
// phpcs:enable
|
||||
if ( 'activate' === $action ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/theme.php'; // NOSONAR -- WP compatible.
|
||||
$theTheme = wp_get_theme( $theme );
|
||||
if ( null !== $theTheme && '' !== $theTheme ) {
|
||||
|
||||
$current_theme = wp_get_theme()->get( 'Name' );
|
||||
|
||||
$deactivate_theme[ $current_theme ] = array(
|
||||
'name' => $current_theme,
|
||||
'version' => wp_get_theme()->display( 'Version', true, false ),
|
||||
'slug' => wp_get_theme()->get_stylesheet(),
|
||||
);
|
||||
|
||||
switch_theme( $theTheme['Template'], $theTheme['Stylesheet'] );
|
||||
$action_items[ $theme ] = array(
|
||||
'name' => $theTheme->get( 'Name' ),
|
||||
'version' => $theTheme->display( 'Version', true, false ),
|
||||
'slug' => $theTheme->get_stylesheet(),
|
||||
);
|
||||
}
|
||||
} elseif ( 'delete' === $action ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/theme.php'; // NOSONAR -- WP compatible.
|
||||
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) { // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/screen.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
include_once ABSPATH . '/wp-admin/includes/file.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/template.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-base.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/class-wp-filesystem-direct.php'; // NOSONAR -- WP compatible.
|
||||
|
||||
MainWP_Helper::check_wp_filesystem();
|
||||
|
||||
$themeUpgrader = new \Theme_Upgrader();
|
||||
|
||||
$theme_name = wp_get_theme()->get_stylesheet();
|
||||
$parent = wp_get_theme()->parent();
|
||||
$parent_name = $parent ? $parent->get_stylesheet() : '';
|
||||
|
||||
$themes = explode( '||', $theme );
|
||||
|
||||
$themes = array_filter( $themes );
|
||||
|
||||
if ( count( $themes ) === 1 ) {
|
||||
$themeToDelete = current( $themes );
|
||||
if ( $themeToDelete === $theme_name ) {
|
||||
$information['error']['is_activated_theme'] = $themeToDelete;
|
||||
MainWP_Helper::write( $information );
|
||||
return;
|
||||
} elseif ( $themeToDelete === $parent_name ) {
|
||||
$information['error']['is_activated_parent'] = $themeToDelete;
|
||||
MainWP_Helper::write( $information );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $themes as $themeToDelete ) {
|
||||
if ( $themeToDelete === $theme_name ) {
|
||||
$information['error']['is_activated_theme'] = $themeToDelete;
|
||||
} elseif ( $themeToDelete === $parent_name ) {
|
||||
$information['error']['is_activated_parent'] = $themeToDelete;
|
||||
}
|
||||
if ( $themeToDelete !== $theme_name && $themeToDelete !== $parent_name ) {
|
||||
$theTheme = wp_get_theme( $themeToDelete );
|
||||
if ( null !== $theTheme && '' !== $theTheme ) {
|
||||
$tmp['theme'] = $theTheme->stylesheet; // to fix delete parent theme issue.
|
||||
if ( true === $themeUpgrader->delete_old_theme( null, null, null, $tmp ) ) {
|
||||
$args = array(
|
||||
'action' => 'delete',
|
||||
'Name' => $theTheme['Name'],
|
||||
);
|
||||
do_action( 'mainwp_child_theme_action', $args );
|
||||
|
||||
$action_items[ $themeToDelete ] = array(
|
||||
'name' => $theTheme->get( 'Name' ),
|
||||
'version' => $theTheme->display( 'Version', true, false ),
|
||||
'slug' => $theTheme->get_stylesheet(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$information['status'] = 'FAIL';
|
||||
}
|
||||
|
||||
if ( ! isset( $information['status'] ) ) {
|
||||
$information['status'] = 'SUCCESS';
|
||||
}
|
||||
|
||||
$information['sync'] = MainWP_Child_Stats::get_instance()->get_site_stats( array(), false );
|
||||
|
||||
$information['other_data'] = array(
|
||||
'theme_action_data' => $action_items,
|
||||
);
|
||||
|
||||
if ( 'activate' === $action && ! empty( $deactivate_theme ) ) {
|
||||
$information['other_data']['theme_deactivate_data'] = $deactivate_theme;
|
||||
}
|
||||
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method install_plugin_theme()
|
||||
*
|
||||
* Plugin & Theme Installation functions.
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Child_Install::require_files() Include necessary files.
|
||||
* @uses \MainWP\Child\MainWP_Child_Install::after_installed() After plugin or theme has been installed.
|
||||
* @uses \MainWP\Child\MainWP_Child_Install::no_ssl_filter_function() Hook to set ssl verify value.
|
||||
* @uses \MainWP\Child\MainWP_Child_Install::try_second_install() Alternative installation method.
|
||||
* @uses \MainWP\Child\MainWP_Helper::check_wp_filesystem()
|
||||
* @uses \MainWP\Child\MainWP_Helper::instance()->error()
|
||||
* @uses \MainWP\Child\MainWP_Helper::get_class_name()
|
||||
* @uses \MainWP\Child\MainWP_Helper::write()
|
||||
*/
|
||||
public function install_plugin_theme() { //phpcs:ignore -- NOSONAR - complex.
|
||||
|
||||
MainWP_Helper::check_wp_filesystem();
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if ( ! isset( $_POST['type'] ) || ! isset( $_POST['url'] ) || ( 'plugin' !== $_POST['type'] && 'theme' !== $_POST['type'] ) || '' === $_POST['url'] ) {
|
||||
MainWP_Helper::instance()->error( esc_html__( 'Plugin or theme not specified, or missing required data. Please reload the page and try again.', 'mainwp-child' ) );
|
||||
}
|
||||
|
||||
$type = sanitize_text_field( wp_unslash( $_POST['type'] ) );
|
||||
|
||||
$this->require_files();
|
||||
|
||||
$urlgot = isset( $_POST['url'] ) ? json_decode( stripslashes( wp_unslash( $_POST['url'] ) ) ) : ''; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
|
||||
$urls = array();
|
||||
if ( ! is_array( $urlgot ) ) {
|
||||
$urls[] = $urlgot;
|
||||
} else {
|
||||
$urls = $urlgot;
|
||||
}
|
||||
|
||||
// ensure admin upgrade classes are available.
|
||||
if ( ! class_exists( '\Automatic_Upgrader_Skin' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; // NOSONAR -ok.
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php'; // NOSONAR -ok.
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // NOSONAR -ok.
|
||||
}
|
||||
|
||||
// To fix conflict.
|
||||
if ( is_plugin_active( 'git-updater/git-updater.php' ) ) {
|
||||
remove_all_filters( 'upgrader_source_selection' );
|
||||
}
|
||||
|
||||
$install_results = array();
|
||||
$result = array();
|
||||
$install_items = array();
|
||||
foreach ( $urls as $url ) {
|
||||
$skin = new \Automatic_Upgrader_Skin();
|
||||
$installer = new \WP_Upgrader( $skin );
|
||||
$ssl_verify = true;
|
||||
// @see wp-admin/includes/class-wp-upgrader.php
|
||||
if ( isset( $_POST['sslVerify'] ) && '0' === $_POST['sslVerify'] ) {
|
||||
add_filter( 'http_request_args', array( static::get_class_name(), 'no_ssl_filter_function' ), 99, 2 );
|
||||
$ssl_verify = false;
|
||||
}
|
||||
add_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'reject_unsafe_urls' ), 99, 2 );
|
||||
|
||||
$result = $installer->run(
|
||||
array(
|
||||
'package' => $url,
|
||||
'destination' => ( 'plugin' === $type ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/themes' ),
|
||||
'clear_destination' => ( isset( $_POST['overwrite'] ) && sanitize_text_field( wp_unslash( $_POST['overwrite'] ) ) ),
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_wp_error( $result ) && true === $ssl_verify && strpos( $url, 'https://' ) === 0 ) {
|
||||
$ssl_verify = false;
|
||||
$result = $this->try_second_install( $url, $installer );
|
||||
}
|
||||
|
||||
remove_filter( 'http_request_args', array( MainWP_Helper::get_class_name(), 'reject_unsafe_urls' ), 99, 2 );
|
||||
if ( false === $ssl_verify ) {
|
||||
remove_filter( 'http_request_args', array( static::get_class_name(), 'no_ssl_filter_function' ), 99 );
|
||||
}
|
||||
$this->after_installed( $result, $output );
|
||||
$basename = basename( rawurldecode( $url ) );
|
||||
$install_results[ $basename ] = is_array( $result ) && isset( $result['destination_name'] ) ? true : false;
|
||||
|
||||
if ( is_array( $output ) ) {
|
||||
if ( 'plugin' === $type && isset( $output['Name'] ) ) {
|
||||
$install_items[] = array(
|
||||
'name' => $output['Name'],
|
||||
'version' => $output['Version'],
|
||||
'slug' => $output['slug'],
|
||||
);
|
||||
} elseif ( 'theme' === $type && isset( $output['slug'] ) ) {
|
||||
$install_items[] = array(
|
||||
'name' => isset( $output['name'] ) ? $output['name'] : $output['slug'],
|
||||
'slug' => $output['slug'],
|
||||
'version' => isset( $output['version'] ) ? $output['version'] : '',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// phpcs:enable
|
||||
|
||||
$information['installation'] = 'SUCCESS';
|
||||
$information['destination_name'] = $result['destination_name'];
|
||||
$information['install_results'] = $install_results;
|
||||
$information['other_data']['install_items'] = $install_items;
|
||||
|
||||
MainWP_Helper::write( $information );
|
||||
}
|
||||
|
||||
/**
|
||||
* Method no_ssl_filter_function()
|
||||
*
|
||||
* Hook to set ssl verify value.
|
||||
*
|
||||
* @param array $r Request's array values.
|
||||
*
|
||||
* @used-by install_plugin_theme() Plugin & Theme Installation functions.
|
||||
*
|
||||
* @return array $r Request's array values.
|
||||
*/
|
||||
public static function no_ssl_filter_function( $r ) {
|
||||
$r['sslverify'] = false;
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method require_files()
|
||||
*
|
||||
* Include necessary files.
|
||||
*
|
||||
* @used-by install_plugin_theme() Plugin & Theme Installation functions.
|
||||
*/
|
||||
private function require_files() {
|
||||
if ( file_exists( ABSPATH . '/wp-admin/includes/screen.php' ) ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/screen.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
include_once ABSPATH . '/wp-admin/includes/template.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/misc.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php'; // NOSONAR -- WP compatible.
|
||||
include_once ABSPATH . '/wp-admin/includes/plugin.php'; // NOSONAR -- WP compatible.
|
||||
}
|
||||
|
||||
/**
|
||||
* Method after_installed()
|
||||
*
|
||||
* After plugin or theme has been installed.
|
||||
*
|
||||
* @param array $result Results array from static::install_plugin_theme().
|
||||
* @param array $output Results output array.
|
||||
*
|
||||
* @uses wp_cache_set() Saves the data to the cache.
|
||||
* @see https://developer.wordpress.org/reference/functions/wp_cache_set/
|
||||
*
|
||||
* @uses activate_plugin() Attempts activation of plugin in a “sandbox” and redirects on success.
|
||||
* @see https://developer.wordpress.org/reference/functions/activate_plugin/
|
||||
*
|
||||
* @uses get_plugin_data() Parses the plugin contents to retrieve plugin’s metadata.
|
||||
* @see https://developer.wordpress.org/reference/functions/get_plugin_data/
|
||||
*
|
||||
* @used-by install_plugin_theme() Plugin & Theme Installation functions.
|
||||
*/
|
||||
private function after_installed( $result, &$output ) { //phpcs:ignore -- NOSONAR - complex.
|
||||
$args = array(
|
||||
'success' => 1,
|
||||
'action' => 'install',
|
||||
);
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
if ( isset( $_POST['type'] ) && 'plugin' === $_POST['type'] ) {
|
||||
$path = $result['destination'];
|
||||
$fileName = '';
|
||||
wp_cache_set( 'plugins', array(), 'plugins' );
|
||||
foreach ( $result['source_files'] as $srcFile ) {
|
||||
if ( is_dir( $path . $srcFile ) ) {
|
||||
continue;
|
||||
}
|
||||
$thePlugin = get_plugin_data( $path . $srcFile );
|
||||
if ( null !== $thePlugin && '' !== $thePlugin && '' !== $thePlugin['Name'] && 'readme.txt' !== $srcFile && 'README.md' !== $srcFile ) { // to fix: skip readme.txt.
|
||||
$args['type'] = 'plugin';
|
||||
$args['Name'] = $thePlugin['Name'];
|
||||
$args['Version'] = $thePlugin['Version'];
|
||||
$args['slug'] = $result['destination_name'] . '/' . $srcFile;
|
||||
$fileName = $srcFile;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $fileName ) ) {
|
||||
do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' ); // NOSONAR - no IP.
|
||||
do_action( 'mainwp_child_install_plugin_theme', $args );
|
||||
|
||||
if ( isset( $_POST['activatePlugin'] ) && 'yes' === $_POST['activatePlugin'] ) {
|
||||
// to fix activate issue.
|
||||
if ( 'quotes-collection/quotes-collection.php' === $args['slug'] ) {
|
||||
activate_plugin( $path . $fileName, '', false, true );
|
||||
} else {
|
||||
activate_plugin( $path . $fileName, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$args['type'] = 'theme';
|
||||
$slug = $result['destination_name'];
|
||||
$args['slug'] = $slug;
|
||||
if ( ! empty( $slug ) ) {
|
||||
wp_clean_themes_cache();
|
||||
$theme = wp_get_theme( $slug );
|
||||
if ( $theme ) {
|
||||
$args['name'] = $theme->name;
|
||||
$args['version'] = $theme->version;
|
||||
}
|
||||
}
|
||||
do_action_deprecated( 'mainwp_child_installPluginTheme', array( $args ), '4.0.7.1', 'mainwp_child_install_plugin_theme' ); // NOSONAR - no IP.
|
||||
do_action( 'mainwp_child_install_plugin_theme', $args );
|
||||
}
|
||||
$output = $args;
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
/**
|
||||
* Method try_second_install()
|
||||
*
|
||||
* Alternative installation method.
|
||||
*
|
||||
* @return object $result Return error messages or TRUE.
|
||||
*
|
||||
* @param string $url Package URL.
|
||||
* @param object $installer Instance of \WP_Upgrader.
|
||||
*
|
||||
* @uses is_wp_error() Check whether variable is a WordPress Error.
|
||||
* @see https://developer.wordpress.org/reference/functions/is_wp_error/
|
||||
*
|
||||
* @uses \MainWP\Child\MainWP_Helper::instance()->error()
|
||||
*
|
||||
* @used-by install_plugin_theme() Plugin & Theme Installation functions.
|
||||
*/
|
||||
private function try_second_install( $url, $installer ) {
|
||||
// phpcs:disable WordPress.Security.NonceVerification
|
||||
$result = $installer->run(
|
||||
array(
|
||||
'package' => $url,
|
||||
'destination' => ( isset( $_POST['type'] ) && 'plugin' === $_POST['type'] ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/themes' ),
|
||||
'clear_destination' => ( isset( $_POST['overwrite'] ) && sanitize_text_field( wp_unslash( $_POST['overwrite'] ) ) ),
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(),
|
||||
)
|
||||
);
|
||||
// phpcs:enable
|
||||
if ( is_wp_error( $result ) ) {
|
||||
$err_code = $result->get_error_code();
|
||||
if ( $result->get_error_data() && is_string( $result->get_error_data() ) ) {
|
||||
$error = $result->get_error_data();
|
||||
MainWP_Helper::instance()->error( $error, $err_code );
|
||||
} else {
|
||||
MainWP_Helper::instance()->error( '', $err_code );
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||