Support » Themes and Templates » rong parameter count for preg_replace()

  • I am receiving the following error just below the header on my newly updated wordpress sliding door theme. I am using the most current version of wordpress and sliding door. Any thoughts on how to remove this error code from website http://www.burnsville-realtor.com/

    error code:

    Warning: Wrong parameter count for preg_replace() in /home/jasondai/public_html/burnsvillerealtor/wp-content/themes/sliding-door/functions.php on line 59

    Thanks.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Post your functions.php file here, you have a syntax error that we may be able to catch.

    Thread Starter thumbuddy

    (@thumbuddy)

    <?php
    if ( function_exists('register_sidebar') )
    register_sidebar(array('name'=>'sidebar1',
    ));
    register_sidebar(array('name'=>'sidebar2',
    ));
    
    class Elixir
    	{
    		function timesince(){
    
    			global $post;
    
    			$older_date = abs(strtotime($post->post_date_gmt . " GMT"));
    			$newer_date = time();
    
    			$chunks = array(
    			array(60 * 60 * 24 * 365 , 'year'),
    			array(60 * 60 * 24 * 30 , 'month'),
    			array(60 * 60 * 24 * 7, 'week'),
    			array(60 * 60 * 24 , 'day'),
    			array(60 * 60 , 'hour'),
    			array(60 , 'minute'),
    			);
    
    			$newer_date = ($newer_date == false) ? (time()+(60*60*get_settings("gmt_offset"))) : $newer_date;
    
    			$since = $newer_date - $older_date;
    
    			for ($i = 0, $j = count($chunks); $i < $j; $i++) {
    				$seconds = $chunks[$i][0];
    				$name = $chunks[$i][1];
    
    				if (($count = floor($since / $seconds)) != 0) {
    					break;
    				}
    			}
    
    			$output = ($count == 1) ? '1 '.$name : "$count {$name}s";
    
    			if ($i + 1 < $j) {
    				$seconds2 = $chunks[$i + 1][0];
    				$name2 = $chunks[$i + 1][1];
    
    				if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) {
    					$output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
    				}
    			}
    
    			echo $output;
    		}
    	}
    
    $elixir = new Elixir();
    
    function slider_menuparse($input) {
    $output =  preg_replace("'page-item-\d+'", 'page-item-11', $input, -1, $count);
    $number�=�0;
    
    if ($count < 6)
    echo '<!-- THESE AR ETHE LINKS YOU GO TO WHEN YOU CLICK ON A SLIDING DOOR IMAGE-->
    				<!-- change the href to look like this: <a href="yourlink.com">     -->
    				<li class="bk1"><a href="http://mac-host.com/install.html">About</a></li>
    				<li class="bk2"><a href="http://mac-host.com/install.html">Weddings</a></li>
    				<li class="bk3"><a href="http://mac-host.com/support">Places</a></li>
    				<li class="bk4"><a href="http://mac-host.com/install.html">Food</a></li>
    				<li class="bk5"><a href="http://dubbo.org">People</a></li>
    				<li class="bk6"><a href="http://macintoshhowto.com">Nature</a></li>
    				<li class="bk7"><a href="http://7.barracks.cl">Architecture</a></li>
    			';
    else {
    for ( $counter = $count+1; $counter <= 7; $counter += 1) {
    	$output = $output.'<li class="page_item bk'.($counter).'"><a href="" title=""></a></li>';
    }
    for ( $counter = 1; $counter <= $count; $counter += 1) {
    	$output = preg_replace("'page-item-11'", 'bk'.sprintf($counter,u), $output, 1, $count2);
    }
    echo $output;
    }
    
    }
    
    /*
    The followign is the page links to plugin incorportated into this theme.
    Plugin URI: http://txfx.net/code/wordpress/page-links-to/
    Version: 1.5
    Author: Mark Jaquith
    Author URI: http://coveredwebservices.com/
    */
    
    /*  Copyright 2005-2008  Mark Jaquith (email: mark.gpl@txfx.net)
    
        This program is free software; you can redistribute it and/or modify
        it under the terms of the GNU General Public License as published by
        the Free Software Foundation; either version 2 of the License, or
        (at your option) any later version.
    
        This program is distributed in the hope that it will be useful,
        but WITHOUT ANY WARRANTY; without even the implied warranty of
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        GNU General Public License for more details.
    
        You should have received a copy of the GNU General Public License
        along with this program; if not, write to the Free Software
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    */
    
    function txfx_get_page_links_to_meta () {
    	global $wpdb, $page_links_to_cache;
    
    	if ( !isset( $page_links_to_cache ) ) {
    		$links_to = $wpdb->get_results(
    		"SELECT post_id, meta_value " .
    		"FROM $wpdb->postmeta, $wpdb->posts " .
    		"WHERE post_id = ID AND meta_key = 'links_to' AND (post_status = 'static' OR post_status = 'publish')");
    	} else {
    		return $page_links_to_cache;
    	}
    
    	if ( !$links_to ) {
    		$page_links_to_cache = false;
    		return false;
    	}
    
    	foreach ( (array) $links_to as $link ) {
    		$page_links_to_cache[$link->post_id] = $link->meta_value;
    	}
    
    	return $page_links_to_cache;
    }
    
    function txfx_get_page_links_to_targets () {
    	global $wpdb, $page_links_to_target_cache;
    
    	if ( !isset( $page_links_to_target_cache ) ) {
    		$links_to = $wpdb->get_results(
    		"SELECT post_id, meta_value " .
    		"FROM $wpdb->postmeta, $wpdb->posts " .
    		"WHERE post_id = ID AND meta_key = 'links_to_target' AND (post_status = 'static' OR post_status = 'publish')");
    	} else {
    		return $page_links_to_target_cache;
    	}
    
    	if ( !$links_to ) {
    		$page_links_to_target_cache = false;
    		return false;
    	}
    
    	foreach ( (array) $links_to as $link ) {
    		$page_links_to_target_cache[$link->post_id] = $link->meta_value;
    	}
    
    	return $page_links_to_target_cache;
    }
    
    function txfx_plt_add_meta_box( $page, $context ) {
    	if ( ( 'page' === $page || 'post' === $page ) && 'advanced' === $context )
    		add_meta_box('page-links-to', 'Page Links To', 'txfx_plt_meta_box', $page, 'advanced', 'low');
    }
    
    function txfx_plt_meta_box() {
    	global $post;
    
    	if ( get_post_meta( $post->ID, 'links_to', true) )
    		echo '<p>';
    		wp_nonce_field( 'txfx_plt', '_txfx_pl2_nonce', false, true );
    		echo '</p>';
    	?>
    	Point to this URL: <input name="txfx_links_to" type="text" size="65" id="txfx_links_to" value="<?php echo attribute_escape( get_post_meta( $post->ID, 'links_to', true) ); ?>" />
    	<?php
    }
    
    function txfx_plt_save_meta_box( $post_ID ) {
    	if ( wp_verify_nonce( $_REQUEST['_txfx_pl2_nonce'], 'txfx_plt' ) && isset( $_POST['txfx_links_to'] ) && strlen( $_POST['txfx_links_to'] ) > 7 )
    		update_post_meta( $post_ID, 'links_to', $_POST['txfx_links_to'] );
    	return $post_ID;
    }
    
    function txfx_filter_links_to_pages ($link, $post) {
    	$page_links_to_cache = txfx_get_page_links_to_meta();
    
    	// Really strange, but page_link gives us an ID and post_link gives us a post object
    	$id = ($post->ID) ? $post->ID : $post;
    
    	if ( $page_links_to_cache[$id] )
    		$link = $page_links_to_cache[$id];
    
    	return $link;
    }
    
    function txfx_redirect_links_to_pages() {
    	if ( !is_single() && !is_page() )
    		return;
    
    	global $wp_query;
    
    	$link = get_post_meta( $wp_query->post->ID, 'links_to', true );
    
    	if ( !$link )
    		return;
    
    	$redirect_type = get_post_meta( $wp_query->post->ID, 'links_to_type', true );
    
    	if ( $redirect_type && $redirect_type != '302' ) {
    		// Only supporting 301 and 302 for now.
    		// The others aren't widely supported or needed anyway
    		header( "HTTP/1.0 301 Moved Permanently" );
    		header( "Status: 301 Moved Permanently" );
    		header( "Location: $link" );
    		exit;
    	}
    
    	// If we got this far, it's a 302 redirect
    	header( "Status: 302 Moved Temporarily" );
    	wp_redirect( $link );
    	exit;
    }
    
    function txfx_page_links_to_highlight_tabs( $pages ) {
    	$page_links_to_cache = txfx_get_page_links_to_meta();
    	$page_links_to_target_cache = txfx_get_page_links_to_targets();
    
    	if ( !$page_links_to_cache && !$page_links_to_target_cache )
    		return $pages;
    
    	$this_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    	$targets = array();
    
    	foreach ( (array) $page_links_to_cache as $id => $page ) {
    		if ( $page_links_to_target_cache[$id] )
    			$targets[$page] = $page_links_to_target_cache[$id];
    
    		if ( str_replace( 'http://www.', 'http://', $this_url ) == str_replace( 'http://www.', 'http://', $page ) || ( is_home() && str_replace( 'http://www.', 'http://', trailingslashit( get_bloginfo( 'home' ) ) ) == str_replace( 'http://www.', 'http://', trailingslashit( $page ) ) ) ) {
    			$highlight = true;
    			$current_page = $page;
    		}
    	}
    
    	if ( count( $targets ) ) {
    		foreach ( $targets as  $p => $t ) {
    			$pages = str_replace( '<a href="' . $p . '" ', '<a href="' . $p . '" target="' . $t . '" ', $pages );
    		}
    	}
    
    	if ( $highlight ) {
    		$pages = str_replace( ' class="page_item current_page_item"', ' class="page_item"', $pages );
    		$pages = str_replace( '<li class="page_item"><a href="' . $current_page . '"', '<li class="page_item current_page_item"><a href="' . $current_page . '"', $pages );
    	}
    
    	return $pages;
    }
    
    add_filter( 'wp_list_pages',     'txfx_page_links_to_highlight_tabs' );
    add_action( 'template_redirect', 'txfx_redirect_links_to_pages'      );
    add_filter( 'page_link',         'txfx_filter_links_to_pages', 20, 2 );
    add_filter( 'post_link',         'txfx_filter_links_to_pages', 20, 2 );
    add_action( 'do_meta_boxes',     'txfx_plt_add_meta_box',      10, 2 );
    add_action( 'save_post',         'txfx_plt_save_meta_box'            );
    ?>
    Thread Starter thumbuddy

    (@thumbuddy)

    Any help on this?

    same issue here…haven’t found a solution yet but it appears innumerous themes….handy….

    Thread Starter thumbuddy

    (@thumbuddy)

    okay, thanks. I will go back to another theme.

    It’s because you need to have your server running php5 where the preg_replace function has an extra parameter. Any theme that uses the new parameter won’t work on PHP4.

    After many attempts with 1&1 hosting I was able to change to php5 and my theme is working correctly now. Thanks!!

    wayneconnor – You Rock! Using DoDaddy hosting, I activated PHP 5.x and the error message went away for me too. Brandon (GoDaddy phone Tech support rep) read YOUR post and that helped him to relay the solution to me while we were on the phone. THANK YOU!

    I am also getting the message:

    Wrong parameter count for preg_replace() in /homepages/24/d179645069/htdocs/wp-content/themes/sliding-door/functions.php on line 10

    Verified that web host is running PHP 5.0

    ‘<?php
    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(‘name’=>’sidebar1’,
    ));
    register_sidebar(array(‘name’=>’sidebar2’,
    ));

    function slider_menuparse($input) {
    $output = preg_replace(“‘page-item-\d+'”, ‘page-item-11’, $input, -1, $count);
    $numberÊ=Ê0;

    if ($count < 4)
    echo ‘<!– default links – these are not used if you have your own pages–>

    <li class=”bk1″>Teapots
    <li class=”bk2″>Bowls
    <li class=”bk3″>Serving Pieces
    <li class=”bk4″>Jars
    <li class=”bk5″>Mugs/Cups
    <li class=”bk6″>Creamer and Sugar sets
    <li class=”bk7″>Vases
    ‘;
    else {
    for ( $counter = $count+1; $counter <= 7; $counter += 1) {
    $output = $output.'<li class=”page_item bk’.($counter).'”>‘;
    }
    for ( $counter = 1; $counter <= $count; $counter += 1) {
    $output = preg_replace(“‘page-item-11′”, ‘bk’.sprintf($counter,u), $output, 1, $count2);
    }
    echo $output;
    }
    }

    // Let’s add the options page.
    add_action (‘admin_menu’, ‘sdthememenu’);

    function sdthememenu() {
    add_submenu_page(‘themes.php’, ‘Picture Perfect’, ‘Picture Perfect’, 5, ‘sd-submenu’, ‘menu’);
    }

    function menu() {
    load_plugin_textdomain(‘sdoptions’);
    //this begins the admin page
    ?>

    <div class=”wrap”>

    <h2><?php _e(‘Theme Note’); ?></h2>

    <h2><?php
    $plugins = get_option(‘active_plugins’);
    $required_plugin = ‘page-links-to/page-links-to.php’;
    if ( !in_array( $required_plugin , $plugins ) ) _e(‘Warning: The page-link-to plugin is NOT active.’);

    ?> </h2>

    </div>

    <div class=”wrap”>
    <p style=”text-align: center;”>This theme works best with the page-links-to plugin installed. You can install and activate it from the plugin’s page. Find out more about this plugin from this page.</p>
    </div>

    <?php } // this ends the admin page ?>’

    I have a work around fix for…

    Wrong parameter count for preg_replace()… wp-content/themes/sliding-door/functions.php on line 10

    I am running MYSQL 5 with 1and1.co.uk and was getting the error with sliding doors version 1.8.7… So I went to the author’s site and downloaded an older version of sliding doors (version 1.4) from http://mac-host.com/slidingdoor/ (Click on the download link under the welcome section on the page). I uploaded this into WordPress and the error went away.

    I would still like to use the latest verions of sliding doors but for now, this fix works for me.

    Try this new version!

    Try this version:

    http://mac-host.com/support/theme/slidingdoor.zip

    Thanks Wayne, the error has now gone with version 2.0!
    Some feedback for you: On the main page title, the tails of letters are cut off, this affects ‘g’ and ‘y’ for instance. Also is there any way to may the background black again?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘rong parameter count for preg_replace()’ is closed to new replies.