Working on the fix for image alignment.
add_action( 'admin_notices', 'glmMembersMessagesPluginRequired' );
deactivate_plugins('/'.GLM_MEMBERS_MESSAGES_PLUGIN_SLUG.'/index.php');
}
+// Check for the Contact Plugin to be installed and active.
+function glmMembersMessagesContactPluginRequired() {
+ echo '
+ <div class="error">
+ <p>The '.GLM_MEMBERS_MESSAGES_PLUGIN_NAME.' add-on requires the GLM Associate Contacts Plugin to be installed and active!</p>
+ <p>The '.GLM_MEMBERS_MESSAGES_PLUGIN_NAME.' plugin has been de-activated.</p>
+ </div>
+ ';
+}
+$plugin_name = 'glm-member-db-contacts/index.php';
+$is_active = is_plugin_active($plugin_name);
+if ($is_active != '1') {
+ add_action( 'admin_notices', 'glmMembersMessagesContactPluginRequired' );
+ deactivate_plugins('/'.GLM_MEMBERS_MESSAGES_PLUGIN_SLUG.'/index.php');
+}
/**
* Hooks for creating help documentation
// Save plugin configuration object
$this->config = $config;
+ parent::__construct( $this->wpdb, $this->config );
+
}
$smarty->templateAssign( $k, $d );
}
}
- $emailContent = $smarty->template->fetch( 'eval:' . wpautop( $message['message_body'] ) );
+ $message['message_body'] = $this->fixImages( $message['message_body'] );
+ $htmlMessage = wpautop( $message['message_body'] );
+ // $htmlMessage = nl2br( $message['message_body'] );
+ $emailContent = $smarty->template->fetch( 'eval:' . $htmlMessage );
} else {
$emailContent = '<p>Message Content would go here!</p>';
}
echo $output;
exit;
}
+
+
+ public function fixImages( $content )
+ {
+ $dom = new DOMDocument( '1.0', 'UTF-8' );
+ $dom->encoding = 'UTF-8';
+ $test = $dom->loadHTML( $content );
+ $images = $dom->getElementsByTagName( 'img' );
+ foreach ( $images as $image ) {
+ $width = $height = $align = null;
+ if ( $image->hasAttribute( 'class' ) ) {
+ // Is it left or right or center?
+ if ( preg_match( '%alignleft%', $image->getAttribute('class'))) {
+ $align = 'left';
+ }
+ if ( preg_match( '%alignright%', $image->getAttribute('class'))) {
+ $align = 'right';
+ }
+ if ( preg_match( '%aligncenter%', $image->getAttribute('class'))) {
+ $align = 'center';
+ }
+ }
+ switch ( $align ) {
+ case 'left':
+ $image->setAttribute( 'style', 'float: left; margin: 5px;' );
+ break;
+ case 'right':
+ $image->setAttribute( 'style', 'float: right; margin: 5px;' );
+ break;
+ case 'center':
+ $image->setAttribute( 'style', 'display: block; text-align: center; margin: 0 auto;' );
+ break;
+ }
+ }
+ $content = $dom->saveHTML();
+ return $content;
+ }
+
}
break;
case 'preview':
+ trigger_error( 'REQUEST: ' . print_r($_REQUEST, true), E_USER_NOTICE );
$view = 'newsletterFrame';
$viewPath = 'email/messages/';
$emailContent = '';
$messageId = false;
$Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
+ trigger_error( '$this: ' . print_r($this->fields, true), E_USER_NOTICE );
if ( isset( $_REQUEST['message_id'] ) && $messageId = filter_var( $_REQUEST['message_id'], FILTER_VALIDATE_INT ) ) {
- $message = $this->getEntry( $messageId );
- // echo '<pre>$message: ' . print_r( $message, true ) . '</pre>';
+ trigger_error( 'messageId: ' . print_r($messageId, true), E_USER_NOTICE );
+ $message = $this->getEntry( $messageId );
+ trigger_error( 'message: ' . print_r($message, true), E_USER_NOTICE );
$emailData = array(
'member' => array(
'name' => 'Test Member',
$smarty->templateAssign( $k, $d );
}
}
- $emailContent = $smarty->template->fetch( 'eval:' . wpautop( $message['message_body'] ) );
+ // $htmlMessage = wpautop( $message['message_body'] );
+ $htmlMessage = nl2br( $message['message_body'] );
+ $emailContent = $smarty->template->fetch( 'eval:' . $htmlMessage );
} else {
$emailContent = '<p>Message Content would go here!</p>';
}
if ( isset( $_REQUEST['id'] ) && $id = filter_var( $_REQUEST['id'], FILTER_VALIDATE_INT ) ) {
$template = $Templates->getEntry( $id );
+ trigger_error( 'template: ' . print_r($template, true), E_USER_NOTICE );
}
$tData = array(
'template_id' => $id,
case 'list':
$view = 'list';
+
default:
- $where = "T.archived <> true";
+ if ( isset( $_REQUEST['filterArchived'] ) && $filterArchived = filter_var( $_REQUEST['filterArchived'], FILTER_VALIDATE_BOOLEAN ) ) {
+ $where = "T.archived = true";
+ } else {
+ $where = "T.archived <> true";
+ }
$this->postStats = true;
$this->postSent = true;
$messages = $this->getList( $where );
'field' => 'message_body',
'label' => 'Message Content',
'height' => '450',
+ 'media' => true,
'required' => $data.fieldRequired.message_body,
'errorText' => 'Message Content is Required',
'dataError' => $data.fieldFail.message_body
{include file='admin/header.html'}
<h3>List Messages</h3>
+{* Form Start *}
+{$ui = [
+ 'id' => 'messageSearch',
+ 'action' => "{$thisUrl}?page={$thisPage}",
+ 'method' => 'post',
+ 'file' => false
+]}
+{include file='ui/f6/form-start.html'}
+
+<input type="hidden" name="option" value="list" />
+
+<div class="grid-x grid-margin-x">
+ <fieldset class="fieldset cell small-12 medium-6">
+ <legend>Filter</legend>
+
+ {* Show Archived *}
+ {$ui = [
+ 'value' => $smarty.request.filterArchived|default:'',
+ 'field' => 'filterArchived',
+ 'label' => 'Show Archived',
+ 'required' => false,
+ 'errorText' => 'Show Archived is Required',
+ 'dataError' => ''
+ ]}
+ {include file='ui/f6/checkbox.html'}
+
+ {* Submit *}
+ {$ui = [
+ 'class' => 'primary',
+ 'label' => 'Submit',
+ 'submit' => true,
+ 'id' => '',
+ 'cancel' => ""
+ ]}
+ {include file='ui/f6/submit.html'}
+
+ </fieldset>
+</div>
+
+{* Form End *}
+{include file='ui/f6/form-end.html'}
+
<a href="{$thisUrl}?page={$thisPage}&option=editHtmlEmail" class="button button-primary glm-right">Add Message</a>
{include file='admin/messages/listMessagesTable.html'}