Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/sendinblue.tar
Ðазад
contact-form-properties.php 0000644 00000015240 15155121410 0012040 0 ustar 00 <?php add_filter( 'wpcf7_contact_form_properties', 'wpcf7_sendinblue_register_property', 10, 2 ); function wpcf7_sendinblue_register_property( $properties, $contact_form ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return $properties; } $properties += array( 'sendinblue' => array(), ); return $properties; } add_action( 'wpcf7_save_contact_form', 'wpcf7_sendinblue_save_contact_form', 10, 3 ); function wpcf7_sendinblue_save_contact_form( $contact_form, $args, $context ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return; } $prop = isset( $_POST['wpcf7-sendinblue'] ) ? (array) $_POST['wpcf7-sendinblue'] : array(); $prop = wp_parse_args( $prop, array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); $prop['contact_lists'] = array_map( 'absint', $prop['contact_lists'] ); $prop['email_template'] = absint( $prop['email_template'] ); $contact_form->set_properties( array( 'sendinblue' => $prop, ) ); } add_filter( 'wpcf7_editor_panels', 'wpcf7_sendinblue_editor_panels', 10, 1 ); function wpcf7_sendinblue_editor_panels( $panels ) { $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return $panels; } $contact_form = WPCF7_ContactForm::get_current(); $prop = wp_parse_args( $contact_form->prop( 'sendinblue' ), array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); $editor_panel = function () use ( $prop, $service ) { $description = sprintf( esc_html( __( "You can set up the Sendinblue integration here. For details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ), __( 'Sendinblue integration', 'contact-form-7' ) ) ); $lists = $service->get_lists(); $templates = $service->get_templates(); ?> <h2><?php echo esc_html( __( 'Sendinblue', 'contact-form-7' ) ); ?></h2> <fieldset> <legend><?php echo $description; ?></legend> <table class="form-table" role="presentation"> <tbody> <tr class="<?php echo $prop['enable_contact_list'] ? '' : 'inactive'; ?>"> <th scope="row"> <?php echo esc_html( __( 'Contact lists', 'contact-form-7' ) ); ?> </th> <td> <fieldset> <legend class="screen-reader-text"> <?php echo esc_html( __( 'Contact lists', 'contact-form-7' ) ); ?> </legend> <label for="wpcf7-sendinblue-enable-contact-list"> <input type="checkbox" name="wpcf7-sendinblue[enable_contact_list]" id="wpcf7-sendinblue-enable-contact-list" value="1" <?php checked( $prop['enable_contact_list'] ); ?> /> <?php echo esc_html( __( "Add form submitters to your contact lists", 'contact-form-7' ) ); ?> </label> </fieldset> </td> </tr> <tr> <th scope="row"></th> <td> <fieldset> <?php if ( $lists ) { echo sprintf( '<legend>%1$s</legend>', esc_html( __( 'Select lists to which contacts are added:', 'contact-form-7' ) ) ); echo '<ul>'; foreach ( $lists as $list ) { echo sprintf( '<li><label><input %1$s /> %2$s</label></li>', wpcf7_format_atts( array( 'type' => 'checkbox', 'name' => 'wpcf7-sendinblue[contact_lists][]', 'value' => $list['id'], 'checked' => in_array( $list['id'], $prop['contact_lists'] ) ? 'checked' : '', ) ), esc_html( $list['name'] ) ); } echo '</ul>'; } else { echo sprintf( '<legend>%1$s</legend>', esc_html( __( 'You have no contact list yet.', 'contact-form-7' ) ) ); } ?> </fieldset> <?php echo sprintf( '<p><a %1$s>%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', wpcf7_format_atts( array( 'href' => 'https://my.sendinblue.com/lists', 'target' => '_blank', 'rel' => 'external noreferrer noopener', ) ), esc_html( __( 'Manage your contact lists', 'contact-form-7' ) ), esc_html( __( '(opens in a new tab)', 'contact-form-7' ) ) ); ?> </td> </tr> <tr class="<?php echo $prop['enable_transactional_email'] ? '' : 'inactive'; ?>"> <th scope="row"> <?php echo esc_html( __( 'Welcome email', 'contact-form-7' ) ); ?> </th> <td> <fieldset> <legend class="screen-reader-text"> <?php echo esc_html( __( 'Welcome email', 'contact-form-7' ) ); ?> </legend> <label for="wpcf7-sendinblue-enable-transactional-email"> <input type="checkbox" name="wpcf7-sendinblue[enable_transactional_email]" id="wpcf7-sendinblue-enable-transactional-email" value="1" <?php checked( $prop['enable_transactional_email'] ); ?> /> <?php echo esc_html( __( "Send a welcome email to new contacts", 'contact-form-7' ) ); ?> </label> </fieldset> </td> </tr> <tr> <th scope="row"></th> <td> <fieldset> <?php if ( $templates ) { echo sprintf( '<legend>%1$s</legend>', esc_html( __( 'Select an email template:', 'contact-form-7' ) ) ); echo '<select name="wpcf7-sendinblue[email_template]">'; echo sprintf( '<option %1$s>%2$s</option>', wpcf7_format_atts( array( 'value' => 0, 'selected' => 0 === $prop['email_template'] ? 'selected' : '', ) ), esc_html( __( '— Select —', 'contact-form-7' ) ) ); foreach ( $templates as $template ) { echo sprintf( '<option %1$s>%2$s</option>', wpcf7_format_atts( array( 'value' => $template['id'], 'selected' => $prop['email_template'] === $template['id'] ? 'selected' : '', ) ), esc_html( $template['name'] ) ); } echo '</select>'; } else { echo sprintf( '<legend>%1$s</legend>', esc_html( __( 'You have no active email template yet.', 'contact-form-7' ) ) ); } ?> </fieldset> <?php echo sprintf( '<p><a %1$s>%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>', wpcf7_format_atts( array( 'href' => 'https://my.sendinblue.com/camp/lists/template', 'target' => '_blank', 'rel' => 'external noreferrer noopener', ) ), esc_html( __( 'Manage your email templates', 'contact-form-7' ) ), esc_html( __( '(opens in a new tab)', 'contact-form-7' ) ) ); ?> </td> </tr> </tbody> </table> </fieldset> <?php }; $panels += array( 'sendinblue-panel' => array( 'title' => __( 'Sendinblue', 'contact-form-7' ), 'callback' => $editor_panel, ), ); return $panels; } sendinblue.php 0000644 00000010044 15155121410 0007377 0 ustar 00 <?php include_once path_join( WPCF7_PLUGIN_MODULES_DIR, 'sendinblue/service.php' ); include_once path_join( WPCF7_PLUGIN_MODULES_DIR, 'sendinblue/contact-form-properties.php' ); add_action( 'wpcf7_init', 'wpcf7_sendinblue_register_service', 1, 0 ); function wpcf7_sendinblue_register_service() { $integration = WPCF7_Integration::get_instance(); $integration->add_service( 'sendinblue', WPCF7_Sendinblue::get_instance() ); } add_action( 'wpcf7_submit', 'wpcf7_sendinblue_submit', 10, 2 ); function wpcf7_sendinblue_submit( $contact_form, $result ) { if ( $contact_form->in_demo_mode() ) { return; } $service = WPCF7_Sendinblue::get_instance(); if ( ! $service->is_active() ) { return; } if ( empty( $result['posted_data_hash'] ) ) { return; } if ( empty( $result['status'] ) or ! in_array( $result['status'], array( 'mail_sent', 'mail_failed' ) ) ) { return; } $submission = WPCF7_Submission::get_instance(); $consented = true; foreach ( $contact_form->scan_form_tags( 'feature=name-attr' ) as $tag ) { if ( $tag->has_option( 'consent_for:sendinblue' ) and null == $submission->get_posted_data( $tag->name ) ) { $consented = false; break; } } if ( ! $consented ) { return; } $prop = wp_parse_args( $contact_form->prop( 'sendinblue' ), array( 'enable_contact_list' => false, 'contact_lists' => array(), 'enable_transactional_email' => false, 'email_template' => 0, ) ); if ( ! $prop['enable_contact_list'] ) { return; } $attributes = wpcf7_sendinblue_collect_parameters(); if ( empty( $attributes['EMAIL'] ) and empty( $attributes['SMS'] ) ) { return; } $contact_params = apply_filters( 'wpcf7_sendinblue_contact_parameters', array( 'email' => $attributes['EMAIL'], 'attributes' => (object) $attributes, 'listIds' => (array) $prop['contact_lists'], 'updateEnabled' => false, ) ); $contact_id = $service->create_contact( $contact_params ); if ( ! $contact_id ) { return; } if ( ! $prop['enable_transactional_email'] or ! $prop['email_template'] ) { return; } $first_name = isset( $attributes['FIRSTNAME'] ) ? trim( $attributes['FIRSTNAME'] ) : ''; $last_name = isset( $attributes['LASTNAME'] ) ? trim( $attributes['LASTNAME'] ) : ''; if ( $first_name or $last_name ) { $email_to_name = sprintf( /* translators: 1: first name, 2: last name */ _x( '%1$s %2$s', 'personal name', 'contact-form-7' ), $first_name, $last_name ); } else { $email_to_name = ''; } $email_params = apply_filters( 'wpcf7_sendinblue_email_parameters', array( 'templateId' => absint( $prop['email_template'] ), 'to' => array( array( 'name' => $email_to_name, 'email' => $attributes['EMAIL'], ), ), 'params' => (object) $attributes, 'tags' => array( 'Contact Form 7' ), ) ); $service->send_email( $email_params ); } function wpcf7_sendinblue_collect_parameters() { $params = array(); $submission = WPCF7_Submission::get_instance(); foreach ( (array) $submission->get_posted_data() as $name => $val ) { $name = strtoupper( $name ); if ( 'YOUR-' == substr( $name, 0, 5 ) ) { $name = substr( $name, 5 ); } if ( $val ) { $params += array( $name => $val, ); } } if ( isset( $params['SMS'] ) ) { $sms = implode( ' ', (array) $params['SMS'] ); $sms = trim( $sms ); $plus = '+' == substr( $sms, 0, 1 ) ? '+' : ''; $sms = preg_replace( '/[^0-9]/', '', $sms ); if ( 6 < strlen( $sms ) and strlen( $sms ) < 18 ) { $params['SMS'] = $plus . $sms; } else { // Invalid phone number unset( $params['SMS'] ); } } if ( isset( $params['NAME'] ) ) { $your_name = implode( ' ', (array) $params['NAME'] ); $your_name = explode( ' ', $your_name ); if ( ! isset( $params['LASTNAME'] ) ) { $params['LASTNAME'] = implode( ' ', array_slice( $your_name, 1 ) ); } if ( ! isset( $params['FIRSTNAME'] ) ) { $params['FIRSTNAME'] = implode( ' ', array_slice( $your_name, 0, 1 ) ); } } $params = apply_filters( 'wpcf7_sendinblue_collect_parameters', $params ); return $params; } service.php 0000644 00000022346 15155121410 0006717 0 ustar 00 <?php if ( ! class_exists( 'WPCF7_Service' ) ) { return; } class WPCF7_Sendinblue extends WPCF7_Service { use WPCF7_Sendinblue_API; private static $instance; private $api_key; public static function get_instance() { if ( empty( self::$instance ) ) { self::$instance = new self; } return self::$instance; } private function __construct() { $option = WPCF7::get_option( 'sendinblue' ); if ( isset( $option['api_key'] ) ) { $this->api_key = $option['api_key']; } } public function get_title() { return __( 'Sendinblue', 'contact-form-7' ); } public function is_active() { return (bool) $this->get_api_key(); } public function get_api_key() { return $this->api_key; } public function get_categories() { return array( 'email_marketing' ); } public function icon() { } public function link() { echo wpcf7_link( 'https://www.sendinblue.com/?tap_a=30591-fb13f0&tap_s=1031580-b1bb1d', 'sendinblue.com' ); } protected function log( $url, $request, $response ) { wpcf7_log_remote_request( $url, $request, $response ); } protected function menu_page_url( $args = '' ) { $args = wp_parse_args( $args, array() ); $url = menu_page_url( 'wpcf7-integration', false ); $url = add_query_arg( array( 'service' => 'sendinblue' ), $url ); if ( ! empty( $args ) ) { $url = add_query_arg( $args, $url ); } return $url; } protected function save_data() { WPCF7::update_option( 'sendinblue', array( 'api_key' => $this->api_key, ) ); } protected function reset_data() { $this->api_key = null; $this->save_data(); } public function load( $action = '' ) { if ( 'setup' == $action and 'POST' == $_SERVER['REQUEST_METHOD'] ) { check_admin_referer( 'wpcf7-sendinblue-setup' ); if ( ! empty( $_POST['reset'] ) ) { $this->reset_data(); $redirect_to = $this->menu_page_url( 'action=setup' ); } else { $this->api_key = isset( $_POST['api_key'] ) ? trim( $_POST['api_key'] ) : ''; $confirmed = $this->confirm_key(); if ( true === $confirmed ) { $redirect_to = $this->menu_page_url( array( 'message' => 'success', ) ); $this->save_data(); } elseif ( false === $confirmed ) { $redirect_to = $this->menu_page_url( array( 'action' => 'setup', 'message' => 'unauthorized', ) ); } else { $redirect_to = $this->menu_page_url( array( 'action' => 'setup', 'message' => 'invalid', ) ); } } wp_safe_redirect( $redirect_to ); exit(); } } public function admin_notice( $message = '' ) { if ( 'unauthorized' == $message ) { echo sprintf( '<div class="notice notice-error"><p><strong>%1$s</strong>: %2$s</p></div>', esc_html( __( "Error", 'contact-form-7' ) ), esc_html( __( "You have not been authenticated. Make sure the provided API key is correct.", 'contact-form-7' ) ) ); } if ( 'invalid' == $message ) { echo sprintf( '<div class="notice notice-error"><p><strong>%1$s</strong>: %2$s</p></div>', esc_html( __( "Error", 'contact-form-7' ) ), esc_html( __( "Invalid key values.", 'contact-form-7' ) ) ); } if ( 'success' == $message ) { echo sprintf( '<div class="notice notice-success"><p>%s</p></div>', esc_html( __( 'Settings saved.', 'contact-form-7' ) ) ); } } public function display( $action = '' ) { echo '<p>' . sprintf( esc_html( __( "Store and organize your contacts while protecting user privacy on Sendinblue, the leading CRM & email marketing platform in Europe. Sendinblue offers unlimited contacts and advanced marketing features. For details, see %s.", 'contact-form-7' ) ), wpcf7_link( __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ), __( 'Sendinblue integration', 'contact-form-7' ) ) ) . '</p>'; if ( $this->is_active() ) { echo sprintf( '<p class="dashicons-before dashicons-yes">%s</p>', esc_html( __( "Sendinblue is active on this site.", 'contact-form-7' ) ) ); } if ( 'setup' == $action ) { $this->display_setup(); } else { echo sprintf( '<p><a href="%1$s" class="button">%2$s</a></p>', esc_url( $this->menu_page_url( 'action=setup' ) ), esc_html( __( 'Setup integration', 'contact-form-7' ) ) ); } } private function display_setup() { $api_key = $this->get_api_key(); ?> <form method="post" action="<?php echo esc_url( $this->menu_page_url( 'action=setup' ) ); ?>"> <?php wp_nonce_field( 'wpcf7-sendinblue-setup' ); ?> <table class="form-table"> <tbody> <tr> <th scope="row"><label for="publishable"><?php echo esc_html( __( 'API key', 'contact-form-7' ) ); ?></label></th> <td><?php if ( $this->is_active() ) { echo esc_html( wpcf7_mask_password( $api_key, 4, 8 ) ); echo sprintf( '<input type="hidden" value="%s" id="api_key" name="api_key" />', esc_attr( $api_key ) ); } else { echo sprintf( '<input type="text" aria-required="true" value="%s" id="api_key" name="api_key" class="regular-text code" />', esc_attr( $api_key ) ); } ?></td> </tr> </tbody> </table> <?php if ( $this->is_active() ) { submit_button( _x( 'Remove key', 'API keys', 'contact-form-7' ), 'small', 'reset' ); } else { submit_button( __( 'Save changes', 'contact-form-7' ) ); } ?> </form> <?php } } /** * Trait for the Sendinblue API (v3). * * @link https://developers.sendinblue.com/reference */ trait WPCF7_Sendinblue_API { public function confirm_key() { $endpoint = 'https://api.sendinblue.com/v3/account'; $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), ); $response = wp_remote_get( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 200 === $response_code ) { // 200 OK return true; } elseif ( 401 === $response_code ) { // 401 Unauthorized return false; } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } } public function get_lists() { $endpoint = add_query_arg( array( 'limit' => 50, 'offset' => 0, ), 'https://api.sendinblue.com/v3/contacts/lists' ); $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), ); $response = wp_remote_get( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 200 === $response_code ) { // 200 OK $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); if ( empty( $response_body['lists'] ) ) { return array(); } else { return (array) $response_body['lists']; } } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } } public function get_templates() { $endpoint = add_query_arg( array( 'templateStatus' => 'true', 'limit' => 100, 'offset' => 0, ), 'https://api.sendinblue.com/v3/smtp/templates' ); $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), ); $response = wp_remote_get( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 200 === $response_code ) { // 200 OK $response_body = wp_remote_retrieve_body( $response ); $response_body = json_decode( $response_body, true ); if ( empty( $response_body['templates'] ) ) { return array(); } else { return (array) $response_body['templates']; } } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } } public function create_contact( $properties ) { $endpoint = 'https://api.sendinblue.com/v3/contacts'; $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), 'body' => json_encode( $properties ), ); $response = wp_remote_post( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( in_array( $response_code, array( 201, 204 ), true ) ) { $contact_id = wp_remote_retrieve_body( $response ); return $contact_id; } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } return false; } public function send_email( $properties ) { $endpoint = 'https://api.sendinblue.com/v3/smtp/email'; $request = array( 'headers' => array( 'Accept' => 'application/json', 'Content-Type' => 'application/json; charset=utf-8', 'API-Key' => $this->get_api_key(), ), 'body' => json_encode( $properties ), ); $response = wp_remote_post( $endpoint, $request ); $response_code = (int) wp_remote_retrieve_response_code( $response ); if ( 201 === $response_code ) { // 201 Transactional email sent $message_id = wp_remote_retrieve_body( $response ); return $message_id; } elseif ( 400 <= $response_code ) { if ( WP_DEBUG ) { $this->log( $endpoint, $request, $response ); } } return false; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка