Plugin Directory

Changeset 3481664


Ignore:
Timestamp:
03/13/2026 05:02:27 AM (2 weeks ago)
Author:
karim42
Message:

comment code

Location:
quran-text-multilanguage/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • quran-text-multilanguage/trunk/admin/quran-admin.php

    r3481626 r3481664  
    11<?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 */
     5if ( ! current_user_can( 'activate_plugins' ) ) {
     6    return;
     7}
     8defined( 'ABSPATH' ) || die( 'Salem aleykoum!' );
     9
     10wp_register_script( 'quran_admin_color', plugin_dir_url( __FILE__ ) . 'js/jscolor/jscolor.js' );
     11wp_enqueue_script( 'quran_admin_color' );
     12
     13if ( isset( $_POST['template_quran_update'] ) ) {
    1314
    1415        if(!wp_verify_nonce($_POST['template_quran_noncename'], 'tplquran')){
     
    2122        }
    2223
    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 ) {
    2828                $hex = ltrim($value, "#");
    2929                if(!preg_match('/^[a-f0-9]{6}$/i', $hex)) {
     
    577577});
    578578</script>
    579 
    580579<?php
    581 }
    582 ?>
  • quran-text-multilanguage/trunk/inc/functions_quran.php

    r3481626 r3481664  
    11<?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
     6if ( ! 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). */
     11function qtm_get_recitator_base_url() {
    812        $opt = get_option( 'quran_recitator' );
    913        $base = 'https://quran.s3.fr-par.scw.cloud/verset/';
     
    1822    }
    1923
     24    /** Output HTML for a range of verses (used by initial render and AJAX load more). */
    2025    function qtm_render_verses_chunk( $sura, $lang, $from_aya, $to_aya ) {
    2126        global $quranFile, $transFile;
     
    5055    }
    5156
     57    /** AJAX: lazy-load next chunk of verses (nonce-protected). */
    5258    function qtm_load_verses_chunk() {
    5359        $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
     
    7379    }
    7480
    75     function qtm_changeprevsura(){
     81    /** AJAX: previous sura. */
     82    function qtm_changeprevsura() {
    7683
    7784        $sura = sanitize_text_field($_POST['sura']);
     
    8996
    9097        die();
    91 
    92     }
    93 
    94     function qtm_changenextsura(){
     98    }
     99
     100    /** AJAX: next sura. */
     101    function qtm_changenextsura() {
    95102
    96103        $sura = sanitize_text_field($_POST['sura']);
     
    107114        echo "</div>";
    108115        die();
    109 
    110     }
    111 
     116    }
     117
     118    /** AJAX: change sura (dropdown). */
    112119    function qtm_changesura() {
    113120
  • quran-text-multilanguage/trunk/inc/quran_style.php

    r3481660 r3481664  
    11<?php
    2 defined( 'ABSPATH' ) or die( 'Salem aleykoum!' );
    3 if (!defined('REST_REQUEST')) {
     2defined( 'ABSPATH' ) || die( 'Salem aleykoum!' );
     3if ( ! defined( 'REST_REQUEST' ) ) {
    44?>
    5 
    65<style>
    7 /* ========== Quran Plugin - Design v2.3.27 ========== */
     6/* Quran plugin – scoped under #template_quran to avoid theme overrides */
    87#template_quran {
    98    --quran-radius: 10px;
  • quran-text-multilanguage/trunk/inc/template.php

    r3481645 r3481664  
    11<?php
    2 if (!defined('REST_REQUEST')) {
     2/**
     3 * Front-end markup for [quran] shortcode. Skipped for REST to avoid output in API responses.
     4 */
     5if ( ! defined( 'REST_REQUEST' ) ) :
    36
    47?>
    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"' : ''; ?>>
    79<div id="quran_main">
    810<div id="kb_select_quran">
    9 <form  class="aya1">
    10 
     11<form class="aya1">
    1112<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>
    1514<?php
    16 
    1715    global $wpdb;
    18 
    1916    $req_sourate = $wpdb->get_results(
    2017
     
    3027
    3128);
    32 
    33 
    34 if(isset($_POST['cheikh_quran'])){
    35 
    36 
    37 
    38 }
    3929
    4030
     
    7363</div>
    7464<div id="kb_select_language">
    75         <form  id="select_languages" method="get">
    76 
     65        <form id="select_languages" method="get">
    7766        <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>             
    8068
    8169            <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>           
     
    149137
    150138<?php
    151 
    152139    init_quran();
    153140
    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 ) ) {
    156144            $sura = $matches[0];
    157145            ?>
     
    173161            echo '<div class="error">Invalid surah number</div>';
    174162        }
    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' );
    179166        ?>
    180167<script>
     
    198185</div>
    199186<?php
    200 }
     187endif;
    201188?>
  • 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 */
     4jQuery(document).ready(function($) {
    35  var qtmLazyLoading = false;
    46
     
    6062  }
    6163
    62 /*************************************************GET PARAM FROM URL***************************************************/
    63   $.urlParam = function (name) {
     64  $.urlParam = function(name) {
    6465    var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
    6566    if (results == null) {
     
    7172
    7273  };
    73 /*************************************************PARSE PARAM FROM URL**************************************************/
    74     function getParameterByName(name, url) {
     74
     75  function getParameterByName(name, url) {
    7576        if (!url) url = window.location.href;
    7677        name = name.replace(/[\[\]]/g, "\\$&");
     
    8081        if (!results[2]) return '';
    8182        return decodeURIComponent(results[2].replace(/\+/g, " "));
    82     }
    83 
    84 /*************************************************CHANGE SURA**********************************************************/
    85       $('#change_sura').change(function(){
     83  }
     84
     85  $('#change_sura').change(function() {
    8686          $.each($('audio'), function () {
    8787          this.pause();
  • quran-text-multilanguage/trunk/quran-text-multilanguage.php

    r3481661 r3481664  
    1616defined( 'ABSPATH' ) or die( 'Salem aleykoum!' );
    1717
    18 
    1918define( 'QURAN__PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    2019
    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(){
     20add_action( 'admin_menu', 'qtm_quranadmin' );
     21
     22function 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
     27function 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 */
     34function qtm_quraninstall() {
    4235
    4336
     
    301294dbDelta( $sql );
    302295
    303 //DEFAUT OPTIONS COLORS/TEXT
     296/* Default options (only used when option does not exist). */
    304297add_option( 'quran_changerecitatortxt', 'Choose récitator', '', 'yes' );
    305298
     
    385378
    386379
    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(){
     380register_activation_hook( __FILE__, 'qtm_quraninstall' );
     381register_uninstall_hook( __FILE__, 'qtm_quranuninstall' );
     382
     383/** Admin-only scripts (e.g. jscolor for options). */
     384function qtm_quranscripts() {
    398385
    399386
     
    404391}
    405392
    406 add_action('wp_enqueue_scripts','qtm_quranscripts');
    407 
    408 
    409 
     393add_action( 'wp_enqueue_scripts', 'qtm_quranscripts' );
     394
     395/** Register all plugin options with Settings API. */
    410396function qtm_registeroptions() {
    411397
     
    444430    register_setting( 'quran-options', 'background_quran_arabic' );
    445431
    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
     434function 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. */
    456441function add_js_scripts() {
    457442    wp_enqueue_script( 'jquery' );
     
    474459
    475460
    476 add_action('wp_enqueue_scripts', 'add_js_scripts');
    477 
    478 //LOAD STYLE MENU
    479 
    480 
    481    
     461add_action( 'wp_enqueue_scripts', 'add_js_scripts' );
     462
     463/* AJAX handlers (logged-in and guest). */
    482464add_action( 'wp_ajax_qtm_changesura', 'qtm_changesura' );
    483465add_action( 'wp_ajax_nopriv_qtm_changesura', 'qtm_changesura' );
     
    491473add_action( 'wp_ajax_nopriv_qtm_load_verses_chunk', 'qtm_load_verses_chunk' );
    492474
    493 require('inc/functions_quran.php');
    494 
    495 
     475require_once 'inc/functions_quran.php';
     476
     477/** Shortcode [quran]: inject styles, markup, and init. */
    496478function 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
     485add_shortcode( 'quran', 'quran_shortcode' );
    510486
    511487function quran_shortcode() {
    512 
    513488    return qtm_renderquran();
    514 
    515 }
     489}
Note: See TracChangeset for help on using the changeset viewer.