[wordpress插件] Absolute Relative URLs绝对相对URL

wordpress 插件 文章 2020-01-24 16:00 675 0 全屏看文

AI助手支持GPT4.0

评分

100

100

描述

    • Develop/stage in one domain, go live in another.
    • 在一个领域中开发/演出,在另一个领域中上线。

    • Backup a production site from one domain, restore to a test site at another domain.
    • 从一个域备份生产站点,然后还原到另一域的测试站点。

    • Migrate from one domain to another with minimal effort.
    • 轻松地从一个域迁移到另一个域。

    • Ease migration between stand alone and multi-site installations.
    • 简化了独立安装和多站点安装之间的迁移。

    • Ease migration between domain and sub-folder installations.
    • 简化域和子文件夹安装之间的迁移。

    • Switch between ssl and non-ssl sites.
    • 在ssl网站和非ssl网站之间切换。

    • Always present your content in an SEO friendly way.
    • 始终以SEO友好的方式展示您的内容。

    We aim to achieve these capabilities with this plugin.

    我们旨在通过此插件实现这些功能。

    The idea is to remove creator urls as content is produced, and play the current url when content is viewed.

    这个想法是在创建内容时删除创建者URL,并在查看内容时播放当前URL。

    By default, WordPress saves the local url with content, and that makes it a challenge to access your content from a different domaim, even when you have a legitimate reason to do so.

    默认情况下,WordPress会使用内容保存本地url,即使您有正当的理由,也很难从另一个域名访问您的内容。

    This plugin makes your WordPress content adaptable in that you can present content from a domain other than the one in it which it was produced.

    此插件使您的WordPress内容具有适应性,因为您可以呈现其生产域之外的域中的内容。

    It achieves this by saving URLs as relative URLs.

    它通过将URL保存为相对URL来实现。

    At the same time it supports SEO requirements by reverting to absolute URLs when content is viewed.

    同时,它通过在查看内容时恢复为绝对URL来支持SEO要求。

    In addition to moving the whole site to a new domain, you can identify specific domains as being related.

    除了将整个站点移到新域之外,您还可以标识特定的相关域。

    This allows you to copy raw content from one related site and paste it into another.

    这样,您就可以从一个相关站点复制原始内容并将其粘贴到另一个站点中。

    The plugin will recognize the related domain and remove it as it gets saved.

    该插件将识别相关的域,并在保存时将其删除。

    Then it will display the absolute URLs of the current domain when it is viewed.

    然后,它会在查看时显示当前域的绝对URL。

    For the technically inclined, the plugin removes the get_bloginfo(‘url’) and get_bloginfo(‘wpurl’) parts of a URL as content is saved and inserts them again as content is viewed.

    出于技术上的考虑,该插件会在保存内容时删除URL的get_bloginfo('url')和get_bloginfo('wpurl')部分,并在查看内容时再次插入它们。

    We use context and some configurable rules to determine when to apply conversions in both directions.

    我们使用上下文和一些可配置的规则来确定何时在两个方向上应用转化。

    Most of the time you can go with the defaults.

    大多数时候,您可以使用默认值。

    If you have a situation where something doesn’t appear to work, let me know your experience (with as much detail as possible please).

    如果您遇到无法解决问题的情况,请告诉我您的经验(请提供尽可能多的详细信息)。

