PluginProbe
Ever Compare – Products Compare Plugin for WooCommerce / 1.0.2
Ever Compare – Products Compare Plugin for WooCommerce v1.0.2
1.3.7 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 trunk 1.0.0 1.0.1 1.0.2 All 31 releases
ever-compare / includes / classes / Admin / Admin_Fields.php

Admin_Fields.php in Ever Compare – Products Compare Plugin for WooCommerce 1.0.2, at includes/classes/Admin/Admin_Fields.php

206 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace EverCompare\Admin;
3 /**
4 * Admin Page Fields handlers class
5 */
6 class Admin_Fields {
7
8 private $settings_api;
9
10 /**
11 * [$_instance]
12 * @var null
13 */
14 private static $_instance = null;
15
16 /**
17 * [instance] Initializes a singleton instance
18 * @return [Admin]
19 */
20 public static function instance() {
21 if ( is_null( self::$_instance ) ) {
22 self::$_instance = new self();
23 }
24 return self::$_instance;
25 }
26
27 function __construct() {
28 $this->settings_api = new Settings_APi();
29 add_action( 'admin_init', [ $this, 'admin_init' ] );
30 }
31
32 public function admin_init() {
33
34 //set the settings
35 $this->settings_api->set_sections( $this->get_settings_sections() );
36 $this->settings_api->set_fields( $this->fields_settings() );
37
38 //initialize settings
39 $this->settings_api->admin_init();
40 }
41
42 // Options page Section register
43 public function get_settings_sections() {
44 $sections = array(
45
46 array(
47 'id' => 'ever_compare_settings_tabs',
48 'title' => esc_html__( 'Button Settings', 'ever-compare' )
49 ),
50
51 array(
52 'id' => 'ever_compare_table_settings_tabs',
53 'title' => esc_html__( 'Table Settings', 'ever-compare' )
54 ),
55
56 );
57 return $sections;
58 }
59
60 // Options page field register
61 protected function fields_settings() {
62
63 $settings_fields = array(
64
65 'ever_compare_settings_tabs' => array(
66
67 array(
68 'name' => 'btn_show_shoppage',
69 'label' => __( 'Show compare button in product list', 'ever-compare' ),
70 'type' => 'checkbox',
71 'default' => 'on',
72 ),
73
74 array(
75 'name' => 'btn_show_productpage',
76 'label' => __( 'Show compare button on single product page', 'ever-compare' ),
77 'type' => 'checkbox',
78 'default' => 'on',
79 ),
80
81 array(
82 'name' => 'open_popup',
83 'label' => __( 'Open popup', 'ever-compare' ),
84 'type' => 'checkbox',
85 'default' => 'on',
86 ),
87
88 array(
89 'name' => 'button_text',
90 'label' => __( 'Button', 'ever-compare' ),
91 'desc' => __( 'Enter your compare button text.', 'ever-compare' ),
92 'type' => 'text',
93 'default' => __( 'Compare', 'ever-compare' ),
94 'placeholder' => __( 'Compare', 'ever-compare' ),
95 ),
96
97 array(
98 'name' => 'added_button_text',
99 'label' => __( 'Added Button Text', 'ever-compare' ),
100 'desc' => __( 'Enter your compare added button text.', 'ever-compare' ),
101 'type' => 'text',
102 'default' => __( 'Added', 'ever-compare' ),
103 'placeholder' => __( 'Added', 'ever-compare' ),
104 ),
105
106 ),
107
108 'ever_compare_table_settings_tabs' => array(
109
110 array(
111 'name' => 'compare_page',
112 'label' => __( 'Compare page', 'ever-compare' ),
113 'desc' => wp_kses_post('Select a compare page for compare table. It should contain the shortcode <code>[evercompare_table]</code>'),
114 'type' => 'select',
115 'default' => '0',
116 'options' => ever_compare_get_post_list()
117 ),
118
119 array(
120 'name' => 'show_fields',
121 'label' => __('Show fields in table', 'ever-compare'),
122 'desc' => __('Choose which fields should be presented on the product compare page with table.', 'ever-compare'),
123 'type' => 'multicheckshort',
124 'options' => ever_compare_get_available_attributes(),
125 'default' => [
126 'title' => esc_html__( 'title', 'ever-compare' ),
127 'ratting' => esc_html__( 'ratting', 'ever-compare' ),
128 'price' => esc_html__( 'price', 'ever-compare' ),
129 'add_to_cart' => esc_html__( 'add_to_cart', 'ever-compare' ),
130 'description' => esc_html__( 'description', 'ever-compare' ),
131 'availability' => esc_html__( 'availability', 'ever-compare' ),
132 'sku' => esc_html__( 'sku', 'ever-compare' ),
133 'weight' => esc_html__( 'weight', 'ever-compare' ),
134 'dimensions' => esc_html__( 'dimensions', 'ever-compare' ),
135 ],
136 ),
137
138 array(
139 'name' => 'table_heading',
140 'label' => __( 'Fields heading text', 'ever-compare' ),
141 'desc' => __( 'You can change heading text from here.', 'ever-compare' ),
142 'type' => 'multitext',
143 'options' => ever_compare_table_heading()
144 ),
145
146 array(
147 'name' => 'empty_table_text',
148 'label' => __('Empty compare page text', 'ever-compare'),
149 'desc' => __('Text will be displayed if user don\'t add any products to compare', 'ever-compare'),
150 'type' => 'textarea'
151 ),
152
153 array(
154 'name' => 'shop_button_text',
155 'label' => __( 'Return to shop button text', 'ever-compare' ),
156 'desc' => __( 'Enter your return to shop button text.', 'ever-compare' ),
157 'type' => 'text',
158 'default' => __( 'Return to shop', 'ever-compare' ),
159 'placeholder' => __( 'Return to shop', 'ever-compare' ),
160 ),
161
162 array(
163 'name' => 'image_size',
164 'label' => __( 'Image size', 'ever-compare' ),
165 'desc' => __( 'Enter your required image size.', 'ever-compare' ),
166 'type' => 'multitext',
167 'options' =>[
168 'width' => esc_html__( 'Width', 'ever-compare' ),
169 'height' => esc_html__( 'Height', 'ever-compare' ),
170 ]
171 ),
172
173 array(
174 'name' => 'hard_crop',
175 'label' => __( 'Image Hard Crop', 'ever-compare' ),
176 'type' => 'checkbox',
177 'default' => 'on',
178 ),
179
180 ),
181
182 );
183
184 return $settings_fields;
185 }
186
187 public function plugin_page() {
188 echo '<div class="wrap">';
189 echo '<h2>'.esc_html__( 'Compare Settings','ever-compare' ).'</h2>';
190 $this->save_message();
191 $this->settings_api->show_navigation();
192 $this->settings_api->show_forms();
193 echo '</div>';
194 }
195
196 public function save_message() {
197 if( isset( $_GET['settings-updated'] ) ) {
198 ?>
199 <div class="updated notice is-dismissible">
200 <p><strong><?php esc_html_e('Successfully Settings Saved.', 'ever-compare') ?></strong></p>
201 </div>
202 <?php
203 }
204 }
205
206 }