PluginProbe ʕ •ᴥ•ʔ
Syncee Premium Dropshipping & Wholesale / 1.0.29
Syncee Premium Dropshipping & Wholesale v1.0.29
1.0.28 1.0.29 1.0.27 trunk 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26
syncee-global-dropshipping / Syncee.php
syncee-global-dropshipping Last commit date
JS 2 weeks ago View 2 weeks ago img 3 years ago includes 2 weeks ago Syncee.php 2 weeks ago plugin.php 2 weeks ago readme.txt 2 weeks ago
Syncee.php
187 lines
1 <?php
2
3 class Syncee
4 {
5
6 private static $instance = null;
7 private $plugin_path;
8 private $plugin_url;
9
10 /**
11 * Creates or returns an instance of this class.
12 */
13 public static function get_instance()
14 {
15 // If an instance hasn't been created and set to $instance create an instance and set it to $instance.
16 if (null == self::$instance) {
17 self::$instance = new self;
18 }
19
20 return self::$instance;
21 }
22
23 /**
24 * Initializes the plugin by setting localization, hooks, filters, and administrative functions.
25 */
26 private function __construct()
27 {
28 $this->plugin_path = plugin_dir_path(__FILE__);
29 $this->plugin_url = plugin_dir_url(__FILE__);
30
31 $this->init_rests();
32
33 add_action('admin_enqueue_scripts', array($this, 'register_scripts'));
34 add_action('admin_enqueue_scripts', array($this, 'register_styles'));
35
36 $this->run_plugin();
37 }
38
39 public function get_plugin_url()
40 {
41 return $this->plugin_url;
42 }
43
44 public function get_plugin_path()
45 {
46 return $this->plugin_path;
47 }
48
49 /**
50 * Enqueue and register JavaScript files here.
51 */
52 public function register_scripts($hook_suffix = '')
53 {
54 if (!is_admin()) {
55 return;
56 }
57 if (!current_user_can('manage_options')) {
58 return;
59 }
60 if ('toplevel_page_syncee' !== $hook_suffix) {
61 return;
62 }
63
64 wp_enqueue_script(
65 'syncee-frontend-js',
66 plugins_url('/JS/index.js', __FILE__),
67 ['jquery'],
68 SYNCEE_PLUGIN_VERSION,
69 true
70 );
71
72 wp_enqueue_script(
73 'syncee-frontend-js-sweetalert',
74 plugins_url('/JS/sweetalert.js', __FILE__),
75 [],
76 SYNCEE_PLUGIN_VERSION
77 );
78
79 // SECURITY: sensitive options (syncee_access_token, syncee_user_token,
80 // data_to_syncee_installer) MUST NOT be localized here. JS reads them
81 // from the capability-gated getDataForFrontend REST endpoint.
82 wp_localize_script(
83 'syncee-frontend-js',
84 'syncee_globals',
85 [
86 'rest_url' => esc_url_raw(get_option('siteurl') . SYNCEE_RETAILER_REST_PATH),
87 'site_url' => esc_url_raw(get_option('siteurl')),
88 'syncee_url' => SYNCEE_URL,
89 'syncee_installer_url' => SYNCEE_INSTALLER_URL,
90 'img_dir_url' => plugins_url('/img/', __FILE__),
91 'syncee_retailer_nonce' => wp_create_nonce('wp_rest'),
92 ]
93 );
94 }
95
96 /**
97 * Enqueue and register CSS files here.
98 */
99 public function register_styles($hook_suffix = '')
100 {
101 if (!is_admin()) {
102 return;
103 }
104 if (!current_user_can('manage_options')) {
105 return;
106 }
107 if ('toplevel_page_syncee' !== $hook_suffix) {
108 return;
109 }
110
111 wp_enqueue_style('syncee-admin-css', plugins_url('/View/index.css', __FILE__), [], SYNCEE_PLUGIN_VERSION);
112 }
113
114 public function displayInterface()
115 {
116 echo '<div class="wrap js-syncee-admin-interface">';
117 esc_html_e('Loading, please wait...', 'syncee');
118 echo '</div>';
119 }
120
121 function registerMenu()
122 {
123 $icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMjQyIDIwNzAuNyI+CiAgPGRlZnM+CiAgICA8c3R5bGU+CiAgICAgIC5jbHMtMSB7CiAgICAgICAgZmlsbDogIzI4NmRmODsKICAgICAgfQogICAgPC9zdHlsZT4KICAKICAKICAKICAGPC9zdHl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cuOSwxNTIsMjEyLjksNy40LDM2My44LTEwNC4zLDQyNi0zMDgsMTUuNi01MS4yLDU4LjMtNzguNSwxMDIuNC02NS41LDQ0LjUsMTMsNjQuMyw1My44LDUxLjgsMTA2LjdaIi8+Cjwvc3ZnPg==';
124
125 add_menu_page(
126 "Syncee",
127 "Syncee",
128 "manage_options",
129 "syncee",
130 array($this, "synceeMenu"),
131 $icon,
132 '55.5'
133 );
134 }
135
136 function synceeMenu()
137 {
138 $img_url = plugins_url('/img/', SYNCEE_PLUGIN_DIR . '/plugin.php');
139 include __DIR__ . '/View/index.php';
140 }
141
142 function okToActivateSynceePlugin()
143 {
144 return in_array('woocommerce/woocommerce.php', get_option('active_plugins'));
145 }
146
147 function uninstallSynceePlugin()
148 {
149 if (in_array('Syncee/plugin.php', get_option('active_plugins')))
150 deactivate_plugins(['Syncee/plugin.php']);
151 if (in_array('syncee-global-dropshipping', get_option('active_plugins')))
152 deactivate_plugins(['syncee-global-dropshipping/plugin.php']);
153
154 }
155
156 function sendErrorMessage($title, $desc)
157 {
158 echo '<div class="error"><p>' . esc_html($title) . '</p><p><b>Error: </b>' . esc_html($desc) . '</p></div>';
159 }
160
161 function removePluginActivatedMessage()
162 {
163 unset($_GET['activate'], $_GET['error']);
164 }
165
166 /**
167 * Place code for your plugin's functionality here.
168 */
169 private function run_plugin()
170 {
171 // if ($this->okToActivateSynceePlugin()) {
172 add_action('admin_menu', array($this, 'registerMenu'));
173 // } else {
174 // $this->uninstallSynceePlugin();
175 // $this->removePluginActivatedMessage();
176 // $this->sendErrorMessage('Syncee plugin', 'WooCoommerce needs to be installed and activated before you can activate Syncee plugin.');
177 // }
178 }
179
180 private function init_rests()
181 {
182 include_once SYNCEE_PLUGIN_DIR . '/includes/RestForSyncee.php';
183 }
184 }
185
186 Syncee::get_instance();
187