PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/wordpress-seo/admin/class-help-center-item.php

https://bitbucket.org/carloskikea/helpet
PHP | 96 lines | 41 code | 15 blank | 40 comment | 5 complexity | 39665cd05b8e2e9e82a048f962d5d9fe MD5 | raw file
 1<?php
 2/**
 3 * WPSEO plugin file.
 4 *
 5 * @package WPSEO\Admin\Options\Tabs
 6 */
 7
 8/**
 9 * Class WPSEO_Help_Center_Item
10 */
11class WPSEO_Help_Center_Item {
12
13	/** @var string Identifier for this tab. */
14	private $identifier;
15
16	/** @var string Label to display. */
17	private $label;
18
19	/** @var string The dashicon classname to display in front of the label. */
20	private $dashicon;
21
22	/** @var array Optional arguments. */
23	private $args = array();
24
25	/**
26	 * WPSEO_Help_Center_Item constructor.
27	 *
28	 * @param string $identifier Unique identifier for this tab.
29	 * @param string $label      Label to display.
30	 * @param array  $args       Optional. Settings for this tab.
31	 * @param string $dashicon   Optional. The classname of the dahsicon to put in front of the label.
32	 */
33	public function __construct( $identifier, $label, $args = array(), $dashicon = '' ) {
34		$this->identifier = $identifier;
35		$this->label      = $label;
36		$this->dashicon   = $dashicon;
37		$this->args       = $args;
38	}
39
40	/**
41	 * Get the label.
42	 *
43	 * @return string
44	 */
45	public function get_label() {
46		return $this->label;
47	}
48
49	/**
50	 * Get the identifier.
51	 *
52	 * @return string
53	 */
54	public function get_identifier() {
55		return $this->identifier;
56	}
57
58	/**
59	 * Get the dashicon.
60	 *
61	 * @return string
62	 */
63	public function get_dashicon() {
64		return $this->dashicon;
65	}
66
67	/**
68	 * Get the content of this tab.
69	 *
70	 * @return mixed|string
71	 */
72	public function get_content() {
73		if ( ! empty( $this->args['content'] ) ) {
74			return $this->args['content'];
75		}
76
77		if ( ! empty( $this->args['callback'] ) ) {
78			return call_user_func_array( $this->args['callback'], array( $this ) );
79		}
80
81		if ( ! empty( $this->args['view'] ) ) {
82			$view = $this->args['view'];
83			if ( substr( $view, - 4 ) === '.php' ) {
84				$view = substr( $view, 0, - 4 );
85			}
86
87			if ( ! empty( $this->args['view_arguments'] ) ) {
88				extract( $this->args['view_arguments'] );
89			}
90
91			include WPSEO_PATH . 'admin/views/' . $view . '.php';
92		}
93
94		return '';
95	}
96}