Changeset 3481664
- Timestamp:
- 03/13/2026 05:02:27 AM (2 weeks ago)
- Location:
- quran-text-multilanguage/trunk
- Files:
-
- 6 edited
-
admin/quran-admin.php (modified) (3 diffs)
-
inc/functions_quran.php (modified) (6 diffs)
-
inc/quran_style.php (modified) (1 diff)
-
inc/template.php (modified) (6 diffs)
-
js/load_sura.js (modified) (4 diffs)
-
quran-text-multilanguage.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
quran-text-multilanguage/trunk/admin/quran-admin.php
r3481626 r3481664 1 1 <?php 2 3 if (current_user_can('activate_plugins')) { 4 5 defined( 'ABSPATH' ) or die( 'Salem aleykoum!' ); 6 7 wp_register_script('quran_admin_color',plugin_dir_url( __FILE__ ).'js/jscolor/jscolor.js'); 8 9 wp_enqueue_script('quran_admin_color'); 10 11 12 if(isset($_POST['template_quran_update'])){ 2 /** 3 * Admin page: options (labels, reciter, language), color theme picker, custom colors, custom CSS, donation block. 4 */ 5 if ( ! current_user_can( 'activate_plugins' ) ) { 6 return; 7 } 8 defined( 'ABSPATH' ) || die( 'Salem aleykoum!' ); 9 10 wp_register_script( 'quran_admin_color', plugin_dir_url( __FILE__ ) . 'js/jscolor/jscolor.js' ); 11 wp_enqueue_script( 'quran_admin_color' ); 12 13 if ( isset( $_POST['template_quran_update'] ) ) { 13 14 14 15 if(!wp_verify_nonce($_POST['template_quran_noncename'], 'tplquran')){ … … 21 22 } 22 23 23 foreach($_POST['option'] as $name => $val){ 24 $value = sanitize_text_field($val); 25 26 // Validation / normalisation des champs de couleur 27 if(strpos($name, 'color') !== false || strpos($name, 'background') !== false) { 24 foreach ( $_POST['option'] as $name => $val ) { 25 $value = sanitize_text_field( $val ); 26 // Normalise hex colors (strip #, validate 6 hex digits, re-add #). 27 if ( strpos( $name, 'color' ) !== false || strpos( $name, 'background' ) !== false ) { 28 28 $hex = ltrim($value, "#"); 29 29 if(!preg_match('/^[a-f0-9]{6}$/i', $hex)) { … … 577 577 }); 578 578 </script> 579 580 579 <?php 581 }582 ?> -
quran-text-multilanguage/trunk/inc/functions_quran.php
r3481626 r3481664 1 1 <?php 2 /** Nombre de versets chargés au premier affichage et par requête "load more" */ 3 if ( ! defined( 'QTM_VERSES_CHUNK_SIZE' ) ) { 4 define( 'QTM_VERSES_CHUNK_SIZE', 20 ); 5 } 6 7 function qtm_get_recitator_base_url() { 2 /** 3 * Quran display logic: sura/verse loading, lazy-load chunks, AJAX handlers, reciter URLs. 4 */ 5 6 if ( ! defined( 'QTM_VERSES_CHUNK_SIZE' ) ) { 7 define( 'QTM_VERSES_CHUNK_SIZE', 20 ); 8 } 9 10 /** Base URL for reciter MP3s (folder name differs per reciter). */ 11 function qtm_get_recitator_base_url() { 8 12 $opt = get_option( 'quran_recitator' ); 9 13 $base = 'https://quran.s3.fr-par.scw.cloud/verset/'; … … 18 22 } 19 23 24 /** Output HTML for a range of verses (used by initial render and AJAX load more). */ 20 25 function qtm_render_verses_chunk( $sura, $lang, $from_aya, $to_aya ) { 21 26 global $quranFile, $transFile; … … 50 55 } 51 56 57 /** AJAX: lazy-load next chunk of verses (nonce-protected). */ 52 58 function qtm_load_verses_chunk() { 53 59 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; … … 73 79 } 74 80 75 function qtm_changeprevsura(){ 81 /** AJAX: previous sura. */ 82 function qtm_changeprevsura() { 76 83 77 84 $sura = sanitize_text_field($_POST['sura']); … … 89 96 90 97 die(); 91 92 } 93 94 function qtm_changenextsura() {98 } 99 100 /** AJAX: next sura. */ 101 function qtm_changenextsura() { 95 102 96 103 $sura = sanitize_text_field($_POST['sura']); … … 107 114 echo "</div>"; 108 115 die(); 109 110 } 111 116 } 117 118 /** AJAX: change sura (dropdown). */ 112 119 function qtm_changesura() { 113 120 -
quran-text-multilanguage/trunk/inc/quran_style.php
r3481660 r3481664 1 1 <?php 2 defined( 'ABSPATH' ) ordie( 'Salem aleykoum!' );3 if ( !defined('REST_REQUEST')) {2 defined( 'ABSPATH' ) || die( 'Salem aleykoum!' ); 3 if ( ! defined( 'REST_REQUEST' ) ) { 4 4 ?> 5 6 5 <style> 7 /* ========== Quran Plugin - Design v2.3.27 ==========*/6 /* Quran plugin – scoped under #template_quran to avoid theme overrides */ 8 7 #template_quran { 9 8 --quran-radius: 10px; -
quran-text-multilanguage/trunk/inc/template.php
r3481645 r3481664 1 1 <?php 2 if (!defined('REST_REQUEST')) { 2 /** 3 * Front-end markup for [quran] shortcode. Skipped for REST to avoid output in API responses. 4 */ 5 if ( ! defined( 'REST_REQUEST' ) ) : 3 6 4 7 ?> 5 <div id="template_quran"<?php echo ( get_option('quran_dark_mode') === 'yes' ) ? ' class="quran-dark-mode"' : ''; ?>> 6 8 <div id="template_quran"<?php echo ( get_option( 'quran_dark_mode' ) === 'yes' ) ? ' class="quran-dark-mode"' : ''; ?>> 7 9 <div id="quran_main"> 8 10 <div id="kb_select_quran"> 9 <form class="aya1"> 10 11 <form class="aya1"> 11 12 <select name="sourate" id="change_sura" class="quran-select aya2"> 12 13 <option disabled="disabled" selected="selected"><?php echo esc_html( get_option('quran_changesuratxt') ); ?></option> 14 13 <option disabled="disabled" selected="selected"><?php echo esc_html( get_option( 'quran_changesuratxt' ) ); ?></option> 15 14 <?php 16 17 15 global $wpdb; 18 19 16 $req_sourate = $wpdb->get_results( 20 17 … … 30 27 31 28 ); 32 33 34 if(isset($_POST['cheikh_quran'])){35 36 37 38 }39 29 40 30 … … 73 63 </div> 74 64 <div id="kb_select_language"> 75 <form id="select_languages" method="get"> 76 65 <form id="select_languages" method="get"> 77 66 <select name="select_language" id="select_language" class="quran-select"> 78 79 <option disabled="disabled" selected="selected"><?php echo esc_html( get_option('quran_changelangtxt') ); ?></option> 67 <option disabled="disabled" selected="selected"><?php echo esc_html( get_option( 'quran_changelangtxt' ) ); ?></option> 80 68 81 69 <option data-image="<?php echo plugin_dir_url(__FILE__); ?>images/country/us.png" value="english" <?php if(isset($_GET['lang_quran'])){if($_GET['lang_quran'] == 'english'):echo 'selected="selected"';endif;}?>>English</option> … … 149 137 150 138 <?php 151 152 139 init_quran(); 153 140 154 if(isset($_GET['sourate']) && isset($_GET['lang'])) { 155 if(preg_match("/[0-9]{1,3}$/", $_GET['sourate'], $matches)) { 141 // URL has sura + lang → show that sura and sync history 142 if ( isset( $_GET['sourate'] ) && isset( $_GET['lang'] ) ) { 143 if ( preg_match( '/[0-9]{1,3}$/', sanitize_text_field( wp_unslash( $_GET['sourate'] ) ), $matches ) ) { 156 144 $sura = $matches[0]; 157 145 ?> … … 173 161 echo '<div class="error">Invalid surah number</div>'; 174 162 } 175 } 176 else{ 177 178 $lang = get_option('quran_languages'); 163 } else { 164 // No sura in URL → show Al-Fatiha with default language 165 $lang = get_option( 'quran_languages' ); 179 166 ?> 180 167 <script> … … 198 185 </div> 199 186 <?php 200 } 187 endif; 201 188 ?> -
quran-text-multilanguage/trunk/js/load_sura.js
r3481626 r3481664 1 jQuery(document).ready(function($){ 2 1 /** 2 * Front-end: sura/language change, prev/next, lazy-load verses, URL sync. 3 */ 4 jQuery(document).ready(function($) { 3 5 var qtmLazyLoading = false; 4 6 … … 60 62 } 61 63 62 /*************************************************GET PARAM FROM URL***************************************************/ 63 $.urlParam = function (name) { 64 $.urlParam = function(name) { 64 65 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); 65 66 if (results == null) { … … 71 72 72 73 }; 73 /*************************************************PARSE PARAM FROM URL**************************************************/ 74 function getParameterByName(name, url) {74 75 function getParameterByName(name, url) { 75 76 if (!url) url = window.location.href; 76 77 name = name.replace(/[\[\]]/g, "\\$&"); … … 80 81 if (!results[2]) return ''; 81 82 return decodeURIComponent(results[2].replace(/\+/g, " ")); 82 } 83 84 /*************************************************CHANGE SURA**********************************************************/ 85 $('#change_sura').change(function(){ 83 } 84 85 $('#change_sura').change(function() { 86 86 $.each($('audio'), function () { 87 87 this.pause(); -
quran-text-multilanguage/trunk/quran-text-multilanguage.php
r3481661 r3481664 16 16 defined( 'ABSPATH' ) or die( 'Salem aleykoum!' ); 17 17 18 19 18 define( 'QURAN__PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 20 19 21 add_action('admin_menu' , 'qtm_quranadmin'); 22 23 24 function qtm_quranadmin(){ 25 26 add_menu_page('Quran', 'Quran', 'activate_plugins', 'qtm_quranadmin', 'qtm_renderquranadmin', ''.QURAN__PLUGIN_URL . 'icon_quran.png', 3); 27 28 add_action( 'admin_init', 'qtm_registeroptions' ); 29 30 } 31 32 function qtm_renderquranadmin(){ 33 34 include('admin/quran-admin.php'); 35 36 } 37 38 39 //COPY TITLE SURA IN BDD 40 41 function qtm_quraninstall(){ 20 add_action( 'admin_menu', 'qtm_quranadmin' ); 21 22 function qtm_quranadmin() { 23 add_menu_page( 'Quran', 'Quran', 'activate_plugins', 'qtm_quranadmin', 'qtm_renderquranadmin', QURAN__PLUGIN_URL . 'icon_quran.png', 3 ); 24 add_action( 'admin_init', 'qtm_registeroptions' ); 25 } 26 27 function qtm_renderquranadmin() { 28 include 'admin/quran-admin.php'; 29 } 30 31 /** 32 * On first install: create sura lookup table + set default options (labels, colors, reciter, etc.). 33 */ 34 function qtm_quraninstall() { 42 35 43 36 … … 301 294 dbDelta( $sql ); 302 295 303 / /DEFAUT OPTIONS COLORS/TEXT296 /* Default options (only used when option does not exist). */ 304 297 add_option( 'quran_changerecitatortxt', 'Choose récitator', '', 'yes' ); 305 298 … … 385 378 386 379 387 //ACTIVATION PLUGIN INSTALL 388 389 register_activation_hook(__FILE__,'qtm_quraninstall'); 390 391 //DELETE PLUGIN 392 393 register_uninstall_hook(__FILE__, 'qtm_quranuninstall'); 394 395 //SCRIPTS DU PLUGIN 396 397 function qtm_quranscripts(){ 380 register_activation_hook( __FILE__, 'qtm_quraninstall' ); 381 register_uninstall_hook( __FILE__, 'qtm_quranuninstall' ); 382 383 /** Admin-only scripts (e.g. jscolor for options). */ 384 function qtm_quranscripts() { 398 385 399 386 … … 404 391 } 405 392 406 add_action('wp_enqueue_scripts','qtm_quranscripts'); 407 408 409 393 add_action( 'wp_enqueue_scripts', 'qtm_quranscripts' ); 394 395 /** Register all plugin options with Settings API. */ 410 396 function qtm_registeroptions() { 411 397 … … 444 430 register_setting( 'quran-options', 'background_quran_arabic' ); 445 431 446 } 447 448 function quran_options(){ 449 if(is_admin()){ 450 include('admin/quran-admin.php'); 451 } 452 453 } 454 455 //LOAD JS FILE 432 } 433 434 function quran_options() { 435 if ( is_admin() ) { 436 include 'admin/quran-admin.php'; 437 } 438 } 439 440 /** Front: enqueue jQuery, load_sura.js (with nonce for lazy load), soundmanager + player. */ 456 441 function add_js_scripts() { 457 442 wp_enqueue_script( 'jquery' ); … … 474 459 475 460 476 add_action('wp_enqueue_scripts', 'add_js_scripts'); 477 478 //LOAD STYLE MENU 479 480 481 461 add_action( 'wp_enqueue_scripts', 'add_js_scripts' ); 462 463 /* AJAX handlers (logged-in and guest). */ 482 464 add_action( 'wp_ajax_qtm_changesura', 'qtm_changesura' ); 483 465 add_action( 'wp_ajax_nopriv_qtm_changesura', 'qtm_changesura' ); … … 491 473 add_action( 'wp_ajax_nopriv_qtm_load_verses_chunk', 'qtm_load_verses_chunk' ); 492 474 493 require ('inc/functions_quran.php');494 495 475 require_once 'inc/functions_quran.php'; 476 477 /** Shortcode [quran]: inject styles, markup, and init. */ 496 478 function qtm_renderquran() { 497 // Enqueue jQuery 498 wp_enqueue_script('jquery'); 499 500 // Native HTML5 selects - no external plugin 501 // Include necessary files 502 require_once plugin_dir_path(__FILE__) . 'inc/quran_style.php'; 503 require_once plugin_dir_path(__FILE__) . 'inc/template.php'; 504 505 // Initialize Quran (assuming this is required) 506 init_quran(); 507 } 508 509 add_shortcode('quran', 'quran_shortcode'); 479 wp_enqueue_script( 'jquery' ); 480 require_once plugin_dir_path( __FILE__ ) . 'inc/quran_style.php'; 481 require_once plugin_dir_path( __FILE__ ) . 'inc/template.php'; 482 init_quran(); 483 } 484 485 add_shortcode( 'quran', 'quran_shortcode' ); 510 486 511 487 function quran_shortcode() { 512 513 488 return qtm_renderquran(); 514 515 } 489 }
Note: See TracChangeset
for help on using the changeset viewer.