-
Lucas García authoredLucas García authored
wpct-i18n.php 10.64 KiB
<?php
/**
* Plugin Name: Wpct i18n
* Plugin URI: https://git.coopdevs.org/codeccoop/wp/wpct-i18n
* Description: String translation
* Author: Còdec Cooperativa
* Author URI: https://www.codeccoop.org
* Text Domain: wpct-i18n
* Domain Path: /languages
* Version: 1.0.5
*
* @package Wpct_i18n
*/
namespace WPCT_I18N;
use WP_Post;
use WP_Term;
if (!defined('ABSPATH')) {
exit;
}
if (!class_exists('\WPCT_I18N\Wpct_i18n')) :
require_once 'abstracts/class-plugin.php';
define('WPCT_I18N_VERSION', '1.0.5');
class Wpct_i18n extends \WPCT_ABSTRACT\Plugin
{
private $_integration;
public static $name = 'Wpct i18n';
public static $textdomain = 'wpct-i18n';
public static function activate()
{
}
public static function deactivate()
{
}
public function __construct()
{
parent::__construct();
}
public function init()
{
// Hooks
add_filter('wpct_i18n_default_language', [$this, 'default_language'], 10, 2);
add_filter('wpct_i18n_current_language', [$this, 'current_language'], 10, 2);
add_filter('wpct_i18n_active_languages', [$this, 'active_languages'], 10, 2);
add_filter('wpct_i18n_post_language', [$this, 'post_language'], 10, 2);
add_filter('wpct_i18n_post_translations', [$this, 'post_translations'], 10);
add_filter('wpct_i18n_term_translations', [$this, 'term_translations'], 10);
add_filter('wpct_i18n_is_translation', [$this, 'is_translation'], 10);
add_filter('wpct_i18n_translate_post', [$this, 'translate_post'], 10, 2);
add_action('wpct_i18n_language_switcher', [$this, 'language_switcher']);
// Configure integration
if (apply_filters('wpct_is_plugin_active', false, 'polylang/polylang.php')) {
$this->_integration = 'pll';
} elseif (apply_filters('wpct_is_plugin_active', false, 'sitepress-multilingual-cms/sitepress.php')) {