Forum Replies Created

Viewing 15 replies - 1 through 15 (of 22 total)
  • @aledesousa this solution worked brilliantly, thanks!

    Plugin Author thomtels

    (@totels)

    I would not recommend putting the code in the google-analytics-post-pageviews.php plugin file, you will lose that change when the plugin is updated. Create a new plugin of your own for this.

    Plugin Author thomtels

    (@totels)

    Fixed in latest patch. Thanks! ??

    Plugin Author thomtels

    (@totels)

    Was just doing some updates and noticed you made this change. Thanks! Looks like I didn’t get back here fast enough to reply. I’d gladly help out if you’re looking for looking for additional coding. I have a few ideas for features and improvements as well.

    Plugin Author thomtels

    (@totels)

    @dashnorth the latest update still doesn’t save to the DB, everything is saved in transients. I created a custom plugin and added an action hook to remedy this for longer-term persistent caching. Flushing our object cache means all of the post pageviews get dumped and then we end up with all the problems again.

    add_action( 'setted_transient', function ( $name, $value, $expiration ) {
        // intercept gapp setting transient value, as long as it's not zero, and
        // add to the post meta for fallback value when gapp fails
        if ( false !== strpos( $name, 'gapp-transient-' ) and 0 !== intval( $value ) ) {
            preg_match( '/gapp-transient-(\d+)/', $name, $matches );
            update_post_meta( (int) $matches[1], 'analytics-pageviews', $value );
        }
    }, 10, 3 );

    This will create a “forever” cache of the latest non-zero result from google-analytics-post-pageviews in the postmeta table. You’ll want to add some logic to your template or elsewhere to adjust the output to use the postmeta value where necessary.

    e.g.:

    if ( function_exists( 'gapp_get_post_pageviews' ) ) {
      $views = intval( gapp_get_post_pageviews( null, false );
      if ( 0 === $views ) {
        $views = intval( get_post_custom_values( 'analytics-pageviews', get_the_ID() )[0] );
      }
    
      // use $views here to output the number of pageviews in the template
    }

    But realistically this isn’t going to help you stop hitting the concurrent connections limit, there’s nothing in the plugin that will do that, doesn’t matter what you set the cache timeout to, if 11 people visit your site in less than 1 sec it’s going to lock up and you’ll have to reauthenticate. I have written some custom code for that as well. Let me know if you’d like to see it.

    I still haven’t solved having the google auth data in the external object cache being dumped whenever we flush the cache and forcing us to reauthenticate. But at least the latest counts don’t get lost and our pages at least look like they’re supposed to.

    Plugin Author thomtels

    (@totels)

    Having similar issues.

    Line 270 and 271 should be using $wpdb->options instead of hard-coding in wp_options as the table name (at the very least). This is also a pretty unreliable manner of deleting transients, hence the transients API having a delete_transient function. Any decently trafficked site is going to be using some sort of caching mechanism and transients will rightly be stored using wp_cache_set rather than the options API. It shouldn’t be assumed that any transient will ever make it to the options table.

    As for hitting API limits, it would be nice if there were some request backoff built in, as with above, any decently busy site is going to hit request limits quite quickly. I’ve been having to reauthenticate about every 3-6 hours due to Quota Error: profileId ga:NNNNNNNN has too many concurrent connections. messages.

    In theory you can put Javascript in the field for the “Host ga.js locally” option, but there’s a bug in the way google-analytics-for-wordpress saves it’s options, it’s not correctly stripping slashes added by magic quotes, but this can be fixed without editing class-frontend.php. I have this working, as in, it’s printing usable code for GA and correctly inserting the script, but due to some of the output from the Yoast plugin (extra “‘” and “;”) it doesn’t yet Validate with Analytics.

    I created a plugin to filter the ga4wp options: https://gist.github.com/tbartels/7580798

    if ( class_exists( "GA_Admin" ) ) {
        global $ga_admin;
    
        function fix_ga4wp_slashes( $new, $old="" ) {
            return stripslashes_deep( $new );
        }
    
        add_filter( "pre_update_option_{$ga_admin->optionname}",
                "fix_ga4wp_slashes", 10, 2 );
    }

    Which makes it possible to paste in the right-hand side of the “ga.src” but you have to compensate for the quotes in the ga4wp plugin. As I said, this outputs usable code, my headers are correctly including the dc.js script, but the tracking code validation doesn’t seem to parse it correctly.

    Having this same issue on a shared-host provider, getting them to bump the PHP memory limit fixed the problem. I believe the issue stems from the use of wp_dropdown_users in wordpress-seo/admin/pages/metas.php. Our subscriber list is over 20k users and rendering that dropdown is pretty inefficient. For the time being I altered line 93 of the metas.php file:

    diff --git a/wp-content/plugins/wordpress-seo/admin/pages/metas.php b/wp-content/plugins/wordpress-seo/admin/pages/metas.php
    index 95782dd..f4e2605 100644
    --- a/wp-content/plugins/wordpress-seo/admin/pages/metas.php
    +++ b/wp-content/plugins/wordpress-seo/admin/pages/metas.php
    @@ -90,7 +90,7 @@ if ( ( isset( $_GET[ 'updated' ] ) && $_GET[ 'updated' ] == 'true' ) || ( isset(
    
     	echo '<h2>' . __( 'Author metadata', 'wordpress-seo' ) . '</h2>';
     	echo '<label class="select" for="">' . __( 'Author highlighting', 'wordpress-seo' ) . ':</label>';
    -	wp_dropdown_users( array( 'show_option_none' => "Don't show", 'name' => 'wpseo_titles[plus-author]', 'class' => 'select', 'selected' => isset( $options[ 'plus-author' ] ) ? $options[ 'plus-author' ] : '' ) );
    +	wp_dropdown_users( array( 'who' => 'authors', 'show_option_none' => "Don't show", 'name' => 'wpseo_titles[plus-author]', 'class' => 'select', 'selected' => isset( $options[ 'plus-author' ] ) ? $options[ 'plus-author' ] : '' ) );
     	echo '<p class="desc label">' . __( 'Choose the user that should be used for the <code>rel="author"</code> on the blog homepage. Make sure the user has filled out his/her Google+ profile link on their profile page.', 'wordpress-seo' ) . '</p>';
     	echo $wpseo_admin_pages->textinput( 'plus-publisher', __( 'Google Publisher Page', 'wordpress-seo' ) );
     	echo '<p class="desc label">' . __( 'If you have a Google+ page for your business, add that URL here and link it on your Google+ page\'s about page.', 'wordpress-seo' ) . '</p>';

    Basically just adding the 'who' => 'authors' option to the wp_dropdown_users args.

    Thread Starter thomtels

    (@totels)

    I have noticed that there is a fix for this in the works, but the last update was over 6 months ago and has not been migrated to the WP SVN yet: https://github.com/canha42/pinterest-pin-it/tree/1.1-nightly perhaps once 1.1 goes live I can change my rating.

    I realize you haven’t updated the code in a while (almost a full year now) but I think the concept is a good one, especially for image-heavy sites. Django has sorl-thumbnail and a few libs built off sorl that do similar things (https://github.com/SmileyChris/easy-thumbnails).

    I looked around on github/bitbucket but didn’t find any repos that might be yours. If you were open to it there might be some interest in having a public repo where others can contribute and possibly bring something like this up to production standards.

    WordPress will not automatically create the images that are “missing”. I believe the default action is to fall back to the first image it can use that is closest in size. So if the only image available is the original image, that is what will be served. If you are correctly using the WordPress media functions (wp_get_attachment_image(), the_post_thumbnail(), etc.) then the <img> tag should be correctly output with a height/width to scale the full-size image, but you would still be loading the full-size image.

    There are a handful of thumbnail regen scripts around. I have used https://www.ads-software.com/extend/plugins/regenerate-thumbnails/ with some success, but depending on the size of your image archive you may need something different.

    Thread Starter thomtels

    (@totels)

    That only barely works for CSS, simplemodal-login themes are comprised of images and JS as well

    If you can’t call it from a document ready it’s possibly something else not loading at all. I find that my best friend is console.log(<data>).

    For this particular problem though, you should be able to just open up a browser console and use it directly to see if things are loaded as you expect. It’s also possible you don’t have jQuery mapped to $ correctly.

    (function($) {
        $('.simplemodel-login').trigger('click');
    })(jQuery);

    might be a better test.

    $('.simplemodal-login').click()
    $('.simplemodal-login').trigger('click')
    $('.simplemodal-login').trigger('click.simplemodal-login')

    All work for me, you may have a context issue if you are trying to call it from someplace where jQuery or SimpleModal are not yet loaded.

    I wasn’t satisfied with editing the simplemodal-login core files so instead I am using an add_action hook in my theme functions.php, you could create a plugin as well.

    in functions.php:

    function theme_login_form() {
        global $action;
        $action = 'login';
    }
    add_action('login_form', 'theme_login_form', 1);

    Luckily the add_action in SFC – Login uses the default priority (Function_Reference/add_action) so we can inject our own add_action hook to run before it and set up the var it is looking for.

Viewing 15 replies - 1 through 15 (of 22 total)