PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
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-menu.php
foogallery / includes / admin Last commit date
class-admin-notice-custom-css.php 4 weeks ago class-admin-notices.php 4 weeks ago class-admin.php 4 weeks ago class-attachment-fields.php 4 weeks ago class-columns.php 4 weeks ago class-demo-content.php 4 weeks ago class-extensions.php 4 weeks ago class-gallery-attachment-modal.php 4 weeks ago class-gallery-datasources.php 4 weeks ago class-gallery-editor.php 4 weeks ago class-gallery-metabox-fields.php 4 weeks ago class-gallery-metabox-items.php 4 weeks ago class-gallery-metabox-settings-helper.php 4 weeks ago class-gallery-metabox-settings.php 4 weeks ago class-gallery-metabox-template.php 4 weeks ago class-gallery-metaboxes.php 4 weeks ago class-menu.php 4 weeks ago class-pro-promotion.php 4 weeks ago class-settings.php 4 weeks ago class-silent-installer-skin.php 4 weeks ago class-trial-mode.php 4 weeks ago demo-content-galleries.php 4 weeks ago demo-content-images.php 4 weeks ago index.php 4 weeks ago pro-features.php 4 weeks ago view-features.php 4 weeks ago view-help-demos.php 4 weeks ago view-help-getting-started.php 4 weeks ago view-help-pro.php 4 weeks ago view-help.php 4 weeks ago view-system-info.php 4 weeks ago
class-menu.php
151 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /*
8 * FooGallery Admin Menu class
9 */
10
11 if ( ! class_exists( 'FooGallery_Admin_Menu' ) ) {
12
13 class FooGallery_Admin_Menu {
14
15 function __construct() {
16 add_action( 'admin_menu', array( $this, 'register_menu_items' ) );
17
18 add_action( 'wp_ajax_foogallery_admin_import_demos', array( $this, 'create_demo_galleries' ) );
19
20 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
21 }
22
23 /**
24 * Load the foogallery assets on the help page
25 *
26 * @param $hook
27 */
28 function enqueue_scripts( $hook ) {
29 if ( 'foogallery_page_foogallery-help' === $hook ) {
30 foogallery_enqueue_core_gallery_template_script( array('jquery', 'masonry' ) );
31 foogallery_enqueue_core_gallery_template_style();
32 }
33 }
34
35 /**
36 * @todo add context to the translations
37 */
38 function register_menu_items() {
39 //we rely on the register_post_type call to add our main menu items
40 $parent_slug = foogallery_admin_menu_parent_slug();
41
42 //allow extensions to add their own menu items beforehand
43 do_action( 'foogallery_admin_menu_before' );
44
45 $menu_labels = apply_filters( 'foogallery_admin_menu_labels',
46 array(
47 array(
48 /* translators: %s: Value inserted at runtime. */
49 'page_title' => sprintf( __( '%s Settings', 'foogallery' ), foogallery_plugin_name() ),
50 'menu_title' => __( 'Settings', 'foogallery' ),
51 ),
52 array(
53 /* translators: %s: Value inserted at runtime. */
54 'page_title' => sprintf( __( '%s Features', 'foogallery' ), foogallery_plugin_name() ),
55 'menu_title' => __( 'Features', 'foogallery' ),
56 ),
57 array(
58 /* translators: %s: Value inserted at runtime. */
59 'page_title' => sprintf( __( '%s Help', 'foogallery' ), foogallery_plugin_name() ),
60 'menu_title' => __( 'Help', 'foogallery' ),
61 ),
62 array(
63 /* translators: %s: Value inserted at runtime. */
64 'page_title' => sprintf( __( '%s System Information', 'foogallery' ), foogallery_plugin_name() ),
65 'menu_title' => __( 'System Info', 'foogallery' ),
66 ),
67 )
68 );
69
70 $capability = apply_filters( 'foogallery_admin_menu_capability', 'manage_options' );
71
72 add_submenu_page( $parent_slug, $menu_labels[0]['page_title'], $menu_labels[0]['menu_title'], $capability, 'foogallery-settings', array( $this, 'foogallery_settings' ) );
73 add_submenu_page( $parent_slug, $menu_labels[1]['page_title'], $menu_labels[1]['menu_title'], $capability, 'foogallery-features', array( $this, 'foogallery_features' ) );
74 add_submenu_page( $parent_slug, $menu_labels[2]['page_title'], $menu_labels[2]['menu_title'], $capability, 'foogallery-help', array( $this, 'foogallery_help' ) );
75
76 if ( current_user_can( 'activate_plugins' ) ) {
77 add_submenu_page( $parent_slug, $menu_labels[3]['page_title'], $menu_labels[3]['menu_title'], $capability, 'foogallery-systeminfo', array( $this, 'foogallery_systeminfo' ) );
78 }
79
80 //allow extensions to add their own menu items afterwards
81 do_action( 'foogallery_admin_menu_after' );
82 }
83
84 function foogallery_settings() {
85
86 $admin_errors = get_transient( 'settings_errors' );
87 $show_reset_message = false;
88
89 if ( is_array( $admin_errors ) ) {
90 //try to find a reset 'error'
91 foreach ( $admin_errors as $error ) {
92 if ( 'reset' === $error['setting'] ) {
93 $show_reset_message = true;
94 break;
95 }
96 }
97 }
98
99 if ( $show_reset_message ) {
100 do_action( 'foogallery_settings_reset' );
101 ?>
102 <div id="message" class="updated">
103 <?php /* translators: %s: Value inserted at runtime. */ ?>
104 <p><strong><?php printf( esc_html__( '%s settings reset to defaults.', 'foogallery' ), esc_html( foogallery_plugin_name() ) ); ?></strong></p>
105 </div>
106 <?php } else if ( isset($_GET['settings-updated']) ) { ?>
107 <div id="message" class="updated">
108 <?php /* translators: %s: Value inserted at runtime. */ ?>
109 <p><strong><?php printf( esc_html__( '%s settings updated.', 'foogallery' ), esc_html( foogallery_plugin_name() ) ); ?></strong></p>
110 </div>
111 <?php }
112
113 $instance = FooGallery_Plugin::get_instance();
114 $instance->admin_settings_render_page();
115 }
116
117 function foogallery_features() {
118 require_once FOOGALLERY_PATH . 'includes/admin/view-features.php';
119 }
120
121 function foogallery_help() {
122 require_once FOOGALLERY_PATH . 'includes/admin/view-help.php';
123 }
124
125 function foogallery_systeminfo() {
126 require_once FOOGALLERY_PATH . 'includes/admin/view-system-info.php';
127 }
128
129 function create_demo_galleries() {
130 if ( check_ajax_referer( 'foogallery_admin_import_demos' ) ) {
131
132 if ( ! current_user_can( 'manage_options' ) ) {
133 wp_send_json_error( array(
134 'message' => __( 'You do not have permission!', 'foogallery' ),
135 ), 403 );
136 }
137
138 $results = foogallery_create_demo_content();
139
140 if ( $results === false ) {
141 echo esc_html__('There was a problem creating the demo galleries!', 'foogallery');
142 } else {
143 /* translators: %d: Value inserted at runtime. */
144 echo esc_html( sprintf( esc_html__('%d sample images imported, and %d demo galleries created!', 'foogallery'), absint( $results['attachments'] ), absint( $results['galleries'] ) ) );
145 }
146 }
147 die();
148 }
149 }
150 }
151