| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
if ( ! class_exists( 'WPB_EA_Plugin_Settings' ) ) : |
| 7 |
/** |
| 8 |
* Plugin settings API class. |
| 9 |
*/ |
| 10 |
class WPB_EA_Plugin_Settings { |
| 11 |
|
| 12 |
/** |
| 13 |
* Settings API. |
| 14 |
* |
| 15 |
* @var Mix |
| 16 |
*/ |
| 17 |
private $settings_api; |
| 18 |
|
| 19 |
/** |
| 20 |
* Class Constructor. |
| 21 |
*/ |
| 22 |
public function __construct() { |
| 23 |
$this->settings_api = new WPB_EA_WeDevs_Settings_API(); |
| 24 |
|
| 25 |
add_action( 'admin_init', array( $this, 'admin_init' ) ); |
| 26 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Admin Init. |
| 31 |
*/ |
| 32 |
public function admin_init() { |
| 33 |
// set the settings. |
| 34 |
$this->settings_api->set_sections( $this->get_settings_sections() ); |
| 35 |
$this->settings_api->set_fields( $this->get_settings_fields() ); |
| 36 |
|
| 37 |
// initialize settings. |
| 38 |
$this->settings_api->admin_init(); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Admin Menu. |
| 43 |
*/ |
| 44 |
public function admin_menu() { |
| 45 |
add_submenu_page( |
| 46 |
'wpb-ea-about', |
| 47 |
esc_html__( 'WPB Elementor Addons Settings', 'wpb-elementor-addons' ), |
| 48 |
esc_html__( 'Settings', 'wpb-elementor-addons' ), |
| 49 |
apply_filters( 'wpb_ea_admin_user_role', 'manage_options' ), |
| 50 |
'wpb_ea_settings', |
| 51 |
array( $this, 'plugin_page' ) |
| 52 |
); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* Settings Sections. |
| 57 |
*/ |
| 58 |
public function get_settings_sections() { |
| 59 |
$sections = apply_filters( |
| 60 |
'wpb_ea_settings_sections', |
| 61 |
array( |
| 62 |
array( |
| 63 |
'id' => 'wpb_ea_addons', |
| 64 |
'title' => esc_html__( 'Elements', 'wpb-elementor-addons' ), |
| 65 |
'addons' => true, |
| 66 |
'icon' => 'dashicons dashicons-admin-tools', |
| 67 |
), |
| 68 |
array( |
| 69 |
'id' => 'wpb_ea_style', |
| 70 |
'title' => esc_html__( 'Style Settings', 'wpb-elementor-addons' ), |
| 71 |
'icon' => 'dashicons dashicons-admin-site-alt3', |
| 72 |
), |
| 73 |
) |
| 74 |
); |
| 75 |
|
| 76 |
return $sections; |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Returns all the settings fields |
| 81 |
* |
| 82 |
* @return array settings fields |
| 83 |
*/ |
| 84 |
public function get_settings_fields() { |
| 85 |
|
| 86 |
$settings_fields = apply_filters( |
| 87 |
'wpb_ea_settings_fields', |
| 88 |
array( |
| 89 |
'wpb_ea_addons' => apply_filters( |
| 90 |
'wpb_ea_required_addons', |
| 91 |
array( |
| 92 |
array( |
| 93 |
'name' => WPB_EA_PREFIX . 'basic_addons', |
| 94 |
'label' => esc_html__( 'Mostly Used Elements', 'wpb-elementor-addons' ), |
| 95 |
'type' => 'section_title', |
| 96 |
), |
| 97 |
array( |
| 98 |
'name' => WPB_EA_PREFIX . 'content_box', |
| 99 |
'label' => esc_html__( 'Content Box', 'wpb-elementor-addons' ), |
| 100 |
'desc' => esc_html__( 'Content Box Grid/Slider can present any static content with an image.', 'wpb-elementor-addons' ), |
| 101 |
'icon' => 'eicon-type-tool', |
| 102 |
'type' => 'toggle', |
| 103 |
'default' => 'on', |
| 104 |
), |
| 105 |
array( |
| 106 |
'name' => WPB_EA_PREFIX . 'counter', |
| 107 |
'label' => esc_html__( 'Counter Up', 'wpb-elementor-addons' ), |
| 108 |
'desc' => esc_html__( 'Counter Up can show your statics in a nice counter.', 'wpb-elementor-addons' ), |
| 109 |
'icon' => 'eicon-counter', |
| 110 |
'type' => 'toggle', |
| 111 |
'default' => 'on', |
| 112 |
), |
| 113 |
array( |
| 114 |
'name' => WPB_EA_PREFIX . 'fancy_list', |
| 115 |
'label' => esc_html__( 'Fancy List', 'wpb-elementor-addons' ), |
| 116 |
'desc' => esc_html__( 'Fancy List can show your list items in a beautiful way.', 'wpb-elementor-addons' ), |
| 117 |
'icon' => 'eicon-editor-list-ul', |
| 118 |
'type' => 'toggle', |
| 119 |
'default' => 'on', |
| 120 |
), |
| 121 |
array( |
| 122 |
'name' => WPB_EA_PREFIX . 'image_gallery', |
| 123 |
'label' => esc_html__( 'Filterable Image Gallery', 'wpb-elementor-addons' ), |
| 124 |
'desc' => esc_html__( 'Filterable Image Gallery to showcase your images with filtering options.', 'wpb-elementor-addons' ), |
| 125 |
'icon' => 'eicon-gallery-grid', |
| 126 |
'type' => 'toggle', |
| 127 |
'default' => 'on', |
| 128 |
), |
| 129 |
array( |
| 130 |
'name' => WPB_EA_PREFIX . 'logo_slider', |
| 131 |
'label' => esc_html__( 'Logo Slider', 'wpb-elementor-addons' ), |
| 132 |
'desc' => esc_html__( 'Logo Slider can showcase your sponsors/featured logos in a slider.', 'wpb-elementor-addons' ), |
| 133 |
'icon' => 'eicon-logo', |
| 134 |
'type' => 'toggle', |
| 135 |
'default' => 'on', |
| 136 |
), |
| 137 |
array( |
| 138 |
'name' => WPB_EA_PREFIX . 'news_ticker', |
| 139 |
'label' => esc_html__( 'News Ticker', 'wpb-elementor-addons' ), |
| 140 |
'desc' => esc_html__( 'This news ticker can scroll/slide content in a different style.', 'wpb-elementor-addons' ), |
| 141 |
'icon' => 'eicon-document-file', |
| 142 |
'type' => 'toggle', |
| 143 |
'default' => 'on', |
| 144 |
), |
| 145 |
array( |
| 146 |
'name' => WPB_EA_PREFIX . 'post_grid_slider', |
| 147 |
'label' => esc_html__( 'Post Grid and Slider', 'wpb-elementor-addons' ), |
| 148 |
'desc' => esc_html__( 'Post Grid/Slider that displays any post types posts in a nice grid or slider.', 'wpb-elementor-addons' ), |
| 149 |
'icon' => 'eicon-posts-grid', |
| 150 |
'type' => 'toggle', |
| 151 |
'default' => 'on', |
| 152 |
), |
| 153 |
array( |
| 154 |
'name' => WPB_EA_PREFIX . 'pricing_tables', |
| 155 |
'label' => esc_html__( 'Pricing Table', 'wpb-elementor-addons' ), |
| 156 |
'desc' => esc_html__( 'Pricing Table to increases your sales.', 'wpb-elementor-addons' ), |
| 157 |
'icon' => 'eicon-price-table', |
| 158 |
'type' => 'toggle', |
| 159 |
'default' => 'on', |
| 160 |
), |
| 161 |
array( |
| 162 |
'name' => WPB_EA_PREFIX . 'service_box', |
| 163 |
'label' => esc_html__( 'Service Box', 'wpb-elementor-addons' ), |
| 164 |
'desc' => esc_html__( 'Service Box for showing your offer for your customers.', 'wpb-elementor-addons' ), |
| 165 |
'icon' => 'eicon-editor-italic', |
| 166 |
'type' => 'toggle', |
| 167 |
'default' => 'on', |
| 168 |
), |
| 169 |
array( |
| 170 |
'name' => WPB_EA_PREFIX . 'slider', |
| 171 |
'label' => esc_html__( 'Hero Slider', 'wpb-elementor-addons' ), |
| 172 |
'desc' => esc_html__( 'Hero Slider can show a slideshow of images, contents and buttons.', 'wpb-elementor-addons' ), |
| 173 |
'icon' => 'eicon-slideshow', |
| 174 |
'type' => 'toggle', |
| 175 |
'default' => 'on', |
| 176 |
), |
| 177 |
array( |
| 178 |
'name' => WPB_EA_PREFIX . 'team_members', |
| 179 |
'label' => esc_html__( 'Team Members', 'wpb-elementor-addons' ), |
| 180 |
'desc' => esc_html__( 'Team Members Grid/Slider for showing all of your team members.', 'wpb-elementor-addons' ), |
| 181 |
'icon' => 'eicon-person', |
| 182 |
'type' => 'toggle', |
| 183 |
'default' => 'on', |
| 184 |
), |
| 185 |
array( |
| 186 |
'name' => WPB_EA_PREFIX . 'testimonials', |
| 187 |
'label' => esc_html__( 'Clients Testimonials', 'wpb-elementor-addons' ), |
| 188 |
'desc' => esc_html__( 'Testimonials Grid/Slider can show your clients feedbacks.', 'wpb-elementor-addons' ), |
| 189 |
'icon' => 'eicon-testimonial-carousel', |
| 190 |
'type' => 'toggle', |
| 191 |
'default' => 'on', |
| 192 |
), |
| 193 |
array( |
| 194 |
'name' => WPB_EA_PREFIX . 'video_popup', |
| 195 |
'label' => esc_html__( 'Video Popup', 'wpb-elementor-addons' ), |
| 196 |
'desc' => esc_html__( 'Video Popup that displays a video in a popup, can be used for video call to action.', 'wpb-elementor-addons' ), |
| 197 |
'icon' => 'eicon-play', |
| 198 |
'type' => 'toggle', |
| 199 |
'default' => 'on', |
| 200 |
), |
| 201 |
array( |
| 202 |
'name' => WPB_EA_PREFIX . 'timeline', |
| 203 |
'label' => esc_html__( 'Content Timeline', 'wpb-elementor-addons' ), |
| 204 |
'desc' => esc_html__( 'Content Timeline to show any type of content in a timeline. Support for image, iframe, ShortCode, icon, date etc.', 'wpb-elementor-addons' ), |
| 205 |
'icon' => 'eicon-time-line', |
| 206 |
'type' => 'toggle', |
| 207 |
'default' => 'on', |
| 208 |
), |
| 209 |
array( |
| 210 |
'name' => WPB_EA_PREFIX . 'videos_grid', |
| 211 |
'label' => esc_html__( 'Videos Grid', 'wpb-elementor-addons' ), |
| 212 |
'desc' => esc_html__( 'Videos Grid with title, content, and details link and self-hosted/ YouTube Videos.', 'wpb-elementor-addons' ), |
| 213 |
'icon' => 'eicon-youtube', |
| 214 |
'type' => 'toggle', |
| 215 |
'default' => 'on', |
| 216 |
), |
| 217 |
|
| 218 |
) |
| 219 |
), |
| 220 |
|
| 221 |
'wpb_ea_style' => array( |
| 222 |
array( |
| 223 |
'name' => 'wpb_ea_primary_color', |
| 224 |
'label' => esc_html__( 'Primary color', 'wpb-elementor-addons' ), |
| 225 |
'desc' => esc_html__( 'Select your primary color. Default: #3878ff', 'wpb-elementor-addons' ), |
| 226 |
'type' => 'color', |
| 227 |
'default' => '#3878ff', |
| 228 |
), |
| 229 |
array( |
| 230 |
'name' => 'wpb_ea_primary_color_light', |
| 231 |
'label' => esc_html__( 'Primary color light', 'wpb-elementor-addons' ), |
| 232 |
'desc' => esc_html__( 'Select your primary color. Default: #7ca6ff', 'wpb-elementor-addons' ), |
| 233 |
'type' => 'color', |
| 234 |
'default' => '#7ca6ff', |
| 235 |
), |
| 236 |
array( |
| 237 |
'name' => 'wpb_ea_primary_color_dark', |
| 238 |
'label' => esc_html__( 'Primary color dark', 'wpb-elementor-addons' ), |
| 239 |
'desc' => esc_html__( 'Select your primary color. Default: #004dcb', 'wpb-elementor-addons' ), |
| 240 |
'type' => 'color', |
| 241 |
'default' => '#004dcb', |
| 242 |
), |
| 243 |
), |
| 244 |
|
| 245 |
) |
| 246 |
); |
| 247 |
|
| 248 |
return $settings_fields; |
| 249 |
} |
| 250 |
|
| 251 |
/** |
| 252 |
* The plugin page. |
| 253 |
*/ |
| 254 |
public function plugin_page() { |
| 255 |
$count = count( $this->get_settings_sections() ); |
| 256 |
if ( $count <= 1 ) { |
| 257 |
$class = 'wpb-ea-settings-sections-no'; |
| 258 |
} else { |
| 259 |
$class = 'wpb-ea-settings-sections-yes'; |
| 260 |
} |
| 261 |
|
| 262 |
echo '<div class="wrap wpb-wrap about-wrap wpb-ea-settings-wrap ' . esc_attr( $class ) . '">'; |
| 263 |
settings_errors(); |
| 264 |
$this->settings_api->show_navigation(); |
| 265 |
$this->settings_api->show_forms(); |
| 266 |
echo '</div>'; |
| 267 |
} |
| 268 |
|
| 269 |
/** |
| 270 |
* Get all the pages |
| 271 |
* |
| 272 |
* @return array page names with key value pairs |
| 273 |
*/ |
| 274 |
public function get_pages() { |
| 275 |
$pages = get_pages(); |
| 276 |
$pages_options = array(); |
| 277 |
if ( $pages ) { |
| 278 |
foreach ( $pages as $page ) { |
| 279 |
$pages_options[ $page->ID ] = $page->post_title; |
| 280 |
} |
| 281 |
} |
| 282 |
|
| 283 |
return $pages_options; |
| 284 |
} |
| 285 |
} |
| 286 |
endif; |
| 287 |
|
| 288 |
|
| 289 |
new WPB_EA_Plugin_Settings(); |
| 290 |
|