updated plugin Gitium version 1.2.1

This commit is contained in:
KawaiiPunk 2025-04-29 21:19:11 +00:00 committed by Gitium
parent d652fac5a4
commit c53f9e0e50
15 changed files with 458 additions and 243 deletions

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
function gitium_error_log( $message ) { function gitium_error_log( $message ) {
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { return; } if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { return; }
@ -418,3 +424,18 @@ function gitium_admin_init() {
} }
} }
add_action( 'admin_init', 'gitium_admin_init' ); add_action( 'admin_init', 'gitium_admin_init' );
add_action('admin_enqueue_scripts', 'enqueue_script_for_gitium_page');
function enqueue_script_for_gitium_page($hook) {
// Check if the current page is your plugin's settings page
if ((isset($_GET['page']) && $_GET['page'] === 'gitium/gitium.php') || (isset($_GET['page']) && $_GET['page'] === 'gitium/gitium-settings.php')) {
// Enqueue your JavaScript file
wp_enqueue_script(
'my-plugin-script', // Handle for the script
plugin_dir_url(__FILE__) . 'js/copy-to-clipboard.js', // URL to the script
array('jquery'), // Dependencies
'1.1', // Version number
true // Load in footer
);
}
}

View File

@ -1,26 +1,58 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
header( 'Content-Type: text/html' ); header( 'Content-Type: text/html' );
define( 'SHORTINIT', true ); define( 'SHORTINIT', true );
//$wordpress_loader = $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
$wordpress_loader = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '/wp-load.php';
require_once $wordpress_loader; $current_dir = __DIR__;
// Define an array of possible WordPress root locations
$try_wp_roots = [
getenv('DOCUMENT_ROOT'),
filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
realpath($current_dir . '/../../../../../'),
realpath($current_dir . '/../../../../'),
realpath($current_dir . '/../../../'), // Typical WordPress structure
realpath($current_dir . '/../../'), // Alternative structure
realpath($current_dir . '/../'), // Closer parent directory
$current_dir, // Fallback to current directory
];
$wordpress_loader = null;
foreach ($try_wp_roots as $root) {
if ($root && file_exists($root . '/wp-load.php')) {
$wordpress_loader = $root . '/wp-load.php';
break;
}
}
if ($wordpress_loader) {
require_once $wordpress_loader;
} else {
die('Error: Unable to locate wp-load.php. Please verify your WordPress installation.');
}
require_once __DIR__ . '/functions.php'; require_once __DIR__ . '/functions.php';
require_once __DIR__ . '/inc/class-git-wrapper.php'; require_once __DIR__ . '/inc/class-git-wrapper.php';

View File

