2018-02-23 04:55:25 -05:00
< ? php
/**
* 2 AM 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 () {
2018-07-02 04:39:41 -04:00
2018-02-23 04:55:25 -05:00
$sections = array (
array (
'id' => 'general_setting_sec' ,
'title' => __ ( 'General Settings' , 'vaincode' )
2018-07-02 04:39:41 -04:00
),
array (
'id' => 'email_setting_sec' ,
'title' => __ ( 'Email Settings' , 'vaincode' )
)
2018-02-23 04:55:25 -05:00
);
2018-07-02 04:39:41 -04:00
2018-02-23 04:55:25 -05:00
return $sections ;
}
/**
* Returns all the settings fields
*
* @ return array settings fields
*/
function get_settings_fields () {
$settings_fields = array (
'general_setting_sec' => array (
2018-07-02 04:39:41 -04:00
2018-02-23 04:55:25 -05:00
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' => ''
),
2018-07-02 04:39:41 -04:00
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' => '' ,
),
2018-02-23 04:55:25 -05:00
),
2018-07-02 04:39:41 -04:00
2018-02-23 04:55:25 -05:00
);
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 ;
}