XF 2.1 Widget HTML

Jonathan Long

Active member
In the manual it says the HTML widget won’t fetch any data. What is the best work-around?

I have a WordPress/XenForo bridge and I’m trying to put an HTML widget from the WordPress part of the site onto the forum widget. As of now, simply copy/pasting the HTML code results in styling issues.

Any simple solutions/addons that will help?
 
Hi,

I would be also interested to display a Worpress widget in a Xenforo widget. Two separate installations. I have no bridge.

Does anybody know how to do that?
 
Basically, you need to get the scripts and html code without the Wordpress CSS classes (or rename them making sure you don't create conflicts with existing XF classes). You'll also want the Wordpress styling (CSS) so you can convert/add that for XF. Then it's a matter of tweaking. :)
 
Download the plugin from Wordpress.org instead of using the "install new plugin from Dashboard" method.

That will contain all the files you need and then you work from there.
 
Ok, I want to display the widget of a WP plugin in the widget of Xnforo. I looke via FTP on the files of that plugin (a review plugin) and found there a directoy "widget" and inside of that a file for "default".

THis is the code:

Code:
<?php
/**
 * Default Widget Layout for front end.
 *
 * @package     WPPR
 * @subpackage  Layouts
 * @copyright   Copyright (c) 2017, Bogdan Preda
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       3.0.0
 */

?>
<ul>
<?php
foreach ( $results as $review ) :
    $review_object         = new WPPR_Review_Model( $review['ID'] );
    // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
    $product_title_display = ( $instance['post_type'] == true ) ? $review_object->get_name() : get_the_title( $review['ID'] );
    $product_image         = $review_object->get_small_thumbnail();

    if ( strlen( $product_title_display ) > $title_length ) {
        $product_title_display = substr( $product_title_display, 0, $title_length ) . '...';
    }
    ?>
    <li class="cwp-popular-review">

    <?php
    $wppr_image = false;
    // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
    if ( $instance['show_image'] == true && ! empty( $product_image ) ) {
        ?>
        <div class="cwp_rev_image wppr-col">
            <img src="<?php echo $product_image; ?>"
             alt="<?php echo $review_object->get_name(); ?>">
        </div>
        <?php
        $wppr_image = true;
    }
    ?>

    <div class="wppr-post-title wppr-col<?php echo ( $wppr_image ) ? '' : ' wppr-no-image'; ?>">
        <a href="<?php echo get_the_permalink( $review['ID'] ); ?>" class="wppr-col" title="<?php echo $review_object->get_name(); ?>">
            <?php echo $product_title_display; ?>
        </a>
    </div>

    <?php
    $review_score = $review_object->get_rating();
    $rating = round( $review_score );
    $rating_10  = round( $review_score, 0 ) / 10;

    $review_class = $review_object->get_rating_class();
    if ( ! empty( $review_score ) ) {
        ?>
        <?php wppr_layout_get_rating( $review_object, 'donut', 'style1-widget', array( 'review-grade-widget wppr-col' ) ); ?>

    <?php } ?>
    </li>
        <?php
    endforeach;
?>
</ul>
 
Looking at one file won't help you if it calls functions from outside the file or core WP funcions. That one file also won't contain any stylinmg or external scripts.
 
Top Bottom