ajax
5 years ago
capabilities
4 years ago
endpoints
5 years ago
exceptions
7 years ago
filters
4 years ago
formatter
4 years ago
google_search_console
5 years ago
import
4 years ago
listeners
8 years ago
menu
4 years ago
metabox
4 years ago
notifiers
4 years ago
pages
4 years ago
roles
5 years ago
ryte
4 years ago
services
5 years ago
statistics
5 years ago
taxonomy
4 years ago
tracking
4 years ago
views
4 years ago
watchers
5 years ago
admin-settings-changed-listener.php
5 years ago
ajax.php
4 years ago
class-admin-asset-analysis-worker-location.php
5 years ago
class-admin-asset-dev-server-location.php
5 years ago
class-admin-asset-location.php
8 years ago
class-admin-asset-manager.php
4 years ago
class-admin-asset-seo-location.php
4 years ago
class-admin-asset-yoast-components-l10n.php
4 years ago
class-admin-editor-specific-replace-vars.php
5 years ago
class-admin-gutenberg-compatibility-notification.php
5 years ago
class-admin-help-panel.php
5 years ago
class-admin-init.php
4 years ago
class-admin-recommended-replace-vars.php
6 years ago
class-admin-user-profile.php
6 years ago
class-admin-utils.php
5 years ago
class-admin.php
4 years ago
class-asset.php
5 years ago
class-bulk-description-editor-list-table.php
5 years ago
class-bulk-editor-list-table.php
4 years ago
class-bulk-title-editor-list-table.php
6 years ago
class-collector.php
6 years ago
class-config.php
4 years ago
class-customizer.php
5 years ago
class-database-proxy.php
5 years ago
class-export.php
5 years ago
class-expose-shortlinks.php
4 years ago
class-gutenberg-compatibility.php
4 years ago
class-helpscout.php
5 years ago
class-meta-columns.php
4 years ago
class-my-yoast-proxy.php
5 years ago
class-option-tab.php
4 years ago
class-option-tabs-formatter.php
5 years ago
class-option-tabs.php
5 years ago
class-paper-presenter.php
5 years ago
class-plugin-availability.php
5 years ago
class-plugin-conflict.php
4 years ago
class-premium-popup.php
5 years ago
class-premium-upsell-admin-block.php
4 years ago
class-primary-term-admin.php
5 years ago
class-product-upsell-notice.php
5 years ago
class-remote-request.php
5 years ago
class-schema-person-upgrade-notification.php
4 years ago
class-suggested-plugins.php
4 years ago
class-yoast-columns.php
5 years ago
class-yoast-dashboard-widget.php
4 years ago
class-yoast-form.php
4 years ago
class-yoast-input-validation.php
5 years ago
class-yoast-network-admin.php
5 years ago
class-yoast-network-settings-api.php
4 years ago
class-yoast-notification-center.php
4 years ago
class-yoast-notification.php
5 years ago
class-yoast-notifications.php
5 years ago
class-yoast-plugin-conflict.php
4 years ago
index.php
10 years ago
interface-collection.php
7 years ago
interface-installable.php
8 years ago
class-admin-help-panel.php
105 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WPSEO plugin file. |
| 4 | * |
| 5 | * @package WPSEO\Admin |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Generates the HTML for an inline Help Button and Panel. |
| 10 | */ |
| 11 | class WPSEO_Admin_Help_Panel { |
| 12 | |
| 13 | /** |
| 14 | * Unique identifier of the element the inline help refers to, used as an identifier in the html. |
| 15 | * |
| 16 | * @var string |
| 17 | */ |
| 18 | private $id; |
| 19 | |
| 20 | /** |
| 21 | * The Help Button text. Needs a properly escaped string. |
| 22 | * |
| 23 | * @var string |
| 24 | */ |
| 25 | private $help_button_text; |
| 26 | |
| 27 | /** |
| 28 | * The Help Panel content. Needs a properly escaped string (might contain HTML). |
| 29 | * |
| 30 | * @var string |
| 31 | */ |
| 32 | private $help_content; |
| 33 | |
| 34 | /** |
| 35 | * Optional Whether to print out a container div element for the Help Panel, used for styling. |
| 36 | * |
| 37 | * @var string |
| 38 | */ |
| 39 | private $wrapper; |
| 40 | |
| 41 | /** |
| 42 | * Constructor. |
| 43 | * |
| 44 | * @param string $id Unique identifier of the element the inline help refers to, used as |
| 45 | * an identifier in the html. |
| 46 | * @param string $help_button_text The Help Button text. Needs a properly escaped string. |
| 47 | * @param string $help_content The Help Panel content. Needs a properly escaped string (might contain HTML). |
| 48 | * @param string $wrapper Optional Whether to print out a container div element for the Help Panel, |
| 49 | * used for styling. |
| 50 | * Pass a `has-wrapper` value to print out the container. Default: no container. |
| 51 | */ |
| 52 | public function __construct( $id, $help_button_text, $help_content, $wrapper = '' ) { |
| 53 | $this->id = $id; |
| 54 | $this->help_button_text = $help_button_text; |
| 55 | $this->help_content = $help_content; |
| 56 | $this->wrapper = $wrapper; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns the html for the Help Button. |
| 61 | * |
| 62 | * @return string |
| 63 | */ |
| 64 | public function get_button_html() { |
| 65 | |
| 66 | if ( ! $this->id || ! $this->help_button_text || ! $this->help_content ) { |
| 67 | return ''; |
| 68 | } |
| 69 | |
| 70 | return sprintf( |
| 71 | ' <button type="button" class="yoast_help yoast-help-button dashicons" id="%1$s-help-toggle" aria-expanded="false" aria-controls="%1$s-help"><span class="yoast-help-icon" aria-hidden="true"></span><span class="screen-reader-text">%2$s</span></button>', |
| 72 | esc_attr( $this->id ), |
| 73 | $this->help_button_text |
| 74 | ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Returns the html for the Help Panel. |
| 79 | * |
| 80 | * @return string |
| 81 | */ |
| 82 | public function get_panel_html() { |
| 83 | |
| 84 | if ( ! $this->id || ! $this->help_button_text || ! $this->help_content ) { |
| 85 | return ''; |
| 86 | } |
| 87 | |
| 88 | $wrapper_start = ''; |
| 89 | $wrapper_end = ''; |
| 90 | |
| 91 | if ( $this->wrapper === 'has-wrapper' ) { |
| 92 | $wrapper_start = '<div class="yoast-seo-help-container">'; |
| 93 | $wrapper_end = '</div>'; |
| 94 | } |
| 95 | |
| 96 | return sprintf( |
| 97 | '%1$s<p id="%2$s-help" class="yoast-help-panel">%3$s</p>%4$s', |
| 98 | $wrapper_start, |
| 99 | esc_attr( $this->id ), |
| 100 | $this->help_content, |
| 101 | $wrapper_end |
| 102 | ); |
| 103 | } |
| 104 | } |
| 105 |