| @@ -8,30 +8,62 @@ | ||
| 8 | 8 | |
| 9 | 9 | public static function init(): void { |
| 10 | 10 | self::send(); |
| 11 | 11 | |
| 12 | + $options = get_option( '_wp_coder_tools', [] ); | |
| 13 | + | |
| 14 | + $tools = [ | |
| 15 | + 'integrations' => __( 'Integrations', 'wpcoderpro' ), | |
| 16 | + 'content' => __( 'Content & Templates', 'wpcoderpro' ), | |
| 17 | + 'developer' => __( 'Developer', 'wpcoderpro' ), | |
| 18 | + ]; | |
| 19 | + | |
| 12 | 20 | ?> |
| 13 | - <div class="wrap wowp-wrap wpcoder-tools-wrap wowp-settings"> | |
| 21 | + | |
| 22 | + <div class="wowp-settings wowp-tools"> | |
| 14 | 23 | <form method="post"> |
| 15 | - <fieldset style="display: block;"> | |
| 16 | - <legend> | |
| 17 | - <?php esc_html_e( 'Tools', 'wpcoder' ); ?> | |
| 18 | - </legend> | |
| 19 | - <div class="tab-content-wrapper wowp-tab-content"> | |
| 20 | - <?php require_once plugin_dir_path( __FILE__ ) . '/page.php'; ?> | |
| 21 | - </div> | |
| 22 | - <div class="wowp-field is-full has-mt"> | |
| 23 | - <?php | |
| 24 | - submit_button( __( 'Save', 'wpcoder' ), 'primary large', 'submit', false ); ?> | |
| 25 | - </div> | |
| 26 | 24 | |
| 25 | + <div class="wowp-snippets__header"> | |
| 26 | + <h3 class="wowp-snippets__header-title">Tools & Integrations</h3> | |
| 27 | + <p class="wowp-snippets__header-description">Manage useful features and external service | |
| 28 | + integrations to enhance your site.</p> | |
| 29 | + </div> | |
| 30 | + | |
| 31 | + <div class="wowp-snippets__tabs" id="wowp-snippets-tabs"> | |
| 27 | 32 | <?php |
| 28 | - wp_nonce_field( WPCoder::PREFIX . '_tools_action', WPCoder::PREFIX . '_save_tools' ); ?> | |
| 29 | - </fieldset> | |
| 33 | + foreach ( $tools as $key => $value ) { | |
| 34 | + $tab = ! empty( $options['tool_tab'] ) ? $options['tool_tab'] : 'integrations'; | |
| 35 | + echo '<input type="radio" class="wowp-snippets__tabs-radio" name="wp_coder_tool[tool_tab]" value="' . esc_attr( $key ) . '" id="wowp-tab-' . esc_attr( $key ) . '" ' . checked( $tab, | |
| 36 | + $key, false ) . '>'; | |
| 37 | + } | |
| 38 | + echo '<div class="wowp-snippets__tabs-labels">'; | |
| 39 | + foreach ( $tools as $key => $value ) { | |
| 40 | + echo '<label class="wowp-snippets__tabs-tab" for="wowp-tab-' . esc_attr( $key ) . '"><span class="icon icon-' . esc_attr( $key ) . '"></span>' . esc_html( $value ) . '</label>'; | |
| 41 | + } | |
| 42 | + echo '</div>'; | |
| 43 | + foreach ( $tools as $key => $value ) { | |
| 44 | + echo '<div class="wowp-snippets__tabs-content" data-content="wowp-tab-' . esc_attr( $key ) . '">'; | |
| 45 | + require_once plugin_dir_path( __FILE__ ) . 'pages/' . esc_attr( $key ) . '.php'; | |
| 46 | + echo '<input type="submit" name="submit" class="wowp-button button button-dark button-hero" value="' . esc_attr__( 'Save', | |
| 47 | + 'wpcoderpro' ) . '">'; | |
| 48 | + echo '</div>'; | |
| 49 | + } | |
| 50 | + | |
| 51 | + ?> | |
| 52 | + </div> | |
| 53 | + | |
| 54 | + <?php | |
| 55 | + // require_once plugin_dir_path( __FILE__ ) . '/page.php'; ?> | |
| 56 | + | |
| 57 | + <?php | |
| 58 | + // submit_button( __( 'Save', 'wpcoderpro' ), 'wowp-button button button-dark button-hero', 'submit', false ); ?> | |
| 59 | + | |
| 60 | + <?php | |
| 61 | + wp_nonce_field( WPCoder::PREFIX . '_tools_action', WPCoder::PREFIX . '_save_tools' ); ?> | |
| 62 | + | |
| 30 | 63 | </form> |
| 31 | 64 | </div> |
| 32 | 65 | <?php |
| 33 | - | |
| 34 | 66 | } |
| 35 | 67 | |
| 36 | 68 | private static function option( $name = '', $def = '' ) { |
| 37 | 69 | $options = get_option( '_wp_coder_tools', [] ); |
| @@ -50,9 +82,9 @@ | ||
| 50 | 82 | private static function field( $type = 'checkbox', $name = '', $def = '', $placeholder = '' ) { |
| 51 | 83 | $options = get_option( '_wp_coder_tools', [] ); |
| 52 | 84 | if ( $type === 'checkbox' ) { |
| 53 | 85 | $checked = array_key_exists( $name, $options ) ? 'checked' : ''; |
| 54 | - echo '<input type="checkbox" name="wp_coder_tool[' . esc_attr( $name ) . ']" ' . esc_attr( $checked ) . ' value="1">'; | |
| 86 | + echo '<input type="checkbox" name="wp_coder_tool[' . esc_attr( $name ) . ']" ' . esc_attr( $checked ) . ' value="1" id="' . esc_attr( $name ) . '">'; | |
| 55 | 87 | } elseif ( $type === 'textarea' ) { |
| 56 | 88 | $value = ! empty( $options[ $name ] ) ? $options[ $name ] : $def; |
| 57 | 89 | echo '<textarea name="wp_coder_tool[' . esc_attr( $name ) . ']" placeholder="' . esc_attr( $placeholder ) . '">' . esc_attr( $value ) . '</textarea>'; |
| 58 | 90 | } else { |