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