Title: Improving plugin code
Last modified: November 23, 2021

---

# Improving plugin code

 *  Resolved [antinopol](https://wordpress.org/support/users/antinopol/)
 * (@antinopol)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/improving-plugin-code/)
 * There are suggestions to improve the code after line 115 in the file ../plugins/
   masterstudy-lms-learning-management-system/stm-lms-templates/lesson/curriculum.
   php
 * The problem with the current code is that when using the Russian language, the
   correct endings of words are not formed with a different number of questions.
   Moreover, the code, which I propose to replace, is already used in the theme 
   on the course page in the “Curriculum” section and forms words well with different
   endings depending on the number of questions.
 *     ```
       <div class="stm-curriculum-item__meta">
       	<?php if( !empty( $quiz_info[ 'progress' ] ) ): ?>
       <?php echo intval( $quiz_info[ 'progress' ] ) ?>%
       <?php else:
       $questions = get_post_meta($curriculum_item, 'questions', true);
       if(!empty($questions)){
       	//New correct code
       	$meta = sprintf(_n(
       		'%s question',
       		'%s questions',
       		count(explode(',', $questions)),
       		'masterstudy-lms-learning-management-system'
       	), count(explode(',', $questions)));
       	if(!empty($meta)){
       		echo wp_kses_post($meta);
       	}
       	//Сurrent code
       	//$questions_array = explode(',', $questions);
       	//if(!empty($questions_array)){
       	//    echo sprintf(esc_html__('%s questions', 'masterstudy-lms-learning-management-system'), count($questions_array));
       	//}
       }
       ?>
       <?php endif; ?>
   
       <?php if( $lesson_style === 'classic' && $lesson_type !== 'stream' && $lesson_type !== 'zoom_conference' && !empty( $meta ) ): ?>
       <?php echo esc_html( $meta ); ?>
       <?php endif; ?>
       </div>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Hope StylemixThemes](https://wordpress.org/support/users/hopestylemixthemes/)
 * (@hopestylemixthemes)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/improving-plugin-code/#post-15101951)
 * Hi [@antinopol](https://wordpress.org/support/users/antinopol/)
 * Thank you for reaching out to us!
 * Please note that we are not experts in grammar rather in writing code. Also, 
   plugins can be translated into different languages with their own grammar rules
   and we can not change core code only for one language.
 * If this code is working for you, you are free to use it. However, please add 
   this customization by using the Child theme in order not to lose your changes
   during the plugin update.
 * Feel free to contact us in case of any other questions.
 * regards
 *  Thread Starter [antinopol](https://wordpress.org/support/users/antinopol/)
 * (@antinopol)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/improving-plugin-code/#post-15104670)
 * I agree with you, but in this case, to display the same information, you use 
   different code in different places.
 * Therefore, I advise you to use whichever version of the code works best for other
   languages and makes your plugin better for users.
 *  Plugin Support [mgordon7](https://wordpress.org/support/users/mgordon7/)
 * (@mgordon7)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/improving-plugin-code/#post-15105424)
 * Thank you for your feedback! We really appreciate your diligence!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Improving plugin code’ is closed to new replies.

 * ![](https://ps.w.org/masterstudy-lms-learning-management-system/assets/icon-256x256.
   gif?rev=2846471)
 * [MasterStudy LMS WordPress Plugin – for Online Courses and Education](https://wordpress.org/plugins/masterstudy-lms-learning-management-system/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/masterstudy-lms-learning-management-system/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/)
 * [Active Topics](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/masterstudy-lms-learning-management-system/reviews/)

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)

 * 3 replies
 * 3 participants
 * Last reply from: [mgordon7](https://wordpress.org/support/users/mgordon7/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/improving-plugin-code/#post-15105424)
 * Status: resolved