Results 1 to 2 of 2

Thread: Turn a function into a class

  1. #1
    Join Date
    May 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Turn a function into a class

    I'm trying to turn this function into a reusable class.

    PHP Code:
    function more_jump_link($link) {
        
    $offset strpos($link'#more-');
        if (
    $offset) {
            
    $end strpos($link'"',$offset);
        }
        if (
    $end) {
            
    $link substr_replace($link''$offset$end-$offset);
        }
        return 
    $link;
    }
    add_filter('the_content_more_link''more_jump_link'); 
    This is what I have so far.

    PHP Code:
    class wp_more_jump_class {

        function 
    __construct() {
                
    $functions_array = array(
                
    $this->more_jump_link($link)
            );
            return 
    $functions_array;
        }


        public function 
    more_jump_link() {
            
    $offset strpos($link'#more-');
            if (
    $offset) {
                
    $end strpos($link'"',$offset);
            }
            if (
    $end) {
                
    $link substr_replace($link''$offset$end-$offset);
            }
            return 
    $link;
        }

      
        public function 
    action_filters (){
            
    add_filter('the_content_more_link'$this->more_jump_link);
        }
    }

    $call_wp_more_jump = new wp_more_jump_class();
    $call_wp_more_jump->more_jump_link(); 
    I don't know why this isn't working. Anyone have an idea on this?
    Last edited by gilgimech; 05-31-2012 at 10:14 PM.

  2. #2
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Could you please tell me how you changed the status of your thread to Resolved? Thanks.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •