Completed
Branch master (7deb3f)
by
unknown
02:39
created

Auto_Load_Next_Post_Settings_Page::need_help()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 0
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * Auto Load Next Post Settings Page
4
 *
5
 * @since    1.0.0
6
 * @version  1.5.5
7
 * @author   Sébastien Dumont
8
 * @category Admin
9
 * @package  Auto Load Next Post/Admin/Settings
10
 * @license  GPL-2.0+
11
 */
12
13
if ( ! defined('ABSPATH') ) {
14
	exit; // Exit if accessed directly.
15
}
16
17
if ( ! class_exists( 'Auto_Load_Next_Post_Settings_Page' ) ) {
18
19
	abstract class Auto_Load_Next_Post_Settings_Page {
20
21
		/**
22
		 * Setting page id.
23
		 *
24
		 * @access protected
25
		 * @var    string $id
26
		 */
27
		protected $id    = '';
28
29
		/**
30
		 * Setting page label.
31
		 *
32
		 * @access protected
33
		 * @var    string $label
34
		 */
35
		protected $label = '';
36
37
		/**
38
		 * Constructor.
39
		 *
40
		 * @access  public
41
		 * @since   1.4.10
42
		 * @version 1.5.5
43
		 */
44
		public function __construct() {
45
			add_filter( 'auto_load_next_post_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
46
			add_action( 'auto_load_next_post_settings_' . $this->id, array( $this, 'need_help' ), 0 );
47
			add_action( 'auto_load_next_post_settings_' . $this->id, array( $this, 'output' ), 10 );
48
			add_action( 'auto_load_next_post_settings_save_' . $this->id, array( $this, 'save' ) );
49
		}
50
51
		/**
52
		 * Get settings page ID.
53
		 *
54
		 * @access public
55
		 * @since  1.4.10
56
		 * @return string
57
		 */
58
		public function get_id() {
59
			return $this->id;
60
		} // END get_id()
61
62
		/**
63
		 * Get settings page label.
64
		 *
65
		 * @access public
66
		 * @since  1.4.10
67
		 * @return string
68
		 */
69
		public function get_label() {
70
			return $this->label;
71
		} // END get_label()
72
73
		/**
74
		 * Add this page to settings.
75
		 *
76
		 * @access public
77
		 * @since  1.0.0
78
		 * @param  array $pages
79
		 * @return array $pages
80
		 */
81
		public function add_settings_page( $pages ) {
82
			$pages[$this->id] = $this->label;
83
84
			return $pages;
85
		} // END add_settings_page()
86
87
		/**
88
		 * Add this settings page to plugin menu.
89
		 *
90
		 * @access public
91
		 * @since  1.0.0
92
		 * @param  array $pages
93
		 * @return array $pages
94
		 */
95
		public function add_menu_page( $pages ) {
96
			$pages[$this->id] = $this->label;
97
98
			return $pages;
99
		} // END add_menu_page()
100
101
		/**
102
		 * Get settings array
103
		 *
104
		 * @access public
105
		 * @since  1.0.0
106
		 * @return array
107
		 */
108
		public function get_settings() {
109
			return array();
110
		} // END get_settings()
111
112
		/**
113
		 * Output the settings.
114
		 *
115
		 * @access public
116
		 * @since  1.0.0
117
		 */
118
		public function output() {
119
			$settings = $this->get_settings();
120
121
			Auto_Load_Next_Post_Admin_Settings::output_fields( $settings );
122
		} // END output()
123
124
		/**
125
		 * Save settings.
126
		 *
127
		 * @access public
128
		 * @since  1.0.0
129
		 * @global $current_tab
130
		 */
131
		public function save() {
132
			global $current_tab;
133
134
			$settings = $this->get_settings();
135
136
			Auto_Load_Next_Post_Admin_Settings::save_fields( $settings, $current_tab );
1 ignored issue
show
Unused Code introduced by
The call to Auto_Load_Next_Post_Admin_Settings::save_fields() has too many arguments starting with $current_tab.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
137
		} // END save()
138
139
		/**
140
		 * Displays a button above the settings header to toggle the help panel.
141
		 * 
142
		 * The help tab does not show for theme selectors if the theme is already supported.
143
		 * 
144
		 * @access public
145
		 * @static
146
		 * @since  1.5.5
147
		 * @global $current_tab
148
		 */
149
		public function need_help() {
150
			global $current_tab;
151
152
			// If theme is already supported then don't show help button for theme selectors.
153
			if ( is_alnp_supported() && $current_tab == 'theme-selectors' ) {
154
				return;
155
			}
156
157
			echo '<a href="#" class="need-help trigger-help" data-tab="' . $current_tab . '"><span class="sonar-dot"></span> ' . esc_html( 'Need Help?', 'auto-load-next-post' ) . '</a>';
158
		} // END need_help()
159
160
	} // END class
161
162
} // END if class exists.
163