YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.26k stars 411 forks source link

Cannot hooks from function #324

Open masitings opened 5 years ago

masitings commented 5 years ago

Hi, i have a problem when i want to put the updater separately from the main index plugin. I put the updater on files activation.php in function update_pinterin and then on main index plugin i called do_action function for calling the update_pinterin but it seems not working and the updater was not showing when i activated the plugin.

This is the main index code :

/*
Plugin Name: Pinterin
Plugin URI: https://semanthic.com/
Description: Plugin for automatic
Version: 1.4.5
Author: SEMANTHIC
Author URI: https://semanthic.com
License: SEMANTHIC LTD.
*/

function pinterin()
{
    include_once plugin_dir_path(__FILE__) . '/vendor/autoload.php';
    include_once plugin_dir_path(__FILE__) . '/vendor/updater-plugin/plugin-update-checker.php';
    include_once plugin_dir_path(__FILE__) . '/activation.php';

    do_action('update_pinterin');

}
add_action('plugins_loaded', 'pinterin');

// register_activation_hook(__FILE__, 'pinterin');

This is the files for activation.php

function update_pinterin()
    {
        $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
            'https://gitlab.com/masiting/plugins,
            __FILE__,
            'pinterin'
        );
        $myUpdateChecker->setAuthentication('Dasdas');
        $myUpdateChecker->setBranch('plugin');
    }

Please help, thanks.

YahnisElsts commented 5 years ago

(I've edited your post to add syntax highlighting to the code blocks.)

Assuming that this is the whole code, it looks like it's missing something: you need to hook the update_pinterin function to the custom update_pinterin action. Like this:

add_action('update_pinterin', 'update_pinterin');