PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.6.7
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.6.7
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / modules / accounting / includes / classes / class-pdf-install.php

class-pdf-install.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.6.7, at modules/accounting/includes/classes/class-pdf-install.php

70 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WeDevs\ERP\Accounting\Includes\Classes;
4
5 use Plugin_Upgrader;
6
7 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
8 require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
9
10 class PDF_Install {
11
12 /**
13 * Install Plugin
14 *
15 * @param $url
16 *
17 * @return int
18 */
19 public function install_plugin( $url ) {
20 if ( strstr( $url, '.zip' ) !== false ) {
21 $download_link = $url;
22 } else {
23 $slug = explode( '/', $url );
24 $slug = $slug[ count( $slug ) - 2 ];
25 $api = plugins_api(
26 'plugin_information',
27 [
28 'slug' => $slug,
29 'fields' => [ 'sections' => 'false' ],
30 ]
31 );
32 $download_link = $api->download_link;
33 }
34
35 $upgrader = new Plugin_Upgrader();
36
37 if ( ! $upgrader->install( $download_link ) ) {
38 return 0;
39 }
40
41 $plugin_to_activate = $upgrader->plugin_info();
42 $this->activate_pdf_plugin( $plugin_to_activate );
43
44 return 1;
45 }
46
47 /**
48 * Activate plugin
49 *
50 * @param $plugin_to_activate
51 */
52 public function activate_pdf_plugin( $plugin_to_activate ) {
53 $activate = activate_plugin( $plugin_to_activate );
54 wp_cache_flush();
55
56 $this->show_activation_notice();
57 }
58
59 /**
60 * Show plugin activation notice
61 *
62 * @param $plugin_to_activate
63 */
64 public function show_activation_notice() {
65 echo '<div class="updated notice is-dismissible"><p>';
66 echo esc_html__( 'Plugin <strong>activated.</strong>', 'erp' );
67 echo '</p></div>';
68 }
69 }
70