init() public static method

Hook in tabs.
public static init ( )
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();