晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/www/wp-content/plugins/wpseo-local/classes/ |
Upload File : |
<?php
/**
* Yoast SEO: Local plugin file.
*
* @package WPSEO_Local
*/
/**
* Class: WPSEO_Local_WooCommerce.
*/
class WPSEO_Local_WooCommerce {
/**
* Minimum supported WooCommerce version.
*
* @var string
*/
private $min_woocommerce_version = '2.6';
/**
* Constructor.
*/
public function __construct() {
// Deactivation.
register_deactivation_hook( __FILE__, array( $this, 'flush_transient_cache_for_shipping_methods' ) );
// Actions.
add_action( 'plugins_loaded', array( $this, 'init_local_seo_woocommerce' ), 10 );
// Filters.
add_filter( 'woocommerce_locate_template', array( $this, 'woocommerce_locate_template' ), 10, 3 );
// Hide WooCommerce' own Local Pickup routine, if our shipping method is enabled.
$settings = get_option( 'woocommerce_yoast_wcseo_local_pickup_settings' );
if ( isset( $settings['enabled'] ) && ( $settings['enabled'] === 'yes' ) ) {
add_filter(
'woocommerce_shipping_zone_shipping_methods',
array( $this, 'shipping_zone_shipping_methods' ),
10
);
add_filter(
'woocommerce_shipping_method_description',
array( $this, 'alter_shipping_method_description' ),
10,
2
);
}
}
public function woocommerce_locate_template( $template, $template_name, $template_path ) {
global $woocommerce;
$_template = $template;
if ( ! $template_path ) {
$template_path = $woocommerce->template_url;
}
// Look within passed path within the theme - this is priority.
$template = locate_template(
array(
$template_path . $template_name,
$template_name,
)
);
// Get the template from this plugin, if it exists.
$plugin_path = WPSEO_LOCAL_PATH . 'woocommerce/templates/';
if ( ! $template && file_exists( $plugin_path . $template_name ) ) {
$template = $plugin_path . $template_name;
}
// Use default template.
if ( ! $template ) {
$template = $_template;
}
// Return what we found.
return $template;
}
public function alter_shipping_method_description( $method_description, $instance ) {
if (
is_a( $instance, 'WC_Shipping_Local_Pickup' ) ||
is_a( $instance, 'WC_Shipping_Legacy_Local_Pickup' ) ||
is_a( $instance, 'WC_Shipping_Legacy_Local_Delivery' )
) {
/* translators: %s expands to "Yoast SEO: Local SEO for WooCommerce". */
$method_description .= sprintf( __( '%s disabled this shipping method. To configure local pickup, go to the Local Store Pickup settings.', 'yoast-local-seo' ), 'Yoast SEO: Local SEO for WooCommerce' );
}
return $method_description;
}
public function shipping_zone_shipping_methods( $methods ) {
$local_pickup_found = false;
if ( is_array( $methods ) && ( ! empty( $methods ) ) ) {
foreach ( $methods as $index => $method ) {
// Woo's Local Pickup has been found, issue a warning for the user.
if ( is_a( $method, 'WC_Shipping_Local_Pickup' ) ) {
$local_pickup_found = true;
/* translators: %s expands to "Yoast SEO: Local SEO for WooCommerce". */
$method->method_description .= sprintf( __( '%s disabled this shipping method. To configure local pickup, go to the Local Store Pickup settings.', 'yoast-local-seo' ), 'Yoast SEO: Local SEO for WooCommerce' );
$method->enabled = 'no';
$methods[ $index ] = $method;
}
}
}
// Woo'c local pickup has not been found,... so deactivate it before someone decides to use it.
if ( ! $local_pickup_found ) {
add_filter( 'woocommerce_shipping_methods', array( $this, 'hide_woos_local_pickup' ), 10, 1 );
}
return $methods;
}
public function hide_woos_local_pickup( $available_methods ) {
unset( $available_methods['local_pickup'] );
return $available_methods;
}
public function flush_transient_cache_for_shipping_methods() {
global $wpdb;
$wpdb->query( 'DELETE FROM ' . $wpdb->prefix . "options WHERE option_name LIKE '_transient_wc_ship%'" );
delete_option( 'wordpress-seo-local-deactivated' );
}
/**
* Load the plugin text domain.
*/
public function load_textdomain_local_seo_woocommerce() {
load_plugin_textdomain( 'yoast-local-seo', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}
/**
* Initialize the WooCommerce specific classes.
*/
public function init_local_seo_woocommerce() {
// Check if WooCommerce is active.
$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
if ( in_array( 'woocommerce/woocommerce.php', $active_plugins, true ) ) {
$version = $this->get_woocommerce_version_number();
if ( version_compare( $version, $this->min_woocommerce_version, '>=' ) ) {
// @todo: we can do better than all these 'requires' <= +1 from JRF.
// @todo: Refactor this to auto loading.
// We have the right WooCommerce version, go gadget go...
require_once WPSEO_LOCAL_PATH . 'woocommerce/includes/class-wc-post-types.php';
$wpseo_local_woocommerce_post_types = new Yoast_WCSEO_Local_Post_Types();
$wpseo_local_woocommerce_post_types->init();
require_once WPSEO_LOCAL_PATH . 'woocommerce/shipping/class-wc-shipping.php';
require_once WPSEO_LOCAL_PATH . 'woocommerce/shipping/class-wc-shipping-method.php';
$wpseo_local_woocommerce_shipping = new Yoast_WCSEO_Local_Shipping();
$wpseo_local_woocommerce_shipping->init();
require_once WPSEO_LOCAL_PATH . 'woocommerce/admin/class-wc-transport.php';
require_once WPSEO_LOCAL_PATH . 'woocommerce/admin/class-wc-transport-list.php';
$wpseo_local_woocommerce_transport = new Yoast_WCSEO_Local_Transport();
$wpseo_local_woocommerce_transport->init();
require_once WPSEO_LOCAL_PATH . 'woocommerce/admin/class-admin-columns.php';
require_once WPSEO_LOCAL_PATH . 'woocommerce/emails/class-wc-emails.php';
require_once WPSEO_LOCAL_PATH . 'woocommerce/includes/wpseo-local-woocommerce-functions.php';
require_once WPSEO_LOCAL_PATH . 'woocommerce/admin/class-woocommerce-settings.php';
new WPSEO_Local_Admin_Woocommerce_Settings();
if ( is_admin() ) {
new Yoast_WCSEO_Local_Admin_Columns();
}
}
else {
// User has an old WooCommerce version.
add_action( 'all_admin_notices', array( $this, 'error_outdated_woocommerce' ) );
}
}
}
/**
* Retrieves the version number of the active WooCommerce plugin.
*
* @return string|null The version number or null if it couldn't be determined.
*/
private function get_woocommerce_version_number() {
// If get_plugins() isn't available, require it.
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
// Create the plugins folder and file variables.
$plugin_folder = get_plugins( '/woocommerce' );
$plugin_file = 'woocommerce.php';
// If the plugin version number is set, return it.
if ( isset( $plugin_folder[ $plugin_file ]['Version'] ) ) {
return $plugin_folder[ $plugin_file ]['Version'];
}
else {
// Otherwise return null.
return null;
}
}
/**
* Throw an error if WooCommerce is out of date.
*/
public function error_outdated_woocommerce() {
$this->admin_message(
sprintf(
/* translators: %s expands to "Yoast SEO: Local for WooCommerce". */
__( 'Please upgrade the WooCommerce plugin to the latest version to allow the "%s" plugin to work.', 'yoast-local-seo' ),
$this->_plugin_name
),
'error'
);
}
/**
* Generic admin message.
*
* @param string $message Admin message text.
* @param string $class CSS class name for the admin notice.
*/
private function admin_message( $message, $class ) {
echo '<div class="' . esc_attr( $class ) . '"><p>' . $message . '</p></div>';
}
}