access.php
1 year ago
checks.php
1 year ago
colors.php
1 year ago
data-presets.php
1 year ago
date-time.php
1 year ago
debug.php
1 year ago
education.php
1 year ago
escape-sanitize.php
1 year ago
filesystem-media.php
1 year ago
form-fields.php
1 year ago
forms.php
1 year ago
list.php
1 year ago
payments.php
1 year ago
plugins.php
1 year ago
privacy.php
1 year ago
providers.php
1 year ago
unused.php
1 year ago
utilities.php
1 year ago
education.php
83 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Helpers functions for the Education pages. |
| 4 | * |
| 5 | * @since 1.8.2.2 |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Get the button. |
| 10 | * |
| 11 | * @since 1.8.2.2 |
| 12 | * |
| 13 | * @param string $action Action to perform. |
| 14 | * @param bool $plugin_allow Is plugin allowed. |
| 15 | * @param string $path Plugin file. |
| 16 | * @param string $url URL for download plugin. |
| 17 | * @param array $utm UTM parameters. |
| 18 | */ |
| 19 | function wpforms_edu_get_button( $action, $plugin_allow, $path, $url, $utm ) { |
| 20 | |
| 21 | // If the user is not allowed to use the plugin, show the upgrade button. |
| 22 | if ( ! $plugin_allow ) { |
| 23 | wpforms_edu_get_upgrade_button( $utm ); |
| 24 | |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | $status = 'inactive'; |
| 29 | $data_plugin = $path; |
| 30 | $title = esc_html__( 'Activate', 'wpforms-lite' ); |
| 31 | $can_install = wpforms_can_install( 'addon' ); |
| 32 | |
| 33 | if ( $action === 'install' ) { |
| 34 | $status = 'download'; |
| 35 | $data_plugin = $url; |
| 36 | $title = esc_html__( 'Install & Activate', 'wpforms-lite' ); |
| 37 | } |
| 38 | |
| 39 | ?> |
| 40 | |
| 41 | <?php if ( $action === 'install' && ! $can_install ) : ?> |
| 42 | <div class="wpforms-notice wpforms-error"> |
| 43 | <p><?php esc_html_e( 'Plugin installation is disabled for this site.', 'wpforms-lite' ); ?></p> |
| 44 | </div> |
| 45 | <?php else : ?> |
| 46 | <button |
| 47 | class="status-<?php echo esc_attr( $status ); ?> wpforms-btn wpforms-btn-lg wpforms-btn-blue wpforms-education-toggle-plugin-btn" |
| 48 | data-type="addon" |
| 49 | data-action="<?php echo esc_attr( $action ); ?>" |
| 50 | data-plugin="<?php echo esc_attr( $data_plugin ); ?>"> |
| 51 | <i></i><?php echo esc_html( $title ); ?> |
| 52 | <?php endif; ?> |
| 53 | <?php |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get the upgrade button. |
| 58 | * |
| 59 | * @since 1.8.2.2 |
| 60 | * |
| 61 | * @param array $utm UTM parameters. |
| 62 | * @param array $classes Classes. |
| 63 | */ |
| 64 | function wpforms_edu_get_upgrade_button( $utm, $classes = [] ) { |
| 65 | |
| 66 | $utm_medium = isset( $utm['medium'] ) ? $utm['medium'] : ''; |
| 67 | $utm_content = isset( $utm['content'] ) ? $utm['content'] : ''; |
| 68 | |
| 69 | $default_classes = [ 'wpforms-btn', 'wpforms-btn-lg', 'wpforms-btn-orange' ]; |
| 70 | $default_classes[] = ! wpforms()->is_pro() ? 'wpforms-upgrade-modal' : ''; |
| 71 | |
| 72 | $btn_classes = array_merge( $default_classes, (array) $classes ); |
| 73 | ?> |
| 74 | <a |
| 75 | href="<?php echo esc_url( wpforms_admin_upgrade_link( $utm_medium, $utm_content ) ); ?>" |
| 76 | target="_blank" |
| 77 | rel="noopener noreferrer" |
| 78 | class="<?php echo esc_attr( implode( ' ', array_filter( $btn_classes ) ) ); ?>"> |
| 79 | <?php esc_html_e( 'Upgrade to WPForms Pro', 'wpforms-lite' ); ?> |
| 80 | </a> |
| 81 | <?php |
| 82 | } |
| 83 |