INN / Google-Analytics-Popular-Posts

A WordPress plugin that uses Google Analytics data to determine the most popular posts on your site and display a list of popular posts via the included widget.
https://wordpress.org/plugins/ga-popular-posts/
23 stars 7 forks source link

Using Largo's of_get_option, which fails on non-Largo themes #43

Closed benlk closed 8 years ago

benlk commented 8 years ago

From #42:

[Sat Jun 25 12:33:50.728867 2016] [:error] [pid 29497] [client 24.126.82.26:62537] PHP Fatal error:  Call to a member function getName() on a non-object in /var/www/html/wp-content/plugins/ga-popular-posts/inc/analytic-bridge-blog-options.php on line 365

This appears to be because we're using a function included in Largo inside this plugin:

In AnalyticBridgePopularPostWidget::widget() https://github.com/INN/analytic-bridge/blob/7ef6cfd2ae93761279b9132bc53f3669c2f1640d/classes/AnalyticsPopularWidget.php#L49

    $posts_term = of_get_option( 'posts_term_plural', 'Posts' );

In AnalyticBridgePopularPostWidget::form() https://github.com/INN/analytic-bridge/blob/7ef6cfd2ae93761279b9132bc53f3669c2f1640d/classes/AnalyticsPopularWidget.php#L172

    $defaults = array(
        'title' => __('Recent ' . of_get_option( 'posts_term_plural', 'Posts' ), 'largo'),
        'num_posts' => 3,
        'olul' => 'ol',
        'thumbnail_display' => 'medium',
    );

That's why the widgets page is failing.

screen shot 2016-06-25 at 12 42 12 pm

benlk commented 8 years ago

Temporary solution here is to set it to a hardcoded value.

Long-term solution is to make that hardcoded value filterable, then put a filter in Largo that sets it to the of_get_option value.

benlk commented 8 years ago

Fixed in v0.1.1 .