Plugin Directory

Changeset 3458311


Ignore:
Timestamp:
02/10/2026 05:46:20 PM (7 weeks ago)
Author:
mi13
Message:

Update plugin

Location:
mi13-glossary/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mi13-glossary/trunk/mi13-glossary.php

    r3135883 r3458311  
    44Plugin URI:  https://wordpress.org/plugins/mi13-glossary/
    55Description: Glossary plugin for your site.
    6 Version:     4
     6Version:     5
    77Author:      mi13
     8Author URI:  https://t.me/galaksy_king
    89License:     GPL v2 or later
    910License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4344register_uninstall_hook( __FILE__, 'mi13_glossary_uninstall' );
    4445
     46function mi13_glossary_valid($settings){
     47    $settings['ignore'] = wp_strip_all_tags( wp_specialchars_decode($settings['ignore'],ENT_QUOTES) );
     48    $settings['link_style'] = wp_strip_all_tags( $settings['link_style'] );
     49    $settings['publish_stop'] = isset($settings['publish_stop']) ? boolval($settings['publish_stop']) : 0;
     50    $settings['pattern'] = isset($settings['pattern']) ? wp_strip_all_tags( $settings['pattern'] ) : '[а-я\x{0301}]{0,4}';
     51    return $settings;
     52}
     53
    4554add_action('init', 'mi13_glossary_init');
    4655function mi13_glossary_init(){
    47     function mi13_glossary_valid($settings){
    48         $settings['ignore'] = wp_strip_all_tags( wp_specialchars_decode($settings['ignore'],ENT_QUOTES) );
    49         $settings['link_style'] = wp_strip_all_tags( $settings['link_style'] );
    50         $settings['publish_stop'] = isset($settings['publish_stop']) ? boolval($settings['publish_stop']) : 0;
    51         $settings['pattern'] = isset($settings['pattern']) ? wp_strip_all_tags( $settings['pattern'] ) : '[а-я\x{0301}]{0,4}';
    52         return $settings;
    53     }
    5456    register_setting( 'mi13_glossary', 'mi13_glossary', 'mi13_glossary_valid' );
    5557    register_post_type('mi13_glossary', array(
     
    127129}
    128130
    129 function mi13_glossary_modal_ajax(){ // функция вызова модального окна
    130     if(isset($_GET['id']) && isset($_GET['pos'])){
    131         $idstr = sanitize_text_field($_GET['id']);
    132         $pos = sanitize_text_field($_GET['pos']);
    133         $id = substr($idstr,3,4);
    134         if( is_numeric($id) && is_numeric($pos) && $id>0 ){
    135             echo '<div class="mi13_glossary_content">';
    136             global $post;
    137             $post = get_post($id);
    138             if( $post && $post->post_type==='mi13_glossary' )  {
    139                 setup_postdata( $post );
    140                 the_content();
    141             } else {
    142                 echo '<p style="color:red">Error: Data not found!</p>';
    143             }
    144             wp_reset_postdata();
    145             echo '</div>';
    146             echo '<div class="mi13_glossary_close"><input type="button" onclick="window.scrollTo(0,' . esc_js($pos) . ');document.getElementById(\'mi13_glossary_block\').classList.remove(\'mi13_glossary_show\');document.getElementById(\'mi13_glossary\').style.visibility = \'hidden\';" value="ok"></div>';
    147         };
    148     }
     131function mi13_glossary_modal_ajax() {
     132    if (!isset($_GET['id'], $_GET['pos'])) {
     133        wp_die();
     134    }
     135    $idstr = sanitize_text_field($_GET['id']);
     136    $pos = sanitize_text_field($_GET['pos']);
     137    $id = substr($idstr,3,4);
     138    if( !is_numeric($id) || !is_numeric($pos) || $id <= 0 ) {
     139        wp_die();
     140    }
     141    echo '<div class="mi13_glossary_content">';
     142    global $post;
     143    $post = get_post($id);
     144    if( $post && $post->post_type==='mi13_glossary' )  {
     145        setup_postdata( $post );
     146        the_content();
     147    } else {
     148        echo '<p style="color:red">Error: Data not found!</p>';
     149    }
     150    wp_reset_postdata();
     151    echo '</div>';
     152    echo '<div class="mi13_glossary_close"><input type="button" onclick="window.scrollTo(0,' . esc_js($pos) . ');document.getElementById(\'mi13_glossary_block\').classList.remove(\'mi13_glossary_show\');document.getElementById(\'mi13_glossary\').style.visibility = \'hidden\';" value="ok"></div>';
    149153    wp_die();
    150154}
     
    506510                    <tr>
    507511                        <th style="padding-left:8px" scope="row">Игнорировать текст внутри тегов (через запятую):</th>
    508                         <td><input type="text" name="mi13_glossary[ignore]" value="<?php echo esc_textarea($settings['ignore']); ?>" size="100">
     512                        <td><input type="text" placeholder="script,style,h1,h2,h3,h4,h5,h6,a,pre,code,span,mark" name="mi13_glossary[ignore]" value="<?php echo esc_textarea($settings['ignore']); ?>" size="100">
    509513                        <p  class="description"><strong>default: script,style,h1,h2,h3,h4,h5,h6,a,pre,code,span,mark</strong></p></td>
    510514                    </tr>
     
    572576}
    573577
    574 function mi13_glossary_pagination_ajax(){ // Аякс пагинация
    575     $return = null;
    576     $page = null;
    577     $id = null;
    578     $val = null;
    579     $nonce = null;
    580     if(isset($_POST['nonce'])) $nonce = sanitize_textarea_field($_POST['nonce']);
    581     wp_verify_nonce( $nonce, 'mi13_glossary_admin' );
    582     if(isset($_POST['val'])) $val = sanitize_textarea_field($_POST['val']);
    583     if(isset($_POST['id'])) $id = sanitize_textarea_field($_POST['id']);
    584     if(isset($_POST['url'])){
    585         $str = wp_parse_url($_POST['url'], PHP_URL_QUERY);
    586         if($str){
    587             wp_parse_str($str, $array);
    588             $page = (isset($array['n_page']) && intval($array['n_page'])>1) ? intval($array['n_page']) : 1; //fix bug for 1 page
    589             $id = 'mi13_glossary_test_posts';
    590         }
    591     }
    592     $return = mi13_glossary_page_table($id,$page,$val);
    593     wp_send_json_success($return);
     578function mi13_glossary_pagination_ajax() {
     579    // Проверка nonce
     580    if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'mi13_glossary_admin')) {
     581        wp_send_json_error('Security check failed');
     582    }
     583
     584    // Валидация данных
     585    $val = isset($_POST['val']) ? sanitize_text_field($_POST['val']) : null;
     586    $id = isset($_POST['id']) ? sanitize_text_field($_POST['id']) : null;
     587
     588    if (isset($_POST['url'])) {
     589        $str = wp_parse_url($_POST['url'], PHP_URL_QUERY);
     590        if ($str) {
     591            wp_parse_str($str, $array);
     592            $page = isset($array['n_page']) && intval($array['n_page']) > 1
     593                ? intval($array['n_page']) : 1;
     594            $id = 'mi13_glossary_test_posts';
     595        }
     596    }
     597
     598    $return = mi13_glossary_page_table($id, $page, $val);
     599    wp_send_json_success($return);
    594600}
    595601add_action( 'wp_ajax_mi13_glossary_pagination', 'mi13_glossary_pagination_ajax' );
     602
    596603
    597604function mi13_glossary_list_for_page(){  // Код для вашей кастомной страницы глоссария
  • mi13-glossary/trunk/readme.txt

    r3135883 r3458311  
    33Tags: glossary, modal keys
    44Requires at least: 4.7
    5 Tested up to: 6.6.1
    6 Stable tag: 4
     5Tested up to: 6.9
     6Stable tag: 5
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    6666= 4 =
    6767* update plugin.
     68= 5 =
     69* update plugin.
Note: See TracChangeset for help on using the changeset viewer.