| @@ -1,232 +1,232 @@ | ||
| 1 | -<?php | |
| 2 | -if (!defined('ABSPATH')) exit; // Exit if accessed directly | |
| 3 | -/******************************************* | |
| 4 | - * QuantumCloud Plugin Upgrade Link for Free Plugins | |
| 5 | - * Last Updated On: 05-24-2017 | |
| 6 | - *******************************************/ | |
| 7 | - | |
| 8 | -if( !class_exists('QcchatbotPluginUpgradeToProNotice') ) | |
| 9 | -{ | |
| 10 | - class QcchatbotPluginUpgradeToProNotice { | |
| 11 | - | |
| 12 | - //Public variables, these can be overrides using instance callback | |
| 13 | - | |
| 14 | - public $upgrade_link = "https://www.quantumcloud.com"; | |
| 15 | - public $link_color = "#FCB214"; | |
| 16 | - public $link_text = "Upgrade to Pro"; | |
| 17 | - public $link_class = ""; | |
| 18 | - public $link_target = "_blank"; | |
| 19 | - | |
| 20 | - public $plugin_slug = ""; //Exact plugin folder name | |
| 21 | - public $plugin_main_file = ""; //Exact file name with extension of primary file | |
| 22 | - public $plugin_menu_slug = ""; //Parent menu slug of the plugin | |
| 23 | - | |
| 24 | - public $plugin_slug_plus_file = ""; | |
| 25 | - | |
| 26 | - //Turn on or off the hooks, use false to off | |
| 27 | - public $show_with_action_links = true; //in plugin.php page | |
| 28 | - public $show_with_meta_links = true; //in plugin.php page | |
| 29 | - public $show_with_plugin_menu = true; //inside parent menu of the plugin | |
| 30 | - | |
| 31 | - //Contructor - Set defaults | |
| 32 | - function __construct() | |
| 33 | - { | |
| 34 | - add_action('admin_head', array(&$this, 'qcld_upgrade_to_pro_heading_part') ); | |
| 35 | - } | |
| 36 | - | |
| 37 | - function qcld_upgrade_to_pro_heading_part() | |
| 38 | - { | |
| 39 | - if( is_admin() ){ | |
| 40 | - ?> | |
| 41 | - <script> | |
| 42 | - jQuery(document).ready(function($){ | |
| 43 | - $(".qc-up-pro-link-chatbot").parent('a').on("click", function(e){ | |
| 44 | - e.preventDefault(); | |
| 45 | - var link = $(this).attr('href'); | |
| 46 | - window.open(link, '_blank'); | |
| 47 | - }); | |
| 48 | - }); | |
| 49 | - </script> | |
| 50 | - <?php | |
| 51 | - } | |
| 52 | - } | |
| 53 | - | |
| 54 | - /******************************* | |
| 55 | - * Check if the current screen | |
| 56 | - * is the plugins.php page or not | |
| 57 | - *******************************/ | |
| 58 | - function check_if_plugin_page() | |
| 59 | - { | |
| 60 | - | |
| 61 | - //Check if current page is plugins.php, otherwise return false | |
| 62 | - global $pagenow; | |
| 63 | - | |
| 64 | - if( is_admin() && $pagenow == 'plugins.php' ) | |
| 65 | - { | |
| 66 | - return true; | |
| 67 | - } | |
| 68 | - | |
| 69 | - return false; | |
| 70 | - | |
| 71 | - } //End of check_if_plugin_page | |
| 72 | - | |
| 73 | - /******************************* | |
| 74 | - * Put Link with Plugin Action Links | |
| 75 | - * Like Active, Edit etc. | |
| 76 | - * Ofcourse, in plugin.php page | |
| 77 | - *******************************/ | |
| 78 | - function hook_with_plugin_action_links(){ | |
| 79 | - | |
| 80 | - $this->plugin_slug_plus_file = $this->plugin_slug .'/'. $this->plugin_main_file; | |
| 81 | - | |
| 82 | - if( $this->show_with_action_links && $this->plugin_slug_plus_file != "" ) | |
| 83 | - { | |
| 84 | - add_action( 'plugin_action_links_' . $this->plugin_slug_plus_file, array(&$this, 'func_show_upgrade_link_with_action_links'), 95 ); | |
| 85 | - } | |
| 86 | - else | |
| 87 | - { | |
| 88 | - return; | |
| 89 | - } | |
| 90 | - | |
| 91 | - } | |
| 92 | - | |
| 93 | - /******************************* | |
| 94 | - * Callback function for the above hook | |
| 95 | - * used inside hook_with_plugin_action_links | |
| 96 | - *******************************/ | |
| 97 | - function func_show_upgrade_link_with_action_links( $links ) | |
| 98 | - { | |
| 99 | - $links = array_merge( $links, array( | |
| 100 | - '<a href="' . esc_url( admin_url('admin.php?page=wpbot') ) . '" target="">' . __( 'Settings', 'chatbot' ) . '</a>' | |
| 101 | - ) ); | |
| 102 | - $links = array_merge( $links, array( | |
| 103 | - '<a href="' . esc_url( admin_url('admin.php?page=wpbot_help_page') ) . '" target="">' . __( 'Help', 'chatbot' ) . '</a>' | |
| 104 | - ) ); | |
| 105 | - $links = array_merge( $links, array( | |
| 106 | - '<a href="' . esc_url('https://www.wpbot.pro/free-support/' ) . '" target="">' . __( 'Get Support', 'chatbot' ) . '</a>' | |
| 107 | - ) ); | |
| 108 | - $links = array_merge( $links, array( | |
| 109 | - '<a style="font-weight: bold; background: '.$this->link_color.';color: #fff;border-radius: 4px; padding:5px" href="' . esc_url( $this->upgrade_link ) . '" target="'.$this->link_target.'">' . $this->link_text . '</a>' | |
| 110 | - ) ); | |
| 111 | - | |
| 112 | - return $links; | |
| 113 | - } | |
| 114 | - | |
| 115 | - /******************************* | |
| 116 | - * Put Link with Plugin Meta Links | |
| 117 | - * Like Plugin Author, Details, etc. | |
| 118 | - * Ofcourse, in plugin.php page | |
| 119 | - *******************************/ | |
| 120 | - function hook_with_plugin_meta_links(){ | |
| 121 | - | |
| 122 | - if( $this->show_with_meta_links && $this->plugin_main_file != "" ) | |
| 123 | - { | |
| 124 | - add_action( 'plugin_row_meta', array(&$this, 'func_show_upgrade_link_with_meta_links'), 10, 2 ); | |
| 125 | - } | |
| 126 | - else | |
| 127 | - { | |
| 128 | - return; | |
| 129 | - } | |
| 130 | - | |
| 131 | - } | |
| 132 | - | |
| 133 | - /******************************* | |
| 134 | - * Callback function for the above hook | |
| 135 | - * used inside hook_with_plugin_meta_links | |
| 136 | - *******************************/ | |
| 137 | - function func_show_upgrade_link_with_meta_links( $links, $file ) | |
| 138 | - { | |
| 139 | - $links = array_merge( array( | |
| 140 | - | |
| 141 | - ), $links ); | |
| 142 | - | |
| 143 | - if ( strpos( $file, "$this->plugin_main_file" ) !== false ) { | |
| 144 | - | |
| 145 | - $new_links = array( | |
| 146 | - '<a class="'.$this->link_class.'" style="font-weight: bold; color: #fff; padding: 5px;border-radius: 4px; background: '.$this->link_color.';" href="' . esc_url( $this->upgrade_link ) . '" title="'.$this->link_text.'" target="'.$this->link_target.'">' . $this->link_text . '</a>' | |
| 147 | - ); | |
| 148 | - | |
| 149 | - $links = array_merge( $links, $new_links ); | |
| 150 | - } | |
| 151 | - | |
| 152 | - return $links; | |
| 153 | - } | |
| 154 | - | |
| 155 | - /******************************* | |
| 156 | - * Put Link inside WP Admin Menu | |
| 157 | - * Created by the respective plugin | |
| 158 | - *******************************/ | |
| 159 | - function hook_with_plugin_submenu() | |
| 160 | - { | |
| 161 | - if( !$this->show_with_plugin_menu || $this->plugin_menu_slug == "" ){ | |
| 162 | - return; | |
| 163 | - } | |
| 164 | - else | |
| 165 | - { | |
| 166 | - add_action( 'admin_menu' , array(&$this, 'func_qc_external_upgrade_link'), 20 ); | |
| 167 | - } | |
| 168 | - } | |
| 169 | - | |
| 170 | - /******************************* | |
| 171 | - * Callback function for the avbove function/hook | |
| 172 | - *******************************/ | |
| 173 | - function func_qc_external_upgrade_link() | |
| 174 | - { | |
| 175 | - global $submenu; | |
| 176 | - $current_user = wp_get_current_user(); | |
| 177 | - | |
| 178 | - if( !$this->show_with_plugin_menu || $this->plugin_menu_slug == "" ) | |
| 179 | - { | |
| 180 | - return; | |
| 181 | - } | |
| 182 | - | |
| 183 | - $link_text = '<span class="qc-up-pro-link-chatbot" style="font-weight: bold; padding: 5px; background: '.esc_attr($this->link_color).'; border-radius: 4px; color: #fff">'.$this->link_text.'</span>'; | |
| 184 | - | |
| 185 | - if($current_user->roles[0]!='subscriber') | |
| 186 | - $submenu["$this->plugin_menu_slug"][300] = array( $link_text, 'activate_plugins' , $this->upgrade_link ); | |
| 187 | - | |
| 188 | - return $submenu; | |
| 189 | - } | |
| 190 | - | |
| 191 | - | |
| 192 | - | |
| 193 | - } //End of class QcPluginUpgradeToProNotice | |
| 194 | - | |
| 195 | -} // End of class_exists | |
| 196 | - | |
| 197 | - | |
| 198 | -/******************************* | |
| 199 | - * Create instance and call the | |
| 200 | - * appropriate worker/callback | |
| 201 | - *******************************/ | |
| 202 | - | |
| 203 | -$instance_bot2 = new QcchatbotPluginUpgradeToProNotice(); | |
| 204 | - | |
| 205 | -if( is_admin() ) | |
| 206 | -{ | |
| 207 | - | |
| 208 | - //Uncommnent and Set these instance variables as per the requirements | |
| 209 | - | |
| 210 | - $instance_bot2->upgrade_link = "https://www.wpbot.pro/"; | |
| 211 | - //$instance_sldf2->link_color = "#FCB214"; | |
| 212 | - //$instance_sldf2->link_text = "Upgrade To Pro"; | |
| 213 | - //$instance_sldf2->link_class = ""; | |
| 214 | - //$instance_sldf2->link_target = "_blank"; | |
| 215 | - | |
| 216 | - $instance_bot2->plugin_slug = 'chatbot'; //Plugin Slug. i.e. Folder Name | |
| 217 | - $instance_bot2->plugin_main_file = 'qcld-wpwbot.php'; //Primary file of the pluign | |
| 218 | - $instance_bot2->plugin_menu_slug = 'wpbot-panel'; //Main Menu Slug | |
| 219 | - | |
| 220 | - $instance_bot2->show_with_action_links = true; //show in plugin.php page | |
| 221 | - $instance_bot2->show_with_meta_links = true; //show in plugin.php page | |
| 222 | - $instance_bot2->show_with_plugin_menu = true; //show inside parent menu of the plugin | |
| 223 | - | |
| 224 | - if( $instance_bot2->check_if_plugin_page() ) | |
| 225 | - { | |
| 226 | - $instance_bot2->hook_with_plugin_action_links(); | |
| 227 | - $instance_bot2->hook_with_plugin_meta_links(); | |
| 228 | - } | |
| 229 | - | |
| 230 | - $instance_bot2->hook_with_plugin_submenu(); | |
| 231 | - | |
| 232 | -} | |
| 1 | +<?php | |
| 2 | +if (!defined('ABSPATH')) exit; // Exit if accessed directly | |
| 3 | +/******************************************* | |
| 4 | + * QuantumCloud Plugin Upgrade Link for Free Plugins | |
| 5 | + * Last Updated On: 05-24-2017 | |
| 6 | + *******************************************/ | |
| 7 | + | |
| 8 | +if( !class_exists('QcchatbotPluginUpgradeToProNotice') ) | |
| 9 | +{ | |
| 10 | + class QcchatbotPluginUpgradeToProNotice { | |
| 11 | + | |
| 12 | + //Public variables, these can be overrides using instance callback | |
| 13 | + | |
| 14 | + public $upgrade_link = "https://www.quantumcloud.net"; | |
| 15 | + public $link_color = "#FCB214"; | |
| 16 | + public $link_text = "Upgrade to Pro"; | |
| 17 | + public $link_class = ""; | |
| 18 | + public $link_target = "_blank"; | |
| 19 | + | |
| 20 | + public $plugin_slug = ""; //Exact plugin folder name | |
| 21 | + public $plugin_main_file = ""; //Exact file name with extension of primary file | |
| 22 | + public $plugin_menu_slug = ""; //Parent menu slug of the plugin | |
| 23 | + | |
| 24 | + public $plugin_slug_plus_file = ""; | |
| 25 | + | |
| 26 | + //Turn on or off the hooks, use false to off | |
| 27 | + public $show_with_action_links = true; //in plugin.php page | |
| 28 | + public $show_with_meta_links = true; //in plugin.php page | |
| 29 | + public $show_with_plugin_menu = true; //inside parent menu of the plugin | |
| 30 | + | |
| 31 | + //Contructor - Set defaults | |
| 32 | + function __construct() | |
| 33 | + { | |
| 34 | + add_action('admin_head', array(&$this, 'qcld_upgrade_to_pro_heading_part') ); | |
| 35 | + } | |
| 36 | + | |
| 37 | + function qcld_upgrade_to_pro_heading_part() | |
| 38 | + { | |
| 39 | + if( is_admin() ){ | |
| 40 | + ?> | |
| 41 | + <script> | |
| 42 | + jQuery(document).ready(function($){ | |
| 43 | + $(".qc-up-pro-link-chatbot").parent('a').on("click", function(e){ | |
| 44 | + e.preventDefault(); | |
| 45 | + var link = $(this).attr('href'); | |
| 46 | + window.open(link, '_blank'); | |
| 47 | + }); | |
| 48 | + }); | |
| 49 | + </script> | |
| 50 | + <?php | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + /******************************* | |
| 55 | + * Check if the current screen | |
| 56 | + * is the plugins.php page or not | |
| 57 | + *******************************/ | |
| 58 | + function check_if_plugin_page() | |
| 59 | + { | |
| 60 | + | |
| 61 | + //Check if current page is plugins.php, otherwise return false | |
| 62 | + global $pagenow; | |
| 63 | + | |
| 64 | + if( is_admin() && $pagenow == 'plugins.php' ) | |
| 65 | + { | |
| 66 | + return true; | |
| 67 | + } | |
| 68 | + | |
| 69 | + return false; | |
| 70 | + | |
| 71 | + } //End of check_if_plugin_page | |
| 72 | + | |
| 73 | + /******************************* | |
| 74 | + * Put Link with Plugin Action Links | |
| 75 | + * Like Active, Edit etc. | |
| 76 | + * Ofcourse, in plugin.php page | |
| 77 | + *******************************/ | |
| 78 | + function hook_with_plugin_action_links(){ | |
| 79 | + | |
| 80 | + $this->plugin_slug_plus_file = $this->plugin_slug .'/'. $this->plugin_main_file; | |
| 81 | + | |
| 82 | + if( $this->show_with_action_links && $this->plugin_slug_plus_file != "" ) | |
| 83 | + { | |
| 84 | + add_action( 'plugin_action_links_' . $this->plugin_slug_plus_file, array(&$this, 'func_show_upgrade_link_with_action_links'), 95 ); | |
| 85 | + } | |
| 86 | + else | |
| 87 | + { | |
| 88 | + return; | |
| 89 | + } | |
| 90 | + | |
| 91 | + } | |
| 92 | + | |
| 93 | + /******************************* | |
| 94 | + * Callback function for the above hook | |
| 95 | + * used inside hook_with_plugin_action_links | |
| 96 | + *******************************/ | |
| 97 | + function func_show_upgrade_link_with_action_links( $links ) | |
| 98 | + { | |
| 99 | + $links = array_merge( $links, array( | |
| 100 | + '<a href="' . esc_url( admin_url('admin.php?page=wpbot') ) . '" target="">' . __( 'Settings', 'chatbot' ) . '</a>' | |
| 101 | + ) ); | |
| 102 | + $links = array_merge( $links, array( | |
| 103 | + '<a href="' . esc_url( admin_url('admin.php?page=wpbot_help_page') ) . '" target="">' . __( 'Help', 'chatbot' ) . '</a>' | |
| 104 | + ) ); | |
| 105 | + $links = array_merge( $links, array( | |
| 106 | + '<a href="' . esc_url('https://www.wpbot.pro/free-support/' ) . '" target="">' . __( 'Get Support', 'chatbot' ) . '</a>' | |
| 107 | + ) ); | |
| 108 | + $links = array_merge( $links, array( | |
| 109 | + '<a style="font-weight: bold; background: '.$this->link_color.';color: #fff;border-radius: 4px; padding:5px" href="' . esc_url( $this->upgrade_link ) . '" target="'.$this->link_target.'">' . $this->link_text . '</a>' | |
| 110 | + ) ); | |
| 111 | + | |
| 112 | + return $links; | |
| 113 | + } | |
| 114 | + | |
| 115 | + /******************************* | |
| 116 | + * Put Link with Plugin Meta Links | |
| 117 | + * Like Plugin Author, Details, etc. | |
| 118 | + * Ofcourse, in plugin.php page | |
| 119 | + *******************************/ | |
| 120 | + function hook_with_plugin_meta_links(){ | |
| 121 | + | |
| 122 | + if( $this->show_with_meta_links && $this->plugin_main_file != "" ) | |
| 123 | + { | |
| 124 | + add_action( 'plugin_row_meta', array(&$this, 'func_show_upgrade_link_with_meta_links'), 10, 2 ); | |
| 125 | + } | |
| 126 | + else | |
| 127 | + { | |
| 128 | + return; | |
| 129 | + } | |
| 130 | + | |
| 131 | + } | |
| 132 | + | |
| 133 | + /******************************* | |
| 134 | + * Callback function for the above hook | |
| 135 | + * used inside hook_with_plugin_meta_links | |
| 136 | + *******************************/ | |
| 137 | + function func_show_upgrade_link_with_meta_links( $links, $file ) | |
| 138 | + { | |
| 139 | + $links = array_merge( array( | |
| 140 | + | |
| 141 | + ), $links ); | |
| 142 | + | |
| 143 | + if ( strpos( $file, "$this->plugin_main_file" ) !== false ) { | |
| 144 | + | |
| 145 | + $new_links = array( | |
| 146 | + '<a class="'.$this->link_class.'" style="font-weight: bold; color: #fff; padding: 5px;border-radius: 4px; background: '.$this->link_color.';" href="' . esc_url( $this->upgrade_link ) . '" title="'.$this->link_text.'" target="'.$this->link_target.'">' . $this->link_text . '</a>' | |
| 147 | + ); | |
| 148 | + | |
| 149 | + $links = array_merge( $links, $new_links ); | |
| 150 | + } | |
| 151 | + | |
| 152 | + return $links; | |
| 153 | + } | |
| 154 | + | |
| 155 | + /******************************* | |
| 156 | + * Put Link inside WP Admin Menu | |
| 157 | + * Created by the respective plugin | |
| 158 | + *******************************/ | |
| 159 | + function hook_with_plugin_submenu() | |
| 160 | + { | |
| 161 | + if( !$this->show_with_plugin_menu || $this->plugin_menu_slug == "" ){ | |
| 162 | + return; | |
| 163 | + } | |
| 164 | + else | |
| 165 | + { | |
| 166 | + add_action( 'admin_menu' , array(&$this, 'func_qc_external_upgrade_link'), 20 ); | |
| 167 | + } | |
| 168 | + } | |
| 169 | + | |
| 170 | + /******************************* | |
| 171 | + * Callback function for the avbove function/hook | |
| 172 | + *******************************/ | |
| 173 | + function func_qc_external_upgrade_link() | |
| 174 | + { | |
| 175 | + global $submenu; | |
| 176 | + $current_user = wp_get_current_user(); | |
| 177 | + | |
| 178 | + if( !$this->show_with_plugin_menu || $this->plugin_menu_slug == "" ) | |
| 179 | + { | |
| 180 | + return; | |
| 181 | + } | |
| 182 | + | |
| 183 | + $link_text = '<span class="qc-up-pro-link-chatbot" style="font-weight: bold; padding: 5px; background: '.esc_attr($this->link_color).'; border-radius: 4px; color: #fff">'.$this->link_text.'</span>'; | |
| 184 | + | |
| 185 | + if($current_user->roles[0]!='subscriber') | |
| 186 | + $submenu["$this->plugin_menu_slug"][300] = array( $link_text, 'activate_plugins' , $this->upgrade_link ); | |
| 187 | + | |
| 188 | + return $submenu; | |
| 189 | + } | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + } //End of class QcPluginUpgradeToProNotice | |
| 194 | + | |
| 195 | +} // End of class_exists | |
| 196 | + | |
| 197 | + | |
| 198 | +/******************************* | |
| 199 | + * Create instance and call the | |
| 200 | + * appropriate worker/callback | |
| 201 | + *******************************/ | |
| 202 | + | |
| 203 | +$instance_bot2 = new QcchatbotPluginUpgradeToProNotice(); | |
| 204 | + | |
| 205 | +if( is_admin() ) | |
| 206 | +{ | |
| 207 | + | |
| 208 | + //Uncommnent and Set these instance variables as per the requirements | |
| 209 | + | |
| 210 | + $instance_bot2->upgrade_link = "https://www.wpbot.pro/"; | |
| 211 | + //$instance_sldf2->link_color = "#FCB214"; | |
| 212 | + //$instance_sldf2->link_text = "Upgrade To Pro"; | |
| 213 | + //$instance_sldf2->link_class = ""; | |
| 214 | + //$instance_sldf2->link_target = "_blank"; | |
| 215 | + | |
| 216 | + $instance_bot2->plugin_slug = 'chatbot'; //Plugin Slug. i.e. Folder Name | |
| 217 | + $instance_bot2->plugin_main_file = 'qcld-wpwbot.php'; //Primary file of the pluign | |
| 218 | + $instance_bot2->plugin_menu_slug = 'wpbot-panel'; //Main Menu Slug | |
| 219 | + | |
| 220 | + $instance_bot2->show_with_action_links = true; //show in plugin.php page | |
| 221 | + $instance_bot2->show_with_meta_links = true; //show in plugin.php page | |
| 222 | + $instance_bot2->show_with_plugin_menu = true; //show inside parent menu of the plugin | |
| 223 | + | |
| 224 | + if( $instance_bot2->check_if_plugin_page() ) | |
| 225 | + { | |
| 226 | + $instance_bot2->hook_with_plugin_action_links(); | |
| 227 | + $instance_bot2->hook_with_plugin_meta_links(); | |
| 228 | + } | |
| 229 | + | |
| 230 | + $instance_bot2->hook_with_plugin_submenu(); | |
| 231 | + | |
| 232 | +} | |