Making WordPress.org


Ignore:
Timestamp:
10/29/2014 12:37:52 AM (12 years ago)
Author:
coffee2code
Message:

translate.wordpress.org: change 'getting started' and 'need help?' links on projects page to point/redirect to the GlotPress part of the polyglots handbook

fixes #688.
props markoheijnen.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-help/wporg-help.php

    r13 r947  
    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();
     
    1213                $this->add_action( 'after_notices' );
    1314        }
    14        
     15
    1516        function init() {
    1617                GP::$router->add( '/getting-started', array('GP_Help_Page_Plugin_Route', 'getting_started') );
     18                GP::$router->add( '/getting-started/', array('GP_Help_Page_Plugin_Route', 'getting_started') );
    1719                GP::$router->add( '/getting-started/hide-notice', array('GP_Help_Page_Plugin_Route', 'hide_notice') );
    1820        }
    19        
     21
    2022        function after_hello() {
    2123                if ( GP::$user->logged_in() || $this->is_notice_hidden() ) {
    22                         echo '<em><a class="secondary" href="'.gp_url('/getting-started').'">Need help?</a></em>';
     24                        echo '<em><a class="secondary" href="' . self::handbook_link . '">Need help?</a></em>';
    2325                }
    2426        }
    25        
     27
    2628        function is_notice_hidden() {
    2729                return ( gp_array_get( $_COOKIE, $this->hide_notice ) || ( GP::$user->logged_in() && GP::$user->get_meta( $this->hide_notice ) ) );
    2830        }
    29        
     31
    3032        function hide_notice() {
    3133                if ( GP::$user->logged_in() ) {
     
    3436                setcookie( $this->hide_notice, '1', time() + 3600*24*30, gp_url( '/' ) ); // a month
    3537        }
    36        
     38
    3739        function after_notices() {
    3840                if ( $this->is_notice_hidden() ) return;
     
    4143                <div class="notice" id="help-notice">
    4244                        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>
     45                        Have a look at the <a href="<?php echo self::handbook_link; ?>" target="_blank">Getting Started guide.</a>
    4446                        <a id="hide-help-notice" class="secondary" style="float: right;" href="<?php echo esc_url( $hide_url ); ?>">Hide</a>
    4547                </div>
     
    5355<?php
    5456        }
    55        
     57
    5658}
    5759
    5860class GP_Help_Page_Plugin_Route extends GP_Route {
     61
    5962        function __construct() {
    6063                parent::__construct();
    6164                $this->template_path = GP::$plugins->wporg_help->template_path;
    6265        }
    63        
     66
    6467        function getting_started() {
    65                 GP::$plugins->wporg_help->remove_action( 'after_notices' );             
    66                 $this->tmpl( 'getting-started' );
     68                GP::$plugins->wporg_help->remove_action( 'after_notices' );
     69
     70                gp_redirect( GP_Help_Page_Plugin::handbook_link, 301 );
     71                exit;
    6772        }
    68        
     73
    6974        function hide_notice() {
    7075                GP::$plugins->wporg_help->hide_notice();
    7176        }
     77
    7278}
    7379
Note: See TracChangeset for help on using the changeset viewer.