Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( !defined( 'ABSPATH' ) ) {
- exit;
- }
- function my_whatsapp_assets() {
- $current_screen = get_current_screen();
- if ( !is_object($current_screen) || 'my_page_my_whatsapp' !== $current_screen->base ) return;
- if ( wp_doing_ajax() ) return;
- wp_enqueue_script( 'jquery-mask', MY_URI . 'assets/js/jquery.mask.min.js', array( 'wp-color-picker' ), my_VERSION );
- }
- add_action( 'admin_enqueue_scripts', 'my_whatsapp_assets' );
- function my_view_whatsapp() {
- if(isset($_POST['submit']) && !wp_verify_nonce($_POST['my_agency_whatsapp_form'], 'my_agency')) {
- echo '<div class="notice notice-error"><p>Falha na verificação!</p></div>';
- exit;
- }
- // Save form submition
- if (isset($_POST['submit'])) {
- update_option( 'my_whatsapp_enable', sanitize_text_field($_POST['my_whatsapp_enable']) );
- update_option( 'my_whatsapp_phone', sanitize_text_field($_POST['my_whatsapp_phone']) );
- update_option( 'my_whatsapp_text', sanitize_text_field($_POST['my_whatsapp_text']) );
- update_option( 'my_whatsapp_message', sanitize_text_field($_POST['my_whatsapp_message']) );
- echo '<div class="notice notice-success is-dismissible"><p>As configurações foram salvas com sucesso!</p></div>';
- }
- ?>
- <form method="POST">
- <?php wp_nonce_field( 'my_agency', 'my_agency_whatsapp_form' ); ?>
- <table class="form-table" role="presentation">
- <tbody>
- <!-- Ativar módulo -->
- <tr>
- <th scope="row"><label>Ativar o módulo Whatsapp</label></th>
- <td>
- <input name="my_whatsapp_enable" type="checkbox" value="1" <?php if (get_option('my_whatsapp_enable') == true) echo "checked"; ?> />
- <p class="description">Marque essa opção para ativar o módulo whatsapp.</p>
- </td>
- </tr>
- <!-- Número do telefone -->
- <tr>
- <th scope="row"><label>Número do telefone</label></th>
- <td>
- <input
- type="text"
- class="regular-text my_mask_phone"
- name="my_whatsapp_phone"
- value="<?php echo get_option('my_whatsapp_phone'); ?>"
- placeholder="(48) 9.9988-7766"
- />
- </td>
- </tr>
- <!-- Texto do botão -->
- <tr>
- <th scope="row"><label>Texto do botão</label></th>
- <td>
- <input
- type="text"
- class="regular-text"
- name="my_whatsapp_text"
- value="<?php echo get_option('my_whatsapp_text'); ?>"
- placeholder="Precisa de ajuda?"
- />
- </td>
- </tr>
- <!-- Mensagem -->
- <tr>
- <th scope="row"><label>Mensagem</label></th>
- <td>
- <textarea name="my_whatsapp_message" class="regular-text" maxlength="180" rows="4" placeholder="Olá, estou entrando em contato através do site"><?php echo get_option('my_whatsapp_message'); ?></textarea>
- </td>
- </tr>
- </tbody>
- </table>
- <p class="submit">
- <input type="submit" name="submit" id="submit" class="button button-primary" value="Salvar alterações">
- </p>
- </form>
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement