Completed
Pull Request — master (#131)
by
unknown
01:49
created

Auto_Load_Next_Post_Settings_Events_Tab::save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Auto Load Next Post Settings - Events
4
 *
5
 * @since    1.0.0
6
 * @version  1.4.10
7
 * @author   Sébastien Dumont
8
 * @category Admin
9
 * @package  Auto Load Next Post
10
 * @license  GPL-2.0+
11
 */
12
13
// Exit if accessed directly.
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
if ( ! class_exists( 'Auto_Load_Next_Post_Settings_Events_Tab' ) ) {
19
20
	class Auto_Load_Next_Post_Settings_Events_Tab extends Auto_Load_Next_Post_Settings_Page {
21
22
		/**
23
		 * Constructor.
24
		 *
25
		 * @access  public
26
		 * @since   1.5.0
27
		 * @version 1.5.0
28
		 */
29
		public function __construct() {
30
			$this->id    = 'events';
31
			$this->label = __( 'Events', 'auto-load-next-post' );
32
33
			parent::__construct();
34
		} // END __construct()
35
36
		/**
37
		 * Get settings array.
38
		 *
39
		 * @access public
40
		 * @since  1.5.0
41
		 * @return array
42
		 */
43
		public function get_settings() {
44
			return apply_filters(
45
				'auto_load_next_post_general_settings', array(
46
47
					array(
48
						'title' => __( 'Events', 'auto-load-next-post' ),
49
						'type'  => 'title',
50
						'desc'  => sprintf( __( 'User defined events, below you can choose external JavaScript events to be triggered alongside Auto Load Next Post native events', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ),
51
						'id'    => 'events_options'
52
					),
53
54
					array(
55
						'title'    => __( 'Post loaded', 'auto-load-next-post' ),
56
						'desc'     => __( 'After the new post has loaded, comma separated events list: <code>event1,event2, ...</code>', 'auto-load-next-post' ),
57
						'id'       => 'auto_load_next_post_on_load_event',
58
						'placeholder' => 'event1,event2, ...',
59
						'type'     => 'textarea',
60
						'css'      => 'min-width:300px;',
61
						'autoload' => false
62
					),
63
64
					array(
65
						'title'    => __( 'Entering a post', 'auto-load-next-post' ),
66
						'desc'     => __( 'Entering a post, comma separated events list: <code>event1,event2, ...</code>', 'auto-load-next-post' ),
67
						'id'       => 'auto_load_next_post_on_entering_event',
68
						'placeholder' => 'event1,event2, ...',
69
						'type'     => 'textarea',
70
						'css'      => 'min-width:300px;',
71
						'autoload' => false
72
					),
73
74
					array(
75
						'type' => 'sectionend',
76
						'id'   => 'events_options'
77
					),
78
			) ); // End general settings
79
		} // END get_settings()
80
81
		/**
82
		 * Output the settings.
83
		 *
84
		 * @access public
85
		 * @since  1.5.0
86
		 */
87
		public function output() {
88
			$settings = $this->get_settings();
89
90
			Auto_Load_Next_Post_Admin_Settings::output_fields( $settings );
91
		} // END output()
92
93
		/**
94
		 * Save settings.
95
		 *
96
		 * @access public
97
		 * @since  1.5.0
98
		 * @global $current_tab
99
		 */
100
		public function save() {
101
			Auto_Load_Next_Post_Admin_Settings::save_fields( $this->get_settings() );
102
		} // END save()
103
104
	} // END class
105
106
} // END if class exists
107
108
return new Auto_Load_Next_Post_Settings_Events_Tab();
109