public static function get_instance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; }
/** * Handles POST request when saving the Widget Options form. */ public function update_widget_options() { $notices = Zopim_Notices::get_instance(); $opts = $_POST['widget-options']; update_option(Zopim_Options::ZOPIM_OPTION_WIDGET, $opts); $notices->add_notice('before_udpate_widget_textarea', '<i>' . $this->get_message('options-updated') . '<br/></i>', 'notice'); }
/** * Handles POST request when saving the Widget Options form. */ public function update_widget_options() { $notices = Zopim_Notices::get_instance(); if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'zopim_widget_options')) { update_option(Zopim_Options::ZOPIM_OPTION_SALT, 'wronglogin'); $notices->add_notice('before_udpate_widget_textarea', 'Invalid CSRF token. Please try re-sending the request.', 'error'); } else { $opts = $_POST['widget-options']; update_option(Zopim_Options::ZOPIM_OPTION_WIDGET, $opts); $notices->add_notice('before_udpate_widget_textarea', '<i>' . $this->get_message('options-updated') . '<br/></i>', 'notice'); } }
/** * Determines which page to display when viewing the plugin admin page and then displays it. */ public function zopim_account_config() { $notices = Zopim_Notices::get_instance(); $login = new Zopim_Login(); $linkedView = new Zopim_Linked_View(); ?> <div class="wrap"> <?php if (isset($_GET['action']) && $_GET['action'] == 'deactivate') { update_option(Zopim_Options::ZOPIM_OPTION_SALT, ''); update_option(Zopim_Options::ZOPIM_OPTION_CODE, 'zopim'); } $authenticated = FALSE; if (isset($_POST['action']) && $_POST['action'] == 'login') { $login->do_login(); } if (get_option(Zopim_Options::ZOPIM_OPTION_CODE) != '' && get_option(Zopim_Options::ZOPIM_OPTION_CODE) != 'zopim') { $accountDetails = $this->zopim_get_account_details(get_option(Zopim_Options::ZOPIM_OPTION_SALT)); if (!isset($accountDetails) || isset($accountDetails->error)) { $authError = ' <div class="metabox-holder"> <div class="postbox"> <h3 class="hndle"><span>' . __('Account no longer linked!', 'zopim') . '</span></h3> <div class="zopim-auth-error-message">' . __('We could not verify your Zopim account. Please check your password and try again.', 'zopim') . '</div> </div> </div>'; $notices->add_notice('before_login', $authError, 'error'); } else { $authenticated = TRUE; } } if ($authenticated) { if (isset($_POST['widget-options'])) { $linkedView->update_widget_options(); } $linkedView->display_linked_view($accountDetails); } else { $login->display_login_form(); } }
/** * */ public function display_login_form() { $notices = Zopim_Notices::get_instance(); Zopim_Template::load_template('login-form', array('notices' => $notices, 'messages' => $this->_messages)); }
target="_blank" data-popup="true"> <div class="zopim_btn_orange"><?php echo $messages['launch-dashboard']; ?> </div> </a> (<?php echo $messages['open-tab-label']; ?> ) <form method="post" action="admin.php?page=zopim_account_config"> <?php $notices = Zopim_Notices::get_instance(); $notices->do_notices('before_udpate_widget_textarea'); ?> <p> <?php echo $messages['textarea-label']; ?> <br/> <textarea name="widget-options"><?php echo esc_textarea(Zopim_Options::get_widget_options()); ?> </textarea> <br/> <input class="button-primary" type="submit" value="Update widget options"/> </p> </form>