Giter Club home page Giter Club logo

wp-gitlab-updater's Introduction

WordPress plugin and theme updates from private GitLab repos

You can use this as a WordPress plugin (for example, if you have multiple themes and/or plugins in one WP installation, which should be updated with the script), or include it directly in a theme or plugin. The script uses the GitLab tags to check for a new version.

Usage as a WordPress plugin

Just download the repo and upload the ZIP as a new plugin to your WordPress install or use the GitHub updater plugin.

After that, you will find a new options page under SettingsGitLab Updater. There you can find all installed themes and plugins, and fields to insert the needed data to make one or more of them use your GitLab repo as update source.

Search the theme or plugin in the list and insert the following data:

  • Access token is the GitLab API access token (needs »api« and »read_registry« scope. If you use the gitlab.com version, you can create the token here: gitlab.com/profile/personal_access_tokens). The safest way might be to create the access token for an external user with the role »reporter«, who has only access to the theme repo. Project features like wiki and issues can be hidden from external users.
  • GitLab URL needs to be the URL of your GitLab install. For example https://gitlab.com
  • Repo needs to be the identifier of the repo in the format username/repo or group/repo

Bundled inside a plugin or theme

Inside a theme

To bundle it into a theme, you can just grab the src/theme-updater.php and src/updater-base.php and put it into your theme, for example, into a wp-gitlab-updater folder. After that, you can call it like that:

/**
 * Include the file with the ThemeUpdater class.
 */
 require_once 'wp-gitlab-updater/theme-updater.php';
  
/**
 * Init the theme updater.
 */
new Moenus\GitLabUpdater\ThemeUpdater( [
    'slug' => 'SlugOfTheTheme', 
    'access_token' => 'YourGitLabAccessToken',
    'gitlab_url' => 'URLtoGitLabInstall',
    'repo' => 'RepoIdentifier',
] );

The params are the same as explained in the Usage as a WordPress plugin part — slug must be the directory of the theme.

Inside a plugin

For that, take the src/plugin-updater.php and src/updater-base.php, put it into your plugin and call it:

/**
 * Include the file with the PluginUpdater class.
 */
require_once 'wp-gitlab-updater/plugin-updater.php';
  
/**
 * Init the plugin updater with the plugin base name.
 */
new Moenus\GitLabUpdater\PluginUpdater( [
    'slug' => 'SlugOfPlugin', 
    'plugin_base_name' => 'BaseNameOfThePlugin', 
    'access_token' => 'YourGitLabAccessToken', 
    'gitlab_url' => 'URLtoGitLabInstall',
    'repo' => 'RepoIdentifier',
] );

Same params as explained in Usage as a WordPress pluginslug is plugin directory and plugin_base_name the basename (for example, svg-social-menu/svg-social-menu.php).

wp-gitlab-updater's People

Contributors

florianbrinkmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-gitlab-updater's Issues

Example please

Hi,

I know opening an issue is probably not the best way to ask this but I can't get your code to work.

My (private) gitlab repo url is: https://gitlab.com/adtrak-web/easigrass-franchise-new/

And this is my code:
`/**

  • Include the file with the ThemeUpdater class.
    */
    require_once 'wp-gitlab-updater/theme-updater.php';

/**

  • Init the theme updater.
    */
    // $slug = get_stylesheet_directory();
    new Moenus\GitLabUpdater\ThemeUpdater( [
    'slug' => 'easigrass-parent',
    'access_token' => 'glpat-zXKj5xfQkuBxXrPBY8xe',
    'gitlab_url' => 'https://gitlab.com',
    'repo' => '31598612',
    ] );`

I can see the tags on the following url: https://gitlab.com/api/v4/projects/31598612/repository/tags/?private_token=glpat-dLmPWBwd6y7EuCUEx43y

I think it's just the 'slug' variable that I can't seem to get right so can you please give me an example of what it should be?

Thanks!

Update not appearing randomly in some servers

Hi there. Sorry to bother again.. But for some reason it seems the updater doesn't work anymore again, similar to issue #7.

  • I followed the instructions step by step.
  • It's the right token and the access is still active.
  • When trying to get to the URL of the api using a browser, I get the versions as expected.

