Plugin Directory

Changeset 2689658


Ignore:
Timestamp:
03/06/2022 08:45:35 PM (4 years ago)
Author:
stooit
Message:

v1.3.2 release.

Location:
quant
Files:
49 added
4 edited

Legend:

Unmodified
Added
Removed
  • quant/trunk/quant.php

    r2689403 r2689658  
    66 * Author: Stuart Rowlands
    77 * Plugin URI: https://www.quantcdn.io
    8  * Version: 1.3.1
     8 * Version: 1.3.2
    99 * License: GPL-2.0+
    1010 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
  • quant/trunk/readme.txt

    r2689404 r2689658  
    66Tested up to: 5.9.1
    77Requires PHP: 7.1
    8 Stable tag: 1.3.1
     8Stable tag: 1.3.2
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5656== Changelog ==
    5757
     58= 1.3.2 =
     59* Improved multisite support: Quant Search (filter content by site)
     60* Multisite bugfix: Resolved some media assets not seeding correctly
     61* Added configurable HTTP timeout value
     62
    5863= 1.3.1 =
    5964* Adds option to disable SSL verification if required.
  • quant/trunk/src/Client.php

    r2689403 r2689658  
    1515    private $host;
    1616    private $disableTlsVerify = FALSE;
     17    private $httpRequestTimeout = 15;
    1718
    1819    public function __construct() {
     
    2728        $this->headers['quant-token'] = $this->settings['api_token'];
    2829        $this->disableTlsVerify = $this->settings['disable_tls_verify'];
     30        $this->httpRequestTimeout = intval($this->settings['http_request_timeout']) ?? 15;
    2931    }
    3032
     
    3436        $args = [
    3537            'headers' => $this->headers,
     38            'timeout' => $this->httpRequestTimeout,
    3639        ];
    3740
     
    5659        $args = [
    5760            'headers' => $headers,
    58             'method' => 'PATCH'
     61            'method' => 'PATCH',
     62            'timeout' => $this->httpRequestTimeout,
    5963        ];
    6064
     
    7983            'headers' => $this->headers,
    8084            'body' => json_encode($data),
    81             'timeout' => 30,
     85            'timeout' => $this->httpRequestTimeout,
    8286        ];
    8387
     
    109113            'headers' => $this->headers,
    110114            'body' => json_encode($data),
    111             'timeout' => 30,
     115            'timeout' => $this->httpRequestTimeout,
    112116        ];
    113117
     
    137141        $args = [
    138142            'headers' => $headers,
    139             'timeout' => 30,
     143            'timeout' => $this->httpRequestTimeout,
    140144        ];
    141145
     
    156160     */
    157161    public function sendAttachments($media) {
     162
     163        // Determine current site (multisite installs).
     164        if (is_multisite()) {
     165            $site = get_site();
     166        }
     167
    158168        $attachments = [];
    159169
     
    167177
    168178            // Strip query params.
    169             $file = strtok($url, '?');
     179            $file = $url = strtok($url, '?');
     180
     181            // Strip the site path from the front of the URL.
     182            if (isset($site->path)) {
     183              $file = preg_replace("#^{$site->path}#", '/', $file);
     184            }
    170185
    171186            if (isset($item['existing_md5'])) {
     
    177192
    178193            if (file_exists(ABSPATH . $file)) {
    179                 $attachments[] = $file;
     194                $attachments[] = [
     195                  'file' => $file,
     196                  'url' => $url,
     197                ];
    180198            }
    181199        }
     
    199217
    200218        foreach ($files as $file) {
    201             $headers['Quant-File-Url'] = $file;
    202             $path = ABSPATH . $file;
     219            $headers['Quant-File-Url'] = $file['url'];
     220            $path = ABSPATH . $file['file'];
    203221
    204222            $requests[] = [
     
    207225                'headers' => $headers,
    208226                'sslverify' => $this->disableTlsVerify ? FALSE : TRUE,
     227                'timeout' => $this->httpRequestTimeout,
    209228            ];
    210229        }
     
    284303            'headers' => [
    285304                'content-type' => $content_type,
    286             ]
     305            ],
    287306        ];
    288307
     
    352371                    'tags' => [],
    353372                    'categories' => wp_get_post_categories($id, ['fields' => 'names']),
     373                    'site_id' => get_current_blog_id(),
    354374                ]
    355375            ]
     
    388408                'Quant-Token' => $token,
    389409            ],
     410            'timeout' => $this->httpRequestTimeout,
    390411        ];
    391412
  • quant/trunk/src/Settings.php

    r2689403 r2689658  
    4949            'description' => 'Optionally disable TLS verification.',
    5050            'value' => $options['disable_tls_verify'] ?? 0,
     51        ]);
     52
     53        add_settings_field('quant_http_request_timeout', 'HTTP request timeout', ['Quant\Field', 'text'], $key, 'general', [
     54            'name' => "{$key}[http_request_timeout]",
     55            'description' => 'Optionally increase the HTTP request timeout on slower servers.',
     56            'value' => $options['http_request_timeout'] ?? 15,
    5157        ]);
    5258
Note: See TracChangeset for help on using the changeset viewer.