Conditions | 4 |
Paths | 8 |
Total Lines | 28 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | private function install() { |
||
20 | include_once( ABSPATH . '/wp-admin/includes/admin.php' ); |
||
21 | include_once( ABSPATH . '/wp-admin/includes/plugin-install.php' ); |
||
22 | include_once( ABSPATH . '/wp-admin/includes/plugin.php' ); |
||
23 | include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' ); |
||
24 | include_once( ABSPATH . '/wp-admin/includes/class-plugin-upgrader.php' ); |
||
25 | |||
26 | $api = plugins_api( 'plugin_information', array( |
||
27 | 'slug' => 'connect-for-woocommerce', |
||
28 | ) ); |
||
29 | |||
30 | if ( is_wp_error( $api ) ) { |
||
31 | wp_die( $api ); |
||
32 | } |
||
33 | |||
34 | $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
||
35 | $result = $upgrader->install( $api->download_link ); |
||
36 | |||
37 | if ( is_wp_error( $result ) ) { |
||
38 | wp_die( $result ); |
||
39 | } |
||
40 | |||
41 | $result = activate_plugin( 'connect-for-woocommerce/woocommerce-connect-client.php' ); |
||
42 | |||
43 | if ( is_wp_error( $result ) ) { |
||
44 | wp_die( $result ); |
||
45 | } |
||
46 | } |
||
47 | } |
||
52 |
An exit expression should only be used in rare cases. For example, if you write a short command line script.
In most cases however, using an
exit
expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.