本文整理汇总了PHP中WC_Install::init方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Install::init方法的具体用法?PHP WC_Install::init怎么用?PHP WC_Install::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Install
的用法示例。
在下文中一共展示了WC_Install::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Exception
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();