| Server IP : 63.32.33.223 / Your IP : 172.31.23.231 Web Server : Apache/2.4.68 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/3.0.2 System : Linux ip-172-31-10-208.eu-west-1.compute.internal 6.8.0-1044-aws #46~22.04.1-Ubuntu SMP Tue Dec 2 12:52:18 UTC 2025 x86_64 User : kazang ( 1006) PHP Version : 8.2.31 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,exec,system,passthru,shell_exec,proc_open,popen MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/kazang/web/kazang.com/public_html/wp-content/plugins/redirection/models/importer/ |
Upload File : |
<?php
/**
* @phpstan-type ImporterInfo array{
* id: string,
* name: string,
* total: int
* }
*/
abstract class Red_Plugin_Importer {
/**
* @return list<array{id: string, name: string, total: int}>
*/
public static function get_plugins(): array {
$results = array();
$importers = array(
'wp-simple-redirect',
'seo-redirection',
'safe-redirect-manager',
'wordpress-old-slugs',
'rank-math',
'quick-redirects',
'pretty-links',
);
foreach ( $importers as $importer_id ) {
$importer = self::get_importer( $importer_id );
if ( ! $importer instanceof Red_Plugin_Importer ) {
continue;
}
$data = $importer->get_data();
if ( $data === false || $data['total'] === 0 ) {
continue;
}
$results[] = $data;
}
return $results;
}
/**
* Get an importer instance by ID.
*
* @param string $id Importer identifier.
* @return Red_Plugin_Importer|false
*/
public static function get_importer( string $id ) {
if ( $id === 'wp-simple-redirect' ) {
return new Red_Simple301_Importer();
}
if ( $id === 'seo-redirection' ) {
return new Red_SeoRedirection_Importer();
}
if ( $id === 'safe-redirect-manager' ) {
return new Red_SafeRedirectManager_Importer();
}
if ( $id === 'wordpress-old-slugs' ) {
return new Red_WordPressOldSlug_Importer();
}
if ( $id === 'rank-math' ) {
return new Red_RankMath_Importer();
}
if ( $id === 'quick-redirects' ) {
return new Red_QuickRedirect_Importer();
}
if ( $id === 'pretty-links' ) {
return new Red_PrettyLinks_Importer();
}
return false;
}
/**
* Import all redirects for a plugin ID into a target group.
*
* @param string $plugin Importer identifier.
* @param int $group_id Target group ID.
* @return int Number of imported redirects.
*/
public static function import( $plugin, $group_id ) {
$importer = self::get_importer( $plugin );
if ( $importer !== false ) {
return $importer->import_plugin( $group_id );
}
return 0;
}
/**
* Import using a specific importer instance.
*
* @param int $group_id Target group ID.
* @return int Number of imported redirects.
*/
abstract public function import_plugin( $group_id );
/**
* Get importer summary data used by UI/CLI.
*
* @return ImporterInfo|false
*/
abstract public function get_data();
}