Respuesta a: MailPress

Inicio Foros WordPress Plugins MailPress Respuesta a: MailPress

#42428

luisoswaldo
Participante

Estoy haciendo un seguimiento al codigo que postee antes para ver como mailpress genera el formulario a partir de la llamada a la funcion form().

La funcion form() esta en mailpress/MailPress.php

Este es el codigo de form()

public static function form($options = array())
{
static $cc = 0;

$options[‘widget_id’] = (isset($options[‘widget_id’])) ? $options[‘widget_id’] . ‘_’ . $cc : ‘mf_’ . $cc;
MP_Widget::widget_form($options);

$cc++;
}

Aqui llama a la func widget_form() que esta mailpress/mp-includes/class/MP_Widget.class.php y el codigo de dicha func es el siguiente:

public static function widget_form($options = array())
{
static $headers = 0;

global $user_ID;
$email = $message = $widget_title = ”;

$options = self::form_defaults($options);

$id = $options[‘widget_id’];

if (isset($_POST[‘MailPress_submit’]) && ($_POST[‘id’] == $id))
list($message, $email, $name) = self::insert(false);
else
{
switch (true)
{
case ($user_ID != 0 && is_numeric($user_ID) ) :
// user connected, so populate the email field if not already a subscriber !
$user = get_userdata($user_ID);
$email = $user->user_email;
$name = $user->display_name;
MailPress::require_class(‘Users’);
if ( MP_Users::is_user($email, $user_ID) ) $email = $name = ”;
break;
default :
// user as already commented, so populate the email field if not already a subscriber !
$email = (isset($_COOKIE[‘comment_author_email_’ . COOKIEHASH])) ? $_COOKIE[‘comment_author_email_’ . COOKIEHASH] : ”;
$name = (isset($_COOKIE[‘comment_author_’ . COOKIEHASH])) ? $_COOKIE[‘comment_author_’ . COOKIEHASH] : ”;
MailPress::require_class(‘Users’);
if ( MP_Users::get_status_by_email($email) == ‘active’ ) $email=”;
break;
}
}

if (” == $email) $email = $options[‘txtfield’];
if (” == $name) $name = $options[‘txtfieldname’];

?>

<!– start of code generated by MailPress –>
<?php
if (!$headers)
{
$headers = 1;
if (!$options[‘css’]) { echo “<style type=’text/css’>n”; include MP_TMP . ‘mp-includes/css/form.css’; echo “n</style>n”; }
if (!$options[‘jq’]) echo “<script type=’text/javascript’ src='” . get_option(‘siteurl’) . “/wp-includes/js/jquery/jquery.js’></script>n”;
if (!$options[‘js’]) echo “<script type=’text/javascript’> var mp_url = ‘” . MP_Action_url . “‘;</script>n”;
if (!$options[‘js’]) echo “<script type=’text/javascript’ src='” . get_option(‘siteurl’) . ‘/’ . MP_PATH . “mp-includes/js/mp_form.js’></script>n”;
}
?>

<div class=’MailPress’ id=’_MP_<?php echo $id; ?>’>
<div class=’mp-container’>
<div class=’mp-message’></div>
<div class=’mp-loading’>/<?php echo MP_PATH; ?>mp-includes/images/loading.gif’ alt='<?php echo $options[‘txtloading’]; ?>’ title='<?php echo $options[‘txtloading’]; ?>’ /><?php echo $options[‘txtloading’]; ?></div>
<div class=’mp-formdiv’>
<?php if (” != $message) echo $message . “n”; ?>
<form class=’mp-form’ method=’post’ action=”>
<input type=’hidden’ name=’action’ value=’add_user_fo’ />
<input type=’hidden’ name=’id’ value='<?php echo ‘_MP_’ . $id; ?>’ />
<input type=’text’ name=’email’ value=”<?php echo $email; ?>” class=’MailPressFormEmail’ size=’25’ onfocus=”if(this.value=='<?php echo js_escape($options[‘txtfield’]); ?>’) this.value=”;” onblur=”if(this.value==”) this.value='<?php echo js_escape($email); ?>’;” />
<input type=’text’ name=’name’ value=”<?php echo $name; ?>” class=’MailPressFormName’ size=’25’ onfocus=”if(this.value=='<?php echo js_escape($options[‘txtfieldname’]); ?>’) this.value=”;” onblur=”if(this.value==”) this.value='<?php echo js_escape($name); ?>’;” />
<?php do_action(‘MailPress_form’, $email, $options); ?>
<input class=’MailPressFormSubmit mp_submit’ type=’submit’ name=’MailPress_submit’ value=”<?php echo MailPress::input_text($options[‘txtbutton’]); ?>” />
</form>
</div>
</div>
<?php
$url = ($options[‘urlsubmgt’]) ? self::get_wp_user_unsubscribe_url() : false;
if ($url) :
?>
<div id=’mp-urlsubmgt’>‘><?php echo MailPress::input_text($options[‘txtsubmgt’]); ?></div>
<?php
endif;
?>
<?php do_action(‘MailPress_form_div_misc’, $email, $options); ?>
</div>
<!– end of code generated by MailPress –>
<?php
}

Ahi crea el formulario y cada quien puede adaptarlo a sus necesidades.

Pin It on Pinterest

Ir al contenido