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;
|
||||||
<div>
|
var item_actions = false;
|
||||||
<div className="row-actions">
|
|
||||||
|
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">
|
<span className="edit">
|
||||||
<Link to="edit" params={{ id: this.props.item.id }}>Edit</Link>
|
<Link to="edit" params={{ id: this.props.item.id }}>Edit</Link>
|
||||||
</span>
|
</span>
|
||||||
|
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var actions = (
|
||||||
|
<div>
|
||||||
|
<div className="row-actions">
|
||||||
|
{ item_actions }
|
||||||
|
{ ' | ' }
|
||||||
<span className="trash">
|
<span className="trash">
|
||||||
<a
|
<a
|
||||||
href="javascript:;"
|
href="javascript:;"
|
||||||
@@ -97,7 +117,7 @@ define(
|
|||||||
return (
|
return (
|
||||||
<tr className={ row_classes }>
|
<tr className={ row_classes }>
|
||||||
{ checkbox }
|
{ checkbox }
|
||||||
{ this.props.onRenderItem(this.props.item, item_actions) }
|
{ this.props.onRenderItem(this.props.item, actions) }
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -166,6 +186,7 @@ define(
|
|||||||
onDeleteItem={ this.props.onDeleteItem }
|
onDeleteItem={ this.props.onDeleteItem }
|
||||||
selection={ this.props.selection }
|
selection={ this.props.selection }
|
||||||
is_selectable={ this.props.is_selectable }
|
is_selectable={ this.props.is_selectable }
|
||||||
|
item_actions={ this.props.item_actions }
|
||||||
key={ 'item-' + item.id }
|
key={ 'item-' + item.id }
|
||||||
item={ item } />
|
item={ item } />
|
||||||
);
|
);
|
||||||
@@ -367,6 +388,9 @@ define(
|
|||||||
// bulk actions
|
// bulk actions
|
||||||
var bulk_actions = this.props.bulk_actions || [];
|
var bulk_actions = this.props.bulk_actions || [];
|
||||||
|
|
||||||
|
// item actions
|
||||||
|
var item_actions = this.props.item_actions || [];
|
||||||
|
|
||||||
var tableClasses = classNames(
|
var tableClasses = classNames(
|
||||||
'wp-list-table',
|
'wp-list-table',
|
||||||
'widefat',
|
'widefat',
|
||||||
@@ -420,6 +444,7 @@ define(
|
|||||||
loading={ this.state.loading }
|
loading={ this.state.loading }
|
||||||
count={ this.state.count }
|
count={ this.state.count }
|
||||||
limit={ this.state.limit }
|
limit={ this.state.limit }
|
||||||
|
item_actions={ item_actions }
|
||||||
items={ items } />
|
items={ items } />
|
||||||
|
|
||||||
<tfoot>
|
<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({
|
var NewsletterList = React.createClass({
|
||||||
renderItem: function(newsletter, actions) {
|
renderItem: function(newsletter, actions) {
|
||||||
|
|
||||||
var rowClasses = classNames(
|
var rowClasses = classNames(
|
||||||
'manage-column',
|
'manage-column',
|
||||||
'column-primary',
|
'column-primary',
|
||||||
@@ -65,7 +76,8 @@ define(
|
|||||||
endpoint="newsletters"
|
endpoint="newsletters"
|
||||||
onRenderItem={this.renderItem}
|
onRenderItem={this.renderItem}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
bulk_actions={ bulk_actions } />
|
bulk_actions={ bulk_actions }
|
||||||
|
item_actions={ item_actions } />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@@ -59,14 +59,30 @@ class Menu {
|
|||||||
'mailpoet-settings',
|
'mailpoet-settings',
|
||||||
array($this, 'settings')
|
array($this, 'settings')
|
||||||
);
|
);
|
||||||
add_submenu_page(
|
// add_submenu_page(
|
||||||
'mailpoet',
|
// 'mailpoet',
|
||||||
__('Newsletter editor'),
|
// __('Newsletter editor'),
|
||||||
__('Newsletter editor'),
|
// __('Newsletter editor'),
|
||||||
'manage_options',
|
// 'manage_options',
|
||||||
'mailpoet-newsletter-editor',
|
// 'mailpoet-newsletter-editor',
|
||||||
array($this, 'newsletterEditor')
|
// 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() {
|
function home() {
|
||||||
@@ -97,11 +113,11 @@ class Menu {
|
|||||||
echo $this->renderer->render('newsletters.html', $data);
|
echo $this->renderer->render('newsletters.html', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function newsletterEditor() {
|
function newletterForm() {
|
||||||
$data = array();
|
$data = array();
|
||||||
wp_enqueue_media();
|
wp_enqueue_media();
|
||||||
wp_enqueue_script('tinymce-wplink', includes_url('js/tinymce/plugins/wplink/plugin.js'));
|
wp_enqueue_script('tinymce-wplink', includes_url('js/tinymce/plugins/wplink/plugin.js'));
|
||||||
wp_enqueue_style('editor', includes_url('css/editor.css'));
|
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 {
|
class Functions extends \Twig_Extension {
|
||||||
|
|
||||||
public function __construct() {
|
function __construct() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
function getName() {
|
||||||
return 'functions';
|
return 'functions';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFunctions() {
|
function getFunctions() {
|
||||||
return array(
|
return array(
|
||||||
new \Twig_SimpleFunction(
|
new \Twig_SimpleFunction(
|
||||||
'json_encode',
|
'json_encode',
|
||||||
@@ -21,7 +21,25 @@ class Functions extends \Twig_Extension {
|
|||||||
'json_decode',
|
'json_decode',
|
||||||
'json_decode',
|
'json_decode',
|
||||||
array('is_safe' => array('all'))
|
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">
|
<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>
|
||||||
<div class="mailpoet_form_field mailpoet_heading_form_field">
|
<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>
|
</div>
|
||||||
|
@@ -1,2 +0,0 @@
|
|||||||
<h3><%= __('Settings') %></h3>
|
|
||||||
{{ user.name }} ({{ user.age }}) - extra value: {{ extra_value }}
|
|
Reference in New Issue
Block a user