lite.php
342 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WPForms Lite. |
| 4 | * |
| 5 | * @package WPForms |
| 6 | * @author WPForms |
| 7 | * @since 1.0.0 |
| 8 | * @license GPL-2.0+ |
| 9 | * @copyright Copyright (c) 2016, WPForms LLC |
| 10 | */ |
| 11 | |
| 12 | |
| 13 | /** |
| 14 | * Display additional templates available in the paid version |
| 15 | * |
| 16 | * @since 1.0.6 |
| 17 | */ |
| 18 | function wpfl_setup_templates() { |
| 19 | $templates = array( |
| 20 | array( |
| 21 | 'name' => 'Request A Quote Form', |
| 22 | 'slug' => 'request-quote', |
| 23 | 'description' => 'Start collecting leads with this pre-made Request a quote form. You can add and remove fields as needed.', |
| 24 | ), |
| 25 | array( |
| 26 | 'name' => 'Donation Form', |
| 27 | 'slug' => 'donation', |
| 28 | 'description' => 'Start collecting donation payments on your website with this ready-made Donation form. You can add and remove fields as needed.', |
| 29 | ), |
| 30 | array( |
| 31 | 'name' => 'Billing / Order Form', |
| 32 | 'slug' => 'order', |
| 33 | 'description' => 'Collect payments for product and service orders with this ready-made form template. You can add and remove fields as needed.', |
| 34 | ), |
| 35 | array( |
| 36 | 'name' => 'Newsletter Sign Up Form', |
| 37 | 'slug' => 'subscribe', |
| 38 | 'description' => 'Add subscribers and grow your email list with this newsletter signup form. You can add and remove fields as needed.', |
| 39 | ) |
| 40 | ); |
| 41 | ?> |
| 42 | <div class="wpforms-setup-title">Unlock Pre-Made Form Templates <a href="https://wpforms.com/lite-upgrade/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin" target="_blank" class="btn-green" style="text-transform:uppercase;font-size:13px;font-weight:700;padding:5px 10px;vertical-align:text-bottom;">Upgrade</a></div> |
| 43 | <p class="wpforms-setup-desc">While WPForms Lite allows you to create any type of form, you can speed up the process by unlocking our other pre-built form templates among other features, so you never have to start from scratch again...</p> |
| 44 | <div class="wpforms-setup-templates wpforms-clear" style="opacity:0.5;"> |
| 45 | <?php |
| 46 | $x = 0; |
| 47 | foreach ( $templates as $template ) { |
| 48 | $class = 0 == $x % 3 ? 'first ' : ''; |
| 49 | ?> |
| 50 | <div class="wpforms-template upgrade-modal <?php echo $class; ?>" id="wpforms-template-<?php echo sanitize_html_class( $template['slug'] ); ?>"> |
| 51 | <div class="wpforms-template-name wpforms-clear"> |
| 52 | <?php echo esc_html( $template['name'] ); ?> |
| 53 | </div> |
| 54 | <div class="wpforms-template-details"> |
| 55 | <p class="desc"><?php echo esc_html( $template['description'] ); ?></p> |
| 56 | </div> |
| 57 | </div> |
| 58 | <?php |
| 59 | $x++; |
| 60 | } |
| 61 | ?> |
| 62 | </div> |
| 63 | <?php |
| 64 | } |
| 65 | add_action( 'wpforms_setup_panel_after', 'wpfl_setup_templates' ); |
| 66 | |
| 67 | /** |
| 68 | * Load templates available in full version. |
| 69 | * |
| 70 | * @since 1.0.0 |
| 71 | * @param array $fields |
| 72 | * @return array |
| 73 | */ |
| 74 | function wpfl_fields( $fields ) { |
| 75 | |
| 76 | $fields['fancy']['fields'][] = array( |
| 77 | 'icon' => 'fa-link', |
| 78 | 'name' => 'Website / URL', |
| 79 | 'type' => 'url', |
| 80 | 'order' => '1', |
| 81 | 'class' => 'upgrade-modal', |
| 82 | ); |
| 83 | $fields['fancy']['fields'][] = array( |
| 84 | 'icon' => 'fa-map-marker', |
| 85 | 'name' => 'Address', |
| 86 | 'type' => 'address', |
| 87 | 'order' => '2', |
| 88 | 'class' => 'upgrade-modal', |
| 89 | ); |
| 90 | $fields['fancy']['fields'][] = array( |
| 91 | 'icon' => 'fa-phone', |
| 92 | 'name' => 'Phone', |
| 93 | 'type' => 'phone', |
| 94 | 'order' => '3', |
| 95 | 'class' => 'upgrade-modal', |
| 96 | ); |
| 97 | $fields['fancy']['fields'][] = array( |
| 98 | 'icon' => 'fa-lock', |
| 99 | 'name' => 'Password', |
| 100 | 'type' => 'password', |
| 101 | 'order' => '4', |
| 102 | 'class' => 'upgrade-modal', |
| 103 | ); |
| 104 | $fields['fancy']['fields'][] = array( |
| 105 | 'icon' => 'fa-calendar-o', |
| 106 | 'name' => 'Date / Time', |
| 107 | 'type' => 'date-time', |
| 108 | 'order' => '5', |
| 109 | 'class' => 'upgrade-modal', |
| 110 | ); |
| 111 | $fields['fancy']['fields'][] = array( |
| 112 | 'icon' => 'fa-eye-slash', |
| 113 | 'name' => 'Hidden Field', |
| 114 | 'type' => 'hidden', |
| 115 | 'order' => '6', |
| 116 | 'class' => 'upgrade-modal', |
| 117 | ); |
| 118 | $fields['fancy']['fields'][] = array( |
| 119 | 'icon' => 'fa-upload', |
| 120 | 'name' => 'File Upload', |
| 121 | 'type' => 'file-upload', |
| 122 | 'order' => '7', |
| 123 | 'class' => 'upgrade-modal', |
| 124 | ); |
| 125 | $fields['fancy']['fields'][] = array( |
| 126 | 'icon' => 'fa-code', |
| 127 | 'name' => 'HTML', |
| 128 | 'type' => 'html', |
| 129 | 'order' => '8', |
| 130 | 'class' => 'upgrade-modal', |
| 131 | ); |
| 132 | $fields['fancy']['fields'][] = array( |
| 133 | 'icon' => 'fa-files-o', |
| 134 | 'name' => 'Page Break', |
| 135 | 'type' => 'pagebreak', |
| 136 | 'order' => '9', |
| 137 | 'class' => 'upgrade-modal', |
| 138 | ); |
| 139 | $fields['fancy']['fields'][] = array( |
| 140 | 'icon' => 'fa-arrows-h', |
| 141 | 'name' => 'Divider', |
| 142 | 'type' => 'Divider', |
| 143 | 'order' => '10', |
| 144 | 'class' => 'upgrade-modal', |
| 145 | ); |
| 146 | $fields['payment']['fields'][] = array( |
| 147 | 'icon' => 'fa-file-o', |
| 148 | 'name' => 'Divider', |
| 149 | 'type' => 'payment-single', |
| 150 | 'order' => '1', |
| 151 | 'class' => 'upgrade-modal', |
| 152 | ); |
| 153 | $fields['payment']['fields'][] = array( |
| 154 | 'icon' => 'fa-list-ul', |
| 155 | 'name' => 'Multiple Items', |
| 156 | 'type' => 'payment-multiple', |
| 157 | 'order' => '2', |
| 158 | 'class' => 'upgrade-modal', |
| 159 | ); |
| 160 | $fields['payment']['fields'][] = array( |
| 161 | 'icon' => 'fa-money', |
| 162 | 'name' => 'Total', |
| 163 | 'type' => 'payment-total', |
| 164 | 'order' => '3', |
| 165 | 'class' => 'upgrade-modal', |
| 166 | ); |
| 167 | return $fields; |
| 168 | } |
| 169 | add_filter( 'wpforms_builder_fields_buttons', 'wpfl_fields', 20 ); |
| 170 | |
| 171 | /** |
| 172 | * Load panels available in full version. |
| 173 | * |
| 174 | * @since 1.0.0 |
| 175 | */ |
| 176 | function wpfl_panels() { |
| 177 | |
| 178 | ?> |
| 179 | <button class="wpforms-panel-providers-button upgrade-modal" data-panel="providers"> |
| 180 | <i class="fa fa-bullhorn"></i><span>Marketing</span> |
| 181 | </button> |
| 182 | <button class="wpforms-panel-payments-button upgrade-modal" data-panel="payments"> |
| 183 | <i class="fa fa-usd"></i><span>Payments</span> |
| 184 | </button> |
| 185 | <?php |
| 186 | } |
| 187 | add_action( 'wpforms_builder_panel_buttons', 'wpfl_panels', 20 ); |
| 188 | |
| 189 | /** |
| 190 | * Load assets for lite version with the admin builder. |
| 191 | * |
| 192 | * @since 1.0.0 |
| 193 | */ |
| 194 | function wpfl_builder_enqueues() { |
| 195 | |
| 196 | wp_enqueue_script( |
| 197 | 'wpforms-builder-lite', |
| 198 | WPFORMS_PLUGIN_URL . 'lite/admin-builder-lite.js', |
| 199 | array( 'jquery', 'jquery-confirm' ), |
| 200 | WPFORMS_VERSION, |
| 201 | false |
| 202 | ); |
| 203 | |
| 204 | wp_localize_script( |
| 205 | 'wpforms-builder-lite', |
| 206 | 'wpforms_builder_lite', |
| 207 | array( |
| 208 | 'upgrade_title' => __( 'is a PRO Feature', 'wpforms' ), |
| 209 | 'upgrade_message' => __( 'We\'re sorry, %name% is not available on your plan.<br><br>Please upgrade to the PRO plan to unlock all these awesome features.', 'wpforms' ), |
| 210 | 'upgrade_button' => __( 'Upgrade to PRO', 'wpforms' ), |
| 211 | ) |
| 212 | ); |
| 213 | } |
| 214 | add_action( 'wpforms_builder_enqueues_before', 'wpfl_builder_enqueues' ); |
| 215 | |
| 216 | /** |
| 217 | * Notify user that entries is a paid feature. |
| 218 | * |
| 219 | * @since 1.0.0 |
| 220 | */ |
| 221 | function wpfl_entries_page() { |
| 222 | |
| 223 | if ( !isset( $_GET['page'] ) || 'wpforms-entries' != $_GET['page'] ) { |
| 224 | return; |
| 225 | } |
| 226 | ?> |
| 227 | |
| 228 | <div id="wpforms-entries" class="wrap"> |
| 229 | <h1 class="page-title"> |
| 230 | Entries |
| 231 | </h1> |
| 232 | <div class="notice notice-info below-h2"> |
| 233 | <p><strong>Entry management and storage is a PRO feature.</strong></p> |
| 234 | <p>Please upgrade to the PRO plan to unlock it and more awesome features.</p> |
| 235 | <p><a href="https://wpforms.com/lite-upgrade/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin" class="button button-primary" target="_blank">Upgrade Now</a></p> |
| 236 | </div> |
| 237 | </div> |
| 238 | <?php |
| 239 | } |
| 240 | add_action( 'wpforms_admin_page', 'wpfl_entries_page' ); |
| 241 | |
| 242 | /** |
| 243 | * Add appropriate styling to addons page. |
| 244 | * |
| 245 | * @since 1.0.4 |
| 246 | */ |
| 247 | function wpfl_addons_page_assets() { |
| 248 | |
| 249 | if ( !isset( $_GET['page'] ) || $_GET['page'] != 'wpforms-addons' ) |
| 250 | return; |
| 251 | |
| 252 | // CSS |
| 253 | wp_enqueue_style( |
| 254 | 'font-awesome', |
| 255 | WPFORMS_PLUGIN_URL . 'assets/css/font-awesome.min.css', |
| 256 | null, |
| 257 | '4.4.0' |
| 258 | ); |
| 259 | wp_enqueue_style( |
| 260 | 'wpforms-addons', |
| 261 | WPFORMS_PLUGIN_URL . 'assets/css/admin-addons.css', |
| 262 | null, |
| 263 | WPFORMS_VERSION |
| 264 | ); |
| 265 | } |
| 266 | add_action( 'admin_enqueue_scripts', 'wpfl_addons_page_assets' ); |
| 267 | |
| 268 | /** |
| 269 | * Notify user that addons are a paid feature. |
| 270 | * |
| 271 | * @since 1.0.0 |
| 272 | */ |
| 273 | function wpfl_addons_page() { |
| 274 | |
| 275 | if ( !isset( $_GET['page'] ) || 'wpforms-addons' != $_GET['page'] ) { |
| 276 | return; |
| 277 | } |
| 278 | $upgrade = 'https://wpforms.com/lite-upgrade/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin'; |
| 279 | ?> |
| 280 | |
| 281 | <div id="wpforms-addons" class="wrap"> |
| 282 | <h1 class="page-title"> |
| 283 | Addons |
| 284 | </h1> |
| 285 | <div class="notice notice-info below-h2"> |
| 286 | <p><strong>Form Addons are a PRO feature.</strong></p> |
| 287 | <p>Please upgrade to the PRO plan to unlock them and more awesome features.</p> |
| 288 | <p><a href="https://wpforms.com/lite-upgrade/" class="button button-primary">Upgrade Now</a></p> |
| 289 | </div> |
| 290 | <div class="wpforms-addon-item wpforms-addon-status-upgrade wpforms-first"> |
| 291 | <div class="wpforms-addon-image"><img src="https://wpforms.com/images/addon-icon-aweber.png"></div> |
| 292 | <div class="wpforms-addon-text"> |
| 293 | <h4>AWeber Addon</h4> |
| 294 | <p class="desc">WPForms AWeber addon allows you to create AWeber newsletter signup forms in WordPress, so you can grow your email list. </p> |
| 295 | </div> |
| 296 | <div class="wpforms-addon-action"><a href="<?php echo $upgrade; ?>" target="_blank">Upgrade Now</a></div> |
| 297 | </div> |
| 298 | <div class="wpforms-addon-item wpforms-addon-status-upgrade wpforms-second"> |
| 299 | <div class="wpforms-addon-image"><img src="https://wpforms.com/images/addon-icon-conditional-logic.png"></div> |
| 300 | <div class="wpforms-addon-text"> |
| 301 | <h4>Conditional Logic Addon</h4> |
| 302 | <p class="desc">WPForms' smart conditional logic addon allows you to show or hide fields, sections, and send specific notifications based on user selections, so you can collect the most relevant information.</p> |
| 303 | </div> |
| 304 | <div class="wpforms-addon-action"><a href="<?php echo $upgrade; ?>" target="_blank">Upgrade Now</a></div> |
| 305 | </div> |
| 306 | <div class="wpforms-addon-item wpforms-addon-status-upgrade wpforms-first"> |
| 307 | <div class="wpforms-addon-image"><img src="https://wpforms.com/images/addon-icon-mailchimp.png"></div> |
| 308 | <div class="wpforms-addon-text"> |
| 309 | <h4>MailChimp Addon</h4> |
| 310 | <p class="desc">WPForms MailChimp addon allows you to create MailChimp newsletter signup forms in WordPress, so you can grow your email list. </p> |
| 311 | </div> |
| 312 | <div class="wpforms-addon-action"><a href="<?php echo $upgrade; ?>" target="_blank">Upgrade Now</a></div> |
| 313 | </div> |
| 314 | <div class="wpforms-addon-item wpforms-addon-status-upgrade wpforms-second"> |
| 315 | <div class="wpforms-addon-image"><img src="https://wpforms.com/images/addon-icon-paypal.png"></div> |
| 316 | <div class="wpforms-addon-text"> |
| 317 | <h4>PayPal Standard Addon</h4> |
| 318 | <p class="desc">WPForms' PayPal addon allows you to connect your WordPress site with PayPal to easily collect payments, donations, and online orders.</p> |
| 319 | </div> |
| 320 | <div class="wpforms-addon-action"><a href="<?php echo $upgrade; ?>" target="_blank">Upgrade Now</a></div> |
| 321 | </div> |
| 322 | <div class="wpforms-addon-item wpforms-addon-status-upgrade wpforms-first"> |
| 323 | <div class="wpforms-addon-image"><img src="https://wpforms.com/images/addon-icon-stripe.png"></div> |
| 324 | <div class="wpforms-addon-text"> |
| 325 | <h4>Stripe Addon</h4> |
| 326 | <p class="desc">WPForms' Stripe addon allows you to connect your WordPress site with Stripe to easily collect payments, donations, and online orders.</p> |
| 327 | </div> |
| 328 | <div class="wpforms-addon-action"><a href="<?php echo $upgrade; ?>" target="_blank">Upgrade Now</a></div> |
| 329 | </div> |
| 330 | <div class="wpforms-addon-item wpforms-addon-status-upgrade wpforms-second"> |
| 331 | <div class="wpforms-addon-image"><img src="https://wpforms.com/images/addon-icon-getresponse.png"></div> |
| 332 | <div class="wpforms-addon-text"> |
| 333 | <h4>GetResponse Addon</h4> |
| 334 | <p class="desc">WPForms GetResponse addon allows you to create GetResponse newsletter signup forms in WordPress, so you can grow your email list. </p> |
| 335 | </div> |
| 336 | <div class="wpforms-addon-action"><a href="<?php echo $upgrade; ?>" target="_blank">Upgrade Now</a></div> |
| 337 | </div> |
| 338 | <div style="clear:both"></div> |
| 339 | </div> |
| 340 | <?php |
| 341 | } |
| 342 | add_action( 'wpforms_admin_page', 'wpfl_addons_page' ); |