WordPress.org

Making WordPress.org

Ticket #1853: meta-1853.patch

File meta-1853.patch, 1.7 KB (added by SergeyBiryukov, 4 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-capital-p-dangit/wporg-gp-capital-p-dangit.php

     
     1<?php
     2/**
     3 * Plugin name: GlotPress: capital_P_dangit()
     4 * Description: Make sure "WordPress" is capitalized correctly in new translations.
     5 * Version:     1.0
     6 * Author:      WordPress.org
     7 * Author URI:  http://wordpress.org/
     8 * License:     GPLv2 or later
     9 */
     10
     11class WPorg_GP_Capital_P_Dangit {
     12
     13        function __construct() {
     14                add_action( 'gp_translation_saved', array( $this, 'apply_capital_P_dangit' ) );
     15        }
     16
     17        function apply_capital_P_dangit( $translation ) {
     18                foreach( range( 0, $translation->get_static( 'number_of_plural_translations' ) - 1 ) as $i ) {
     19                        if ( ! isset( $translation->{"translation_$i"} ) ) {
     20                                continue;
     21                        }
     22
     23                        $translation->{"translation_$i"} = capital_P_dangit( $translation->{"translation_$i"} );
     24                }
     25
     26                remove_action( 'gp_translation_saved', array( $this, 'apply_capital_P_dangit' ) );
     27
     28                $translation->save();
     29
     30                add_action( 'gp_translation_saved', array( $this, 'apply_capital_P_dangit' ) );
     31        }
     32
     33}
     34
     35function wporg_gp_capital_P_dangit() {
     36        global $wporg_gp_capital_P_dangit;
     37
     38        if ( ! isset( $wporg_gp_capital_P_dangit ) ) {
     39                $wporg_gp_capital_P_dangit = new WPorg_GP_Capital_P_Dangit();
     40        }
     41
     42        return $wporg_gp_capital_P_dangit;
     43}
     44add_action( 'plugins_loaded', 'wporg_gp_capital_P_dangit' );