WordPress.org

Ready to get started?Download WordPress

Forums

Create plugin with hook (5 posts)

  1. cruelladeville
    Member
    Posted 7 years ago #

    I strive with the Simple Tagging plugin, and tries to experiment with making things appear in my post form. So - I created this tiny plugin, which only function is to write something to my post-form page, but nothing happens.

    My code:

    <?php
    /*
    Plugin Name: my plugin test
    Plugin URI:
    Description: blablabla
    Version: 1.3
    Author: Siv
    Author URI:
    */
    
    add_filter('simple_edit_form', 'srh_print_dill');
    function srh_print_dill(){
    	print "this should be displayed below my post form";
    }
    
    ?>

    I found a do_action('simple_edit_form','') in my edit_post.php file (in admin folder), but I really don't understand what this means. When I read the codex all the examples are generic, and I'm not able to find an explanation of simple_edit_form nor do_action().

    If anyone has a good idea I'll be overlykkelig! (norwegian for very, very, very, ....., very happy)

  2. Lester Chan
    Member
    Posted 7 years ago #

    use

    add_action('simple_edit_form', 'srh_print_dill');
  3. cruelladeville
    Member
    Posted 7 years ago #

    Thanks, but that made no different. But I refactorated the plugin and now I'm able to print the word "ushj" where the form should be, but the form it self does not appear.
    I can print out strings right 'till the form starts, but then it stops.

     print "tralalala";
    print '<div id="lptagstuff" class="sta-group">            <fieldset class="sta-box" id="posttags">
    <h3 class="sta-handle">'
    . __('Tags (comma separated list)') . '</h3>
    <div class="sta-content">
    <input class="wickEnabled" name="tag_list" id="stp_tag_entry" value="' . $post_tags . '" />
    					<input type="hidden" name="simpletaggingverifykey" id="simpletaggingverifykey" value="' . wp_create_nonce('simpletagging') . '" />' . '
    					<script type="text/javascript" language="JavaScript">'
    . $ta_result . '</script>
    					<script type="text/javascript" language="JavaScript" src="' . $this->sTagObj->info['install_url'] . '/simpletagging.type-ahead.js"></script>
    <div id="stp_taglist">
    <h4>' . (($opt['dsp_suggested']) ? 'Suggested Tags' :
    'Tags') . ':</h4>
    <p>' . $result_tags_str . '</p>
    <div id="clearer">&nbsp;</div>
    </div>
    </div>
    </fieldset>
    </div>';

    The "tralala" gets printed, the following not. What is this????

  4. csautot
    Member
    Posted 6 years ago #

    Maybe you shouldn't use multiple print statements and do something like:

    PHP heredoc notation:

    add_filter('simple_edit_form', 'srh_print_dill');
    
    function srh_print_dill()
    {
       echo <<<EOHTML
    
          this should be displayed below my post form
    
          some more text on another line
    
    EOHTML;
    }

    OR

    add_filter('simple_edit_form', 'srh_print_dill');
    
    function srh_print_dill()
    {
       ?>
          this should be displayed below my post form
    
          some more text on another line
       <?php
    }
  5. csautot
    Member
    Posted 6 years ago #

    Another thing to watch for that is mentioned in this forum post:

    http://wordpress.org/support/topic/51631

    is that if you want your added XHTML to show up when you have gone to Manage > Posts or Manage > Pages, you need to use the edit_form_advanced hook as well.

Topic Closed

This topic has been closed to new replies.

About this Topic