. * */ function_exists('tubepress_load_classes') || require(dirname(__FILE__) . '/../../../classes/tubepress_classloader.php'); tubepress_load_classes(array('org_tubepress_options_storage_WordPressStorageManager', 'org_tubepress_options_category_Advanced', 'org_tubepress_shortcode_SimpleShortcodeService', 'org_tubepress_ioc_DefaultIocService', 'org_tubepress_ioc_IocService', 'org_tubepress_util_Debug', 'org_tubepress_util_StringUtils')); /** * Main filter hook. Looks for a tubepress tag * and, if found, replaces it with a gallery */ function tubepress_content_filter($content = '') { try { return _tubepress_content_filter($content); } catch (Exception $e) { return $e->getMessage() . $content; } } function _tubepress_content_filter($content) { /* do as little work as possible here 'cause we might not even run */ $wpsm = new org_tubepress_options_storage_WordPressStorageManager(); $trigger = $wpsm->get(org_tubepress_options_category_Advanced::KEYWORD); $shortcodeService = new org_tubepress_shortcode_SimpleShortcodeService(); /* no shortcode? get out */ if (!$shortcodeService->somethingToParse($content, $trigger)) { return $content; } /* Whip up the IOC service */ $iocContainer = new org_tubepress_ioc_DefaultIocService(); /* Get a handle to our options manager */ $tpom = $iocContainer->get(org_tubepress_ioc_IocService::OPTIONS_MGR); /* Get a copy of the content that we'll edit */ $newcontent = $content; /* And finally, the gallery itself */ $gallery = $iocContainer->get(org_tubepress_ioc_IocService::GALLERY); while ($shortcodeService->somethingToParse($newcontent, $trigger)) { $shortcodeService->parse($newcontent, $tpom); if (org_tubepress_util_Debug::areWeDebugging($tpom)) { org_tubepress_util_Debug::execute($iocContainer); } /* replace the tag with our new content */ $newcontent = org_tubepress_util_StringUtils::replaceFirst($tpom->getShortcode(), $gallery->generate(mt_rand()), $newcontent); } return $newcontent; } /** * Spits out the CSS and JS files that we always need for TubePress */ function tubepress_head_filter() { try { _tubepress_head_filter(); } catch (Exception $e) { /* this is in the head, so just print an HTML comment and proceed */ print ""; } } function _tubepress_head_filter() { global $tubepress_base_url; print<< GBS; } /** * Tells WordPress to load jQuery for us * * @return void */ function tubepress_load_jquery() { wp_enqueue_script('jquery'); } ?>