Plugin Directory

Changeset 2607958


Ignore:
Timestamp:
10/01/2021 04:32:15 PM (5 years ago)
Author:
mi13
Message:

update plugin

Location:
mi13-glossary/trunk
Files:
2 edited

Legend:

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

    r2606631 r2607958  
    44Plugin URI:     https://wordpress.org/plugins/mi13-glossary/
    55Description:        Glossary plugin for your site (ru).
    6 Version:            0.5
     6Version:            1
    77Author:         mi13
    88Requires at least: 5.8
     
    302302            );
    303303            $posts = new WP_Query($args);
     304
    304305            $test .= '<table class="widefat">
    305306            <thead>
     
    313314            <tbody>';
    314315            $alternate = 'class="alternate"';
    315            
     316
    316317            $ignore = get_option('mi13_glossary')['ignore'];
    317318            $ignore = preg_quote($ignore, '/');
     
    335336                foreach($array as $key) {
    336337                    preg_match($key['search'],$text,$matches);
     338                    $text = preg_replace($key['search'],'',$text,1);
    337339                    if(isset($matches[0])) {
    338                         $n++;
    339                         $test .=
     340                        $test .=
    340341                        '<tr '.$alternate.'>
    341342                            <td class="column-name">'.$id.'</td>
     
    346347                        $id = '';
    347348                        $title = '';
    348                         unset($matches);
     349                        $n++;
    349350                    }
    350351                }
     352                unset($text);
    351353                if($n === 0) {
    352                     $test .= 
     354                    $test .=
    353355                        '<tr '.$alternate.'>
    354356                            <td class="column-name">'.$id.'</td>
     
    377379                <div class="tablenav"><div class="tablenav-pages">' . $pagination . '</div></div>
    378380                <div><p>Всего найдено: ' . mi13_glossary_num_decline($keys_count,'ключ,ключа,ключей') . ' в '.mi13_glossary_num_decline($posts_count,'посте,постах,постах').'.</p></div>';
    379             unset($posts);
     381            unset($posts,$array);
    380382        } else {
    381383            $test .= '<p>data not found!</p>';
     
    444446        'post_status' => 'publish'
    445447    );
    446     $glos = get_posts($args);
    447     $text = '';
    448     foreach( $glos as $post ) {
    449         $text.= $post->post_content;
    450         $text.= '<hr>';
    451     }
    452     unset($glos);
    453     echo wpautop($text);
     448    $posts = new WP_Query($args);
     449    while( $posts->have_posts() ){
     450        $posts->the_post();
     451        $string = get_the_content();
     452        if(substr($string,0,3) === '<h3') {
     453            the_content();
     454        }
     455        echo '<hr>';
     456    }
     457    wp_reset_postdata();
     458    unset($posts);
    454459}
    455460
     
    460465add_action( 'save_post_mi13_glossary','mi13_glossary_delete_cash' );
    461466
    462 function mi13_glossary_publish_stop($id) { // Публиковать может только админ
    463     if(get_post_type($id)==='mi13_glossary') {
    464         $publish_stop = get_option('mi13_glossary')['publish_stop'];
    465         if($publish_stop) {
    466             if(current_user_can('author')) {
    467                 $post = get_post( $id );
    468                 $array = ['responce' => 200,'back_link' => true];
    469                 $post->post_status = 'pending';
    470                 wp_update_post($post);
    471                 wp_die('<p>The administrator can publish posts (mi13_glossary) only!</p>','',$array);
    472             }
    473         }
     467function mi13_glossary_publish_stop($id) { // Проверяем наличие заголовка в тексте; Публиковать может только админ
     468    $stop = false;
     469    $post = get_post( $id );
     470    $publish_stop = get_option('mi13_glossary')['publish_stop'];
     471    $string = $post->post_content;
     472    if(substr($string,0,3) !== '<h3') {
     473        $message = '<p>The &lt;h3&gt; heading is required at the beginning of the text!</p>';
     474        $stop = true;
     475    } elseif($publish_stop && current_user_can('author')) {
     476        $message = '<p>The administrator can publish posts (mi13_glossary) only!</p>';
     477        $stop = true;
     478    }
     479    if($stop) {
     480        $array = ['responce' => 200,'back_link' => true];
     481        $post->post_status = 'pending';
     482        wp_update_post($post);
     483        wp_die($message,'',$array);
    474484    }
    475485}
  • mi13-glossary/trunk/readme.txt

    r2606631 r2607958  
    44Donate link: https://money.yandex.ru/to/41001276246895
    55Tested up to: 5.8.1
    6 Stable tag: 0.5
     6Stable tag: 1
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4040= 0.5 =
    4141* fix bag.
     42= 1 =
     43* Доработан код.
Note: See TracChangeset for help on using the changeset viewer.