Skip to content

Commit

Permalink
Unalbe to change title name #78
Browse files Browse the repository at this point in the history
  • Loading branch information
ritakikani committed Sep 1, 2023
1 parent a6f7702 commit 322b996
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 256 deletions.
196 changes: 84 additions & 112 deletions admin/wpem-rest-api-settings.php
Original file line number Diff line number Diff line change
@@ -1,108 +1,90 @@
<?php
/*
* This file use for settings at admin site for wp event manager plugin.
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
* WPEM_Rest_API_Settings class.
* WPEM_Rest_API_Settings class used to create settings fields and save settings.
*/

class WPEM_Rest_API_Settings {

public $settings;

/**
* __construct function.
*
* @access public
* @return void
*/

public function __construct() {

$this->settings_group = 'wpem_rest_api';
add_action( 'admin_init', array( $this, 'register_settings' ) );
}

/**
* init_settings function.
*
* @access public
* @return void
*/
public function init_settings() {

$this->settings = apply_filters( 'wpem_rest_api_settings',

array(
'general' => array(
'label' => __( 'General', 'wpem-rest-api' ),
'icon' => 'meter',
'type' => 'fields',
'sections' => array(
'general' => __('General Settings','wpem-rest-api'),
'general' => array(
'label' => __( 'General', 'wpem-rest-api' ),
'icon' => 'meter',
'type' => 'fields',
'sections' => array(
'general' => __('General Settings','wpem-rest-api'),
),
'fields' => array(
'general' => array(
array(
'name' => 'enable_wpem_rest_api',
'std' => '1',
'label' => __( 'Enable Rest API', 'wpem-rest-api' ),
'cb_label' => __( 'Disable to remove the API functionality from your event website.', 'wpem-rest-api' ),
'desc' => '',
'type' => 'checkbox',
'attributes' => array(),
),
'fields' => array(
'general' => array(
array(
'name' => 'enable_wpem_rest_api',
'std' => '1',
'label' => __( 'Enable Rest API', 'wpem-rest-api' ),
'cb_label' => __( 'Disable to remove the API functionality from your event website.', 'wpem-rest-api' ),
'desc' => '',
'type' => 'checkbox',
'attributes' => array(),
),

array(
'name' => 'wpem_rest_api_app_name',
'std' => 'WP Event Manager',
'cb_label' => __( 'Add name of your Application.', 'wpem-rest-api' ),
'label' => __( 'Application name', 'wpem-rest-api' ),
'desc' => __( '', 'wpem-rest-api' ),
'type' => 'text',

'attributes' => array(),
),

array(
'name' => 'wpem_rest_api_app_logo',
'std' => '',
'cb_label' => __( 'Upload the logo of your own brand.', 'wpem-rest-api' ),
'label' => __( 'App Logo', 'wpem-rest-api' ),
'desc' => __( 'Upload smallest file possible to ensure lesser loading time', 'wpem-rest-api' ),
'type' => 'file',

'attributes' => array(),
),

),
)
),
'api-access' => array(
'label' => __( 'API Access', 'wpem-rest-api' ),
'icon' => 'loop',
'type' => 'template',
),
'app-branding' => array(
'label' => __( 'APP Branding', 'wpem-rest-api' ),
'icon' => 'mobile',
'type' => 'template',
),
array(
'name' => 'wpem_rest_api_app_name',
'std' => 'WP Event Manager',
'label' => __( 'Application Name', 'wpem-rest-api' ),
'cb_label' => __( 'WP Event Manager', 'wpem-rest-api' ),
'desc' => '',
'type' => 'text',
'attributes' => array(),
),
array(
'name' => 'wpem_rest_api_app_logo',
'std' => '',
'cb_label' => __( 'Upload the logo of your own brand.', 'wpem-rest-api' ),
'label' => __( 'App Logo', 'wpem-rest-api' ),
'desc' => __( 'Upload smallest file possible to ensure lesser loading time', 'wpem-rest-api' ),
'type' => 'file',
'attributes' => array(),
),
),
)
),
'api-access' => array(
'label' => __( 'API Access', 'wpem-rest-api' ),
'icon' => 'loop',
'type' => 'template',
),
'app-branding' => array(
'label' => __( 'APP Branding', 'wpem-rest-api' ),
'icon' => 'mobile',
'type' => 'template',
),
)
);
}

/**
* register_settings function.
*
* @access public
* @return void
*/
public function register_settings() {

$this->init_settings();

foreach($this->settings as $settings ){
Expand All @@ -111,7 +93,6 @@ public function register_settings() {

if(isset($settings['fields'][$section_key]))
foreach ( $settings['fields'][$section_key] as $option ) {

if(isset($option['name']) && isset($option['std']) )
add_option( $option['name'], $option['std'] );

Expand All @@ -122,14 +103,11 @@ public function register_settings() {
}

/**
* output function.
*
* output function used to display setting fields at backend side in settings.
* @access public
* @return void
*/

public function output() {

$this->init_settings();

wp_enqueue_style( 'wpem-rest-api-backend', WPEM_REST_API_PLUGIN_URL.'/assets/css/backend.min.css' );
Expand All @@ -140,51 +118,45 @@ public function output() {
$action = '';
if(in_array($current_tab, ['general'])){
$action = 'action=options.php';
}?>
} ?>
<div class="wrap">
<h1><?php _e( 'Rest API Settings', 'wpem-rest-api' ); ?></h1>
</div>

<div id="wpbody" role="main">
<div id="wpbody-content" class="wpem-admin-container">

<div class="wpem-wrap">
<form method="post" name="wpem-rest-settings-form" <?php echo esc_attr($action); ?> >

<?php settings_fields( $this->settings_group ); ?>

<div class="wpem-admin-left-sidebar">
<ul class="wpem-admin-left-menu">

<?php foreach ( $this->settings as $key => $section ) { ?>
<li class="wpem-admin-left-menu-item">
<a class="wpem-icon-<?php echo isset($section['icon']) ? esc_attr($section['icon']) : 'meter';?> nav-tab <?php if ( isset( $_GET['tab'] ) && ( $_GET['tab'] == $key ) ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( 'edit.php?post_type=event_listing&page=wpem-rest-api-settings&tab='.$key ) );?>"><?php echo esc_html( $section['label'] ) ;?></a>
</li>
<?php } ?>
</ul>
</div>
<div class="wpem-admin-right-container wpem-<?php echo esc_html($current_tab); ?> wpem-app-branding-mode wpem-light-mode">
<div class="metabox-holder wpem-admin-right-container-holder">
<div class="wpem-admin-top-title-section postbox">
<?php
if (!empty($_GET['settings-updated'])) {
flush_rewrite_rules();
echo '<div class="updated fade event-manager-updated"><p>' . __( 'Settings successfully saved', 'wpem-rest-api' ) . '</p></div>';
}
include('templates/wpem-rest-settings-panel.php');
?>
</div>
<p class="submit">
<input type="submit" class="button-primary wpem-backend-theme-button" id="save-changes" value="<?php _e( 'Save Changes', 'wpem-rest-api' ); ?>" />
</p>
<div id="wpbody-content" class="wpem-admin-container">
<div class="wpem-wrap">
<form method="post" name="wpem-rest-settings-form" <?php echo esc_attr($action); ?> >

<?php settings_fields( $this->settings_group ); ?>
<div class="wpem-admin-left-sidebar">
<ul class="wpem-admin-left-menu">
<?php foreach ( $this->settings as $key => $section ) { ?>
<li class="wpem-admin-left-menu-item">
<a class="wpem-icon-<?php echo isset($section['icon']) ? esc_attr($section['icon']) : 'meter';?> nav-tab <?php if ( isset( $_GET['tab'] ) && ( $_GET['tab'] == $key ) ) echo 'nav-tab-active'; ?>" href="<?php echo esc_url( admin_url( 'edit.php?post_type=event_listing&page=wpem-rest-api-settings&tab='.$key ) );?>"><?php echo esc_html( $section['label'] ) ;?></a>
</li>
<?php } ?>
</ul>
</div>

</div>

</form>
</div>
</div>
<div class="wpem-admin-right-container wpem-<?php echo esc_html($current_tab); ?> wpem-app-branding-mode wpem-light-mode">
<div class="metabox-holder wpem-admin-right-container-holder">
<div class="wpem-admin-top-title-section postbox">
<?php
if (!empty($_GET['settings-updated'])) {
flush_rewrite_rules();
echo '<div class="updated fade event-manager-updated"><p>' . __( 'Settings successfully saved', 'wpem-rest-api' ) . '</p></div>';
}
include('templates/wpem-rest-settings-panel.php'); ?>
</div>
<p class="submit">
<input type="submit" class="button-primary wpem-backend-theme-button" id="save-changes" value="<?php _e( 'Save Changes', 'wpem-rest-api' ); ?>" />
</p>
</div>
</div>
</form>
</div>
</div>
</div>
<?php wp_enqueue_script( 'wp-event-manager-admin-settings');
<?php wp_enqueue_script( 'wp-event-manager-admin-settings');
}
}
}
Loading

0 comments on commit 322b996

Please sign in to comment.