diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..2ae70ee --- /dev/null +++ b/.babelrc @@ -0,0 +1,24 @@ +{ + "presets": [ + [ + "env", + { + "modules": false + } + ] + ], + "plugins": [ + "transform-object-rest-spread", + [ + "transform-react-jsx", + { + "pragma": "wp.element.createElement" + } + ] + ], + "env": { + "default": { + "plugins": ["transform-runtime"] + } + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3c52875..85eeb0f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ vendor composer.lock bin/ package-lock.json +themeisle-hash.json diff --git a/.travis.yml b/.travis.yml index 00b710e..29a54a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,12 @@ matrix: - php: "5.6" install: true before_script: chmod +x bin/wraith.sh - env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=2 + env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=3 script: ./bin/wraith.sh - php: '5.3' dist: precise + allow_failures: + - env: TEST_SUITE=Wraith_Visual_Regression_Testing WRAITH_FAIL=3 branches: except: - "/^*-v[0-9]/" diff --git a/CHANGELOG.md b/CHANGELOG.md index 636bf05..e8e99fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,62 @@ + ### v2.4.1 - 2018-05-07 + **Changes:** + * GDPR compliance + + ### v2.4.0 - 2018-04-02 + **Changes:** + * Improves compatibility with various themes. +* Adds support for two new custom fields. +* Adds filter for custom classes into form fields. +* Adds visual/text switch to form wyiwyg editor. + + ### v2.3.5 - 2018-03-05 + **Changes:** + * Fix characters encoding issue in the subject field. +* Fix issue with spam label with two forms on the page. +* Allows zip files to be attached in forms. +* Adds a filter to dynamically change the subject. +* Adds options to send a copy of the email to the sender. + + ### v2.3.4 - 2018-02-15 + **Changes:** + * Added missing Loader.gif file +* Fixed undefined notice +* Fix submit button leaving form when ReCaptcha is enabled + + ### v2.3.3 - 2018-01-06 + **Changes:** + * Fix double reCAPTCHA box bug. +* Fix custom spam trap alignement error. + + ### v2.3.2 - 2017-12-28 + **Changes:** + * Fix for tooltip admin behavior. + + ### v2.3.1 - 2017-12-28 + **Changes:** + * Improves layout and compatibility with various themes. +* Improves form default email format. +* Fix issues with various special characters in the magic tag fields. + + ### v2.3.0 - 2017-11-27 + **Changes:** + * Adds email content wysiwyg editor. +* Improves layout for custom spam trap. + + ### v2.2.5 - 2017-11-16 + **Changes:** + * Adds compatibility with WordPress 4.9 +* Minor improvement for toggle the password in the admin form fields. + + ### v2.2.4 - 2017-11-13 + **Changes:** + * Improved assets loading, loading them only they are necessary. +* Remove hide/show effect for reCaptcha. +* Add toggle for password field. +* Add new docs, keeping them in sync with HelpScout . +* Adds more integration with the pro version. + ### v2.2.3 - 2017-10-24 **Changes:** * Improves compatibility with Hestia theme. diff --git a/Gruntfile.js b/Gruntfile.js index 5a4baea..4a7af3a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,5 +8,8 @@ module.exports = function (grunt) { config = config(); config.files.php.push( '!inc/PhpFormBuilder.php' ); config.files.php.push( '!mailin.php' ); + config.files.js.push( '!gutenberg/**/*.js' ); + config.files.js.push( '!webpack.config.js' ); + config.taskMap.faq_builder = 'grunt-helpscout-faq'; loader( grunt, config ).init(); }; \ No newline at end of file diff --git a/admin/class-pirateforms-admin.php b/admin/class-pirateforms-admin.php index a983e88..5f93ab3 100644 --- a/admin/class-pirateforms-admin.php +++ b/admin/class-pirateforms-admin.php @@ -61,25 +61,28 @@ public function __construct( $plugin_name, $version ) { * @since 1.0.0 */ public function enqueue_styles_and_scripts() { - global $pagenow; + $current_screen = get_current_screen(); - if ( ! empty( $pagenow ) && ( $pagenow == 'options-general.php' || $pagenow == 'admin.php' ) - && isset( $_GET['page'] ) && $_GET['page'] == 'pirateforms-admin' - ) { + if ( ! isset( $current_screen->id ) ) { + return; + } + + if ( in_array( $current_screen->id, array( 'edit-pf_contact', 'edit-pf_form', 'pf_form', 'toplevel_page_pirateforms-admin' ) ) ) { wp_enqueue_style( 'pirateforms_admin_styles', PIRATEFORMS_URL . 'admin/css/wp-admin.css', array(), $this->version ); - wp_enqueue_script( 'pirateforms_scripts_admin', PIRATEFORMS_URL . 'admin/js/scripts-admin.js', array( 'jquery' ), $this->version ); + wp_enqueue_script( 'pirateforms_scripts_admin', PIRATEFORMS_URL . 'admin/js/scripts-admin.js', array( 'jquery', 'jquery-ui-tooltip' ), $this->version ); wp_localize_script( 'pirateforms_scripts_admin', 'cwp_top_ajaxload', array( - 'ajaxurl' => admin_url( 'admin-ajax.php' ), - 'nonce' => wp_create_nonce( PIRATEFORMS_SLUG ), - 'i10n' => array( + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + 'nonce' => wp_create_nonce( PIRATEFORMS_SLUG ), + 'slug' => PIRATEFORMS_SLUG, + 'i10n' => array( 'recaptcha' => __( 'Please specify the Site Key and Secret Key.', 'pirate-forms' ), ), ) ); } - if ( isset( $_GET['page'] ) && $_GET['page'] == 'pf_more_features' ) { + if ( isset( $_GET['page'] ) && $_GET['page'] == 'pf_more_features' ) { wp_enqueue_style( 'pirateforms_upsell_styles', PIRATEFORMS_URL . 'admin/css/upsell.css', array(), $this->version ); } } @@ -177,10 +180,51 @@ public function render_upsell() { function settings() { global $current_user; $pirate_forms_options = PirateForms_Util::get_option(); - $plugin_options = $this->pirate_forms_plugin_options(); + $plugin_options = $this->get_plugin_options(); include_once PIRATEFORMS_DIR . 'admin/partials/pirateforms-settings-display.php'; } + /** + * Get any options that might be configured through the theme. + */ + function get_theme_options() { + $recaptcha_show = ''; + $button_label = __( 'Send Message', 'pirate-forms' ); + $email = get_bloginfo( 'admin_email' ); + + $theme = strtolower( wp_get_theme()->__get( 'name' ) ); + + // Default values from Zerif Lite. + if ( strpos( $theme, 'zerif' ) === 0 ) { + $zerif_contactus_recaptcha_show = get_theme_mod( 'zerif_contactus_recaptcha_show' ); + if ( isset( $zerif_contactus_recaptcha_show ) && ( $zerif_contactus_recaptcha_show == '1' ) ) { + $recaptcha_show = ''; + } else { + $recaptcha_show = 'custom'; + } + + $zerif_contactus_button_label = get_theme_mod( 'zerif_contactus_button_label', __( 'Send Message', 'pirate-forms' ) ); + if ( ! empty( $zerif_contactus_button_label ) ) { + $button_label = $zerif_contactus_button_label; + } + + $zerif_contactus_email = get_theme_mod( 'zerif_contactus_email' ); + $zerif_email = get_theme_mod( 'zerif_email' ); + if ( ! empty( $zerif_contactus_email ) ) { + $email = $zerif_contactus_email; + } elseif ( ! empty( $zerif_email ) ) { + $email = $zerif_email; + } + } + + return array( + $recaptcha_show, + $button_label, + $email, + ); + } + + /** * * OPTIONS @@ -188,63 +232,32 @@ function settings() { * @since 1.0.0 * name; id; desc; type; default; options */ - function pirate_forms_plugin_options() { - /** - ********** Default values from Zerif Lite */ - $zerif_contactus_sitekey = get_theme_mod( 'zerif_contactus_sitekey' ); - if ( ! empty( $zerif_contactus_sitekey ) ) : - $pirate_forms_contactus_sitekey = $zerif_contactus_sitekey; - else : - $pirate_forms_contactus_sitekey = ''; - endif; - $zerif_contactus_secretkey = get_theme_mod( 'zerif_contactus_secretkey' ); - if ( ! empty( $zerif_contactus_secretkey ) ) : - $pirate_forms_contactus_secretkey = $zerif_contactus_secretkey; - else : - $pirate_forms_contactus_secretkey = ''; - endif; - $zerif_contactus_recaptcha_show = get_theme_mod( 'zerif_contactus_recaptcha_show' ); - if ( isset( $zerif_contactus_recaptcha_show ) && ( $zerif_contactus_recaptcha_show == '1' ) ) : - $pirate_forms_contactus_recaptcha_show = ''; - else : - $pirate_forms_contactus_recaptcha_show = 'yes'; - endif; - $zerif_contactus_button_label = get_theme_mod( 'zerif_contactus_button_label', __( 'Send Message', 'pirate-forms' ) ); - if ( ! empty( $zerif_contactus_button_label ) ) : - $pirate_forms_contactus_button_label = $zerif_contactus_button_label; - else : - $pirate_forms_contactus_button_label = __( 'Send Message', 'pirate-forms' ); - endif; - $zerif_contactus_email = get_theme_mod( 'zerif_contactus_email' ); - $zerif_email = get_theme_mod( 'zerif_email' ); - $pirate_forms_contactus_email = ''; - if ( ! empty( $zerif_contactus_email ) ) : - $pirate_forms_contactus_email = $zerif_contactus_email; - elseif ( ! empty( $zerif_email ) ) : - $pirate_forms_contactus_email = $zerif_email; - else : - $pirate_forms_contactus_email = get_bloginfo( 'admin_email' ); - endif; + function get_plugin_options() { + list( + $pirate_forms_contactus_recaptcha_show, + $pirate_forms_contactus_button_label, + $pirate_forms_contactus_email + ) = $this->get_theme_options(); // check if akismet is installed $akismet_status = false; if ( is_plugin_active( 'akismet/akismet.php' ) ) { - $akismet_key = get_option( 'wordpress_api_key' ); + $akismet_key = get_option( 'wordpress_api_key' ); if ( ! empty( $akismet_key ) ) { $akismet_status = true; } } - $akismet_msg = ''; + $akismet_msg = ''; if ( ! $akismet_status ) { - $akismet_msg = __( 'To use this option, please ensure Akismet is activated with a valid key.', 'pirate-forms' ); + $akismet_msg = __( 'To use this option, please ensure Akismet is activated with a valid key.', 'pirate-forms' ); } // the key(s) will be added to the div as class names - // to enable tooltip popup add 'pirate_dashicons' + // to enable tooltip popup add 'pirate_tooltip' return apply_filters( 'pirate_forms_admin_controls', array( - 'pirate_options pirate_dashicons' => array( + 'pirate_options pirate_tooltip' => array( 'heading' => __( 'Form processing options', 'pirate-forms' ), 'controls' => apply_filters( 'pirate_forms_admin_controls_for_options', array( @@ -293,23 +306,24 @@ function pirate_forms_plugin_options() { 'value' => __( 'Store submissions in the database', 'pirate-forms' ), 'html' => '', 'desc' => array( - 'value' => __( 'Should the submissions be stored in the admin area? If chosen, contact form submissions will be saved under "All Entries" on the left (appears after this option is activated).', 'pirate-forms' ), + 'value' => sprintf( '%s
%s', __( 'Should the submissions be stored in the admin area? If chosen, contact form submissions will be saved under "All Entries" on the left (appears after this option is activated).', 'pirate-forms' ), __( 'According to GDPR we recommend you to ask for consent in order to store user data', 'pirate-forms' ) ), 'class' => 'pirate_forms_option_description', ), ), - 'default' => 'yes', + 'default' => 'no', 'value' => PirateForms_Util::get_option( 'pirateformsopt_store' ), 'wrap' => array( 'type' => 'div', 'class' => 'pirate-forms-grouped', ), 'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ), + 'title' => __( 'According to GDPR, we recommend you to ask for consent in order to store user data.', 'pirate-forms' ), ), array( 'id' => 'pirateformsopt_nonce', 'type' => 'checkbox', 'label' => array( - 'value' => __( 'Add a nonce to the contact form:', 'pirate-forms' ), + 'value' => __( 'Add a nonce to the contact form', 'pirate-forms' ), 'html' => '', 'desc' => array( 'value' => __( 'Should the form use a WordPress nonce? This helps reduce spam by ensuring that the form submittor is on the site when submitting the form rather than submitting remotely. This could, however, cause problems with sites using a page caching plugin. Turn this off if you are getting complaints about forms not being able to be submitted with an error of "Nonce failed!"', 'pirate-forms' ), @@ -343,6 +357,25 @@ function pirate_forms_plugin_options() { 'cols' => 70, 'rows' => 5, ), + array( + 'id' => 'pirateformsopt_copy_email', + 'type' => 'checkbox', + 'label' => array( + 'value' => __( 'Add copy of mail to confirmation email', 'pirate-forms' ), + 'html' => '', + 'desc' => array( + 'value' => __( 'Should a copy of the email be appended to the confirmation email? Only the fields that are being displayed will be sent to the sender. Please note that this will only be appended if confirmation email text is provided above.', 'pirate-forms' ), + 'class' => 'pirate_forms_option_description', + ), + ), + 'default' => '', + 'value' => PirateForms_Util::get_option( 'pirateformsopt_copy_email' ), + 'wrap' => array( + 'type' => 'div', + 'class' => 'pirate-forms-grouped', + ), + 'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ) ), + ), array( 'id' => 'pirateformsopt_thank_you_url', 'type' => 'select', @@ -362,9 +395,9 @@ function pirate_forms_plugin_options() { 'options' => PirateForms_Util::get_thank_you_pages(), ), array( - 'id' => 'pirateformsopt_akismet', - 'type' => 'checkbox', - 'label' => array( + 'id' => 'pirateformsopt_akismet', + 'type' => 'checkbox', + 'label' => array( 'value' => __( 'Integrate with Akismet?', 'pirate-forms' ), 'html' => '', 'desc' => array( @@ -372,12 +405,12 @@ function pirate_forms_plugin_options() { 'class' => 'pirate_forms_option_description', ), ), - 'value' => PirateForms_Util::get_option( 'pirateformsopt_akismet' ), - 'wrap' => array( + 'value' => PirateForms_Util::get_option( 'pirateformsopt_akismet' ), + 'wrap' => array( 'type' => 'div', 'class' => 'pirate-forms-grouped', ), - 'options' => array( + 'options' => array( 'yes' => __( 'Yes', 'pirate-forms' ), ), 'disabled' => ! empty( $akismet_msg ), @@ -385,7 +418,7 @@ function pirate_forms_plugin_options() { ) ), ), - 'pirate_fields pirate_dashicons' => array( + 'pirate_fields pirate_tooltip' => array( 'heading' => __( 'Fields Settings', 'pirate-forms' ), 'controls' => apply_filters( 'pirate_forms_admin_controls_for_fields', array( @@ -483,6 +516,23 @@ function pirate_forms_plugin_options() { 'req' => __( 'Required', 'pirate-forms' ), ), ), + array( + 'id' => 'pirateformsopt_checkbox_field', + 'type' => 'select', + 'label' => array( + 'value' => __( 'Checkbox', 'pirate-forms' ), + ), + 'value' => PirateForms_Util::get_option( 'pirateformsopt_checkbox_field' ), + 'wrap' => array( + 'type' => 'div', + 'class' => 'pirate-forms-grouped pirateformsopt_checkbox', + ), + 'options' => array( + '' => __( 'Do not display', 'pirate-forms' ), + 'yes' => __( 'Display but not required', 'pirate-forms' ), + 'req' => __( 'Required', 'pirate-forms' ), + ), + ), /* Recaptcha */ array( 'id' => 'pirateformsopt_recaptcha_field', @@ -497,9 +547,9 @@ function pirate_forms_plugin_options() { 'class' => 'pirate-forms-grouped', ), 'options' => array( - '' => __( 'No', 'pirate-forms' ), + '' => __( 'No', 'pirate-forms' ), 'custom' => __( 'Custom', 'pirate-forms' ), - 'yes' => __( 'Google reCAPTCHA', 'pirate-forms' ), + 'yes' => __( 'Google reCAPTCHA', 'pirate-forms' ), ), ), /* Site key */ @@ -514,7 +564,6 @@ function pirate_forms_plugin_options() { 'class' => 'pirate_forms_option_description', ), ), - 'default' => $pirate_forms_contactus_sitekey, 'value' => PirateForms_Util::get_option( 'pirateformsopt_recaptcha_sitekey' ), 'wrap' => array( 'type' => 'div', @@ -528,17 +577,16 @@ function pirate_forms_plugin_options() { 'label' => array( 'value' => __( 'Secret key', 'pirate-forms' ), ), - 'default' => $pirate_forms_contactus_secretkey, 'value' => PirateForms_Util::get_option( 'pirateformsopt_recaptcha_secretkey' ), 'wrap' => array( 'type' => 'div', - 'class' => 'pirate-forms-grouped pirateformsopt_recaptcha', + 'class' => 'pirate-forms-grouped pirateformsopt_recaptcha pirate-forms-password-toggle', ), ), ) ), ), - 'pirate_labels' => array( + 'pirate_labels pirate_tooltip' => array( 'heading' => __( 'Fields Labels', 'pirate-forms' ), 'controls' => apply_filters( 'pirate_forms_admin_controls_for_field_labels', array( @@ -607,10 +655,46 @@ function pirate_forms_plugin_options() { 'class' => 'pirate-forms-grouped', ), ), + array( + 'id' => 'pirateformsopt_label_checkbox', + 'type' => 'wysiwyg', + 'label' => array( + 'value' => __( 'Checkbox', 'pirate-forms' ), + ), + 'value' => PirateForms_Util::get_option( 'pirateformsopt_label_checkbox' ), + 'wrap' => array( + 'type' => 'div', + 'class' => 'pirate-forms-grouped', + ), + 'wysiwyg' => array( + 'editor_class' => 'pirate-forms-wysiwyg', + 'quicktags' => false, + 'teeny' => true, + 'media_buttons' => false, + ), + ), + array( + 'id' => 'pirateformsopt_email_content', + 'type' => 'wysiwyg', + 'label' => array( + 'value' => __( 'Email content', 'pirate-forms' ), + 'html' => '

' . esc_attr( __( 'You can use the next magic tags:', 'pirate-forms' ) ) . '
' . PirateForms_Util::get_magic_tags(), + ), + 'default' => PirateForms_Util::get_default_email_content( true, null, true ), + 'value' => PirateForms_Util::get_option( 'pirateformsopt_email_content' ), + 'wrap' => array( + 'type' => 'div', + 'class' => 'pirate-forms-grouped', + ), + 'wysiwyg' => array( + 'editor_class' => 'pirate-forms-wysiwyg', + 'editor_height' => 500, + ), + ), ) ), ), - 'pirate_alerts pirate_dashicons' => array( + 'pirate_alerts pirate_tooltip' => array( 'heading' => __( 'Alert Messages', 'pirate-forms' ), 'controls' => apply_filters( 'pirate_forms_admin_controls_for_alerts', array( @@ -679,6 +763,19 @@ function pirate_forms_plugin_options() { 'class' => 'pirate-forms-grouped', ), ), + array( + 'id' => 'pirateformsopt_label_err_no_checkbox', + 'type' => 'text', + 'label' => array( + 'value' => __( 'Checkbox is not checked', 'pirate-forms' ), + ), + 'default' => __( 'Please select the checkbox', 'pirate-forms' ), + 'value' => PirateForms_Util::get_option( 'pirateformsopt_label_err_no_checkbox' ), + 'wrap' => array( + 'type' => 'div', + 'class' => 'pirate-forms-grouped', + ), + ), array( 'id' => 'pirateformsopt_label_submit', 'type' => 'text', @@ -700,7 +797,7 @@ function pirate_forms_plugin_options() { ) ), ), - 'pirate_smtp pirate_dashicons' => array( + 'pirate_smtp pirate_tooltip' => array( 'heading' => __( 'SMTP Options', 'pirate-forms' ), 'controls' => apply_filters( 'pirate_forms_admin_controls_for_smtp', array( @@ -808,7 +905,7 @@ function pirate_forms_plugin_options() { 'value' => PirateForms_Util::get_option( 'pirateformsopt_smtp_password' ), 'wrap' => array( 'type' => 'div', - 'class' => 'pirate-forms-grouped', + 'class' => 'pirate-forms-grouped pirate-forms-password-toggle', ), ), ) @@ -823,7 +920,7 @@ function pirate_forms_plugin_options() { public function settings_init() { if ( ! PirateForms_Util::get_option() ) { $new_opt = array(); - foreach ( $this->pirate_forms_plugin_options() as $tab => $array ) { + foreach ( $this->get_plugin_options() as $tab => $array ) { foreach ( $array['controls'] as $controls ) { $new_opt[ $controls['id'] ] = isset( $controls['default'] ) ? $controls['default'] : ''; } @@ -881,7 +978,7 @@ public function save_callback() { if ( isset( $params['pirateformsopt_email_recipients'] ) ) : $pirate_forms_zerif_lite_mods['zerif_contactus_email'] = $params['pirateformsopt_email_recipients']; endif; - if ( isset( $params['pirateformsopt_recaptcha_field'] ) && ( $params['pirateformsopt_recaptcha_field'] == 'yes' ) ) : + if ( isset( $params['pirateformsopt_recaptcha_field'] ) && ( $params['pirateformsopt_recaptcha_field'] == 'custom' ) ) : $pirate_forms_zerif_lite_mods['zerif_contactus_recaptcha_show'] = 0; else : $pirate_forms_zerif_lite_mods['zerif_contactus_recaptcha_show'] = 1; @@ -937,12 +1034,12 @@ public function manage_contact_posts_columns( $columns ) { public function manage_contact_posts_custom_column( $column, $id ) { switch ( $column ) { case 'pf_mailstatus': - $response = get_post_meta( $id, PIRATEFORMS_SLUG . 'mail-status', true ); - $failed = $response == 'false'; + $response = get_post_meta( $id, PIRATEFORMS_SLUG . 'mail-status', true ); + $failed = $response == 'false'; echo empty( $response ) ? __( 'Status not captured', 'pirate-forms' ) : ( $failed ? __( 'Mail sending failed!', 'pirate-forms' ) : __( 'Mail sent successfully!', 'pirate-forms' ) ); if ( $failed ) { - $reason = get_post_meta( $id, PIRATEFORMS_SLUG . 'mail-status-reason', true ); + $reason = get_post_meta( $id, PIRATEFORMS_SLUG . 'mail-status-reason', true ); if ( ! empty( $reason ) ) { echo ' (' . $reason . ')'; } @@ -960,15 +1057,15 @@ public function manage_contact_posts_custom_column( $column, $id ) { public function test_email() { check_ajax_referer( PIRATEFORMS_SLUG, 'security' ); add_filter( 'pirateformpro_get_form_attributes', array( $this, 'test_configuration' ), 999, 2 ); - add_action( 'pirate_forms_after_processing', array( $this, 'test_result'), 10, 1 ); - add_filter( 'pirate_forms_validate_request', array( $this, 'test_alter_session'), 10, 3 ); - $_POST = array( - 'honeypot' => '', - 'pirate_forms_form_id' => isset( $_POST['pirate_forms_form_id'] ) ? $_POST['pirate_forms_form_id'] : '', - 'pirate-forms-contact-name' => 'Test Name', - 'pirate-forms-contact-email' => get_bloginfo( 'admin_email' ), - 'pirate-forms-contact-subject' => 'Test Email', - 'pirate-forms-contact-message' => 'This is a test.', + add_action( 'pirate_forms_after_processing', array( $this, 'test_result' ), 10, 1 ); + add_filter( 'pirate_forms_validate_request', array( $this, 'test_alter_session' ), 10, 3 ); + $_POST = array( + 'honeypot' => '', + 'pirate_forms_form_id' => isset( $_POST['pirate_forms_form_id'] ) ? $_POST['pirate_forms_form_id'] : '', + 'pirate-forms-contact-name' => 'Test Name', + 'pirate-forms-contact-email' => get_bloginfo( 'admin_email' ), + 'pirate-forms-contact-subject' => 'Test Email', + 'pirate-forms-contact-message' => 'This is a test.', ); do_action( 'pirate_forms_send_email', true ); } @@ -978,12 +1075,55 @@ public function test_email() { */ public function test_configuration( $options, $id ) { // disable captcha - $options['pirateformsopt_recaptcha_field'] = 'no'; + $options['pirateformsopt_recaptcha_field'] = 'no'; // disable attachments $options['pirateformsopt_attachment_field'] = 'no'; + return $options; } + /** + * Show admin notices. + */ + public function admin_notices() { + $screen = get_current_screen(); + if ( empty( $screen ) ) { + return; + } + if ( ! isset( $screen->base ) ) { + return; + } + + if ( ! in_array( $screen->id, array( 'toplevel_page_pirateforms-admin' ) ) ) { + return; + } + + $options = PirateForms_Util::get_option(); + + // check if store submissions is enabled without having a checkbox. + if ( 'yes' !== $options['pirateformsopt_store'] ) { + return; + } + + if ( empty( $options['pirateformsopt_checkbox_field'] ) && false === ( $x = get_transient( 'pirate_forms_gdpr_notice0' ) ) ) { + echo sprintf( '

%s

', __( 'According to GDPR we recommend you to ask for consent in order to store user data', 'pirate-forms' ) ); + } + } + + /** + * Generic ajax handler. + */ + public function ajax() { + check_ajax_referer( PIRATEFORMS_SLUG, 'security' ); + + switch ( $_POST['_action'] ) { + case 'dismiss-notice': + set_transient( 'pirate_forms_gdpr_notice' . $_POST['id'], 'yes' ); + break; + } + wp_die(); + } + /** * Hook into the sent result. */ @@ -996,6 +1136,7 @@ public function test_result( $response ) { */ public function test_alter_session( $body, $error_key, $pirate_forms_options ) { $_SESSION[ $error_key ] = ''; + return $body; } } diff --git a/admin/css/pirate-forms-extended-mailchimp-integration.jpg b/admin/css/pirate-forms-extended-mailchimp-integration.jpg index 6b2e8d2..5b3f417 100644 Binary files a/admin/css/pirate-forms-extended-mailchimp-integration.jpg and b/admin/css/pirate-forms-extended-mailchimp-integration.jpg differ diff --git a/admin/css/wp-admin.css b/admin/css/wp-admin.css index dbc4fa3..7268220 100644 --- a/admin/css/wp-admin.css +++ b/admin/css/wp-admin.css @@ -170,47 +170,6 @@ margin-right: 0; } -div.pirate_dashicons > form > div > label > span.dashicons { - margin-left: 10px; - color: #888; -} - -div.pirate_dashicons > form > div > label > span.dashicons:after { - display: none; - position: absolute; - margin-left: 5px; - border-right: 5px solid transparent; - border-bottom: 5px solid black; - border-left: 5px solid transparent; - content: ""; -} - -div.pirate_dashicons > form > div > label > .pirate_forms_option_description { - display: none; - position: absolute; - z-index: 999; - width: 200px; - margin-top: 4px; - margin-left: 190px; - padding: 15px; - border-radius: 5px; - color: #fff; - background: rgba(0, 0, 0, 0.8); - font-size: 11px; - line-height: 16px; - text-align: left; -} - -div.pirate_dashicons > form > div > label > span.dashicons:hover + .pirate_forms_option_description, -div.pirate_dashicons > form > div > label > span.dashicons:hover::after { - display: block; -} - -div.pirate_dashicons > form > div > label { - width: 400px; - font-weight: normal; -} - .pirate_forms_contact_settings h3.title, .pirate_forms_welcome_text { margin: 10px 0 30px; @@ -368,3 +327,15 @@ input#save.pirate-forms-save-button { margin-right: 10px; margin-left: 5px; } + +.pirate-forms-password-toggle span.dashicons { + cursor: pointer; +} + +.toplevel_page_pirateforms-admin .ui-tooltip { + width: 300px; + padding: 5px; + border-radius: 5px; + color: #fff; + background: #333; +} diff --git a/admin/img/loader.gif b/admin/img/loader.gif new file mode 100644 index 0000000..0250ac5 Binary files /dev/null and b/admin/img/loader.gif differ diff --git a/admin/js/scripts-admin.js b/admin/js/scripts-admin.js index a44a44c..7f30726 100644 --- a/admin/js/scripts-admin.js +++ b/admin/js/scripts-admin.js @@ -1,7 +1,12 @@ /* global cwp_top_ajaxload */ /* global console */ +/* global tinyMCE */ jQuery(document).ready(function() { + initAll(); +}); + +function initAll(){ jQuery('.pirate-forms-nav-tabs a').click(function (event) { event.preventDefault(); jQuery(this).parent().addClass('active'); @@ -13,6 +18,7 @@ jQuery(document).ready(function() { jQuery('.pirate-forms-save-button').click(function (e) { e.preventDefault(); + tinyMCE.triggerSave(); cwpTopUpdateForm(); return false; }); @@ -107,4 +113,52 @@ jQuery(document).ready(function() { } }); -}); + // add visibility toggle to password type fields + jQuery('.pirate-forms-password-toggle').append(''); + jQuery('.pirate-forms-password-toggle span').on('click', function(){ + var span = jQuery(this); + if(span.hasClass('dashicons-visibility')){ + span.parent().find('input[type="password"]').attr('type', 'text'); + span.removeClass('dashicons-visibility').addClass('dashicons-hidden'); + }else{ + span.parent().find('input[type="text"]').attr('type', 'password'); + span.removeClass('dashicons-hidden').addClass('dashicons-visibility'); + } + }); + + // tootips in settings. + jQuery(document).tooltip({ + items: '.dashicons-editor-help', + hide: 200, + position: {within: '#pirate-forms-main'}, + + content: function () { + return jQuery(this).find('div').html(); + }, + show: null, + close: function (event, ui) { + ui.tooltip.hover( + function () { + jQuery(this).stop(true).fadeTo(400, 1); + }, + function () { + jQuery(this).fadeOut('400', function () { + jQuery(this).remove(); + }); + }); + } + }); + + jQuery('.pirateforms-notice-gdpr.is-dismissible').on('click', '.notice-dismiss', function(){ + jQuery.ajax({ + url : cwp_top_ajaxload.ajaxurl, + type : 'POST', + data : { + id : jQuery(this).parent().attr('data-dismissible'), + _action : 'dismiss-notice', + security : cwp_top_ajaxload.nonce, + action : cwp_top_ajaxload.slug + } + }); + }); +} \ No newline at end of file diff --git a/admin/partials/pirateforms-settings-sidebar-subscribe.php b/admin/partials/pirateforms-settings-sidebar-subscribe.php index 2b66be6..84b0c4a 100644 --- a/admin/partials/pirateforms-settings-sidebar-subscribe.php +++ b/admin/partials/pirateforms-settings-sidebar-subscribe.php @@ -6,6 +6,9 @@