Plugin Directory

Changeset 2822057


Ignore:
Timestamp:
11/22/2022 10:36:54 AM (3 years ago)
Author:
nativerentplugin
Message:

1.5.1

Location:
nativerent/trunk
Files:
8 added
26 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • nativerent/trunk/admin/static/main.css

    r2821958 r2822057  
    7171#NativeRentAdmin_dropSiteCacheContainer
    7272{
     73    visibility: hidden;
    7374    line-height: 2.15384615;
    7475    vertical-align: middle;
  • nativerent/trunk/nativerent.php

    r2821958 r2822057  
    1111 * Plugin URI:        https://wordpress.org/plugins/nativerent/
    1212 * Description:       Релевантная реклама для ваших читателей. Рекламодатели сервиса платят в 2-3 раза больше за 1 тыс. показов страниц, чем привычные рекламные сетки. Страница выкупается полностью, на ней размещается максимум четыре рекламных блока, которые выглядят нативно в стиле сайта.
    13  * Version:           1.5.0
    14  * Requires at least: 5.1
    15  * Tested up to:      6.1.1
     13 * Version:           1.5.1
     14 * Requires at least: 4.9
    1615 * Requires PHP:      5.6.20
    1716 * Author:            Native Rent
     
    2120 * Text Domain:       cyr2lat
    2221 * Domain Path:       /languages/
     22 *
     23 *
     24 * WC requires at least: 3.0
     25 * WC tested up to:      5.9.3
    2326 */
    2427
    2528// Exit if accessed directly.
    26 defined( 'ABSPATH' ) || exit;
    27 
     29defined( 'ABSPATH' ) || exit( '403 Forbidden' );
     30
     31// Plugin version.
     32if ( ! defined( 'NATIVERENT_PLUGIN_VERSION' ) ) {
     33    define( 'NATIVERENT_PLUGIN_VERSION', '1.5.1' );
     34}
    2835// Plugin Folder Path.
    2936if ( ! defined( 'NATIVERENT_PLUGIN_DIR' ) ) {
     
    4047// Value for minimal priority argument.
    4148if ( ! defined( 'NATIVERENT_PLUGIN_MIN_PRIORITY' ) ) {
    42     define( 'NATIVERENT_PLUGIN_MIN_PRIORITY', ( - PHP_INT_MAX - 1 ) );
     49    define( 'NATIVERENT_PLUGIN_MIN_PRIORITY', - 2147483647 );
    4350}
    4451// Value for maximal priority argument.
    4552if ( ! defined( 'NATIVERENT_PLUGIN_MAX_PRIORITY' ) ) {
    46     define( 'NATIVERENT_PLUGIN_MAX_PRIORITY', PHP_INT_MAX );
     53    define( 'NATIVERENT_PLUGIN_MAX_PRIORITY', 2147483647 );
    4754}
    4855// API param names.
     
    5057    define( 'NATIVERENT_API_V1_PARAM', 'NativeRentAPIv1' );
    5158}
    52 // Get param name for updating expired auth data.
    53 if ( ! defined( 'NATIVERENT_PARAM_AUTH' ) ) {
    54     define( 'NATIVERENT_PARAM_AUTH', '_nrpluginauth' );
    55 }
    56 // Plugin version.
    57 if ( ! defined( 'NATIVERENT_PLUGIN_VERSION' ) ) {
    58     define( 'NATIVERENT_PLUGIN_VERSION', '1.5.0' );
    59 }
    60 
    61 require_once NATIVERENT_PLUGIN_DIR . 'includes/class-autoloader.php';
    62 require_once NATIVERENT_PLUGIN_DIR . 'includes/functions.php';
    63 
    64 NativeRent\Init::instance();
     59
     60require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentadv.php';
     61require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentapi.php';
     62require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentoptions.php';
     63require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentautoconfig.php';
     64require_once NATIVERENT_PLUGIN_DIR . 'includes/utils.php';
     65
     66// Include admin section.
     67if ( is_admin() ) {
     68    require_once NATIVERENT_PLUGIN_DIR . 'admin/main.php';
     69
     70} elseif (
     71    ( ! isset( $_SERVER['REQUEST_URI'] ) ||
     72      false === strpos( esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'wp-login' ) )
     73    &&
     74    NativeRentOptions::authenticated()
     75) {
     76    // API handlers.
     77    if ( isset( $_GET[ NATIVERENT_API_V1_PARAM ] ) ) {
     78        nativerent_api_v1_handler( filter_input( INPUT_GET, NATIVERENT_API_V1_PARAM ) );
     79
     80        return;
     81    }
     82    // Integration to page.
     83    add_filter(
     84        'nativerent_integration_filter',
     85        function ( $output ) {
     86            try {
     87                return NativeRentAdv::processing( $output );
     88            } catch ( Exception $e ) {
     89                nativerent_report_error( $e );
     90
     91                return $output;
     92            }
     93        },
     94        NATIVERENT_PLUGIN_MAX_PRIORITY
     95    );
     96    add_filter(
     97        'wp_headers',
     98        function ( $headers ) {
     99            // Disable browser cache.
     100            $headers['Expires']       = 'Thu, 01 Jan 1970 00:00:01 GMT';
     101            $headers['Last-Modified'] = gmdate( 'D, d M Y H:i:s' ) . ' GMT';
     102            $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
     103            $headers['Pragma']        = 'no-cache';
     104            if ( isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
     105                unset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] );
     106            }
     107
     108            return $headers;
     109        },
     110        NATIVERENT_PLUGIN_MAX_PRIORITY
     111    );
     112    add_action( 'template_redirect', 'nativerent_integration_action', NATIVERENT_PLUGIN_MIN_PRIORITY );
     113    add_action( 'template_redirect', 'nativerent_content_integration', NATIVERENT_PLUGIN_MIN_PRIORITY + 1 );
     114    add_action( 'shutdown', 'nativerent_shutdown_action', NATIVERENT_PLUGIN_MIN_PRIORITY );
     115}
     116
     117/**
     118 * Run integration process
     119 *
     120 * @return void
     121 */
     122function nativerent_integration_action() {
     123    if ( ! is_single() && ! is_page() ) {
     124        return;
     125    }
     126
     127    ob_start( 'nativerent_head_integration' );
     128}
     129
     130/**
     131 * Action handler for `shutdown`.
     132 *
     133 * @return void
     134 */
     135function nativerent_shutdown_action() {
     136    if ( in_array( 'nativerent_head_integration', ob_list_handlers() ) ) {
     137        ob_get_flush();
     138    }
     139}
     140
     141/**
     142 * Realtime integration scripts and styles to the <head>...</head>.
     143 * We should use code injection method like this to make sure it has the highest priority.
     144 *
     145 * @param string $buffer Content chunk.
     146 *
     147 * @return string
     148 */
     149function nativerent_head_integration( $buffer ) {
     150    return apply_filters( 'nativerent_integration_filter', $buffer );
     151}
     152
     153/**
     154 * Injection <div> to the content for determine the possibility of run `nativerent_head_integration`.
     155 *
     156 * @return void
     157 */
     158function nativerent_content_integration() {
     159    if ( ! is_single() && ! is_page() ) {
     160        return;
     161    }
     162
     163    add_filter(
     164        'the_content',
     165        function ( $content ) {
     166            try {
     167                return NativeRentAdv::content_integration( $content );
     168            } catch ( Exception $e ) {
     169                nativerent_report_error( $e );
     170
     171                return $content;
     172            }
     173        },
     174        NATIVERENT_PLUGIN_MIN_PRIORITY
     175    );
     176}
     177
     178/**
     179 * API handlers
     180 *
     181 * @param  string $method  API method name.
     182 *
     183 * @return void
     184 */
     185function nativerent_api_v1_handler( $method ) {
     186    switch ( $method ) {
     187        case 'check':
     188            NativeRentAPI::check();
     189            break;
     190
     191        case 'updateAdvPatterns':
     192            NativeRentAPI::update_adv_patterns();
     193            break;
     194
     195        case 'vars':
     196            NativeRentAPI::vars();
     197            break;
     198
     199        default:
     200            header( 'HTTP/1.1 403 Forbidden' );
     201            exit();
     202    }
     203}
     204
     205/**
     206 * Plugin event activation hook
     207 *
     208 * @return void
     209 */
     210function nativerent_plugin_activation() {
     211    // just another reactivation.
     212    if ( NativeRentOptions::authenticated() ) {
     213        NativeRentAPI::status( 'activated' );
     214    } else {
     215        // first activation after installation.
     216        NativeRentOptions::install();
     217    }
     218    NativeRentOptions::set( 'status', 'activated' );
     219
     220    // revert configs patches from old versions.
     221    NativeRentAutoconfig::uninstall();
     222}
     223
     224register_activation_hook( NATIVERENT_PLUGIN_FILE, 'nativerent_plugin_activation' );
     225
     226/**
     227 * Plugin event deactivation hook
     228 *
     229 * @return void
     230 */
     231function nativerent_plugin_deactivation() {
     232    if ( NativeRentOptions::authenticated() ) {
     233        NativeRentAPI::status( 'deactivated' );
     234    }
     235    NativeRentOptions::set( 'status', 'deactivated' );
     236}
     237
     238register_deactivation_hook( NATIVERENT_PLUGIN_FILE, 'nativerent_plugin_deactivation' );
     239
     240/**
     241 * Plugin event uninstall hook
     242 *
     243 * @return void
     244 */
     245function nativerent_plugin_uninstall() {
     246    if ( NativeRentOptions::authenticated() ) {
     247        NativeRentAPI::status( 'uninstalled' );
     248    }
     249    NativeRentAdv::uninstall();
     250    NativeRentOptions::uninstall();
     251    NativeRentAutoconfig::uninstall();
     252}
     253
     254register_uninstall_hook( NATIVERENT_PLUGIN_FILE, 'nativerent_plugin_uninstall' );
     255
     256if ( NativeRentOptions::get( 'status' ) !== 'activated' ) {
     257    NativeRentOptions::set( 'status', 'activated' );
     258}
  • nativerent/trunk/readme.txt

    r2821958 r2822057  
    44Contributors:      nativerentplugin
    55Plugin URI:        https://wordpress.org/plugins/nativerent/
    6 Requires at least: 5.1
    7 Tested up to:      6.1.1
    8 Requires PHP:      5.6.20
    9 Stable tag:        1.5.0
     6Requires at least: 4.9
     7Tested up to:      6.0.2
     8Requires PHP:      5.6
     9Stable tag:        1.5.1
    1010License:           GPLv2 or later
    1111License URI:       https://www.gnu.org/licenses/gpl-2.0.html
  • nativerent/trunk/static/content.js

    r2821958 r2822057  
    5959                {
    6060                    var customSelector = decodeURIComponent( adUnit.selector );
    61                     if( /^body[^a-z0-9]/i.test( customSelector ) === false )
     61                    if( /^body[^a-z0-9]/i.test( customSelector ) == false )
    6262                    {
    6363                        anchor = article.querySelector( customSelector );
     
    109109
    110110
    111             if( i === 1 || i === 2 )
     111            if( i == 1 || i == 2 )
    112112            {
    113113                var previousAdUnit = window.NRentAdUnits[i - 1];
    114                 if (previousAdUnit.element === undefined) {
    115                     console.log( "NRent: adUnit '" + adUnit.type + "' is unable to calculate distance to previous adUnit '" + previousAdUnit.type + "'" );
    116                     break;
    117                 }
    118 
    119114                var distance = ( adUnit.element.offsetTop - previousAdUnit.element.offsetTop );
    120115                if( document.body.clientHeight > minDistance & distance < minDistance )
     
    140135}
    141136
    142 if( /complete|interactive|loaded/.test( document.readyState ) === true )
     137if( /complete|interactive|loaded/.test( document.readyState ) == true )
    143138{
    144139    NRentContentIntegration( );
Note: See TracChangeset for help on using the changeset viewer.