Skip to content

Commit d2ea59a

Browse files
committed
Initial commit.
0 parents  commit d2ea59a

3 files changed

Lines changed: 112 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# GlotPress Remove Projects from Breadcrumbs
2+
A plugin for [GlotPress as a WordPress plugin](https://github.com/deliciousbrains/GlotPress) that removes the top level "Projects" link from the breadcrumbs.
3+

readme.txt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
=== GP Remove Projects from Breadcrumbs ===
2+
Contributors: gregross
3+
Donate link: http://toolstack.com/donate
4+
Plugin URI: http://glot-o-matic.com/gp-machine-translate
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 removes the top level "Projects" link from the breadcrumbs.
14+
15+
== Description ==
16+
17+
A plugin for [GlotPress as a WordPress plugin](https://github.com/deliciousbrains/GlotPress) that removes the top level "Projects" link from the breadcrumbs.
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+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/*
3+
Plugin Name: GlotPress Remove Projects from Breadcrumbs
4+
Plugin URI: http://glot-o-matic.com/gp-remove-projects-from-breadcrumbs
5+
Description: Remove the "Projects" link from the breadcrumbs in GlotPress
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_Remove_Projects_From_Breadcrumbs {
15+
public $id = 'gp-remove-projects-from-breadcrumbs';
16+
17+
public $errors = array();
18+
public $notices = array();
19+
20+
public function __construct() {
21+
22+
add_action( 'gp_breadcrumb_items', array( $this, 'gp_breadcrumb_items'), 10, 1 );
23+
add_action( 'gp_nav_menu_items', array( $this, 'gp_nav_menu_items' ), 10, 2 );
24+
add_action( 'gp_logo_url', array( $this, 'gp_logo_url' ), 10, 1 );
25+
}
26+
27+
public function gp_breadcrumb_items( $breadcrums ) {
28+
29+
if( is_array( $breadcrums ) ) {
30+
if( is_array( $breadcrums[0] ) ) {
31+
32+
unset( $breadcrums[0][0] );
33+
}
34+
else {
35+
unset( $breadcrums[0] );
36+
}
37+
}
38+
39+
return $breadcrums;
40+
}
41+
42+
public function gp_nav_menu_items( $items, $locaiton ) {
43+
$as = array_search( __('Projects'), $items );
44+
45+
if( $as !== FALSE ) { unset( $items[$as] ); }
46+
47+
return $items;
48+
}
49+
50+
public function gp_logo_url( $url ) {
51+
52+
if( gp_const_get('GP_REMOVE_PROJECTS_FROM_BREADCRUMS_LOGO_URL') ) {
53+
$url = $url . GP_REMOVE_PROJECTS_FROM_BREADCRUMS_LOGO_URL;
54+
}
55+
56+
return $url;
57+
}
58+
59+
}
60+
61+
// 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.
62+
add_action( 'gp_init', 'gp_remove_projects_from_breadcrumbs_init' );
63+
64+
// This function creates the plugin.
65+
function gp_remove_projects_from_breadcrumbs_init() {
66+
GLOBAL $gp_remove_projects_from_breadcrumbs;
67+
68+
$gp_remove_projects_from_breadcrumbs = new GP_Remove_Projects_From_Breadcrumbs;
69+
}

0 commit comments

Comments
 (0)