/** * @param $foobox Foobox_Free * @param $debug boolean * * @return string */ static function generate_javascript($foobox, $debug = false) { $fbx_options = $foobox->options()->get_all(); $info = $foobox->get_plugin_info(); $js = '/* Run FooBox FREE (v' . $info['version'] . ') */'; $js_options = self::generate_js_options($fbx_options); if (!empty($js_options)) { $js .= sprintf(' (function( FOOBOX, $, undefined ) { FOOBOX.o = %s; FOOBOX.init = function() { $(".fbx-link").removeClass("fbx-link"); ', $js_options); $js_options = 'FOOBOX.o'; } $foobox_selectors[] = '.foobox'; if (foo_check_plugin_settings_page(FOOBOXFREE_SLUG)) { $foobox_selectors[] = '.demo-gallery,.bad-image'; } if (self::is_option_checked($fbx_options, 'enable_galleries', true)) { $foobox_selectors[] = '.gallery'; } if (self::is_option_checked($fbx_options, 'enable_captions', true)) { $foobox_selectors[] = '.wp-caption'; } if (self::is_option_checked($fbx_options, 'enable_attachments', true)) { $foobox_selectors[] = 'a:has(img[class*=wp-image-])'; if ($foobox->render_for_archive()) { $foobox_selectors[] = '.post a:has(img[class*=wp-image-])'; //archive selector } } //add support for foogallery! if (class_exists('FooGallery_Plugin')) { $foobox_selectors[] = '.foogallery-container.foogallery-lightbox-foobox'; $foobox_selectors[] = '.foogallery-container.foogallery-lightbox-foobox-free'; } if (self::is_option_checked($fbx_options, 'disable_others', false)) { $js .= ' $(".fbx-link").unbind(".prettyphoto").unbind(".fb"); '; } //output the call to foobox! $seperator = $debug ? ', ' : ', '; $js .= self::generate_javascript_call('"' . implode($seperator, $foobox_selectors) . '"', $js_options); $ready_event = 'FooBox.ready'; $preload = ' //preload the foobox font jQuery("body").append("<span style=\\"font-family:\'foobox\'; color:transparent; position:absolute; top:-1000em;\\">f</span>");'; $js .= ' }; }( window.FOOBOX = window.FOOBOX || {}, jQuery )); ' . $ready_event . '(function() { ' . $preload . ' FOOBOX.init(); '; $js .= ' }); '; return $js; }
function admin_inline_content() { if (foo_check_plugin_settings_page(FOOBOXFREE_SLUG)) { $this->inline_dynamic_js(); } }
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'); }