Skip to content

Commit 25a99a2

Browse files
committed
Initial commit.
1 parent 5e35962 commit 25a99a2

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# gp-use-slug-for-downloads
2-
A plugin for GlotPress as a WordPress plugin that uses the translation set slug for the name of the download file name.
1+
# GlotPress Remove Projects from Breadcrumbs
2+
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.
3+

readme.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
=== GP Use Slug for Downloads ===
2+
Contributors: gregross
3+
Donate link: http://toolstack.com/donate
4+
Plugin URI: http://glot-o-matic.com/gp-use-slug-for-downloads
5+
Author URI: http://toolstack.com
6+
Tags: translation, glotpress
7+
Requires at least: 4.4
8+
Tested up to: 4.4
9+
Stable tag: 0.5
10+
License: GPLv2
11+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
12+
13+
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.
14+
15+
== Description ==
16+
17+
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.
18+
19+
== Installation ==
20+
21+
Install from the WordPress plugin directory.
22+
23+
== Frequently Asked Questions ==
24+
25+
= TBD =
26+
27+
TBD
28+
29+
== Changelog ==
30+
31+
= 1.0 =
32+
* Release Date: TBD
33+
* Initial release.
34+
35+
== Upgrade Notice ==
36+
37+
= 1.0 =
38+
39+
Initial release, no upgrade notes at this time.
40+

use-slug-for-downloads.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/*
3+
Plugin Name: GlotPress Use Slug for Downloads
4+
Plugin URI: http://glot-o-matic.com/gp-use-slug-for-downloads
5+
Description: Use the translation set slug for the name of the download file name.
6+
Version: 0.5
7+
Author: gregross
8+
Author URI: http://toolstack.com
9+
Tags: glotpress, glotpress plugin
10+
License: GPLv2
11+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
12+
*/
13+
14+
class GP_Use_Slug_for_Downloads {
15+
public $id = 'use-slug-for-downloads';
16+
17+
public function __construct() {
18+
19+
add_action( 'gp_export_translations_filename', array( $this, 'gp_export_translations_filename' ), 10, 5 );
20+
}
21+
22+
public function gp_export_translations_filename( $filename, $format, $locale, $project, $translation_set ) {
23+
24+
if( $translation_set->slug != '' && $translation_set->slug != 'default' ) {
25+
$filename = $translation_set->slug . '.' . $format->extension;
26+
}
27+
28+
return $filename;
29+
}
30+
31+
}
32+
33+
// 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.
34+
add_action( 'gp_init', 'gp_use_slug_for_downloads_init' );
35+
36+
// This function creates the plugin.
37+
function gp_use_slug_for_downloads_init() {
38+
GLOBAL $gp_use_slug_for_downloads;
39+
40+
$gp_use_slug_for_downloads = new GP_Use_Slug_for_Downloads;
41+
}

0 commit comments

Comments
 (0)