Ejemplo n.º 1
0
 public function include_required_scripts()
 {
     $screen_id = foo_current_screen_id();
     //only include scripts if we on the foogallery add/edit page
     if (FOOGALLERY_CPT_GALLERY === $screen_id || 'edit-' . FOOGALLERY_CPT_GALLERY === $screen_id) {
         //spectrum needed for the colorpicker field
         $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.js';
         wp_enqueue_script('foogallery-spectrum', $url, array('jquery'), FOOGALLERY_VERSION);
         $url = FOOGALLERY_URL . 'lib/spectrum/spectrum.css';
         wp_enqueue_style('foogallery-spectrum', $url, array(), FOOGALLERY_VERSION);
         //include any admin js required for the templates
         foreach (foogallery_gallery_templates() as $template) {
             $admin_js = foo_safe_get($template, 'admin_js');
             if ($admin_js) {
                 wp_enqueue_script('foogallery-gallery-admin-' . $template['slug'], $admin_js, array('jquery', 'media-upload', 'jquery-ui-sortable'), FOOGALLERY_VERSION);
             }
         }
     }
 }
Ejemplo n.º 2
0
 function admin_print_styles()
 {
     //add a general admin stylesheet
     $this->register_and_enqueue_css('admin.css');
     //if we are on the current plugin's settings page then check for file /css/admin-settings.css
     if (foo_check_plugin_settings_page($this->plugin_slug)) {
         $this->register_and_enqueue_css('admin-settings.css');
         //Media Uploader Style
         wp_enqueue_style('thickbox');
     }
     //add any scripts for the current post type /css/admin-foobar.css
     $post_type = foo_current_screen_post_type();
     if (!empty($post_type)) {
         $this->register_and_enqueue_css('admin-' . $post_type . '.css');
     }
     //finally try add any styles for the current screen id /css/admin-screen-id.css
     $this->register_and_enqueue_css('admin-' . foo_current_screen_id() . '.css');
     do_action($this->plugin_slug . '-admin_print_styles');
 }
Ejemplo n.º 3
0
        public function admin_notice_foogallery_lightboxes_inline_js()
        {
            if (!current_user_can('activate_plugins') || !class_exists('FooGallery_Plugin')) {
                return;
            }
            if (get_user_meta(get_current_user_id(), 'foogallery_fooboxfree_lightbox_ignore')) {
                return;
            }
            if ('settings_page_fooboxfree-help' === foo_current_screen_id()) {
                return;
            }
            ?>
			<script type="text/javascript">
				( function ( $ ) {
					$( document ).ready( function () {
						$( '.foobox-foogallery-lightboxes.is-dismissible' )
							.on( 'click', '.notice-dismiss', function ( e ) {
								e.preventDefault();
								$.post( ajaxurl, {
									action: 'foobox_foogallery_lightboxes_ignore_notice',
									url: '<?php 
            echo admin_url('admin-ajax.php');
            ?>
',
									_wpnonce: '<?php 
            echo wp_create_nonce('foobox_foogallery_lightboxes_ignore_notice');
            ?>
'
								} );
							} )

							.on( 'click', '.foobox-foogallery-update-lightbox', function ( e ) {
								e.preventDefault();
								var $spinner = $(this).parents('div:first').find('.spinner');
								$spinner.addClass('is-active');

								var data = 'action=foobox_foogallery_lightboxes_update' +
									'&foobox_foogallery_lightboxes_update_nonce=<?php 
            echo wp_create_nonce('foobox_foogallery_lightboxes_update');
            ?>
' +
									'&_wp_http_referer=' + encodeURIComponent($('input[name="_wp_http_referer"]').val());

								$.ajax({
									type: "POST",
									url: ajaxurl,
									data: data,
									success: function(data) {
										$('.foobox-foogallery-lightboxes').slideUp();
										alert(data.updated);
										$spinner.removeClass('is-active');
									}
								});
							} );
						} );
				} )( jQuery );
			</script>
			<?php 
        }
Ejemplo n.º 4
0
 function foo_check_plugin_settings_page($plugin_slug)
 {
     return is_admin() && 'settings_page_' . $plugin_slug === foo_current_screen_id();
 }