Support » Plugin: RedFruits: PHP API for wordpress development » [Plugin: RedFruits: PHP API for wordpress development] any body can show how to use

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ok, pescadito01. Do you want to make a plugin with this funcionality?

    It’s possible making a shortcode. For example, the shortcode will show the form and It must save the data where you want.

    In few minutes I can show you a little example.

    Here is the solution. Steps:

    1. Create a folder called Pescadito in the plugins folder.
    2. Create a PHP file called Pescadito.php. This is the code:
    <?php
    /*

    Plugin Name: Pescadito

    Plugin URI: http://pescadito.com

    Description: pescadito example!!

    Author: RedFruits team

    Version: 1.0

    Author URI: http://redfruits.wordpress.com

    */
    if (!defined(‘REDFRUITS_PATH’)) define(‘REDFRUITS_PATH’, dirname(dirname(__FILE__)).’/redfruits/’);
    if (!defined(‘PESCADITO_PATH’)) define(‘PESCADITO_PATH’, dirname(__FILE__).’/’);
    if (!defined(‘ADMIN_RENDER’)) define(‘ADMIN_RENDER’, ‘ADWordpressRender’);
    if (!defined(‘resources_db_adapter’)) define(‘resources_db_adapter’, ‘wordpress’);

    require_once(REDFRUITS_PATH.’wp-extension/ADWPPlugin.class.php’);

    class Pescadito extends ADWPPlugin
    {
    function __construct()
    {
    parent::__construct();
    $this->addShortCode(‘pescadito’, PESCADITO_PATH.’shortcodes/PescaditoSC.class.php’, ‘PescaditoSC’);
    }
    }
    new Pescadito();
    ?>
    3. A new folder (inside Pescadito folder) called shortcodes.
    4. a new file (inside shortcodes) called PescaditoSC.class.php. This is the code:
    <?php
    class PescaditoSC extends ADLayer
    {
    function render()
    {
    if (is_single()) //only shows when the post is being displayed, not in the category list
    {
    $this->setClassStyle(‘pescadito’);
    $form = $this->add(new ADForm(‘pescadito_form’));
    $form->add(new ADLabeledField(‘First name:’, new ADTextField(‘first_name’, ”, 20, 40)));
    $form->add(new ADLabeledField(‘Last name:’, new ADTextField(‘last_name’, ”, 20, 40)));
    $form->add(new ADSubmit(‘pescadito_save’, ‘save’));
    $form->setValues($_REQUEST);
    $form->addRequirement(‘first_name’, ‘required’, ‘the first name field must be completed’);
    if (isset($_REQUEST[‘pescadito_save’]))
    if ($form->runRequirements($_REQUEST))
    {
    //TODO save the data
    global $post;
    echo ‘TODO: Save data \”, $_REQUEST[‘first_name’], ‘\’ and \”, $_REQUEST[‘last_name’], ‘\’ in post id ‘,$post->ID, ”;
    }
    return parent::render(ADMIN_RENDER);
    }
    }
    }
    ?>

    And that’s all!!!!

    I’ll try to make a post in http://redfruits.wordpress.com with this example and with more comments.

    See you

    Remember to write [pescadito] in the post that you want to show the request form!!

    thanks inigoini, just give some days to try it

    best regards, pescadito

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: RedFruits: PHP API for wordpress development] any body can show how to use’ is closed to new replies.