Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Shortcode is not working

$
0
0

Replies: 0

Hello, my shortcode is not working where the code is in my custom plugin.

See the below code:

<?php
class Ajax_Activity {
  function __construct() {
    $this->cld_add_custom_shortcode();
  }
  public function cld_add_custom_shortcode(){
    add_shortcode('sc', [$this, 'cld_generate_form']);
  }
  public function cld_generate_form(){
    $form = '
      <form id="green_form" action="">
        field1:<br>
        <input type="text" name="field1" value="">
        <br>
        field2:<br>
        <input type="text" name="field2" value="">
        <br>
        <input type="submit" value="Submit">          
      </form>';
    return $form;
  }
}

Note: add_shortcode line is in a inner php file in my custom plugin.
I include this class by below way:

<?php 
class Admin_Classes_Loader {
  function __construct() {
    require_once CA_FEEDER_DIR_PATH . '/admin/Ajax_Activity.php';
    new Ajax_Activity(); 
  }
}

And this class loader is invoked in main plugin file.


Viewing all articles
Browse latest Browse all 59525

Trending Articles