| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
class Dealfront |
| 7 |
{ |
| 8 |
|
| 9 |
public function init() |
| 10 |
{ |
| 11 |
$this->init_dealfront_admin(); |
| 12 |
$this->enqueue_script(); |
| 13 |
$this->enqueue_admin_styles(); |
| 14 |
} |
| 15 |
|
| 16 |
public function init_dealfront_admin() |
| 17 |
{ |
| 18 |
register_setting('dealfront', 'leadfeeder_tracker_id'); |
| 19 |
add_action('admin_menu', array($this, 'create_dealfront_nav_page')); |
| 20 |
} |
| 21 |
|
| 22 |
public function create_dealfront_nav_page() |
| 23 |
{ |
| 24 |
require_once plugin_dir_path(__DIR__) . '/../admin/includes/logo.php'; |
| 25 |
$menu_icon = (new Dealfront_Logo())->get_base64_logo(); |
| 26 |
|
| 27 |
add_menu_page( |
| 28 |
DEALFRONT_PLUGIN_MENU_LABEL, |
| 29 |
DEALFRONT_PLUGIN_MENU_LABEL, |
| 30 |
'manage_options', |
| 31 |
'tracker_settings', |
| 32 |
array($this, 'admin_view'), |
| 33 |
$menu_icon |
| 34 |
); |
| 35 |
} |
| 36 |
|
| 37 |
public static function admin_view() |
| 38 |
{ |
| 39 |
require_once plugin_dir_path(__FILE__) . 'settings.php'; |
| 40 |
} |
| 41 |
|
| 42 |
public static function dealfront_script() |
| 43 |
{ |
| 44 |
$leadfeeder_tracker_id = sanitize_text_field(get_option('leadfeeder_tracker_id')); |
| 45 |
$is_admin = is_admin(); |
| 46 |
|
| 47 |
if (!$leadfeeder_tracker_id) { |
| 48 |
return; |
| 49 |
} |
| 50 |
|
| 51 |
if ($is_admin) { |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
if (strpos($leadfeeder_tracker_id, 'v1') === 0) { |
| 56 |
$leadfeeder_tracker_id = explode('_', $leadfeeder_tracker_id)[1]; |
| 57 |
} |
| 58 |
|
| 59 |
require_once plugin_dir_path(__DIR__) . '/../admin/includes/script-generator.php'; |
| 60 |
} |
| 61 |
|
| 62 |
private function enqueue_script() |
| 63 |
{ |
| 64 |
add_action('wp_head', array($this, 'dealfront_script')); |
| 65 |
} |
| 66 |
|
| 67 |
private function enqueue_admin_styles() |
| 68 |
{ |
| 69 |
add_action('admin_enqueue_scripts', array($this, 'dealfront_admin_styles')); |
| 70 |
} |
| 71 |
|
| 72 |
public static function dealfront_admin_styles() |
| 73 |
{ |
| 74 |
wp_register_style( |
| 75 |
'dealfront_custom_admin_style', |
| 76 |
plugins_url('../static/dealfront-admin.css', __FILE__), |
| 77 |
array(), |
| 78 |
1717676114 // timestamp when the css was modified |
| 79 |
); |
| 80 |
wp_enqueue_style('dealfront_custom_admin_style'); |
| 81 |
} |
| 82 |
} |
| 83 |
?> |
| 84 |
|