Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-kachurin committed Sep 14, 2018
2 parents a919a62 + 2f7e832 commit ea1a79b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
59 changes: 35 additions & 24 deletions includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,26 @@ function ( $args ) {
*/
public function bu_liaison_inquiry_options_page() {
add_options_page(
'Liaison API Keys',
'Liaison API Keys',
'Liaison Forms',
'Liaison Forms',
'manage_categories',
'bu_liaison_inquiry',
array( $this, 'bu_liaison_inquiry_options_page_html' )
);
}

/**
* Check if the current user can edit settings.
*
* @return boolean
*/
public function check_edit_capability() {
$required_capabilty = apply_filters(
'option_page_capability_bu_liaison_inquiry', 'manage_options'
);
return current_user_can( $required_capabilty );
}

/**
* Outputs the form on the admin page using the defined actions.
*/
Expand All @@ -184,37 +196,36 @@ public function bu_liaison_inquiry_options_page_html() {
return;
}

// Add status messages.
// WordPress will add the "settings-updated" $_GET parameter to the url.
if ( isset( $_GET['settings-updated'] ) ) {
// Add settings saved message with the class of "updated".
add_settings_error( 'bu_liaison_inquiry_messages', 'bu_liaison_inquiry_message', __( 'Settings Saved', 'bu_liaison_inquiry' ), 'updated' );
}

// Show status messages.
settings_errors( 'bu_liaison_inquiry_messages' );
?>
<div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<form action="options.php" method="post">
<?php
// Output security fields for the registered setting.
settings_fields( 'bu_liaison_inquiry' );
// Output setting sections and their fields.
// (sections are registered for "bu_liaison_inquiry", each field is registered to a specific section).
do_settings_sections( 'bu_liaison_inquiry' );
// Output save settings button.
submit_button( 'Save Settings' );
?>
</form>
</div>
<div class="wrap">
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<?php if ( $this->check_edit_capability() ) : ?>
<form action="options.php" method="post">
<?php
// Output security fields for the registered setting.
settings_fields( 'bu_liaison_inquiry' );
// Output setting sections and their fields.
// (sections are registered for "bu_liaison_inquiry", each field is registered to a specific section).
do_settings_sections( 'bu_liaison_inquiry' );
// Output save settings button.
submit_button( 'Save Settings' );
?>
</form>
<hr>
<?php else : ?>
<div class="notice notice-info">
<p><?php echo esc_html( 'To change settings, please contact Administrator.', 'bu_liaison_inquiry' ); ?></p>
</div>
<?php endif; ?>
</div>
<?php
// If there is already a key set, use it to fetch and display a field inventory.
$options = get_option( 'bu_liaison_inquiry_options' );
if ( ! empty( $options['APIKey'] ) ) {
$api = new Spectrum_API( null, $options['APIKey'] );
?>
<hr>
<h2>Select Liaison Form</h2>
<p>Select a form below to see the list of field IDs that it contains. </p>
<?php
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Inquiry form for Liaison Inc.'s SpectrumEMP enrollment CRM
This WordPress plugin provides an inquiry form for prospective students. It uses the SpectrumEMP API to get the form parameters from Liaison, and submit the form data back to Liaison. It is based on example code from `https://github.com/Liaison-Intl/EMP_API-Example`
## Basic Usage
### Admin
The plugin provides an option page in the WordPress admin, under the main `Settings` menu called `Liaison API Keys`. Enter the API Key and Client ID provided by Liaison for the relevant account here.
The plugin provides an option page in the WordPress admin, under the main `Settings` menu called `Liaison Forms`. Enter the API Key and Client ID provided by Liaison for the relevant account here.
### Inquiry Form shortcode
Once the API Key and Client ID have been set, the inquiry form can be placed anywhere in the site by using the following shortcode:

Expand Down

0 comments on commit ea1a79b

Please sign in to comment.