Changeset 380651
- Timestamp:
- 05/04/2011 10:20:24 AM (15 years ago)
- File:
-
- 1 edited
-
phpbb-recent-topics/trunk/phpbb_recent_topics.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
phpbb-recent-topics/trunk/phpbb_recent_topics.php
r380628 r380651 9 9 */ 10 10 11 require_once(WP_PLUGIN_DIR . "/phpbb-recent-topics/upgrade.php"); // before we start, check for upgrades. 11 # before we start, check for upgrades. 12 require_once(WP_PLUGIN_DIR . "/phpbb-recent-topics/upgrade.php"); 12 13 13 $lnx_PRT_options = get_option('lnx_PRT_options'); // Plugin Options 14 # Load Plugin Options from WP DB 15 $lnx_PRT_options = get_option('lnx_PRT_options'); 14 16 15 if (is_admin()) { // load admin stuff if we are an admin. 17 # Only run admin code,if in admin screen. 18 if (is_admin()) { 16 19 include_once(WP_PLUGIN_DIR . "/phpbb-recent-topics/admin.php"); 17 20 } 18 21 22 # Go! 19 23 if ($lnx_PRT_options) { // only move on if we have options.. 20 24 25 add_action('wp_head', 'DisplayPRTHeader'); // Hook into the WP Header 21 26 22 // The path to the plugin 27 function DisplayPRTHeader() { // Filter the post content 28 29 global $post; 30 31 add_filter('the_content', 'DisplayPRTMagicFilter'); 32 } 23 33 24 define('PRTPLUGINPATH', (DIRECTORY_SEPARATOR != '/') ? str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__)) : dirname(__FILE__)); 25 /* * The base class */ 26 class phpbbRecentTopics { 27 /* * The boostrap function */ 28 function bootstrap() { 29 // Add the installation and uninstallation hooks 30 $file = PRTPLUGINPATH . '/' . basename(__FILE__); 31 32 // Add the actions 33 add_action('wp_head', array('phpbbRecentTopics', 'DisplayPRTHeader')); 34 35 } 34 function DisplayPRTMagicFilter($content) { // Replace magic text with list of topics 36 35 37 /* * The function to check for the presence of a contact form and link to it's CSS if required */ 38 function DisplayPRTHeader() { 39 global $post; 40 41 // Add the content filter 42 add_filter('the_content', array('phpbbRecentTopics', 'DisplayPRTMagicFilter')); 43 } 44 /* * The function to display the contact form */ 45 function DisplayPRTMagicFilter($content) { 46 return str_replace('{phpbb_recent_topics}', phpbbRecentTopics::DisplayPRT(), $content); 47 } 48 /* * The function to get the contact form's markup */ 49 function DisplayPRT() { 50 51 // Start the cache 52 ob_start(); 53 // Add the contact form 54 require(PRTPLUGINPATH . '/display/display.php'); 55 // Get the markup 56 $PRT_html = ob_get_contents(); 57 // Cleanup 58 ob_end_clean(); 59 return $PRT_html; 60 } 61 62 63 36 return str_replace('{phpbb_recent_topics}', DisplayPRT(), $content); 64 37 } 65 38 66 39 67 phpbbRecentTopics::bootstrap(); 40 function DisplayPRT() { // The standard display function 41 42 ob_start(); // Start the cache 43 44 require(WP_PLUGIN_DIR . "/phpbb-recent-topics/display/display.php"); // run my code. 45 46 $PRT_html = ob_get_contents(); 47 48 ob_end_clean(); // clean cache 49 50 return $PRT_html; // return output 51 } 68 52 69 // legacy sidebar function53 # Legacy function for side bar 70 54 function phpbb_topics($LIMIT = "") { 71 require(PRTPLUGINPATH . '/display/display.php'); 55 56 require(WP_PLUGIN_DIR . "/phpbb-recent-topics/display/display.php"); 72 57 } 73 58 74 75 // Wiget functions... 76 59 # New sidebar widget (options) 77 60 function wiget_options_phpbb_recent_topics() { 78 61 79 $options = $newoptions = get_option('prt_widget'); 62 $options = $newoptions = get_option('prt_widget'); // widget options 63 80 64 if ( $_POST["prt-submit"] ) { 81 65 $newoptions['title'] = strip_tags(stripslashes($_POST["prt-title"])); 82 66 } 67 83 68 if ( $options != $newoptions ) { 84 69 $options = $newoptions; 85 70 update_option('prt_widget', $options); 86 71 } 72 87 73 $title = attribute_escape($options['title']); 88 74 ?> … … 90 76 <input type="hidden" id="prt-submit" name="prt-submit" value="1" /> 91 77 <?php 92 }78 } 93 79 94 function widget_phpbb_recent_topics($args) { 80 # New sidebar widget (display) 81 function widget_phpbb_recent_topics($args) { 82 83 # Credits to http://toni.uebernickel.info/entwicklung/wordpress/phpbb-recent-topics-widget/ 84 # for pointing out my mistake!! 85 86 extract($args); // get variables 87 $options = get_option('prt_widget'); // retrieve title 88 $title = stripslashes($options['title']); 89 90 echo $before_widget, $before_title, $title, $after_title; 91 92 require(WP_PLUGIN_DIR . "/phpbb-recent-topics/display/display.php"); 93 94 echo $after_widget; 95 } 95 96 96 # Credits to http://toni.uebernickel.info/entwicklung/wordpress/phpbb-recent-topics-widget/ 97 # for pointing out my mistake!! 97 # Widget init function (for action below). 98 function phpbb_recent_topics_init_widget() { 99 if (!function_exists('register_sidebar_widget')) 100 101 return; 102 103 register_sidebar_widget('phpBB Recent Topics','widget_phpbb_recent_topics'); 104 register_widget_control('phpBB Recent Topics', 'wiget_options_phpbb_recent_topics', 300, 100); 105 } 98 106 99 // get variables 100 extract($args); 101 // retrieve title 102 $options = get_option('prt_widget'); 103 $title = stripslashes($options['title']); 104 105 echo $before_widget, $before_title, $title, $after_title; 106 107 require(PRTPLUGINPATH . '/display/display.php'); 108 109 echo $after_widget; 110 } 111 112 function phpbb_recent_topics_init_widget() { 113 if (!function_exists('register_sidebar_widget')) 114 return; 115 register_sidebar_widget('phpBB Recent Topics','widget_phpbb_recent_topics'); 116 register_widget_control('phpBB Recent Topics', 'wiget_options_phpbb_recent_topics', 300, 100); 117 } 118 119 120 # Delay plugin execution until sidebar is loaded 121 add_action('widgets_init', 'phpbb_recent_topics_init_widget'); 107 # Delay plugin execution until sidebar is loaded 108 add_action('widgets_init', 'phpbb_recent_topics_init_widget'); 122 109 123 110 }
Note: See TracChangeset
for help on using the changeset viewer.