Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

hook 'plugin_row_meta ' to add GitHub link to plugins page #12

Closed
cfoellmann opened this Issue · 20 comments

4 participants

@cfoellmann

@fracek I hope you can help me. I am one step away from a complete meltdown :imp:

This site seems to be the "main" reference for the hook: http://wpengineer.com/1295/meta-links-for-wordpress-plugins/

and I would like to implement this code example:

    function set_plugin_meta($links, $file) {
    $plugin = plugin_basename(__FILE__);
    // create link
    if ($file == $plugin) {
    return array_merge(
    $links,
    array( sprintf( '<a href="options-general.php?page=%s">%s</a>', $plugin, __('Settings') ) )
    );
    }
    return $links;
    }
    add_filter( 'plugin_row_meta', 'set_plugin_meta', 10, 2 );

I thought: Learning by doing. Lets get a little better at PHP - after trying and reading... nothing. OOP seems to be devils work for a non-programmer.

@fracek
Owner

I tried it and found 2 way to do it:

  • Add the set_plugin_meta function outside the class, then call add_filter like you did. (So add the snippet after the add_action('widgets_init', [...]); line)
  • Add set_plugin_meta as a class method, then add this add_filter('plugin_row_meta', array(&$this, 'set_plugin_meta'), 10, 2); in the __construct() method (a.k.a. the object constructor). The difference is array(&$this, 'set_plugin_meta'), this tells PHP to call the set_plugin_meta method of the $this object, that is the current object.

I'm a PHP newbie too so I may be wrong, but it worked :D

@fracek
Owner

If you want to see just the change this is the commit, I added a link to the issues page. 223e0f3

@cfoellmann

I am not sure what the problem is but it is not working for me. The first way exactly what I did and something is blocking it on my installation.
Your implementation is not working either.

@fracek
Owner

I don't know what it is, can you read the php logs on your system? They might help us.

@cfoellmann

No errors there. I even cranked up the log level to the max.
Nothing.
What WP version are you using? I am on 3.5

plugins

On other plugins its working :-1:

@fracek
Owner

After a bit of trial and error I noticed you need to activate the plugin to view the additional links with our plugin and "Wp-Piwik", somehow "WordPress HTTPS" displays it even when not active. I'm gonna investigate this.

@cfoellmann

The WordPress HTTPS code is here on GitHub: https://github.com/Mvied/wordpress-https
I can ask @Mvied . He is pretty nice, too. :-) (now he gets a notification)

He is using his own "framework" maybe that could help figure it out. https://github.com/Mvied/mvied

@fracek
Owner

BTW can you confirm that it works when you activate it? One thing less to worry about :smiley:

@cfoellmann

Yes, after activation it is displayed. But I do not think that is a good thing.

@cfoellmann

if you like, you can send me an IM address via email to foellmann@foe-services.de, ICQ, Facebook, Skype

@fracek
Owner

I'm leaving this issue open until we can display the links even if the plugin is not active.

@cfoellmann cfoellmann referenced this issue in picandocodigo/List-Category-Posts
Closed

meta links not working #24

@picandocodigo

Having this same issue as @cfoellmann commented on my plugin. Maybe this is on purpose? Perhaps it makes sense not to see the links if someone didn't activate the plugin. I deactivated other plugins on one of my blogs which also use meta links, and their links are not working either.

@cfoellmann

I dont know if you know https://github.com/Mvied/wordpress-https but maybe you can test it. It is providing meta links while deactivated

@mvied

I can't reliably get my plugin to show the meta links while deactivated. Are you using a multisite installation? On a multisite, if the plugin is enabled for any site, it seems to make the meta links show up.

@cfoellmann

@Mvied I have a WP 3.5 multisite and your plugin is displaying all the additional links in activated and deactivated state.

@cfoellmann cfoellmann closed this
@cfoellmann cfoellmann reopened this
@mvied

Is it deactivated on every site?

@cfoellmann

I did a complete deactivation and I now see that all of you are right. All meta links are only displayed when the plugin is activated. :disappointed:

@cfoellmann

It seems to be the case for all plugins. The hook might have this limitation.
Nothing about it on the WordPress Trac though

@fracek
Owner

Mystery solved then :neckbeard:

I'll close this issue because it's more a WP issue than mine.

@fracek fracek closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.