Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pirate-bot/e62dd80bfd27c09d464240f9e242e0a4 to your computer and use it in GitHub Desktop.

Select an option

Save pirate-bot/e62dd80bfd27c09d464240f9e242e0a4 to your computer and use it in GitHub Desktop.
Do not import items that do not have images.
<?php
/*
Plugin Name: Feedzy tweak - Do not import items that do not have images
Version: 0.0.1
Author URI: https://themeisle.com
*/
add_filter( 'feedzy_insert_post_args', 'feedzy_insert_post_limit', 10, 4 );
function feedzy_insert_post_limit( $args, $item, $title, $content ) {
// empty title and content prevents WP from inserting a post.
$allowed = array('gif', 'png', 'jpg', 'jpeg');
$filename = $item['item_img_path'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (!in_array($ext, $allowed)) {
$args['post_title'] = '';
$args['post_content'] = '';
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment