晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/rainic/www/oldTZh/wp-content/plugins/powerpack-elements/classes/ |
Upload File : |
<?php
namespace PowerpackElements\Classes;
use PowerpackElements\Classes\PP_Admin_Settings;
/**
* Handles logic for login and registration pages.
*
* @package PowerPack
* @since 1.4.15
*/
/**
* Exit if accessed directly.
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* PP_Login_Register.
*/
final class PP_Login_Register {
/**
* Settings Tab constant.
*/
const SETTINGS_TAB = 'login_register';
private static $cached_data = array();
/**
* Initializing PowerPack maintenance mode.
*
* @since 1.4.15
*/
public static function init() {
add_filter( 'pp_elements_admin_settings_tabs', __CLASS__ . '::render_settings_tab', 10, 1 );
add_action( 'pp_elements_admin_settings_save', __CLASS__ . '::save_settings' );
// add_action( 'login_init', __CLASS__ . '::redirect' );
//add_action( 'init', __CLASS__ . '::login_redirect' );
add_filter( 'authenticate', __CLASS__ . '::auth_redirect', 10, 3 );
add_action( 'wp_logout', __CLASS__ . '::logout_redirect' );
}
/**
* Render settings tab.
*
* Adds Login / Register tab in PowerPack admin settings.
*
* @since 1.4.15
* @param array $tabs Array of existing settings tabs.
*/
public static function render_settings_tab( $tabs ) {
$tabs[ self::SETTINGS_TAB ] = array(
'title' => esc_html__( 'Login / Register', 'powerpack' ),
'show' => ! PP_Admin_Settings::get_option( 'ppwl_hide_login_register_tab' ),
'file' => POWERPACK_ELEMENTS_PATH . 'includes/admin/admin-settings-login-register.php',
'priority' => 355,
);
return $tabs;
}
/**
* Save settings.
*
* Saves setting fields value in options.
*
* @since 2.6.10
*/
public static function save_settings() {
if ( isset( $_POST['pp_login_page'] ) ) {
$login_page = wp_unslash( $_POST['pp_login_page'] );
update_option( 'pp_login_page', $login_page );
}
if ( isset( $_POST['pp_register_page'] ) ) {
$register_page = wp_unslash( $_POST['pp_register_page'] );
update_option( 'pp_register_page', $register_page );
}
}
/**
* Get pages.
*
* Get all pages and create options for select field.
*
* @since 1.4.15
* @param string $selected Selected page for the field.
* @return array $options An array of pages.
*/
public static function get_pages( $selected = '' ) {
if ( empty( self::$cached_data ) ) {
$args = array(
'post_type' => 'page',
'post_status' => 'publish',
'orderby' => 'title',
'order' => 'ASC',
'posts_per_page' => '-1',
'update_post_meta_cache' => false,
);
self::$cached_data = get_posts( $args );
}
$options = '<option value="">' . __( '-- Select --', 'powerpack' ) . '</option>';
if ( count( self::$cached_data ) ) {
foreach ( self::$cached_data as $post ) {
$options .= '<option value="' . $post->ID . '" ' . selected( $selected, $post->ID, false ) . '>' . $post->post_title . '</option>';
}
} else {
$options = '<option value="" disabled>' . __( 'No pages found!', 'powerpack' ) . '</option>';
}
return $options;
}
/**
* Redirect.
*
* Redirects wp-login.php to custom login page or register page.
*
* @since 1.4.15
* @return void
*/
public static function redirect() {
$redirect_to = '';
$page_id = '';
if ( isset( $_REQUEST['interim-login'] ) ) {
return;
}
if ( isset( $_GET['action'] ) && 'register' == $_GET['action'] ) {
$page_id = PP_Admin_Settings::get_option( 'pp_register_page', true );
} else {
if ( ! is_user_logged_in() ) {
$page_id = PP_Admin_Settings::get_option( 'pp_login_page', true );
}
}
if ( ! empty( $page_id ) ) {
$redirect_to = get_permalink( $page_id );
}
if ( ! empty( $redirect_to ) ) {
wp_redirect( $redirect_to );
exit;
}
}
/**
* Login redirect.
*
* Redirects wp-login.php to custom login page.
*
* @since 1.4.15
* @return void
*/
public static function login_redirect() {
$redirect_to = '';
if (
'wp-login.php' == basename( $_SERVER['REQUEST_URI'] ) &&
'GET' == $_SERVER['REQUEST_METHOD']
) {
$page_id = '';
if ( isset( $_GET['action'] ) && 'register' == $_GET['action'] ) {
$page_id = PP_Admin_Settings::get_option( 'pp_register_page', true );
} else {
$page_id = PP_Admin_Settings::get_option( 'pp_login_page', true );
}
if ( ! empty( $page_id ) ) {
$redirect_to = get_permalink( $page_id );
}
}
if ( ! empty( $redirect_to ) ) {
wp_redirect( $redirect_to );
exit;
}
}
/**
* Authentication redirect.
*
* Redirect to custom login page if username and password fields
* left empty.
*
* @since 1.4.15
* @param object $user User object.
* @param string $username User's login name.
* @param string $password User's login password.
* @return object $user
*/
public static function auth_redirect( $user, $username, $password ) {
if ( isset( $_REQUEST['interim-login'] ) ) {
return $user;
}
if ( empty( $username ) || empty( $password ) ) {
$id = PP_Admin_Settings::get_option( 'pp_login_page', true );
if ( ! empty( $id ) ) {
$login_page = get_permalink( $id );
wp_redirect( $login_page );
exit;
}
}
return $user;
}
/**
* Logout redirect.
*
* Redirects to login page after succesful logout.
*
* @since 1.4.15
* @return void
*/
public static function logout_redirect() {
$id = PP_Admin_Settings::get_option( 'pp_login_page', true );
if ( ! empty( $id ) ) {
$login_page = get_permalink( $id );
wp_redirect( $login_page );
exit;
}
}
}
// Initialize the class.
PP_Login_Register::init();