Actually the script worked once... But only once. (I remember there was even a glitch on the update page. The picture of the theme was "missing" what picture file wordpress is looking for, here?)
But when it happened, I remember the theme was in a folder with a different name than the theme (it was "duenarevival"). And when it updated, it put everything in a new folder with the right name (which was "duena"), while keeping the old version "duenarevival" in its folder. For now I activated the theme with the folder "duena" and deleted the other one. Maybe it's the cause of the problem?

In case you wanna check, here's the repository of the theme with the updater.

error 401 when trying to fetch tags

Hi. I'm trying to bundle this script inside my theme, i followed all the instructions of your repo, but I'm getting the same problem as issue #7 . Except the website where i'm trying it is not in localhost and is hosted outside. I found something odd though.

When I try the command curl --request GET --header with the token and the url, I get the tags fetched as expected:

max@VirtualBox:~$ curl --request GET --header "PRIVATE_TOKEN: XXXXXXXXXXX" https://gitlab.com/api/v4/projects/xxxxxxxx%2Fxxxxxxxxx/repository/tags/
[{"name":"2.2.1","message":"xxxxxxxx!","target":"XXXXXXXXXXX","commit":{"id":"XXXXXXXXXXXXX","short_id":"xxxx",...

But when I try the curl command using the url that the script uses in its code (line 54 in updater-base.php), i get this:

max@VirtualBox:~$ curl https://gitlab.com/api/v4/projects/xxxxxxxx%2Fxxxxxxxxx/repository/tags/?private_token=XXXXXXXXXXX
{"message":"401 Unauthorized"}

It's probably an error with gitlab but i don't understand it and it looks like it's preventing the script to work and fetch update. :/ any idea of what's wrong?

Not working

Is it possible this plugin is not working anymore?

Doesn't working

I did everything right, I included in my theme with correct fields, but it doesn't work. I tested put the url directly and it returns tag data, but no updates shown in my wordpress administration panel.

Prevent crash with theme or plugin updates from W.org with the same slug

Currently, the script does not consider conflicts with theme or plugin updates from the W.org repo, where the slug is identical with a theme or plugin which uses the script.

Should be possible to check for that inside the theme_update() and plugin_update() method. If this runs after the core adds available updates from W.org to the transient, we can check there if a W.org update is set for our theme/plugin, and unset it.

this not working

I am trying to update a plugin but i couldn't understand when you said ', put it into your plugin and call it:' what do you mean by this? i am a beginner in WP i don't know maybe i am wrong in some implementation but i am listing what i have tried.

i have a private repo which is apparently a WP plugin. i

i made a private gitlab repo
i pushed an apparently called WP plugin in that repo ( after 1. adding 'src/plugin-updater.php' and 'src/updater-base.php' from my local WP and 2. adding that repo access token, gitlab url and repo).
now as i already said. i don't know about 'put it into your plugin and call it'. so maybe thats the problem. otherwise what i think work now is, whenever i make a change in any file in gitlab repo. it should show me a message about updating that plugin on local. is this what it is ought to do? right?

Add options page

If used as a plugin, it would be more practical to render an options page where the user can insert one or more repos.

Commited but won't show up in wp updates.

Hi,
I just found your plugin and installed, but the commited update won't show up on plugins updates.

Do I need to change something on the plugin files other than just commit to gitlab and configure token/url/repo ?

Error detected with theme check plugin

Still working on my theme and, since it's apparently possible to post a fork of a theme, I decided to do the necessary to post mine there.

Among the errors the plugin "theme check" found, there's one about theme-updater.php from wp-gitlab-updater:

INFO: theme-updater.php The theme appears to use include or require. If these are being used to include separate sections of a template from independent files, then get_template_part() should be used instead.
Line 25: require_once 'updater-base.php';

Well I know wp-gitlab-updater is no longer necessary if you post the theme in wordpress repos. Though this error looks interesting and maybe it's good to know it. Maybe it's even related to my previous error #10 ?

Gitlab updated not working with new Worpdpress ?

Hello,

With my Wordpress 5.9.3 wp-gitlab-updater started to raise errors on line 56 of them-updater.php and 103 of plugin-updater.php

I guess that get_site_option does not return an array any more for some reason...

Is there somebody active in here to answer this question ?

With my best regards,
PVI

Time check ?

Hello

I'm using your plugin with gitlab repo private.
But I have one issue, how many times the plugin are checking for update ?
Because sometimes the plugin didn't see my new tags .. and I have to wait or try to changes the access token
(I checked with postman and everything is working (gitlab versio 14.7.0)

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.