WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] connecting two plugins problem (2 posts)

  1. rcpkrc
    Member
    Posted 4 years ago #

    Hello, l have two plugins l am using in my wp. l want to connect them each other or make another plugin from two of them with some mods, but l couldnt..

    One: Title rewriter

    <?php
    /*
    Plugin Name: Luke's Default Post Title for WP&micro;
    Plugin URI: http://thunderlounge.com/wordpress/plugins/default-post-title.html
    Description: Set a default post title below, and forget about it.
    Author: Luke Poland
    Author URI: http://thunderlounge.com/
    Version: 1.0
    Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
    */
    
    if ( !defined('ABSPATH') ) {
    	die("I don't think so, Tim.");
    }
    
    /* -----     -----  USER EDIT AREA  -----     ----- */
    
    // Replace 'Untitled Post' inside the quotes below with your default post title.
    // If you muck it up, you should learn php. ;)
    $tl_default_title = "Untitled Post";
    
    function tl_KillBlankPosts($post_title) {
    	global $tl_default_title;
    	// Only touch post titles which are blank
    	if( !empty($post_title) ) {
    		return $post_title;
    	} else {
    		$post_title = $tl_default_title;
    		return $post_title;
    	}
    	unset($tl_default_title);
    }
    
    add_filter('title_save_pre', 'tl_KillBlankPosts');
    
    ?>

    Two: Post rewriter

    <?php
    
    $dic = array(
    " a.m. " => " antemeridian ",
    " Aachen " => " city ",
    );
    
    $url=ABSPATH."wp-content/plugins/rewriter/words.txt";
    
    $lines=file($url);
    
    $not_replace_list = " ";
    foreach ($lines as $line_num => $line) {
        $not_replace_list = $not_replace_list.$line." ";
    }
    
    function rewrite_text( $article, $case_sensitive=false ) {
    	global $dic;
    	global $not_replace_list;
    
    	$dorewrite=strpos($article,"<NOREWRITE>");
    	if($dorewrite>0)
    		{
    		$article=str_replace("<NOREWRITE>","",$article);
    		}
    	else
    	{
    
    		$artarray=$article;
    		 $step1 = array("(", ")", "[", "]", "?", ".", ",", "|", "\$", "*", "+", "^","{", "}");
    		 $artarray=str_replace($step1," ",$artarray);
    		 $artarray=str_replace("  "," ",$artarray);
    		$words_artarray = explode(" ",$artarray);
    
    		if (sizeof($words_artarray)>0)
    		{
    		for($i=0;$i<sizeof($words_artarray);$i++)
    			{
    			$to_be_replaced=$words_artarray[$i];
    			$to_be_replaced=str_replace(" ","",$to_be_replaced);
    
    			$ignore="no";
    			if($to_be_replaced!="")
    				{
    				$pos=strpos($not_replace_list, $to_be_replaced);
    				if($pos>0)
    					{
    					$ignore="yes";
    					}
    				}
    
    			$to_be_replaced=" ".$to_be_replaced." ";
    			$to_be_replaced_with=$dic[$to_be_replaced];
    			if(($to_be_replaced!="")&amp;&amp;($to_be_replaced!=" ")&amp;&amp;($to_be_replaced_with!="")&amp;&amp;($ignore=="no"))
    				{
    				$article = str_replace($to_be_replaced,$to_be_replaced_with,$article);
    				}
    			}
    		}
    	}
    	return $article;
    }
    
    function title($title)
    {
    $title=($title);
    return $title;
    }
    
    add_filter('the_content', 'rewrite_text', 2);
    add_filter('the_excerpt', 'rewrite_text', 2);
    add_filter('the_title', 'title');
    ?>

    My question is how can l make a plugin with these plugins that changes the titles of post each time with the keywords giwen in the plugin.

  2. mikejonessmith
    Member
    Posted 4 years ago #

    I was hoping someone would have answered you ... I love your idea... How are things going ... please try to contact me ...

    user name [at] gm...com

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags