WordPress.org

Plugin Directory

Changeset 76389 for sermon-browser/trunk


Ignore:
Timestamp:
11/29/08 00:24:42 (5 years ago)
Author:
mark8barnes
Message:
 
Location:
sermon-browser/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • sermon-browser/trunk/sb-includes/dictionary.php

    r67681 r76389  
    1212        '[series_link]' => '<a href="<?php sb_print_series_link($sermon) ?>"><?php echo stripslashes($sermon->series) ?></a>', 
    1313        '[service_link]' => '<a href="<?php sb_print_service_link($sermon) ?>"><?php echo stripslashes($sermon->service) ?></a>',    
    14         '[date]' => '<?php echo date(get_option("date_format"), strtotime($sermon->date)) ?>', 
     14        '[date]' => '<?php echo date(get_option("date_format"), strtotime($sermon->date." 00:00 ".date("O"))) ?>', 
    1515        '[first_passage]' => '<?php $foo = unserialize($sermon->start); $bar = unserialize($sermon->end); echo sb_get_books($foo[0], $bar[0]) ?>', 
    1616        '[files_loop]' => '<?php foreach ((array) $stuff["Files"] as $file): ?>', 
     
    4343        '[series_link]' => '<a href="<?php sb_print_series_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->series) ?></a>', 
    4444        '[service_link]' => '<a href="<?php sb_print_service_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->service) ?></a>', 
    45         '[date]' => '<?php echo date(get_option("date_format"), strtotime($sermon["Sermon"]->date)) ?>', 
     45        '[date]' => '<?php echo date(get_option("date_format"), strtotime($sermon["Sermon"]->date." 00:00 ".date("O"))) ?>', 
    4646        '[passages_loop]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): ?>', 
    4747        '[/passages_loop]' => '<?php endfor ?>', 
     
    6565        '[akjvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "akjv"); endfor ?>', 
    6666        '[hnvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "hnv"); endfor ?>', 
     67        '[lbrvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "lbrv"); endfor ?>', 
    6768        '[biblepassage]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): sb_print_bible_passage ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i]); endfor ?>', 
    6869        '[editlink]' => '<?php sb_edit_link($_GET["sermon_id"]) ?>', 
  • sermon-browser/trunk/sb-includes/filetypes.php

    r57080 r76389  
    2525        'name' => 'Microsoft Word', 
    2626        'icon' => 'doc.png', 
    27         'content-type' => 'application/ms-word', 
     27        'content-type' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 
    2828    ),       
    2929    'rtf' => array( 
     
    4040        'name' => 'Powerpoint', 
    4141        'icon' => 'ppt.png', 
    42         'content-type' => 'application/vnd.ms-powerpoint', 
     42        'content-type' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 
    4343    ),       
    4444    'pdf' => array( 
     
    9090        'name' => 'Microsoft Excel', 
    9191        'icon' => 'xls.png', 
    92         'content-type' => 'application/vnd.ms-excel', 
     92        'content-type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 
    9393    ),       
    9494    'zip' => array( 
  • sermon-browser/trunk/sb-includes/frontend.php

    r68914 r76389  
    11<?php  
    22// Get the URL of the sermons page 
    3 function sb_display_url() { 
     3function sb_display_url($recalc=FALSE) { 
    44    global $display_url, $wpdb; 
    5     if (!$display_url) { 
    6         $pageid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%[sermons]%' AND post_status = 'publish' AND post_date < NOW();"); 
     5    if (!$display_url | $recalc) { 
     6        $pageid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%[sermons]%' AND (post_status = 'publish' OR post_status = 'private') AND post_date < NOW();"); 
    77        $display_url = get_permalink($pageid); 
    88        if ($display_url == sb_get_value('wordpress_url')|$display_url =="") { // Hack to force true permalink even if page used for front page. 
     
    197197//Returns ESV text 
    198198function sb_add_esv_text ($start, $end) { 
    199     // If you are experiencing errors, you should sign up for an ESV API key, and insert the name of your key in place of the letters IP in the URL below (.e.g. ...passageQuery?key=YOURAPIKEY&passage=...) 
     199    // If you are experiencing errors, you should sign up for an ESV API key,  
     200    // and insert the name of your key in place of the letters IP in the URL 
     201    // below (.e.g. ...passageQuery?key=YOURAPIKEY&passage=...) 
    200202    $esv_url = 'http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage='.urlencode(sb_tidy_reference ($start, $end)).'&include-headings=false&include-footnotes=false'; 
    201203    return sb_download_page ($esv_url); 
     
    281283            header("Content-Type: application/octet-stream"); 
    282284            header("Content-Type: application/download"); 
    283             header("Content-Disposition: attachment; filename=".$file_name.";"); 
     285            header('Content-Disposition: attachment; filename="'.$file_name.'";'); 
    284286            header("Content-Transfer-Encoding: binary"); 
    285287            sb_increase_download_count ($file_name); 
     
    317319                header ("Content-Disposition: ".$cd); } 
    318320            else { 
    319                 header("Content-Disposition: attachment; filename=".basename($url).";"); } 
     321                header('Content-Disposition: attachment; filename="'.basename($url).'";'); } 
    320322            header("Content-Transfer-Encoding: binary"); 
    321323            if ($filesize) header("Content-Length: ".$filesize); 
     
    336338        $file_name = $wpdb->get_var("SELECT name FROM {$wpdb->prefix}sb_stuff WHERE name='{$file_name}'"); 
    337339        if (!is_null($file_name)) { 
    338             $ext = substr($file_name, strrpos($file_name, '.') + 1); 
    339             if (isset($filetypes[$ext]['content-type'])) { 
    340                 header ("Content-Type: ".$filetypes[$ext]['content-type']); } 
    341             else { 
    342                 header ("Content-Type: application/octet-stream"); } 
     340            $url = get_option('sb_sermon_upload_url').$file_name; 
    343341            sb_increase_download_count ($file_name); 
    344             $file_name = sb_get_value('wordpress_path').get_option("sb_sermon_upload_dir").$file_name; 
    345             header("Content-Length: ".filesize($file_name)); 
    346             header("Content-Transfer-Encoding: binary"); 
    347             readfile_segments($file_name); 
     342            header("Location: ".$url); 
    348343        } 
    349344        exit(); 
     
    353348    if (isset($_REQUEST['show']) AND isset($_REQUEST['url'])) { 
    354349        $url = URLDecode($_GET['url']); 
    355         if(ini_get('allow_url_fopen')) { 
    356             $headers = array_change_key_case(get_headers($url, 1),CASE_LOWER); 
    357             $filesize = $headers['content-length']; 
    358             $cd =  $headers['content-disposition']; 
    359             $location =  $headers['location']; 
    360             $ext = substr($url, strrpos($url, '.') + 1); //Check this 
    361             if ($location) { 
    362                 header('Location: '.get_bloginfo('wpurl').'?show&url='.$location); 
    363                 die(); 
    364             } 
    365             if (isset($filetypes[$ext]['content-type'])) { 
    366                 header ("Content-Type: ".$filetypes[$ext]['content-type']); 
    367             } else { 
    368                 header ("Content-Type: application/octet-stream");  
    369             } 
    370             if ($cd) { 
    371                 header ("Content-Disposition: ".$cd); } 
    372             else { 
    373                 header("Content-Disposition: attachment; filename=".basename($url).";"); } 
    374             header("Content-Transfer-Encoding: binary"); 
    375             if ($filesize) header("Content-Length: ".$filesize); 
    376             sb_increase_download_count ($url); 
    377             readfile_segments($url); 
    378             exit(); 
    379         } 
    380         else { 
    381             sb_increase_download_count ($url); 
    382             header('Location: '.$url); 
    383         } 
     350        sb_increase_download_count ($url); 
     351        header('Location: '.$url); 
    384352    } 
    385353} 
     
    488456} 
    489457 
    490 // Adds sermon-browser code to Wordpress header 
    491 function sb_print_header() { 
    492 ?> 
    493     <!-- Added by SermonBrowser (version <?php echo SB_CURRENT_VERSION ?>) - http://www.4-14.org.uk/sermon-browser --> 
    494     <link rel="alternate" type="application/rss+xml" title="<?php _e('Sermon podcast', $sermon_domain) ?>" href="<?php echo get_option('sb_podcast') ?>" /> 
    495 <?php 
     458// Adds javascript and CSS where required 
     459function sb_add_headers() { 
     460    global $post, $wpdb; 
     461    $current_page = $post->ID; 
     462    $pageid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%[sermons]%' AND (post_status = 'publish' OR post_status = 'private') AND post_date < NOW();"); 
     463    if ($current_page == $pageid) { 
     464        wp_enqueue_script('sb_datepicker'); 
     465        wp_enqueue_script('sb_64'); 
     466        wp_enqueue_style ('sb_datepicker'); 
     467        wp_enqueue_style ('sb_style'); 
     468    } 
     469} 
     470 
     471// Adds podcast feeds to header 
     472function sb_add_feed_links() { 
    496473    global $sermon_domain, $post, $wpdb; 
    497     if ($_REQUEST['title'] OR $_REQUEST['preacher'] OR $_REQUEST['date'] OR $_REQUEST['enddate'] OR $_REQUEST['series'] OR $_REQUEST['service'] OR $_REQUEST['book'] OR $_REQUEST['stag']) { 
    498 ?> 
    499     <link rel="alternate" type="application/rss+xml" title="<?php _e('Custom sermon podcast', $sermon_domain) ?>" href="<?php echo sb_podcast_url() ?>" /> 
    500 <?php 
    501     } 
    502     $pageinfo = $wpdb->get_results("SELECT ID, post_type FROM {$wpdb->posts} WHERE post_content LIKE '%[sermons]%' AND post_status = 'publish' AND post_date < NOW();"); 
    503     $pageinfo = $pageinfo [0]; 
    504     if (($pageinfo->ID == $post->ID) OR $pageinfo->post_type == "post") { 
    505 ?> 
    506     <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/sb-includes/datepicker.css" type="text/css"/> 
    507     <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/sb-includes/style.php" type="text/css"/> 
    508     <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
    509     <script type="text/javascript" src="<?php echo sb_get_value('plugin_url') ?>/sb-includes/datePicker.js"></script> 
    510 <?php 
     474    echo "<!-- Added by SermonBrowser (version ".SB_CURRENT_VERSION.") - http://www.4-14.org.uk/sermon-browser -->\r"; 
     475    echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"".__('Sermon podcast', $sermon_domain)."\" href=\"".get_option('sb_podcast')."\" />\r"; 
     476    $current_page = $post->ID; 
     477    $pageid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%[sermons]%' AND (post_status = 'publish' OR post_status = 'private') AND post_date < NOW();"); 
     478    if ($current_page == $pageid) { 
     479        if ($_REQUEST['title'] OR $_REQUEST['preacher'] OR $_REQUEST['date'] OR $_REQUEST['enddate'] OR $_REQUEST['series'] OR $_REQUEST['service'] OR $_REQUEST['book'] OR $_REQUEST['stag']) { 
     480            echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"".__('Custom sermon podcast', $sermon_domain)."\" href=\"".sb_podcast_url()."\" />\r"; 
     481        } 
     482    } 
     483} 
     484 
     485//Returns the default time for a particular service 
     486function sb_default_time($service) { 
     487    global $wpdb; 
     488    $sermon_time = $wpdb->get_var("SELECT time FROM {$wpdb->prefix}sb_services WHERE id='{$service}'"); 
     489    if (isset($sermon_time)) { 
     490        return $sermon_time; 
     491    } else { 
     492        return "00:00"; 
    511493    } 
    512494} 
     
    724706        $tags[] = $tag->name; 
    725707    } 
    726 foreach ($stuff as $cur) { 
     708    foreach ($stuff as $cur) { 
    727709        switch ($cur->type) { 
    728710            case "file": 
     
    822804 
    823805//Gets attachments from database 
    824 function sb_get_stuff($sermon) { 
     806function sb_get_stuff($sermon, $mp3_only = FALSE) { 
    825807    global $wpdb; 
    826     $stuff = $wpdb->get_results("SELECT f.type, f.name FROM {$wpdb->prefix}sb_stuff as f WHERE sermon_id = $sermon->id ORDER BY id desc"); 
     808    if ($mp3_only) { 
     809        $stuff = $wpdb->get_results("SELECT f.type, f.name FROM {$wpdb->prefix}sb_stuff as f WHERE sermon_id = $sermon->id AND name LIKE '%.mp3' ORDER BY id desc"); 
     810    } else { 
     811        $stuff = $wpdb->get_results("SELECT f.type, f.name FROM {$wpdb->prefix}sb_stuff as f WHERE sermon_id = $sermon->id ORDER BY id desc"); 
     812    } 
    827813    foreach ($stuff as $cur) { 
    828814        ${$cur->type}[] = $cur->name; 
  • sermon-browser/trunk/sb-includes/podcast.php

    r57080 r76389  
    22//Prints ISO date for podcast 
    33function sb_print_iso_date($sermon) { 
    4     echo date('d M Y H:i:s O', strtotime($sermon->date.' '.$sermon->time)); 
     4    $sermon_time = $sermon->time; 
     5    echo "<!-- "; 
     6    print_r($sermon); 
     7    echo " -->"; 
     8    if ($sermon_time == "") 
     9        $sermon_time = sb_default_time ($sermon->sid); 
     10    echo date('d M Y H:i:s', strtotime($sermon->date.' '.$sermon_time))." +0000"; 
    511} 
    612 
     
    814function sb_first_mp3($sermon) { 
    915    $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; 
    10     $itunes = stristr($user_agent, 'itunes') ? true : false; 
    11     $stuff = sb_get_stuff($sermon); 
     16    $nostats = TRUE; 
     17    if (stripos($user_agent, 'itunes')===FALSE AND stripos($user_agent, 'itunes')===FALSE) 
     18        $nostats = FALSE; // Stats have to be turned off for iTunes compatibility 
     19    $stuff = sb_get_stuff($sermon, true); 
    1220    foreach ((array) $stuff['Files'] as $file) { 
    1321        if (strtolower(substr($file, strrpos($file, '.') + 1)) == 'mp3') { 
    1422            if (substr($file,0,7) == "http://") { 
    15                 if (!$itunes) $file=sb_display_url().sb_query_char().'show&amp;url='.URLencode($file); 
     23                if (!$nostats) $file=sb_display_url().sb_query_char().'show&amp;url='.URLencode($file); 
    1624            } else { 
    17                 if ($itunes) 
     25                if ($nostats) 
    1826                    $file=sb_get_value('wordpress_url').get_option('sb_sermon_upload_dir').URLencode($file); 
    1927                else 
     
    6169    <lastBuildDate><?php sb_print_iso_date($sermon[0]) ?></lastBuildDate> 
    6270    <pubDate><?php sb_print_iso_date($sermon[0]) ?></pubDate> 
    63     <generator>Wordpress Sermon Browser plugin (http://www.4-14.org.uk/sermon-browser)</generator> 
     71    <generator>Wordpress Sermon Browser plugin <?php SB_CURRENT_VERSION ?> (http://www.4-14.org.uk/sermon-browser)</generator> 
    6472    <docs>http://blogs.law.harvard.edu/tech/rss</docs> 
    6573    <category>Religion &amp; Spirituality</category> 
    6674    <itunes:category text="Religion &amp; Spirituality"></itunes:category> 
    67 <?php foreach ($sermons as $sermon):  ++$i; if($i>15) break; ?> 
    68         <item> 
    69             <guid><?php echo sb_first_mp3($sermon) ?></guid> 
    70             <title><?php echo stripslashes($sermon->title) ?></title> 
    71             <link><?php echo sb_display_url().sb_query_char().'sermon_id='.$sermon->id ?></link> 
    72             <description><?php echo stripslashes($sermon->description) ?></description> 
    73             <enclosure url="<?php echo sb_first_mp3($sermon) ?>" length="<?php echo sb_first_mp3_size($sermon) ?>" type="audio/mpeg"/> 
    74             <category><?php echo stripslashes($sermon->service) ?></category> 
    75             <pubDate><?php sb_print_iso_date($sermon) ?></pubDate> 
    76         </item> 
    77         <?php endforeach ?> 
     75<?php foreach ($sermons as $sermon):  ++$i; if($i>15) break; 
     76    $stuff = sb_get_stuff($sermon); 
     77    if ($stuff['Files'][0] != "") { 
     78    ?> 
     79    <item> 
     80        <guid><?php echo sb_first_mp3($sermon) ?></guid> 
     81        <title><?php echo stripslashes($sermon->title) ?></title> 
     82        <link><?php echo sb_display_url().sb_query_char().'sermon_id='.$sermon->id ?></link> 
     83        <description><?php echo stripslashes($sermon->description) ?></description> 
     84        <enclosure url="<?php echo sb_first_mp3($sermon) ?>" length="<?php echo sb_first_mp3_size($sermon) ?>" type="audio/mpeg"/> 
     85        <category><?php echo stripslashes($sermon->service) ?></category> 
     86        <pubDate><?php sb_print_iso_date($sermon) ?></pubDate> 
     87    </item> 
     88    <?php } 
     89        endforeach ?> 
    7890</channel> 
    7991</rss> 
  • sermon-browser/trunk/sb-includes/readme.txt

    r68920 r76389  
    44Tags: sermons, podcast, mp3, church, bible, audio, widget, embed, video, esv, wpmu 
    55Requires at least: 2.2 
    6 Tested up to: 2.6 
     6Tested up to: 2.7 
    77Stable tag: trunk 
    88 
     
    17173. Sermons uploaded in mp3 format can be **played directly** on your website using the 1PixelOut Audio Player. 
    18184. An optional **sidebar widget** displays sermons on all of your posts or pages. 
    19 5. **Embed videos** from sites such as YouTube or Google Video. 
     195. **Embed videos** and other flash files from sites such as YouTube or Google Video. 
    20206. **Other file types** can also be uploaded, including PDF, Powerpoint, Word, text and RTF. Multiple files can be attached to single sermons. 
    21217. The **full Bible text** of the passage being preached on can be included on each sermon page (five different versions, including ESV). 
     
    6666#### How do I change the Bible version from the ESV? 
    6767 
    68 Five Bible versions are supported by Sermon Browser: the English Standard Version, American Standard Version, King James Version, Young's Literal Transaltion and the World English Bible. To change to one of these other versions, go to Options, and edit the single template. Replace [esvtext] with [asvtext], [kjvtext], [ylttext] or [webtext]. Thanks go to Crossway for providing access to the ESV, and Living Stones Ministries for the other versions. 
     68Six Bible versions are supported by Sermon Browser: the English Standard Version, American Standard Version, King James Version, Young's Literal Translation, the World English Bible and the Spanish-language Reina Valera. To change to one of these other versions, go to Options, and edit the single template. Replace [esvtext] with [asvtext], [kjvtext], [ylttext], [webtext] or [lbrvtext]. Thanks go to Crossway for providing access to the ESV, and Living Stones Ministries for the other versions. 
    6969 
    7070If you're desperate to use other versions not currently supported, you can manage it using other Wordpress plugins (albeit with reduced functionality). However, if you're desperate to use other versions, you can manage it using other Wordpress plugins (albeit with reduced functionality). The eBibleicious plugin allows for NASB, MSG, KJV, NKJV, ESV, HCSB, and NCV (use it in 'snippet' mode). However, there are three disadvantages. (1) To use it, you'll need to register for an API key (although it is free). (2) It uses Javascript so search engines won't see the Bible text, and nor will users with javascript turned off. (3) Most importantly, it only shows a maximum of four verses (the ESV shows up to 500 verses!). 
  • sermon-browser/trunk/sb-includes/widget.php

    r57080 r76389  
    5454    foreach ( array_keys($options) as $o ) { 
    5555        // Old widgets can have null values for some reason 
    56         if ( !isset($options[$o]['limit']) ) // we used 'something' above in our exampple.  Replace with with whatever your real data are. 
     56        if ( !isset($options[$o]['limit']) ) // we used 'something' above in our example.  Replace with with whatever your real data are. 
    5757            continue; 
    5858 
  • sermon-browser/trunk/sermon.php

    r68914 r76389  
    55Description: Add sermons to your Wordpress blog. Main coding by <a href="http://codeandmore.com/">Tien Do Xuan</a>. Design and additional coding 
    66Author: Mark Barnes 
    7 Version: 0.37.3 
     7Version: 0.38 
    88Author URI: http://www.4-14.org.uk/ 
    99 
     
    2828 ** Initialisation                    ** 
    2929 **************************************/ 
    30 add_action('init', 'sb_sermon_init'); 
    31 add_action('admin_menu', 'sb_add_pages'); 
    32 add_action('rightnow_end', 'sb_rightnow'); 
    33 add_action('template_redirect', 'sb_hijack'); 
    34 add_filter('wp_title', 'sb_page_title'); 
    35 add_action('wp_head', 'sb_print_header'); 
    36 add_filter('the_content', 'sb_sermons_filter'); 
    37 add_action('widgets_init', 'sb_widget_sermon_init'); 
    38 if (SAVEQUERIES) add_action('wp_footer', 'sb_footer_stats'); 
    39 if (SAVEQUERIES) add_action('admin_footer', 'sb_footer_stats'); 
    40 register_activation_hook( __FILE__, 'sb_activate' ); 
     30//add_action('update_option_permalink_structure', 'update_podcast_url'); 
     31register_activation_hook( __FILE__, 'sb_activate' );            // Re-saves template on activation 
     32add_action('init', 'sb_sermon_init');                           // Initialise the plugin 
     33add_action('template_redirect', 'sb_hijack');                   // Check for file download or feed output 
     34add_action('admin_menu', 'sb_add_pages');                       // Add menus to admin 
     35add_action('rightnow_end', 'sb_rightnow');                      // Display stats in the dashboard 
     36add_filter('the_content', 'sb_sermons_filter');                 // Replace [sermons] 
     37add_action('widgets_init', 'sb_widget_sermon_init');            // Initialise the widget 
     38add_action('wp_head', 'sb_add_headers', 0);                     // Add CSS and javascript to frontend 
     39add_action('admin_init', 'sb_add_admin_headers');               // Add CSS and javascript to admin 
     40add_action('wp_head', 'wp_print_styles', 9);                    // Force styles output in header 
     41add_action('wp_head', 'sb_add_feed_links');                     // Add podcast feeds to HEAD 
     42add_filter('wp_title', 'sb_page_title');                        // Amend page title on sermon pages 
     43add_action('save_post', 'update_podcast_url');                  // Add check if [sermons] moves, and update podcast URL 
     44if (SAVEQUERIES) add_action('wp_footer', 'sb_footer_stats');    // Add stats to footer if required (frontend) 
     45if (SAVEQUERIES) add_action('admin_footer', 'sb_footer_stats'); // Add stats to footer if required (admin) 
    4146 
    4247// Include required files 
    43 require('sb-includes/dictionary.php'); // Template functions 
    44 require('sb-includes/filetypes.php'); // User-defined icons 
    45 require('sb-includes/frontend.php'); // Everything related to displaying sermons 
    46 require('sb-includes/widget.php'); // Displays widget if requested 
     48require('sb-includes/dictionary.php');  // Template functions 
     49require('sb-includes/filetypes.php');   // User-defined icons 
     50require('sb-includes/frontend.php');    // Everything related to displaying sermons 
     51require('sb-includes/widget.php');      // Widget functionality 
    4752 
    4853// Initialisation 
     
    5055    global $sermon_domain; 
    5156    //Set global constants 
    52     define('SB_CURRENT_VERSION', '0.37.3'); 
     57    define('SB_CURRENT_VERSION', '0.38'); 
    5358    define('SB_DATABASE_VERSION', '1.5'); 
    5459    $directories = explode(DIRECTORY_SEPARATOR,dirname(__FILE__)); 
     
    6772    // Return AJAX data if that is all that is required 
    6873    if ($_POST['sermon'] == 1) sb_return_ajax_data(); 
     74 
     75    // Register custom CSS and javascript files 
     76    wp_register_script('sb_64', sb_get_value('plugin_url').'/sb-includes/64.js', false, SB_CURRENT_VERSION); 
     77    wp_register_script('sb_datepicker', sb_get_value('plugin_url').'/sb-includes/datePicker.js', array('jquery'), SB_CURRENT_VERSION); 
     78    wp_register_style('sb_datepicker', sb_get_value('plugin_url').'/sb-includes/datepicker.css', false, SB_CURRENT_VERSION); 
     79    wp_register_style('sb_style', sb_get_value('plugin_url').'/sb-includes/style.php', false, get_option('sb_sermon_style_date_modified')); 
    6980 
    7081    //Attempt to set php.ini directives 
     
    344355} 
    345356 
     357// Adds javascript and CSS where required in admin 
     358function sb_add_admin_headers() { 
     359    if (substr($_REQUEST['page'],14) == 'sermon-browser') 
     360        wp_enqueue_script('jquery'); 
     361    if ($_REQUEST['page'] == 'sermon-browser/new_sermon.php') { 
     362        wp_enqueue_script('sb_datepicker'); 
     363        wp_enqueue_script('sb_64'); 
     364        wp_enqueue_style ('sb_datepicker'); 
     365    } 
     366} 
     367 
    346368// Display the options page and handle changes 
    347369function sb_options() { 
     
    718740    if ($_GET['act'] == 'new' || $_GET['act'] == 'edit') { 
    719741        if ($_GET['act'] == 'edit') $preacher = $wpdb->get_row("SELECT * FROM {$wpdb->prefix}sb_preachers WHERE id = ".(int) $_GET['pid']); 
    720     sb_check_sermon_tag(); 
    721742    //Display HTML 
    722743?> 
     
    780801     
    781802    $preachers = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}sb_preachers ORDER BY name asc"); 
     803    sb_check_sermon_tag(); 
    782804?> 
    783805    <div class="wrap"> 
     
    10651087    sb_check_sermon_tag(); 
    10661088?> 
    1067     <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
    1068     <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/fat.js"></script> 
    10691089    <script> 
    10701090        function rename(id, old) { 
    10711091            var f = prompt("<?php _e('New file name?', $sermon_domain) ?>", old); 
    10721092            if (f != null) { 
    1073                 jQuery.post('<?php echo sb_get_value('wordpress_url') ?>'/wp-admin/admin.php?page=sermon-browser/uploads.php', {fid: id, oname: old, fname: f, sermon: 1}, function(r) { 
     1093                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fid: id, oname: old, fname: f, sermon: 1}, function(r) { 
    10741094                    if (r) { 
    10751095                        if (r == 'renamed') { 
     
    10921112        } 
    10931113        function kill(id, f) { 
    1094             jQuery.post('<?php echo sb_get_value('wordpress_url') ?>'/wp-admin/admin.php?page=sermon-browser/uploads.php', {fname: f, fid: id, del: 1, sermon: 1}, function(r) { 
     1114            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fname: f, fid: id, del: 1, sermon: 1}, function(r) { 
    10951115                if (r) { 
    10961116                    if (r == 'deleted') { 
     
    11181138        } 
    11191139        function fetchU(st) { 
    1120             jQuery.post('<?php echo sb_get_value('wordpress_url') ?>'/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchU: st + 1, sermon: 1}, function(r) { 
     1140            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchU: st + 1, sermon: 1}, function(r) { 
    11211141                if (r) { 
    11221142                    jQuery('#the-list-u').html(r);                   
     
    11371157        } 
    11381158        function fetchL(st) { 
    1139             jQuery.post('<?php echo sb_get_value('wordpress_url') ?>'/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchL: st + 1, sermon: 1}, function(r) { 
     1159            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchL: st + 1, sermon: 1}, function(r) { 
    11401160                if (r) { 
    11411161                    jQuery('#the-list-l').html(r);                   
     
    11561176        } 
    11571177        function findNow() { 
    1158             jQuery.post('<?php echo sb_get_value('wordpress_url') ?>'/wp-admin/admin.php?page=sermon-browser/uploads.php', {search: jQuery('#search').val(), sermon: 1}, function(r) { 
     1178            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {search: jQuery('#search').val(), sermon: 1}, function(r) { 
    11591179                if (r) { 
    11601180                    jQuery('#the-list-s').html(r);                                       
     
    13561376    $series = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}sb_series ORDER BY name;"); 
    13571377?>   
    1358     <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
    13591378    <script> 
    13601379        function fetch(st) { 
     
    14581477// Displays new/edit sermon page 
    14591478function sb_new_sermon() { 
    1460     global $wpdb, $sermon_domain; 
    1461     global $allowedposttags; 
     1479    global $wpdb, $sermon_domain, $allowedposttags; 
    14621480    //Security check 
    14631481    if (function_exists('current_user_can')&&!(current_user_can('edit_posts')|current_user_can('publish_posts'))) 
     
    14911509        $end = mysql_real_escape_string(serialize($endz)); 
    14921510        $date = date('Y-m-d', strtotime($_POST['date'])); 
    1493         $description = mysql_real_escape_string(wp_kses($_POST['description'], $allowedposttags)); 
     1511        if (function_exists('current_user_can') && !current_user_can('unfiltered_html')) { 
     1512            $description = mysql_real_escape_string(wp_kses($_POST['description'], $allowedposttags)); 
     1513        } else { 
     1514            $description = mysql_real_escape_string($_POST['description']); 
     1515        } 
    14941516        $override = $_POST['override'] == 'on' ? 1 : 0; 
    14951517        // edit or not edit 
     
    16321654    $books = sb_get_value('bible_books'); 
    16331655?> 
    1634     <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/sb-includes/style.php" type="text/css"> 
    1635     <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/sb-includes/datepicker.css" type="text/css"> 
    1636     <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
    1637     <script type="text/javascript" src="<?php echo sb_get_value('plugin_url') ?>/sb-includes/datePicker.js"></script> 
    1638     <script type="text/javascript" src="<?php echo sb_get_value('plugin_url') ?>/sb-includes/64.js"></script> 
    16391656    <script type="text/javascript">      
    16401657        var timeArr = new Array(); 
     
    20362053            <li><a href="http://www.4-14.org.uk/sermonbrowser-tutorial/tutorial-5.html" target="_blank">Editing a sermon and adding embedded video</a></li> 
    20372054        </ul> 
    2038         <h4>Template tags</h4> 
     2055        <h3>Template tags</h3> 
    20392056        <p>If you want to change the way SermonBrowser displays on your website, you'll need to edit the templates and/or CSS file. Check out <a href="#templatetags">this guide to the template tags</a>.</p> 
    20402057        <h3>Frequently asked questions</h3> 
     
    23622379// Warns if [sermons] tag not found 
    23632380function sb_check_sermon_tag() { 
    2364     if (sb_display_url() == "") echo '<div id="message" class="updated"><p><b>'.__('You must create a post or preferably a page that includes the code [sermons] in order for your sermons to be displayed on your site.', $sermon_domain).'</b></div>'; 
     2381    if (sb_display_url() == "") { 
     2382        echo '<div id="message" class="updated"><p><b>'.__('You must create a post or preferably a page that includes the code [sermons] in order for your sermons to be displayed on your site.', $sermon_domain).'</b></div>'; 
     2383    } else { 
     2384        sb_check_audioplayer(); 
     2385    } 
     2386} 
     2387 
     2388// Alerts if AudioPlayer not installed 
     2389function sb_check_audioplayer() { 
     2390    global $wpdb, $sermon_domain; 
     2391    if (!function_exists('ap_insert_player_widgets')) { 
     2392        if ($wpdb->get_var("SELECT COUNT(id) FROM wp_sb_stuff WHERE name LIKE '%.mp3'")>0) 
     2393            echo '<div id="message" class="updated"><p><b>'.sprintf(__('Tip: Installing the %1$sWordpress Audio Player%2$s will allow users to listen to your sermons more easily.', $sermon_domain), '<a href="http://wpaudioplayer.com/" target="_blank">', '</a>').'</b></div>'; 
     2394    } else { 
     2395        if (rand (1,5) == 1) 
     2396            echo '<div id="message" class="updated"><p><b>'.sprintf(__('If you find SermonBrowser useful, please consider a %1$ssmall donation%2$s.', $sermon_domain), '<a href="http://www.4-14.org.uk/sermon-browser#support" target="_blank">', '</a>').'</b></div>'; 
     2397    } 
    23652398} 
    23662399 
     
    24262459    $files = $wpdb->get_results("SELECT name FROM {$wpdb->prefix}sb_stuff WHERE type = 'file';"); 
    24272460    $bnn = array(); 
     2461    $dir = sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir');    
    24282462    foreach ($files as $file) { 
    24292463        $bnn[] = $file->name; 
     2464        if (!file_exists($dir.$file->name)) { 
     2465            $wpdb->query("DELETE FROM {$wpdb->prefix}sb_stuff WHERE name='".$file->name."' AND sermon_id=0;"); 
     2466        } 
    24302467    } 
    24312468     
    2432     $dir = sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir');    
    24332469    if ($dh = @opendir($dir)) { 
    24342470        while (false !== ($file = readdir($dh))) { 
     
    24832519    switch($last) { 
    24842520        case 'g': 
    2485             $val *= 1024; 
     2521            $val *= 1024000; 
    24862522        case 'm': 
    24872523            $val *= 1024; 
     
    24952531    $stats = $wpdb->get_var("SELECT SUM(count) FROM ".$wpdb->prefix."sb_stuff WHERE sermon_id=".$sermonid); 
    24962532    if ($stats > 0) return $stats; 
     2533} 
     2534 
     2535//Updates podcast URL in wp_options (required if permalinks changed or [sermons] added to a different page) 
     2536function update_podcast_url () { 
     2537    global $wp_rewrite; 
     2538    $existing_url = get_option('sb_podcast'); 
     2539    if (substr($existing_url, 0, strlen(sb_get_value('wordpress_url'))) == sb_get_value('wordpress_url')) { 
     2540        if (sb_display_url(TRUE)=="") { 
     2541            update_option('sb_podcast', sb_get_value('wordpress_url').sb_query_char().'podcast'); 
     2542        } else { 
     2543            update_option('sb_podcast', sb_display_url().sb_query_char ().'podcast'); 
     2544        } 
     2545    } 
    24972546} 
    24982547 
Note: See TracChangeset for help on using the changeset viewer.