Skip to content

Commit

Permalink
Add support for submit attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
mihdan committed Jul 20, 2020
1 parent 3ce1570 commit 1e5d325
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
6 changes: 4 additions & 2 deletions examples/wposa-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
* Description: Settings API wrapper built with Object Oriented Programming practices.
* Author: mrahmadawais, WPTie, deviodigital
* Author URI: http://AhmadAwais.com/
* Version: 1.0.0
* Version: 1.0.4
* License: GPL2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*
* @package WPOSA
*/

namespace Mihdan\WPOSA;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
Expand All @@ -24,7 +26,7 @@
*/
// Plugin version.
if ( ! defined( 'WPOSA_VERSION' ) ) {
define( 'WPOSA_VERSION', '1.0.0' );
define( 'WPOSA_VERSION', '1.0.4' );
}

if ( ! defined( 'WPOSA_NAME' ) ) {
Expand Down
17 changes: 13 additions & 4 deletions src/WPOSA.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,24 +780,33 @@ function show_navigation() {
* This function displays every sections in a different form
*/
function show_forms() {
$default = array(
'label_submit' => null,
'submit_type' => 'primary',
'wrap' => true,
'attributes' => null,
);
?>
<div class="metabox-holder">
<?php foreach ( $this->sections_array as $form ) { ?>
<?php foreach ( $this->sections_array as $form ) : ?>
<?php
$form = wp_parse_args( $form, $default );
?>
<!-- style="display: none;" -->
<div id="<?php echo $form['id']; ?>" class="group" >
<form method="post" action="options.php">
<form method="post" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>">
<?php
do_action( 'wsa_form_top_' . $form['id'], $form );
settings_fields( $form['id'] );
do_settings_sections( $form['id'] );
do_action( 'wsa_form_bottom_' . $form['id'], $form );
?>
<div style="padding-left: 10px">
<?php submit_button(null, 'primary', 'submit_'.$form['id']); ?>
<?php submit_button( $form['label_submit'], $form['submit_type'], 'submit_' . $form['id'], $form['wrap'], $form['attributes'] ); ?>
</div>
</form>
</div>
<?php } ?>
<?php endforeach; ?>
</div>
<?php
$this->script();
Expand Down

0 comments on commit 1e5d325

Please sign in to comment.