Plugin Directory

Changeset 3255346


Ignore:
Timestamp:
03/13/2025 12:09:08 PM (13 months ago)
Author:
PressLabs
Message:
  • 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
Location:
gitium
Files:
58 added
14 edited

Legend:

Unmodified
Added
Removed
  • gitium/trunk/functions.php

    r3146858 r3255346  
    11<?php
    2 /*  Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>
    3 
    4     This program is free software; you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License, version 2, as
    6     published by the Free Software Foundation.
    7 
    8     This program is distributed in the hope that it will be useful,
    9     but WITHOUT ANY WARRANTY; without even the implied warranty of
    10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11     GNU General Public License for more details.
    12 
    13     You should have received a copy of the GNU General Public License
    14     along with this program; if not, write to the Free Software
    15     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    16 */
     2/**
     3 * Gitium provides automatic git version control and deployment for
     4 * your plugins and themes integrated into wp-admin.
     5 *
     6 * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
     7 *
     8 * Gitium is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * any later version.
     12 *
     13 * Gitium is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with Gitium. If not, see <http://www.gnu.org/licenses/>.
     20 *
     21 * @package         Gitium
     22 */
    1723
    1824function gitium_error_log( $message ) {
     
    419425}
    420426add_action( 'admin_init', 'gitium_admin_init' );
     427
     428add_action('admin_enqueue_scripts', 'enqueue_script_for_gitium_page');
     429function enqueue_script_for_gitium_page($hook) {
     430    // Check if the current page is your plugin's settings page
     431    if ((isset($_GET['page']) && $_GET['page'] === 'gitium/gitium.php') || (isset($_GET['page']) && $_GET['page'] === 'gitium/gitium-settings.php')) {
     432        // Enqueue your JavaScript file
     433        wp_enqueue_script(
     434            'my-plugin-script',  // Handle for the script
     435            plugin_dir_url(__FILE__) . 'js/copy-to-clipboard.js',  // URL to the script
     436            array('jquery'),  // Dependencies
     437            '1.1',  // Version number
     438            true    // Load in footer
     439        );
     440    }
     441}
  • gitium/trunk/gitium-webhook.php

    r3146858 r3255346  
    11<?php
    2 /*  Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>
    3 
    4     This program is free software; you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License, version 2, as
    6     published by the Free Software Foundation.
    7 
    8     This program is distributed in the hope that it will be useful,
    9     but WITHOUT ANY WARRANTY; without even the implied warranty of
    10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11     GNU General Public License for more details.
    12 
    13     You should have received a copy of the GNU General Public License
    14     along with this program; if not, write to the Free Software
    15     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    16 */
     2/**
     3 * Gitium provides automatic git version control and deployment for
     4 * your plugins and themes integrated into wp-admin.
     5 *
     6 * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
     7 *
     8 * Gitium is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * any later version.
     12 *
     13 * Gitium is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with Gitium. If not, see <http://www.gnu.org/licenses/>.
     20 *
     21 * @package         Gitium
     22 */
    1723
    1824header( 'Content-Type: text/html' );
    1925define( 'SHORTINIT', true );
    20 //$wordpress_loader = $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
    21 $wordpress_loader = filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_FULL_SPECIAL_CHARS) . '/wp-load.php';
    2226
    23 require_once $wordpress_loader;
     27$current_dir = __DIR__;
     28
     29// Define an array of possible WordPress root locations
     30$try_wp_roots = [
     31    getenv('DOCUMENT_ROOT'),
     32    filter_input(INPUT_SERVER, 'DOCUMENT_ROOT', FILTER_SANITIZE_FULL_SPECIAL_CHARS),
     33    realpath($current_dir . '/../../../../../'),
     34    realpath($current_dir . '/../../../../'),
     35    realpath($current_dir . '/../../../'), // Typical WordPress structure
     36    realpath($current_dir . '/../../'),    // Alternative structure
     37    realpath($current_dir . '/../'),       // Closer parent directory
     38    $current_dir,                          // Fallback to current directory
     39];
     40
     41$wordpress_loader = null;
     42
     43foreach ($try_wp_roots as $root) {
     44    if ($root && file_exists($root . '/wp-load.php')) {
     45        $wordpress_loader = $root . '/wp-load.php';
     46        break;
     47    }
     48}
     49
     50if ($wordpress_loader) {
     51    require_once $wordpress_loader;
     52} else {
     53    die('Error: Unable to locate wp-load.php. Please verify your WordPress installation.');
     54}
     55
    2456require_once __DIR__ . '/functions.php';
    2557require_once __DIR__ . '/inc/class-git-wrapper.php';
  • gitium/trunk/gitium.php

    r3146858 r3255346  
    11<?php
    22/**
    3  * Plugin Name: Gitium
    4  * Version: 1.0.7
    5  * Author: Presslabs
    6  * Author URI: https://www.presslabs.com
    7  * License: GPL2
    8  * Description: Keep all your code on git version control system.
    9  * Text Domain: gitium
    10  * Domain Path: /languages/
     3 * Plugin Name:     Gitium
     4 * Plugin URI:      https://www.presslabs.com/gitium/
     5 * Description:     Keep all your code on git version control system.
     6 * Author:          PRESSINFRA SRL
     7 * Author URI:      https://www.presslabs.com
     8 * Text Domain:     gitium
     9 * Domain Path:     /languages
     10 * Version:         1.0.7
     11 * License:         GPL3
     12 *
     13 * Gitium provides automatic git version control and deployment for
     14 * your plugins and themes integrated into wp-admin.
     15 *
     16 * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
     17 *
     18 * Gitium is free software: you can redistribute it and/or modify
     19 * it under the terms of the GNU General Public License as published by
     20 * the Free Software Foundation, either version 3 of the License, or
     21 * any later version.
     22 *
     23 * Gitium is distributed in the hope that it will be useful,
     24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     26 * GNU General Public License for more details.
     27 *
     28 * You should have received a copy of the GNU General Public License
     29 * along with Gitium. If not, see <http://www.gnu.org/licenses/>.
     30 *
     31 * @package         Gitium
    1132 */
    12 /*  Copyright 2014-2024 Presslabs <ping@presslabs.com>
    13 
    14     This program is free software; you can redistribute it and/or modify
    15     it under the terms of the GNU General Public License, version 2, as
    16     published by the Free Software Foundation.
    17 
    18     This program is distributed in the hope that it will be useful,
    19     but WITHOUT ANY WARRANTY; without even the implied warranty of
    20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21     GNU General Public License for more details.
    22 
    23     You should have received a copy of the GNU General Public License
    24     along with this program; if not, write to the Free Software
    25     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    26 */
    2733
    2834define( 'GITIUM_LAST_COMMITS', 20 );
  • gitium/trunk/inc/class-git-wrapper.php

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

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

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

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

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

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

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

    r3146858 r3255346  
    11<?php
    2 /*  Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>
    3 
    4     This program is free software; you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License, version 2, as
    6     published by the Free Software Foundation.
    7 
    8     This program is distributed in the hope that it will be useful,
    9     but WITHOUT ANY WARRANTY; without even the implied warranty of
    10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11     GNU General Public License for more details.
    12 
    13     You should have received a copy of the GNU General Public License
    14     along with this program; if not, write to the Free Software
    15     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    16 */
     2/**
     3 * Gitium provides automatic git version control and deployment for
     4 * your plugins and themes integrated into wp-admin.
     5 *
     6 * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
     7 *
     8 * Gitium is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * any later version.
     12 *
     13 * Gitium is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with Gitium. If not, see <http://www.gnu.org/licenses/>.
     20 *
     21 * @package         Gitium
     22 */
    1723
    1824class Gitium_Submenu_Configure extends Gitium_Menu {
     
    153159                <td>
    154160                    <p>
    155                     <input type="text" class="regular-text" name="key_pair" id="key_pair" value="<?php echo esc_attr( $git_public_key ); ?>" readonly="readonly">
    156                     <input type="submit" name="GitiumSubmitRegenerateKeypair" class="button" value="<?php _e( 'Regenerate Key', 'gitium' ); ?>" />
     161                        <input type="text" class="regular-text" name="key_pair" id="key_pair" value="<?php echo esc_attr( $git_public_key ); ?>" readonly="readonly">
     162                        <input type="submit" name="GitiumSubmitRegenerateKeypair" class="button" value="<?php _e( 'Regenerate Key', 'gitium' ); ?>" />
     163                    </p>
     164                    <p>
     165                        <div>
     166                            <button id="copyButton" class="button" data-copy-text="<?php echo esc_attr($git_public_key); ?>">Copy Key Pair</button>
     167                        </div>
    157168                    </p>
    158169                    <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 />
  • gitium/trunk/inc/class-gitium-submenu-settings.php

    r3146858 r3255346  
    11<?php
    2 /*  Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>
    3 
    4     This program is free software; you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License, version 2, as
    6     published by the Free Software Foundation.
    7 
    8     This program is distributed in the hope that it will be useful,
    9     but WITHOUT ANY WARRANTY; without even the implied warranty of
    10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11     GNU General Public License for more details.
    12 
    13     You should have received a copy of the GNU General Public License
    14     along with this program; if not, write to the Free Software
    15     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    16 */
     2/**
     3 * Gitium provides automatic git version control and deployment for
     4 * your plugins and themes integrated into wp-admin.
     5 *
     6 * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
     7 *
     8 * Gitium is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * any later version.
     12 *
     13 * Gitium is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with Gitium. If not, see <http://www.gnu.org/licenses/>.
     20 *
     21 * @package         Gitium
     22 */
    1723
    1824class Gitium_Submenu_Settings extends Gitium_Menu {
     
    6470            <td>
    6571              <p><code id="webhook-url"><?php echo esc_url( gitium_get_webhook() ); ?></code>
    66               <?php if ( ! defined( 'GIT_WEBHOOK_URL' ) || GIT_WEBHOOK_URL == '' ) : ?>
    67               <input type="submit" name="GitiumSubmitRegenerateWebhook" class="button" value="<?php _e( 'Regenerate Webhook', 'gitium' ); ?>" />
    68                           <a class="button" href="<?php echo esc_url( gitium_get_webhook() ); ?>" target="_blank">Merge changes</a></p>
    69               <?php endif; ?>
    70               <p class="description"><?php _e( 'Pinging this URL triggers an update from remote repository.', 'gitium' ); ?></p>
     72                <?php if ( ! defined( 'GIT_WEBHOOK_URL' ) || GIT_WEBHOOK_URL == '' ) : ?>
     73                <input type="submit" name="GitiumSubmitRegenerateWebhook" class="button" value="<?php _e( 'Regenerate Webhook', 'gitium' ); ?>" />
     74                            <a class="button" href="<?php echo esc_url( gitium_get_webhook() ); ?>" target="_blank">Merge changes</a></p>
     75                <?php endif; ?>
     76                <p>
     77                    <div>
     78                        <button id="copyButton" class="button" data-copy-text="<?php echo esc_url( gitium_get_webhook() ) ?>">Copy Webhook URL</button>
     79                    </div>
     80                </p>
     81                <p class="description"><?php _e( 'Pinging this URL triggers an update from remote repository.', 'gitium' ); ?></p>
    7182            </td>
    7283        </tr>
  • gitium/trunk/inc/class-gitium-submenu-status.php

    r3146858 r3255346  
    11<?php
    2 /*  Copyright 2014-2016 Presslabs SRL <ping@presslabs.com>
    3 
    4     This program is free software; you can redistribute it and/or modify
    5     it under the terms of the GNU General Public License, version 2, as
    6     published by the Free Software Foundation.
    7 
    8     This program is distributed in the hope that it will be useful,
    9     but WITHOUT ANY WARRANTY; without even the implied warranty of
    10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11     GNU General Public License for more details.
    12 
    13     You should have received a copy of the GNU General Public License
    14     along with this program; if not, write to the Free Software
    15     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    16 */
     2/**
     3 * Gitium provides automatic git version control and deployment for
     4 * your plugins and themes integrated into wp-admin.
     5 *
     6 * Copyright (C) 2014-2025 PRESSINFRA SRL <ping@presslabs.com>
     7 *
     8 * Gitium is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * any later version.
     12 *
     13 * Gitium is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with Gitium. If not, see <http://www.gnu.org/licenses/>.
     20 *
     21 * @package         Gitium
     22 */
    1723
    1824class Gitium_Submenu_Status extends Gitium_Menu {
     
    95101
    96102    public function save_changes() {
    97         $gitium_save_changes = filter_input(INPUT_POST, 'GitiumSubmitSaveChanges', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
     103        $gitium_save_changes = filter_input(INPUT_POST, 'GitiumSubmitSaveChanges', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
    98104        $gitium_commit_msg = filter_input(INPUT_POST, 'commitmsg', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
    99         if ( ! isset( $gitium_save_changes ) ) {
     105
     106        if ( ! isset( $gitium_save_changes ) ) {
    100107            return;
    101108        }
     109   
    102110        check_admin_referer( 'gitium-admin' );
    103 
     111       
    104112        gitium_enable_maintenance_mode() or wp_die( __( 'Could not enable the maintenance mode!', 'gitium' ) );
    105         $this->git->add();
     113       
    106114        $commitmsg = sprintf( __( 'Merged changes from %s on %s', 'gitium' ), get_site_url(), date( 'm.d.Y' ) );
     115       
    107116        if ( isset( $gitium_commit_msg ) && ! empty( $gitium_commit_msg ) ) {
    108117            $commitmsg = $gitium_commit_msg;
    109118        }
     119
     120        $commits = array();
     121
    110122        $current_user = wp_get_current_user();
    111         $commit = $this->git->commit( $commitmsg, $current_user->display_name, $current_user->user_email );
    112         if ( ! $commit ) {
    113             $this->redirect( __( 'Could not commit!', 'gitium' ) );
    114         }
    115         $merge_success = gitium_merge_and_push( $commit );
     123       
     124        // Get local status and behind commits
     125        $local_status = $this->git->local_status();
     126        $behind_commits = count( $this->git->get_behind_commits() );
     127       
     128        if ( $this->git->is_dirty() && $this->git->add() > 0 ) {
     129            $commit = $this->git->commit( $commitmsg, $current_user->display_name, $current_user->user_email );
     130            if ( ! $commit ) {
     131                gitium_disable_maintenance_mode();
     132                $this->redirect( __( 'Could not commit!', 'gitium' ) );
     133            }
     134            $commits[] = $commit;
     135        }
     136
     137        $merge_success = gitium_merge_and_push( $commits );
     138       
    116139        gitium_disable_maintenance_mode();
     140       
    117141        if ( ! $merge_success ) {
    118142            $this->redirect( __( 'Merge failed: ', 'gitium' ) . $this->git->get_last_error() );
    119143        }
    120         $this->success_redirect( sprintf( __( 'Pushed commit: `%s`', 'gitium' ), $commitmsg ) );
     144       
     145        // Determine message based on previous conditions
     146        if ( $behind_commits > 0 && empty( $local_status[1] ) ) {
     147            $this->success_redirect( sprintf( __( 'Pull done!', 'gitium' ) ) );
     148        } else{
     149            $this->success_redirect( sprintf( __( 'Pushed commit: `%s`', 'gitium' ), $commitmsg ) );
     150        }
    121151    }
    122152
     
    194224        <?php
    195225    }
    196 
    197     private function show_git_changes_table_submit_buttons( $changes ) {
    198         if ( ! empty( $changes ) ) : ?>
    199             <p>
    200             <label for="save-changes"><?php _e( 'Commit message', 'gitium' ); ?>:</label>
    201             <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' ) ); ?>" />
    202             </p>
    203             <p>
    204             <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;
    205             </p>
    206         <?php endif;
    207     }
     226   
     227   private function show_git_changes_table_submit_buttons( $changes ) {
     228        // Get local status and behind commits
     229        $local_status = $this->git->local_status();
     230        $behind_commits = count( $this->git->get_behind_commits() );
     231
     232        // Determine button value based on conditions
     233        if ( $behind_commits > 0 && !empty( $local_status[1] ) ) {
     234            $button_value = __( 'Pull & Push changes', 'gitium' );
     235        } else if ( $behind_commits > 0 ) {
     236            $button_value = __( 'Pull changes', 'gitium' );
     237        } else if ( !empty( $local_status[1] ) ) {
     238            $button_value = __( 'Push changes', 'gitium' );
     239        }
     240
     241        // Check if there are any changes to display the form
     242        if ( !empty( $changes ) ) : ?>
     243            <p>
     244                <label for="save-changes"><?php _e( 'Commit message', 'gitium' ); ?>:</label>
     245                <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' ) ); ?>" />
     246            </p>
     247            <p>
     248                <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;
     249            </p>
     250        <?php endif;
     251    }
    208252
    209253    private function changes_page() {
  • gitium/trunk/readme.txt

    r3146858 r3255346  
    55Tags: git, version, versioning, deployment, version-control, github, bitbucket, travis, code, revision, testing, development, branch, production, staging, debug, plugin, gitium, presslabs, simple
    66Requires at least: 4.7
    7 Tested up to: 6.6
    8 Requires PHP: 5.6
    9 License: GPLv2
    10 Stable tag: 1.0.7
     7Tested up to: 6.7.2
     8Requires PHP: 7.4
     9License: GPLv3
     10Stable tag: 1.2.0
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1212
     
    123123
    124124== Upgrade Notice ==
    125 = 1.0.7 =
    126 PHP8.1 compatibility, check if gitignore is already defined and add HOME env
     125= 1.2.0 =
     126Updated licenses to GPLv3. Updated the check for the wp-load.php file.
    127127
    128128== Changelog ==
     129
     130= 1.2.0 =
     131* Changed the license for all files to GPLv3
     132* 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
     133
     134= 1.1.0 =
     135* Fix: In some cases, the website was stuck in maintenance when it was pulling the changes from remote
     136* Added: A copy-to-clipboard button was introduced for copying ssh key-pair and webhook url
    129137
    130138= 1.0.7 =
Note: See TracChangeset for help on using the changeset viewer.