PluginProbe
weDocs: AI Powered Knowledge Base, Docs, Documentation, Wiki & AI Chatbot / trunk
weDocs: AI Powered Knowledge Base, Docs, Documentation, Wiki & AI Chatbot vtrunk
2.5.0 2.4.1 2.4.0 2.3.1 2.3.0 2.2.5 2.2.6 2.2.7 2.2.2 2.2.3 2.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.4 1.4.1 1.5 1.6 1.6.1 1.6.2 1.6.3 1.7 1.7.1 1.7.2 All 54 releases
wedocs / includes / Admin.php

Admin.php in weDocs: AI Powered Knowledge Base, Docs, Documentation, Wiki & AI Chatbot trunk, at includes/Admin.php

125 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WeDevs\WeDocs;
4
5 use \WeDevs\WeDocs\Appsero\Client as Appsero_Client;
6
7 /**
8 * Frontend Handler Class
9 */
10 class Admin {
11
12 /**
13 * Initialize the class
14 */
15 public function __construct() {
16 new Admin\Admin();
17 new Admin\Migrate();
18 new Admin\Docs_List_Table();
19 new Admin\ChangelogUpsell();
20
21 add_action( 'admin_init', array( $this, 'init_admin_actions' ), 5 );
22
23 // Redirect to a new design after trashing a doc
24 add_action('load-edit.php', array($this, 'trashed_docs_redirect'));
25
26 // 1. Add links in the installed plugins list page
27 add_filter( 'plugin_action_links_' . plugin_basename(WEDOCS_FILE ), [$this, 'plugin_instalation_page_link'], 10, 3 );
28 // 2. Add links in the plugin install/info popup page
29 add_filter( 'plugins_api_result', [$this, 'plugin_details_popup_link'], 10, 3 );
30 }
31
32 /**
33 * Redirect to a new design after trashing a doc.
34 *
35 * @return void
36 */
37 public function trashed_docs_redirect() {
38 $screen = get_current_screen();
39 if ($screen->id === 'edit-docs') {
40 if (isset($_GET['trashed']) && intval(sanitize_text_field($_GET['trashed'])) > 0) {
41 wp_redirect(admin_url('admin.php?page=wedocs#'));
42 exit();
43 }
44 }
45 }
46
47 /**
48 * Admin initialization hook.
49 *
50 * @since 2.0.0
51 *
52 * @return void
53 */
54 public function init_admin_actions() {
55 $this->handle_plugin_activate_redirection();
56 $this->init_appsero();
57 }
58
59 /**
60 * Handle redirection after activate wedocs.
61 *
62 * @since 2.0.0
63 *
64 * @return void
65 */
66 public function handle_plugin_activate_redirection() {
67 // Check if the plugin is being activated for the first time.
68 if ( get_option( 'wedocs_activation_redirect', false ) ) {
69 // Remove the redirect option to prevent further redirections.
70 delete_option('wedocs_activation_redirect');
71
72 // Redirect to the weDocs dashboard & exit.
73 wp_safe_redirect( admin_url( 'admin.php?page=wedocs#/' ) );
74 exit;
75 }
76 }
77
78 /**
79 * Initialize the appsero tracker
80 *
81 * @since 1.6.0
82 *
83 * @return void
84 */
85 public function init_appsero() {
86 $client = new Appsero_Client( 'aa0ffba5-b889-40af-a34c-41fc8f707faa', 'weDocs', WEDOCS_FILE );
87 $client->insights()->init();
88 }
89
90
91 function plugin_instalation_page_link( $links ) {
92 $pro_link = '<a href="https://wedocs.co/pricing/" target="_blank" style="font-weight:bold; color:#17b517;">'. esc_html__( 'Upgrade to Pro', 'wedocs' ) .'</a> ';
93 $discount_link = '<a href="https://wedevs.com/coupons/" target="_blank" style="color:#d63638;">'. esc_html__( 'Check Discount', 'wedocs' ) .'</a>';
94 $docs_link = '<a href="https://wedocs.co/docs/" target="_blank">'. esc_html__( 'Docs', 'wedocs' ) .'</a> ';
95 $support_link = '<a href="https://wedocs.co/get-support/" target="_blank">'. esc_html__( 'Get Support', 'wedocs' ) .'</a>';
96 $items = [
97 $docs_link
98 ];
99 if(!is_plugin_active('wedocs-pro/wedocs-pro.php')){
100 $items[]= $pro_link;
101 $items []= $discount_link;
102 }
103 $items[] = $support_link;
104 array_push( $links, ...$items, );
105 return $links;
106 }
107
108 function plugin_details_popup_link( $res, $action, $args ) {
109 if ( isset($res->slug) && $res->slug === 'wedocs' ) {
110 if ( isset( $res->sections['description'] ) ) {
111 $extra_html = '<p style="margin-top:10px;">';
112 if(!is_plugin_active('wedocs-pro/wedocs-pro.php')){
113 $extra_html .= '<a href="https://wedocs.co/pricing/" target="_blank" style="margin-right:6px;color:green;">'. esc_html__( 'Upgrade to Pro', 'wedocs' ) .'</a> | ';
114 $extra_html .= '<a href="https://wedevs.com/coupons/" target="_blank">'. esc_html__( 'Check Discount', 'wedocs' ) .'</a> | ';
115 }
116 $extra_html .= '<a href="https://wedocs.co/docs/" target="_blank">'. esc_html__( 'Docs', 'wedocs' ) .'</a> | ';
117 $extra_html .= '<a href="https://wedocs.co/get-support/" target="_blank">'. esc_html__( 'Get Support', 'wedocs' ) .'</a>';
118 $extra_html .= '</p>';
119 $res->sections['description'] .= $extra_html;
120 }
121 }
122 return $res;
123 }
124
125 }