Wordpress Sermon Browser podcast feed missing length attribute - rss

My podcast feed won't validate and gives the error "Missing enclosure attribute: length" I see the call for sb_media_size (file size function) within the enclosure tag but no results. This is a WordPress plugin, Sermon Browser. Help appreciated. Thank you!
//Prints size of file
function sb_media_size($media_name, $media_type) {
if ($media_type == 'URLs') {
if(ini_get('allow_url_fopen')) {
$headers = is_array($media_name) && array_change_key_case(#get_headers($media_name, 1),CASE_LOWER);
$filesize = $headers['content-length'];
if ($filesize)
return "length=\"{$filesize}\"";
}
} else
return 'length="'.#filesize(SB_ABSPATH.sb_get_option('upload_dir').$media_name).'"';
}
<enclosure url="<?php echo sb_podcast_file_url($media_name, $media_type).'" '.sb_media_size($media_name, $media_type).sb_mime_type($media_name); ?> />

Used fiverr.com. Solution was reinstalling the plugin. WP wouldn't allow me. The developer went to plugin editor, and changed plugin version to lower, so WP will detect that there's a newer version, and plugin will be reinstalled while settings are kept.

Related

Appending parameter to URL to solve issue with Page Caching and Tax Toggles

I have a WooCommerce website which uses a plugin called "Booster for WooCommerce" primarily for their "Tax Display" module. This plugin enables us to have a button in the header which allows the customer to switch between inc and exc VAT. The default setting is including tax.
The problem I'm encountering now is when I enable page caching in W3 Total Cache, the plugin is caching the first visit to a shop or product page along with the prices and then the next person to visit that page sees pricing based on the first user's tax toggle setting, not their own.
I can think of a few solutions to this in varying complexity but after noticing that the booster plugin sets a session variable via:
WC()->session->set('wcj_toggle_tax_display',( 'incl' === $current_value ? 'excl' : 'incl' ));
I'm wondering if there's a simple fix where I could simply hook in just before page load and if that session variable is set to excl, then set a URL parameter such as "?vat=false". Which I'm assuming would then cache as it's own unique URL and solve the problem.
I'm just not sure which hook would work for appending the parameter to the URL and my searches are getting me nowhere.
I've scoured over various solutions to this issue for days now, so a simple fix like this would be a godsend, I'm just not 100% sure how possible it is.
Any help on this would be greatly appreciated!
Thanks,
Jack
So far, the following code seems to have solved this problem but I'm still testing further with W3 Total Cache.
// Add URL parameter vat=false if tax toggle set to excl
function custom_redirect_append_url_params() {
if (is_woocommerce()) {
$toggle_status = wcj_session_get( 'wcj_toggle_tax_display' );
if (empty($toggle_status)) $toggle_status = 'incl'; //default value = incl
//if vat isn't set as a query var && toggle status is set to excl then redirect
if(!isset($_GET['vat']) && $toggle_status === 'excl') {
//do your redirect here with wp_redirect()
wp_redirect( add_query_arg( 'vat', 'false', $_SERVER['REQUEST_URI'] ));
exit; //prevent wordpress continuing to load templates
}
elseif($_GET['vat'] === 'false' && $toggle_status === 'incl') {
wp_redirect( add_query_arg( 'vat', 'true', $_SERVER['REQUEST_URI'] ));
exit; //prevent wordpress continuing to load templates
}
}
}
add_action('template_redirect','custom_redirect_append_url_params');

Wordpress is single undefined

I'm creating a new wordpress plugin, which only be displayed in posts, but to detect it's a post, I'm trying to use is_single(), but it does not work.
class myplugin{
//my plugin code here
}
function load_plugin($plugin_class, $priority = 10) {
if (class_exists($plugin_class)) {
add_action("init",
create_function('', "global \$$plugin_class; \$$plugin_class = new $plugin_class();"),
$priority);
}
}
if(is_single()){ // witout this, the plugin is displayed everywhere, but whit it it's not displayed at all
load_plugin(myplugin);
}
I even tried to see the output of is_single
echo"<script>alert('".is_single()."');</script>";
i get "undefined"
edit // witout the is_single and just loading my plugin, my plugin works on every page of wordpress.
Conditional tags, like is_single, are not available until the the wp hook has fired. You're trying to use it too early, which is why it returns undefined.
Add your function to a hook after that and do the is_single test there. There is very little overhead in this so don't worry about performance issues.

Way to get Twitter button, with count, with custom bit.ly URL, working?

I'm stuck. I posted this on WordPress.StackExchange and they suggested I try at WebApps.StackExchange, and they suggested I try here. So, apologies for the multiple posts if you follow all those!
I have a client blog using bit.ly pro to generate custom short urls (ie foo.co). I want to show the regular horizontal version of the Twitter button, with tweet-count, and have the link that goes to the post use their custom bit.ly pro url.
I have installed Joost de Valk's Bit.ly Shortlinks plugin, which successfully converts normal WP shortlinks (wp_get_shortlink()) to the custom Bit.ly pro URL elsewhere in the site, but Twitter seems to trump that and render everything with the default t.co domain instead.
I've looked at the suggestions from this question but using the # as the data-url doesn't work, and the suggested Twitter support pages don't seem to contain any info on how to get Bit.ly to work (though they say they're going to).
Here's the function I created to insert the button in my theme - any ideas on where I'm going wrong? this is used to insert the button both within the Loop and on single-post pages.
function tweet_this() {
global $post;
ob_start();
$tweet = wp_get_shortlink();
echo '<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>Tweet';
return ob_get_clean();
}
In case it helps, this function does work, except it doesn't render the tweet-count:
function tweet_this() {
global $post;
ob_start();
$tweet = sprintf( __('%1$s %2$s'), $post->post_title, wp_get_shortlink() );
echo '<a class="tweethis" href="http://twitter.com/intent/tweet?text=' . urlencode( $tweet ) . ' via #clientname">Tweet this</a>';
return ob_get_clean();
}
Let me know if you need more info - and thanks in advance for any help you can throw my way!
Michelle
function tweet_this() {
global $post;
$tweet = get_permalink(); //replace with your code
$tweetmarkup = '<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>Tweet';
echo $tweetmarkup;
}
This works for me, but I don't have the WPShortlinks installed, so I replaced it with the permalink. You should be able to replace the permalink with your wp_get_shortlink and it should work.

