Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-mendonca committed Feb 7, 2024
2 parents c80c030 + ddac966 commit dc9981c
Show file tree
Hide file tree
Showing 14 changed files with 560 additions and 432 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Toolbox for GlotPress
# GP Toolbox

Set of tools to help you manage your GlotPress.

Expand All @@ -24,6 +24,12 @@ This set of tools extends the functionality of GlotPress, bringing to light any

## Features

* WordPress dashboard:
* Admin menu link to GlotPress menu item.
* Admin menu link to the Tools page.
* GlotPress menu:
* Menu item for GlotPress Tools.
* Menu item for WordPress dashboard.
* GlotPress project page:
* Adds 'Old' and 'Rejected' columns to the project table of Translation Sets.
* Button to quickly and permanently delete 'Old' and 'Rejected' translations.
Expand Down Expand Up @@ -56,3 +62,5 @@ Sure! You are welcome to report any issues or add feature suggestions on the [Gi
* Originals tools page.
* Glossary tools page.
* Translation Sets tools page.
* WordPress dashboard menu items.
* GlotPress menu items.
28 changes: 28 additions & 0 deletions assets/img/glotpress-logo-inverted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions assets/img/glotpress-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions assets/img/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* Intentionally empty file.
*
* It exists to stop directory listings on poorly configured servers.
*
* @package GP_Toolbox
*/

// Silence is golden.
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,18 @@
"optimize-autoloader": true
},
"scripts": {
"i18n": [
"@i18n:pot",
"@i18n:po",
"@i18n:json"
],
"i18n:pot": "wp i18n make-pot . languages/gp-toolbox.pot",
"i18n:po": "wp i18n update-po languages/gp-toolbox.pot languages",
"i18n:json": "wp i18n make-json languages --no-purge",
"build": [
"@lint",
"@compile"
"@compile",
"@i18n"
],
"build:css": "npm run build:css",
"compat:php": "phpcs -v --standard=phpcompat.xml.dist",
Expand Down
2 changes: 1 addition & 1 deletion gp-toolbox.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Toolbox for GlotPress
* GP Toolbox
*
* @package GP_Toolbox
* @link https://github.com/pedro-mendonca/GP_Toolbox
Expand Down
84 changes: 81 additions & 3 deletions includes/class-toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public function __construct() {
// Load things after templates.
add_action( 'gp_post_tmpl_load', array( self::class, 'post_template_load' ), 10, 2 );

// Add GlotPress and Toolbox items do admin menu.
add_action( 'admin_menu', array( self::class, 'admin_menu' ), 10 );

// Add Tools menu item.
add_filter( 'gp_nav_menu_items', array( self::class, 'nav_menu_items' ), 10, 2 );

Expand All @@ -68,7 +71,71 @@ public function __construct() {


/**
* Add Tools menu item.
* Add GlotPress and Tools items do admin menu.
*
* @since 1.0.0
*
* @return void
*/
public static function admin_menu() {

// GlotPress icon.
$svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
<rect x="0" width="20" height="20"/>
<g fill="none">
<path d="M10,0.6c1.269,0,2.5,0.249,3.658,0.738c0.557,0.235,1.094,0.528,1.596,0.867c0.498,0.336,0.966,0.723,1.392,1.149
c0.424,0.426,0.811,0.894,1.147,1.392c0.339,0.502,0.63,1.04,0.867,1.596c0.49,1.158,0.738,2.389,0.738,3.658
c0,1.269-0.249,2.5-0.738,3.658c-0.235,0.558-0.528,1.094-0.867,1.596c-0.336,0.498-0.723,0.966-1.147,1.392
c-0.426,0.426-0.894,0.812-1.392,1.147c-0.502,0.34-1.04,0.631-1.596,0.867C12.5,19.15,11.269,19.398,10,19.398
c-1.269,0-2.5-0.249-3.658-0.738c-0.557-0.235-1.094-0.528-1.596-0.867c-0.498-0.336-0.966-0.722-1.392-1.147
c-0.426-0.426-0.812-0.894-1.147-1.392c-0.341-0.502-0.632-1.04-0.867-1.596C0.849,12.498,0.6,11.268,0.6,9.999
c0-1.269,0.249-2.5,0.739-3.66c0.235-0.556,0.528-1.093,0.867-1.596c0.336-0.498,0.721-0.966,1.147-1.392
C3.78,2.926,4.248,2.539,4.746,2.203c0.502-0.339,1.04-0.63,1.596-0.867C7.5,0.849,8.731,0.6,10,0.6 M10,0c-5.522,0-10,4.476-10,10
c0,5.524,4.477,9.999,10,9.999c5.523,0,10-4.476,10-10C20,4.474,15.522,0,10,0"/>
<path d="M9.986,1.638c-4.611,0-8.348,3.737-8.348,8.348c0,4.612,3.737,8.35,8.348,8.35c4.61,0,8.35-3.738,8.35-8.35
C18.336,5.375,14.597,1.638,9.986,1.638z M15.56,9.99c-0.428,0.336-1.025,0.504-1.792,0.504h-0.74v0.648
c0,0.636,0.069,1.048,0.207,1.234c0.138,0.188,0.46,0.28,0.965,0.28v0.342h-3.585v-0.342c0.492,0,0.812-0.09,0.956-0.27
c0.144-0.18,0.216-0.594,0.216-1.244v-0.675h-0.615c-0.504,0-0.825,0.072-0.963,0.248C10.07,10.892,10,11.504,10,12.152v0.54
c-0.25,0-0.715,0.09-1.387,0.27c-0.673,0.18-1.135,0.27-1.389,0.27c-0.938,0-1.742-0.318-2.414-0.956
c-0.673-0.636-1.009-1.399-1.009-2.289s0.333-1.651,1-2.281C5.467,7.078,6.275,6.76,7.224,6.76c0.781,0,1.423,0.278,1.929,0.842
c0.036-0.06,0.081-0.177,0.135-0.327c0.054-0.15,0.087-0.087,0.099-0.321h0.379v2.578H9.35C9.207,8.828,8.951,8.286,8.587,7.915
C8.221,7.541,7.765,7.323,7.214,7.323c-0.729,0-1.254,0.264-1.57,0.793c-0.316,0.53-0.477,1.154-0.477,1.875
c0,0.709,0.158,1.331,0.477,1.864c0.318,0.534,0.84,0.803,1.572,0.803c0.518,0,0.918-0.09,1.22-0.27
c0.301-0.18,0.438-0.474,0.438-0.883c0-0.312-0.108-0.849-0.27-0.975c-0.162-0.126-0.477-0.189-0.947-0.189V9.999h4.128V8.837
c0-0.649-0.069-1.061-0.207-1.234c-0.138-0.174-0.459-0.261-0.964-0.261V7h3.153c0.756,0,1.352,0.165,1.783,0.497
c0.434,0.33,0.649,0.747,0.649,1.251C16.199,9.239,15.986,9.655,15.56,9.99z M14.631,7.882c0.192,0.228,0.288,0.518,0.288,0.866
c0,0.324-0.099,0.603-0.297,0.838c-0.198,0.234-0.483,0.351-0.855,0.351h-0.74V7.54h0.74C14.151,7.54,14.439,7.654,14.631,7.882z"
/>
</g>
</svg>';

$menu_icon = 'data:image/svg+xml;base64,' . base64_encode( $svg ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode

// Add the new menu item to the admin menu.
add_menu_page(
esc_html__( 'GlotPress', 'gp-toolbox' ), // Page title.
esc_html__( 'GlotPress', 'gp-toolbox' ), // Menu title.
'read', // Capability required to access this menu item.
gp_url_public_root(), // URL.
'', // Callback. @phpstan-ignore-line.
$menu_icon, // Menu icon.
3 // Menu position.
);

if ( self::current_user_is_glotpress_admin() ) {
add_submenu_page(
gp_url_public_root(), // Parent slug.
esc_html__( 'Tools', 'gp-toolbox' ), // Page title.
esc_html__( 'Tools', 'gp-toolbox' ), // Menu title.
'manage_options', // Capability required to access this menu item.
gp_url_join( gp_url_public_root() . '/tools/' ) // URL.
);
}
}


/**
* Add Tools and Dashboard items do side menu.
*
* @since 1.0.0
*
Expand All @@ -88,6 +155,12 @@ public static function nav_menu_items( $items, $location ) {
if ( self::current_user_is_glotpress_admin() ) {
// Add Tools item to admin bar side menu.
$new_item[ strval( gp_url( '/tools/' ) ) ] = esc_html__( 'Tools', 'gp-toolbox' );

// Check if exist a link to Dashboard from another plugin.
if ( ! isset( $new_item[ admin_url() ] ) ) {
// Add link to WP Dashboard.
$new_item[ admin_url() ] = esc_html__( 'Dashboard', 'gp-toolbox' );
}
}
}

Expand Down Expand Up @@ -178,7 +251,7 @@ public static function notice_gp_not_found() {
printf(
/* translators: 1: Plugin name. 2: Error message. */
esc_html__( '%1$s: %2$s', 'gp-toolbox' ),
'<b>' . esc_html_x( 'Toolbox for GlotPress', 'Plugin name', 'gp-toolbox' ) . '</b>',
'<b>' . esc_html_x( 'GP Toolbox', 'Plugin name', 'gp-toolbox' ) . '</b>',
esc_html__( 'GlotPress not found. Please install and activate it.', 'gp-toolbox' )
);
?>
Expand Down Expand Up @@ -344,7 +417,12 @@ public static function register_plugin_styles() {
GP_TOOLBOX_VERSION
);

gp_enqueue_styles( array( 'gp-toolbox', 'dashicons' ) );
gp_enqueue_styles(
array(
'gp-toolbox',
'dashicons',
)
);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"translation-revision-date":"2024-02-07 16:11+0000","generator":"WP-CLI\/2.7.1","source":"assets\/js\/tools-permissions.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"pt_PT","plural-forms":"nplurals=2; plural=(n != 1);"},"Deleting...":["A eliminar..."],"%s Permission found.":["%s permiss\u00e3o encontrada.","%s permiss\u00f5es encontradas."],"No permissions found.":["Nenhuma permiss\u00e3o encontrada."],"Error: %s":["Erro: %s"]}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"translation-revision-date":"2024-02-07 16:11+0000","generator":"WP-CLI\/2.7.1","source":"assets\/js\/project.js","domain":"messages","locale_data":{"messages":{"":{"domain":"messages","lang":"pt_PT","plural-forms":"nplurals=2; plural=(n != 1);"},"Old":["Antigas"],"Rejected":["Rejeitadas"],"Changes requested":[""],"Deleting...":["A eliminar..."]}}}
Binary file modified languages/gp-toolbox-pt_PT.mo
Binary file not shown.
Loading

0 comments on commit dc9981c

Please sign in to comment.