Changeset 2822057
- Timestamp:
- 11/22/2022 10:36:54 AM (3 years ago)
- Location:
- nativerent/trunk
- Files:
-
- 8 added
- 26 deleted
- 4 edited
-
admin/class-actions.php (deleted)
-
admin/class-cache-actions.php (deleted)
-
admin/class-clear-cache-button.php (deleted)
-
admin/class-notices.php (deleted)
-
admin/class-settings.php (deleted)
-
admin/js/clear-cache.js (deleted)
-
admin/main.php (added)
-
admin/static/main.css (modified) (1 diff)
-
includes/class-adv.php (deleted)
-
includes/class-api.php (deleted)
-
includes/class-apicore.php (deleted)
-
includes/class-autoloader.php (deleted)
-
includes/class-cache-handler.php (deleted)
-
includes/class-connect-handler.php (deleted)
-
includes/class-dnaconvert.php (deleted)
-
includes/class-handler.php (deleted)
-
includes/class-init.php (deleted)
-
includes/class-install.php (deleted)
-
includes/class-maintanance.php (deleted)
-
includes/class-metrics.php (deleted)
-
includes/class-migrations-autoconfig.php (deleted)
-
includes/class-migrations.php (deleted)
-
includes/class-nativerent.php (deleted)
-
includes/class-nativerentadv.php (added)
-
includes/class-nativerentapi.php (added)
-
includes/class-nativerentapicore.php (added)
-
includes/class-nativerentautoconfig.php (added)
-
includes/class-nativerentidnaconvert.php (added)
-
includes/class-nativerentoptions.php (added)
-
includes/class-optimization-handler.php (deleted)
-
includes/class-options.php (deleted)
-
includes/class-settings.php (deleted)
-
includes/functions.php (deleted)
-
includes/utils.php (added)
-
nativerent-connect.php (deleted)
-
nativerent.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
-
static/content.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nativerent/trunk/admin/static/main.css
r2821958 r2822057 71 71 #NativeRentAdmin_dropSiteCacheContainer 72 72 { 73 visibility: hidden; 73 74 line-height: 2.15384615; 74 75 vertical-align: middle; -
nativerent/trunk/nativerent.php
r2821958 r2822057 11 11 * Plugin URI: https://wordpress.org/plugins/nativerent/ 12 12 * 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 16 15 * Requires PHP: 5.6.20 17 16 * Author: Native Rent … … 21 20 * Text Domain: cyr2lat 22 21 * Domain Path: /languages/ 22 * 23 * 24 * WC requires at least: 3.0 25 * WC tested up to: 5.9.3 23 26 */ 24 27 25 28 // Exit if accessed directly. 26 defined( 'ABSPATH' ) || exit; 27 29 defined( 'ABSPATH' ) || exit( '403 Forbidden' ); 30 31 // Plugin version. 32 if ( ! defined( 'NATIVERENT_PLUGIN_VERSION' ) ) { 33 define( 'NATIVERENT_PLUGIN_VERSION', '1.5.1' ); 34 } 28 35 // Plugin Folder Path. 29 36 if ( ! defined( 'NATIVERENT_PLUGIN_DIR' ) ) { … … 40 47 // Value for minimal priority argument. 41 48 if ( ! defined( 'NATIVERENT_PLUGIN_MIN_PRIORITY' ) ) { 42 define( 'NATIVERENT_PLUGIN_MIN_PRIORITY', ( - PHP_INT_MAX - 1 ));49 define( 'NATIVERENT_PLUGIN_MIN_PRIORITY', - 2147483647 ); 43 50 } 44 51 // Value for maximal priority argument. 45 52 if ( ! defined( 'NATIVERENT_PLUGIN_MAX_PRIORITY' ) ) { 46 define( 'NATIVERENT_PLUGIN_MAX_PRIORITY', PHP_INT_MAX);53 define( 'NATIVERENT_PLUGIN_MAX_PRIORITY', 2147483647 ); 47 54 } 48 55 // API param names. … … 50 57 define( 'NATIVERENT_API_V1_PARAM', 'NativeRentAPIv1' ); 51 58 } 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 60 require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentadv.php'; 61 require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentapi.php'; 62 require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentoptions.php'; 63 require_once NATIVERENT_PLUGIN_DIR . 'includes/class-nativerentautoconfig.php'; 64 require_once NATIVERENT_PLUGIN_DIR . 'includes/utils.php'; 65 66 // Include admin section. 67 if ( 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 */ 122 function 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 */ 135 function 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 */ 149 function 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 */ 158 function 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 */ 185 function 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 */ 210 function 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 224 register_activation_hook( NATIVERENT_PLUGIN_FILE, 'nativerent_plugin_activation' ); 225 226 /** 227 * Plugin event deactivation hook 228 * 229 * @return void 230 */ 231 function nativerent_plugin_deactivation() { 232 if ( NativeRentOptions::authenticated() ) { 233 NativeRentAPI::status( 'deactivated' ); 234 } 235 NativeRentOptions::set( 'status', 'deactivated' ); 236 } 237 238 register_deactivation_hook( NATIVERENT_PLUGIN_FILE, 'nativerent_plugin_deactivation' ); 239 240 /** 241 * Plugin event uninstall hook 242 * 243 * @return void 244 */ 245 function nativerent_plugin_uninstall() { 246 if ( NativeRentOptions::authenticated() ) { 247 NativeRentAPI::status( 'uninstalled' ); 248 } 249 NativeRentAdv::uninstall(); 250 NativeRentOptions::uninstall(); 251 NativeRentAutoconfig::uninstall(); 252 } 253 254 register_uninstall_hook( NATIVERENT_PLUGIN_FILE, 'nativerent_plugin_uninstall' ); 255 256 if ( NativeRentOptions::get( 'status' ) !== 'activated' ) { 257 NativeRentOptions::set( 'status', 'activated' ); 258 } -
nativerent/trunk/readme.txt
r2821958 r2822057 4 4 Contributors: nativerentplugin 5 5 Plugin URI: https://wordpress.org/plugins/nativerent/ 6 Requires at least: 5.17 Tested up to: 6. 1.18 Requires PHP: 5.6 .209 Stable tag: 1.5. 06 Requires at least: 4.9 7 Tested up to: 6.0.2 8 Requires PHP: 5.6 9 Stable tag: 1.5.1 10 10 License: GPLv2 or later 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html -
nativerent/trunk/static/content.js
r2821958 r2822057 59 59 { 60 60 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 ) 62 62 { 63 63 anchor = article.querySelector( customSelector ); … … 109 109 110 110 111 if( i == = 1 || i === 2 )111 if( i == 1 || i == 2 ) 112 112 { 113 113 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 119 114 var distance = ( adUnit.element.offsetTop - previousAdUnit.element.offsetTop ); 120 115 if( document.body.clientHeight > minDistance & distance < minDistance ) … … 140 135 } 141 136 142 if( /complete|interactive|loaded/.test( document.readyState ) == =true )137 if( /complete|interactive|loaded/.test( document.readyState ) == true ) 143 138 { 144 139 NRentContentIntegration( );
Note: See TracChangeset
for help on using the changeset viewer.