WordPress.org

Ready to get started?Download WordPress

Forums

AppStore Links
[resolved] Add another REGEXP(?) (3 posts)

  1. THEPNTR
    Member
    Posted 3 years ago #

    Hello!

    I need some help. I want to add another method to post link to appstore beside than [app ##idnumber##]. I'm pretty new to PHP so I'm if there is a easy way to do it?

    I've found the som clues on the way like:

    define("APPSTORELINKS_REGEXP", "/\[app (<a href="http://codex.wordpress.org/:print:">:print:</a>+)\]/");
    define("APPSTORELINKS_REGEXP_2", "/\[applink (<a href="http://codex.wordpress.org/:print:">:print:</a>+)\]/");

    (I tried to add so I could use [applink XXXXXX])

    that lead me to this:

    function AppStoreLinks_plugin($content)
    {
    	return (preg_replace_callback(APPSTORELINKS_REGEXP, 'AppStoreLinks_plugin_callback', $content));
    	return (preg_replace_callback(APPSTORELINKS_LINK, 'AppStoreLinks_plugin_callback', $content));
    }

    If I add preg_replace_callback(APPSTORELINKS_REGEXP_2... last it won't load. But if I put it before the original lines it will load the not the original lines. So I tried to create a new function but I couldn't get that to work either.

    The solution I use now is that I've dublicated the plugin and just changed the REGEXP to make a new link and the $output value. But I don't feel that it's the option to go with.

  2. THEPNTR
    Member
    Posted 3 years ago #

    I found the solution myself

    I created a new function like:

    function AppStoreLinks_plugin2($content)
    {
    	return (preg_replace_callback(APPSTORELINKS_REGEXP2, 'AppStoreLinks_plugin_callback2', $content));
    	return (preg_replace_callback(APPSTORELINKS_LINK, 'AppStoreLinks_plugin_callback2', $content));
    }

    then I added a new filter:
    add_filter('the_content', 'AppStoreLinks_plugin2');

    then I created a new AppStoreLinks_plugin_callback function namned AppStoreLinks_plugin_callback2. And just edited that out so there would be another $outbput.

    Please tell me if this is totally wrong. I'm pretty new to this like I mentioned earlier. :)

  3. Ste-Bi
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks - helped me in adding new features to the plugin ;-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags