Changeset 947
- Timestamp:
- 10/29/2014 12:37:52 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-help/wporg-help.php
r13 r947 2 2 3 3 class 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 7 8 function __construct() { 8 9 parent::__construct(); … … 12 13 $this->add_action( 'after_notices' ); 13 14 } 14 15 15 16 function init() { 16 17 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') ); 17 19 GP::$router->add( '/getting-started/hide-notice', array('GP_Help_Page_Plugin_Route', 'hide_notice') ); 18 20 } 19 21 20 22 function after_hello() { 21 23 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>'; 23 25 } 24 26 } 25 27 26 28 function is_notice_hidden() { 27 29 return ( gp_array_get( $_COOKIE, $this->hide_notice ) || ( GP::$user->logged_in() && GP::$user->get_meta( $this->hide_notice ) ) ); 28 30 } 29 31 30 32 function hide_notice() { 31 33 if ( GP::$user->logged_in() ) { … … 34 36 setcookie( $this->hide_notice, '1', time() + 3600*24*30, gp_url( '/' ) ); // a month 35 37 } 36 38 37 39 function after_notices() { 38 40 if ( $this->is_notice_hidden() ) return; … … 41 43 <div class="notice" id="help-notice"> 42 44 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> 44 46 <a id="hide-help-notice" class="secondary" style="float: right;" href="<?php echo esc_url( $hide_url ); ?>">Hide</a> 45 47 </div> … … 53 55 <?php 54 56 } 55 57 56 58 } 57 59 58 60 class GP_Help_Page_Plugin_Route extends GP_Route { 61 59 62 function __construct() { 60 63 parent::__construct(); 61 64 $this->template_path = GP::$plugins->wporg_help->template_path; 62 65 } 63 66 64 67 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; 67 72 } 68 73 69 74 function hide_notice() { 70 75 GP::$plugins->wporg_help->hide_notice(); 71 76 } 77 72 78 } 73 79
Note: See TracChangeset
for help on using the changeset viewer.