PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.1.36
Gallery : FooGallery v3.1.36
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / admin / class-admin.php
foogallery / includes / admin Last commit date
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
149 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 if ( apply_filters( 'foogallery_enable_custom_css_update_notice', false ) ) {
35 new FooGallery_Admin_Notice_CustomCSS();
36 }
37 new FooGallery_Admin_Gallery_Attachment_Modal();
38 $foogallery_admin_datasource_instance = new FooGallery_Admin_Gallery_Datasources();
39
40 // include PRO promotion.
41 new FooGallery_Pro_Promotion();
42 new FooGallery_Trial_Mode();
43
44 // Command Palette integration (WP 6.3+).
45 new FooGallery_Command_Palette();
46 }
47
48 function init() {
49 add_filter( 'foogallery_admin_has_settings_page', '__return_false' );
50 add_action( 'foogallery_admin_print_styles', array( $this, 'admin_print_styles' ) );
51 add_action( 'foogallery_admin_print_scripts', array( $this, 'admin_print_scripts' ) );
52 // Add a links to the plugin listing
53 add_filter( 'foogallery_admin_plugin_action_links', array( $this, 'plugin_listing_links' ) );
54 //output shortcode for javascript
55 add_action( 'admin_footer', array( $this, 'output_shortcode_variable' ), 200 );
56 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ) );
57
58 add_filter( 'fs_show_trial_foogallery', array( $this, 'force_trial_hide' ) );
59 add_action( 'admin_init', array( $this, 'force_hide_trial_notice' ), 99 );
60 }
61
62 public function enqueue_scripts_and_styles( $hook ) {
63 //check if the gallery edit page is being shown
64 $screen = get_current_screen();
65 if ( 'foogallery' !== $screen->id ) {
66 return;
67 }
68
69 foogallery_enqueue_core_gallery_template_script();
70 foogallery_enqueue_core_gallery_template_style();
71
72 $foogallery = FooGallery_Plugin::get_instance();
73 $handle = $foogallery->register_and_enqueue_js( 'admin-foogallery-edit.js' );
74
75 if ( $handle ) {
76 $strings = apply_filters( 'foogallery_admin_il8n', array() );
77
78 if ( ! empty( $strings ) && is_array( $strings ) ) {
79 $inline_script = 'window.FOOGALLERY = window.FOOGALLERY || {};'
80 . 'window.FOOGALLERY.il8n = Object.assign({}, window.FOOGALLERY.il8n || {}, '
81 . wp_json_encode( $strings )
82 . ');';
83
84 wp_add_inline_script( $handle, $inline_script, 'before' );
85 }
86 }
87
88 do_action('foogallery_admin_enqueue_scripts' );
89 }
90
91 function admin_print_styles() {
92 $page = safe_get_from_request( 'page' );
93 $foogallery = FooGallery_Plugin::get_instance();
94 $foogallery->register_and_enqueue_css( 'admin-page-' . $page . '.css' );
95 }
96
97 function admin_print_scripts() {
98 $page = safe_get_from_request( 'page' );
99 $foogallery = FooGallery_Plugin::get_instance();
100 $foogallery->register_and_enqueue_js( 'admin-page-' . $page . '.js' );
101 }
102
103 /**
104 * @param $links
105 *
106 * @return string[]
107 */
108 function plugin_listing_links( $links ) {
109 if ( !is_array( $links ) ) {
110 $links = array();
111 }
112
113 // Add a 'Settings' link to the plugin listing
114 $links[] = '<a href="' . esc_url( foogallery_admin_settings_url() ) . '"><b>' . __( 'Settings', 'foogallery' ) . '</b></a>';
115
116 $links[] = '<a href="' . esc_url( foogallery_admin_help_url() ) . '"><b>' . __( 'Help', 'foogallery' ) . '</b></a>';
117
118 return $links;
119 }
120
121 function output_shortcode_variable() {
122 if ( foogallery_gallery_shortcode_tag() != FOOGALLERY_CPT_GALLERY ) {
123 ?>
124 <script type="text/javascript">
125 window.FOOGALLERY_SHORTCODE = '<?php echo esc_js( foogallery_gallery_shortcode_tag() ); ?>';
126 </script>
127 <?php
128 }
129 }
130
131 function force_trial_hide( $show_trial ) {
132 if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) {
133 $show_trial = false;
134 }
135
136 return $show_trial;
137 }
138
139 function force_hide_trial_notice() {
140 if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) {
141 $freemius_sdk = foogallery_fs();
142 $plugin_id = $freemius_sdk->get_slug();
143 $admin_notice_manager = FS_Admin_Notice_Manager::instance( $plugin_id );
144 $admin_notice_manager->remove_sticky( 'trial_promotion' );
145 }
146 }
147 }
148 }
149