Advertisement
Guest User

Untitled

a guest
May 23rd, 2022
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.57 KB | None
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. /**
  15. * The admin-specific functionality of the plugin.
  16. *
  17. * Defines the plugin name, version, and two examples hooks for how to
  18. * enqueue the admin-specific stylesheet and JavaScript.
  19. *
  20. * @package Architect_Ink
  21. * @subpackage Architect_Ink/admin
  22. * @author architect.ink <contact@architect.ink>
  23. */
  24. class Architect_Ink_Admin
  25. {
  26. /**
  27. * The ID of this plugin.
  28. *
  29. * @since 1.0.0
  30. * @access private
  31. * @var string $plugin_name The ID of this plugin.
  32. */
  33. private $plugin_name;
  34. /**
  35. * The version of this plugin.
  36. *
  37. * @since 1.0.0
  38. * @access private
  39. * @var string $version The current version of this plugin.
  40. */
  41. private $version;
  42. /**
  43. * The locale
  44. *
  45. * @since 1.0.0
  46. * @access private
  47. * @var string $version The locale of this plugin.
  48. */
  49. private $locale;
  50. /**
  51. * The plugin version is outdated
  52. *
  53. * @since 1.0.0
  54. * @access private
  55. * @var string $version The locale of this plugin.
  56. */
  57. private $is_outdated;
  58.  
  59. /**
  60. * Initialize the class and set its properties.
  61. *
  62. * @since 1.0.0
  63. * @param string $plugin_name The name of this plugin.
  64. * @param string $version The version of this plugin.
  65. */
  66. public function __construct($plugin_name, $version)
  67. {
  68. $this->plugin_name = $plugin_name;
  69. $this->version = $version;
  70. $this->locale = $this->getDefaultLocale();
  71. $this->generateRequestsJob = new Architect\Jobs\GenerateRequests();
  72. }
  73.  
  74. /**
  75. * Register the stylesheets for the admin area.
  76. *
  77. * @since 1.0.0
  78. */
  79. public function enqueue_styles()
  80. {
  81. wp_enqueue_style($this->plugin_name . '-toastify', plugin_dir_url(__FILE__) . 'css/libs/toastify.css', [], $this->version, 'all');
  82. wp_enqueue_style($this->plugin_name . '-datatable', plugin_dir_url(__FILE__) . 'css/libs/jquery.dataTables.css', [], $this->version, 'all');
  83. wp_enqueue_style($this->plugin_name . '-daterangepicker', plugin_dir_url(__FILE__) . 'css/libs/daterangepicker.css', [], $this->version, 'all');
  84. wp_enqueue_style($this->plugin_name . '-normalize', plugin_dir_url(__FILE__) . 'css/normalize.css', [], $this->version, 'all');
  85. wp_enqueue_style($this->plugin_name . '-tailwind', plugin_dir_url(__FILE__) . 'css/tailwind.css', [], $this->version, 'all');
  86. wp_enqueue_style($this->plugin_name . '-core', plugin_dir_url(__FILE__) . 'css/architect-ink-admin.css', [], $this->version, 'all');
  87. }
  88.  
  89. /**
  90. * Register the JavaScript for the admin area.
  91. *
  92. * @since 1.0.0
  93. */
  94. public function enqueue_scripts()
  95. {
  96. $plugin = $this->plugin_name;
  97. $this->load_script('toastify', 'libs/toastify.js');
  98. $this->load_script('datatable', 'libs/jquery.dataTables.js', ['jquery']);
  99. $this->load_script('daterangepicker', 'libs/daterangepicker.js', ['jquery', 'moment']);
  100. $this->load_script('textarea-tabulation', 'libs/textarea-tabulation.js', ['jquery']);
  101. wp_enqueue_script('jquery-ui-sortable');
  102. $this->load_script('nested-sortable', 'libs/jquery.nestedSortable.js', ['jquery-ui-sortable']);
  103. $this->load_script('api', 'utils/api.js', ['jquery']);
  104. $this->load_script('help', 'utils/help.js', ['jquery']);
  105. $this->load_script('toast', 'components/toast.js', [], ['toastify']);
  106. $this->load_script('button', 'components/button.js', ['jquery']);
  107. $this->load_script('range-slider', 'components/range-slider.js', ['jquery']);
  108. $this->load_script('dropdown', 'components/dropdown.js', ['jquery']);
  109. $this->load_script('languages-dropdown', 'components/languages-dropdown.js', ['jquery', 'lodash'], ['dropdown']);
  110. $this->load_script('modal', 'components/modal.js', ['jquery']);
  111. $this->load_script('toggle', 'components/toggle.js', ['jquery']);
  112. $this->load_script('publishing', 'publishing.js', ['jquery'], ['daterangepicker']);
  113. $this->load_script('input-single', 'content-generator-modules/input-types/single.js', ['jquery'], ['button', 'toast', 'dropdown', 'languages-dropdown', 'nested-sortable']);
  114. $this->load_script('input-multi', 'content-generator-modules/input-types/multi.js', ['jquery'], ['button', 'toast', 'dropdown', 'languages-dropdown']);
  115. $this->load_script('input-rss', 'content-generator-modules/input-types/rss.js', ['jquery'], ['button', 'toast', 'dropdown', 'languages-dropdown']);
  116. $this->load_script('input-edit', 'content-generator-modules/input-types/edit.js', ['jquery'], ['button', 'toast', 'dropdown', 'languages-dropdown']);
  117. $this->load_script('input-gapfill', 'content-generator-modules/input-types/gapfill.js', ['jquery'], ['button', 'toast', 'dropdown', 'languages-dropdown', 'modal']);
  118. $this->load_script('input', 'content-generator-modules/input.js', ['jquery', 'lodash'], ['input-single', 'input-multi', 'input-rss', 'input-edit']);
  119. $this->load_script('text', 'content-generator-modules/text.js', ['jquery', 'lodash']);
  120. $this->load_script('custom', 'content-generator-modules/custom.js', ['jquery', 'lodash']);
  121. $this->load_script('images', 'content-generator-modules/images.js', ['jquery', 'lodash'], ['dropdown']);
  122. $this->load_script('video', 'content-generator-modules/video.js', ['jquery', 'lodash'], ['dropdown']);
  123. $this->load_script('local', 'content-generator-modules/local.js', ['jquery', 'lodash']);
  124. $this->load_script('seo', 'content-generator-modules/seo.js', ['jquery', 'lodash']);
  125. $this->load_script('spin', 'content-generator-modules/spin.js', ['jquery', 'lodash'], ['dropdown']);
  126. $this->load_script('translate', 'content-generator-modules/translate.js', ['jquery', 'lodash'], ['dropdown', 'languages-dropdown']);
  127. $this->load_script('output', 'content-generator-modules/output.js', ['jquery', 'lodash']);
  128. $this->load_script('content-generator', 'pages/content-generator.js', ['jquery'], ['input', 'languages-dropdown', 'dropdown', 'toast', 'toggle', 'text', 'custom', 'images', 'video', 'local', 'seo', 'spin', 'translate', 'output']);
  129. $this->load_script('manage-task', 'pages/manage-task.js', ['jquery'], ['button', 'toast', 'api', 'dropdown', 'toggle', 'text', 'custom', 'images', 'video', 'local', 'seo', 'spin', 'translate', 'output']);
  130. $this->load_script('settings', 'pages/settings.js', ['jquery'], ['button', 'toast', 'translate', 'api']);
  131. $this->load_script('linking', 'pages/linking.js', ['jquery'], ['button', 'toast', 'api']);
  132. $this->load_script('login', 'pages/login.js', ['jquery'], ['button', 'api']);
  133. $this->load_script('tasks', 'pages/tasks.js', ['jquery', 'moment'], ['button', 'toast', 'api', 'modal']);
  134. $this->load_script('pages', 'pages/pages.js', ['jquery', 'moment'], ['button', 'toast', 'api', 'modal']);
  135. $this->load_script('templates', 'pages/templates.js', ['jquery', 'moment'], ['modal', 'toast', 'api']);
  136. if (defined('ARCHITECT_INK_LOG') && ARCHITECT_INK_LOG) {
  137. $this->load_script('logs', 'pages/logs.js', ['jquery'], ['button', 'toast', 'api']);
  138. }
  139.  
  140. $this->load_script('architect-admin', 'architect-admin.js', ['jquery'], ['api', 'toast']);
  141. wp_add_inline_script($plugin . '-api', 'var architect_ink_ajaxurl = "' . admin_url('admin-ajax.php') . '";');
  142. wp_add_inline_script($plugin . '-api', 'var architect_ink_nonce = "' . wp_create_nonce('architect-ink-nonce') . '";');
  143. wp_add_inline_script($plugin . '-tasks', 'var architect_task_manage = "' . admin_url('admin.php?page=architect-ink-tasks&sub=manage&task=') . '";');
  144. wp_add_inline_script($plugin . '-tasks', 'var architect_pages_list_url = "' . admin_url('admin.php?page=architect-ink-tasks&sub=pages&task=') . '";');
  145. wp_add_inline_script($plugin . '-content-generator', 'var architect_pages_list_url = "' . admin_url('admin.php?page=architect-ink-tasks&sub=pages&task=') . '";');
  146. wp_add_inline_script($plugin . '-architect-admin', 'var architect_images_path = "' . plugin_dir_url(__FILE__) . 'images' . '";');
  147. wp_add_inline_script($plugin . '-architect-admin', 'var architect_default_locale = "' . $this->locale . '";');
  148. }
  149.  
  150. private function load_script($name, $path, $wordpressDependencies = [], $pluginDependencies = [])
  151. {
  152. $name = $this->plugin_name . '-' . $name;
  153. $url = plugin_dir_url(__FILE__) . 'js/' . $path;
  154. $dependencies = $wordpressDependencies;
  155.  
  156. foreach ($pluginDependencies as $dep) {
  157. $dependencies[] = $this->plugin_name . '-' . $dep;
  158. }
  159.  
  160. wp_enqueue_script($name, $url, $dependencies, $this->version, false);
  161. }
  162.  
  163. /**
  164. * Create the Kiwys Lite menu page with add_menu_page()
  165. *
  166. * @since 1.0.0
  167. */
  168. public function menu()
  169. {
  170. add_menu_page('architect.ink', 'architect.ink', 'manage_options', $this->plugin_name, [$this, 'load_admin_page_content_generator'], plugin_dir_url(__FILE__) . 'images/logo-sidebar.png', 5);
  171. add_submenu_page($this->plugin_name, 'architect.ink', __('Content generator', 'architect-ink'), 'manage_options', $this->plugin_name, [$this, 'load_admin_page_content_generator']);
  172. add_submenu_page($this->plugin_name, 'architect.ink', __('Tasks', 'architect-ink'), 'manage_options', $this->plugin_name . '-tasks', [$this, 'load_admin_page_tasks']);
  173. add_submenu_page($this->plugin_name, 'architect.ink', __('Templates', 'architect-ink'), 'manage_options', $this->plugin_name . '-templates', [$this, 'load_admin_page_templates']);
  174. add_submenu_page($this->plugin_name, 'architect.ink', 'Maillage', 'manage_options', $this->plugin_name . '-linking', [$this, 'load_admin_page_linking']);
  175. add_submenu_page($this->plugin_name, 'architect.ink', __('Settings', 'architect-ink'), 'manage_options', $this->plugin_name . '-settings', [$this, 'load_admin_page_settings']);
  176. if (defined('ARCHITECT_INK_LOG') && ARCHITECT_INK_LOG) {
  177. add_submenu_page($this->plugin_name, 'architect.ink', 'Logs', 'manage_options', $this->plugin_name . '-logs', [$this, 'load_admin_page_logs']);
  178. }
  179. if (defined('ARCHITECT_INK_TEST') && ARCHITECT_INK_TEST) {
  180. add_submenu_page($this->plugin_name, 'architect.ink', 'Test', 'manage_options', $this->plugin_name . '-test', [$this, 'load_admin_page_test']);
  181. }
  182.  
  183. $updates = get_plugin_updates();
  184. $this->is_outdated = isset($updates[$this->plugin_name . '/' . $this->plugin_name . '.php']);
  185. }
  186.  
  187. /**
  188. * Load the plugin admin content generator page.
  189. *
  190. * @since 1.0.0
  191. */
  192. public function load_admin_page_content_generator()
  193. {
  194. if (!Architect_Ink_Licence::isAuth()) {
  195. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-login.php';
  196. return NULL;
  197. }
  198.  
  199. require_once plugin_dir_path(__FILE__) . 'views/content-generator/architect-ink-admin-content-generator.php';
  200. }
  201.  
  202. /**
  203. * Load the plugin admin tasks page.
  204. *
  205. * @since 1.0.0
  206. */
  207. public function load_admin_page_tasks()
  208. {
  209. if (!Architect_Ink_Licence::isAuth()) {
  210. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-login.php';
  211. return NULL;
  212. }
  213.  
  214. $subPage = 'index';
  215.  
  216. if (isset($_GET['sub'])) {
  217. switch ($_GET['sub']) {
  218. case 'manage':
  219. $subPage = 'manage';
  220. $task = Architect\Models\Job::find($_GET['task']);
  221. break;
  222. case 'pages':
  223. $subPage = 'pages';
  224. $task = Architect\Models\Job::find($_GET['task']);
  225. break;
  226. default:
  227. $subPage = 'index';
  228. }
  229. }
  230.  
  231. require_once plugin_dir_path(__FILE__) . 'views/tasks/architect-ink-admin-tasks.php';
  232. }
  233.  
  234. public function load_admin_page_templates()
  235. {
  236. if (!Architect_Ink_Licence::isAuth()) {
  237. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-login.php';
  238. return NULL;
  239. }
  240.  
  241. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-templates.php';
  242. }
  243.  
  244. /**
  245. * Load the plugin admin settings page.
  246. *
  247. * @since 1.0.0
  248. */
  249. public function load_admin_page_settings()
  250. {
  251. if (!Architect_Ink_Licence::isAuth()) {
  252. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-login.php';
  253. return NULL;
  254. }
  255.  
  256. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-settings.php';
  257. }
  258.  
  259. /**
  260. * Load the plugin admin linking page.
  261. *
  262. * @since 1.0.0
  263. */
  264. public function load_admin_page_linking()
  265. {
  266. if (!Architect_Ink_Licence::isAuth()) {
  267. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-login.php';
  268. return NULL;
  269. }
  270.  
  271. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-linking.php';
  272. }
  273.  
  274. /**
  275. * Load the plugin admin test page.
  276. * To be deleted
  277. *
  278. * @since 1.0.0
  279. */
  280. public function load_admin_page_logs()
  281. {
  282. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-logs.php';
  283. }
  284.  
  285. /**
  286. * Load the plugin admin test page.
  287. * To be deleted
  288. *
  289. * @since 1.0.0
  290. */
  291. public function load_admin_page_test()
  292. {
  293. require_once plugin_dir_path(__FILE__) . 'views/architect-ink-admin-test.php';
  294. }
  295.  
  296. public function login()
  297. {
  298. status_header(200);
  299.  
  300. if ($this->verifyNonce('_ajax_nonce')) {
  301. if (isset($_POST['data'])) {
  302. $data = json_decode(stripcslashes($_POST['data']), true);
  303. $errors = [];
  304.  
  305. if (!isset($data['email'])) {
  306. $errors['email'] = 'The email field is required.';
  307. }
  308.  
  309. if (!isset($data['password'])) {
  310. $errors['password'] = 'The password field is required.';
  311. }
  312.  
  313. if (0 < count($errors)) {
  314. $this->response(['success' => false, 'errors' => $errors]);
  315. }
  316.  
  317. $email = $data['email'];
  318. $password = $data['password'];
  319. return $this->response(Architect_Ink_Licence::login($email, $password));
  320. ............................................................................
  321. ....................................................
  322. .....................
Advertisement
RAW Paste Data Copied
Advertisement