ArnaudHocevar / ZPGoogleAnalytics

Google Analytics plugin for Zenphoto
1 stars 2 forks source link

Plugin is enabled, yet the checkbox isn't set #4

Open marcoskirsch opened 10 years ago

marcoskirsch commented 10 years ago
/zp-core/admin-plugins.php?page=plugins&tab=all&subpage=1 Shows a list of plugins including ZPGoogleAnalytics. It shows unchecked, even if I check it and apply. I know it's enabled though, because the Analytics snippet shows up in the gallery HTML, and it is also lists in the HTML comment for the gallery: Do you think this could be a problem in the plug in? Or in ZenPhoto itself? Thanks!
ArnaudHocevar commented 10 years ago

it might be related to an issue with the plugin filter set up.

Either take the latest master version, or change line 13 From

$plugin_is_filter = THEME_PLUGIN;

to

$plugin_is_filter = 5 | THEME_PLUGIN | ADMIN_PLUGIN;
marcoskirsch commented 10 years ago

I made the change, it made no difference:

// Changing as suggested by author: https://github.com/ArnaudHocevar/ZPGoogleAnalytics/issues/4 //$plugin_is_filter = THEME_PLUGIN; $plugin_is_filter = 5 | THEME_PLUGIN | ADMIN_PLUGIN;

ArnaudHocevar commented 10 years ago

I'm currently testing against 1.4.6 master, and the plugin shows the checked box in the administration panel. Which version are you using ?

Also do you have any output in the error log ? Did you refresh the plugin page of the administration panel ?

marcoskirsch commented 10 years ago

Which version are you using ? Zenphoto version 1.4.6 [bbddab7675]

Also do you have any output in the error log ? Enabling and disabling the plugin does not generate any entries in the log. I assume you refer to the log viewable under: /zp-core/admin-logs.php?page=logs&tab=setup

Did you refresh the plugin page of the administration panel ? Yep

Could this be related to me installing the plugin in the wrong place at first, and some setting being stored in the DB incorrectly?

ArnaudHocevar commented 10 years ago

It can be although I'm not sure where everything is stored if you install the plugin in zp-core/zp-extension.

If you want to remove everything related to the plugin setup from the database, run this on your ZP database (at your own risk !)

DELETE
    FROM `zp_options` 
    WHERE 
        `name` IN ('analyticsId','domainName','adminTracking','trackPageViews','theme_head','trackImageViews','theme_body_close','alwaysSendReferrer','trackPageLoadSampleRate','trackPageLoadSpeedSampleRate','anonymizeIp','forceSSL','trackDemographics','enhancedLink','zp_plugin_google_analytics')
    OR 
        `creator` = 'plugins/google_analytics.php'

Note that this snippet only applies if you are using master version up to 2338c5c3759c56f6400fb7c97adb0132435c5314 . I realized I did not prefix the property names for the plugin, causing potential collisions. Version be6560cd399345c34dd87bb086c96e152e35bee7 and later will address the issue (prefixed all properties with _zp_google_analytics__.

If you need to clean up the plugin data with the new properties, execute the following SQL

DELETE
    FROM `zp_options` 
    WHERE 
        `name` = 'zp_plugin_google_analytics'
    OR 
        `creator` = 'plugins/google_analytics.php'
    OR
        `name` LIKE 'zp_google_analytics%'

To migrate the properties to the new prefixed one, this should work:

UPDATE `zp_options`
    SET `name` = CONCAT('zp_google_analytics_',`name`)
    WHERE ( `name` IN ('analyticsId','domainName','adminTracking','trackPageViews','theme_head','trackImageViews','theme_body_close','alwaysSendReferrer','trackPageLoadSampleRate','trackPageLoadSpeedSampleRate','anonymizeIp','forceSSL','trackDemographics','enhancedLink')
        OR `creator` = 'plugins/google_analytics.php')
        AND `name` != 'zp_plugin_google_analytics'
acrylian commented 10 years ago

It can be although I'm not sure where everything is stored if you install the plugin in zp-core/zp-extension.

It is stored in the same place always if you use the standard options. I just quickly looked and your option handling seems not the standard way.

ArnaudHocevar commented 10 years ago

Oh really ? I simply improved the original plugin, maybe this one wasn't correct. What should be changed to follow the ZP standard?

acrylian commented 10 years ago

I have to admit I don't ever used or looked at the original plugin. I haven't looked that closely but it seems the options are wrapped into some other function logic. That might generate the same so might be okay. However it is not how we generally define options. You can look at the demo plugin here, it's pretty straight forward and maybe easier to find from defines or something: https://github.com/zenphoto/DevTools/blob/master/demo_plugin-and-theme/demo_plugin/zenphoto_demoplugin.php