When echoing my own shortcode, it keeps adding a 1 at the end of my blogpost

Question

I am currently building my own plugin and testing things around, to make sure everything works.
I used register_settings() to create a form on my backend, I filled it with information and have no problem of retrieving the information. Inside my post edit, I write [ItemList], my shortcode, and this is what I get in my frontend.
enter image description here

At the end, you can see a 1. Kind of looks like pagination, but it’s not. When I inspected the one, it’s just a text frament. Then I wote several shortcodes into my editor ([ItemList][ItemList][ItemList][ItemList]), and then I get this:
enter image description here

Again, several 1s! This time they’re all in the same p tag. I have NO idea, where those 1s are coming from.

Here is my layout PHP file:

<?php

$title = get_option( "set_title" );
$icon = get_option( "choose_icon" );
$desc = get_option( "set_description" );

?>

<ul>
<li><?php echo $icon; ?></li>
</ul>

<div>
  <div>
    <span>
    <?php echo $icon; ?>
    </span>
    <span>
    <?php echo $title; ?>
    </span>
  </div>
  <div>
    <p>
    <?php echo $desc; ?>
    </p>
  </div>
</div>

Even when I create a new Post or Page and added the shortcode, same result. When I delete the shortcode and write some text, no 1. Anyone got any idea why this is happening?

The Shortcode Code:

<?php
/**
 * @package XXXXX
 */

 namespace IncAPI;

 use IncBaseBaseController;

/*
Basecontroller declares the plugin_path variable.
$this->plugin_path = plugin_dir_path( dirname( __FILE__, 2 ) );
it directions to the root dir.
*/

 class ShortcodeList extends BaseController {

   public function listLayout() {
    return require( $this->plugin_path . "/admin/itemList.php" );
  }

  public function register() {
    add_shortcode( "ItemList", array( $this, "listLayout") );
  }
 }
0
Mahnenwolf 8 months 2020-11-23T07:10:23-05:00 0 Answers 14 views 0

Leave an answer

Browse
Browse