@ -1,29 +1,35 @@
<?php <?php
/** /**
* Plugin Name: Gitium * Plugin Name: Gitium
* Version: 1.0.7 * Plugin URI: https://www.presslabs.com/gitium/
* Author: Presslabs * Description: Keep all your code on git version control system.
* Author URI: https://www.presslabs.com * Author: PRESSINFRA SRL
* License: GPL2 * Author URI: https://www.presslabs.com
* Description: Keep all your code on git version control system. * Text Domain: gitium
* Text Domain: gitium * Domain Path: /languages
* Domain Path: /languages/ * Version: 1.2.1
* License: GPL3
*
* Gitium provides automatic git version control and deployment for
* your plugins and themes integrated into wp-admin.
*
* Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
* Gitium is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Gitium is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/ */
/* Copyright 2014-2024 Presslabs <ping@presslabs.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define( 'GITIUM_LAST_COMMITS', 20 ); define( 'GITIUM_LAST_COMMITS', 20 );
define( 'GITIUM_MIN_GIT_VER', '1.7' ); define( 'GITIUM_MIN_GIT_VER', '1.7' );

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
if (!defined('GITIGNORE')) if (!defined('GITIGNORE'))
define('GITIGNORE', <<<EOF define('GITIGNORE', <<<EOF

View File

@ -1,20 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Admin { class Gitium_Admin {
public function __construct() { public function __construct() {

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Help { class Gitium_Help {

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Menu_Bubble extends Gitium_Menu { class Gitium_Menu_Bubble extends Gitium_Menu {

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Menu { class Gitium_Menu {

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Requirements { class Gitium_Requirements {

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Submenu_Commits extends Gitium_Menu { class Gitium_Submenu_Commits extends Gitium_Menu {

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Submenu_Configure extends Gitium_Menu { class Gitium_Submenu_Configure extends Gitium_Menu {
@ -152,8 +158,13 @@ class Gitium_Submenu_Configure extends Gitium_Menu {
<th scope="row"><label for="key_pair"><?php _e( 'Key pair', 'gitium' ); ?></label></th> <th scope="row"><label for="key_pair"><?php _e( 'Key pair', 'gitium' ); ?></label></th>
<td> <td>
<p> <p>
<input type="text" class="regular-text" name="key_pair" id="key_pair" value="<?php echo esc_attr( $git_public_key ); ?>" readonly="readonly"> <input type="text" class="regular-text" name="key_pair" id="key_pair" value="<?php echo esc_attr( $git_public_key ); ?>" readonly="readonly">
<input type="submit" name="GitiumSubmitRegenerateKeypair" class="button" value="<?php _e( 'Regenerate Key', 'gitium' ); ?>" /> <input type="submit" name="GitiumSubmitRegenerateKeypair" class="button" value="<?php _e( 'Regenerate Key', 'gitium' ); ?>" />
</p>
<p>
<div>
<button id="copyButton" class="button" data-copy-text="<?php echo esc_attr($git_public_key); ?>">Copy Key Pair</button>
</div>
</p> </p>
<p class="description"><?php _e( 'If your code use ssh keybased authentication for git you need to allow write access to your repository using this key.', 'gitium' ); ?><br /> <p class="description"><?php _e( 'If your code use ssh keybased authentication for git you need to allow write access to your repository using this key.', 'gitium' ); ?><br />
<?php _e( 'Checkout instructions for <a href="https://help.github.com/articles/generating-ssh-keys#step-3-add-your-ssh-key-to-github" target="_blank">github</a> or <a href="https://confluence.atlassian.com/display/BITBUCKET/Add+an+SSH+key+to+an+account#AddanSSHkeytoanaccount-HowtoaddakeyusingSSHforOSXorLinux" target="_blank">bitbucket</a>.', 'gitium' ); ?> <?php _e( 'Checkout instructions for <a href="https://help.github.com/articles/generating-ssh-keys#step-3-add-your-ssh-key-to-github" target="_blank">github</a> or <a href="https://confluence.atlassian.com/display/BITBUCKET/Add+an+SSH+key+to+an+account#AddanSSHkeytoanaccount-HowtoaddakeyusingSSHforOSXorLinux" target="_blank">bitbucket</a>.', 'gitium' ); ?>

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Submenu_Settings extends Gitium_Menu { class Gitium_Submenu_Settings extends Gitium_Menu {
@ -63,11 +69,16 @@ class Gitium_Submenu_Settings extends Gitium_Menu {
<th><label for="webhook-url"><?php _e( 'Webhook URL', 'gitium' ); ?>:</label></th> <th><label for="webhook-url"><?php _e( 'Webhook URL', 'gitium' ); ?>:</label></th>
<td> <td>
<p><code id="webhook-url"><?php echo esc_url( gitium_get_webhook() ); ?></code> <p><code id="webhook-url"><?php echo esc_url( gitium_get_webhook() ); ?></code>
<?php if ( ! defined( 'GIT_WEBHOOK_URL' ) || GIT_WEBHOOK_URL == '' ) : ?> <?php if ( ! defined( 'GIT_WEBHOOK_URL' ) || GIT_WEBHOOK_URL == '' ) : ?>
<input type="submit" name="GitiumSubmitRegenerateWebhook" class="button" value="<?php _e( 'Regenerate Webhook', 'gitium' ); ?>" /> <input type="submit" name="GitiumSubmitRegenerateWebhook" class="button" value="<?php _e( 'Regenerate Webhook', 'gitium' ); ?>" />
<a class="button" href="<?php echo esc_url( gitium_get_webhook() ); ?>" target="_blank">Merge changes</a></p> <a class="button" href="<?php echo esc_url( gitium_get_webhook() ); ?>" target="_blank">Merge changes</a></p>
<?php endif; ?> <?php endif; ?>
<p class="description"><?php _e( 'Pinging this URL triggers an update from remote repository.', 'gitium' ); ?></p> <p>
<div>
<button id="copyButton" class="button" data-copy-text="<?php echo esc_url( gitium_get_webhook() ) ?>">Copy Webhook URL</button>
</div>
</p>
<p class="description"><?php _e( 'Pinging this URL triggers an update from remote repository.', 'gitium' ); ?></p>
</td> </td>
</tr> </tr>
<?php <?php

View File

@ -1,19 +1,25 @@
<?php <?php
/* Copyright 2014-2016 Presslabs SRL <ping@presslabs.com> /**
* Gitium provides automatic git version control and deployment for
This program is free software; you can redistribute it and/or modify * your plugins and themes integrated into wp-admin.
it under the terms of the GNU General Public License, version 2, as *
published by the Free Software Foundation. * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
*
This program is distributed in the hope that it will be useful, * Gitium is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of * it under the terms of the GNU General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * the Free Software Foundation, either version 3 of the License, or
GNU General Public License for more details. * any later version.
*
You should have received a copy of the GNU General Public License * Gitium is distributed in the hope that it will be useful,
along with this program; if not, write to the Free Software * but WITHOUT ANY WARRANTY; without even the implied warranty of
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*/ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Gitium. If not, see <http://www.gnu.org/licenses/>.
*
* @package Gitium
*/
class Gitium_Submenu_Status extends Gitium_Menu { class Gitium_Submenu_Status extends Gitium_Menu {
@ -94,30 +100,54 @@ class Gitium_Submenu_Status extends Gitium_Menu {
} }
public function save_changes() { public function save_changes() {
$gitium_save_changes = filter_input(INPUT_POST, 'GitiumSubmitSaveChanges', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $gitium_save_changes = filter_input(INPUT_POST, 'GitiumSubmitSaveChanges', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$gitium_commit_msg = filter_input(INPUT_POST, 'commitmsg', FILTER_SANITIZE_FULL_SPECIAL_CHARS); $gitium_commit_msg = filter_input(INPUT_POST, 'commitmsg', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
if ( ! isset( $gitium_save_changes ) ) {
if ( ! isset( $gitium_save_changes ) ) {
return; return;
} }
check_admin_referer( 'gitium-admin' ); check_admin_referer( 'gitium-admin' );
gitium_enable_maintenance_mode() or wp_die( __( 'Could not enable the maintenance mode!', 'gitium' ) ); gitium_enable_maintenance_mode() or wp_die( __( 'Could not enable the maintenance mode!', 'gitium' ) );
$this->git->add();
$commitmsg = sprintf( __( 'Merged changes from %s on %s', 'gitium' ), get_site_url(), date( 'm.d.Y' ) ); $commitmsg = sprintf( __( 'Merged changes from %s on %s', 'gitium' ), get_site_url(), date( 'm.d.Y' ) );
if ( isset( $gitium_commit_msg ) && ! empty( $gitium_commit_msg ) ) { if ( isset( $gitium_commit_msg ) && ! empty( $gitium_commit_msg ) ) {
$commitmsg = $gitium_commit_msg; $commitmsg = $gitium_commit_msg;
} }
$commits = array();
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
$commit = $this->git->commit( $commitmsg, $current_user->display_name, $current_user->user_email );
if ( ! $commit ) { // Get local status and behind commits
$this->redirect( __( 'Could not commit!', 'gitium' ) ); $local_status = $this->git->local_status();
$behind_commits = count( $this->git->get_behind_commits() );
if ( $this->git->is_dirty() && $this->git->add() > 0 ) {
$commit = $this->git->commit( $commitmsg, $current_user->display_name, $current_user->user_email );
if ( ! $commit ) {
gitium_disable_maintenance_mode();
$this->redirect( __( 'Could not commit!', 'gitium' ) );
}
$commits[] = $commit;
} }
$merge_success = gitium_merge_and_push( $commit );
$merge_success = gitium_merge_and_push( $commits );
gitium_disable_maintenance_mode(); gitium_disable_maintenance_mode();
if ( ! $merge_success ) { if ( ! $merge_success ) {
$this->redirect( __( 'Merge failed: ', 'gitium' ) . $this->git->get_last_error() ); $this->redirect( __( 'Merge failed: ', 'gitium' ) . $this->git->get_last_error() );
} }
$this->success_redirect( sprintf( __( 'Pushed commit: `%s`', 'gitium' ), $commitmsg ) );
// Determine message based on previous conditions
if ( $behind_commits > 0 && empty( $local_status[1] ) ) {
$this->success_redirect( sprintf( __( 'Pull done!', 'gitium' ) ) );
} else{
$this->success_redirect( sprintf( __( 'Pushed commit: `%s`', 'gitium' ), $commitmsg ) );
}
} }
private function show_ahead_and_behind_info( $changes = '' ) { private function show_ahead_and_behind_info( $changes = '' ) {
@ -193,18 +223,32 @@ class Gitium_Submenu_Status extends Gitium_Menu {
</table> </table>
<?php <?php
} }
private function show_git_changes_table_submit_buttons( $changes ) {
// Get local status and behind commits
$local_status = $this->git->local_status();
$behind_commits = count( $this->git->get_behind_commits() );
private function show_git_changes_table_submit_buttons( $changes ) { // Determine button value based on conditions
if ( ! empty( $changes ) ) : ?> if ( $behind_commits > 0 && !empty( $local_status[1] ) ) {
<p> $button_value = __( 'Pull & Push changes', 'gitium' );
<label for="save-changes"><?php _e( 'Commit message', 'gitium' ); ?>:</label> } else if ( $behind_commits > 0 ) {
<input type="text" name="commitmsg" id="save-changes" class="widefat" value="" placeholder="<?php printf( __( 'Merged changes from %s on %s', 'gitium' ), get_site_url(), date( 'm.d.Y' ) ); ?>" /> $button_value = __( 'Pull changes', 'gitium' );
</p> } else if ( !empty( $local_status[1] ) ) {
<p> $button_value = __( 'Push changes', 'gitium' );
<input type="submit" name="GitiumSubmitSaveChanges" class="button-primary button" value="<?php _e( 'Save changes', 'gitium' ); ?>" <?php if ( get_transient( 'gitium_remote_disconnected' ) ) { echo 'disabled="disabled" '; } ?>/>&nbsp; }
</p>
<?php endif; // Check if there are any changes to display the form
} if ( !empty( $changes ) ) : ?>
<p>
<label for="save-changes"><?php _e( 'Commit message', 'gitium' ); ?>:</label>
<input type="text" name="commitmsg" id="save-changes" class="widefat" value="" placeholder="<?php printf( __( 'Merged changes from %s on %s', 'gitium' ), get_site_url(), date( 'm.d.Y' ) ); ?>" />
</p>
<p>
<input type="submit" name="GitiumSubmitSaveChanges" class="button-primary button" value="<?php echo esc_html( $button_value ); ?>" <?php if ( get_transient( 'gitium_remote_disconnected' ) ) { echo 'disabled="disabled" '; } ?>/>&nbsp;
</p>
<?php endif;
}
private function changes_page() { private function changes_page() {
list( , $changes ) = _gitium_status(); list( , $changes ) = _gitium_status();
@ -233,4 +277,4 @@ class Gitium_Submenu_Status extends Gitium_Menu {
_gitium_status( true ); _gitium_status( true );
$this->changes_page(); $this->changes_page();
} }
} }

View File

@ -0,0 +1,38 @@
document.addEventListener('DOMContentLoaded', function() {
const copyButton = document.getElementById('copyButton');
copyButton.addEventListener('click', function() {
// Get the text to copy from the button's data attribute
const textToCopy = copyButton.getAttribute('data-copy-text');
// Check if navigator.clipboard is supported
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(textToCopy)
.then(() => {
alert('Copied to clipboard using navigator: ' + textToCopy);
})
.catch(err => {
console.error('Could not copy text with navigator: ', err);
});
} else {
// Deprecated fallback for older browsers
console.warn('Using deprecated document.execCommand("copy") as a fallback. Update your browser for better clipboard support.');
// Fallback using document.execCommand
const tempTextarea = document.createElement('textarea');
tempTextarea.value = textToCopy;
document.body.appendChild(tempTextarea);
tempTextarea.select();
try {
document.execCommand('copy');
alert('Copied to clipboard (using fallback): ' + textToCopy);
} catch (err) {
console.error('Fallback copy failed: ', err);
}
// Remove the temporary textarea
document.body.removeChild(tempTextarea);
}
});
});

View File

@ -2,13 +2,13 @@
Contributors: PressLabs Contributors: PressLabs
Donate link: https://www.presslabs.com/gitium/ Donate link: https://www.presslabs.com/gitium/
Tags: git, version, versioning, deployment, version-control, github, bitbucket, travis, code, revision, testing, development, branch, production, staging, debug, plugin, gitium, presslabs, simple Tags: git, version control, revision, gitium, presslabs
Requires at least: 4.7 Requires at least: 4.7
Tested up to: 6.6 Tested up to: 6.8
Requires PHP: 5.6 Requires PHP: 7.4
License: GPLv2 License: GPLv3
Stable tag: 1.0.7 Stable tag: 1.2.1
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
Automatic git version control and deployment for your plugins and themes integrated into wp-admin. Automatic git version control and deployment for your plugins and themes integrated into wp-admin.
@ -122,11 +122,22 @@ Submodules are currently not supported.
Please report security bugs found in the source code of the Gitium plugin through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/gitium). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin. Please report security bugs found in the source code of the Gitium plugin through the [Patchstack Vulnerability Disclosure Program](https://patchstack.com/database/vdp/gitium). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
== Upgrade Notice == == Upgrade Notice ==
= 1.0.7 = = 1.2.1 =
PHP8.1 compatibility, check if gitignore is already defined and add HOME env Tested up to WP 6.8
== Changelog == == Changelog ==
= 1.2.1 =
* Tested the compatibility of the plugin with WP 6.8
= 1.2.0 =
* Changed the license for all files to GPLv3
* Fix: In some cases, the WP is configured in another folder. We've made some changes on how we check for the wp-load.php file
= 1.1.0 =
* Fix: In some cases, the website was stuck in maintenance when it was pulling the changes from remote
* Added: A copy-to-clipboard button was introduced for copying ssh key-pair and webhook url
= 1.0.7 = = 1.0.7 =
* Fix: HOME env definition; * Fix: HOME env definition;
* Fix: deprecation warnings in PHP 8.1; * Fix: deprecation warnings in PHP 8.1;