PluginProbe ʕ •ᴥ•ʔ
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel / trunk
Photo Gallery by FooGallery : Responsive Image Gallery, Masonry Gallery & Carousel vtrunk
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 7 months ago class-admin-notices.php 7 months ago class-admin.php 7 months ago class-attachment-fields.php 7 months ago class-columns.php 7 months ago class-demo-content.php 7 months ago class-extensions.php 7 months ago class-gallery-attachment-modal.php 7 months ago class-gallery-datasources.php 7 months ago class-gallery-editor.php 7 months ago class-gallery-metabox-fields.php 7 months ago class-gallery-metabox-items.php 7 months ago class-gallery-metabox-settings-helper.php 7 months ago class-gallery-metabox-settings.php 7 months ago class-gallery-metabox-template.php 7 months ago class-gallery-metaboxes.php 7 months ago class-menu.php 7 months ago class-pro-promotion.php 7 months ago class-settings.php 7 months ago class-silent-installer-skin.php 7 months ago class-trial-mode.php 7 months ago demo-content-galleries.php 7 months ago demo-content-images.php 7 months ago index.php 11 years ago pro-features.php 7 months ago view-features.php 7 months ago view-help-demos.php 7 months ago view-help-getting-started.php 7 months ago view-help-pro.php 7 months ago view-help.php 7 months ago view-system-info.php 7 months ago
class-admin.php
144 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
43 function init() {
44 add_filter( 'foogallery_admin_has_settings_page', '__return_false' );
45 add_action( 'foogallery_admin_print_styles', array( $this, 'admin_print_styles' ) );
46 add_action( 'foogallery_admin_print_scripts', array( $this, 'admin_print_scripts' ) );
47 // Add a links to the plugin listing
48 add_filter( 'foogallery_admin_plugin_action_links', array( $this, 'plugin_listing_links' ) );
49 //output shortcode for javascript
50 add_action( 'admin_footer', array( $this, 'output_shortcode_variable' ), 200 );
51 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ) );
52
53 add_filter( 'fs_show_trial_foogallery', array( $this, 'force_trial_hide' ) );
54 add_action( 'admin_init', array( $this, 'force_hide_trial_notice' ), 99 );
55 }
56
57 public function enqueue_scripts_and_styles( $hook ) {
58 //check if the gallery edit page is being shown
59 $screen = get_current_screen();
60 if ( 'foogallery' !== $screen->id ) {
61 return;
62 }
63
64 foogallery_enqueue_core_gallery_template_script();
65 foogallery_enqueue_core_gallery_template_style();
66
67 $foogallery = FooGallery_Plugin::get_instance();
68 $handle = $foogallery->register_and_enqueue_js( 'admin-foogallery-edit.js' );
69
70 if ( $handle ) {
71 $strings = apply_filters( 'foogallery_admin_il8n', array() );
72
73 if ( ! empty( $strings ) && is_array( $strings ) ) {
74 $inline_script = 'window.FOOGALLERY = window.FOOGALLERY || {};'
75 . 'window.FOOGALLERY.il8n = Object.assign({}, window.FOOGALLERY.il8n || {}, '
76 . wp_json_encode( $strings )
77 . ');';
78
79 wp_add_inline_script( $handle, $inline_script, 'before' );
80 }
81 }
82
83 do_action('foogallery_admin_enqueue_scripts' );
84 }
85
86 function admin_print_styles() {
87 $page = safe_get_from_request( 'page' );
88 $foogallery = FooGallery_Plugin::get_instance();
89 $foogallery->register_and_enqueue_css( 'admin-page-' . $page . '.css' );
90 }
91
92 function admin_print_scripts() {
93 $page = safe_get_from_request( 'page' );
94 $foogallery = FooGallery_Plugin::get_instance();
95 $foogallery->register_and_enqueue_js( 'admin-page-' . $page . '.js' );
96 }
97
98 /**
99 * @param $links
100 *
101 * @return string[]
102 */
103 function plugin_listing_links( $links ) {
104 if ( !is_array( $links ) ) {
105 $links = array();
106 }
107
108 // Add a 'Settings' link to the plugin listing
109 $links[] = '<a href="' . esc_url( foogallery_admin_settings_url() ) . '"><b>' . __( 'Settings', 'foogallery' ) . '</b></a>';
110
111 $links[] = '<a href="' . esc_url( foogallery_admin_help_url() ) . '"><b>' . __( 'Help', 'foogallery' ) . '</b></a>';
112
113 return $links;
114 }
115
116 function output_shortcode_variable() {
117 if ( foogallery_gallery_shortcode_tag() != FOOGALLERY_CPT_GALLERY ) {
118 ?>
119 <script type="text/javascript">
120 window.FOOGALLERY_SHORTCODE = '<?php echo esc_js( foogallery_gallery_shortcode_tag() ); ?>';
121 </script>
122 <?php
123 }
124 }
125
126 function force_trial_hide( $show_trial ) {
127 if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) {
128 $show_trial = false;
129 }
130
131 return $show_trial;
132 }
133
134 function force_hide_trial_notice() {
135 if ( 'on' === foogallery_get_setting( 'force_hide_trial', false ) ) {
136 $freemius_sdk = foogallery_fs();
137 $plugin_id = $freemius_sdk->get_slug();
138 $admin_notice_manager = FS_Admin_Notice_Manager::instance( $plugin_id );
139 $admin_notice_manager->remove_sticky( 'trial_promotion' );
140 }
141 }
142 }
143 }
144