WC_Install::init PHP Method

init() public static method

Hook in tabs.
public static init ( )
    public static function init()
    {
        add_action('init', array(__CLASS__, 'check_version'), 5);
        add_action('init', array(__CLASS__, 'init_background_updater'), 5);
        add_action('admin_init', array(__CLASS__, 'install_actions'));
        add_action('in_plugin_update_message-woocommerce/woocommerce.php', array(__CLASS__, 'in_plugin_update_message'));
        add_filter('plugin_action_links_' . WC_PLUGIN_BASENAME, array(__CLASS__, 'plugin_action_links'));
        add_filter('plugin_row_meta', array(__CLASS__, 'plugin_row_meta'), 10, 2);
        add_filter('wpmu_drop_tables', array(__CLASS__, 'wpmu_drop_tables'));
        add_filter('cron_schedules', array(__CLASS__, 'cron_schedules'));
        add_action('woocommerce_plugin_background_installer', array(__CLASS__, 'background_installer'), 10, 2);
    }

Usage Example

Exemplo n.º 1
0
                    if (is_wp_error($working_dir)) {
                        throw new Exception($working_dir->get_error_message());
                    }
                    $result = $upgrader->install_package(array('source' => $working_dir, 'destination' => WP_PLUGIN_DIR, 'clear_destination' => false, 'abort_if_destination_exists' => false, 'clear_working' => true, 'hook_extra' => array('type' => 'plugin', 'action' => 'install')));
                    if (is_wp_error($result)) {
                        throw new Exception($result->get_error_message());
                    }
                    $activate = true;
                } catch (Exception $e) {
                    WC_Admin_Notices::add_custom_notice($plugin_to_install_id . '_install_error', sprintf(__('%1$s could not be installed (%2$s). <a href="%3$s">Please install it manually by clicking here.</a>', 'woocommerce'), $plugin_to_install['name'], $e->getMessage(), esc_url(admin_url('index.php?wc-install-plugin-redirect=' . $plugin_to_install['repo-slug']))));
                }
                // Discard feedback
                ob_end_clean();
            }
            wp_clean_plugins_cache();
            // Activate this thing
            if ($activate) {
                try {
                    $result = activate_plugin($plugin);
                    if (is_wp_error($result)) {
                        throw new Exception($result->get_error_message());
                    }
                } catch (Exception $e) {
                    WC_Admin_Notices::add_custom_notice($plugin_to_install_id . '_install_error', sprintf(__('%1$s was installed but could not be activated. <a href="%2$s">Please activate it manually by clicking here.</a>', 'woocommerce'), $plugin_to_install['name'], admin_url('plugins.php')));
                }
            }
        }
    }
}
WC_Install::init();