Forum Replies Created

Viewing 15 replies - 16 through 30 (of 55 total)
  • Thread Starter radgh

    (@radgh)

    I managed to get this to work with a small plugin that replaces the URLs, similar to my original idea.

    https://example.org/podcast-player/27363/example.mp3

    Into this:

    https://example.org/podcast-download/27363/example_._mp3

    As luck would have it, this URL still redirects to the correct media file without any extra effort. Tracking seems to work, too.

    The only downside is that the link didn’t convert into an audio player automatically, so I copied that audio player and used that directly in “aa_ssp_audio_shortcode_params”. This basically means instead of WordPress’s black themed audio player, you get the browser default player (which is gray in chrome).

    Here is the plugin, put this in a php file in your plugins folder and then activate it:

    <?php
    /*
    Plugin Name: Seriously Simple Podcasting - NGINX
    Description: This plugin fixes the "virtual URLs" generated by S.S.P. by removing the .mp3 extension of audio files. This fix resolves routing issues in when NGINX is used to serve static resources.
    Author: Radley Sustaire
    Author URI: https://radleysustaire.com/
    */
    
    /**
     * Converts "example.mp3" into "example_._mp3" which is sufficient for the file to skip nginx, but WordPress still redirects properly.
     *
     * @param $link
     *
     * @return mixed
     */
    function aa_ssp_remove_mp3_ext( $link ) {
    	// Check length of extension because on 2-3 length extensions will be unfurled
    	$replaces = array(
    		'.mp3' => '_._mp3',
    		'.wav' => '_._wav',
    		'.mp4' => '_._mp4'
    	);
    	
    	$link = str_replace( array_keys($replaces), array_values($replaces), $link );
    	
    	return $link;
    }
    add_filter( 'ssp_episode_download_link', 'aa_ssp_remove_mp3_ext', 20 );
    add_filter( 'ssp_feed_item_enclosure', 'aa_ssp_remove_mp3_ext', 20 );
    
    /**
     * For replacing the download link generated by ssp
     *
     * @param $link
     *
     * @return mixed
     */
    function aa_ssp_modify_download_link( $link ) {
    	return aa_ssp_remove_mp3_ext( $link );
    }
    add_filter( 'ssp_episode_download_link', 'aa_ssp_modify_download_link', 20 );
    
    /**
     * For replacing other meta keys of ssp, primarily the "download file" and "play in new window" links.
     *
     * @param $meta
     *
     * @return mixed
     */
    function aa_ssp_modify_meta_urls( $meta ) {
    	$keys_to_replace = array(
    		'link',
    		'new_window'
    	);
    	
    	foreach( $meta as $k => $v ) {
    		if ( in_array($k, $keys_to_replace) ) {
    			$meta[$k] = aa_ssp_remove_mp3_ext( $v );
    		}
    	}
    	
    	return $meta;
    }
    add_filter( 'ssp_episode_meta_details', 'aa_ssp_modify_meta_urls', 20 );
    
    /**
     * Makes the shortcode embed an audio player. When using the "example_._mp3" format WordPress does not treat it as an audio file and does not put it into a media player.
     *
     * @param null $player
     * @param null $srcFile
     * @param null $episode_id
     *
     * @return null|string
     */
    function aa_ssp_audio_shortcode_params( $player = null, $srcFile = null, $episode_id = null ) {
    	if ( strpos( $srcFile, '_._' ) !== false ) {
    		// This is a modified podcast mp3 link.
    		
    		static $x = 0;
    		$x++;
    		
    		$html =
    			'<!--[if lt IE 9]><script>document.createElement(\'audio\');</script><![endif]-->
    			<audio class="wp-audio-shortcode" id="audio-'.$episode_id.'-'.$x.'" preload="none" style="width: 100%;" controls="controls" autoplay="autoplay"><source type="audio/mpeg" src="'.$srcFile.'?_=1" /><a href="'.$srcFile.'">'.$srcFile.'</a></audio>';
    		
    		return $html;
    	}
    	
    	return $player;
    }
    add_filter( 'ssp_media_player', 'aa_ssp_audio_shortcode_params', 20, 3 );
    Thread Starter radgh

    (@radgh)

    Oh sorry I’m sure I tried using it as a boolean before at some point as I tried many combinations of options when I was testing. In any case, once I got rid of the plugin all of the issues I was facing disappeared and the website has launched with an alternative to block spam.

    Thanks for the effort anyway!

    Thread Starter radgh

    (@radgh)

    Below is the ACF form I used prior to leaving my comment. When viewing the form on the front-end, only the recaptcha was visible until you tick the box and then submit, then the full form appears. Doing this created an empty “open_house” post. And actually for some reason, it created two at the exact same time.

    Submitting the full form after the recaptcha worked, though.

    	$args = array(
    		'post_id'		=> 'new_post',
    		'post_title'	=> false,
    		'post_content'	=> false,
    		'new_post'		=> array(
    			'post_type'		=> 'open_house',
    			'post_status'	=> 'publish'
    		),
    	    'field_groups' => array(
                'group_59bae2a7e074a' // Open House Details
    		),
                'fields' => array( 'field_59c3114cf1839' ), // Recaptcha field from an active field group
                'recaptcha' => 'true',
    	    'submit_value'    => 'Add Listing',
    	    'updated_message' => 'Listing created successfully',
    	    'return'          => add_query_arg( array( 'h_action' => 'edit', 'h_id' => '%post_id%', 'updated' => 1), get_permalink() ),
    	);
    	acf_form($args);

    Later on, I tried a second time with a different ACF form with an inline ReCAPTCHA field. This one showed the entire form along with the recaptcha. This was for an event post type with different fields.

    However, when submitting this form it also created empty events. This also made it so ajax validation didn’t work – if you have an error it goes to a new page and gives you a screen of error messages in a wp_die() dialog. Without the recaptcha field, trying to submit with errors would highlight the bad fields in red without reloading the page.

    	$args = array(
    		'post_id'		=> 'new_post',
    		'post_title'	=> true,
    		'post_content'	=> false,
    		'new_post'		=> array(
    			'post_type'		=> 'event',
    			'post_status'	=> 'pending'
    		),
    		'field_groups' => array(
    			'group_59c2a8fd60859' // Event Details
    		),
    		'submit_value'    => 'Add Event',
    		'updated_message' => 'Event created successfully',
    	);
    	
    	acf_form($args);

    Note for the second one: I added the recaptcha field to the field group seen in that code. I added the keys appropriately, and made the recaptcha required. I also turned on the switch at the bottom of the ACF settings that said it requires the recaptcha field to submit (I don’t remember the exact verbiage of that checkbox though).

    Hope that helps.

    Thread Starter radgh

    (@radgh)

    Cool. I haven’t tested to be sure, but I’m happy to take your word for it that these are addressed (or will be in the next update). I updated my review to 5 stars, though that is pending moderator approval so you might still see 4 stars for now.

    Thanks Collins

    Thread Starter radgh

    (@radgh)

    No, it’s actually just a very old Media Temple server that the website was on (plesk, unmanaged server). I manage a lot of websites and I have ran into this issue only a couple of times. It’s not my responsibility to manage this client’s server so I’m actually OK with the workaround ??

    • This reply was modified 8 years, 3 months ago by radgh.
    Thread Starter radgh

    (@radgh)

    Ah, I’ve learned our content manager has an exported version of his settings to roll out for SEO Ultimate. The keywords module is still turned on in there probably from a long time ago. I’ve removed that from my previous comments and added a star to the review.

    Regarding the pro version, if your pricing model was more inline with Advanced Custom Fields or WP All Import, then we would definitely upgrade.

    But updates only last a year. This doesn’t work for us. Thanks anyway.

    I don’t think I’ll be contributing since it sounds like the features I’ve requested are all locked in the pro version already.

    Thread Starter radgh

    (@radgh)

    Oh great. I quickly realized from my settings, this plugin only works with image sizes that have cropping enabled.

    // Default image sizes
    'thumbnail' => array( 360, 360, false ),
    'medium' => array( 720, 720, false ),
    'large' => array( 1080, 1080, false ),
    
    // Custom image sizes
    'thumbnail-cropped' => array( 360, 360, true ),
    'huge' => array( 1440, 1440, false ),
    'rssfeed-landscape' => array( 560, 280, true ),

    Is there a way to allow non-cropped photos to be manually cropped? The jquery resizing plugin that is used looks like it would allow a custom aspect ratio.

    Thread Starter radgh

    (@radgh)

    I would actually recommend using the widgets built-in to the plugin for that, unless it’s really not suited to it. Just create three “sidebars” and configure the widget in each one, then display the “sidebar” for each tab.

    You might also try Ultimate Tabbed Widgets to save even more time: https://www.ads-software.com/support/view/plugin-reviews/ultimate-tabbed-widgets

    If this doesn’t work for you, you should still be able to use the original code. You’ll just need to do three separate queries, so repeat step 2 for each tab, with a different meta key.

    Thread Starter radgh

    (@radgh)

    There shouldn’t be a problem using all four at the same time, if that’s what you mean. They shouldn’t conflict with each other.

    I’m not sure what you mean by:

    “this add plus 1 for all custom_fields”

    Thread Starter radgh

    (@radgh)

    I’ve thought of that too, but when it comes to losing data, meh. Also, very much used to those question marks popping up in a window. But it can go either way I suppose.

    Definitely a grey area ??

    Yeah, I guess that was obvious. It could almost be a separate plugin by itself. But since it’s also not really useful unless you’re a developer, I guess there’s not much sense to build it versus building a function like the one above. Ah well.

    Thanks for the plugin as it is! I am definitely pleased with it, even lacking the feature.

    The code provided by the OP no longer works. This was pointed out by Hector, but it’s easy to miss!

    I posted a separate thread here: https://www.ads-software.com/support/topic/how-to-sort-a-custom-query-by-views-all-time-monthly-weekly-or-daily?replies=1

    I spent a good 20 minutes trying to debug the code before I noticed Hector’s comment. It might be a good idea to sticky the working example to save some people the frustration in the future ??

    I’m surprised this isn’t built-in to the plugin!

    Thread Starter radgh

    (@radgh)

    Ok, I got a similar issue pointing to a random file in wp-admin. Changed to PHP 5.3 and it went away. The plugin worked for several days without issue which is weird. I don’t think this plugin is at fault though.

    Working fine in PHP 5.3 again.

    Thread Starter radgh

    (@radgh)

    The code tags shown above are meant to be grave symbols… The forums added them.

    Thread Starter radgh

    (@radgh)

    Yes I am using seamless mode.

    Thanks for the example on Gist. I couldn’t get it to work though. It seems the filters are not being called. Got any ideas?

    Here’s my settings:

    General – https://i.imgur.com/x0c5Rhb.jpg
    Search Results 1/2 – https://i.imgur.com/LZn6xl0.jpg
    Search Results 2/2 – https://i.imgur.com/wFIaf3L.jpg

    The page I am testing on is:

    https://willamalane.org/?s=lil

    Some of the classes shown, such as “Junior Turbos: Lil Dribblers”, have expired. We’re trying to hide them from that page, for now I’ve simply made them say “This class expired on ____”.

    Here’s what I was trying, which seemed to have no effect on the search page. It should have killed the page to display the where statement (var_dump, exit). The SQL itself hasn’t been tested yet, but it couldn’t be reached, so I can’t exactly test it yet.

    function class_hide_expired_bsearch_join( $join ) {
    	global $wpdb;
    
    	$join = $join . "\n  LEFT JOIN {$wpdb->postmeta} <code>class_date</code> ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id";
    	$join = $join . "\n  LEFT JOIN {$wpdb->postmeta} <code>always_show</code> ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id";
    
    	return $join;
    }
    function class_hide_expired_bsearch_where( $where ) {
    	global $wpdb;
    
    	$time = time();
    
    	$where = $where . "\n
    	AND (
    		{$wpdb->posts}.post_type != 'class'
    		OR (
    			<code>class_date</code>.meta_key = 'date-timestamp'
    			AND (
    				<code>class_date</code>.meta_value = 0
    				OR
    				<code>class_date</code>.meta_value > {$time}
    			)
    		) OR (
    			<code>always_show</code>.meta_key = 'always-show'
    			AND
    			<code>always_show</code>.meta_value = 'on'
    		)
    	)";
    
    	// Let's take a look at the WHERE statement
    	echo "<pre>";
    	var_dump($where);
    	exit;
    
    	return $where;
    }
    add_filter( 'bsearch_posts_join', 'class_hide_expired_bsearch_join' );
    add_filter( 'bsearch_posts_where', 'class_hide_expired_bsearch_where' );
Viewing 15 replies - 16 through 30 (of 55 total)