WordPress.org

Ready to get started?Download WordPress

Forums

Shortcode Exec PHP
Need help adapting a snippet to work with plugin (6 posts)

  1. Prometheus Fire
    Member
    Posted 2 years ago #

    I'm trying to adapt this code snippet to work with this plugin.

    I've removed all the php tags and html, but I keep getting various errors that I don't understand how to fix (I'm not a coder...)

    I've been able to get other snippets to work, just not this one.

    <?php if($multi_site_on == "true"){
    if( function_exists('get_sitestats')) { ?>
    <div class="site-stats"><span><?php _e("Currently powering",TEMPLATE_DOMAIN); ?> <?php
    $stats = get_sitestats();
    $tmp_user_count = number_format ($stats[ 'users' ] );
    $tmp_blog_count = number_format ($stats[ 'blogs' ] );
    print "<strong>" . $tmp_blog_count . " Sites" . "</strong>";
    ;?></span></div>
    <?php } } ?>

    Any idea how to edit that?

    Incidentally, it is for a WPMU site and displays the current number of blogs on the network.

  2. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    Try replacing

    if($multi_site_on == "true"){

    by

    if (is_multisite()) {

  3. Prometheus Fire
    Member
    Posted 2 years ago #

    I'm not sure that is the problem, the errors I keep getting when I test it revolved around "unexpected brackets, $ends, or < signs. Basically, syntax errors based on the needs of the plugin itself. The code works, but just doesn't seem to input into the plugin very well.

  4. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    The <?php at the begin and ?> at the end should be removed probably ...

  5. Prometheus Fire
    Member
    Posted 2 years ago #

    did that, but there is also a bunch of them in the middle that cause problems, took those out too and then I started getting "unexpected }" errors.

    I'm hoping that somebody with php knowledge and the plugin can drop this snippet into theirs and test it.

  6. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    This is in any case syntactically correct:

    if ($multi_site_on == "true") {
    if (function_exists('get_sitestats')) {
    echo '<div class="site-stats"><span>';
    _e("Currently powering",TEMPLATE_DOMAIN);
    $stats = get_sitestats();
    $tmp_user_count = number_format($stats['users']);
    $tmp_blog_count = number_format($stats['blogs']);
    echo '' . $tmp_blog_count . ' Sites' . '';
    echo '</span></div>';
    }
    }

    But not tested functionally.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic