1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

title rewriter exercises

Discussion in 'General Programming Chat' started by recep, Apr 30, 2009.

  1. recep

    recep Junior Member

    Joined:
    Dec 7, 2006
    Messages:
    111
    Likes Received:
    7
    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:
    <?php
    /*
    Plugin Name: Luke's Default Post Title for WPµ
    Plugin URI: [url]http://thunderlounge.com/wordpress/plugins/default-post-title.html[/url]
    Description: Set a default post title below, and forget about it.
    Author: Luke Poland
    Author URI: [url]http://thunderlounge.com/[/url]
    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:
    <?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!="")&&($to_be_replaced!=" ")&&($to_be_replaced_with!="")&&($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. recep

    recep Junior Member

    Joined:
    Dec 7, 2006
    Messages:
    111
    Likes Received:
    7
    no1 read my post yet?
     
  3. _Austin

    _Austin Junior Member

    Joined:
    Apr 9, 2009
    Messages:
    147
    Likes Received:
    39
    So you want the title of each post to match the keyword for that post? Or you want the title of each post to change every time the keywords to that post change?

    _Austin
     
  4. recep

    recep Junior Member

    Joined:
    Dec 7, 2006
    Messages:
    111
    Likes Received:
    7
    just one time when keywords matchs.. austin u are able to do this?
     
  5. _Austin

    _Austin Junior Member

    Joined:
    Apr 9, 2009
    Messages:
    147
    Likes Received:
    39
    After looking through the second script, it replaces multiple keyword right?

    If so how would you want these multiple keywords handled in the post title?


    _Austin
     
  6. recep

    recep Junior Member

    Joined:
    Dec 7, 2006
    Messages:
    111
    Likes Received:
    7
    if l was a coder, l would reply u man, l just want a help who is coder and who can understand how to run first script as 2nd one, 2nd one finds and replace with keywords so l want the first one as same but not in post content in titles..
     
  7. _Austin

    _Austin Junior Member

    Joined:
    Apr 9, 2009
    Messages:
    147
    Likes Received:
    39
    What I asked has nothing to do with being a coder. I am looking through the scripts and telling you how they function and asking what you want done if a certain thing happens. It's not that difficult.

    Do you want multiple keywords in the title or not?

    _Austin