项目作者: silverbackstudio

项目描述 :
Extensible Wordpress form framework for busy developers
高级语言: PHP
项目地址: git://github.com/silverbackstudio/wp-forms.git
创建时间: 2018-03-07T11:19:45Z
项目社区:https://github.com/silverbackstudio/wp-forms

开源协议:

下载


Silverback Wordpress Forms

Requires silverbackstudio/wp-email to send emails.

Example

  1. use Svbk\WP;
  2. use Svbk\WP\Email;
  3. /**
  4. * Register forms after theme setup.
  5. *
  6. * @return void
  7. */
  8. function register_custom_forms() {
  9. /**
  10. * Set the default email marketing platform and transactional email service
  11. */
  12. Forms\Form::setDefaults(
  13. array(
  14. // Sendinblue
  15. 'transactional' => new Email\Transactional\SendInBlue,
  16. 'marketing' => new Email\Marketing\SendInBlue,
  17. // Mailchimp:
  18. //'transactional' => new Email\Transactional\Mandrill( 'mandrill-apikey' ),
  19. //'marketing' => new Email\Marketing\MailChimp( 'mailchimp-apikey' ),
  20. )
  21. );
  22. /**
  23. * Creates a `Subscribe` form named 'trial'
  24. */
  25. Forms\Manager::create( 'trial', Forms\Subscribe::class,
  26. [
  27. 'marketing_lists' => array( 8 ),
  28. ]
  29. );
  30. }
  31. add_action( 'after_setup_theme', 'register_custom_forms', 11 );

Creates a Contact form named ‘contact’ and return the form instance

  1. $trial_form = Forms\Manager::create( 'contact', Forms\Contact::class, [
  2. 'admin_template' => 'template-id-or-name',
  3. 'user_template' => 'template-id-or-name',
  4. 'marketing_lists' => array( 1 ),
  5. 'recipient' => new Email\Contact( [ 'email' => env('RECIPIENT_EMAIL') ] ),
  6. // to customize policy flag texts
  7. //'policyScope' => __('<b>[privacy-controller-name]</b> will process your information to respond to your request.', '[textdomain]');
  8. //'policyUnsubscribe' => __('You can unsubscribe at any time by clicking on the link at the bottom of each email.', '[textdomain]');
  9. //'policyAllText' => __( 'I have read and accept the [privacy-policy-link] and agree to receive personalized promotional informations.', '[textdomain]' );
  10. //'policyAllToggleText' ==> __( 'To select partial consents %s', '[textdomain]' );
  11. //'policyService' => __( 'I have read and agree to the [privacy-policy-link]', '[textdomain]' );
  12. //'policyNewsletter' => __( 'I have read the [privacy-policy-link] and agree to the processing of my data to receive informative material', '[textdomain]' );
  13. //'policyMarketing' => __( 'I have read the [privacy-policy-link] and agree to the processing of my data to receive personalized promotional materials based on my browsing data.', '[textdomain]' );
  14. ] );

See silverbackstudio/wp-shortcakes or silverbackstudio/wp-widgets see how to render forms in a shortcode or a widget.