Making WordPress.org

Ticket #688: glotpress.diff

File glotpress.diff, 3.0 KB (added by markoheijnen, 11 years ago)
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-help/wporg-help.php

     
    11<?php
    22
    33class GP_Help_Page_Plugin extends GP_Plugin {
    4         var $id = 'wporg-help';
    5         var $hide_notice = 'wporg-help-hide-notice';
    6        
     4        public $id = 'wporg-help';
     5        private $hide_notice = 'wporg-help-hide-notice';
     6        const $handbook_link = 'https://make.wordpress.org/polyglots/handbook/tools/glotpress-translate-wordpress-org/';
     7
    78        function __construct() {
    89                parent::__construct();
    910                $this->template_path = dirname( __FILE__ );
     
    1112                $this->add_action( 'after_hello' );
    1213                $this->add_action( 'after_notices' );
    1314        }
    14        
     15
    1516        function init() {
    16                 GP::$router->add( '/getting-started', array('GP_Help_Page_Plugin_Route', 'getting_started') );
    1717                GP::$router->add( '/getting-started/hide-notice', array('GP_Help_Page_Plugin_Route', 'hide_notice') );
    1818        }
    19        
     19
    2020        function after_hello() {
    2121                if ( GP::$user->logged_in() || $this->is_notice_hidden() ) {
    22                         echo '<em><a class="secondary" href="'.gp_url('/getting-started').'">Need help?</a></em>';
     22                        echo '<em><a class="secondary" href="' . self::handbook_link . '">Need help?</a></em>';
    2323                }
    2424        }
    25        
     25
    2626        function is_notice_hidden() {
    2727                return ( gp_array_get( $_COOKIE, $this->hide_notice ) || ( GP::$user->logged_in() && GP::$user->get_meta( $this->hide_notice ) ) );
    2828        }
    29        
     29
    3030        function hide_notice() {
    3131                if ( GP::$user->logged_in() ) {
    3232                        GP::$user->set_meta( $this->hide_notice, true );
    3333                }
    3434                setcookie( $this->hide_notice, '1', time() + 3600*24*30, gp_url( '/' ) ); // a month
    3535        }
    36        
     36
    3737        function after_notices() {
    3838                if ( $this->is_notice_hidden() ) return;
    3939                $hide_url = gp_url( '/getting-started/hide-notice' );
    4040?>
    4141                <div class="notice" id="help-notice">
    4242                        New to <em>translate.wordpress.org</em>?
    43                         Have a look at the <a href="<?php echo esc_url( gp_url( '/getting-started' ) ); ?>">Getting Started guide.</a>
     43                        Have a look at the <a href="<?php echo self::handbook_link; ?>" target="_blank">Getting Started guide.</a>
    4444                        <a id="hide-help-notice" class="secondary" style="float: right;" href="<?php echo esc_url( $hide_url ); ?>">Hide</a>
    4545                </div>
    4646                <script type="text/javascript">
     
    5252                </script>       
    5353<?php
    5454        }
    55        
     55
    5656}
    5757
    5858class GP_Help_Page_Plugin_Route extends GP_Route {
     59
    5960        function __construct() {
    6061                parent::__construct();
    6162                $this->template_path = GP::$plugins->wporg_help->template_path;
    6263        }
    63        
     64
    6465        function getting_started() {
    65                 GP::$plugins->wporg_help->remove_action( 'after_notices' );             
    66                 $this->tmpl( 'getting-started' );
     66                GP::$plugins->wporg_help->remove_action( 'after_notices' );
     67
     68                gp_redirect( GP_Help_Page_Plugin::link );
     69                exit;
    6770        }
    68        
     71
    6972        function hide_notice() {
    7073                GP::$plugins->wporg_help->hide_notice();
    7174        }
     75
    7276}
    7377
    7478GP::$plugins->wporg_help = new GP_Help_Page_Plugin;