芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/metform/core/integrations/crm/hubspot/loader.php
tab_id = 'mf_crm'; $this->tab_title = esc_html__('CRM & Marketing Integrations', 'metform'); $this->tab_sub_title = esc_html__('All CRM and Marketing integrations info here', 'metform'); $this->sub_tab_id = 'hub'; $this->sub_tab_title = esc_html__('HubSpot', 'metform'); add_action('metform_settings_tab', [$this, 'settings_tab']); add_action('metform_settings_content', [$this, 'settings_tab_content']); add_action('metform_settings_subtab_' . $this->tab_id, [$this, 'sub_tab']); add_action('metform_settings_subtab_content_' . $this->tab_id, [$this, 'sub_tab_content']); add_action('metform_after_store_form_data', [$this, 'hubspot_action'], 10, 4); } public function settings_tab() { Render::tab($this->tab_id, $this->tab_title, $this->tab_sub_title); } public function settings_tab_content() { Render::tab_content($this->tab_id, $this->tab_title); } public function sub_tab() { Render::sub_tab($this->sub_tab_title, $this->sub_tab_id, 'active'); } public function contents() { $data = [ 'lable' => esc_html__('Token', 'metform'), 'name' => 'mf_hubsopt_token', 'description' => '', 'placeholder' => esc_html__('Enter HubSpot token here', 'metform'), ]; $section_id = 'mf_crm'; $current_page = isset($_GET["page"]) ? admin_url("admin.php?page=" . sanitize_text_field(wp_unslash($_GET["page"]))) : ''; $settings_option = \MetForm\Core\Admin\Base::instance()->get_settings_option(); $build_redirect = [ 'redirect_url' => $current_page, 'section_id' => $section_id, 'state' => wp_create_nonce('redirect_nonce_url') ]; if(isset($_GET['state']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['state'])), 'redirect_nonce_url')){ if (isset($_GET['refresh_token']) && isset($_GET['token_type']) && isset($_GET['access_token']) && isset($_GET['expires_in'])) { $token_type = sanitize_text_field(wp_unslash($_GET['token_type'])); $refresh_token = sanitize_text_field(wp_unslash($_GET['refresh_token'])); $access_token = sanitize_text_field(wp_unslash($_GET['access_token'])); $expires_in = sanitize_text_field(wp_unslash($_GET['expires_in'])); $settings_option['mf_hubsopt_token'] = $access_token; $settings_option['mf_hubsopt_refresh_token'] = $refresh_token; $settings_option['mf_hubsopt_token_type'] = $token_type; $settings_option['mf_hubsopt_expires_in'] = $expires_in; // Save the results in a transient named latest_5_posts set_transient('mf_hubsopt_token_transient', $access_token, $expires_in); // Update settings options update_option('metform_option__settings', $settings_option); echo ' '; } } if (!empty($settings_option['mf_hubsopt_token'])) { ?>
esc_html__('Token', 'metform'), 'name' => 'mf_hubsopt_token', 'description' => '', 'placeholder' => esc_html__('Enter Hubsopt token here', 'metform'), ]; Render::textbox($data); $data = [ 'lable' => esc_html__('Refresh Token', 'metform'), 'name' => 'mf_hubsopt_refresh_token', 'description' => '', 'placeholder' => esc_html__('Enter Hubsopt refresh token here', 'metform'), ]; Render::textbox($data); $data = [ 'lable' => esc_html__('Token Tyoe', 'metform'), 'name' => 'mf_hubsopt_token_type', 'description' => '', 'placeholder' => esc_html__('Enter Hubsopt token type here', 'metform'), ]; Render::textbox($data); $data = [ 'lable' => esc_html__('Token Expires In', 'metform'), 'name' => 'mf_hubsopt_expires_in', 'description' => '', 'placeholder' => esc_html__('Enter Hubsopt token expires in here', 'metform'), ]; Render::textbox($data); ?>
sub_tab_id, [$this, 'contents'], 'active'); } /** * @param $form_id * @param $form_data * @param $form_settings */ public function hubspot_action($form_id, $form_data, $form_settings, $attributes) { $hubspot = new Hubspot; if (isset($form_settings['mf_hubspot']) && $form_settings['mf_hubspot'] == '1') { $hubspot->create_contact($form_data, $attributes); } if (isset($form_settings['mf_hubspot_forms']) && $form_settings['mf_hubspot_forms'] == '1') { $hubspot->submit_data($form_id, $form_data); } } } Integration::instance()->init();