| @@ -1,0 +1,142 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Contextual Help | |
| 4 | + * | |
| 5 | + * @package GamiPress\Admin\Contextual_Help | |
| 6 | + * @author GamiPress <contact@gamipress.com>, Ruben Garcia <rubengcdev@gmail.com> | |
| 7 | + * @since 1.1.0 | |
| 8 | + */ | |
| 9 | +// Exit if accessed directly | |
| 10 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Adds the contextual help for GamiPress pages | |
| 14 | + * | |
| 15 | + * @since 1.1.0 | |
| 16 | + * @return void | |
| 17 | + */ | |
| 18 | +function gamipress_edit_screen_contextual_help() { | |
| 19 | + $screen = get_current_screen(); | |
| 20 | + | |
| 21 | + $gamipress_edit_screens = array( 'points-type', 'achievement-type', 'rank-type' ); | |
| 22 | + | |
| 23 | + if ( ! ( in_array( $screen->id, $gamipress_edit_screens ) | |
| 24 | + || in_array( $screen->id, gamipress_get_achievement_types_slugs() ) ) ) | |
| 25 | + return; | |
| 26 | + | |
| 27 | + $screen->set_help_sidebar( | |
| 28 | + '<p><strong>' . sprintf( __( 'For more information:', 'gamipress' ) . '</strong></p>' . | |
| 29 | + '<p>' . sprintf( __( 'Visit the <a href="%s">documentation</a> on the GamiPress website.', 'gamipress' ), esc_url( 'https://gamipress.com/docs' ) ) ) . '</p>' | |
| 30 | + ); | |
| 31 | + | |
| 32 | + // Points/Achievement/Rank types edit screens | |
| 33 | + if( in_array( $screen->id, $gamipress_edit_screens ) ) { | |
| 34 | + | |
| 35 | + switch( $screen->id ) { | |
| 36 | + case 'achievement-type': | |
| 37 | + $label = __( 'Achievement Type', 'gamipress' ); | |
| 38 | + break; | |
| 39 | + case 'points-type': | |
| 40 | + $label = __( 'Points Type', 'gamipress' ); | |
| 41 | + break; | |
| 42 | + case 'rank-type': | |
| 43 | + $label = __( 'Rank Type', 'gamipress' ); | |
| 44 | + break; | |
| 45 | + } | |
| 46 | + | |
| 47 | + $screen->add_help_tab( array( | |
| 48 | + 'id' => 'gamipress-' . $screen->id . '-data', | |
| 49 | + 'title' => sprintf( __( '%s Data', 'gamipress' ), $label ), | |
| 50 | + 'content' => | |
| 51 | + '<p>' . sprintf( __( '<strong>Singular Name</strong> - The singular name for this %s.', 'gamipress' ), strtolower( $label ) ) . '</p>' . | |
| 52 | + '<p>' . sprintf( __( '<strong>Plural Name</strong> - The plural name for this %s.', 'gamipress' ), strtolower( $label ) ) . '</p>' . | |
| 53 | + '<p>' . sprintf( __( '<strong>Slug</strong> - Slug is used for internal references, as some shortcode attributes, to completely differentiate this %s from any other (leave blank to automatically generate one).', 'gamipress' ), strtolower( $label ) ) . '</p>' . | |
| 54 | + (( $screen->id === 'achievement-type' ) ? '<p>' . __( 'After adding a new achievement type a new menu will appear in your admin area named <strong>Achievements</strong>. Inside the achievements menu will appear new sub menus with each achievement type registered to let you manage the achievements similar to WordPress default posts or pages.', 'gamipress' ) . '</p>' : '' ) | |
| 55 | + ) ); | |
| 56 | + | |
| 57 | + if( $screen->id === 'points-type' ) { | |
| 58 | + | |
| 59 | + $screen->add_help_tab( array( | |
| 60 | + 'id' => 'gamipress-points-awards', | |
| 61 | + 'title' => __( 'Points Awards', 'gamipress' ), | |
| 62 | + 'content' => | |
| 63 | + '<p>' . __( 'Points awards are automatic ways a user could retrieve an amount of a points type.', 'gamipress' ) . '</p>' . | |
| 64 | + '<p>' . sprintf( __( 'For more information, see <a href="%s">Points Awards and Deductions</a> documentation page on the GamiPress website.', 'gamipress' ), esc_url( 'https://gamipress.com/docs/getting-started/points-awards-and-deducts/' ) ) . '</p>' | |
| 65 | + ) ); | |
| 66 | + | |
| 67 | + $screen->add_help_tab( array( | |
| 68 | + 'id' => 'gamipress-points-deducts', | |
| 69 | + 'title' => __( 'Points Deductions', 'gamipress' ), | |
| 70 | + 'content' => | |
| 71 | + '<p>' . __( 'Points deduct are automatic ways a user could lose an amount of a points type.', 'gamipress' ) . '</p>' . | |
| 72 | + '<p>' . sprintf( __( 'For more information, see <a href="%s">Points Awards and Deductions</a> documentation page on the GamiPress website.', 'gamipress' ), esc_url( 'https://gamipress.com/docs/getting-started/points-awards-and-deducts/' ) ) . '</p>' | |
| 73 | + ) ); | |
| 74 | + | |
| 75 | + } | |
| 76 | + | |
| 77 | + } | |
| 78 | + | |
| 79 | + // Achievement edit screen | |
| 80 | + if( in_array( $screen->id, gamipress_get_achievement_types_slugs() ) ) { | |
| 81 | + | |
| 82 | + $screen->add_help_tab( array( | |
| 83 | + 'id' => 'gamipress-achievement-data', | |
| 84 | + 'title' => __( 'Achievement Data', 'gamipress' ), | |
| 85 | + 'content' => | |
| 86 | + '<p>' . __( '<strong>Points Awarded</strong> - The amount of points to award to the user for earn the achievement (Optional).', 'gamipress' ) . '</p>' . | |
| 87 | + '<p>' . __( '<strong>Points Type</strong> - The points type of the amount of points to award (Optional).', 'gamipress' ) . '</p>' . | |
| 88 | + '<p>' . __( '<strong>Earned by</strong> - To define how this achievement can be earned. Choosing "Completing steps" will add a new box to configure the steps required.', 'gamipress' ) . '</p>' . | |
| 89 | + '<p>' . __( '<strong>Sequential Steps</strong> <small>(Only if achievement is set up to earned by completing steps)</small> - Checking this option will force users to complete the steps in order.', 'gamipress' ) . '</p>' . | |
| 90 | + '<p>' . __( '<strong>Minimum Points Required</strong> <small>(Only if achievement is set up to earned by a minimum number of points)</small> - The fewest amount of points required to earn the achievement.', 'gamipress' ) . '</p>' . | |
| 91 | + '<p>' . __( '<strong>Points Type Required</strong> <small>(Only if achievement is set up to earned by a minimum number of points)</small> - The points type of the amount of points required to earn the achievement (Optional).', 'gamipress' ) . '</p>' . | |
| 92 | + '<p>' . __( '<strong>Rank Type Required</strong> <small>(Only if achievement is set up to earned by reaching a rank)</small> - The rank type of rank required to earn the achievement (Used to quickly filter the rank required options).', 'gamipress' ) . '</p>' . | |
| 93 | + '<p>' . __( '<strong>Rank Required</strong> <small>(Only if achievement is set up to earned by reaching a rank)</small> - The rank required to earn the achievement .', 'gamipress' ) . '</p>' . | |
| 94 | + '<p>' . __( '<strong>Show Earners</strong> - Checking this option will add a list of users who have earned this achievement on the achievement single view.', 'gamipress' ) . '</p>' . | |
| 95 | + '<p>' . __( '<strong>Congratulations Text</strong> - The text displayed after achievement is earned.', 'gamipress' ) . '</p>' . | |
| 96 | + '<p>' . __( '<strong>Maximum Earnings</strong> - Maximum number of times a user can earn the achievement. You can leave it empty for no maximum.', 'gamipress' ) . '</p>' . | |
| 97 | + '<p>' . __( '<strong>Hidden</strong> - Checking this option will hide the achievement on frontend.', 'gamipress' ) . '</p>' | |
| 98 | + ) ); | |
| 99 | + | |
| 100 | + | |
| 101 | + $screen->add_help_tab( array( | |
| 102 | + 'id' => 'gamipress-steps', | |
| 103 | + 'title' => __( 'Steps', 'gamipress' ), | |
| 104 | + 'content' => | |
| 105 | + '<p>' . __( 'Steps are the conditionals of an achievement to be considered complete. They are present just on achievements that are configured to be earned by completing steps.', 'gamipress' ) . '</p>' . | |
| 106 | + '<p>' . sprintf( __( 'For more information, see <a href="%s">Steps</a> documentation page on the GamiPress website.', 'gamipress' ), esc_url( 'https://gamipress.com/docs/getting-started/steps/' ) ) . '</p>' | |
| 107 | + ) ); | |
| 108 | + } | |
| 109 | + | |
| 110 | + // Rank edit screen | |
| 111 | + if( in_array( $screen->id, gamipress_get_rank_types_slugs() ) ) { | |
| 112 | + | |
| 113 | + $screen->add_help_tab( array( | |
| 114 | + 'id' => 'gamipress-rank-data', | |
| 115 | + 'title' => __( 'Rank Data', 'gamipress' ), | |
| 116 | + 'content' => | |
| 117 | + '<p>' . __( '<strong>Sequential Requirements</strong> - Checking this option will force users to complete the requirements in order.', 'gamipress' ) . '</p>' . | |
| 118 | + '<p>' . __( '<strong>Show Earners</strong> - Checking this option will add a list of users who have reached this rank on the rank single view.', 'gamipress' ) . '</p>' . | |
| 119 | + '<p>' . __( '<strong>Congratulations Text</strong> - The text displayed after rank is earned.', 'gamipress' ) . '</p>' | |
| 120 | + ) ); | |
| 121 | + | |
| 122 | + $screen->add_help_tab( array( | |
| 123 | + 'id' => 'gamipress-rank-details', | |
| 124 | + 'title' => __( 'Rank Details', 'gamipress' ), | |
| 125 | + 'content' => | |
| 126 | + '<p>' . __( '<strong>Priority</strong> - The priority order of the rank.', 'gamipress' ) . '</p>' . | |
| 127 | + '<p>' . __( '<strong>Previous Rank</strong> - Link to the previous rank that user needs to reach to start completing the requirements of the this one.', 'gamipress' ) . '</p>' . | |
| 128 | + '<p>' . __( '<strong>Next Rank</strong> - Link to the next rank user can reach on complete this one.', 'gamipress' ) . '</p>' | |
| 129 | + ) ); | |
| 130 | + | |
| 131 | + | |
| 132 | + $screen->add_help_tab( array( | |
| 133 | + 'id' => 'gamipress-rank-requirements', | |
| 134 | + 'title' => __( 'Rank Requirements', 'gamipress' ), | |
| 135 | + 'content' => | |
| 136 | + '<p>' . __( 'Rank Requirements are the conditionals of a rank to be considered that user can reach it.', 'gamipress' ) . '</p>' . | |
| 137 | + '<p>' . sprintf( __( 'For more information, see <a href="%s">Rank Requirements</a> documentation page on the GamiPress website.', 'gamipress' ), esc_url( 'https://gamipress.com/docs/getting-started/rank-requirements/' ) ) . '</p>' | |
| 138 | + ) ); | |
| 139 | + } | |
| 140 | +} | |
| 141 | +add_action( 'load-post.php', 'gamipress_edit_screen_contextual_help' ); | |
| 142 | +add_action( 'load-post-new.php', 'gamipress_edit_screen_contextual_help' ); | |