| @@ -51,9 +51,8 @@ | ||
| 51 | 51 | add_action('wp_ajax_e2pdf_visual_mapper', [new Controller_E2pdf_Templates(), 'ajax_visual_mapper']); |
| 52 | 52 | add_action('wp_ajax_e2pdf_get_styles', [new Controller_E2pdf_Templates(), 'ajax_get_styles']); |
| 53 | 53 | add_action('wp_ajax_e2pdf_email', [new Controller_E2pdf_Templates(), 'ajax_email']); |
| 54 | 54 | add_action('wp_ajax_e2pdf_license_key', [new Controller_E2pdf_License(), 'ajax_change_license_key']); |
| 55 | - add_action('wp_ajax_e2pdf_restore_license_key', [new Controller_E2pdf_License(), 'ajax_restore_license_key']); | |
| 56 | 55 | add_action('wp_ajax_e2pdf_deactivate_all_templates', [new Controller_E2pdf_License(), 'ajax_deactivate_all_templates']); |
| 57 | 56 | add_action('wp_ajax_e2pdf_templates', [new Controller_E2pdf(), 'ajax_templates']); |
| 58 | 57 | add_action('wp_ajax_e2pdf_dataset', [new Controller_E2pdf(), 'ajax_dataset']); |
| 59 | 58 | add_action('wp_ajax_e2pdf_datasets_refresh', [new Controller_E2pdf(), 'ajax_datasets_refresh']); |
| @@ -70,9 +69,9 @@ | ||
| 70 | 69 | public function load_actions() { |
| 71 | 70 | if (is_admin()) { |
| 72 | 71 | add_action('wpmu_new_blog', [&$this, 'action_wpmu_new_blog']); |
| 73 | 72 | add_action('admin_menu', [&$this, 'action_admin_menu']); |
| 74 | - add_action('admin_init', [&$this, 'action_admin_init']); | |
| 73 | + add_action('admin_init', [&$this, 'action_admin_init'], 9); | |
| 75 | 74 | add_action('admin_enqueue_scripts', [&$this, 'action_admin_enqueue_scripts']); |
| 76 | 75 | add_action('current_screen', [&$this, 'action_current_screen']); |
| 77 | 76 | add_action('plugins_loaded', [&$this, 'action_plugins_loaded']); |
| 78 | 77 | } |
| @@ -502,8 +501,41 @@ | ||
| 502 | 501 | |
| 503 | 502 | // settings page |
| 504 | 503 | public function action_admin_init() { |
| 505 | 504 | register_setting('e2pdf-settings', 'e2pdf_debug'); |
| 505 | + | |
| 506 | + /** | |
| 507 | + * Compatibility fix with Gallery : FooGallery | |
| 508 | + * https://wordpress.org/plugins/foogallery/ | |
| 509 | + */ | |
| 510 | + if (class_exists('FooGallery_Admin_Extensions')) { | |
| 511 | + if (!wp_doing_ajax()) { | |
| 512 | + return; | |
| 513 | + } | |
| 514 | + $action = isset($_REQUEST['action']) && is_string($_REQUEST['action']) ? $_REQUEST['action'] : ''; | |
| 515 | + if ('e2pdf_upload' !== $action) { | |
| 516 | + return; | |
| 517 | + } | |
| 518 | + global $wp_filter; | |
| 519 | + if (isset($wp_filter['admin_init']) && $wp_filter['admin_init'] instanceof WP_Hook) { | |
| 520 | + foreach ($wp_filter['admin_init']->callbacks as $priority => $callbacks) { | |
| 521 | + if (!is_array($callbacks)) { | |
| 522 | + continue; | |
| 523 | + } | |
| 524 | + foreach ($callbacks as $callback) { | |
| 525 | + if ( | |
| 526 | + isset($callback['function']) && | |
| 527 | + is_array($callback['function']) && | |
| 528 | + isset($callback['function'][0], $callback['function'][1]) && | |
| 529 | + $callback['function'][0] instanceof FooGallery_Admin_Extensions && | |
| 530 | + 'handle_extension_action' === $callback['function'][1] | |
| 531 | + ) { | |
| 532 | + remove_action('admin_init', $callback['function'], $priority); | |
| 533 | + } | |
| 534 | + } | |
| 535 | + } | |
| 536 | + } | |
| 537 | + } | |
| 506 | 538 | } |
| 507 | 539 | |
| 508 | 540 | // admin_enqueue_scripts action |
| 509 | 541 | public function action_admin_enqueue_scripts($page) { |
| @@ -858,8 +890,15 @@ | ||
| 858 | 890 | 'Quick Props' => __('Quick Props', 'e2pdf'), |
| 859 | 891 | 'The Template ID used in the backup will be overwritten. Continue?' => __('The Template ID used in the backup will be overwritten. Continue?', 'e2pdf'), |
| 860 | 892 | /* translators: %d: Template ID */ |
| 861 | 893 | 'This will overwrite the Template ID "%d". Continue?' => __('This will overwrite the Template ID "%d". Continue?', 'e2pdf'), |
| 894 | + 'Filter' => __('Filter...', 'e2pdf'), | |
| 895 | + 'Not linked' => __('Not linked', 'e2pdf'), | |
| 896 | + 'Inner Radius' => __('Inner Radius', 'e2pdf'), | |
| 897 | + 'Start Angle' => __('Start Angle', 'e2pdf'), | |
| 898 | + 'Key Labels' => __('Key Labels', 'e2pdf'), | |
| 899 | + 'Amount Labels' => __('Amount Labels', 'e2pdf'), | |
| 900 | + 'Percent Labels' => __('Percent Labels', 'e2pdf'), | |
| 862 | 901 | ]; |
| 863 | 902 | break; |
| 864 | 903 | case 'params': |
| 865 | 904 | $nonces = []; |
| @@ -924,20 +963,14 @@ | ||
| 924 | 963 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 925 | 964 | if ($current_screen->id == 'e2pdf_page_e2pdf-templates' && !isset($_GET['action'])) { |
| 926 | 965 | $screen_option = [ |
| 927 | 966 | 'label' => __('Templates per page', 'e2pdf') . ':', |
| 928 | - 'default' => get_option('e2pdf_templates_screen_per_page') ? get_option('e2pdf_templates_screen_per_page') : '20', | |
| 967 | + 'default' => (int) get_option('e2pdf_templates_screen_per_page', '20'), | |
| 929 | 968 | 'option' => 'e2pdf_templates_screen_per_page', |
| 930 | 969 | ]; |
| 931 | 970 | add_screen_option('per_page', $screen_option); |
| 932 | 971 | } |
| 933 | - | |
| 934 | - $this->helper->set('license', new Model_E2pdf_License()); | |
| 935 | - if ($this->helper->get('license')->get('error') === 'Site Url Not Found. Please try to "Reactivate" plugin.') { | |
| 936 | - update_option('e2pdf_version', '1.00.00'); | |
| 937 | - $this->action_plugins_loaded(); | |
| 938 | - $this->helper->set('license', new Model_E2pdf_License()); | |
| 939 | - } | |
| 972 | + $this->helper->load('license')->load(); | |
| 940 | 973 | } |
| 941 | 974 | |
| 942 | 975 | // wp_loaded action |
| 943 | 976 | public function action_wp_loaded() { |
| @@ -1119,8 +1152,12 @@ | ||
| 1119 | 1152 | update_option('e2pdf_adobe_api_version', '1'); |
| 1120 | 1153 | } |
| 1121 | 1154 | } |
| 1122 | 1155 | |
| 1156 | + if ((int) get_option('e2pdf_templates_screen_per_page', '20') <= 0) { | |
| 1157 | + update_option('e2pdf_templates_screen_per_page', '20'); | |
| 1158 | + } | |
| 1159 | + | |
| 1123 | 1160 | delete_option('e2pdf_developer'); |
| 1124 | 1161 | delete_option('e2pdf_developer_ips'); |
| 1125 | 1162 | delete_option('e2pdf_translatepress_translation'); |
| 1126 | 1163 | delete_option('e2pdf_wc_invoice_template_id'); |
| @@ -1128,18 +1165,12 @@ | ||
| 1128 | 1165 | delete_option('e2pdf_wc_checkout_template_id_order'); |
| 1129 | 1166 | delete_option('e2pdf_wc_cart_template_id_order'); |
| 1130 | 1167 | delete_option('e2pdf_hash_timeout'); |
| 1131 | 1168 | |
| 1132 | - $model_e2pdf_api = new Model_E2pdf_Api(); | |
| 1133 | - $model_e2pdf_api->set( | |
| 1134 | - [ | |
| 1135 | - 'action' => 'common/activate', | |
| 1136 | - ] | |
| 1137 | - ); | |
| 1138 | - $model_e2pdf_api->request(); | |
| 1139 | - | |
| 1140 | - $model_e2pdf_license = new Model_E2pdf_License(); | |
| 1141 | - $model_e2pdf_license->load_templates(); | |
| 1169 | + $license = $this->helper->load('license'); | |
| 1170 | + if ($license && method_exists($license, 'activate')) { | |
| 1171 | + $license->activate(); | |
| 1172 | + } | |
| 1142 | 1173 | |
| 1143 | 1174 | wp_clear_scheduled_hook('e2pdf_cronjob'); |
| 1144 | 1175 | if (!wp_next_scheduled('e2pdf_cache_tmp_cron')) { |
| 1145 | 1176 | wp_schedule_event(time(), 'daily', 'e2pdf_cache_tmp_cron'); |