PluginProbe
Additional Terms Lite for WooCommerce / 1.6.1
Additional Terms Lite for WooCommerce v1.6.1
1.7.3 1.7.2.1 trunk 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 All 35 releases
woo-additional-terms / src / Settings / Settings.php

Settings.php in Additional Terms Lite for WooCommerce 1.6.1, at src/Settings/Settings.php

144 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The plugin settings.
4 *
5 * @author MyPreview (Github: @mahdiyazdani, @gooklani, @mypreview)
6 *
7 * @since 1.4.0
8 *
9 * @package woo-additional-terms
10 */
11
12 namespace Woo_Additional_Terms\Settings;
13
14 use WC_Settings_Page;
15 use Woo_Additional_Terms\Helper;
16
17 /**
18 * Class Settings.
19 */
20 class Settings extends WC_Settings_Page {
21
22 /**
23 * Setup settings class.
24 *
25 * @since 1.4.0
26 *
27 * @return void
28 */
29 public function __construct() {
30
31 $this->assign();
32 $this->setup();
33 $this->enqueue();
34
35 parent::__construct();
36 }
37
38 /**
39 * Assign the settings properties.
40 *
41 * @since 1.4.0
42 *
43 * @return void
44 */
45 private function assign() {
46
47 $this->id = sanitize_key( woo_additional_terms()->get_slug() );
48 $this->label = _x( 'Additional Terms', 'settings tab label', 'woo-additional-terms' );
49 }
50
51 /**
52 * Setup hooks and filters.
53 *
54 * @since 1.4.0
55 *
56 * @return void
57 */
58 public function setup() {
59
60 add_filter( 'admin_body_class', array( $this, 'add_body_class' ) );
61 add_action( "woocommerce_settings_{$this->id}", array( $this, 'sidebar' ) );
62 }
63
64 /**
65 * Add plugin specific class to body.
66 *
67 * @since 1.4.0
68 *
69 * @param string $classes Classes to be added to the body element.
70 *
71 * @return string
72 */
73 public function add_body_class( $classes ) {
74
75 // Bail early if the current page is not the settings page.
76 if ( ! Helper\Settings::is_page() ) {
77 return $classes;
78 }
79
80 $classes .= sprintf( ' %s-page', sanitize_html_class( $this->id ) );
81
82 return $classes;
83 }
84
85 /**
86 * Display the sidebar.
87 *
88 * @since 1.4.0
89 *
90 * @return void
91 */
92 public function sidebar() {
93
94 woo_additional_terms()->service( 'template_manager' )->echo_template(
95 'sidebar/sidebar.php'
96 );
97 }
98
99 /**
100 * Enqueue the settings assets.
101 *
102 * @since 1.4.0
103 *
104 * @return void
105 */
106 private function enqueue() {
107
108 // Bail early if the current page is not the settings page.
109 if ( ! Helper\Settings::is_page() ) {
110 return;
111 }
112
113 // Enqueue the settings assets.
114 wp_enqueue_style( 'woo-additional-terms-admin' );
115 wp_enqueue_script( 'woo-additional-terms-admin' );
116 }
117
118 /**
119 * Get own sections.
120 *
121 * @since 1.6.0
122 *
123 * @return array
124 */
125 protected function get_own_sections() {
126
127 return array(
128 '' => _x( 'General', 'settings tab', 'woo-additional-terms' ),
129 );
130 }
131
132 /**
133 * Get settings array.
134 *
135 * @since 1.4.0
136 *
137 * @return array
138 */
139 protected function get_settings_for_default_section() {
140
141 return woo_additional_terms()->service( 'settings_general' )->get_fields();
142 }
143 }
144