Content elements for wordpress

I'm looking for a plugin (or better yet, not a plugin) for wordpress that lets me generate standard content elements, or includes for posts and pages.
For example, my_content_1 could be:
buy it now for $23!!
Which could then be included in posts and pages using some kind of syntax (or whatever) like:
Welcome to my site, blah blah blah.. check out this product - %my_content_1%
Not looking for anything fancy, anything that does this sort of thing would be awesome.
The point of this being much like a regular php include I could have the same information updated in one place and applied over many pages/posts.
I found something that is pretty much what I'm looking for:
http://wordpress.org/extend/plugins/reusables/
However, other suggestions would be good as I'm not too confident in the quality of the code for that plugin.
Not sure about a plugin, but how about simply creating something yourself? If you created a PHP page and set up variables such as
$content->title = "This is a title"
$content->smallText = "Insert some short paragraph here"
And then just include it in your header? You could store it in your theme directory and then call it like so
<?php $themeFolder = get_bloginfo("template_url"); ?>
<?php include($themeFolder."/content.php") ?>
Would that be suitable?
How about creating a few files and link them in using shortcode?
ie: open your themes/functions.php file add this..
<?php
function wp_my_shortcodes($atts)
{
extract(shortcode_atts(array(
'type' => '', //author, rss, adverts
), $atts));
switch($type) {
case 'author' : $display = wp_display_author_info(); break;
case 'rssview' : $display = wp_display_rss_info(); break;
case 'adverts' : $display = wp_display_adverts(); break;
default : $display = wp_display_author_info(); break;
}
return $display ;
}
add_shortcode('mycontent', wp_my_shortcodes);
function wp_display_author_info()
{
include(TEMPLATEPATH.'/my_author_info.php');
}
function wp_display_rss_info()
{
include(TEMPLATEPATH.'/my_rss_info.php');
}
function wp_display_adverts()
{
include(TEMPLATEPATH.'/my_adverts.php');
}
?>
using shortcodes inside your posts you can then bring in which ever piece of content that you want.. in the example above I've created 3 pages in the template root folder called
my_author_info.php, my_rss_info.php, my_adverts.php all of which speak for themself..
my_author_info.php
this page could use the the_author_meta() to populate a div box with included author info,
my_rss_info.php
include your subscription box to let users subscribe to your blog
my_adverts.php
include 4x 125x125 adverts?
so in the post i could use
[mycontent type='author']
[mycontent type='rssview']
[mycontent type='adverts']
if no argument is added to the shortcode then the default view is shown, in this case..
[mycontent]
would return the authorview as default...
this would then include that file in the content...
just remember to create the included files :)
I found something that is pretty much what I'm looking for:
http://wordpress.org/extend/plugins/reusables/

Wordpress Plug-ins: How-to add custom URL Handles

I'm trying to write a Wordpress Plug-in but can't seem to figure out how you would modify how a URL gets handled, so for example: any requests made for:
<url>/?myplugin=<pageID>
will get handled by a function in my plug-in. I'm sure this is a very simple to do, but I'm pretty new to working with Wordpress and couldn't find it in the documentation.
In order to handle just a specific URL use the code below:
add_action('parse_request', 'my_custom_url_handler');
function my_custom_url_handler() {
if(isset($_GET['myplugin']) && $_SERVER["REQUEST_URI"] == '/custom_url') {
echo "<h1>TEST</h1>";
exit();
}
}
add_action('parse_request', 'my_custom_url_handler');
function my_custom_url_handler() {
if( isset($_GET['myplugin']) ) {
// do something
exit();
}
}
That should set you on the right direction. parse_request happens before WordPress runs any of the complicated WordPress queries used to get the posts for the current URL.

Resources