Giter VIP home page Giter VIP logo

Comments (5)

johnbillion avatar johnbillion commented on August 18, 2024

The theme update hook might need to go into a plugin or a mu-plugin, yeah. I must admit I'm not sure if the active theme's functions file gets loaded when updates are checked for.

Feel free to paste your code in here if you can't get it working.

from external-update-api.

anthoweb-code avatar anthoweb-code commented on August 18, 2024

That's what I suspected, here's the code - tried it in a network enabled plugin and mu-plugin but no luck. I think part of the trouble is that with multisite the themes can only be updated via the main network admin dashboard and not within each of the separates sites admin's.

function doc_update_handler( EUAPI_Handler $handler = null, EUAPI_Item $item ) {
    
    if ( 'ic-doc-default/style.css' == $item->file ) {
        $handler = new EUAPI_Handler_GitHub( array(
            'type'       => $item->type,
            'file'       => $item->file,
            'github_url' => 'https://github.com/anthoweb-code/ic-doc-default',
            'sslverify'  => false
        ) );
    }
    return $handler;
}
add_filter( 'euapi_theme_handler', 'doc_update_handler', 10, 2 );

Not sure if I have the $item->file comparison correct either - could only see an example of an implementation for a plugin in the readme?

If not in the themes functions , then where would be the usual location for adding the 'euapi_theme_handler' hook?

from external-update-api.

anthoweb-code avatar anthoweb-code commented on August 18, 2024

Ok, managed to get the update_handler to fire on /wp-admin/network/update-core.php (Network Admin > Updates > Available Updates), it doesn't seem to get triggered at all on the wp-admin/network/themes.php, not sure if its supposed to?

After some debugging I realised the file comparison should just be the theme folder name, so I changed that in the params and the handler now gets setup. However there seems to be an issue with the way in which the URL is constructed which then gets used by fetch_new_version() in handler-github.php.

EUAPI_Handler_GitHub Object
    [config] => Array
        (
            [timeout] => 5
            [type] => theme
            [access_token] => 
            [folder_name] => .
            [file_name] => ic-doc-default
            [sslverify] => 
            [base_url] => https://raw.github.com/anthoweb-code/ic-doc-default/master
            [zip_url] => https://api.github.com/repos/anthoweb-code/ic-doc-default/zipball
            [file] => ic-doc-default
            [github_url] => https://github.com/anthoweb-code/ic-doc-default
        )

So the base_url is https://raw.github.com/anthoweb-code/ic-doc-default/master, however $this->get_file_url() returns https://raw.github.com/anthoweb-code/ic-doc-default/master/ic-doc-default

It seems to be adding the folder/file name onto the end, which results in a 404 when EUAPI::fetch is called in fetch_new_version()...

WP_Error Object
(
    [errors] => Array
        (
            [fetch_failed] => Array
                (
                    [0] => Received HTTP response code 404 (Not Found).
                )
        )
    [error_data] => Array
        (
        )
)

How exactly is the version comparison made, I thought it would be via style.css as this is where WP expects to find meta about each theme?
The base_url https://raw.github.com/anthoweb-code/ic-doc-default/master seems to link to a random template file in the theme, which has no version number in it.
Sorry I'm quite new to github, perhaps there's some settings I need to adjust to make style.css the master file for the repo?

from external-update-api.

aristath avatar aristath commented on August 18, 2024

@anthoweb-code did you ever get this working?

from external-update-api.

johnbillion avatar johnbillion commented on August 18, 2024

This turned out to be an issue with updating themes - not tied to Multisite specifically. Fixed in the latest version.

from external-update-api.

Related Issues (7)

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.