Making WordPress.org


Ignore:
Timestamp:
04/30/2017 04:00:54 PM (9 years ago)
Author:
ocean90
Message:

Plugin Directory: Introduce I18n_Import::get_plugin_svn_url() and use it in the code/readme importers.

Also move the constructor to the parent class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/cli/i18n/class-i18n-import.php

    r4223 r5444  
    11<?php
    22namespace WordPressdotorg\Plugin_Directory\CLI\I18N;
     3
     4use WordPressdotorg\Plugin_Directory\CLI\Import;
    35use WordPressdotorg\Plugin_Directory\Plugin_I18n;
    46use WordPressdotorg\Plugin_Directory\Tools\Filesystem;
    57use WP_Error;
    6 
    78
    89/**
     
    1213 */
    1314abstract class I18n_Import {
     15
     16    /**
     17     * Slug of the plugin.
     18     *
     19     * @var string
     20     */
     21    protected $plugin;
     22
     23    /**
     24     * Constructor.
     25     *
     26     * @param string $plugin The plugin slug.
     27     */
     28    public function __construct( $plugin ) {
     29        $this->plugin = $plugin;
     30    }
     31
     32    /**
     33     * Imports a specific tag to GlotPress.
     34     *
     35     * @param string $tag SVN tag of the import.
     36     *
     37     * @throws Exception
     38     */
     39    abstract public function import_from_tag( $tag );
     40
     41    /**
     42     * Returns the SVN URL for a plugins tag.
     43     *
     44     * @param string $tag SVN tag or 'trunk'.
     45     * @return string Plugins SVN URL.
     46     */
     47    public function get_plugin_svn_url( $tag ) {
     48        if ( 'trunk' === $tag ) {
     49            return Import::PLUGIN_SVN_BASE . "/{$this->plugin}/trunk/";
     50        } else {
     51            return Import::PLUGIN_SVN_BASE . "/{$this->plugin}/tags/{$tag}/";
     52        }
     53    }
    1454
    1555    /**
Note: See TracChangeset for help on using the changeset viewer.