PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.1.36
Gallery : FooGallery v3.1.36
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-gallery-metabox-settings.php
foogallery / includes / admin Last commit date
class-admin-notice-custom-css.php 2 months ago class-admin-notices.php 2 months ago class-admin.php 2 months ago class-attachment-fields.php 2 months ago class-columns.php 2 months ago class-demo-content.php 2 months ago class-extensions.php 2 months ago class-gallery-attachment-modal.php 2 months ago class-gallery-datasources.php 2 months ago class-gallery-editor.php 2 months ago class-gallery-metabox-fields.php 2 months ago class-gallery-metabox-items.php 2 months ago class-gallery-metabox-settings-helper.php 2 months ago class-gallery-metabox-settings.php 2 months ago class-gallery-metabox-template.php 2 months ago class-gallery-metaboxes.php 2 months ago class-menu.php 2 months ago class-pro-promotion.php 2 months ago class-settings.php 2 months ago class-silent-installer-skin.php 2 months ago class-trial-mode.php 2 months ago demo-content-galleries.php 2 months ago demo-content-images.php 2 months ago index.php 2 months ago pro-features.php 2 months ago view-features.php 2 months ago view-help-demos.php 2 months ago view-help-getting-started.php 2 months ago view-help-pro.php 2 months ago view-help.php 2 months ago view-system-info.php 2 months ago
class-gallery-metabox-settings.php
135 lines
1 <?php
2 /**
3 * Class to handle adding the Settings metabox to a gallery
4 */
5
6
7 if ( ! class_exists( 'FooGallery_Admin_Gallery_MetaBox_Settings' ) ) {
8
9 class FooGallery_Admin_Gallery_MetaBox_Settings {
10
11 /**
12 * FooGallery_Admin_Gallery_MetaBox_Settings constructor.
13 */
14 function __construct() {
15 add_action( 'add_meta_boxes_' . FOOGALLERY_CPT_GALLERY, array( $this, 'add_settings_metabox' ), 8 );
16
17 //enqueue assets for the new settings tabs
18 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
19
20 //get the section slug
21 add_filter( 'foogallery_gallery_settings_metabox_section_slug', array( $this, 'get_section_slug' ) );
22
23 //set default settings tab icons
24 add_filter( 'foogallery_gallery_settings_metabox_section_icon', array( $this, 'add_section_icons') );
25 }
26
27 public function add_settings_metabox( $post ) {
28 add_meta_box(
29 'foogallery_settings',
30 __( 'Gallery Settings', 'foogallery' ),
31 array( $this, 'render_gallery_settings_metabox' ),
32 FOOGALLERY_CPT_GALLERY,
33 'normal',
34 'high'
35 );
36 }
37
38 public function render_gallery_settings_metabox( $post ) {
39 $gallery = foogallery_admin_get_current_gallery( $post );
40
41 //attempt to load default gallery settings from another gallery, as per FooGallery settings page
42 $gallery->load_default_settings_if_new();
43
44 $gallery = apply_filters( 'foogallery_render_gallery_settings_metabox', $gallery );
45
46 if ( true === apply_filters( 'foogallery_should_render_gallery_settings_metabox', true, $gallery ) ) {
47
48 $settings = new FooGallery_Admin_Gallery_MetaBox_Settings_Helper( $gallery );
49
50 $settings->render_gallery_settings();
51 }
52
53 do_action( 'foogallery_after_render_gallery_settings_metabox', $gallery );
54 }
55
56 /***
57 * Enqueue the assets needed by the settings
58 * @param $hook_suffix
59 */
60 function enqueue_assets( $hook_suffix ){
61 if( in_array( $hook_suffix, array( 'post.php', 'post-new.php' ) ) ) {
62 $screen = get_current_screen();
63
64 if ( is_object( $screen ) && FOOGALLERY_CPT_GALLERY === $screen->post_type ){
65
66 //spectrum needed for the colorpicker field
67 $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.js';
68 wp_enqueue_script( 'foogallery-spectrum', $url, array('jquery'), FOOGALLERY_VERSION );
69 $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.css';
70 wp_enqueue_style( 'foogallery-spectrum', $url, array(), FOOGALLERY_VERSION );
71
72 // Register, enqueue scripts and styles here
73 wp_enqueue_script( 'foogallery-admin-settings', FOOGALLERY_URL . 'js/foogallery.admin.min.js', array('jquery'), FOOGALLERY_VERSION );
74 wp_enqueue_style( 'foogallery-admin-settings', FOOGALLERY_URL . 'css/foogallery.admin.min.css', array(), FOOGALLERY_VERSION );
75 }
76 }
77 }
78
79 /**
80 * Returns the section slug that can be used in the settings tabs
81 * @param $section
82 * @return string
83 */
84 function get_section_slug( $section ) {
85 switch ( $section ) {
86 case __('General', 'foogallery'):
87 return 'general';
88 case __('Advanced', 'foogallery'):
89 return 'advanced';
90 case __('Appearance', 'foogallery'):
91 return 'appearance';
92 case __('Video', 'foogallery'):
93 return 'video';
94 case __('Hover Effects', 'foogallery'):
95 return 'hover effects';
96 case __('Captions', 'foogallery'):
97 return 'captions';
98 case __('Paging', 'foogallery'):
99 return 'paging';
100 case __('Social', 'foogallery'):
101 return 'social';
102 }
103 return strtolower( $section );
104 }
105
106 /**
107 * Returns the Dashicon that can be used in the settings tabs
108 *
109 * @param string $section_slug
110 * @return string
111 */
112 function add_section_icons( $section_slug ) {
113 switch ( $section_slug ) {
114 case 'general':
115 return 'dashicons-format-gallery';
116 case 'advanced':
117 return 'dashicons-admin-tools';
118 case 'appearance':
119 return 'dashicons-admin-appearance';
120 case 'video':
121 return 'dashicons-video-alt3';
122 case 'hover effects':
123 return 'dashicons-star-filled';
124 case 'captions':
125 return 'dashicons-editor-quote';
126 case 'paging':
127 return 'dashicons-admin-page';
128 case 'social':
129 return 'dashicons-share';
130 }
131 return $section_slug;
132 }
133 }
134 }
135