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