| 1 |
<?php |
| 2 |
/** |
| 3 |
* Add some content to the help tab |
| 4 |
* |
| 5 |
* @version 1.2.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
if( !class_exists('UsersWP_Admin_Help') ) { |
| 13 |
|
| 14 |
class UsersWP_Admin_Help{ |
| 15 |
|
| 16 |
public function __construct() { |
| 17 |
add_action( 'current_screen', array( $this, 'add_tabs' ), 50 ); |
| 18 |
add_filter( 'aui_screen_ids', array( $this, 'add_aui_screens' )); |
| 19 |
} |
| 20 |
|
| 21 |
public function get_screen_ids() { |
| 22 |
|
| 23 |
$screen_ids = array( |
| 24 |
'user-edit', |
| 25 |
'users', |
| 26 |
'profile', |
| 27 |
'toplevel_page_userswp', |
| 28 |
'userswp_page_uwp_form_builder', |
| 29 |
'userswp_page_uwp_status', |
| 30 |
'userswp_page_uwp-addons', |
| 31 |
'userswp_page_uwp_tools', |
| 32 |
); |
| 33 |
|
| 34 |
$screen_ids = apply_filters('uwp_admin_help_screen_ids',$screen_ids); |
| 35 |
|
| 36 |
return $screen_ids; |
| 37 |
} |
| 38 |
|
| 39 |
/** |
| 40 |
* Tell AyeCode UI to load on certain admin pages. |
| 41 |
* |
| 42 |
* @param $screen_ids |
| 43 |
* |
| 44 |
* @return array |
| 45 |
*/ |
| 46 |
public function add_aui_screens( $screen_ids ){ |
| 47 |
|
| 48 |
// load on these pages if set |
| 49 |
$screen_ids = array_merge( $screen_ids, $this->get_screen_ids() ); |
| 50 |
|
| 51 |
return $screen_ids; |
| 52 |
} |
| 53 |
|
| 54 |
public function add_tabs() { |
| 55 |
|
| 56 |
$screen = get_current_screen(); |
| 57 |
|
| 58 |
$screen_ids = $this->get_screen_ids(); |
| 59 |
|
| 60 |
if ( ! $screen || ! in_array( $screen->id, $screen_ids) ) { |
| 61 |
return; |
| 62 |
} |
| 63 |
|
| 64 |
$screen->add_help_tab( array( |
| 65 |
'id' => 'uwp_help_support_tab', |
| 66 |
'title' => __( 'Help & Support', 'userswp' ), |
| 67 |
'content' => $this->get_support_tab_content() |
| 68 |
) ); |
| 69 |
|
| 70 |
$screen->add_help_tab( array( |
| 71 |
'id' => 'uwp_help_bugs_tab', |
| 72 |
'title' => __( 'Found a bug?', 'userswp' ), |
| 73 |
'content' => $this->get_bugs_tab_content() |
| 74 |
) ); |
| 75 |
|
| 76 |
$screen->add_help_tab( array( |
| 77 |
'id' => 'uwp_help_onboard_tab', |
| 78 |
'title' => __( 'Setup wizard', 'userswp' ), |
| 79 |
'content' => $this->get_onboard_tab_content() |
| 80 |
) ); |
| 81 |
|
| 82 |
$screen->set_help_sidebar( $this->get_help_tab_sidebar_content()); |
| 83 |
|
| 84 |
$section = !empty( $_GET['section'] ) ? '_'.esc_attr($_GET['section']) : ''; |
| 85 |
|
| 86 |
do_action( 'uwp_adds_help_screen_tabs'.$section,$screen ); |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
public function get_support_tab_content() { |
| 91 |
|
| 92 |
$support_html = "<h2>".__('Help & Support','userswp')."</h2>"; |
| 93 |
$support_html .= "<p>".sprintf(__('Should you need help understanding, using, or extending UsersWP <a href="%1$s">please read our documentation</a>. You will find all kinds of resources including snippets, tutorials and much more.,','userswp'),'https://userswp.io/docs/?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=userswpplugin')."</p>"; |
| 94 |
$support_html .= "<p>".sprintf(__('For further assistance with UsersWP core or with premium extensions sold by UsersWP you can use our <a href="%1$s">support forums</a>.','userswp'),'https://userswp.io/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=userswpplugin')."</p>"; |
| 95 |
$support_html .= "<p>".__('Before asking for help we recommend checking the system status page to identify any problems with your configuration.','userswp')."</p>"; |
| 96 |
$support_html .= "<p><a class='button button-primary' href='".admin_url( 'admin.php?page=uwp_status' )."'>".__( 'System status', 'userswp' )."</a> <a class='button' href='https://userswp.io/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=userswpplugin'>".__( 'UsersWP support', 'userswp' )."</a></p>"; |
| 97 |
return apply_filters('uwp_support_help_tab_content',$support_html); |
| 98 |
} |
| 99 |
|
| 100 |
public function get_bugs_tab_content() { |
| 101 |
|
| 102 |
$bugs_html = "<h2>".__('Found a bug?','userswp')."</h2>"; |
| 103 |
$bugs_html .= "<p>".sprintf(__('If you find a bug within UsersWP core you can create a ticket via <a href="%1$s">Github issues</a>. Ensure you read the <a href="%2$s">contribution guide</a> prior to submitting your report. To help us solve your issue, please be as descriptive as possible and include your <a href="%3$s">system status report</a>','userswp'),'https://github.com/UsersWP/userswp/issues?state=open','https://github.com/UsersWP/userswp/blob/master/CONTRIBUTING.md',admin_url( 'admin.php?page=uwp_status' ))."</p>"; |
| 104 |
$bugs_html .= "<p><a href='https://github.com/UsersWP/userwp/issues?state=open' class='button button-primary'>". __( 'Report a bug', 'userswp' ) ."</a> <a href='".admin_url( 'admin.php?page=uwp_status' )."' class='button'>".__( 'System status', 'userswp' )."</a></p>"; |
| 105 |
|
| 106 |
return apply_filters('uwp_bugs_help_tab_content',$bugs_html); |
| 107 |
} |
| 108 |
|
| 109 |
public function get_onboard_tab_content() { |
| 110 |
|
| 111 |
$onboard_html = "<h2>".__('Setup wizard','userswp')."</h2>"; |
| 112 |
$onboard_html .= "<p>".__('If you need to access the setup wizard again, please click on the button below.','userswp')."</p>"; |
| 113 |
$onboard_html .= "<p>".__('Running the wizard again will not delete your current settings. You will have the option to change any current settings.','userswp')."</p>"; |
| 114 |
$onboard_html .= "<p><a href='".admin_url( 'index.php?page=uwp-setup' )."' class='button button-primary'>".__('Setup wizard','userswp')."</a></p>"; |
| 115 |
|
| 116 |
return apply_filters('uwp_setup_wizard_help_tab_content',$onboard_html); |
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
public function get_help_tab_sidebar_content() { |
| 121 |
|
| 122 |
$sidebar_html = '<p><strong>' . __( 'For more information:', 'userswp' ) . '</strong></p>'; |
| 123 |
$sidebar_html .= '<p><a target="_blank" href="https://userswp.io/?utm_source=helptab&utm_medium=product&utm_content=about&utm_campaign=userswpplugin">'.__('About UsersWP','userswp').'</a></p>'; |
| 124 |
$sidebar_html .= '<p><a target="_blank" href="https://wordpress.org/plugins/userswp/">'.__('WordPress.org project','userswp').'</a></p>'; |
| 125 |
$sidebar_html .= '<p><a target="_blank" href="https://github.com/UsersWP/userswp">'.__('Github project','userswp').'</a></p>'; |
| 126 |
$sidebar_html .= '<p><a target="_blank" href="https://userswp.io/downloads/category/addons/?utm_source=helptab&utm_medium=product&utm_content=uwpextensions&utm_campaign=userswpplugin">'.__('Official extensions','userswp').'</a></p>'; |
| 127 |
|
| 128 |
return apply_filters('uwp_sidebar_help_tab_content',$sidebar_html); |
| 129 |
} |
| 130 |
|
| 131 |
} |
| 132 |
|
| 133 |
new UsersWP_Admin_Help(); |
| 134 |
} |