Changeset 3700366
- Timestamp:
- 09/17/2026 01:17:59 PM (2 months ago)
- Location:
- ravooka/trunk
- Files:
-
- 4 edited
-
modules/ads/package.json (modified) (1 diff)
-
modules/ads/ravooka-ads.php (modified) (7 diffs)
-
ravooka.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ravooka/trunk/modules/ads/package.json
r3506972 r3700366 1 1 { 2 2 "name": "ravooka", 3 "version": "1.0. 1",3 "version": "1.0.2", 4 4 "description": "Unified Ads + PR Publishing plugin for WordPress.", 5 5 "author": "Ravooka", -
ravooka/trunk/modules/ads/ravooka-ads.php
r3506972 r3700366 239 239 // 🔹 Prepare blocks 240 240 $blocks = [ 241 // External Banner 242 'external-banner' => ' 243 <div class="ravooka-external-banner" style="width:100%; padding-bottom:10px;"> 244 <ins 245 class="ravookaads" 246 data-ad-slot="external-banner"> 247 </ins> 248 </div> 249 ', 241 250 'press' => '<ins class="ravookaads" data-ad-client="' . esc_attr($pub_id) . '" data-ad-slot="10492067384"' . ($press_prod ? ' data-ad-prod="' . esc_attr($press_prod) . '"' : '') . '></ins>', 242 251 'carousel' => '<ins class="ravookaads" data-ad-client="' . esc_attr($pub_id) . '" data-ad-slot="54220348490"' . ($carousel_prod ? ' data-ad-prod="' . esc_attr($carousel_prod) . '"' : '') . '></ins>', … … 261 270 $order_array = explode(',', $order_setting); 262 271 263 // 🔹 Always keep Press-Unifier first 264 $output = $blocks['press']; 265 266 // 🔹 Append the other blocks according to the order 272 273 274 // 🔹 External Banner is ALWAYS first 275 $output = $blocks['external-banner']; 276 277 // 🔹 Press-Unifier is ALWAYS second 278 $output .= $blocks['press']; 279 280 // 🔹 Append Carousel / Leaderboard / Composite according to settings 267 281 foreach ($order_array as $key) { 282 283 // Prevent external banner and press from being duplicated 284 if ($key === 'external-banner' || $key === 'press') { 285 continue; 286 } 287 268 288 if (isset($blocks[$key])) { 269 289 $output .= $blocks[$key]; … … 274 294 275 295 }, 20, 2); 296 297 /** 298 * 🔹 Fallback: No Featured Image 299 * 300 * If the post has no featured image, WordPress never calls 301 * post_thumbnail_html(). Therefore inject ONLY the External Banner 302 * at the beginning of the post content. 303 */ 304 add_filter('the_content', function ($content) { 305 306 if ( 307 is_admin() || 308 !is_singular('post') || 309 !in_the_loop() || 310 !is_main_query() 311 ) { 312 return $content; 313 } 314 315 $post_id = get_queried_object_id(); 316 317 // Only run when there is NO featured image. 318 if (has_post_thumbnail($post_id)) { 319 return $content; 320 } 321 322 // Prevent duplicate injection. 323 if (strpos($content, 'ravooka-external-banner') !== false) { 324 return $content; 325 } 326 327 $pub_id = ravooka_get_pub_id(); 328 329 $external_banner = ' 330 <div class="ravooka-external-banner" 331 style="width:100%; padding-bottom:10px;"> 332 <ins 333 class="ravookaads" 334 data-ad-client="' . esc_attr($pub_id) . '" 335 data-ad-slot="external-banner"> 336 </ins> 337 </div> 338 '; 339 340 // Put External Banner at the beginning of the content. 341 return $external_banner . $content; 342 343 }, 19); 276 344 277 345 /** … … 358 426 }, 10, 2); 359 427 428 429 /** 430 * 🔹 Insert VAST Ad After Second Paragraph 431 */ 432 433 434 add_filter('the_content', function ($content) { 435 436 // Only run on individual posts on the frontend 437 if ( 438 is_admin() || 439 !is_singular('post') || 440 !in_the_loop() || 441 !is_main_query() 442 ) { 443 return $content; 444 } 445 446 // Prevent duplicate injection 447 if (strpos($content, 'ravooka-inarticle-video') !== false) { 448 return $content; 449 } 450 451 // Video ad block 452 $ad = ' 453 <video 454 id="ravooka-test-video" 455 controls 456 playsinline 457 preload="none" 458 data-ravooka-video="true" 459 data-ad-slot="external-vast" 460 data-content-src="https://asset.ravooka.ai/internal-ad/playlist.m3u8" 461 ></video>'; 462 463 // Find all paragraphs 464 preg_match_all( 465 '/<p\b[^>]*>.*?<\/p>/is', 466 $content, 467 $matches, 468 PREG_OFFSET_CAPTURE 469 ); 470 471 $paragraph_count = count($matches[0]); 472 473 // No paragraphs → append VAST ad at the end 474 if ($paragraph_count === 0) { 475 return $content . $ad; 476 } 477 478 /* 479 * 2 or more paragraphs: 480 * Insert after the second paragraph. 481 * 482 * 1 paragraph: 483 * Insert after the first/last paragraph. 484 */ 485 $target_index = ($paragraph_count >= 2) 486 ? 1 487 : 0; 488 489 $paragraph = $matches[0][$target_index][0]; 490 $position = $matches[0][$target_index][1] + strlen($paragraph); 491 492 // Insert VAST ad immediately after target paragraph 493 $content = substr_replace( 494 $content, 495 $ad, 496 $position, 497 0 498 ); 499 500 return $content; 501 502 }, 20); 503 360 504 /** 361 505 * 🔹 Enqueue Ravooka JS 362 506 */ 363 507 508 364 509 add_action('wp_enqueue_scripts', function () { 365 510 366 511 $pub_id = ravooka_get_pub_id(); 367 $script_url = 'https://ads.ravooka.ai/ravooka.min.js?client=' . urlencode($pub_id); 512 513 // Change the script version every hour for automatic cache busting. 514 // $version = gmdate('YmdH'); 515 $version = gmdate('Ymd'); 516 517 $script_url = 518 'https://ads.ravooka.ai/ravooka.min.js?client=' . 519 urlencode($pub_id); 368 520 369 521 wp_register_script( … … 371 523 $script_url, 372 524 [], 373 '1.0.1',525 $version, 374 526 true 375 527 ); … … 378 530 379 531 /** 380 * 🔹 BEFORE script (replaces wp_head inline script)532 * BEFORE script 381 533 */ 382 534 wp_add_inline_script( … … 387 539 388 540 /** 389 * 🔹 AFTER script (replaces wp_footer inline script)541 * AFTER script 390 542 */ 391 543 wp_add_inline_script( -
ravooka/trunk/ravooka.php
r3506972 r3700366 3 3 * Plugin Name: Ravooka Platform 4 4 * Description: Unified Ads + PR Publishing plugin for WordPress. 5 * Version: 1.0. 15 * Version: 1.0.2 6 6 * Author: Ravooka 7 7 * Author URI: https://www.ravooka.ai -
ravooka/trunk/readme.txt
r3506972 r3700366 4 4 Tags: ads, advertising, monetization, blocks, gutenberg 5 5 Requires at least: 4.7 6 Tested up to: 6.97 Stable tag: 1.0. 16 Tested up to: 7.1 7 Stable tag: 1.0.2 8 8 Requires PHP: 7.4 9 9 License: GPL-2.0-or-later … … 115 115 * Removed hidden file 116 116 117 = 1.0.2 = 118 * Added programmatic option 119 117 120 == Upgrade Notice == 118 121 … … 123 126 * Removed hidden file 124 127 128 = 1.0.2 = 129 * Added programmatic option and ready for 7.1 130 125 131 == Additional Notes == 126 132
Note:
See TracChangeset
for help on using the changeset viewer.