Log in

View Full Version : Resolved Turn a function into a class



gilgimech
05-31-2012, 08:00 PM
I'm trying to turn this function into a reusable class.


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.


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?

kuau
06-01-2012, 12:39 AM
Could you please tell me how you changed the status of your thread to Resolved? Thanks.