HEX
Server: Apache
System: Linux cpanelx.inxs.ro 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: crowdandsafety (1041)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/cwd/wp-content/plugins/tco-email-forms/email-integration/functions/admin/controller.php
<?php
// =============================================================================
// EMAIL-INTEGRATION/FUNCTIONS/ADMIN/CONTROLLER.PHP
// -----------------------------------------------------------------------------
// This file handles all the admin page logic, and loads the view. Included
// from the context of "Tco_Email_Integration"
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
//   01. Run Conditionally
//   02. Generate Tabs
//   03. Set Active Provider
//   04. Save Options
//   05. Prepare Additional Data For View
//   06. Tab Setup: Email Forms
//   07. Tab Setup: General Settings
//   08. Tab Setup: Specific Providers
//   09. Load View
// =============================================================================

// Run Conditionally
// =============================================================================

if ( ! current_user_can( 'manage_options' ) ) {
  wp_die( __( 'You do not have sufficient permissions to access this page.', '__tco__') );
}



// Generate Tabs
// =============================================================================

$tabs = $this->config['admin_tabs'];

foreach ( $this->email_providers as $provider ) {

  $name        = $provider->get_name();
  $tabs[$name] = array(
    'title' => $provider->get_title(),
    'view'  => 'admin/tab-settings'
  );

}

foreach ( $tabs as $name => $tab ) {
  $tabs[$name]['url'] = add_query_arg( array( 'tab' => $name ), $this->get_transport( 'plugin_admin_url' ) );
}

$current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : $this->config['default_tab'];

$this->set_transport( 'tabs', $tabs );
$this->set_transport( 'current_tab', $current_tab );
$this->set_transport( 'selected_tab_view', $tabs[$current_tab]['view'] );



// Set Active Provider
// =============================================================================

//
// False if not a provider tab.
//

$provider = $this->resolve_provider( $current_tab );



// Save Options
// =============================================================================

if ( isset( $_POST[ $this->slug . '_form_submitted' ] ) && strtolower( $_POST[ $this->slug . '_form_submitted' ] ) == 'submitted' && current_user_can('manage_options') && isset($_POST['tco_email_forms_noncename']) && wp_verify_nonce( $_POST['tco_email_forms_noncename'], 'tco_email_forms' ) ) {

  $this->options->validate_form();

  if ( $provider ) {
    $provider->before_save();
  }

  $this->options->save();

}



// Prepare Additional Data For View
// =============================================================================

$about_items = array();
$meta_boxes  = array();
$this->build_master_list();



// Tab Setup: Email Forms
// =============================================================================

if ( $current_tab == 'forms' ) {

  require_once( $this->path . '/functions/admin/email-forms-list-table.php' );

  $email_forms_table = new X_Opt_In_Forms_List_Table( $this->config['email_forms_list_table'] );
  $email_forms_table->prepare_items();

  $this->set_transport( 'email_forms_table', $email_forms_table );

}



// Tab Setup: General Settings
// =============================================================================

if ( $current_tab == 'general' ) {

  foreach ( $this->config['settings_metaboxes'] as $key => $item ) {
    $meta_boxes[$key]['title']   = $item['title'];
    $meta_boxes[$key]['content'] = $this->view->make( $item['view'] );
  }

  $about_items = array_merge( $about_items, $this->config['about_items'] );

}



// Tab Setup: Specific Providers
// =============================================================================

if ( $provider ) {

  $provider->settings_page();

  $meta_boxes  = array_merge( $meta_boxes, $provider->get_metaboxes() );
  $about_items = array_merge( $about_items, $provider->get_about_items() );

}



// Load View
// =============================================================================

$this->set_transport( 'about_items', $about_items );
$this->set_transport( 'meta_boxes', $meta_boxes );
$this->view->show( 'admin/options-page' );