Forum Replies Created

Viewing 15 replies - 166 through 180 (of 259 total)
  • Forum: Plugins
    In reply to: [Gitium] wp-cli error
    Plugin Author Presslabs

    (@presslabs)

    Thanks Andrei for your feedback, we really appreciate it! We try to figure out what is going on here so we put an issue accordingly here https://github.com/PressLabs/gitium/issues/132

    Plugin Author Presslabs

    (@presslabs)

    Большое спасибо!

    I’m glad to hear this and hope will save a lot of time for a lot of people from WordPress community and not only.

    Forum: Plugins
    In reply to: [Toplytics] Post views
    Plugin Author Presslabs

    (@presslabs)

    Hi! Thank you for your interest in Toplytics. I am afraid we will close this thread here as we have answered your questions regarding our plugin, but if you have any further questions on Toplytics, please do not hesitate to contact us.

    Forum: Reviews
    In reply to: [Autover] Working perfect
    Plugin Author Presslabs

    (@presslabs)

    Hi there, we are happy to see that our work is useful and more than that makes other people life’s more happy ?? Thanks!

    Forum: Plugins
    In reply to: [Toplytics] Post views
    Plugin Author Presslabs

    (@presslabs)

    Try like this:

    
    if ( $toplytics_results ) {
                $k = 0;
                foreach ( $toplytics_results as $post_id => $post_views ) {
                    echo '
    
    Forum: Plugins
    In reply to: [Toplytics] Post views
    Plugin Author Presslabs

    (@presslabs)

    Dear Vicetias, the above code was just an example is not the solution, you must adjust it to fit your needs. I don’t guarantee that the example works with copy-paste. As you can see I add all the HTML code in order to show up how all things work together.

    Let me explain it a little:

    First you create a ‘div’ HTML element like in example(with an unique ID):
    <div id=”unique-id”></div>

    Second, after you created the ‘div’ HTML element, you have to load the JS code which will load the toplytics.json file.

    Third you have to compose your HTML code using ‘li’ HTML tags like in the example above.

    Notice:

    The CSS code of the ‘unique-id’ have to be built by you according with your entire HTML design.

    The reason I put it in index.php is just because it is the first template of the theme, you must put it in your template.

    Very important is to use JS code not PHP because if you use the PHP code you will break the cache system of your hosting and you will have problems on high traffic.

    About your example of PHP code and your problem with CSS, you have to add a ‘div’ HTML tag above your PHP code, with a unique id and then try to adjust the style for this id in style.css I don’t see any problem of adding your own style for PHP code?

    Another important thing is to understand that the widget used as WP let to be used(select Appearance->Widgets then drag and drop) the Toplytics Widget will have the default css from the active theme. If you want a custom CSS you must Inspect the HTML code resulted, find the widget-id and then add the custom CSS into style.css

    I hope this helped you. If you need more help let me know.
    Thanks

    • This reply was modified 8 years, 1 month ago by Presslabs.
    Forum: Plugins
    In reply to: [Toplytics] Post views
    Plugin Author Presslabs

    (@presslabs)

    Here is a simple example of using the toplytics JS code inside of the index.php template https://olarmarius.tk/

    <!DOCTYPE html><html><head><title>::</title><style>#widget {
      background-color: lime;
      width: 100%;
      height: 400px;
    }</style></head><body><div id="widget"></div> <script>function toplytics_get_data( args, callback ) {
        var xmlhttp;
        if ( window.XMLHttpRequest ) {
            xmlhttp = new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
        } else {
            xmlhttp = new ActiveXObject('Microsoft.XMLHTTP'); // code for IE6, IE5
        }
    
        xmlhttp.onreadystatechange = function() {
            if ( xmlhttp.readyState === 4 && xmlhttp.status === 200 ) {
                var toplytics_json_data = JSON.parse(xmlhttp.responseText);
                callback( args, toplytics_json_data );
            }
        };
        xmlhttp.open('GET', 'https://olarmarius.tk/toplytics.json/', true);
        xmlhttp.send();console.log('after xmlhttp.send();');
    }
    
    function toplytics_results( toplytics_args ) {console.log('here...');
        toplytics_get_data( toplytics_args, function( args, toplytics_json_data ) {console.log('toplytics_json_data...');
            var html    = '';
            var results = toplytics_json_data[args.period];
            var counter = 0;
            for ( var index in results ) {
                if ( results.hasOwnProperty( index ) ) {
                    var permalink = results[ index ].permalink;
                    var title     = results[ index ].title;
                    //var post_id   = results[ index ].post_id;
                    var views     = results[ index ].views;
                    counter++;
                    if ( counter > args.numberposts ) { break; }
    
                    var views_html = '';
                    if ( args.showviews ) {
                        views_html = '<span class="post-views">' + views + ' views</span>';
                    }
    
                    if ( permalink && title ) {
                        html = html + '<li><a href="' + permalink + '">' + title + '</a>&nbsp;' + views_html + '</li>';
                    }
                }
            }
            document.getElementById( args.widget_id ).innerHTML = '<ol>' + html + '</ol>';
        });
    }
    
    toplytics_args = {
    	'period' : 'month',
    	'numberposts' : 3,
    	'showviews' : true,
      'widget_id' : 'widget'
    }
    
    toplytics_results( toplytics_args );</script> </body></html>
    • This reply was modified 8 years, 1 month ago by Presslabs.
    • This reply was modified 8 years, 1 month ago by Presslabs.
    • This reply was modified 8 years, 1 month ago by Presslabs.
    Forum: Plugins
    In reply to: [Toplytics] Post views
    Plugin Author Presslabs

    (@presslabs)

    Hi Vicetias,

    In Toplytics the logic is different because the results https://tendencilandia.com/toplytics.json are only for the top posts therefore if you use the data from Toplytics in a template file you must be aware that not all posts will have the post views available so you must use an ‘if’ statement and sometimes (when the post is not in top) the post views will not be available in template. Anyway, if you still want to use Toplytics results for this, I strongly advise you to use only JS code(avoid using PHP) and this code will help you to get your post views as you wish https://github.com/PressLabs/toplytics/blob/master/toplytics/js/toplytics.js you just need to change it a little.

    If you want to use a better solution for your post views in template you can try this plugin (Google Analytics Post Pageviews)[https://www.ads-software.com/plugins/google-analytics-post-pageviews/] the logic of this plugin is exactly what you try to make in your theme.

    If you need more help just let me know.

    Thanks,

    Plugin Author Presslabs

    (@presslabs)

    I’m glad it’s all good now.

    Plugin Author Presslabs

    (@presslabs)

    How does it look the toplytics.json file? You can find it on the root of you site like this one https://sitename.domain/toplytics.json

    Plugin Author Presslabs

    (@presslabs)

    Well in this case, this is how it’s supposed to be. It is a delay, on the plugin side it is one hour, and on Google side it’s approx. the same, one hour.

    Plugin Author Presslabs

    (@presslabs)

    What do you mean exactly by “it takes a bit of time”?

    Plugin Author Presslabs

    (@presslabs)

    If you put the custom changes into a separate plugin you make updates more easy.

    All ranges are related to the current day, so you cand find something that fit this logic.

    The code seems correct, just make sure you put the CSS code on the same page where you put the template code.

    Plugin Author Presslabs

    (@presslabs)

    Create a new directory named ‘toplytics-allowed-post-types’ and then, inside of the dir. paste the code into a file named ‘toplytics-allowed-post-types.php’. Then archive it as zip and add it as a plugin or copy paste it via FTP inside of wp-content/plugins/ dir.

    Plugin Author Presslabs

    (@presslabs)

    It’s ok how you write the code, but a better way will be to use the filter properly like this:

    
    <?php
    /**
     * Plugin Name: Toplytics allowed post types
     * Description: Add the post type 'ajde_events' to Toplytics plugin.
     */
    
    add_filter( 'toplytics_allowed_post_types', 'toplytics_add_allowed_post_types' );
    function toplytics_add_allowed_post_types( $allowed_post_types ) {
    	if ( ! in_array( 'ajde_events', $allowed_post_types ) ) {
    		$allowed_post_types[] = 'ajde_events';
    	}
    	return $allowed_post_types;
    }
    

    You can try yo debug the code, by getting the correct post type (maybe it’s not the correct one). Try to use the plugin Debug Bar and Debug Bar Console in order to get the correct post type. Install those plugins view one event page and click the Debug option from the Admin Bar and see what post type is there.

    • This reply was modified 8 years, 2 months ago by Presslabs.
Viewing 15 replies - 166 through 180 (of 259 total)