PluginProbe
Leadfeeder / 1.3.1
Leadfeeder v1.3.1
1.3.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0
dealfront / dealfront.php

dealfront.php in Leadfeeder 1.3.1, at dealfront.php

148 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Leadfeeder
4 * Description: Turn page views into pipeline
5 * Author: Leadfeeder
6 * Author URI: https://www.leadfeeder.com/?utm_source=wordpress&utm_medium=plugin
7 * Version: 1.3.1
8 * License: GPLv3
9 * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
10 * Text Domain: dealfront
11 *
12 */
13
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 define(
19 'DEALFRONT_PLUGIN_MENU_LABEL',
20 'Leadfeeder'
21 );
22
23 define(
24 'DEALFRONT_PLUGIN_BASENAME',
25 plugin_basename(__FILE__)
26 );
27
28 add_action('plugins_loaded', 'dealfront_plugin_init');
29
30 function dealfront_plugin_init()
31 {
32
33 if (class_exists('LeadfeederByDealfront')) {
34 return LeadfeederByDealfront::get_instance();
35 }
36
37 class LeadfeederByDealfront
38 {
39 /**
40 * @var Const Plugin Version Number
41 */
42 const VERSION = '1.3.1';
43
44 /**
45 * @var Singleton The reference the *Singleton* instance of this class
46 */
47 private static $instance;
48
49 /**
50 * Returns the *Singleton* instance of this class.
51 *
52 * @return Singleton The *Singleton* instance.
53 */
54 public static function get_instance()
55 {
56 if (null === self::$instance) {
57 self::$instance = new self();
58 }
59 return self::$instance;
60 }
61
62 /**
63 * Protected constructor to prevent creating a new instance of the
64 * *Singleton* via the `new` operator from outside of this class.
65 */
66 private function __construct()
67 {
68 add_action('admin_init', array($this, 'install'));
69 add_action('admin_enqueue_scripts', array($this, 'enqueue_validator_script'));
70 add_filter('plugin_action_links', array($this, 'add_settings_link'), 10, 2);
71 $this->init();
72 }
73
74 /**
75 * Init the plugin after plugins_loaded so environment variables are set.
76 *
77 * @since 1.2.0
78 */
79 public function init()
80 {
81 require_once(dirname(__FILE__) . '/admin/views/admin.php');
82 $dealfront = new Dealfront();
83 $dealfront->init();
84 }
85
86 public function enqueue_validator_script()
87 {
88 wp_enqueue_script(
89 'dealfront',
90 plugins_url('admin/static/validator.js', __FILE__),
91 array('jquery'),
92 1714557814, // timestamp when the js was modified, remember to update this when you modify the js code
93 array('in_footer' => true)
94 );
95 }
96
97 /**
98 * Updates the plugin version in db
99 *
100 * @since 1.2.0
101 */
102 public function update_plugin_version()
103 {
104 delete_option('dealfront_version');
105 update_option('dealfront_version', self::VERSION);
106 }
107
108 /**
109 * Handles upgrade routines.
110 *
111 * @since 1.2.0
112 */
113 public function install()
114 {
115 if (!is_plugin_active(plugin_basename(__FILE__))) {
116 return;
117 }
118
119 if ((self::VERSION !== get_option('dealfront_version'))) {
120
121 $this->update_plugin_version();
122 }
123 }
124
125 /**
126 * Adds plugin action links.
127 *
128 * @since 1.2.0
129 */
130 public function add_settings_link($links, $file)
131 {
132 if ( $file != DEALFRONT_PLUGIN_BASENAME ) {
133 return $links;
134 }
135
136 $plugin_links = array(
137 sprintf(
138 '<a href="%s">Settings</a>',
139 esc_url(admin_url("admin.php?page=tracker_settings"))
140 )
141 );
142 return array_merge($plugin_links, $links);
143 }
144 }
145
146 LeadfeederByDealfront::get_instance();
147 }
148