builder
2 years ago
plugin-updates
8 years ago
settings
2 years ago
views
2 years ago
class-evf-admin-addons.php
4 years ago
class-evf-admin-assets.php
2 years ago
class-evf-admin-builder.php
7 years ago
class-evf-admin-deactivation-feedback.php
3 years ago
class-evf-admin-editor.php
4 years ago
class-evf-admin-entries-table-list.php
3 years ago
class-evf-admin-entries.php
4 years ago
class-evf-admin-form-templates.php
3 years ago
class-evf-admin-forms-table-list.php
3 years ago
class-evf-admin-forms.php
3 years ago
class-evf-admin-import-export.php
4 years ago
class-evf-admin-menus.php
2 years ago
class-evf-admin-notices.php
3 years ago
class-evf-admin-settings.php
2 years ago
class-evf-admin-tools.php
4 years ago
class-evf-admin-welcome.php
2 years ago
class-evf-admin.php
2 years ago
evf-admin-functions.php
3 years ago
class-evf-admin-addons.php
87 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Addons Page |
| 4 | * |
| 5 | * @package EverestForms/Admin |
| 6 | * @version 1.6.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * Addons Class. |
| 13 | */ |
| 14 | class EVF_Admin_Addons { |
| 15 | |
| 16 | /** |
| 17 | * Get sections for the addons screen. |
| 18 | * |
| 19 | * @return array of objects |
| 20 | */ |
| 21 | public static function get_sections() { |
| 22 | $addon_sections = get_transient( 'evf_addons_sections_list' ); |
| 23 | |
| 24 | if ( false === $addon_sections ) { |
| 25 | $addon_sections = evf_get_json_file_contents( 'assets/extensions-json/addon-sections.json' ); |
| 26 | |
| 27 | if ( $addon_sections ) { |
| 28 | set_transient( 'evf_addons_sections_list', $addon_sections, WEEK_IN_SECONDS ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return apply_filters( 'everest_forms_extensions_sections', $addon_sections ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Get section content for the extensions screen. |
| 37 | * |
| 38 | * @return array |
| 39 | */ |
| 40 | public static function get_extension_data() { |
| 41 | $extension_data = get_transient( 'evf_extensions_section_list' ); |
| 42 | |
| 43 | if ( false === $extension_data ) { |
| 44 | $extension_data = evf_get_json_file_contents( 'assets/extensions-json/sections/all_extensions.json' ); |
| 45 | |
| 46 | if ( ! empty( $extension_data->products ) ) { |
| 47 | set_transient( 'evf_extensions_section_list', $extension_data, WEEK_IN_SECONDS ); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return apply_filters( 'everest_forms_extensions_section_data', $extension_data->products ); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Handles output of the addons page in admin. |
| 56 | */ |
| 57 | public static function output() { |
| 58 | $addons = array(); |
| 59 | $sections = self::get_sections(); |
| 60 | $refresh_url = add_query_arg( |
| 61 | array( |
| 62 | 'page' => 'evf-addons', |
| 63 | 'action' => 'evf-addons-refresh', |
| 64 | 'evf-addons-nonce' => wp_create_nonce( 'refresh' ), |
| 65 | ), |
| 66 | admin_url( 'admin.php' ) |
| 67 | ); |
| 68 | $license_plan = evf_get_license_plan(); |
| 69 | $current_section = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : '_all'; // phpcs:ignore WordPress.Security.NonceVerification |
| 70 | |
| 71 | if ( '_featured' !== $current_section ) { |
| 72 | $category = isset( $_GET['section'] ) ? sanitize_text_field( wp_unslash( $_GET['section'] ) ) : null; // phpcs:ignore WordPress.Security.NonceVerification |
| 73 | $addons = self::get_extension_data( $category ); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Addon page view. |
| 78 | * |
| 79 | * @uses $addons |
| 80 | * @uses $sections |
| 81 | * @uses $refresh_url |
| 82 | * @uses $current_section |
| 83 | */ |
| 84 | include_once dirname( __FILE__ ) . '/views/html-admin-page-addons.php'; |
| 85 | } |
| 86 | } |
| 87 |