mage-eventpress/inc/admin_setting_panel.php

162 lines
4.2 KiB
PHP

<?php
/**
* 2AM Awesome loginbar Settings Controls
*
* @version 1.0
*
*/
if ( !class_exists('MAGE_Events_Setting_Controls' ) ):
class MAGE_Events_Setting_Controls {
private $settings_api;
function __construct() {
$this->settings_api = new MAGE_Setting_API;
add_action( 'admin_init', array($this, 'admin_init') );
add_action( 'admin_menu', array($this, 'admin_menu') );
}
function admin_init() {
//set the settings
$this->settings_api->set_sections( $this->get_settings_sections() );
$this->settings_api->set_fields( $this->get_settings_fields() );
//initialize settings
$this->settings_api->admin_init();
}
function admin_menu() {
add_options_page( 'Event Settings', 'Event Settings', 'delete_posts', 'mep_event_settings_page', array($this, 'plugin_page') );
}
function get_settings_sections() {
$sections = array(
array(
'id' => 'general_setting_sec',
'title' => __( 'General Settings', 'vaincode' )
),
array(
'id' => 'email_setting_sec',
'title' => __( 'Email Settings', 'vaincode' )
)
);
return $sections;
}
/**
* Returns all the settings fields
*
* @return array settings fields
*/
function get_settings_fields() {
$settings_fields = array(
'general_setting_sec' => array(
array(
'name' => 'google-map-api',
'label' => __( 'Google Map API Key', 'mep' ),
'desc' => __( 'Enter Your Google Map API key. <a href=https://developers.google.com/maps/documentation/javascript/get-api-key target=_blank>Get KEY</a>', 'mep' ),
'type' => 'text',
'default' => ''
),
array(
'name' => 'mep_global_single_template',
'label' => __( 'Event Details Template', 'mep' ),
'desc' => __( 'Event Details Template', 'mep' ),
'type' => 'select',
'default' => 'no',
'options' => event_template_name()
),
),
'email_setting_sec' => array(
array(
'name' => 'mep_email_form_name',
'label' => __( 'Email Form Name', 'mep' ),
'desc' => __( 'Email Form Name', 'mep' ),
'type' => 'text'
),
array(
'name' => 'mep_email_form_email',
'label' => __( 'Form Email', 'mep' ),
'desc' => __( 'Form Email', 'mep' ),
'type' => 'text'
),
array(
'name' => 'mep_email_subject',
'label' => __( 'Email Subject', 'mep' ),
'desc' => __( 'Email Subject', 'mep' ),
'type' => 'text'
),
array(
'name' => 'mep_confirmation_email_text',
'label' => __( 'Confirmation Email Text', 'mep' ),
'desc' => __( 'Confirmation Email Text', 'mep' ),
'type' => 'textarea',
'default' => '',
),
),
);
return $settings_fields;
}
function plugin_page() {
echo '<div class="wrap">';
$this->settings_api->show_navigation();
$this->settings_api->show_forms();
echo '</div>';
}
/**
* Get all the pages
*
* @return array page names with key value pairs
*/
function get_pages() {
$pages = get_pages();
$pages_options = array();
if ( $pages ) {
foreach ($pages as $page) {
$pages_options[$page->ID] = $page->post_title;
}
}
return $pages_options;
}
}
endif;
$settings = new MAGE_Events_Setting_Controls();
function mep_get_option( $option, $section, $default = '' ) {
$options = get_option( $section );
if ( isset( $options[$option] ) ) {
return $options[$option];
}
return $default;
}