| 1 |
<?php |
| 2 |
/** |
| 3 |
* Ubigeo de Perú para WooCommerce y WordPress |
| 4 |
* |
| 5 |
* |
| 6 |
* @link https://renzotejada.com/ |
| 7 |
* @package Ubigeo de Perú para WooCommerce y WordPress |
| 8 |
* @author Renzo Tejada |
| 9 |
* @wordpress-plugin |
| 10 |
* Plugin Name: Ubigeo de Perú para WooCommerce y WordPress |
| 11 |
* Plugin URI: https://renzotejada.com/ubigeo-de-peru-para-woocommerce/ |
| 12 |
* Description: Peru's Ubigeo for WordPress and WooCommerce - Plugin contains the departments - provinces and districts of Peru |
| 13 |
* Version: 4.7.3 |
| 14 |
* Author: Renzo Tejada |
| 15 |
* Author URI: https://renzotejada.com/ |
| 16 |
* License: GPL-2.0-or-later |
| 17 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 18 |
* Text Domain: ubigeo-peru |
| 19 |
* Domain Path: /language |
| 20 |
* Requires at least: 5.6 |
| 21 |
* Requires PHP: 8.0 |
| 22 |
* WC tested up to: 11.0.1 |
| 23 |
* WC requires at least: 2.6 |
| 24 |
*/ |
| 25 |
if (!defined('ABSPATH')) { |
| 26 |
exit; |
| 27 |
} |
| 28 |
|
| 29 |
$plugin_ubigeo_peru_version = get_file_data(__FILE__, array('Version' => 'Version'), false); |
| 30 |
|
| 31 |
define('Version_RT_Ubigeo_Peru', $plugin_ubigeo_peru_version['Version']); |
| 32 |
|
| 33 |
add_action( 'before_woocommerce_init', function() { |
| 34 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 35 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 36 |
} |
| 37 |
} ); |
| 38 |
|
| 39 |
function ubigeo_load_textdomain() |
| 40 |
{ |
| 41 |
load_plugin_textdomain('ubigeo-peru', false, basename(dirname(__FILE__)) . '/language/'); |
| 42 |
} |
| 43 |
|
| 44 |
add_action('init', 'ubigeo_load_textdomain'); |
| 45 |
|
| 46 |
// Agrega la página de settings en plugins |
| 47 |
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'rt_add_plugin_page_settings_link'); |
| 48 |
|
| 49 |
// Agrega link plugins |
| 50 |
add_filter( 'plugin_row_meta', 'rt_ubigeo_plugin_row_meta', 10, 2 ); |
| 51 |
|
| 52 |
// Actualizaciones para el plugin |
| 53 |
add_action( 'plugins_loaded', 'rt_plugin_update_change'); |
| 54 |
|
| 55 |
function rt_ubigeo_plugin_row_meta( $links, $file ) |
| 56 |
{ |
| 57 |
if ( 'ubigeo-peru/ubigeo-peru.php' !== $file ) { |
| 58 |
return $links; |
| 59 |
} |
| 60 |
|
| 61 |
$row_meta = array( |
| 62 |
'docs' => '<a href="' . admin_url('admin.php?page=rt_ubigeo_settings') . '">' . __('Docs', 'ubigeo-peru') . '</a>', |
| 63 |
'support' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/ubigeo-peru/' ) . '">' . esc_html__( 'Support', 'ubigeo-peru' ) . '</a>', |
| 64 |
); |
| 65 |
|
| 66 |
return array_merge( $links, $row_meta ); |
| 67 |
} |
| 68 |
|
| 69 |
function rt_add_plugin_page_settings_link($links) |
| 70 |
{ |
| 71 |
$links2[] = '<a href="' . admin_url('admin.php?page=rt_ubigeo_settings&tab=settings') . '">' . __('Settings', 'ubigeo-peru') . '</a>'; |
| 72 |
$links = array_merge($links2, $links); |
| 73 |
return $links; |
| 74 |
} |
| 75 |
|
| 76 |
/* |
| 77 |
* LIB |
| 78 |
*/ |
| 79 |
require dirname(__FILE__) . "/rt_ubigeo_lib.php"; |
| 80 |
|
| 81 |
/* |
| 82 |
* STANDARD WOOCOMMERCE ADDRESS BRIDGE |
| 83 |
* Sincroniza Provincia/Distrito con state/city para pasarelas y APIs. |
| 84 |
*/ |
| 85 |
require dirname(__FILE__) . "/rt_ubigeo_standard_address.php"; |
| 86 |
|
| 87 |
/* |
| 88 |
* SETUP |
| 89 |
*/ |
| 90 |
require dirname(__FILE__) . "/rt_ubigeo_setup.php"; |
| 91 |
|
| 92 |
register_activation_hook(__FILE__, 'rt_ubigeo_setup'); |
| 93 |
|
| 94 |
/* |
| 95 |
* ADMIN |
| 96 |
*/ |
| 97 |
require dirname(__FILE__) . "/rt_ubigeo_admin.php"; |
| 98 |
|
| 99 |
/* |
| 100 |
* CHECKOUT |
| 101 |
*/ |
| 102 |
if (get_option('ubigeo_checkout_checkbox') == "on") { |
| 103 |
require dirname(__FILE__) . "/rt_ubigeo_checkout.php"; |
| 104 |
} |
| 105 |
|
| 106 |
/* |
| 107 |
* MY ACCOUNT ADDRESS |
| 108 |
* Recupera la edición de Ubigeo en Mi Cuenta sin reactivar el antiguo calculador de carrito. |
| 109 |
*/ |
| 110 |
require dirname(__FILE__) . "/rt_ubigeo_address.php"; |
| 111 |
|