安装步骤

    1. In WordPress go to Plugins->Add New and locate the plugin (e.g. search ‘absolute relative url’
    2. 在WordPress中,转到“插件”->“添加新项”并找到插件(例如,搜索“绝对相对网址”

    3. Click the install button
    4. 点击安装按钮

    5. Activate the plugin through the ‘Plugins’ menu
    6. 通过“插件”菜单激活插件

    That’s it!

    就是这样!

    Check your database after you’ve saved some content.

    保存一些内容后,请检查数据库。

    URLs should be root relative.

    URL应该是根目录相对的。

    Check your editor.

    检查您的编辑器。

    URLs should be absolute.

    URL应该是绝对的。

    Check the source on your web page.

    检查网页上的来源。

    URLs should be absolute.

    URL应该是绝对的。

    The plugin does not retroactively modify urls in your database unless you manually update content.

    除非您手动更新内容,否则该插件不会追溯修改数据库中的URL。

    However, it can convert urls as needed.

    但是,它可以根据需要转换网址。

    See notes about related sites.

    请参阅有关相关站点的注释。

    Should you stop using the plugin your website will still work as the plugin uses root relative urls and browsers assume the same domain when they see a relative url.

    如果您停止使用该插件,则您的网站仍将正常工作,因为该插件使用的是相对根目录,并且浏览器在看到相对目录时采用相同的域。

    Exceptions would be when a you are running in a subdirectory and that is part of your site url, if you are providing an RSS feed to third parties where absolute urls are required, or if you use the multi-site conversion.

    如果您在子目录中运行并且是站点URL的一部分,则例外,如果您是向需要绝对URL的第三方提供RSS提要,或者您使用多站点转换。

      • New in version 1.6.0
      • 1.6.0版中的新功能

      With the introduction of the WordPress block editor, urls were not being converted to absolute urls when editing content.

      随着WordPress块编辑器的引入,在编辑内容时URL并未转换为绝对URL。

      They were converted properly when viewing content on the front end, and that is where it is important.

      在前端查看内容时,它们已正确转换,这很重要。

      But for consistency, and to meet the intent of the plugin, you now see absolute urls in the block editor.

      但是为了保持一致性并满足插件的意图,您现在可以在块编辑器中看到绝对URL。

      This is enabled by default.

      默认情况下启用。

      You can disable it with the following code in your functions.php:

      您可以在functions.php中使用以下代码禁用它:

      // disable conversion to absolute urls when editing using the block editor

        //在使用块编辑器进行编辑时,禁止转换为绝对URL

      add_filter( 'of_absolute_relative_urls_use_block_editor', function() { return false; } );

      add_filter('of_absolute_relative_urls_use_block_editor',function(){return false;});

      A new feature in this version is the ability to remove and restore the ‘sites/’ part of the upload path when running in a multi-site environment.

      此版本中的一项新功能是能够在多站点环境中运行时删除和还原上载路径的“站点/”部分。

      Unlike url conversions, where most websites will continue to display appropriately when you deactivate this plugin, this feature requires this plugin to be active in order to restore the sites part of the upload path.

      与url转换不同,在大多数情况下,停用该插件后大多数网站将继续正确显示,而此功能要求该插件处于活动状态才能恢复上传路径中的网站部分。

      On the other hand, you should be able to move a stand alone site into a multi-site environment and let this plugin insert the sites part of the upload path without having to convert your database.

      另一方面,您应该能够将独立站点移动到多站点环境中,并让该插件将站点插入上载路径的一部分,而无需转换数据库。

      To enable this feature, add the following filter to your functions.php:

      要启用此功能,请将以下过滤器添加到您的functions.php中:

      // enable multi-site feature for upload path

        //为上传路径启用多站点功能

      add_filter( 'of_absolute_relative_urls_parse_sites_path', function() { return true; } );

      add_filter('of_absolute_relative_urls_parse_sites_path',function(){return true;});

      Tested plugin in a multi-site environment and confirmed that conversion of urls, except for the sites part of the upload path, work as expected.

      在多站点环境中测试了插件,并确认除上载路径中的站点部分外,URL的转换按预期工作。

      In a multi-domain environment, the domain is removed and restored.

      在多域环境中,将删除并还原该域。

      In a multi-folder environment, the domain and folder are removed and restored.

      在多文件夹环境中,将删除并还原域和文件夹。

      This is the same as running stand-alone with a domain only, or in a folder within a domain.

      这与仅在域中或域中的文件夹中独立运行相同。

      Another feature introduced in this version is the ability to disable the conversion to absolute or relative urls.

      此版本中引入的另一个功能是能够禁止转换为绝对或相对URL。

      There are other wordpress plugins that convert to relative urls, but don’t offer the complement.

      还有其他的wordpress插件可以转换为相对网址,但不提供补充。

      Disable the conversion to absolute urls and you have the same functionality.

      禁用到绝对URL的转换,并且您具有相同的功能。

      Or should you want to revert back to having absolute urls stored in the database, disable relative urls, then edit and save content to restore the full urls to your database.

      还是要恢复为在数据库中存储绝对URL,禁用相对URL,然后编辑并保存内容以将完整URL还原到数据库中。

      To disable one or the other, add one of the following to your functions.php:

      要禁用其中一项,请将以下其中一项添加到您的functions.php中:

      // disable absolute url conversion on your website

        //在您的网站上禁用绝对URL转换

      add_filter( 'of_absolute_relative_urls_enable_absolute', function() { return false; } );

      add_filter('of_absolute_relative_urls_enable_absolute',function(){return false;});

      // disable relative url conversion on your website

      //在您的网站上禁用相对网址转换

      add_filter( 'of_absolute_relative_urls_enable_relative', function() { return false; } );

      add_filter('of_absolute_relative_urls_enable_relative',function(){return false;});

      What may be the most poweful new feature is the ability to display your site under your current domain, even when it was created under a different domain, without doing any conversion.

      最有力的新功能是可以在当前域下显示您的网站,即使该网站是在其他域下创建的,也无需进行任何转换。

      That’s right.

      那就对了。

      We’ve enhanced the related sites feature to do real time conversion from existing content, not just new content.

      我们增强了相关网站的功能,可以从现有内容(不仅仅是新内容)进行实时转换。

      You can now migate one domain to another, add a related site for the former domain, and enable related sites for existing content.

      现在,您可以将一个域迁移到另一个域,为前一个域添加一个相关站点,并为现有内容启用相关站点。

      To do this last bit, add the following to your functions.php:

      为此,请将以下内容添加到您的functions.php中:

      // enable related sites feature for existing content

        //为现有内容启用相关站点功能

      add_filter( 'of_absolute_relative_urls_enable_related_sites_existing_content', function() { return true; } );

      add_filter('of_absolute_relative_urls_enable_related_sites_existing_content',function(){return true;});

      When you set up related sites, and the site url and wordpress url are the same, you can now specify either one.

      设置相关网站时,如果网站网址和wordpress网址相同,则可以指定其中一个。

      For example, either of the following will work:

      例如,以下任何一种都可以工作:

      // add a related site using 'site url'

        //使用“站点网址”添加相关站点

      add_filter( 'of_absolute_relative_urls_related_sites',    

      add_filter('of_absolute_relative_urls_related_sites',    

      function( $related_sites ) {        

      函数($ related_sites){        

      $related_sites[]['url'] = "http://apatterson.org/site2";        

      $ related_sites [] ['url'] =“ http://apatterson.org/site2”;        

      return $related_sites;    

      返回$ related_sites;    

      }

      }

      );

      );

      // add a related site using 'wordpress url'

      //使用“ wordpress url”添加相关网站

      add_filter( 'of_absolute_relative_urls_related_sites',    

      add_filter('of_absolute_relative_urls_related_sites',    

      function( $related_sites ) {        

      函数($ related_sites){        

      $related_sites[]['wpurl'] = "http://site2.apatterson.org";        

      $ related_sites [] ['wpurl'] =“ http://site2.apatterson.org”;        

      return $related_sites;    

      返回$ related_sites;    

      }

      }

      );

      );

      One more thing.

      还有一件事。

      We now parse ‘data-link’ urls along with others such as ‘href’ and ‘src’.

      现在,我们将解析“数据链接”网址以及诸如“ href”和“ src”之类的其他网址。

      We discovered these being used in the gallery component of the block editor.

      我们发现这些已在块编辑器的图库组件中使用。

        • New in version 1.5.4
        • 1.5.4版的新功能

        Allow urls from related sites to be saved as relative urls.

        允许将来自相关站点的URL保存为相对URL。

        This makes it easier to copy/paste html content from one site to another (e.g. staging to production, production to development).

        这样可以更轻松地将html内容从一个站点复制/粘贴到另一个站点(例如,从生产到生产,从生产到开发)。

        Note that this doesn’t solve all problems with copy/paste from one site to another.

        请注意,这不能解决从一个站点到另一个站点的复制/粘贴的所有问题。

        For example, if images on one site are in a different folder, they will still need to be tweaked manually.

        例如,如果一个站点上的图像位于另一个文件夹中,则仍然需要手动对其进行调整。

        To add related sites, add a filter and function to your functions.php similar to the following:

        要添加相关站点,请向您的functions.php添加一个过滤器和函数,类似于以下内容:

        // add related sites to be saved as relative urls

          //添加相关站点以保存为相对URL

        add_filter( 'of_absolute_relative_urls_related_sites', 'my_related_sites' );

        add_filter('of_absolute_relative_urls_related_sites','my_related_sites');

        function my_related_sites( $related_sites ) {    

        函数my_related_sites($ related_sites){    

        $related_sites[] = [        

        $ related_sites [] = [        

        'wpurl' => 'https://www.chennabaree.com', // wp url        

        'wpurl'=>'https://www.chennabaree.com',// wp网址        

        'url' => 'https://www.chennabaree.com' // site url    

        'url'=>'https://www.chennabaree.com'//网站网址    

        ];    

        ];    

        $related_sites[] = [        

        $ related_sites [] = [        

        'wpurl' => 'https://www.schoolofunusualarts.com'    

        'wpurl'=>'https://www.schoolofunusualarts.com'    

        ];    

        ];    

        return $related_sites;

        返回$ related_sites;

        }

        }

        Note: if site url and wp url are identical, you only need to specify ‘wpurl’.

        注意:如果网站网址和wp网址相同,则只需指定“ wpurl”。

          • New in version 1.5.0, 1.5.1
          • 1.5.0、1.5.1版中的新功能

          Enable all options instead of specific options.

          启用所有选项,而不是特定选项。

          In functions.php, put:

          在functions.php中,放入:

          // enable all options

            //启用所有选项

          add_filter( 'of_absolute_relative_urls_enable_all', function() { return true; } );

          add_filter('of_absolute_relative_urls_enable_all',function(){return true;});

          Manage filters that get processed by modifying the array of filters.

          管理通过修改过滤器数组处理的过滤器。

          Build a function to add or remove filter names in the array.

          构建一个函数以添加或删除数组中的过滤器名称。

          Then in functions.php, put:

          然后在functions.php中,放入:

          // modify list of filters to include or exclude

            //修改过滤器列表以包含或排除

          add_filter( 'of_absolute_relative_urls_{type}_filters', 'your_function' );

          add_filter('of_absolute_relative_urls_ {type} _filters','您的函数');

          where {type} is ‘view’, ‘save’, ‘option’ or ‘exclude_option’.

          其中{type}为“视图”,“保存”,“选项”或“排除选项”。

下载地址

https://downloads.wordpress.org/plugin/absolute-relative-urls.zip

https://downloads.wordpress.org/plugin/absolute-relative-urls.zip

-EOF-

AI助手支持GPT4.0