Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Closed
cfoellmann opened this Issue Dec 19, 2012 · 20 comments

Comments

Projects
None yet
4 participants
Contributor

cfoellmann commented Dec 19, 2012

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

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.

Owner

fracek commented Dec 19, 2012

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

Owner

fracek commented Dec 19, 2012

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

Contributor

cfoellmann commented Dec 19, 2012

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.

Owner

fracek commented Dec 19, 2012

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

Contributor

cfoellmann commented Dec 19, 2012

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 👎

Owner

fracek commented Dec 19, 2012

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.

Contributor

cfoellmann commented Dec 19, 2012

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

Owner

fracek commented Dec 19, 2012

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

Contributor

cfoellmann commented Dec 19, 2012

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

Contributor

cfoellmann commented Dec 19, 2012

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

Owner

fracek commented Dec 19, 2012

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 Dec 20, 2012

Closed

meta links not working #24

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.

Contributor

cfoellmann commented Dec 20, 2012

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 commented Dec 30, 2012

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.

Contributor

cfoellmann commented Dec 30, 2012

@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 Dec 30, 2012

@cfoellmann cfoellmann reopened this Dec 30, 2012

mvied commented Dec 30, 2012

Is it deactivated on every site?

Contributor

cfoellmann commented Dec 30, 2012

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. 😞

Contributor

cfoellmann commented Dec 30, 2012

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

Owner

fracek commented Dec 30, 2012

Mystery solved then :neckbeard:

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

@fracek fracek closed this Dec 30, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment