How do I remove youtube link in title when pulling from facebookfeed?

Hi there.. Great plugin!! Does everything I need it to do, so I hope you can help me with this one thing:
When using a facebook-feed with a youtube link in it, the youtube link is visible in the post-title when it imports into wordpress. Is there any way to avoid that?
Cheers
Karsten

  • Hoang Ngo

    Hi @Karsten Christrup,

    Thanks for your information.

    I have checked your feed, and it seem the youtube url already in the feed item's title.

    And because of the title length, sometime the url will look like "http://yo....", so I think, better we should remove all the url in the title.

    Please add this code to your theme functions.php, it will strip urls in post title.

    add_filter( 'autoblog_pre_post_insert', 'remove_youtube_url_in_title', 40, 2 );
    add_filter( 'autoblog_pre_post_update', 'remove_youtube_url_in_title', 40, 2 );
    function remove_youtube_url_in_title( $data, $details ) {
    	$feeds_to_do = array(
    		'test',
    		'your feed title'
    	);
    	if ( in_array( strtolower( $details['title'] ), $feeds_to_do ) ) {
    		$title = htmlspecialchars_decode( $data['post_title'] );
    		$title = html_entity_decode( $title );
    		$title = str_replace( 'http://', ' http://', $title );
    		foreach ( explode( ' ', $title ) as $val ) {
    			if ( stristr( $val, 'http://' ) ) {
    				$data['post_title'] = str_replace( $val, '', $data['post_title'] );
    			}
    		}
    	}
    
    	return $data;
    }

    You will see the $feeds_to_do variable, this is where you put the feed need to process.

    Best Regards,
    Hoang

  • Karsten Christrup

    Hi Hoang, This is brilliant - thank you!
    However I´m having troubles getting the function and filter to work. The site is using a framework from mysitemyway.com - which it calls from function.php - like so:

    require_once( TEMPLATEPATH . '/framework.php' );
    
    # Get theme data.
    $theme_data = get_theme_data( TEMPLATEPATH . '/style.css' );
    
    # Initialize the Mysitemyway framework.
    Mysitemyway::init(array(
    	'theme_name' => $theme_data['Name'],
    	'theme_version' => $theme_data['Version']
    ));

    .. and when I insert the function and filter after this, it just gives me a wsod.. I´ve also tried different ways to insert the function in the framework.php, but nothing happens.. I´ve attached the framework file -- could you perhaps show me how and where to insert your function correctly? I apologize for being a novice in this, and thank you so much for helping me :slight_smile:

    Best Regards,
    Karsten

  • Karsten Christrup

    Ahr.. file extension not allowed - I´m pasting the framework.php as code instead.. sorry for the inconvenience. Best Regards,
    Karsten

    <?php
    /**
     * The Mysitemyway class. Defines the necessary constants
     * and includes the necessary files for theme's operation.
     *
     * @package Mysitemyway
     * @subpackage Echelon
     */
    
    class Mysitemyway {
    
    	/**
    	 * Initializes the theme framework by loading
    	 * required files and functions for the theme.
    	 *
    	 * @since 1.0
    	 */
    	function init( $options ) {
    		self::constants( $options );
    		self::functions();
    		self::extensions();
    		self::classes();
    		self::variables();
    		self::actions();
    		self::filters();
    		self::supports();
    		self::locale();
    		self::admin();
    	}
    
    	/**
    	 * Define theme constants.
    	 *
    	 * @since 1.0
    	 */
    	function constants( $options ) {
    		define( 'THEME_NAME', $options['theme_name'] );
    		define( 'THEME_SLUG', get_template() );
    		define( 'THEME_VERSION', $options['theme_version'] );
    		define( 'FRAMEWORK_VERSION', '2.8' );
    		define( 'DOCUMENTATION_URL', 'http://mysitemyway.com/docs/index.php/Main_Page' );
    		define( 'SUPPORT_URL', 'http://mysitemyway.com/support' );
    		define( 'MYSITE_PREFIX', 'mysite' );
    		define( 'MYSITE_TEXTDOMAIN', THEME_SLUG );
    		define( 'MYSITE_ADMIN_TEXTDOMAIN', THEME_SLUG . '_admin' );
    
    		define( 'MYSITE_SETTINGS', 'mysite_' . THEME_SLUG . '_options' );
    		define( 'MYSITE_INTERNAL_SETTINGS', 'mysite_' . THEME_SLUG . '_internal_options' );
    		define( 'MYSITE_SIDEBARS', 'mysite_' . THEME_SLUG . '_sidebars' );
    		define( 'MYSITE_SKINS', 'mysite_' . THEME_SLUG . '_skins' );
    		define( 'MYSITE_ACTIVE_SKIN', 'mysite_' . THEME_SLUG . '_active_skin' );
    		define( 'MYSITE_SKIN_NT_WRITABLE', 'mysite_' . THEME_SLUG . '_skins_nt_writable' );
    
    		define( 'THEME_URI', get_template_directory_uri() );
    		define( 'THEME_DIR', get_template_directory() );
    
    		define( 'THEME_LIBRARY', THEME_DIR . '/lib' );
    		define( 'THEME_ADMIN', THEME_LIBRARY . '/admin' );
    		define( 'THEME_FUNCTIONS', THEME_LIBRARY . '/functions' );
    		define( 'THEME_CLASSES', THEME_LIBRARY . '/classes' );
    		define( 'THEME_EXTENSIONS', THEME_LIBRARY . '/extensions' );
    		define( 'THEME_SHORTCODES', THEME_LIBRARY . '/shortcodes' );
    		define( 'THEME_CACHE', THEME_DIR . '/cache' );
    		define( 'THEME_FONTS', THEME_LIBRARY . '/scripts/fonts' );
    		define( 'THEME_STYLES_DIR', THEME_DIR . '/styles' );
    		define( 'THEME_PATTERNS_DIR', THEME_STYLES_DIR . '/_patterns' );
    		define( 'THEME_SPRITES_DIR', THEME_STYLES_DIR . '/_sprites' );
    		define( 'THEME_IMAGES_DIR', THEME_DIR . '/images' );
    
    		define( 'THEME_PATTERNS', '_patterns' );
    		define( 'THEME_IMAGES', THEME_URI . '/images' );
    		define( 'THEME_IMAGES_ASSETS', THEME_IMAGES . '/assets' );
    		define( 'THEME_JS', THEME_URI . '/lib/scripts' );
    		define( 'THEME_STYLES', THEME_URI . '/styles' );
    		define( 'THEME_SPRITES', THEME_STYLES . '/_sprites' );
    
    		define( 'THEME_ADMIN_FUNCTIONS', THEME_ADMIN . '/functions' );
    		define( 'THEME_ADMIN_CLASSES', THEME_ADMIN . '/classes');
    		define( 'THEME_ADMIN_OPTIONS', THEME_ADMIN . '/options');
    		define( 'THEME_ADMIN_ASSETS_URI', THEME_URI . '/lib/admin/assets' );
    	}
    
    	/**
    	 * Loads theme functions.
    	 *
    	 * @since 1.0
    	 */
    
    	function functions() {
    		require_once( THEME_DIR . '/activation.php' );
    		require_once( THEME_FUNCTIONS . '/hooks-actions.php' );
    		require_once( THEME_FUNCTIONS . '/context.php' );
    		require_once( THEME_FUNCTIONS . '/core.php' );
    		require_once( THEME_FUNCTIONS . '/theme.php' );
    		require_once( THEME_FUNCTIONS . '/sliders.php' );
    		require_once( THEME_FUNCTIONS . '/scripts.php' );
    		require_once( THEME_FUNCTIONS . '/image.php' );
    		require_once( THEME_FUNCTIONS . '/bookmarks.php' );
    		require_once( THEME_FUNCTIONS . '/hooks-actions.php' );
    		require_once( THEME_FUNCTIONS . '/compatibility.php' );
    	}
    
    	/**
    	 * Loads theme extensions.
    	 *
    	 * @since 1.0
    	 */
    	function extensions() {
    		require_once( THEME_EXTENSIONS . '/breadcrumbs-plus/breadcrumbs-plus.php' );
    	}
    
    	/**
    	 * Loads theme classes.
    	 *
    	 * @since 1.0
    	 */
    	function classes() {
    		require_once( THEME_CLASSES . '/twitter-api.php' );
    		require_once( THEME_CLASSES . '/contact.php' );
    		require_once( THEME_CLASSES . '/menu-walker.php' );
    		require_once( THEME_CLASSES . '/raw-shortcode.php' );
    	}
    
    	/**
    	 * Loads theme actions.
    	 *
    	 * @since 1.0
    	 */
    	function actions() {
    
    		# WordPress actions
    		add_action( 'init', 'mysite_is_mobile_device' );
    		add_action( 'init', 'mysite_is_responsive' );
    		add_action( 'init', 'mysite_shortcodes_init' );
    		add_action( 'init', 'mysite_menus' );
    		add_action( 'init', 'mysite_post_types'  );
    		add_action( 'init', 'mysite_register_script' );
    		add_action( 'init', 'mysite_wp_image_resize', 11 );
    		add_action( 'init', array( 'mysiteForm', 'init'), 11 );
    		add_action( 'widgets_init', 'mysite_sidebars' );
    		add_action( 'widgets_init', 'mysite_widgets' );
    		add_action( 'wp_head', 'mysite_seo_meta' );
    		add_action( 'wp_head', 'mysite_mobile_meta' );
    		add_action( 'wp_head', 'mysite_analytics' );
    		add_action( 'wp_head', 'mysite_custom_bg' );
    		add_action( 'wp_head', 'mysite_additional_headers', 99 );
    		add_action( 'wp_head', 'mysite_fitvids' );
    		add_action( 'template_redirect', 'mysite_enqueue_script' );
    		add_action( 'template_redirect', 'mysite_squeeze_page' );
    		add_action( 'comment_form_defaults', 'mysite_comment_form_args' );
    		remove_action( 'wp_head', 'rel_canonical' );
    
    		# Mysitemyway actions
    		add_action( 'mysite_head', 'mysite_header_scripts' );
    		add_action( 'mysite_before_header', 'mysite_fullscreen_bg' );
    		add_action( 'mysite_header', 'mysite_logo' );
    		add_action( 'mysite_header', 'mysite_header_extras' );;
    		add_action( 'mysite_header', 'mysite_primary_menu' );
    		add_action( 'mysite_header', 'mysite_responsive_menu' );
    		add_action( 'mysite_after_header', 'mysite_slider_module' );
    		add_action( 'mysite_after_header', 'mysite_teaser' );
    		add_action( 'mysite_before_page_content', 'mysite_breadcrumbs' );
    		add_action( 'mysite_before_page_content', 'mysite_home_content' );
    		add_action( 'mysite_before_page_content', 'mysite_page_content' );
    		add_action( 'mysite_before_page_content', 'mysite_page_title' );
    		add_action( 'mysite_before_page_content', 'mysite_query_posts' );
    		add_action( 'mysite_before_post', 'mysite_fancy_meta' );
    		add_action( 'mysite_before_post', 'mysite_post_image' );
    		add_action( 'mysite_before_entry', 'mysite_post_title' );
    		add_action( 'mysite_blog_before_entry', 'mysite_post_meta' );
    		add_action( 'mysite_singular-post_before_entry', 'mysite_post_meta' );
    		add_action( 'mysite_singular-portfolio_before_entry', 'mysite_portfolio_date' );
    		add_action( 'mysite_singular-page_before_entry', 'mysite_post_image' );
    		add_action( 'mysite_singular-post_after_entry', 'mysite_post_meta_bottom' );
    		add_action( 'mysite_singular-post_after_post', 'mysite_post_nav' );
    		add_action( 'mysite_singular-post_after_post', 'mysite_post_sociables' );
    		add_action( 'mysite_singular-post_after_post', 'mysite_like_module' );
    		add_action( 'mysite_singular-post_after_post', 'mysite_about_author' );
    		add_action( 'mysite_singular-portfolio_after_post', 'mysite_post_sociables' );
    		add_action( 'mysite_after_post', 'mysite_page_navi' );
    		add_action( 'mysite_after_main', 'mysite_get_sidebar' );
    		add_action( 'mysite_before_footer', 'mysite_footer_teaser' );
    		add_action( 'mysite_footer', 'mysite_main_footer' );
    		add_action( 'mysite_after_footer', 'mysite_sub_footer' );
    		add_action( 'mysite_body_end', 'mysite_print_cufon' );
    		add_action( 'mysite_body_end', 'mysite_image_preloading' );
    		add_action( 'mysite_body_end', 'mysite_ios_rotate' );
    		add_action( 'mysite_body_end', 'mysite_custom_javascript' );
    	}
    
    	/**
    	 * Loads theme filters.
    	 *
    	 * @since 1.0
    	 */
    
    function filters() {
    
    		# Mysitemyway filters
    		add_filter( 'mysite_author_avatar_size', create_function('','return "60";') );
    		add_filter( 'mysite_avatar_size', create_function('','return "60";') );
    		add_filter( 'mysite_date_format', create_function('','return __( "m-d-y" );') );
    		add_filter( 'mysite_read_more', 'mysite_read_more' );
    		add_filter( 'mysite_widget_meta', 'mysite_widget_meta' );
    
    		# WordPress filters
    		//remove_filter( 'the_content', 'wpautop' );
    		//remove_filter( 'the_content', 'wptexturize' );
    		//add_filter( 'the_content', 'mysite_formatter', 99 );
    		//add_filter( 'widget_text', 'mysite_formatter', 99 );
    
    		add_filter( 'the_content', 'mysite_texturize_shortcode_before' );
    		add_filter( 'the_content_more_link', 'mysite_full_read_more', 10, 2 );
    		add_filter( 'excerpt_length', 'mysite_excerpt_length_long', 999 );
    		add_filter( 'excerpt_more', 'mysite_excerpt_more' );
    		add_filter( 'posts_where', 'mysite_multi_tax_terms' );
    		add_filter( 'pre_get_posts', 'mysite_exclude_category_feed' );
    		add_filter( 'pre_get_posts', 'mysite_custom_search' );
    		add_filter( 'widget_categories_args', 'mysite_exclude_category_widget' );
    		add_filter( 'query_vars', 'mysite_queryvars' );
    		add_filter( 'rewrite_rules_array', 'mysite_rewrite_rules',10,2 );
    		add_filter( 'widget_text', 'do_shortcode' );
    		add_filter( 'wp_page_menu_args', 'mysite_page_menu_args' );
    		add_filter( 'the_password_form', 'mysite_password_form' );
    
    	}
    
    	/**
    	 * Loads theme supports.
    	 *
    	 * @since 1.0
    	 */
    	function supports() {
    		add_theme_support( 'menus' );
    		add_theme_support( 'widgets' );
    		add_theme_support( 'post-thumbnails' );
    		add_theme_support( 'automatic-feed-links' );
    	}
    
    	/**
    	 * Handles the locale functions file and translations.
    	 *
    	 * @since 1.0
    	 */
    	function locale() {
    		# Get the user's locale.
    		$locale = get_locale();
    
    		if( is_admin() ) {
    			# Load admin theme textdomain.
    			load_theme_textdomain( MYSITE_ADMIN_TEXTDOMAIN, THEME_ADMIN . '/languages' );
    			$locale_file = THEME_ADMIN . "/languages/$locale.php";
    
    		} else {
    			# Load theme textdomain.
    			load_theme_textdomain( MYSITE_TEXTDOMAIN, THEME_DIR . '/languages' );
    			$locale_file = THEME_DIR . "/languages/$locale.php";
    		}
    
    		if ( is_readable( $locale_file ) )
    			require_once( $locale_file );
    	}
    
    	/**
    	 * Loads admin files.
    	 *
    	 * @since 1.0
    	 */
    	function admin() {
    		if( !is_admin() ) return;
    
    		require_once( THEME_ADMIN . '/admin.php' );
    		mysiteAdmin::init();
    	}
    
    	/**
    	 * Define theme variables.
    	 *
    	 * @since 1.0
    	 */
    
    	function variables() {
    		global $mysite;
    
    		$layout = '';
    		$img_set = get_option( MYSITE_SETTINGS );
    		$img_set = ( !empty( $img_set ) && !isset( $_POST[MYSITE_SETTINGS]['reset'] ) ) ? $img_set : array();
    		$blog_layout = apply_filters( 'mysite_blog_layout', mysite_get_setting( 'blog_layout' ) );
    
    		# Images
    		$images = array(
    		    'one_column_portfolio' => array(
    		        ( !empty( $img_set['one_column_portfolio_full']['w'] ) ? $img_set['one_column_portfolio_full']['w'] : 908 ),
    		        ( !empty( $img_set['one_column_portfolio_full']['h'] ) ? $img_set['one_column_portfolio_full']['h'] : 563 )),
    		    'two_column_portfolio' => array(
    		        ( !empty( $img_set['two_column_portfolio_full']['w'] ) ? $img_set['two_column_portfolio_full']['w'] : 429 ),
    		        ( !empty( $img_set['two_column_portfolio_full']['h'] ) ? $img_set['two_column_portfolio_full']['h'] : 266 )),
    		    'three_column_portfolio' => array(
    		        ( !empty( $img_set['three_column_portfolio_full']['w'] ) ? $img_set['three_column_portfolio_full']['w'] : 270 ),
    		        ( !empty( $img_set['three_column_portfolio_full']['h'] ) ? $img_set['three_column_portfolio_full']['h'] : 167 )),
    		    'four_column_portfolio' => array(
    		        ( !empty( $img_set['four_column_portfolio_full']['w'] ) ? $img_set['four_column_portfolio_full']['w'] : 190 ),
    		        ( !empty( $img_set['four_column_portfolio_full']['h'] ) ? $img_set['four_column_portfolio_full']['h'] : 118 )),
    
    		    'one_column_blog' => array(
    		        ( !empty( $img_set['one_column_blog_full']['w'] ) ? $img_set['one_column_blog_full']['w'] : 908 ),
    		        ( !empty( $img_set['one_column_blog_full']['h'] ) ? $img_set['one_column_blog_full']['h'] : 349 )),
    		    'two_column_blog' => array(
    		        ( !empty( $img_set['two_column_blog_full']['w'] ) ? $img_set['two_column_blog_full']['w'] : 429 ),
    		        ( !empty( $img_set['two_column_blog_full']['h'] ) ? $img_set['two_column_blog_full']['h'] : 165 )),
    		    'three_column_blog' => array(
    		        ( !empty( $img_set['three_column_blog_full']['w'] ) ? $img_set['three_column_blog_full']['w'] : 270 ),
    		        ( !empty( $img_set['three_column_blog_full']['h'] ) ? $img_set['three_column_blog_full']['h'] : 103 )),
    		    'four_column_blog' => array(
    		        ( !empty( $img_set['four_column_blog_full']['w'] ) ? $img_set['four_column_blog_full']['w'] : 190 ),
    		        ( !empty( $img_set['four_column_blog_full']['h'] ) ? $img_set['four_column_blog_full']['h'] : 73 )),
    
    		    'small_post_list' => array(
    		        ( !empty( $img_set['small_post_list_full']['w'] ) ? $img_set['small_post_list_full']['w'] : 50 ),
    		        ( !empty( $img_set['small_post_list_full']['h'] ) ? $img_set['small_post_list_full']['h'] : 50 )),
    		    'medium_post_list' => array(
    		        ( !empty( $img_set['medium_post_list_full']['w'] ) ? $img_set['medium_post_list_full']['w'] : 200 ),
    		        ( !empty( $img_set['medium_post_list_full']['h'] ) ? $img_set['medium_post_list_full']['h'] : 200 )),
    		    'large_post_list' => array(
    		        ( !empty( $img_set['large_post_list_full']['w'] ) ? $img_set['large_post_list_full']['w'] : 589 ),
    		        ( !empty( $img_set['large_post_list_full']['h'] ) ? $img_set['large_post_list_full']['h'] : 365 )),
    
    		    'portfolio_single_full' => array(
    		        ( !empty( $img_set['portfolio_single_full_full']['w'] ) ? $img_set['portfolio_single_full_full']['w'] : 980 ),
    		        ( !empty( $img_set['portfolio_single_full_full']['h'] ) ? $img_set['portfolio_single_full_full']['h'] : 600 )),
    		    'additional_posts_grid' => array(
    		        ( !empty( $img_set['additional_posts_grid_full']['w'] ) ? $img_set['additional_posts_grid_full']['w'] : 190 ),
    		        ( !empty( $img_set['additional_posts_grid_full']['h'] ) ? $img_set['additional_posts_grid_full']['h'] : 118 )),
    
    		);
    
    		$big_sidebar_images = array(
    		    'one_column_portfolio' => array(
    		        ( !empty( $img_set['one_column_portfolio_big']['w'] ) ? $img_set['one_column_portfolio_big']['w'] : 588 ),
    		        ( !empty( $img_set['one_column_portfolio_big']['h'] ) ? $img_set['one_column_portfolio_big']['h'] : 365 )),
    		    'two_column_portfolio' => array(
    		        ( !empty( $img_set['two_column_portfolio_big']['w'] ) ? $img_set['two_column_portfolio_big']['w'] : 276 ),
    		        ( !empty( $img_set['two_column_portfolio_big']['h'] ) ? $img_set['two_column_portfolio_big']['h'] : 171 )),
    		    'three_column_portfolio' => array(
    		        ( !empty( $img_set['three_column_portfolio_big']['w'] ) ? $img_set['three_column_portfolio_big']['w'] : 172 ),
    		        ( !empty( $img_set['three_column_portfolio_big']['h'] ) ? $img_set['three_column_portfolio_big']['h'] : 106 )),
    		    'four_column_portfolio' => array(
    		        ( !empty( $img_set['four_column_portfolio_big']['w'] ) ? $img_set['four_column_portfolio_big']['w'] : 120 ),
    		        ( !empty( $img_set['four_column_portfolio_big']['h'] ) ? $img_set['four_column_portfolio_big']['h'] : 74 )),
    
    		    'one_column_blog' => array(
    		        ( !empty( $img_set['one_column_blog_big']['w'] ) ? $img_set['one_column_blog_big']['w'] : 588 ),
    		        ( !empty( $img_set['one_column_blog_big']['h'] ) ? $img_set['one_column_blog_big']['h'] : 226 )),
    		    'two_column_blog' => array(
    		        ( !empty( $img_set['two_column_blog_big']['w'] ) ? $img_set['two_column_blog_big']['w'] : 276 ),
    		        ( !empty( $img_set['two_column_blog_big']['h'] ) ? $img_set['two_column_blog_big']['h'] : 106 )),
    		    'three_column_blog' => array(
    		        ( !empty( $img_set['three_column_blog_big']['w'] ) ? $img_set['three_column_blog_big']['w'] : 172 ),
    		        ( !empty( $img_set['three_column_blog_big']['h'] ) ? $img_set['three_column_blog_big']['h'] : 66 )),
    		    'four_column_blog' => array(
    		        ( !empty( $img_set['four_column_blog_big']['w'] ) ? $img_set['four_column_blog_big']['w'] : 120 ),
    		        ( !empty( $img_set['four_column_blog_big']['h'] ) ? $img_set['four_column_blog_big']['h'] : 46 )),
    
    		    'small_post_list' => array(
    		        ( !empty( $img_set['small_post_list_big']['w'] ) ? $img_set['small_post_list_big']['w'] : 50 ),
    		        ( !empty( $img_set['small_post_list_big']['h'] ) ? $img_set['small_post_list_big']['h'] : 50 )),
    		    'medium_post_list' => array(
    		        ( !empty( $img_set['medium_post_list_big']['w'] ) ? $img_set['medium_post_list_big']['w'] : 200 ),
    		        ( !empty( $img_set['medium_post_list_big']['h'] ) ? $img_set['medium_post_list_big']['h'] : 200 )),
    		    'large_post_list' => array(
    		        ( !empty( $img_set['large_post_list_big']['w'] ) ? $img_set['large_post_list_big']['w'] : 380 ),
    		        ( !empty( $img_set['large_post_list_big']['h'] ) ? $img_set['large_post_list_big']['h'] : 236 )),
    
    		    'portfolio_single_full' => array(
    		        ( !empty( $img_set['portfolio_single_full_big']['w'] ) ? $img_set['portfolio_single_full_big']['w'] : 588 ),
    		        ( !empty( $img_set['portfolio_single_full_big']['h'] ) ? $img_set['portfolio_single_full_big']['h'] : 365 )),
    		    'additional_posts_grid' => array(
    		        ( !empty( $img_set['additional_posts_grid_big']['w'] ) ? $img_set['additional_posts_grid_big']['w'] : 120 ),
    		        ( !empty( $img_set['additional_posts_grid_big']['h'] ) ? $img_set['additional_posts_grid_big']['h'] : 74 )),
    
    		);
    
    		$small_sidebar_images = array(
    		    'one_column_portfolio' => array(
    		        ( !empty( $img_set['one_column_portfolio_small']['w'] ) ? $img_set['one_column_portfolio_small']['w'] : 638 ),
    		        ( !empty( $img_set['one_column_portfolio_small']['h'] ) ? $img_set['one_column_portfolio_small']['h'] : 396 )),
    		    'two_column_portfolio' => array(
    		        ( !empty( $img_set['two_column_portfolio_small']['w'] ) ? $img_set['two_column_portfolio_small']['w'] : 300 ),
    		        ( !empty( $img_set['two_column_portfolio_small']['h'] ) ? $img_set['two_column_portfolio_small']['h'] : 186 )),
    		    'three_column_portfolio' => array(
    		        ( !empty( $img_set['three_column_portfolio_small']['w'] ) ? $img_set['three_column_portfolio_small']['w'] : 187 ),
    		        ( !empty( $img_set['three_column_portfolio_small']['h'] ) ? $img_set['three_column_portfolio_small']['h'] : 116 )),
    		    'four_column_portfolio' => array(
    		        ( !empty( $img_set['four_column_portfolio_small']['w'] ) ? $img_set['four_column_portfolio_small']['w'] : 131 ),
    		        ( !empty( $img_set['four_column_portfolio_small']['h'] ) ? $img_set['four_column_portfolio_small']['h'] : 81 )),
    
    		    'one_column_blog' => array(
    		        ( !empty( $img_set['one_column_blog_small']['w'] ) ? $img_set['one_column_blog_small']['w'] : 638 ),
    		        ( !empty( $img_set['one_column_blog_small']['h'] ) ? $img_set['one_column_blog_small']['h'] : 245 )),
    		    'two_column_blog' => array(
    		        ( !empty( $img_set['two_column_blog_small']['w'] ) ? $img_set['two_column_blog_small']['w'] : 300 ),
    		        ( !empty( $img_set['two_column_blog_small']['h'] ) ? $img_set['two_column_blog_small']['h'] : 115 )),
    		    'three_column_blog' => array(
    		        ( !empty( $img_set['three_column_blog_small']['w'] ) ? $img_set['three_column_blog_small']['w'] : 187 ),
    		        ( !empty( $img_set['three_column_blog_small']['h'] ) ? $img_set['three_column_blog_small']['h'] : 71 )),
    		    'four_column_blog' => array(
    		        ( !empty( $img_set['four_column_blog_small']['w'] ) ? $img_set['four_column_blog_small']['w'] : 131 ),
    		        ( !empty( $img_set['four_column_blog_small']['h'] ) ? $img_set['four_column_blog_small']['h'] : 50 )),
    
    		    'small_post_list' => array(
    		        ( !empty( $img_set['small_post_list_small']['w'] ) ? $img_set['small_post_list_small']['w'] : 50 ),
    		        ( !empty( $img_set['small_post_list_small']['h'] ) ? $img_set['small_post_list_small']['h'] : 50 )),
    		    'medium_post_list' => array(
    		        ( !empty( $img_set['medium_post_list_small']['w'] ) ? $img_set['medium_post_list_small']['w'] : 200 ),
    		        ( !empty( $img_set['medium_post_list_small']['h'] ) ? $img_set['medium_post_list_small']['h'] : 200 )),
    		    'large_post_list' => array(
    		        ( !empty( $img_set['large_post_list_small']['w'] ) ? $img_set['large_post_list_small']['w'] : 412 ),
    		        ( !empty( $img_set['large_post_list_small']['h'] ) ? $img_set['large_post_list_small']['h'] : 255 )),
    
    		    'portfolio_single_full' => array(
    		        ( !empty( $img_set['portfolio_single_full_small']['w'] ) ? $img_set['portfolio_single_full_small']['w'] : 638 ),
    		        ( !empty( $img_set['portfolio_single_full_small']['h'] ) ? $img_set['portfolio_single_full_small']['h'] : 396 )),
    		    'additional_posts_grid' => array(
    		        ( !empty( $img_set['additional_posts_grid_small']['w'] ) ? $img_set['additional_posts_grid_small']['w'] : 131 ),
    		        ( !empty( $img_set['additional_posts_grid_small']['h'] ) ? $img_set['additional_posts_grid_small']['h'] : 81 )),
    
    		);
    
    		$additional_images = array(
    		    'image_banner_intro' => array(
    		        ( !empty( $img_set['image_banner_intro_full']['w'] ) ? $img_set['image_banner_intro_full']['w'] : 980 ),
    		        ( !empty( $img_set['image_banner_intro_full']['h'] ) ? $img_set['image_banner_intro_full']['h'] : 360 )),
    		);
    
    		# Slider
    		$images_slider = array(
    			'responsive_slide' => array( 980, 360 ),
    			'floating_slide' => array( 920, 300 ),
    			'staged_slide' => array( 920, 300 ),
    			'partial_staged_slide' => array( 532, 300 ),
    			'partial_gradient_slide' => array( 580, 360 ),
    			'overlay_slide' => array( 980, 360 ),
    			'full_slide' => array( 980, 360 ),
    			'nivo_slide' => array( 980, 360 ),
    			'nav_thumbs' => array( 45, 35 )
    		);
    
    		foreach( $images as $key => $value ) {
    			foreach( $value as $img => $size ) {
    				$size = str_replace( ' ', '', $size );
    				$new_size[$img] = str_replace( 'px', '', $size );
    			}
    			$images[$key] = $new_size;
    		}
    
    		foreach( $big_sidebar_images as $key => $value ) {
    			foreach( $value as $img => $size ) {
    				$size = str_replace( ' ', '', $size );
    				$new_size[$img] = str_replace( 'px', '', $size );
    			}
    			$big_sidebar_images[$key] = $new_size;
    		}
    
    		foreach( $small_sidebar_images as $key => $value ) {
    			foreach( $value as $img => $size ) {
    				$size = str_replace( ' ', '', $size );
    				$new_size[$img] = str_replace( 'px', '', $size );
    			}
    			$small_sidebar_images[$key] = $new_size;
    		}
    
    		foreach( $additional_images as $key => $value ) {
    			foreach( $value as $img => $size ) {
    				$size = str_replace( ' ', '', $size );
    				$new_size[$img] = str_replace( 'px', '', $size );
    			}
    			$additional_images[$key] = $new_size;
    		}
    
    		# Blog layouts
    		switch( $blog_layout ) {
    			case "blog_layout1":
    				$layout = array(
    					'blog_layout' => $blog_layout,
    					'main_class' => 'post_grid blog_layout1',
    					'post_class' => 'post_grid_module',
    					'content_class' => 'post_grid_content',
    					'img_class' => 'post_grid_image'
    				);
    				break;
    			case "blog_layout2":
    				$layout = array(
    					'blog_layout' => $blog_layout,
    					'main_class' => 'post_list blog_layout2',
    					'post_class' => 'post_list_module',
    					'content_class' => 'post_list_content',
    					'img_class' => 'post_list_image'
    				);
    				break;
    			case "blog_layout3":
    				$columns_num = 2;
    				$featured = 1;
    				$columns = ( $columns_num == 2 ? 'one_half'
    				: ( $columns_num == 3 ? 'one_third'
    				: ( $columns_num == 4 ? 'one_fourth'
    				: ( $columns_num == 5 ? 'one_fifth'
    				: ( $columns_num == 6 ? 'one_sixth'
    				: ''
    				)))));
    
    				$layout = array(
    					'blog_layout' => $blog_layout,
    					'main_class' => 'post_grid blog_layout3',
    					'post_class' => 'post_grid_module',
    					'content_class' => 'post_grid_content',
    					'img_class' => 'post_grid_image',
    					'columns_num' => ( !empty( $columns_num ) ? $columns_num : '' ),
    					'featured' => ( !empty( $featured ) ? $featured : '' ),
    					'columns' => ( !empty( $columns ) ? $columns : '' )
    				);
    				break;
    		}
    
    		$mysite->layout['blog'] = $layout;
    		$mysite->layout['images'] = array_merge( $images, array( 'image_padding' => 12 ) );
    		$mysite->layout['big_sidebar_images'] = $big_sidebar_images;
    		$mysite->layout['small_sidebar_images'] = $small_sidebar_images;
    		$mysite->layout['additional_images'] = $additional_images;
    		$mysite->layout['images_slider'] = $images_slider;
    	}
    
    }
    
    /**
     * Functions & Pluggable functions specific to theme.
     *
     * @package Mysitemyway
     * @subpackage Echelon
     */
    
    if ( !function_exists( 'mysite_post_meta' ) ) :
    /**
     *
     */
    function mysite_post_meta( $args = array() ) {
    	$defaults = array(
    		'shortcode' => false,
    		'echo' => true
    	);
    
    	$args = wp_parse_args( $args, $defaults );
    
    	extract( $args );
    
    	if( is_page() && !$shortcode ) return;
    	if( !empty( $shortcode ) && strpos( $disable, 'meta' ) !== false ) return;
    
    	$out = '';
    	$meta_options = mysite_get_setting( 'disable_meta_options' );
    	$_meta = ( is_array( $meta_options ) ) ? $meta_options : array();
    	$meta_output = '';
    
    	if( !in_array( 'date_meta', $_meta ) )
    		$meta_output .= '[post_date text="" after=" <em>|</em>"] ';
    
    	if( !in_array( 'comments_meta', $_meta ) )
    		$meta_output .= '[post_comments after=" <em>|</em>"] ';
    
    	if( !in_array( 'author_meta', $_meta ) )
    		$meta_output .= '[post_author text=""] ';
    
    	if( !empty( $meta_output ) )
    		$out .='<p class="post_meta">' . $meta_output . '</p>';
    
    	if( $echo )
    		echo apply_atomic_shortcode( 'post_meta', $out );
    	else
    		return apply_atomic_shortcode( 'post_meta', $out );
    }
    endif;
    
    if ( !function_exists( 'mysite_fancy_meta' ) ) :
    /**
     *
     */
    function mysite_fancy_meta( $args = array() ) {
    	$defaults = array(
    		'echo' => true
    	);
    
    	$args = wp_parse_args( $args, $defaults );
    
    	extract( $args );
    
    	if( is_page() && !$shortcode ) return;
    	if( !empty( $type ) && $type == 'blog_grid' && $column == 4 ) return;
    	if( !empty( $type ) && $type == 'blog_list' && $thumb == 'small' ) return;
    	if( is_singular( 'portfolio' ) ) return;
    
    	$meta_options = mysite_get_setting( 'disable_meta_options' );
    	$_meta = ( is_array( $meta_options ) ) ? $meta_options : array();
    	if( in_array( 'date_meta', $_meta ) ) return;
    
    	$post_id = get_the_ID();
    	$post_thumbnail_id = get_post_thumbnail_id( $post_id );
    	$auto_img = mysite_get_setting( 'auto_img' );
    
    	if ( ( empty( $post_thumbnail_id ) ) && ( $auto_img[0] ) ) {
    		$attachments = get_children(array(
    			'post_parent' => $post_id,
    			'post_status' => 'inherit',
    			'post_type' => 'attachment',
    			'post_mime_type' => 'image',
    			'order' => 'ASC',
    			'orderby' => 'menu_order ID',
    			'numberposts' => 1
    		));
    
    		if( !$attachments ) return;
    	}
    
    	$out = '<div class="fancy_meta" style="display:none;">';
    	$out .= '[post_date text="" format="M"] [post_date text="" format="d"]';
    	$out .= '</div>';
    
    	if( $echo )
    		echo apply_atomic_shortcode( 'fancy_meta', $out );
    	else
    		return apply_atomic_shortcode( 'fancy_meta', $out );
    }
    endif;
    
    if ( !function_exists( 'mysite_before_post_sc' ) ) :
    /**
     *
     */
    function mysite_before_post_sc( $filter_args ) {
    	$out = '';
    
    	if( strpos( $filter_args['disable'], 'meta' ) === false )
    		$out .= mysite_fancy_meta( $filter_args );
    
    	if( strpos( $filter_args['disable'], 'image' ) === false )
    		$out .= mysite_get_post_image( $filter_args );
    
    	if( strpos( $filter_args['disable'], 'title' ) === false )
    		$out .= mysite_post_title( $filter_args );
    
    	return $out;
    }
    endif;
    
    if ( !function_exists( 'mysite_widget_meta' ) ) :
    /**
     *
     */
    function mysite_widget_meta() {
    	return do_shortcode( '[post_date text=""]' );
    }
    endif;
    
    if ( !function_exists( 'mysite_image_preloading' ) ) :
    /**
     *
     */
    function mysite_image_preloading() {
    	global $mysite;
    
    	if( isset( $mysite->mobile ) )
    		return;
    
    	$out = "
    	<script type=\"text/javascript\">
    	/* <![CDATA[ */
    
    	jQuery( '#main_inner' ).preloader({ imgSelector: '.blog_index_image_load span img', imgAppend: '.blog_index_image_load', oneachload: function(image) { jQuery(image).parent().parent().parent().prev().css('display','block'); } });
    
    	jQuery( '.one_column_portfolio' ).preloader({ imgSelector: '.portfolio_img_load span img', imgAppend: '.portfolio_img_load' });
    	jQuery( '.two_column_portfolio' ).preloader({ imgSelector: '.portfolio_img_load span img', imgAppend: '.portfolio_img_load' });
    	jQuery( '.three_column_portfolio' ).preloader({ imgSelector: '.portfolio_img_load span img', imgAppend: '.portfolio_img_load' });
    	jQuery( '.four_column_portfolio' ).preloader({ imgSelector: '.portfolio_img_load span img', imgAppend: '.portfolio_img_load' });
    
    	jQuery( '.portfolio_gallery.large_post_list' ).preloader({ imgSelector: '.portfolio_img_load span img', imgAppend: '.portfolio_img_load' });
    	jQuery( '.portfolio_gallery.medium_post_list' ).preloader({ imgSelector: '.portfolio_img_load span img', imgAppend: '.portfolio_img_load' });
    	jQuery( '.portfolio_gallery.small_post_list' ).preloader({ imgSelector: '.portfolio_img_load span img', imgAppend: '.portfolio_img_load' });
    
    	jQuery( '#main_inner' ).preloader({ imgSelector: '.portfolio_full_image span img', imgAppend: '.portfolio_full_image' });
    	jQuery( '#main_inner' ).preloader({ imgSelector: '.blog_sc_image_load span img', imgAppend: '.blog_sc_image_load', oneachload: function(image) { jQuery(image).parent().parent().parent().prev().css('display','block'); } });
    	jQuery( '#main_inner, #sidebar_inner' ).preloader({ imgSelector: '.fancy_image_load span img', imgAppend: '.fancy_image_load', oneachload: function(image){
    			var imageCaption = jQuery(image).parent().parent().next();
    			if(imageCaption.length>0){
    				imageCaption.remove();
    				jQuery(image).parent().addClass('has_caption_frame');
    				jQuery(image).parent().append(imageCaption);
    				jQuery(image).next().css('display','block');
    			}
    		}
    	});
    	jQuery( '#intro_inner' ).preloader({ imgSelector: '.fancy_image_load span img', imgAppend: '.fancy_image_load', oneachload: function(image){
    			var imageCaption = jQuery(image).parent().parent().next();
    			if(imageCaption.length>0){
    				imageCaption.remove();
    				jQuery(image).parent().addClass('has_caption_frame');
    				jQuery(image).parent().append(imageCaption);
    				jQuery(image).next().css('display','block');
    			}
    		}
    	});
    
    	function mysite_jcarousel_setup(c) {
    		c.clip.parent().parent().parent().parent().parent().removeClass('noscript');
    		var jcarousel_img_load = c.clip.children().children().find('.post_grid_image .portfolio_img_load');
    		if( jcarousel_img_load.length>1 ) {
    			jcarousel_img_load.each(function(i) {
    				var filename = jQuery(this).attr('href'),
    					videos=['swf','youtube','vimeo','mov'];
    				for(var v in videos){
    				    if(filename.match(videos[v])){
    						jQuery(this).css('backgroundImage','url(' +assetsUri+ '/play.png)');
    					}else{
    						jQuery(this).css('backgroundImage','url(' +assetsUri+ '/zoom.png)');
    					}
    				}
    
    			});
    		}
    	}
    
    	/* ]]> */
    	</script>";
    
    	echo preg_replace( "/(\r\n|\r|\n)\s*/i", '', $out );
    }
    endif;
    
    ?>
  • Hoang Ngo

    Hi @Karsten Christrup,

    I hope you are well today and I'm sorry about the delay.

    If the functions.php not work due to different theme struct, can you please use the mu-plugins instead?

    Basically, there are 2 step:
    1. Create a folder "mu-plugins" inside "wp-content".
    2. Save my script to a php file, example remove_utube_link_header.php, and upload the file to mu-plugins folder.

    This will auto activate the code.

    Best Regards,
    Hoang

  • Hoang Ngo

    Hi @Karsten Christrup,

    Hmm, I've done some another test on my lab and it still work for me.

    I will need some access to your site to have a closer look, can you please send in:

    - Mark to my attention - ATTN: Hoang Ngo
    - Link back to this thread
    - Include admin/network access
    - Include cPanel (I will need to look at the DB so need PHPMyAdmin or similar)
    - Include FTP
    - Include any relevant URLS for your site

    On the contact form, select "I have a different question", this ensures it comes through and gets assigned to me.

    Best Regards,
    Hoang

  • Karsten Christrup

    Hi Hoang,

    I´m sorry to bother you, but could I perhaps convince you to do your magic once more? - I´ve had to rebuild my site after I accidentally removed the entire site folder, when I tried to remove your FTP-access via EHCP (which by the way didn´t inform me that it also erases the folder - talk about learning the hard way :grinning:.

    What was worse though, was that my hosting provider had misconfigured the EHCP backup to not include subfolders. leaving me with only the DB left of my site :slight_frown: --> and this also meant that any modification you did earlier has been erased.

    Hope you can help me out once more - and sorry about the inconvenience.

    Best Regards
    Karsten

  • Hoang Ngo

    Hi @Karsten Christrup,

    I hope you are well today and I'm sorry about your issue :slight_frown:.

    Sure, here you go:

    add_filter( 'autoblog_pre_post_insert', 'remove_youtube_url_in_title', 40, 2 );
    add_filter( 'autoblog_pre_post_update', 'remove_youtube_url_in_title', 40, 2 );
    function remove_youtube_url_in_title( $data, $details ) {
    	$feeds_exclude = array(
    		'facebook',
    		'your feed title'
    	);
    	if ( in_array( strtolower( $details['title'] ), $feeds_exclude ) ) {
    		$title = htmlspecialchars_decode( $data['post_title'] );
    		$title = html_entity_decode( $title );
    		$title = str_replace( array( 'http', 'https' ), ' http', $title );
    		$mark  = true;
    		while ( $mark ) {
    			foreach ( explode( ' ', $title ) as $val ) {
    				if ( stristr( $val, 'http' ) ) {
    					$data['post_title'] = trim( str_replace( $val, '', $data['post_title'] ) );
    				}
    			}
    			if ( stristr( $data['post_title'], 'http' ) ) {
    				$title = $data['post_title'];
    			} else {
    				$mark = false;
    			}
    		}
    	}
    
    	return $data;
    }

    Please add this code to your theme functions.php or use mu-plugins

    If you have any issues please don't hesitate to let us know so we can assist

    Best Regards,
    Hoang

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.