Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
toolstack committed Dec 14, 2015
1 parent 5e35962 commit 25a99a2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# gp-use-slug-for-downloads
A plugin for GlotPress as a WordPress plugin that uses the translation set slug for the name of the download file name.
# GlotPress Remove Projects from Breadcrumbs
A plugin for [GlotPress as a WordPress plugin](https://github.com/deliciousbrains/GlotPress) that uses the translation set slug for the name of the download file name.

40 changes: 40 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
=== GP Use Slug for Downloads ===
Contributors: gregross
Donate link: http://toolstack.com/donate
Plugin URI: http://glot-o-matic.com/gp-use-slug-for-downloads
Author URI: http://toolstack.com
Tags: translation, glotpress
Requires at least: 4.4
Tested up to: 4.4
Stable tag: 0.5
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

A plugin for [GlotPress as a WordPress plugin](https://github.com/deliciousbrains/GlotPress) that uses the translation set slug for the name of the download file name.

== Description ==

A plugin for [GlotPress as a WordPress plugin](https://github.com/deliciousbrains/GlotPress) that uses the translation set slug for the name of the download file name.

== Installation ==

Install from the WordPress plugin directory.

== Frequently Asked Questions ==

= TBD =

TBD

== Changelog ==

= 1.0 =
* Release Date: TBD
* Initial release.

== Upgrade Notice ==

= 1.0 =

Initial release, no upgrade notes at this time.

41 changes: 41 additions & 0 deletions use-slug-for-downloads.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*
Plugin Name: GlotPress Use Slug for Downloads
Plugin URI: http://glot-o-matic.com/gp-use-slug-for-downloads
Description: Use the translation set slug for the name of the download file name.
Version: 0.5
Author: gregross
Author URI: http://toolstack.com
Tags: glotpress, glotpress plugin
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/

class GP_Use_Slug_for_Downloads {
public $id = 'use-slug-for-downloads';

public function __construct() {

add_action( 'gp_export_translations_filename', array( $this, 'gp_export_translations_filename' ), 10, 5 );
}

public function gp_export_translations_filename( $filename, $format, $locale, $project, $translation_set ) {

if( $translation_set->slug != '' && $translation_set->slug != 'default' ) {
$filename = $translation_set->slug . '.' . $format->extension;
}

return $filename;
}

}

// Add an action to WordPress's init hook to setup the plugin. Don't just setup the plugin here as the GlotPress plugin may not have loaded yet.
add_action( 'gp_init', 'gp_use_slug_for_downloads_init' );

// This function creates the plugin.
function gp_use_slug_for_downloads_init() {
GLOBAL $gp_use_slug_for_downloads;

$gp_use_slug_for_downloads = new GP_Use_Slug_for_Downloads;
}

0 comments on commit 25a99a2

Please sign in to comment.