Plugin Directory

Changeset 2983037


Ignore:
Timestamp:
10/24/2023 11:28:55 AM (2 years ago)
Author:
nativerentplugin
Message:

1.8.4

Location:
nativerent/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • nativerent/trunk/includes/class-apicore.php

    r2964096 r2983037  
    5959        $method  = ( isset( $options['requestMethod'] ) ) ? $options['requestMethod'] : 'POST';
    6060        $args    = array();
    61         $headers = array();
     61        $headers = array(
     62            'Connection' => 'keep-alive',
     63        );
    6264
    6365        $request_url        = self::get_api_host() . $path . $command;
  • nativerent/trunk/includes/class-maintenance.php

    r2974729 r2983037  
    1313
    1414use const INPUT_GET;
    15 use const NATIVERENT_API_V1_PARAM;
    1615
    1716defined( 'ABSPATH' ) || exit;
     
    2120 */
    2221class Maintenance {
     22    const API_PARAM = 'NativeRentAPIv1';
    2323
    2424    /**
     
    2626     */
    2727    public static function init() {
    28         // API handlers.
    29         if ( isset( $_GET[ NATIVERENT_API_V1_PARAM ] ) ) {
    30             self::handle_v1_api( filter_input( INPUT_GET, NATIVERENT_API_V1_PARAM ) );
     28        $action = self::get_action_name();
     29        if ( is_string( $action ) ) {
     30            self::handle_v1_api( $action );
    3131        }
     32    }
     33
     34    /**
     35     * Getting API method name.
     36     *
     37     * @return string|null
     38     */
     39    private static function get_action_name() {
     40        // Getting API method by GET param value.
     41        if ( isset( $_GET[ self::API_PARAM ] ) ) {
     42            $action = filter_input( INPUT_GET, self::API_PARAM );
     43            if ( is_string( $action ) ) {
     44                return $action;
     45            }
     46        }
     47
     48        // Trying to get a method from the HTTP header.
     49        $header_name = strtoupper( 'HTTP_X_' . self::API_PARAM );
     50        if ( isset( $_SERVER[ $header_name ] ) ) {
     51            $action = filter_input( INPUT_SERVER, $header_name );
     52            if ( is_string( $action ) ) {
     53                return $action;
     54            }
     55        }
     56
     57        return null;
    3258    }
    3359
  • nativerent/trunk/includes/class-optimization-handler.php

    r2964096 r2983037  
    2020     * @var array
    2121     */
    22     public static $scripts_patterns = array(
    23         'nativerent',
    24         'window.NRent(AdUnits|Counter|Plugin)',
    25         'nativerent-integration-head',
    26     );
     22    public static $scripts_patterns
     23        = array(
     24            'nativerent',
     25            'window.NRent(AdUnits|Counter|Plugin)',
     26            'nativerent-integration-head',
     27        );
    2728
    2829    /**
     
    3233        // WP Rocket.
    3334        add_filter( 'rocket_exclude_js', array( __CLASS__, 'exclude_js' ) );
    34         add_filter( 'rocket_excluded_inline_js_content', array( __CLASS__, 'exclude_inline_js_wp_rocket' ) );
    3535        add_filter( 'rocket_exclude_defer_js', array( __CLASS__, 'exclude_js' ) );
    3636        add_filter( 'rocket_delay_js_exclusions', array( __CLASS__, 'exclude_js' ) );
     37        add_filter( 'rocket_excluded_inline_js_content', array( __CLASS__, 'exclude_js' ) );
    3738
    3839        // LiteSpeed Cache.
     
    4546     * Excludes JS files from minification/combine
    4647     *
    47      * @param array $scripts Array of JS patterns to be excluded.
    48      * @return array
     48     * @param  string[]|null $scripts  Array of JS patterns to be excluded.
     49     *
     50     * @return string[]
    4951     */
    5052    public static function exclude_js( $scripts = array() ) {
    51         return array_merge( $scripts, self::$scripts_patterns );
     53        return ! is_array( $scripts )
     54            ? self::$scripts_patterns
     55            : array_merge( $scripts, self::$scripts_patterns );
    5256    }
    53 
    5457}
  • nativerent/trunk/nativerent-bootstrap.php

    r2974729 r2983037  
    3131    define( 'NATIVERENT_PLUGIN_MAX_PRIORITY', PHP_INT_MAX );
    3232}
    33 // API param names.
    34 if ( ! defined( 'NATIVERENT_API_V1_PARAM' ) ) {
    35     define( 'NATIVERENT_API_V1_PARAM', 'NativeRentAPIv1' );
    36 }
    3733// Get param name for updating expired auth data.
    3834if ( ! defined( 'NATIVERENT_PARAM_AUTH' ) ) {
    3935    define( 'NATIVERENT_PARAM_AUTH', '_nrpluginauth' );
    40 }
    41 // Interval in seconds for running self check cron job.
    42 if ( ! defined( 'NATIVERENT_SELF_CHECK_INTERVAL' ) ) {
    43     $_nsci_sec = getenv( 'NATIVERENT_SELF_CHECK_INTERVAL' );
    44     define( 'NATIVERENT_SELF_CHECK_INTERVAL', is_numeric( $_nsci_sec ) ? $_nsci_sec : ( 3 * 60 * 60 ) );
    45     unset( $_nsci_sec );
    4636}
    4737// Interval in seconds for running auto-update monetizations.
     
    5343// Plugin version.
    5444if ( ! defined( 'NATIVERENT_PLUGIN_VERSION' ) ) {
    55     define( 'NATIVERENT_PLUGIN_VERSION', '1.8.3' );
     45    define( 'NATIVERENT_PLUGIN_VERSION', '1.8.4' );
    5646}
    5747
  • nativerent/trunk/nativerent.php

    r2974729 r2983037  
    66 * Plugin URI:        https://wordpress.org/plugins/nativerent/
    77 * Description:       Релевантная реклама для ваших читателей. Рекламодатели сервиса платят в 2-3 раза больше за 1 тыс. показов страниц, чем привычные рекламные сетки. Страница выкупается полностью, на ней размещается максимум четыре рекламных блока, которые выглядят нативно в стиле сайта.
    8  * Version:           1.8.3
     8 * Version:           1.8.4
    99 * Requires at least: 4.9
    10  * Tested up to:      6.3
     10 * Tested up to:      6.3.2
    1111 * Requires PHP:      5.6.20
    1212 * Author:            Native Rent
  • nativerent/trunk/readme.txt

    r2974729 r2983037  
    55Plugin URI:        https://wordpress.org/plugins/nativerent/
    66Requires at least: 4.9
    7 Tested up to:      6.3
     7Tested up to:      6.3.2
    88Requires PHP:      5.6.20
    9 Stable tag:        1.8.3
     9Stable tag:        1.8.4
    1010License:           GPLv2 or later
    1111License URI:       https://www.gnu.org/licenses/gpl-2.0.html
  • nativerent/trunk/static/content.js

    r2974729 r2983037  
    2222    }
    2323
     24    function calcOffsetTop(el) {
     25        return (el.getBoundingClientRect().top + window.pageYOffset)
     26    }
     27
    2428    function contentIntegration() {
    2529        if (window.NRentContentIntegrated === true) {
     
    4347                var adUnit = window.NRentAdUnits[i]
    4448                var anchor = undefined
     49                var dataPlacementAttr = true
    4550
    4651                switch (adUnit.autoSelector) {
     
    7176                    case 'body': {
    7277                        anchor = window.document.body
     78                        dataPlacementAttr = false
    7379                        break
    7480                    }
    7581                    case '': {
    7682                        try {
     83                            dataPlacementAttr = false
    7784                            var customSelector = decodeURIComponent(adUnit.selector)
    7885                            if (!/^body[^a-z0-9]/i.test(customSelector)) {
     
    106113                    (window.NRentCounter.options || window.NRentCounter || {id: 'undefined'}).id + '-' + i
    107114
     115                if (dataPlacementAttr) {
     116                    adUnit.element.setAttribute(
     117                        'data-placement',
     118                        (typeof adUnit.insert === 'string' && adUnit.insert !== '' ? adUnit.insert : 'after')
     119                    )
     120                }
     121
    108122                switch (adUnit.insert) {
    109123                    case 'after': {
     
    144158                        }
    145159
    146                         var distance = (adUnit.element.offsetTop - previousAdUnit.element.offsetTop)
     160                        var distance = (calcOffsetTop(adUnit.element) - calcOffsetTop(previousAdUnit.element))
    147161                        if (window.document.body.clientHeight > minDistance && distance < minDistance) {
    148162                            logger.log(
Note: See TracChangeset for help on using the changeset viewer.