Edit newsletter
- added custom item_actions to listings - added special function in order to register pages that aren't present in the menu - removed useless test.hbs - added wp_nonce_field & params functions to Twig - created a separate "newsletter/form.html" (copy of editor.html) but properly formatted
This commit is contained in:
@@ -69,13 +69,33 @@ define(
|
||||
);
|
||||
}
|
||||
|
||||
var item_actions = (
|
||||
var custom_actions = this.props.item_actions;
|
||||
var item_actions = false;
|
||||
|
||||
if(custom_actions.length > 0) {
|
||||
item_actions = custom_actions.map(function(action, index) {
|
||||
return (
|
||||
<span key={ 'action-'+index } className={ action.name }>
|
||||
<a href={ action.link(this.props.item.id) }>
|
||||
{ action.label }
|
||||
</a>
|
||||
{(index < (custom_actions.length - 1)) ? ' | ' : ''}
|
||||
</span>
|
||||
);
|
||||
}.bind(this));
|
||||
} else {
|
||||
item_actions = (
|
||||
<span className="edit">
|
||||
<Link to="edit" params={{ id: this.props.item.id }}>Edit</Link>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
var actions = (
|
||||
<div>
|
||||
<div className="row-actions">
|
||||
<span className="edit">
|
||||
<Link to="edit" params={{ id: this.props.item.id }}>Edit</Link>
|
||||
</span>
|
||||
|
|
||||
{ item_actions }
|
||||
{ ' | ' }
|
||||
<span className="trash">
|
||||
<a
|
||||
href="javascript:;"
|
||||
@@ -97,7 +117,7 @@ define(
|
||||
return (
|
||||
<tr className={ row_classes }>
|
||||
{ checkbox }
|
||||
{ this.props.onRenderItem(this.props.item, item_actions) }
|
||||
{ this.props.onRenderItem(this.props.item, actions) }
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
@@ -166,6 +186,7 @@ define(
|
||||
onDeleteItem={ this.props.onDeleteItem }
|
||||
selection={ this.props.selection }
|
||||
is_selectable={ this.props.is_selectable }
|
||||
item_actions={ this.props.item_actions }
|
||||
key={ 'item-' + item.id }
|
||||
item={ item } />
|
||||
);
|
||||
@@ -367,6 +388,9 @@ define(
|
||||
// bulk actions
|
||||
var bulk_actions = this.props.bulk_actions || [];
|
||||
|
||||
// item actions
|
||||
var item_actions = this.props.item_actions || [];
|
||||
|
||||
var tableClasses = classNames(
|
||||
'wp-list-table',
|
||||
'widefat',
|
||||
@@ -420,6 +444,7 @@ define(
|
||||
loading={ this.state.loading }
|
||||
count={ this.state.count }
|
||||
limit={ this.state.limit }
|
||||
item_actions={ item_actions }
|
||||
items={ items } />
|
||||
|
||||
<tfoot>
|
||||
|
@@ -34,8 +34,19 @@ define(
|
||||
}
|
||||
];
|
||||
|
||||
var item_actions = [
|
||||
{
|
||||
name: 'edit',
|
||||
label: 'Edit',
|
||||
link: function(id) {
|
||||
return '?page=mailpoet-newsletter-editor&id='+parseInt(id, 10);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var NewsletterList = React.createClass({
|
||||
renderItem: function(newsletter, actions) {
|
||||
|
||||
var rowClasses = classNames(
|
||||
'manage-column',
|
||||
'column-primary',
|
||||
@@ -65,7 +76,8 @@ define(
|
||||
endpoint="newsletters"
|
||||
onRenderItem={this.renderItem}
|
||||
columns={columns}
|
||||
bulk_actions={ bulk_actions } />
|
||||
bulk_actions={ bulk_actions }
|
||||
item_actions={ item_actions } />
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@@ -59,14 +59,30 @@ class Menu {
|
||||
'mailpoet-settings',
|
||||
array($this, 'settings')
|
||||
);
|
||||
add_submenu_page(
|
||||
'mailpoet',
|
||||
__('Newsletter editor'),
|
||||
__('Newsletter editor'),
|
||||
'manage_options',
|
||||
'mailpoet-newsletter-editor',
|
||||
array($this, 'newsletterEditor')
|
||||
// add_submenu_page(
|
||||
// 'mailpoet',
|
||||
// __('Newsletter editor'),
|
||||
// __('Newsletter editor'),
|
||||
// 'manage_options',
|
||||
// 'mailpoet-newsletter-editor',
|
||||
// array($this, 'newletterEditor')
|
||||
// );
|
||||
$this->registered_pages();
|
||||
}
|
||||
|
||||
function registered_pages() {
|
||||
global $_registered_pages;
|
||||
$pages = array(
|
||||
//'mailpoet-form-editor' => 'formEditor',
|
||||
'mailpoet-newsletter-editor' => array($this, 'newletterForm')
|
||||
);
|
||||
foreach($pages as $menu_slug => $callback) {
|
||||
$hookname = get_plugin_page_hookname($menu_slug, null);
|
||||
if(!empty($hookname)) {
|
||||
add_action($hookname, $callback);
|
||||
}
|
||||
$_registered_pages[$hookname] = true;
|
||||
}
|
||||
}
|
||||
|
||||
function home() {
|
||||
@@ -97,11 +113,11 @@ class Menu {
|
||||
echo $this->renderer->render('newsletters.html', $data);
|
||||
}
|
||||
|
||||
function newsletterEditor() {
|
||||
function newletterForm() {
|
||||
$data = array();
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script('tinymce-wplink', includes_url('js/tinymce/plugins/wplink/plugin.js'));
|
||||
wp_enqueue_style('editor', includes_url('css/editor.css'));
|
||||
echo $this->renderer->render('newsletter/editor.html', $data);
|
||||
echo $this->renderer->render('newsletter/form.html', $data);
|
||||
}
|
||||
}
|
||||
|
@@ -3,14 +3,14 @@ namespace MailPoet\Twig;
|
||||
|
||||
class Functions extends \Twig_Extension {
|
||||
|
||||
public function __construct() {
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
function getName() {
|
||||
return 'functions';
|
||||
}
|
||||
|
||||
public function getFunctions() {
|
||||
function getFunctions() {
|
||||
return array(
|
||||
new \Twig_SimpleFunction(
|
||||
'json_encode',
|
||||
@@ -21,7 +21,25 @@ class Functions extends \Twig_Extension {
|
||||
'json_decode',
|
||||
'json_decode',
|
||||
array('is_safe' => array('all'))
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'wp_nonce_field',
|
||||
'wp_nonce_field',
|
||||
array('is_safe' => array('all'))
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'params',
|
||||
array($this, 'params'),
|
||||
array('is_safe' => array('all'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function params($key = null) {
|
||||
$args = stripslashes_deep($_GET);
|
||||
if(array_key_exists($key, $args)) {
|
||||
return $args[$key];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
1274
views/newsletter/form.html
Normal file
1274
views/newsletter/form.html
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,15 @@
|
||||
<div class="mailpoet_form_field mailpoet_heading_form_field">
|
||||
<input type="text" class="mailpoet_input mailpoet_input_title" value="{{ model.subject }}" placeholder="<%= __('Click to change the subject!') %>" />
|
||||
<input
|
||||
type="text"
|
||||
class="mailpoet_input mailpoet_input_title"
|
||||
value="{{ model.subject }}"
|
||||
placeholder="<%= __('Click to change the subject!') %>"
|
||||
/>
|
||||
</div>
|
||||
<div class="mailpoet_form_field mailpoet_heading_form_field">
|
||||
<input type="text" class="mailpoet_input mailpoet_input_preheader" value="{{ model.preheader }}" placeholder="<%= __('Write your preheader here...') %>" />
|
||||
<input type="text"
|
||||
class="mailpoet_input mailpoet_input_preheader"
|
||||
value="{{ model.preheader }}"
|
||||
placeholder="<%= __('Write your preheader here...') %>"
|
||||
/>
|
||||
</div>
|
||||
|
@@ -1,2 +0,0 @@
|
||||
<h3><%= __('Settings') %></h3>
|
||||
{{ user.name }} ({{ user.age }}) - extra value: {{ extra_value }}
|
Reference in New Issue
Block a user