PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 1.4.2
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v1.4.2
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / inc / common / admin-bar.php

admin-bar.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 1.4.2, at inc/common/admin-bar.php

78 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' );
3
4 /**
5 * Add Imagify menu in the admin bar
6 *
7 * @since 1.0
8 */
9 add_action( 'admin_bar_menu', '_imagify_admin_bar', PHP_INT_MAX );
10 function _imagify_admin_bar( $wp_admin_bar ) {
11 $cap = imagify_is_active_for_network() ? 'manage_network_options' : 'manage_options';
12 /** This filter is documented in inc/admin/options.php */
13 $cap = apply_filters( 'imagify_capacity', $cap );
14
15 if ( ! current_user_can( $cap ) || ! get_imagify_option( 'admin_bar_menu', 0 ) ) {
16 return;
17 }
18
19 // Parent
20 $wp_admin_bar->add_menu( array(
21 'id' => 'imagify',
22 'title' => 'Imagify',
23 'href' => get_imagify_admin_url(),
24 ) );
25
26 // Settings
27 $wp_admin_bar->add_menu(array(
28 'parent' => 'imagify',
29 'id' => 'imagify-settings',
30 'title' => __( 'Settings' ),
31 'href' => get_imagify_admin_url(),
32 ) );
33
34 // Bulk Optimization
35 if ( ! is_network_admin() ) {
36 $wp_admin_bar->add_menu(array(
37 'parent' => 'imagify',
38 'id' => 'imagify-bulk-optimization',
39 'title' => __( 'Bulk Optimization', 'imagify' ),
40 'href' => get_imagify_admin_url( 'bulk-optimization' ),
41 ) );
42 }
43
44 // Rate it
45 $wp_admin_bar->add_menu(array(
46 'parent' => 'imagify',
47 'id' => 'imagify-rate-it',
48 'title' => sprintf( __( 'Rate Imagify on %s', 'imagify' ), 'WordPress.org' ),
49 'href' => 'https://wordpress.org/support/view/plugin-reviews/imagify?rate=5#postform',
50 ) );
51
52 // Quota & Profile informations
53 if ( defined( 'IMAGIFY_HIDDEN_ACCOUNT' ) && IMAGIFY_HIDDEN_ACCOUNT ) {
54 return;
55 }
56
57 if ( ( defined( 'IMAGIFY_API_KEY' ) && IMAGIFY_API_KEY ) || get_imagify_option( 'api_key', false ) ) {
58 $wp_admin_bar->add_menu( array(
59 'parent' => 'imagify',
60 'id' => 'imagify-profile',
61 'title' => wp_nonce_field( 'imagify-get-admin-bar-profile', 'imagifygetadminbarprofilenonce', false, false ) . '<div id="wp-admin-bar-imagify-profile-loading">' . __( 'Loading...' ) . '</div><div id="wp-admin-bar-imagify-profile-content"></div>',
62 ) );
63 }
64 }
65
66 /**
67 * Include Admin Bar Profile informations styles in front
68 *
69 * @since 1.2
70 */
71 add_action( 'admin_bar_init', '_imagify_admin_bar_styles' );
72 function _imagify_admin_bar_styles() {
73 if ( ! is_admin() && get_imagify_option( 'admin_bar_menu', 0 ) ) {
74 $css_ext = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.css' : '.min.css';
75 wp_enqueue_style( 'imagify-css-admin-bar', IMAGIFY_ASSETS_CSS_URL . 'admin-bar' . $css_ext, array(), IMAGIFY_VERSION, 'all' );
76 }
77 }
78