class-admin-notice-custom-css.php
1 week ago
class-admin-notices.php
1 week ago
class-admin.php
1 week ago
class-attachment-fields.php
1 week ago
class-columns.php
1 week ago
class-demo-content.php
1 week ago
class-extensions.php
1 week ago
class-gallery-attachment-modal.php
1 week ago
class-gallery-datasources.php
1 week ago
class-gallery-editor.php
1 week ago
class-gallery-metabox-fields.php
1 week ago
class-gallery-metabox-items.php
1 week ago
class-gallery-metabox-settings-helper.php
1 week ago
class-gallery-metabox-settings.php
1 week ago
class-gallery-metabox-template.php
1 week ago
class-gallery-metaboxes.php
1 week ago
class-menu.php
1 week ago
class-pro-promotion.php
1 week ago
class-settings.php
1 week ago
class-silent-installer-skin.php
1 week ago
class-trial-mode.php
1 week ago
demo-content-galleries.php
1 week ago
demo-content-images.php
1 week ago
index.php
1 week ago
pro-features.php
1 week ago
view-features.php
1 week ago
view-help-demos.php
1 week ago
view-help-getting-started.php
1 week ago
view-help-pro.php
1 week ago
view-help.php
1 week ago
view-system-info.php
1 week ago
class-admin.php
154 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | /* |
| 8 | * FooGallery Admin class |
| 9 | */ |
| 10 | |
| 11 | if ( ! class_exists( 'FooGallery_Admin' ) ) { |
| 12 | |
| 13 | /** |
| 14 | * Class FooGallery_Admin |
| 15 | */ |
| 16 | class FooGallery_Admin { |
| 17 | |
| 18 | /** |
| 19 | * |
| 20 | */ |
| 21 | function __construct() { |
| 22 | global $foogallery_admin_datasource_instance; |
| 23 | |
| 24 | //init some other actions |
| 25 | add_action( 'init', array( $this, 'init' ) ); |
| 26 | |
| 27 | new FooGallery_Admin_Settings(); |
| 28 | new FooGallery_Admin_Menu(); |
| 29 | new FooGallery_Admin_Gallery_Editor(); |
| 30 | new FooGallery_Admin_Gallery_MetaBoxes(); |
| 31 | new FooGallery_Admin_Gallery_MetaBox_Items(); |
| 32 | new FooGallery_Admin_Gallery_MetaBox_Settings(); |
| 33 | new FooGallery_Admin_Gallery_MetaBox_Template(); |
| 34 | new FooGallery_Admin_Gallery_MetaBox_Fields(); |
| 35 | new FooGallery_Admin_Columns(); |
| 36 | new FooGallery_Admin_Extensions(); |
| 37 | new FooGallery_Attachment_Fields(); |
| 38 | new FooGallery_Admin_Notices(); |
| 39 | if ( apply_filters( 'foogallery_enable_custom_css_update_notice', false ) ) { |
| 40 | new FooGallery_Admin_Notice_CustomCSS(); |
| 41 | } |
| 42 | new FooGallery_Admin_Gallery_Attachment_Modal(); |
| 43 | $foogallery_admin_datasource_instance = new FooGallery_Admin_Gallery_Datasources(); |
| 44 | |
| 45 | // include PRO promotion. |
| 46 | new FooGallery_Pro_Promotion(); |
| 47 | new FooGallery_Trial_Mode(); |
| 48 | |
| 49 | // Command Palette integration (WP 6.3+). |
| 50 | new FooGallery_Command_Palette(); |
| 51 | } |
| 52 | |
| 53 | function init() { |
| 54 | add_filter( 'foogallery_admin_has_settings_page', '__return_false' ); |
| 55 | add_action( 'foogallery_admin_print_styles', array( $this, 'admin_print_styles' ) ); |
| 56 | add_action( 'foogallery_admin_print_scripts', array( $this, 'admin_print_scripts' ) ); |
| 57 | // Add a links to the plugin listing |
| 58 | add_filter( 'foogallery_admin_plugin_action_links', array( $this, 'plugin_listing_links' ) ); |
| 59 | //output shortcode for javascript |
| 60 | add_action( 'admin_footer', array( $this, 'output_shortcode_variable' ), 200 ); |
| 61 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ) ); |
| 62 | |
| 63 | add_filter( 'fs_show_trial_foogallery', array( $this, 'force_trial_hide' ) ); |
| 64 | add_action( 'admin_init', array( $this, 'force_hide_trial_notice' ), 99 ); |
| 65 | } |
| 66 | |
| 67 | public function enqueue_scripts_and_styles( $hook ) { |
| 68 | //check if the gallery edit page is being shown |
| 69 | $screen = get_current_screen(); |
| 70 | if ( 'foogallery' !== $screen->id ) { |
| 71 | return; |
| 72 | } |
| 73 | |
| 74 | foogallery_enqueue_core_gallery_template_script(); |
| 75 | foogallery_enqueue_core_gallery_template_style(); |
| 76 | |
| 77 | $foogallery = FooGallery_Plugin::get_instance(); |
| 78 | $handle = $foogallery->register_and_enqueue_js( 'admin-foogallery-edit.js' ); |
| 79 | |
| 80 | if ( $handle ) { |
| 81 | $strings = apply_filters( 'foogallery_admin_il8n', array() ); |
| 82 | |
| 83 | if ( ! empty( $strings ) && is_array( $strings ) ) { |
| 84 | $inline_script = 'window.FOOGALLERY = window.FOOGALLERY || {};' |
| 85 | . 'window.FOOGALLERY.il8n = Object.assign({}, window.FOOGALLERY.il8n || {}, ' |
| 86 | . wp_json_encode( $strings ) |
| 87 | . ');'; |
| 88 | |
| 89 | wp_add_inline_script( $handle, $inline_script, 'before' ); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | do_action('foogallery_admin_enqueue_scripts' ); |
| 94 | } |
| 95 | |
| 96 | function admin_print_styles() { |
| 97 | $page = safe_get_from_request( 'page' ); |
| 98 | $foogallery = FooGallery_Plugin::get_instance(); |
| 99 | $foogallery->register_and_enqueue_css( 'admin-page-' . $page . '.css' ); |
| 100 | } |
| 101 | |
| 102 | function admin_print_scripts() { |
| 103 | $page = safe_get_from_request( 'page' ); |
| 104 | $foogallery = FooGallery_Plugin::get_instance(); |
| 105 | $foogallery->register_and_enqueue_js( 'admin-page-' . $page . '.js' ); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @param $links |
| 110 | * |
| 111 | * @return string[] |
| 112 | */ |
| 113 | function plugin_listing_links( $links ) { |
| 114 | if ( !is_array( $links ) ) { |
| 115 | $links = array(); |
| 116 | } |
| 117 | |
| 118 | // Add a 'Settings' link to the plugin listing |
| 119 | $links[] = '<a href="' . esc_url( foogallery_admin_settings_url() ) . '"><b>' . __( 'Settings', 'foogallery' ) . '</b></a>'; |
| 120 | |
| 121 | $links[] = '<a href="' . esc_url( foogallery_admin_help_url() ) . '"><b>' . __( 'Help', 'foogallery' ) . '</b></a>'; |
| 122 | |
| 123 | return $links; |
| 124 | } |
| 125 | |
| 126 | function output_shortcode_variable() { |
| 127 | if ( foogallery_gallery_shortcode_tag() != FOOGALLERY_CPT_GALLERY ) { |
| 128 | ?> |
| 129 | <script type="text/javascript"> |
| 130 | window.FOOGALLERY_SHORTCODE = '<?php echo esc_js( foogallery_gallery_shortcode_tag() ); ?>'; |
| 131 | </script> |
| 132 | <?php |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | function force_trial_hide( $show_trial ) { |
| 137 | if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) { |
| 138 | $show_trial = false; |
| 139 | } |
| 140 | |
| 141 | return $show_trial; |
| 142 | } |
| 143 | |
| 144 | function force_hide_trial_notice() { |
| 145 | if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) { |
| 146 | $freemius_sdk = foogallery_fs(); |
| 147 | $plugin_id = $freemius_sdk->get_slug(); |
| 148 | $admin_notice_manager = FS_Admin_Notice_Manager::instance( $plugin_id ); |
| 149 | $admin_notice_manager->remove_sticky( 'trial_promotion' ); |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 |