provider = $provider; $this->path = $this->provider->getPath() . '/admin'; add_filter('nsl_update_settings_validate_' . $this->provider->getOptionKey(), array( $this, 'validateSettings' ), 10, 2); } /** * @return NextendSocialProvider */ public function getProvider() { return $this->provider; } /** * @param string $subview * Returns the admin URL for a subview. * * @return string */ public function getUrl($subview = '') { return add_query_arg(array( 'subview' => $subview ), NextendSocialLoginAdmin::getAdminUrl('provider-' . $this->provider->getId())); } /** * @param $newData * @param $postedData * Returns the validated settings for the buttons. * * @return mixed */ public function validateSettings($newData, $postedData) { $newData = $this->provider->validateSettings($newData, $postedData); if (isset($postedData['custom_default_button'])) { if (isset($postedData['custom_default_button_enabled']) && $postedData['custom_default_button_enabled'] == '1') { $newData['custom_default_button'] = $postedData['custom_default_button']; } else { if ($postedData['custom_default_button'] != '') { $newData['custom_default_button'] = ''; } } } if (isset($postedData['custom_icon_button'])) { if (isset($postedData['custom_icon_button_enabled']) && $postedData['custom_icon_button_enabled'] == '1') { $newData['custom_icon_button'] = $postedData['custom_icon_button']; } else { if ($postedData['custom_icon_button'] != '') { $newData['custom_icon_button'] = ''; } } } if (isset($postedData['terms'])) { if (isset($postedData['terms_override']) && $postedData['terms_override'] == '1') { $newData['terms'] = $postedData['terms']; } else { $newData['terms'] = ''; } } if (!empty($postedData['sync_profile']) && is_array($postedData['sync_profile'])) { $sync_profile = $postedData['sync_profile']; if (isset($sync_profile['register'])) { $newData['sync_profile/register'] = intval($sync_profile['register']) ? 1 : 0; } if (isset($sync_profile['login'])) { $newData['sync_profile/login'] = intval($sync_profile['login']) ? 1 : 0; } if (isset($sync_profile['link'])) { $newData['sync_profile/link'] = intval($sync_profile['link']) ? 1 : 0; } } foreach ($postedData as $key => $value) { switch ($key) { case 'login_label': case 'register_label': case 'link_label': case 'unlink_label': $newData[$key] = wp_kses_post($value); break; case 'user_prefix': case 'user_fallback': $value = preg_replace("/[^A-Za-z0-9\-_ ]/", '', $value); /** * The length of WordPress usernames are limited to a maximum of 60 characters. * We should allow a maximum of 28 characters for both prefix and fallback, as the fallback generates 32 character long md5 hashes. * * @see NSLDEV-623 */ if (mb_strlen($value) > 28) { $value = substr($value, 0, 28); } $newData[$key] = $value; break; case 'settings_saved': $newData[$key] = intval($value) ? 1 : 0; break; case 'oauth_redirect_url': $newData[$key] = $value; break; } } return $newData; } /** * Displays a subview if it is set in the URL. */ public function settingsForm() { $subview = !empty($_REQUEST['subview']) ? $_REQUEST['subview'] : ''; $this->displaySubView($subview); } /** * @param $subview * Display the requested subview */ protected function displaySubView($subview) { if (!$this->provider->adminDisplaySubView($subview)) { switch ($subview) { case 'settings': $this->render('settings'); break; case 'buttons': $this->render('buttons'); break; case 'sync-data': if ($this->provider->hasSyncFields() || $this->provider->hasSyncableProfileFields()) { $this->render('sync-data'); } else { if (headers_sent()) { echo ''; } else { wp_redirect($this->provider->getAdmin() ->getUrl()); } exit; } break; case 'usage': $this->render('usage'); break; default: $this->render('getting-started'); break; } } } /** * @param $view * @param bool $showMenu * Enframe the specified part-view with the complete view(header, menu, footer). */ public function render($view, $showMenu = true) { include(self::$globalPath . '/templates/header.php'); $_view = $view; $view = 'providers'; include(self::$globalPath . '/templates/menu.php'); $view = $_view; echo '
'; echo '

' . $this->provider->getLabel() . '

'; if ($showMenu) { include(self::$globalPath . '/templates-provider/menu.php'); } Notices::displayNotices(); if ($view == 'buttons') { include(self::$globalPath . '/templates-provider/buttons.php'); } else if ($view == 'usage') { include(self::$globalPath . '/templates-provider/usage.php'); } else if ($view == 'sync-data') { include(self::$globalPath . '/templates-provider/sync-data.php'); } else { include($this->path . '/' . $view . '.php'); } echo '
'; include(self::$globalPath . '/templates/footer.php'); } /** * Display the Verify part of the settings subview. */ public function renderSettingsHeader() { $provider = $this->provider; $state = $provider->getState(); ?>

If you see error message in the popup check the copied ID and secret or the app itself. Otherwise your settings are fine.', 'nextend-facebook-connect'); ?>

settings->get('tested') == '1') : ?>

-

getLabel()); break; case 'enabled': printf(__('This provider works fine, but you can test it again. If you don’t want to let users register or login with %s anymore you can disable it.', 'nextend-facebook-connect'), $provider->getLabel()); echo '

'; echo '

'; printf(__('This provider is currently enabled, which means that users can register or login via their %s account.', 'nextend-facebook-connect'), $provider->getLabel()); break; } ?>

path . '/fix-redirect-uri.php'; if (file_exists($path)) { echo '

' . $this->provider->getLabel() . '

'; include($path); } } public static function getSiteUrlWithoutPath() { $siteUrl = site_url(); $siteUrlPath = parse_url($siteUrl, PHP_URL_PATH); return $siteUrlPath ? str_replace($siteUrlPath, "", $siteUrl) : $siteUrl; } } NextendSocialProviderAdmin::$globalPath = NSL_PATH . '/admin';