PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.3.3
Gallery : FooGallery v3.3.3
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 days ago class-admin-notices.php 2 days ago class-admin.php 2 days ago class-attachment-fields.php 2 days ago class-columns.php 2 days ago class-demo-content.php 2 days ago class-extensions.php 2 days ago class-gallery-attachment-modal.php 2 days ago class-gallery-datasources.php 2 days ago class-gallery-editor.php 2 days ago class-gallery-metabox-fields.php 2 days ago class-gallery-metabox-items.php 2 days ago class-gallery-metabox-settings-helper.php 2 days ago class-gallery-metabox-settings.php 2 days ago class-gallery-metabox-template.php 2 days ago class-gallery-metaboxes.php 2 days ago class-menu.php 2 days ago class-pro-promotion.php 2 days ago class-settings.php 2 days ago class-silent-installer-skin.php 2 days ago class-trial-mode.php 2 days ago demo-content-galleries.php 2 days ago demo-content-images.php 2 days ago index.php 2 days ago pro-features.php 2 days ago view-features.php 2 days ago view-help-demos.php 2 days ago view-help-getting-started.php 2 days ago view-help-pro.php 2 days ago view-help.php 2 days ago view-system-info.php 2 days ago
class-admin.php
171 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 $strings = is_array( $strings ) ? $strings : array();
83
84 $strings['mobileSettingsPromo'] = array(
85 'title' => __( 'Give {field} its own mobile value', 'foogallery' ),
86 'body' => __( 'Mobile currently inherits the desktop value. PRO Starter lets you tune it independently for mobile devices, with live mobile preview.', 'foogallery' ),
87 'trial' => __( 'Start 7-day free trial', 'foogallery' ),
88 'upgrade' => __( 'Upgrade to PRO Starter', 'foogallery' ),
89 'compare' => __( 'Compare plans', 'foogallery' ),
90 'close' => __( 'Close', 'foogallery' ),
91 'trialUrl' => foogallery_admin_freetrial_url(),
92 'upgradeUrl' => foogallery_admin_pricing_url(),
93 'compareUrl' => foogallery_admin_url(
94 'https://fooplugins.com/foogallery-wordpress-gallery-plugin/compare-plans/',
95 'promos',
96 'mobile-settings'
97 ),
98 );
99
100 if ( ! empty( $strings ) ) {
101 $inline_script = 'window.FOOGALLERY = window.FOOGALLERY || {};'
102 . 'window.FOOGALLERY.il8n = Object.assign({}, window.FOOGALLERY.il8n || {}, '
103 . wp_json_encode( $strings )
104 . ');';
105
106 wp_add_inline_script( $handle, $inline_script, 'before' );
107 }
108 }
109
110 do_action('foogallery_admin_enqueue_scripts' );
111 }
112
113 function admin_print_styles() {
114 $page = safe_get_from_request( 'page' );
115 $foogallery = FooGallery_Plugin::get_instance();
116 $foogallery->register_and_enqueue_css( 'admin-page-' . $page . '.css' );
117 }
118
119 function admin_print_scripts() {
120 $page = safe_get_from_request( 'page' );
121 $foogallery = FooGallery_Plugin::get_instance();
122 $foogallery->register_and_enqueue_js( 'admin-page-' . $page . '.js' );
123 }
124
125 /**
126 * @param $links
127 *
128 * @return string[]
129 */
130 function plugin_listing_links( $links ) {
131 if ( !is_array( $links ) ) {
132 $links = array();
133 }
134
135 // Add a 'Settings' link to the plugin listing
136 $links[] = '<a href="' . esc_url( foogallery_admin_settings_url() ) . '"><b>' . __( 'Settings', 'foogallery' ) . '</b></a>';
137
138 $links[] = '<a href="' . esc_url( foogallery_admin_help_url() ) . '"><b>' . __( 'Help', 'foogallery' ) . '</b></a>';
139
140 return $links;
141 }
142
143 function output_shortcode_variable() {
144 if ( foogallery_gallery_shortcode_tag() != FOOGALLERY_CPT_GALLERY ) {
145 ?>
146 <script type="text/javascript">
147 window.FOOGALLERY_SHORTCODE = '<?php echo esc_js( foogallery_gallery_shortcode_tag() ); ?>';
148 </script>
149 <?php
150 }
151 }
152
153 function force_trial_hide( $show_trial ) {
154 if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) {
155 $show_trial = false;
156 }
157
158 return $show_trial;
159 }
160
161 function force_hide_trial_notice() {
162 if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) {
163 $freemius_sdk = foogallery_fs();
164 $plugin_id = $freemius_sdk->get_slug();
165 $admin_notice_manager = FS_Admin_Notice_Manager::instance( $plugin_id );
166 $admin_notice_manager->remove_sticky( 'trial_promotion' );
167 }
168 }
169 }
170 }
171