Changeset 2607958
- Timestamp:
- 10/01/2021 04:32:15 PM (5 years ago)
- Location:
- mi13-glossary/trunk
- Files:
-
- 2 edited
-
mi13-glossary.php (modified) (8 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mi13-glossary/trunk/mi13-glossary.php
r2606631 r2607958 4 4 Plugin URI: https://wordpress.org/plugins/mi13-glossary/ 5 5 Description: Glossary plugin for your site (ru). 6 Version: 0.56 Version: 1 7 7 Author: mi13 8 8 Requires at least: 5.8 … … 302 302 ); 303 303 $posts = new WP_Query($args); 304 304 305 $test .= '<table class="widefat"> 305 306 <thead> … … 313 314 <tbody>'; 314 315 $alternate = 'class="alternate"'; 315 316 316 317 $ignore = get_option('mi13_glossary')['ignore']; 317 318 $ignore = preg_quote($ignore, '/'); … … 335 336 foreach($array as $key) { 336 337 preg_match($key['search'],$text,$matches); 338 $text = preg_replace($key['search'],'',$text,1); 337 339 if(isset($matches[0])) { 338 $n++; 339 $test .= 340 $test .= 340 341 '<tr '.$alternate.'> 341 342 <td class="column-name">'.$id.'</td> … … 346 347 $id = ''; 347 348 $title = ''; 348 unset($matches);349 $n++; 349 350 } 350 351 } 352 unset($text); 351 353 if($n === 0) { 352 $test .= 354 $test .= 353 355 '<tr '.$alternate.'> 354 356 <td class="column-name">'.$id.'</td> … … 377 379 <div class="tablenav"><div class="tablenav-pages">' . $pagination . '</div></div> 378 380 <div><p>Всего найдено: ' . mi13_glossary_num_decline($keys_count,'ключ,ключа,ключей') . ' в '.mi13_glossary_num_decline($posts_count,'посте,постах,постах').'.</p></div>'; 379 unset($posts );381 unset($posts,$array); 380 382 } else { 381 383 $test .= '<p>data not found!</p>'; … … 444 446 'post_status' => 'publish' 445 447 ); 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); 454 459 } 455 460 … … 460 465 add_action( 'save_post_mi13_glossary','mi13_glossary_delete_cash' ); 461 466 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 } 467 function 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 <h3> 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); 474 484 } 475 485 } -
mi13-glossary/trunk/readme.txt
r2606631 r2607958 4 4 Donate link: https://money.yandex.ru/to/41001276246895 5 5 Tested up to: 5.8.1 6 Stable tag: 0.56 Stable tag: 1 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 40 40 = 0.5 = 41 41 * fix bag. 42 = 1 = 43 * Доработан код.
Note: See TracChangeset
for help on using the changeset viewer.