Changeset 1179694
- Timestamp:
- 06/12/2015 02:59:13 PM (11 years ago)
- Location:
- ceske-komentare/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
ceske-komentare.php (modified) (3 diffs)
-
nastaveni.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ceske-komentare/trunk/README.txt
r1105377 r1179694 1 1 === Plugin Name === 2 Contributors: FeniXx2 Contributors: Petr Baloun 3 3 Donate link: http://blog.doprofilu.cz 4 4 Tags: komentáře,čeština,wordpress, 5 5 Requires at least: 3.0.1 6 Tested up to: 4. 17 Stable tag: 1. 5.56 Tested up to: 4.2.2 7 Stable tag: 1.6 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 44 44 == Changelog == 45 45 46 = 1.6 = 47 * nahrává plugin's texdomain 48 * přivádá localization functions pro všechny stringy užité v pluginu 49 * ošetřuje XSS vulenrability 50 * ošetřuje CSFR vulnerability 51 * odstraňuje false-positive u "úspěšně uloženo" 52 * ruší užití globálních proměných 53 * přidává unikátní prefix pro všechny funkce * obsahuje úpravy kódu tak, aby vyhovovaly WordPress coding standards 54 * Patch vytvořil: David Binda 55 46 56 = 1.5.5 = 47 57 * Úprava přepočítání komentářů -
ceske-komentare/trunk/ceske-komentare.php
r1105377 r1179694 4 4 Plugin URI: http://blog.doprofilu.cz 5 5 Description: Plugin převede všechny řetězce, kde se nachází slovo komentář do správného pádu. v 1.1 Lze nastavit vlastní řetězce. 6 Version: 1. 5.57 Author: fenixx6 Version: 1.6 7 Author: Petr Baloun 8 8 Author URI: http://blog.doprofilu.cz 9 9 License: GNU General Public License v2 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 Text Domain: ceske-komentare 11 12 */ 13 12 14 // If this file is called directly, abort. 13 15 if ( ! defined( 'WPINC' ) ) { … … 15 17 } 16 18 19 //Load plugin's texdomain 20 function ceske_komentare_load_plugin_textdomain() { 21 load_plugin_textdomain( 'ceske-komentare', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); 22 } 17 23 18 function pridat() { 24 add_action( 'plugins_loaded', 'ceske_komentare_load_plugin_textdomain' ); 25 26 function ceske_komentare_activation_callback() { 19 27 // Activation code here... 20 28 add_option( 'pocet0', 'Žádný komentář', '', 'yes' ); … … 23 31 add_option( 'pocet5', '% komentářů', '', 'yes' ); 24 32 } 25 register_activation_hook( __FILE__, ' pridat' );33 register_activation_hook( __FILE__, 'ceske_komentare_activation_callback' ); 26 34 27 $pocet0=get_option('pocet0'); 28 $pocet1=get_option('pocet1'); 29 $pocet2=get_option('pocet2'); 30 $pocet5=get_option('pocet5'); 35 function ceske_komentare_get_options() { 36 return array( 37 'pocet0' => get_option( 'pocet0' ), 38 'pocet1' => get_option( 'pocet1' ), 39 'pocet2' => get_option( 'pocet2' ), 40 'pocet5' => get_option( 'pocet5' ), 41 ); 42 } 31 43 32 add_action( 'admin_menu', ' register_my_custom_menu_page' );44 add_action( 'admin_menu', 'ceske_komentare_register_menu_page' ); 33 45 34 function register_my_custom_menu_page(){35 $page_title = 'Administrace';36 $menu_title = 'České komentáře';46 function ceske_komentare_register_menu_page(){ 47 $page_title = esc_html__( 'Administrace', 'ceske-komentare' ); 48 $menu_title = esc_html__( 'České komentáře', 'ceske-komentare' ); 37 49 $capability = 'manage_options'; 38 50 $menu_slug = 'ceske_komentare'; 39 $function = ' my_custom_menu_page';51 $function = 'ceske_komentare_menu_page'; 40 52 add_options_page($page_title, $menu_title, $capability, $menu_slug, $function); 41 53 } 42 54 43 function my_custom_menu_page(){44 echo '<h1>Administrace</h1>';45 include('nastaveni.php');55 function ceske_komentare_menu_page() { 56 echo '<h1>' . esc_html__( 'Administrace', 'ceske-komentare' ) . '</h1>'; 57 include('nastaveni.php'); 46 58 } 47 59 48 function ceske_komentare($output, $number ){ 49 global $pocet0,$pocet1,$pocet2,$pocet5; 50 if ( $number == 0) $output = $pocet0; 51 elseif ($number == 1 ) 52 $output = str_replace('%', number_format_i18n($number), $pocet1); 53 elseif ($number > 1 and $number < 5 ) 54 $output = str_replace('%', number_format_i18n($number), $pocet2); 55 else 56 $output = str_replace('%', number_format_i18n($number), $pocet5); 57 58 return $output; } 59 60 60 function ceske_komentare( $output, $number ) { 61 $options = ceske_komentare_get_options(); 62 63 $pocet0 = $options['pocet0']; 64 $pocet1 = $options['pocet1']; 65 $pocet2 = $options['pocet2']; 66 $pocet5 = $options['pocet5']; 67 68 if ( intval( $number ) === 0) { 69 $output = $pocet0; 70 } elseif ( intval( $number ) === 1 ) { 71 $output = str_replace( '%', number_format_i18n( $number ), $pocet1 ); 72 } elseif ( intval( $number ) > 1 && intval( $number ) < 5 ) { 73 $output = str_replace( '%', number_format_i18n( $number ), $pocet2 ); 74 } else { 75 $output = str_replace( '%', number_format_i18n( $number ), $pocet5 ); 76 } 77 return $output; 78 } 61 79 62 80 add_action('comments_number', 'ceske_komentare', 10, 2); 63 81 64 82 65 function komentare_meta( $links, $file ) { // Add a link to this plugin's settings page83 function ceske_komentare_meta( $links, $file ) { // Add a link to this plugin's settings page 66 84 static $this_plugin; 67 if(!$this_plugin) $this_plugin = plugin_basename(__FILE__); 68 if($file == $this_plugin) { 69 $settings_link = '<a href="options-general.php?page=ceske_komentare">'.__('Nastavení', 'ceske-komentare').'</a>'; 70 array_unshift($links, $settings_link); 85 if ( !$this_plugin ) { 86 $this_plugin = plugin_basename(__FILE__); 87 } 88 if ( $file == $this_plugin ) { 89 $settings_link_url = esc_url( admin_url( 'options-general.php?page=ceske_komentare') ); 90 $settings_link = '<a href="'.$settings_link_url.'">'.esc_html__( 'Nastavení', 'ceske-komentare' ).'</a>'; 91 array_unshift( $links, $settings_link ); 71 92 } 72 93 return $links; 73 94 } 74 95 75 add_filter( 'plugin_row_meta','komentare_meta', 10, 2);96 add_filter( 'plugin_row_meta', 'ceske_komentare_meta', 10, 2 ); 76 97 77 98 ?> -
ceske-komentare/trunk/nastaveni.php
r1105246 r1179694 11 11 </style> 12 12 <?php 13 if( $_SERVER['REQUEST_METHOD'] == 'POST') { 14 //.. 15 update_option( 'pocet0', $_POST['pocet0']); 16 update_option( 'pocet1', $_POST['pocet1']); 17 update_option( 'pocet2', $_POST['pocet2']); 18 update_option( 'pocet5', $_POST['pocet5']); 13 if ( $_SERVER['REQUEST_METHOD'] == 'POST') { 14 if ( 15 true === current_user_can( 'manage_options' ) //only administrators can update strings 16 && false !== wp_verify_nonce( $_POST['_wpnonce'], 'ceske-komentare-update' ) //nonces verify intention 17 ) { 18 update_option( 'pocet0', sanitize_text_field( $_POST['pocet0'] ) ); 19 update_option( 'pocet1', sanitize_text_field( $_POST['pocet1'] ) ); 20 update_option( 'pocet2', sanitize_text_field( $_POST['pocet2'] ) ); 21 update_option( 'pocet5', sanitize_text_field( $_POST['pocet5'] ) ); 22 $updated = true; 23 } 19 24 } 20 if ( ! isset( $_POST['updated'] ) ) 21 $_POST['updated'] = false; 22 if ( false !== $_POST['updated']) : ?> 23 <div id="message" class="updated fade"><p><strong><?php _e( 'Nastavení uloženo' ); ?></strong></p></div> 24 <?php endif; ?> 25 if ( true === isset( $updated ) && true === $updated ) : ?> 26 <div id="message" class="updated fade"><p><strong><?php esc_html_e( 'Nastavení uloženo', 'ceske-komentare' ); ?></strong></p></div> 27 <?php endif; ?> 28 25 29 <div class="wrap"> 26 <h2>České komentáře nastavení</h2> 27 <form action="" method="post"> 28 <label class="left" for="pocet0"><b>Text při žádném komentáři</b>: </label><input type="text" id="pocet0" name="pocet0" value="<?php echo get_option('pocet0')?>"></br> 29 <label class="left" for="pocet1"><b>Text při 1 komentáři</b>:</label><input id="pocet1" type="text" name="pocet1" value="<?php echo get_option('pocet1')?>"></br> 30 <label class="left" for="pocet2"><b>Text při 2 - 4 komentářích</b>:</label><input id="pocet2" type="text" name="pocet2" value="<?php echo get_option('pocet2')?>"></br> 31 <label class="left" for="pocet5"><b>Text při více jak 4 komentáříh (5,6,...)</b>:</label><input id="pocet5" type="text" name="pocet5" value="<?php echo get_option('pocet5')?>"><br> 32 <input type="hidden" name="updated"> 33 <b>Pozn: Je možné používat zástupný znak "%" pro dosazení aktuálního počtu komentářů</b> 34 <?php submit_button ('Uložit nastavení'); ?> 35 </form> 30 <h2><?php esc_html_e( 'České komentáře nastavení', 'ceske-komentare' ); ?></h2> 31 <form action="<?php echo esc_url( admin_url( 'options-general.php?page=ceske_komentare' ) ); ?>" method="post"> 32 <label class="left" for="pocet0"><b><?php esc_html_e( 'Text při žádném komentáři', 'ceske-komentare' ); ?></b>: </label><input type="text" id="pocet0" name="pocet0" value="<?php echo esc_attr( get_option('pocet0' ) ); ?>"></br> 33 <label class="left" for="pocet1"><b><?php esc_html_e( 'Text při 1 komentáři', 'ceske-komentare' ); ?></b>:</label><input id="pocet1" type="text" name="pocet1" value="<?php echo esc_attr( get_option('pocet1') ); ?>"></br> 34 <label class="left" for="pocet2"><b><?php esc_html_e( 'Text při 2 - 4 komentářích', 'ceske-komentare' ); ?></b>:</label><input id="pocet2" type="text" name="pocet2" value="<?php echo esc_attr( get_option('pocet2') ); ?>"></br> 35 <label class="left" for="pocet5"><b><?php esc_html_e( 'Text při více jak 4 komentářích (5,6,...)', 'ceske-komentare' ); ?></b>:</label><input id="pocet5" type="text" name="pocet5" value="<?php echo esc_attr( get_option('pocet5') ); ?>"><br> 36 <b><?php esc_html_e( 'Pozn: Je možné používat zástupný znak "%" pro dosazení aktuálního počtu komentářů', 'ceske-komentare' ); ?></b> 37 <?php 38 wp_nonce_field( 'ceske-komentare-update' ); 39 submit_button ( esc_html__( 'Uložit nastavení', 'ceske-komentare' ) ); 40 ?>
Note: See TracChangeset
for help on using the changeset viewer.