| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Help And Footer Menu Class |
| 5 |
* |
| 6 |
* @author : Premio <contact@premio.io> |
| 7 |
* @license : GPL2 |
| 8 |
* */ |
| 9 |
|
| 10 |
if (defined('ABSPATH') === false) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
// Class for help and footer menu |
| 15 |
class MSE_HELP |
| 16 |
{ |
| 17 |
// Allowed pages for showing the help menu |
| 18 |
private static $allowed_pages = ['my-sticky-elements', 'my-sticky-elements-new-widget', 'mystickyelements-upgrade-to-pro', 'my-sticky-elements-integration', 'my-sticky-elements-analytics', 'my-sticky-elements-leads', 'my-sticky-elements-upgrade']; |
| 19 |
|
| 20 |
// constructor |
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
|
| 24 |
$page = $_GET['page'] ?? ''; |
| 25 |
// Check if we're on one of those pages |
| 26 |
if (in_array($page, self::$allowed_pages, true)) { |
| 27 |
// register enqueue css |
| 28 |
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
| 29 |
// add need help in footer |
| 30 |
add_action('admin_footer', array($this, 'admin_footer_need_help_content')); |
| 31 |
} |
| 32 |
|
| 33 |
// add ajax action |
| 34 |
add_action('wp_ajax_hide_mse_help_cta', array($this, 'hide_mse_help_cta')); |
| 35 |
|
| 36 |
}//end __construct() |
| 37 |
|
| 38 |
// load help settings |
| 39 |
public function load_help_settings() |
| 40 |
{ |
| 41 |
define('MSE_FOOTER_HELP_DATA', array( |
| 42 |
'help_icon' => esc_url(MYSTICKYELEMENTS_URL."images/help/help-icon.svg"), |
| 43 |
'close_icon' => esc_url(MYSTICKYELEMENTS_URL."images/help/close.svg"), |
| 44 |
'premio_site_info' => esc_url('https://premio.io/'), |
| 45 |
'help_center_link' => esc_url('https://premio.io/help/mystickyelements/?utm_source=pluginspage'), |
| 46 |
'footer_menu' => array( |
| 47 |
'support' => array( |
| 48 |
'title' => esc_html("Get Support", "mystickyelements"), |
| 49 |
'link' => esc_url("https://premio.io/help/mystickyelements"), |
| 50 |
'status' => true, |
| 51 |
), |
| 52 |
'upgrade_to_pro' => array( |
| 53 |
'title' => esc_html("Upgrade to Pro", "mystickyelements"), |
| 54 |
'link' => esc_url(admin_url("admin.php?page=my-sticky-elements-upgrade")), |
| 55 |
'status' => true, |
| 56 |
), |
| 57 |
'recommended_plugins' => array( |
| 58 |
'title' => esc_html("Recommended Plugins", "mystickyelements"), |
| 59 |
'link' => esc_url(admin_url("admin.php?page=recommended-plugins")), |
| 60 |
'status' => get_option("hide_mserecommended_plugin") ? false : true, |
| 61 |
), |
| 62 |
'live_link' => array( |
| 63 |
'title' => esc_html("Add Live Chat", "mystickyelements"), |
| 64 |
'link' => esc_url(admin_url("admin.php?page=my-sticky-elements-chatway-plugin")), |
| 65 |
'status' => class_exists('Chatway') ? false : true, |
| 66 |
), |
| 67 |
), |
| 68 |
'support_widget' => array( |
| 69 |
'upgrade_to_pro' => array( |
| 70 |
'title' => esc_html("Upgrade to Pro", "mystickyelements"), |
| 71 |
'link' => esc_url(admin_url("admin.php?page=my-sticky-elements-upgrade")), |
| 72 |
'icon' => esc_url(MYSTICKYELEMENTS_URL."images/help/pro.svg"), |
| 73 |
), |
| 74 |
'get_support' => array( |
| 75 |
'title' => esc_html("Get Support", "mystickyelements"), |
| 76 |
'link' => esc_url("https://premio.io/help/mystickyelements"), |
| 77 |
'icon' => esc_url(MYSTICKYELEMENTS_URL."images/help/help-circle.svg"), |
| 78 |
), |
| 79 |
'contact' => array( |
| 80 |
'title' => esc_html("Contact Us", "mystickyelements"), |
| 81 |
'link' => false, |
| 82 |
'icon' => esc_url(MYSTICKYELEMENTS_URL."images/help/headphones.svg"), |
| 83 |
), |
| 84 |
), |
| 85 |
)); |
| 86 |
} |
| 87 |
|
| 88 |
// enqueue scripts |
| 89 |
public function admin_enqueue_scripts() |
| 90 |
{ |
| 91 |
// enqueue css |
| 92 |
wp_enqueue_style('mystickyelements-help-css', MYSTICKYELEMENTS_URL . 'dist/css/help.css', array(), MY_STICKY_ELEMENT_VERSION); |
| 93 |
|
| 94 |
} |
| 95 |
|
| 96 |
// Need Help Footer Content |
| 97 |
public function admin_footer_need_help_content() |
| 98 |
{ |
| 99 |
$this->load_help_settings(); |
| 100 |
|
| 101 |
include_once MYSTICKYELEMENTS_PATH.'/admin/help.php'; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
// Hide MSE Help CTA |
| 106 |
public function hide_mse_help_cta() |
| 107 |
{ |
| 108 |
$response = array(); |
| 109 |
$response['status'] = 0; |
| 110 |
$response['error'] = 0; |
| 111 |
$response['data'] = array(); |
| 112 |
$response['message'] = ""; |
| 113 |
$postData = filter_input_array(INPUT_POST); |
| 114 |
$errorCounter = 0; |
| 115 |
if (!isset($postData['nonce']) || empty($postData['nonce'])) { |
| 116 |
$response['message'] = esc_html__("Your request is not valid", 'mystickyelements'); |
| 117 |
$errorCounter++; |
| 118 |
} else { |
| 119 |
$nonce = esc_attr($postData['nonce']); |
| 120 |
if (!wp_verify_nonce($nonce, 'hide_mse_help_cta')) { |
| 121 |
$response['message'] = esc_html__("Your request is not valid", 'mystickyelements'); |
| 122 |
$errorCounter++; |
| 123 |
} |
| 124 |
} |
| 125 |
if ($errorCounter == 0) { |
| 126 |
$response['status'] = 1; |
| 127 |
add_option("mse_help_cta", "yes"); |
| 128 |
} |
| 129 |
echo wp_json_encode($response); |
| 130 |
die; |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
} |
| 135 |
new MSE_HELP(); |
| 136 |
|