WYSIJA_view_back_campaigns

The MailPoet Newsletters WYSIJA view back campaigns class.

Defined (1)

The class is defined in the following location(s).

/views/back/campaigns.php  
  1. class WYSIJA_view_back_campaigns extends WYSIJA_view_back { 
  2.  
  3. var $icon = 'icon-edit-news'; 
  4. var $column_action_list = 'name'; 
  5. var $queuedemails = false; 
  6.  
  7. function __construct() { 
  8. $this->title = __('All Newsletters'); 
  9. parent::__construct(); 
  10. $this->jsTrans['selecmiss'] = __('Select at least 1 subscriber!', WYSIJA); 
  11. $this->search = array('title' => __('Search newsletters', WYSIJA)); 
  12. $this->column_actions = array('editlist' => __('Edit', WYSIJA), 'duplicatelist' => __('Duplicate', WYSIJA), 'deletelist' => __('Delete', WYSIJA)); 
  13.  
  14. function installation() { 
  15. return ''; 
  16.  
  17. /** 
  18. * @see parent::header() 
  19. */ 
  20. function header($data = '') 
  21. if (!empty($_REQUEST['action'])) 
  22. switch (trim(strtolower($_REQUEST['action']))) 
  23. case 'viewstats': 
  24. $this->icon = 'icon-stats'; 
  25. break; 
  26. default: 
  27. break; 
  28. parent::header($data); 
  29.  
  30. function main($data) { 
  31. $this->menuTop($this->action); 
  32.  
  33. echo '<form method="post" action="" id="posts-filter">'; 
  34. $this->filtersLink($data); 
  35. $this->filterDDP($data); 
  36. $this->listing($data); 
  37. echo '</form>'; 
  38.  
  39. function menuTop($actionmenu = false, $data = false) { 
  40.  
  41. $array_translation = array( 
  42. 'back' => __('Back', WYSIJA),  
  43. 'add' => __('Create a new email', WYSIJA) 
  44. ); 
  45.  
  46. $arrayMenus = array(); 
  47. switch ($actionmenu) { 
  48. case 'main': 
  49. $arrayMenus[] = 'add'; 
  50. break; 
  51.  
  52. case 'viewstats': 
  53. case 'add': 
  54. case 'edit': 
  55. default: 
  56. break; 
  57. $menu = ''; 
  58. $classes = function_exists('wp_star_rating') ? 'add-new-h2' : 'button-secondary2'; 
  59. if ($arrayMenus) { 
  60. $menu .= '<span class="action_buttons">'; 
  61. foreach ($arrayMenus as $action) { 
  62. $action_params = $action; 
  63. $extra_params = $link = ''; 
  64. if (empty($link)) 
  65. $link = 'admin.php?page=wysija_campaigns&action=' . $action_params; 
  66. $menu.= '<a id="action-' . str_replace("_", "-", $action) . '" ' . $extra_params . ' href="' . $link . '" class="action-' . str_replace("_", "-", $action) . ' ' . $classes . '">' . $array_translation[$action] . '</a>'; 
  67. if ($actionmenu == 'main' && $action == 'add') { 
  68. $menu.='<span class="description" > ' . __('... or duplicate one below to copy its design.', WYSIJA) . '</span>'; 
  69. $menu .= '</span>'; 
  70. $menu .= '</h2>'; 
  71. $menu .= '<h2 class="hidden">'; 
  72. return $menu; 
  73.  
  74. function filterDDP($data) { 
  75. if (empty($data['campaigns'])) 
  76. return; 
  77. ?> 
  78. <ul class="subsubsub"> 
  79. <?php 
  80. $total = count($data['counts']); 
  81. $i = 1; 
  82. foreach ($data['counts'] as $countType => $count) { 
  83. if (!$count) { 
  84. $i++; 
  85. continue; 
  86. switch ($countType) { 
  87. case 'all': 
  88. $tradText = __('All', WYSIJA); 
  89. break; 
  90. case 'status-sent': 
  91. $tradText = __('Sent', WYSIJA); 
  92. break; 
  93. case 'status-sending': 
  94. $tradText = __('Sending', WYSIJA); 
  95. break; 
  96. case 'status-draft': 
  97. $tradText = __('Draft', WYSIJA); 
  98. break; 
  99. case 'status-paused': 
  100. $tradText = __('Paused', WYSIJA); 
  101. break; 
  102. case 'status-scheduled': 
  103. $tradText = __('Scheduled', WYSIJA); 
  104. break; 
  105. case 'type-regular': 
  106. $tradText = __('Standard Newsletters', WYSIJA); 
  107. break; 
  108. case 'type-autonl': 
  109. $tradText = __('Auto Newsletters', WYSIJA); 
  110. break; 
  111. $classcurrent = ''; 
  112. if ((isset($_REQUEST['link_filter']) && $_REQUEST['link_filter'] == $countType) || ($countType == 'all' && !isset($_REQUEST['link_filter']))) 
  113. $classcurrent = 'class="current"'; 
  114. echo '<li><a ' . $classcurrent . ' href="admin.php?page=wysija_campaigns&link_filter=' . $countType . '">' . $tradText . ' <span class="count">(' . $count . ')</span></a>'; 
  115.  
  116. if ($total != $i) 
  117. echo ' | '; 
  118. echo '</li>'; 
  119. $i++; 
  120. ?> 
  121. </ul> 
  122.  
  123. <?php $this->searchBox(); ?> 
  124.  
  125. <div class="tablenav"> 
  126. <div class="alignleft actions"> 
  127. <span class="alignleft actions" id="bulksubmit-area" style="display:none;"> 
  128. <?php 
  129. $action_locale = array( 
  130. 'delete' => __('Delete this newsletter for ever?', WYSIJA),  
  131. 'delete_bulk' => __('Delete these newsletters for ever?', WYSIJA) 
  132. ); 
  133. ?> 
  134. <?php 
  135. /** 
  136. <input type="submit" class="bulksubmit-button button-secondary action" name="doaction" data-action="delete" 
  137. data-locale='<?php echo json_encode($action_locale); ?>' 
  138. value="<?php echo esc_attr(__('Delete selected', WYSIJA)); ?>"> 
  139. */ 
  140. ?> 
  141. <?php $this->secure('delete'); ?> 
  142. </span> 
  143.  
  144. <select name="filter-date" class="global-filter"> 
  145. <option selected="selected" value=""><?php echo esc_attr(__('Show all months', WYSIJA)); ?></option> 
  146. <?php 
  147. //echo $this->fieldListHTML_created_at($row["created_at"]) 
  148.  
  149. foreach ($data['dates'] as $listK => $list) { 
  150. $selected = ""; 
  151. if (isset($_REQUEST['filter-date']) && $_REQUEST['filter-date'] == $listK) 
  152. $selected = ' selected="selected" '; 
  153. echo '<option ' . $selected . ' value="' . esc_attr($listK) . '">' . $list . '</option>'; 
  154. ?> 
  155. </select> 
  156. </div> 
  157.  
  158. <div class="alignleft actions"> 
  159. <select name="filter-list" class="global-filter"> 
  160. <option selected="selected" value=""><?php _e('View by lists', WYSIJA); ?></option> 
  161. <?php 
  162. foreach ($data['lists'] as $listK => $list) { 
  163. $selected = ""; 
  164. if (isset($_REQUEST['filter-list']) && $_REQUEST['filter-list'] == $listK) 
  165. $selected = ' selected="selected" '; 
  166. if ($list['users'] > 0) 
  167. echo '<option ' . $selected . ' value="' . $list['list_id'] . '">' . $list['name'] . ' (' . $list['users'] . ')' . '</option>'; 
  168. ?> 
  169. </select> 
  170. <input type="submit" class="filtersubmit button-secondary action" name="doaction" value="<?php echo esc_attr(__('Filter', WYSIJA)); ?>"> 
  171. </div> 
  172. <?php $this->pagination(); ?> 
  173.  
  174. <div class="clear"></div> 
  175. </div> 
  176. <?php 
  177.  
  178. function getTransStatusEmail($status) { 
  179. switch ($status) { 
  180. case 'all': 
  181. $tradText = __('All', WYSIJA); 
  182. break; 
  183. case 'allsent': 
  184. $tradText = __('All Sent', WYSIJA); 
  185. break; 
  186. case 'inqueue': 
  187. $tradText = __('In Queue', WYSIJA); 
  188. break; 
  189. case 'notsent': 
  190. $tradText = __('Failed Send', WYSIJA); 
  191. break; 
  192. case 'sent': 
  193. $tradText = __('Unopened', WYSIJA); 
  194. break; 
  195. case 'opened': 
  196. $tradText = __('Opened', WYSIJA); 
  197. break; 
  198. case 'bounced': 
  199. $tradText = __('Bounced', WYSIJA); 
  200. break; 
  201. case 'clicked': 
  202. $tradText = __('Clicked', WYSIJA); 
  203. break; 
  204. case 'unsubscribe': 
  205. $tradText = __('Unsubscribe', WYSIJA); 
  206. break; 
  207. default: 
  208. $tradText = 'status : ' . $status; 
  209. return $tradText; 
  210.  
  211. function filterDDPVIEW($data) { 
  212. ?> 
  213. <ul class="subsubsub"> 
  214. <?php 
  215. $total = count($data['counts']); 
  216. $i = 1; 
  217. foreach ($data['counts'] as $countType => $count) { 
  218. if (!$count || $countType == 'all') { 
  219. $i++; 
  220. continue; 
  221. $tradText = $this->getTransStatusEmail($countType); 
  222. $classcurrent = ''; 
  223. if ((isset($_REQUEST['link_filter']) && $_REQUEST['link_filter'] == $countType) || ($countType == 'allsent' && !isset($_REQUEST['link_filter']))) 
  224. $classcurrent = 'class="current"'; 
  225.  
  226. echo '<li><a ' . $classcurrent . ' href="admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id'] . '&link_filter=' . $countType . '">' . $tradText . ' <span class="count">(' . $count . ')</span></a>'; 
  227.  
  228. if ($total != $i) 
  229. echo ' | '; 
  230. echo '</li>'; 
  231. $i++; 
  232. ?> 
  233. </ul> 
  234.  
  235. <?php $this->searchBox(); ?> 
  236.  
  237. <div class="tablenav"> 
  238.  
  239. <div class="alignleft actions"> 
  240. <select name="action2" class="global-action" id="viewstats_ddp"> 
  241. <option value="" data-sort="0"><?php _e('With this segment', WYSIJA); ?></option> 
  242. <?php 
  243. if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter'] == 'notsent') { 
  244.  
  245. ?> 
  246. <option value="removequeue" data-nonce="<?php echo $this->secure(array('action' => "removequeue", 'id' => $_REQUEST['id']), true) ?>"><?php _e('Remove from the queue', WYSIJA); ?></option> 
  247. <?php 
  248. ?> 
  249. <option value="createnewlist" data-nonce="<?php echo $this->secure(array('action' => "createnewlist", 'id' => $_REQUEST['id']), true) ?>"><?php _e('Create a new list', WYSIJA); ?></option> 
  250. <option value="unsubscribeall" data-nonce="<?php echo $this->secure(array('action' => "unsubscribeall", 'id' => $_REQUEST['id']), true) ?>"><?php _e('Unsubscribe from all lists', WYSIJA); ?></option> 
  251. <?php 
  252. foreach ($data['lists'] as $listK => $list) { 
  253. if ($list['is_enabled']) { 
  254. echo '<option value="actionvar_unsubscribelist-listid_' . $list['list_id'] . '" data-nonce="'. $this->secure(array('action' => "actionvar_unsubscribelist-listid_" . $list['list_id'], 'id' => $_REQUEST['id']), true).'">' . sprintf(__('Unsubscribe from list: %1$s', WYSIJA), $list['name']) . ' (' . $list['users'] . ')' . '</option>'; 
  255. ?> 
  256. <option value="export" data-nonce="<?php echo $this->secure(array('action' => "export", 'id' => $_REQUEST['id']), true) ?>"><?php _e('Export to CSV', WYSIJA); ?></option> 
  257.  
  258. </select> 
  259. <?php $this->secure(array('action' => "bulkoptions", 'id' => $_REQUEST['id'])); ?> 
  260. <input type="submit" class="bulksubmitcamp button-secondary action" name="doaction" value="<?php echo esc_attr(__('Apply', WYSIJA)); ?>"> 
  261. </div> 
  262. <?php $this->pagination(); ?> 
  263.  
  264. <div class="clear"></div> 
  265. </div> 
  266. <?php 
  267.  
  268. /** 
  269. * main view 
  270. */ 
  271.  
  272. function listing($data, $simple = false) { 
  273. if (empty($data['campaigns'])) 
  274. return; 
  275. ?> 
  276. <div class="list"> 
  277. <table cellspacing="0" class="widefat fixed"> 
  278. <thead> 
  279. <?php 
  280. $openedsorting = $statussorting = $namesorting = $datesorting = $datesorting2 = " sortable desc"; 
  281. $hiddenOrder = ""; 
  282. if (isset($_REQUEST["orderby"])) { 
  283. switch ($_REQUEST["orderby"]) { 
  284. case "name": 
  285. $namesorting = " sorted " . $_REQUEST["ordert"]; 
  286. break; 
  287. case "modified_at": 
  288. $datesorting = " sorted " . $_REQUEST["ordert"]; 
  289. break; 
  290. case "sent_at": 
  291. $datesorting2 = " sorted " . $_REQUEST["ordert"]; 
  292. break; 
  293. case "status": 
  294. $statussorting = " sorted " . $_REQUEST["ordert"]; 
  295. break; 
  296. case "number_opened": 
  297. $openedsorting = " sorted " . $_REQUEST["ordert"]; 
  298. break; 
  299. $hiddenOrder = '<input type="hidden" name="orderby" id="wysija-orderby" value="' . esc_attr($_REQUEST["orderby"]) . '"/>'; 
  300. $hiddenOrder.='<input type="hidden" name="ordert" id="wysija-ordert" value="' . esc_attr($_REQUEST["ordert"]) . '"/>'; 
  301. $header = '<tr class="thead"> 
  302. <th scope="col" id="campaign-id" class="manage-column column-campaign-id check-column"><input type="checkbox" /></th> 
  303. <th class="manage-column column-name' . $namesorting . '" id="name" scope="col" style="width:25%"><a href="#" class="orderlink" ><span>' . __('Name', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  304. /** $header.='<th class="manage-column column-fname'.$fnamesorting.'" id="firstname" scope="col" style="width:80px;">'.__('First name', WYSIJA).'</th> 
  305. <th class="manage-column column-lname'.$lnamesorting.'" id="lastname" scope="col" style="width:80px;">'.__('Last name', WYSIJA).'</th>'; */ 
  306. $header.='<th class="manage-column column-status' . $statussorting . '" id="status" scope="col" style="width:15%;"><a href="#" class="orderlink" ><span>' . __('Status', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  307. $header.='<th class="manage-column column-list-names" id="list-list" scope="col">' . __('Lists', WYSIJA) . '</th>'; 
  308. $header.='<th class="manage-column column-opened' . $openedsorting . '" id="number_opened" scope="col" style="width:15%;"><a href="#" class="orderlink" ><span>' . __('Open, clicks, unsubscribed', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  309.  
  310.  
  311. /** $header.='<th class="manage-column column-emails" id="emails-list" scope="col">'.__('Emails', WYSIJA).'</th> 
  312. <th class="manage-column column-opened" id="opened-list" scope="col">'.__('Opened', WYSIJA).'</th> 
  313. <th class="manage-column column-clic" id="clic-list" scope="col">'.__('Clicked', WYSIJA).'</th>'; */ 
  314. $header.='<th class="manage-column column-date' . $datesorting . '" id="modified_at" scope="col"><a href="#" class="orderlink" ><span>' . __('Modified On', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  315. $header.='<th class="manage-column column-date' . $datesorting2 . '" id="sent_at" scope="col"><a href="#" class="orderlink" ><span>' . __('Sent On', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th> 
  316. </tr>'; 
  317. echo $header; 
  318. ?> 
  319. </thead> 
  320. <tfoot> 
  321. <?php 
  322. echo $header; 
  323. ?> 
  324. </tfoot> 
  325.  
  326. <tbody class="list:<?php echo $this->model->table_name . ' ' . $this->model->table_name . '-list" id="wysija-' . $this->model->table_name . '"' ?>> 
  327.  
  328. <?php 
  329. $listingRows = ''; 
  330. $alt = true; 
  331.  
  332. $statuses = array('-1' => __('Sent to %1$s out of %2$s', WYSIJA), '0' => __('Draft', WYSIJA), '1' => __('%1$s out of %2$s sent.', WYSIJA), '3' => __('%1$s out of %2$s sent.', WYSIJA), '2' => __('Sent to %1$s out of %2$s', WYSIJA), '99' => __('%1$s out of %2$s sent.', WYSIJA)); 
  333.  
  334. foreach ($data['campaigns'] as $row) { 
  335. $classRow = $messageListEdit = ''; 
  336. //check if lists have been removed in case of scheduled newsletter or auto post notif 
  337. if (empty($row['name'])) { 
  338. $row['name'] = $row['campaign_name']; 
  339.  
  340. if (isset($row['classRow'])) { 
  341. $classRow.=$row['classRow']; 
  342. if (isset($row['msgListEdit'])) 
  343. $messageListEdit = $row['msgListEdit']; 
  344.  
  345.  
  346. if ($alt) 
  347. $classRow.='alternate'; 
  348. $editStep = 'editTemplate'; 
  349. if ($row["type"] == 2) { 
  350. $classRow.=" autonl"; 
  351. $editStep = 'edit'; 
  352.  
  353. if ((int) $row['status'] == 4 && isset($row['params']['schedule']['isscheduled'])) { 
  354. $classRow.=' scheduled'; 
  355. if (in_array($row['status'], array(1, 3, 99))) 
  356. $classRow.=' sending'; 
  357. if ($row['status'] == 2) 
  358. $classRow.=' sent'; 
  359.  
  360.  
  361. //$row["params"]=unserialize(base64_decode($row["params"])); 
  362. ?> 
  363. <tr class="<?php echo $classRow ?>" > 
  364.  
  365. <th scope="col" class="check-column" > 
  366. <input type="checkbox" name="wysija[campaign][campaign_id][]" id="campaign_id_<?php echo $row["campaign_id"] ?>" value="<?php echo esc_attr($row["campaign_id"]) ?>" class="checkboxselec" /> 
  367. </th> 
  368. <td class="name column-name"> 
  369. <strong> 
  370. <?php 
  371. if (in_array($row['status'], array(0, 4, -1))) { 
  372. $durationsent = $statusshared = ''; 
  373. ?><a href="admin.php?page=wysija_campaigns&id=<?php echo $row['email_id'] ?>&action=edit" class="row-title"><?php echo $row['name']; ?></a> - <span class="post-state"><?php 
  374. if (isset($row['params']['schedule']['isscheduled']) && $row['status'] == 4) { 
  375. $helper_toolbox = WYSIJA::get('toolbox', 'helper'); 
  376.  
  377. //no recording just conversion 
  378. $scheduletimenoffset = strtotime($row['params']['schedule']['day'] . ' ' . $row['params']['schedule']['time']); 
  379. $timeleft = $helper_toolbox->localtime_to_servertime($scheduletimenoffset) - time(); 
  380. if ($timeleft <= 0) { 
  381. $autoNL = WYSIJA::get('autonews', 'helper'); 
  382. $autoNL->checkScheduled(); 
  383. } else { 
  384.  
  385. $scheduled_on = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $scheduletimenoffset); 
  386. if ($timeleft <= (60 * 60 * 24)) { // 1 day 
  387. $timeleft = $helper_toolbox->duration_string($timeleft, true, 4); 
  388. $durationsent = '<span title="' . $scheduled_on . '">' . sprintf(__('Scheduled to be sent in %1$s'), $timeleft) . '</span>'; 
  389. } else { 
  390.  
  391. $durationsent = sprintf(__('Scheduled to be sent on %1$s'), $scheduled_on); 
  392.  
  393.  
  394. $statusshared = $durationsent; 
  395. echo __('Scheduled', WYSIJA); 
  396. } else { 
  397. if ($row['type'] == 2) 
  398. if ($row['status'] == -1) 
  399. echo __('Paused', WYSIJA); 
  400. else 
  401. echo __('Draft', WYSIJA); 
  402. else { 
  403. if ((int) $row['status'] == -1) 
  404. $resulttext = sprintf($statuses[(int) $row['status']], $data['sent'][$row["email_id"]]['to'], $data['sent'][$row["email_id"]]['total']); 
  405. else 
  406. $resulttext = $statuses[(int) $row['status']]; 
  407.  
  408. echo $resulttext; 
  409. ?></span> 
  410.  
  411. <?php 
  412. }else { 
  413.  
  414. if (isset($data['sent'][$row['email_id']]['to']) && $data['sent'][$row['email_id']]['to'] > 0) { 
  415. ?><a href="admin.php?page=wysija_campaigns&id=<?php echo $row["email_id"] ?>&action=viewstats" class="row-title"><?php echo $row['name']; ?></a><?php 
  416. } else { 
  417. if ($row["type"] == 2) { 
  418. ?> 
  419. <a href="admin.php?page=wysija_campaigns&id=<?php echo $row["email_id"] ?>&action=pause&_wpnonce=<?php echo $this->secure(array('action' => 'pause' , 'id' => $row["email_id"]), true); ?>" class="row-title pause-edit"> 
  420. <?php echo $row['name']; ?> 
  421. </a><?php 
  422. } else { 
  423. echo $row['name']; 
  424. ?></strong> 
  425. <div class="row-actions"> 
  426. <?php 
  427. $emailH = WYSIJA::get('email', 'helper'); 
  428. $fullurl = $emailH->getVIB($row); 
  429. ?><span class="viewnl"> 
  430. <a href="<?php echo $fullurl ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>"><?php _e('Preview', WYSIJA) ?></a> 
  431. </span><?php 
  432. $deleteAction = ''; 
  433. $dupid = $deleteId = $row['campaign_id']; 
  434. if (isset($row['params']['autonl']['parent']) || ((int) $row['type'] === 2 && $row['params']['autonl']['event'] == 'new-articles')) { 
  435. $deleteAction = 'Email'; 
  436. $deleteId = $row['email_id']; 
  437.  
  438. if ($row['status'] == 0 || $row['status'] == 4) { 
  439. ?> 
  440. | <span class="edit"> 
  441. <a href="admin.php?page=wysija_campaigns&id=<?php echo $row['email_id'] ?>&action=<?php echo $editStep ?>" class="submitedit"><?php _e('Edit', WYSIJA) ?></a> 
  442. </span> 
  443. <?php 
  444. if (isset($data['sent'][$row["email_id"]]['to']) && $data['sent'][$row["email_id"]]['to'] > 0) { 
  445. ?> 
  446.  
  447. | <span class="viewstats"> 
  448. <a href="admin.php?page=wysija_campaigns&id=<?php echo $row["email_id"] ?>&action=viewstats" class="stats"><?php _e('Stats', WYSIJA) ?></a> 
  449. </span> 
  450.  
  451. <?php 
  452. ?> 
  453. | <span class="duplicate"> 
  454. <a href="admin.php?page=wysija_campaigns&id=<?php echo $dupid ?>&email_id=<?php echo $row['email_id'] ?>&action=duplicate&_wpnonce=<?php echo $this->secure(array("action" => "duplicate", "id" => $dupid), true); ?>" class="submitedit"><?php _e('Duplicate', WYSIJA) ?></a> 
  455. </span> 
  456. | <span class="delete"> 
  457. <a href="<?php echo $data['base_url'] ?>&id=<?php echo $deleteId ?>&action=delete<?php echo $deleteAction ?>&_wpnonce=<?php echo $this->secure(array('action' => 'delete' . $deleteAction, 'id' => $deleteId), true); ?>" class="submitdelete"><?php _e('Delete', WYSIJA) ?></a> 
  458. </span> 
  459. <?php 
  460. } else { 
  461.  
  462. if ($row["status"] == -1) { 
  463. ?> 
  464. | <span class="edit"><a href="admin.php?page=wysija_campaigns&id=<?php echo $row['email_id'] ?>&action=<?php echo $editStep ?>" class="submitedit"><?php _e('Edit', WYSIJA) ?></a></span> 
  465. <?php 
  466. if (isset($data['sent'][$row["email_id"]]['to']) && $data['sent'][$row["email_id"]]['to'] > 0) { 
  467. ?> 
  468.  
  469. | <span class="viewstats"> 
  470. <a href="admin.php?page=wysija_campaigns&id=<?php echo $row["email_id"] ?>&action=viewstats" class="stats"><?php _e('Stats', WYSIJA) ?></a> 
  471. </span> 
  472.  
  473. <?php } 
  474. ?> 
  475. | <span class="duplicate"> 
  476. <a href="admin.php?page=wysija_campaigns&id=<?php echo $dupid ?>&email_id=<?php echo $row['email_id'] ?>&action=duplicate&_wpnonce=<?php echo $this->secure(array("action" => "duplicate", "id" => $dupid), true); ?>" class="submitedit"><?php _e('Duplicate', WYSIJA) ?></a> 
  477. </span> 
  478. | <span class="delete"> 
  479. <a href="<?php echo $data['base_url'] ?>&id=<?php echo $deleteId ?>&action=delete<?php echo $deleteAction ?>&_wpnonce=<?php echo $this->secure(array("action" => "delete" . $deleteAction, "id" => $deleteId), true); ?>" class="submitdelete"><?php _e('Delete', WYSIJA) ?></a> 
  480. </span> 
  481. <?php 
  482. } else { 
  483. if ($row['type'] == 2) { 
  484. ?> 
  485. | <span class="edit"> 
  486. <a href="admin.php?page=wysija_campaigns&id=<?php echo $row["email_id"] ?>&action=pause&_wpnonce=<?php echo $this->secure(array('action' => 'pause' , 'id' => $row["email_id"]), true); ?>" class="submitedit pause-edit"><?php _e('Edit', WYSIJA) ?></a> 
  487. </span> 
  488. <?php 
  489. if (isset($data['sent'][$row["email_id"]]['to']) && $data['sent'][$row["email_id"]]['to'] > 0) { 
  490. ?> 
  491.  
  492. | <span class="viewstats"> 
  493. <a href="admin.php?page=wysija_campaigns&id=<?php echo $row["email_id"] ?>&action=viewstats" class="stats"><?php _e('Stats', WYSIJA) ?></a> 
  494. </span> 
  495.  
  496. <?php 
  497. ?> 
  498. | <span class="duplicate"> 
  499. <a href="admin.php?page=wysija_campaigns&id=<?php echo $dupid ?>&email_id=<?php echo $row["email_id"] ?>&action=duplicate&_wpnonce=<?php echo $this->secure(array("action" => "duplicate", "id" => $dupid), true); ?>" class="submitedit"><?php _e('Duplicate', WYSIJA) ?></a> 
  500. </span> 
  501. | <span class="delete"> 
  502. <a href="<?php echo $data['base_url'] ?>&id=<?php echo $deleteId ?>&action=delete<?php echo $deleteAction ?>&_wpnonce=<?php echo $this->secure(array("action" => "delete" . $deleteAction, "id" => $deleteId), true); ?>" class="submitdelete"><?php _e('Delete', WYSIJA) ?></a> 
  503. </span> 
  504. <?php 
  505. ?> 
  506. </div> 
  507. </td> 
  508. <td><?php 
  509. switch ((int) $row['status']) { 
  510. case 99: 
  511. case 3: 
  512. case 2: 
  513. case 1: 
  514. // automatic newsletters 
  515. if ($row['type'] == 2) { 
  516. $pause = ''; 
  517. // non immediate post notifications 
  518. if (isset($row['params']['autonl']['event']) && $row['params']['autonl']['event'] == 'new-articles' && $row['params']['autonl']['when-article'] != 'immediate') { 
  519.  
  520.  
  521. //if the next send value of the post notification newsletter is not set or 
  522. if (!isset($row['params']['autonl']['nextSend'])) { 
  523. $nextSend = false; 
  524. //find a way to update the missing next send without triggerring a give_birth 
  525. } else { 
  526. $nextSend = $row['params']['autonl']['nextSend']; 
  527.  
  528. $helper_toolbox = WYSIJA::get('toolbox', 'helper'); 
  529. $time = $helper_toolbox->localtime($row['params']['autonl']['time'], true); 
  530. $dayname = $helper_toolbox->getday($row['params']['autonl']['dayname']); 
  531. $daynumber = $helper_toolbox->getdaynumber($row['params']['autonl']['daynumber']); 
  532. $weeknumber = $helper_toolbox->getweeksnumber($row['params']['autonl']['dayevery']); 
  533. $durationsent = ''; 
  534. if ($nextSend) { 
  535. $timeleft = $helper_toolbox->localtime_to_servertime($nextSend) - time(); 
  536.  
  537. $scheduled_on = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $nextSend); 
  538. if ($timeleft < (3600 * 24)) { 
  539. $timeleft = $helper_toolbox->duration_string($timeleft, true, 2); 
  540. $durationsent = '<span title="' . $scheduled_on . '">' . sprintf(__('Next send out in %1$s', WYSIJA), $timeleft) . '</span>'; 
  541. } else { 
  542. $timeleft = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $nextSend); 
  543. $durationsent = sprintf(__('Next send out on %1$s', WYSIJA), $timeleft); 
  544.  
  545.  
  546. switch ($row['params']['autonl']['when-article']) { 
  547. case 'daily': 
  548. $statussent = sprintf(__('Sent daily at %1$s.', WYSIJA), $time); 
  549. break; 
  550. case 'weekly': 
  551. $statussent = sprintf(__('Sent weekly on %1$s at %2$s', WYSIJA), $dayname, $time); 
  552. break; 
  553. case 'monthly': 
  554. $statussent = sprintf(__('Sent monthly on the %1$s at %2$s', WYSIJA), $daynumber, $time); 
  555. break; 
  556. case 'monthlyevery': 
  557. $statussent = sprintf(__('Sent monthly on the %1$s %2$s at %3$s', WYSIJA), $weeknumber, $dayname, $time); 
  558. break; 
  559.  
  560. echo '<p>' . $statussent . '</p>'; 
  561.  
  562. echo '<p>' . $durationsent . ' (' . __('if there\'s new content', WYSIJA) . ')</p>'; 
  563. if (isset($row['params']['autonl']['late_send']) && WYSIJA_DBG > 1) { 
  564. $last_send = $late_send = 0; 
  565. if(!empty($row['params']['autonl']['late_send'])) $late_send = $row['params']['autonl']['late_send']; 
  566. $late_send = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $late_send); 
  567.  
  568. if(!empty($row['params']['autonl']['lastSend'])) $last_send = $row['params']['autonl']['lastSend']; 
  569. $last_send = date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $last_send); 
  570. echo '<p>' . sprintf('The last scheduled send due on %1$s was late and postponed.', $late_send) . '</p>'; 
  571. echo '<p>' . sprintf('The last executed send was on : %1$s ', $last_send) . '</p>'; 
  572.  
  573. echo $pause; 
  574. } else { 
  575. // autoresponders and immediate post notifications 
  576. $delay = ''; 
  577. if (!isset($row['params']['autonl']['numberafter'])) 
  578. $numberafter = 0; 
  579. else { 
  580. $numberafter = (int) $row['params']['autonl']['numberafter']; 
  581. $delay = $numberafter . ' ' . $data['autonl']['fields']['numberofwhat']['valuesunit'][$row['params']['autonl']['numberofwhat']]; 
  582.  
  583.  
  584. $statustext = $this->getSendingStatus($row, $data, $numberafter, $delay); 
  585. echo $statustext . $pause . $this->dataBatches($data, $row, $pause, $statuses, true); 
  586. } else { 
  587. // standard emails 
  588. $pause = ' <a href="admin.php?page=wysija_campaigns&id=' . $row['email_id'] . '&action=pause&_wpnonce='.$this->secure(array('action' => 'pause' , 'id' => $row["email_id"]), true).'" class="submitedit button">' . __("Pause", WYSIJA) . '</a>'; 
  589. echo $this->dataBatches($data, $row, $pause, $statuses); 
  590.  
  591. break; 
  592. case -1: 
  593. if ($row['type'] == 2) { 
  594. $resumelink = __('Not active.', WYSIJA) . ' | <a href="admin.php?page=wysija_campaigns&id=' . $row['email_id'] . '&action=resume&_wpnonce='.$this->secure(array('action' => 'resume' , 'id' => $row["email_id"]), true).'" class="submitedit">' . __('Activate', WYSIJA) . '</a>'; 
  595. echo $resumelink; 
  596. } else { 
  597. $resumelink = '<a href="admin.php?page=wysija_campaigns&id=' . $row['email_id'] . '&action=resume&_wpnonce='.$this->secure(array('action' => 'resume' , 'id' => $row["email_id"]), true).'" class="submitedit">' . __('Resume', WYSIJA) . '</a>'; 
  598. echo sprintf($statuses[$row['status']], $data['sent'][$row['email_id']]['to'], $data['sent'][$row['email_id']]['total']); 
  599. echo ' | ' . $resumelink; 
  600.  
  601. break; 
  602. case 4: 
  603. case 0: 
  604. if ($statusshared) 
  605. echo $statusshared; 
  606. else { 
  607. if ($row["type"] == 2) 
  608. echo __('Not active.', WYSIJA); 
  609. else 
  610. echo __('Not sent yet.', WYSIJA); //$statuses[$row["status"]]; 
  611. break; 
  612. ?></td> 
  613. <td><?php 
  614. if (($row['type'] == 2 && isset($row['params']['autonl']['event']) && $row['params']['autonl']['event'] == 'subs-2-nl')) { 
  615. $row['lists'] = $data['lists'][$row['params']['autonl']['subscribetolist']]['name']; 
  616.  
  617. if (isset($row['lists'])) 
  618. echo $row['lists']; 
  619. else 
  620. echo $messageListEdit; 
  621. ?></td> 
  622.  
  623. <td> 
  624. <?php if (isset($row['stats'])) echo $row['stats']; elseif ($row['status'] != 0) { ?> 
  625. <a href="admin.php?page=wysija_campaigns&id=<?php echo $row["email_id"] ?>&action=viewstats" class="stats" title="<?php echo $row['number_opened'] . ' - ' . $row['number_clicked'] . ' - ' . $row['number_unsub']; ?>"> 
  626. <?php echo $row['rate_opened'] . '% - ' . $row['rate_clicked'] . '% - ' . $row['rate_unsub'] . '%'; ?> 
  627. </a> 
  628. <?php } ?> 
  629. </td> 
  630. <td title='<?php echo $this->fieldListHTML_created_at_time($row['modified_at'], get_option('date_format') . ' ' . get_option('time_format')); ?>'><?php echo $this->fieldListHTML_created_at($row['modified_at']); ?></td> 
  631. <td title='<?php echo $this->fieldListHTML_created_at_time($row['sent_at'], get_option('date_format') . ' ' . get_option('time_format')); ?>'><?php echo $this->fieldListHTML_created_at($row['sent_at']); ?> 
  632. <?php 
  633. if (WYSIJA_DBG > 1) { 
  634. echo '<p>' . $row['sent_at'] . '</p>'; 
  635. ?></td> 
  636. </tr><?php 
  637. $alt = !$alt; 
  638. ?> 
  639.  
  640. </tbody> 
  641. </table> 
  642. </div> 
  643.  
  644. <?php 
  645. echo $hiddenOrder; 
  646.  
  647. function getSendingStatus($row, $data, $numberafter, $delay) { 
  648. $statustext = false; 
  649. if (isset($row['msgSendSuspended'])) { 
  650. $statustext = $row['msgSendSuspended']; 
  651. } else { 
  652. switch ($row["params"]['autonl']['event']) { 
  653. case 'new-articles': 
  654.  
  655. $statustext = __('Send immediately.', WYSIJA); 
  656. break; 
  657. case 'subs-2-nl': 
  658. $list = ''; 
  659. if (isset($data['autonl']['fields']['subscribetolist']['values'][$row["params"]['autonl']['subscribetolist']])) 
  660. $list = '<em>"' . $data['autonl']['fields']['subscribetolist']['values'][$row["params"]['autonl']['subscribetolist']] . '"</em>'; 
  661.  
  662. if ($numberafter < 1 || $row["params"]['autonl']['numberofwhat'] == 'immediate') 
  663. $statustext = sprintf(__('Sending immediately after someone subscribes to the mailing list %1$s', WYSIJA), $list); 
  664. else 
  665. $statustext = sprintf(__('Sent %2$s after someone subscribes to the mailing list %1$s', WYSIJA), $list, '<strong>' . $delay . '</strong>'); 
  666. break; 
  667. // Auto newsletter when new user is added to WordPress. 
  668. case 'new-user': 
  669. // Make the "any" word translatable. 
  670. $roles = $row["params"]['autonl']['roles']; 
  671. if ($roles === 'any') { 
  672. $roles = __('any role', WYSIJA); 
  673. if ($numberafter < 1 || $row["params"]['autonl']['numberofwhat'] == 'immediate') { 
  674. // Send immediately on subscription. 
  675. $statustext = sprintf(__('Sent immediately after a new user is added to your site as %1$s.', WYSIJA), '<b>' . $roles . '</b>'); 
  676. } else { 
  677. // Send with delay. 
  678. $statustext = sprintf(__('Sent %2$s after a new user is added to your site as %1$s.', WYSIJA), '<b>' . $roles . '</b>', '<strong>' . $delay . '</strong>'); 
  679. break; 
  680. default: 
  681. //try to see if the plugin returns something 
  682. $functioname = str_replace('-', '_', $row["params"]['autonl']['event']) . '_sendingStatus'; 
  683. if (function_exists($functioname)) 
  684. $statustext = call_user_func($functioname, $row["params"]['autonl'], $numberafter, $delay); 
  685. if (!$statustext) 
  686. $statustext = __('Sending per event', WYSIJA); 
  687.  
  688. return $statustext; 
  689.  
  690. function sending_process() { 
  691. $config = WYSIJA::get("config", "model"); 
  692. if ((int) $config->getValue('total_subscribers') < 2000) 
  693. return true; 
  694. return false; 
  695.  
  696. function dataBatches($data, $row, $pause, $statuses, $pending = false) { 
  697. $sentto = $senttotal = $sentleft = 0; 
  698. $return = '<div>'; 
  699. if (isset($data['sent'][$row["email_id"]]['to'])) 
  700. $sentto = $data['sent'][$row["email_id"]]['to']; 
  701. if (isset($data['sent'][$row["email_id"]]['total'])) 
  702. $senttotal = $data['sent'][$row["email_id"]]['total']; 
  703. if (isset($data['sent'][$row["email_id"]]['left'])) 
  704. $sentleft = $data['sent'][$row["email_id"]]['left']; 
  705.  
  706. $statusdata = $senttohowmany = ''; 
  707. if ($row['type'] != 2) 
  708. $statusdata = sprintf($statuses[$row["status"]], $sentto, $senttotal); 
  709. elseif ($row['params']['autonl']['event'] != 'new-articles') 
  710. $return.=sprintf(__('Sent to %1$s subscribers.', WYSIJA), $sentto) . ' '; 
  711.  
  712. if ($sentleft > 0) { 
  713.  
  714. $config = WYSIJA::get('config', 'model'); 
  715. add_filter('wysija_send_ok', array($this, 'sending_process')); 
  716. $letsgo = apply_filters('wysija_send_ok', false); 
  717.  
  718. if ($letsgo) { 
  719.  
  720. $helper_toolbox = WYSIJA::get('toolbox', 'helper'); 
  721.  
  722. // Standard newsletter. Let's show the progress bar. 
  723. if ($row['type'] != 2) { 
  724.  
  725. $percent_status = round(($sentto * 100) / $senttotal); 
  726.  
  727. $return .= '<p><strong>'; 
  728.  
  729. if($data['sent'][$row['email_id']]['remaining_time'] < 1) { 
  730. $return .= __('The last batch of emails should start sending automatically in the next few minutes.', WYSIJA); 
  731. }else{ 
  732. $return .= sprintf(__('Time remaining: %1$s', WYSIJA), $helper_toolbox->duration_string($data['sent'][$row['email_id']]['remaining_time'], true, 4, 4)); 
  733.  
  734. $return .= '</strong></p>'; 
  735. $return .= '<div class="progress_bar">'; 
  736. $return .= '<div class="bar">'; 
  737. $return .= '<div class="progress" style="width: ' . $percent_status . '%">'; 
  738. $return .= '</div>'; 
  739. $return .= '<div class="percent">'; 
  740. $return .= $sentto . ' / ' . $senttotal; 
  741. $return .= '</div>'; 
  742. $return .= '</div>'; 
  743. $return .= $pause; 
  744. $return .= '</div>'; 
  745. $return .= '<div class="info-stats">'; 
  746.  
  747. $is_multisite = is_multisite(); 
  748.  
  749. //$is_multisite=true;//PROD comment that line 
  750. if ($is_multisite && $config->getValue('sending_method') == 'network') { 
  751. $sending_emails_number = (int) $config->getValue('ms_sending_emails_number'); 
  752. } else { 
  753. $sending_emails_number = (int) $config->getValue('sending_emails_number'); 
  754.  
  755. if ($sentleft > $sending_emails_number) 
  756. $nextBatchnumber = $sending_emails_number; 
  757. else 
  758. $nextBatchnumber = (int) $sentleft; 
  759.  
  760. //Next batch of xx emails will be sent in xx minutes. Don't wait & send right now. 
  761. if ($pending) { 
  762. $return.= '<span style="color:#555"><a href="admin.php?page=wysija_campaigns&action=manual_send&emailid=' . $row['email_id'] . '&pending=1&_wpnonce='.$this->secure(array('action' => 'manual_send'), true).'" title="view pending" class="action-send-test-editor" >' . sprintf(__(' %1$s email(s) scheduled.', WYSIJA) . '</a>', $sentleft); 
  763. $return.= '</span>'; 
  764. } else { 
  765. if ($data['sent'][$row['email_id']]['running_for']) { 
  766. $return.= sprintf(__('Latest batch was sent %1$s ago.', WYSIJA), $data['sent'][$row['email_id']]['running_for']); 
  767. } else { 
  768. $time_remaining = trim($helper_toolbox->duration_string($data['sent'][$row['email_id']]['next_batch'], true, 4)); 
  769. $return.= '<a href="admin.php?page=wysija_campaigns&action=manual_send&emailid=' . $row['email_id'] . '&_wpnonce='.$this->secure(array('action' => 'manual_send'), true).'" class="action-send-test-editor" >' . __('Don\'t wait & send right now.', WYSIJA) . '</a>'; 
  770. } else { 
  771. $return.= $statusdata; 
  772. $helper_licence = WYSIJA::get('licence', 'helper'); 
  773. $url_checkout = $helper_licence->get_url_checkout('resume_send'); 
  774.  
  775. $link = str_replace( 
  776. array('[link]', '[/link]'), array('<a title="' . __('Get Premium now', WYSIJA) . '" target="_blank" href="' . $url_checkout . '">', '</a>'), __('To resume send [link]Go premium now![/link]', WYSIJA)); 
  777. $return.= '<p>' . $link . '</p>'; 
  778. else 
  779. $return.= $statusdata; 
  780. $return.='</div>'; 
  781. return $return; 
  782.  
  783. function linkStats($result, $data) { 
  784. $result = '<ol>'; 
  785. $countloop = 0; 
  786. $helper_licence = WYSIJA::get('licence', 'helper'); 
  787. $url_checkout = $helper_licence->get_url_checkout('count_click_stats'); 
  788. foreach ($data['clicks'] as $click) { 
  789. if ($countloop == 0) 
  790. $label = str_replace(array('[link]', '[/link]'), array('<a class="premium-tab" target="_blank" href="' . $url_checkout . '">', '</a>'), __('see links with a [link]Premium licence[/link].', WYSIJA)); 
  791. else 
  792. $label = '...'; 
  793.  
  794. $css_class = 'stats-url-link'; 
  795. if (!empty($_REQUEST['url_id']) && $_REQUEST['url_id'] == $click['url_id']) 
  796. $css_class .= ' select'; 
  797.  
  798. $link = 'admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id'] . '&url_id=' . $click['url_id']; 
  799. $result.='<li><a href="' . $link . '" class="' . $css_class . '">' . $click['name'] . '</a> : ' . $label . '</li>'; 
  800. $countloop++; 
  801. $result.='</ol>'; 
  802. return $result; 
  803.  
  804. /** 
  805. * main view 
  806. */ 
  807.  
  808. function viewstats($data) { 
  809. $this->icon = 'icon-stats'; 
  810. $this->search['title'] = __('Search recipients', WYSIJA); 
  811. ?> 
  812. <?php if (!empty($data['hooks']['hook_newsletter_top'])) { ?> 
  813. <div id="hook_newsletter_top" class="hook clear"><?php echo $data['hooks']['hook_newsletter_top']; ?></div> 
  814. <?php } ?> 
  815. <?php 
  816. echo '<div style="clear:both;"></div>'; 
  817. echo '<form method="post" action="" id="posts-filter">'; 
  818. $this->filtersLink($data); 
  819. $this->filterDDPVIEW($data); 
  820. ?> 
  821. <div class="list"> 
  822. <table cellspacing="0" class="widefat fixed"> 
  823. <thead> 
  824. <?php 
  825. $umstatussorting = $statussorting = $fnamesorting = $lnamesorting = $usrsorting = $datesorting = " sortable desc"; 
  826. $hiddenOrder = ""; 
  827. if (isset($_REQUEST["orderby"])) { 
  828. switch ($_REQUEST["orderby"]) { 
  829. case "email": 
  830. $usrsorting = " sorted " . $_REQUEST["ordert"]; 
  831. break; 
  832. case "opened_at"://default stat view 
  833. case "created_at"://queue stat view 
  834. case "clicked_at"://filter by url view 
  835. $datesorting = " sorted " . $_REQUEST["ordert"]; 
  836. break; 
  837. case "ustatus": 
  838. $statussorting = " sorted " . $_REQUEST["ordert"]; 
  839. break; 
  840. case "umstatus": 
  841. $umstatussorting = " sorted " . $_REQUEST["ordert"]; 
  842. break; 
  843. $hiddenOrder = '<input type="hidden" name="orderby" id="wysija-orderby" value="' . esc_attr($_REQUEST["orderby"]) . '"/>'; 
  844. $hiddenOrder.='<input type="hidden" name="ordert" id="wysija-ordert" value="' . esc_attr($_REQUEST["ordert"]) . '"/>'; 
  845. $header = '<tr class="thead"> 
  846. <th class="manage-column column-username' . $usrsorting . '" id="email" scope="col" style="width:140px;"><a href="#" class="orderlink" ><span>' . __('Email', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  847. /** $header.='<th class="manage-column column-fname'.$fnamesorting.'" id="firstname" scope="col" style="width:80px;">'.__('First name', WYSIJA).'</th> 
  848. <th class="manage-column column-lname'.$lnamesorting.'" id="lastname" scope="col" style="width:80px;">'.__('Last name', WYSIJA).'</th>'; */ 
  849. $header.='<th class="manage-column column-umstatus' . $umstatussorting . '" id="umstatus" scope="col" style="width:80px;"><a href="#" class="orderlink" ><span>' . __('Email Status', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  850. $header.='<th class="manage-column column-list-names" id="list-list" scope="col">' . __('Lists', WYSIJA) . '</th>'; 
  851. $header.='<th class="manage-column column-ustatus' . $statussorting . '" id="ustatus" scope="col" style="width:80px;"><a href="#" class="orderlink" ><span>' . __('Subscriber Status', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  852. /** $header.='<th class="manage-column column-emails" id="emails-list" scope="col">'.__('Emails', WYSIJA).'</th> 
  853. <th class="manage-column column-opened" id="opened-list" scope="col">'.__('Opened', WYSIJA).'</th> 
  854. <th class="manage-column column-clic" id="clic-list" scope="col">'.__('Clicked', WYSIJA).'</th>'; */ 
  855. if (empty($data['tableQuery'])) 
  856. $data['tableQuery'] = ''; 
  857. switch ($data['tableQuery']) { 
  858. case 'email_user_url': 
  859. $header.='<th class="manage-column column-date' . $datesorting . '" id="clicked_at" scope="col"><a href="#" class="orderlink" ><span>' . __('Clicked on', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  860. break; 
  861. case 'email_user_stat': 
  862. $label = __('Opened date', WYSIJA); 
  863. if (!empty($_REQUEST['link_filter']) && $_REQUEST['link_filter'] == 'clicked') 
  864. $label = __('Clicked on', WYSIJA); 
  865. $header.='<th class="manage-column column-date' . $datesorting . '" id="opened_at" scope="col"><a href="#" class="orderlink" ><span>' . $label . '</span><span class="sorting-indicator"></span></a></th>'; 
  866. break; 
  867. case 'queue': 
  868. default: 
  869. $header.='<th class="manage-column column-date' . $datesorting . '" id="created_at" scope="col"><a href="#" class="orderlink" ><span>' . __('Subscribed on', WYSIJA) . '</span><span class="sorting-indicator"></span></a></th>'; 
  870. break; 
  871. $header .= '</tr>'; 
  872. echo $header; 
  873. ?> 
  874. </thead> 
  875. <tfoot> 
  876. <?php 
  877. echo $header; 
  878. ?> 
  879. </tfoot> 
  880.  
  881. <tbody class="list:<?php echo $this->model->table_name . ' ' . $this->model->table_name . '-list'; ?>" id="wysija-<?php echo $this->model->table_name; ?>"> 
  882. <?php 
  883. $listingRows = ''; 
  884. $alt = true; 
  885.  
  886. $statuses = array("-1" => __("Unsubscribed", WYSIJA), "0" => __("Unconfirmed", WYSIJA), "1" => __("Subscribed", WYSIJA)); 
  887. $config = WYSIJA::get("config", "model"); 
  888. if (!$config->getValue("confirm_dbleoptin")) 
  889. $statuses["0"] = $statuses["1"]; 
  890.  
  891.  
  892. $mstatuses = array('-2' => $this->getTransStatusEmail('notsent'), '-1' => $this->getTransStatusEmail('bounced'), '0' => $this->getTransStatusEmail('sent') 
  893. , '1' => $this->getTransStatusEmail('opened'), '2' => $this->getTransStatusEmail('clicked'), '3' => $this->getTransStatusEmail('unsubscribe')); 
  894. //dbg($data, false); 
  895. foreach ($data['subscribers'] as $row) { 
  896. $classRow = ''; 
  897. if ($alt) 
  898. $classRow = ' class="alternate" '; 
  899.  
  900. echo '<tr ' . $classRow . ' >'; 
  901. echo '<td class="username column-username">'; 
  902. echo get_avatar($row['email'], 32); 
  903. echo '<strong>' . $row['email'] . '</strong>'; 
  904. echo '<p style="margin:0;">' . $row['lastname'] . ' ' . $row['firstname'] . '</p>'; 
  905.  
  906.  
  907. echo '<div class="row-actions"> 
  908. <span class="edit"> 
  909. <a href="admin.php?page=wysija_subscribers&id=' . $row['user_id'] . '&action=edit" class="submitedit">' . __('View stats or edit', WYSIJA) . '</a> 
  910. </span> 
  911. </div>'; 
  912.  
  913. echo '</td>'; 
  914. /** <td><?php echo $row["firstname"] ?></td> 
  915. <td><?php echo $row["lastname"] ?></td> */ 
  916. ?> 
  917. <td><?php echo $mstatuses[$row["umstatus"]]; ?></td> 
  918. <td><?php if (isset($row["lists"])) echo $row["lists"] ?></td> 
  919. <td><?php echo $statuses[$row["ustatus"]]; ?></td> 
  920. <?php /** <td><?php echo $row["emails"] ?></td> 
  921. <td><?php echo $row["opened"] ?></td> 
  922. <td><?php echo $row["clicked"] ?></td> */ ?> 
  923. <td> 
  924. <?php 
  925. if (empty($data['tableQuery'])) 
  926. $data['tableQuery'] = ''; 
  927. switch ($data['tableQuery']) { 
  928. case 'email_user_url': 
  929. echo $this->fieldListHTML_created_at_time($row["clicked_at"]); 
  930. break; 
  931. case 'email_user_stat': 
  932. echo $this->fieldListHTML_created_at_time($row["opened_at"]); 
  933. break; 
  934. case 'queue': 
  935. default: 
  936. if (isset($row['created_at'])) 
  937. echo $this->fieldListHTML_created_at_time($row['created_at']); 
  938. break; 
  939. ?> 
  940. </td> 
  941. <?php 
  942. echo '</tr>'; 
  943. $alt = !$alt; 
  944. ?> 
  945. </tbody> 
  946. </table> 
  947. </div> 
  948.  
  949. <?php 
  950. echo $hiddenOrder; 
  951. $this->limitPerPage(); 
  952. echo '</form>'; 
  953. ?> 
  954. <?php if (!empty($data['hooks']['hook_newsletter_bottom'])) { ?> 
  955. <div id="hook_newsletter_bottom" class="hook"> 
  956. <?php echo $data['hooks']['hook_newsletter_bottom']; ?> 
  957. </div> 
  958. <?php 
  959.  
  960. /** when creating a newsletter or when editing as a draft */ 
  961.  
  962. function add($data = false) { 
  963.  
  964. $this->data = $data; 
  965. $step = array(); 
  966.  
  967. $step['type'] = array( 
  968. 'type' => 'type_nl',  
  969. 'class' => 'validate[required]',  
  970. 'label' => __('What type of newsletter is this?', WYSIJA),  
  971. 'labeloff' => 1,  
  972. 'desc' => ''); 
  973.  
  974. $step['params'] = array( 
  975. 'type' => 'frequencies',  
  976. 'label' => __('Automatically sent...', WYSIJA), 'class' => 'validate[required]',  
  977. 'desc' => '',  
  978. 'labeloff' => 1,  
  979. 'rowclass' => 'automatic-nl'); 
  980.  
  981.  
  982. $step['subject'] = array( 
  983. 'type' => 'subject',  
  984. 'label' => __('Subject line', WYSIJA),  
  985. 'class' => 'validate[required]',  
  986. 'desc' => __("This is the subject of the email. Be creative since it's the first thing your subscribers will see.", WYSIJA)); 
  987.  
  988. if ($this->data['lists']) { 
  989. $step['lists'] = array( 
  990. 'type' => 'lists',  
  991. 'class' => 'validate[minCheckbox[1]] checkbox',  
  992. 'rowclass' => 'listcheckboxes',  
  993. 'label' => __('Lists', WYSIJA),  
  994. 'labeloff' => 1); 
  995.  
  996.  
  997.  
  998.  
  999.  
  1000. if (!isset($msg['browsermsg'])) { 
  1001. ?> 
  1002. <div id="browsernotsupported" class="updated" style="display:none;"> 
  1003. <?php 
  1004. echo str_replace( 
  1005. array("[/linkchrome]", "[/linkff]", "[/linkie]", "[/linksafari]", "[/link_ignore]",  
  1006. "[linkchrome]", "[linkff]", "[linkie]", "[linksafari]", "[link_ignore]"), array("</a>", "</a>", "</a>", "</a>", "</a>",  
  1007. '<a href="http://www.google.com/chrome/" target="_blank">', '<a href="http://www.getfirefox.com" target="_blank">', '<a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home" target="_blank">', '<a href="http://www.apple.com/safari/download/" target="_blank">', '<a class="linkignore browsermsg" href="javascript:;">'), __("Yikes! Your browser might not be supported. Get the latest [linkchrome]Chrome[/linkchrome], [linkff]Firefox[/linkff], [linkie]Internet Explorer[/linkie] or [linksafari]Safari[/linksafari]. It seems to work?[link_ignore]Dismiss[/link_ignore].", WYSIJA)); 
  1008. ?> 
  1009. </div> 
  1010. <?php 
  1011. ?> 
  1012. <form name="step1" method="post" id="campaignstep3" action="" class="form-valid"> 
  1013.  
  1014. <table class="form-table"> 
  1015. <tbody> 
  1016. <?php 
  1017. //dbg($data); 
  1018. echo $this->buildMyForm($step, $data, "email", true); 
  1019. ?> 
  1020. </tbody> 
  1021. </table> 
  1022.  
  1023. <?php 
  1024. $this->model->table_name = 'email'; 
  1025. $this->model->pk = 'email_id'; 
  1026.  
  1027. if (isset($data['email']['type']) && $data['email']['type'] == 2) 
  1028. $this->immediatewarning = '<input type="submit" id="save-reactivate" value="' . __("Save and reactivate", WYSIJA) . '" name="save-reactivate" class="button-primary wysija"/>' . $this->immediatewarning; 
  1029.  
  1030. $this->_savebuttonsecure($data, "savecamp", __("Next step", WYSIJA), $this->immediatewarning); 
  1031. ?> 
  1032.  
  1033. </form> 
  1034. <?php 
  1035.  
  1036. function editTemplate($data=false) { 
  1037. wp_print_styles('editor-buttons'); 
  1038.  
  1039. $wjEngine = WYSIJA::get('wj_engine', 'helper'); 
  1040.  
  1041. if (isset($data['email']['wj_data'])) { 
  1042. $wjEngine->setData($data['email']['wj_data'], true); 
  1043. } else { 
  1044. $wjEngine->setData(); 
  1045. if (isset($data['email']['wj_styles'])) { 
  1046. $wjEngine->setStyles($data['email']['wj_styles'], true); 
  1047. } else { 
  1048. $wjEngine->setStyles(); 
  1049.  
  1050. ?> 
  1051. <style type="text/css" id="wj_css"> 
  1052. <?php echo $wjEngine->renderStyles(); ?> 
  1053. </style> 
  1054.  
  1055. <!-- BEGIN: Wysija Editor --> 
  1056. <?php echo $wjEngine->renderEditor(); ?> 
  1057. <!-- END: Wysija Editor --> 
  1058.  
  1059. <?php $defaultData = $wjEngine->getDefaultData(); ?> 
  1060. <div id="wysija_default_header" style="display:none;"><?php echo $wjEngine->renderEditorHeader($defaultData['header']); ?></div> 
  1061. <div id="wysija_default_footer" style="display:none;"><?php echo $wjEngine->renderEditorFooter($defaultData['footer']); ?></div> 
  1062. <div id="wysija_widgets_settings" style="display:none;"> 
  1063. <div class="autopost"><?php 
  1064. // if it's a post notification that should be sent immediately after an article is published, constrain to only 1 autopost with 1 post_limit 
  1065. if ((int) $data['email']['type'] === 2 && $data['email']['params']['autonl']['event'] === 'new-articles' && $data['email']['params']['autonl']['when-article'] === 'immediate') { 
  1066. print 'single'; 
  1067. } else { 
  1068. print 'multiple'; 
  1069. ?></div> 
  1070. <div class="divider"> 
  1071. <?php 
  1072. $params = $data['email']['params']; 
  1073.  
  1074. if(is_array($params) and isset($params['divider'])) { 
  1075. $divider = $params['divider']; 
  1076. } else { 
  1077. $divider = $defaultData['widgets']['divider']; 
  1078. echo $wjEngine->renderEditorBlock(array_merge(array('type' => 'divider', 'no-block' => true), $divider)); 
  1079. ?> 
  1080. </div> 
  1081. <div class="image"><?php print WYSIJA_EDITOR_IMG . "transparent.png"; ?></div> 
  1082. <div class="theme"><?php if (isset($data['email']['params']['theme'])) { 
  1083. print $data['email']['params']['theme']; 
  1084. } else { 
  1085. print 'default'; 
  1086. } ?> 
  1087. </div> 
  1088. </div> 
  1089.  
  1090. <!-- BEGIN: Wysija Toolbar --> 
  1091. <div id="wysija_toolbar"> 
  1092. <ul class="wysija_toolbar_tabs"> 
  1093. <li class="wjt-content"> 
  1094. <a class="selected" href="javascript:;" rel="content"><?php _e("Content", WYSIJA) ?></a> 
  1095. </li> 
  1096. <li class="wjt-images"><a href="javascript:;" rel="images"><?php _e("Images", WYSIJA) ?></a></li> 
  1097. <?php if (WYSIJA::current_user_can('wysija_style_tab')): ?> 
  1098. <li class="wjt-styles"><a href="javascript:;" rel="styles"><?php _e("Styles", WYSIJA) ?></a></li> 
  1099. <?php endif; ?> 
  1100. <?php if (WYSIJA::current_user_can('wysija_theme_tab')): ?> 
  1101. <li class="last wjt-themes"><a href="javascript:;" rel="themes"><?php _e("Themes", WYSIJA) ?></a></li> 
  1102. <?php endif; ?> 
  1103. </ul> 
  1104.  
  1105. <!-- CONTENT BAR --> 
  1106. <ul class="wj_content" style="display:block;"> 
  1107. <li class="notice"><?php _e('Drag the widgets below into your newsletter.', WYSIJA) ?></li> 
  1108. <li><a class="wysija_item" wysija_type="text"><?php _e('Titles & text', WYSIJA) ?></a></li> 
  1109. <?php if ((int) $data['email']['type'] === 1 || ((int) $data['email']['type'] === 2 && (empty($data['email']['params']['autonl']['event']) || $data['email']['params']['autonl']['event'] !== 'new-articles'))) { ?><li><a class="wysija_item" wysija_type="post"><?php _e('WordPress post', WYSIJA) ?></a></li><?php } ?> 
  1110. <?php if ((int) $data['email']['type'] === 2) { ?><li><a class="wysija_item" id="wysija-widget-autopost" wysija_type="popup-auto-post"><?php _e('Automatic latest content', WYSIJA) ?></a></li><?php } ?> 
  1111. <li> 
  1112. <a class="wysija_item" wysija_type="divider" wysija_src="<?php echo $divider['src'] ?>" wysija_width="<?php echo $divider['width'] ?>" wysija_height="<?php echo $divider['height'] ?>"><?php _e('Divider', WYSIJA) ?></a> 
  1113. <a id="wysija_divider_settings" class="wysija_item_settings settings" title="<?php _e('Edit', WYSIJA); ?>" href="javascript:;" href2="admin.php?page=wysija_campaigns&action=dividers&tab=dividers&emailId=<?php echo $_REQUEST['id'] ?>"><span class="dashicons dashicons-admin-generic"></span></a> 
  1114. </li> 
  1115. <li><a class="wysija_item" wysija_type="popup-bookmark"><?php _e('Social bookmarks', WYSIJA) ?></a></li> 
  1116. </ul> 
  1117.  
  1118. <!-- IMAGES BAR --> 
  1119. <div class="wj_images" style="display:none;"> 
  1120. <div class="wj_button"> 
  1121. <?php 
  1122. if (version_compare(get_bloginfo('version'), '3.3.0') >= 0) { 
  1123. $action = 'special_new_wordp_upload'; 
  1124. } else { 
  1125. $action = 'special_wordp_upload'; 
  1126. ?> 
  1127. <a id="wysija-upload-browse" class="button" href="javascript:;" href2="admin.php?page=wysija_campaigns&action=medias&tab=<?php echo $action; ?>&emailId=<?php echo $_REQUEST['id'] ?>"><?php _e('Add Images', WYSIJA) ?></a> 
  1128. </div> 
  1129.  
  1130. <ul id="wj-images-quick" class="clearfix"> 
  1131. <?php 
  1132. //get list images from template 
  1133. $helper_image = WYSIJA::get('image', 'helper'); 
  1134. $result = $helper_image->get_list_directory(); 
  1135.  
  1136. $quick_select = $data['email']['params']; 
  1137. if(!isset($quick_select['quickselection'])) { 
  1138. $quick_select['quickselection'] = array(); 
  1139. }else{ 
  1140. foreach($quick_select['quickselection'] as &$image) { 
  1141. $image = $helper_image->valid_image($image); 
  1142.  
  1143. if($result && empty($quick_select['quickselection'])) { 
  1144. echo $wjEngine->renderImages($result); 
  1145. } else { 
  1146. echo $wjEngine->renderImages($quick_select['quickselection']); 
  1147. ?> 
  1148. </ul> 
  1149. <div id="wj_images_preview" style="display:none;"></div> 
  1150. </div> 
  1151.  
  1152. <!-- STYLES BAR --> 
  1153. <?php if (WYSIJA::current_user_can('wysija_style_tab')): ?> 
  1154. <div class="wj_styles" style="display:none;"> 
  1155. <form id="wj_styles_form" action="" method="post" accept-charset="utf-8"> 
  1156. <?php 
  1157. echo $wjEngine->renderStylesBar(); 
  1158. ?> 
  1159. </form> 
  1160. </div> 
  1161. <?php endif; ?> 
  1162.  
  1163. <!-- THEMES BAR --> 
  1164. <?php if (WYSIJA::current_user_can('wysija_theme_tab')): ?> 
  1165. <div class="wj_themes" style="display:none;"> 
  1166. <div class="wj_button"> 
  1167. <a id="wysija-themes-browse" class="button" href="javascript:;" href2="admin.php?page=wysija_campaigns&action=themes"><?php _e('Add more themes', WYSIJA) ?></a> 
  1168. </div> 
  1169. <ul id="wj_themes_list" class="clearfix"> 
  1170. <?php 
  1171. //get themes 
  1172. echo $wjEngine->renderThemes(); 
  1173. ?> 
  1174. </ul> 
  1175. <div id="wj_themes_preview" style="display:none;"></div> 
  1176. </div> 
  1177. <?php endif; ?> 
  1178.  
  1179. <div id="wysija_notices"> 
  1180. <span id="wysija_notice_msg"> 
  1181. <?php echo __('Our toolbar doesn\'t load?', WYSIJA) ?> 
  1182. <br /> 
  1183. <?php 
  1184. echo str_replace(array('[link]', '[/link]'), array('<a title="' . __('Conflict', WYSIJA) . '" target="_blank" href="http://support.mailpoet.com/knowledgebase/list-of-plugins-that-may-cause-conflict/">', '</a>'), __('There must be an active 3rd party plugin or theme breaking our interface. [link]Read more.[/link]', WYSIJA)); 
  1185. ?> 
  1186. </span> 
  1187. <img alt="loader" id="ajax-loading" src="<?php echo WYSIJA_URL ?>img/wpspin_light.gif" /> 
  1188. </div> 
  1189. </div> 
  1190. <!-- END: Wysija Toolbar --> 
  1191. <?php 
  1192. global $current_user; 
  1193.  
  1194. $emailuser = $current_user->data->user_email; 
  1195. ?> 
  1196. <p><input type="text" name="receiver-preview" id="preview-receiver" value="<?php echo $emailuser ?>" /> <a href="javascript:;" id="wj-send-preview" class="button wysija"><?php _e("Send preview", WYSIJA) ?></a></p> 
  1197. <?php 
  1198. echo apply_filters('wysija_howspammy', ''); 
  1199. ?> 
  1200.  
  1201. <p class="submit"> 
  1202. <?php $this->secure(array('action' => "saveemail", 'id' => $data['email']['email_id'])); ?> 
  1203. <input data-type="<?php echo (int) $data['email']['type'] ?>" type="hidden" name="wysija[email][email_id]" id="email_id" value="<?php echo esc_attr($data['email']['email_id']) ?>" /> 
  1204. <input type="hidden" value="saveemail" name="action" /> 
  1205.  
  1206. <a id="wysija-do-save" class="button-primary wysija" href="javascript:;"><?php _e("Save changes", WYSIJA) ?></a> 
  1207. <a id="wysija-next-step" class="button-primary wysija" href="admin.php?page=wysija_campaigns&action=editDetails&id=<?php echo $data['email']['email_id'] ?>"><?php _e("Next step", WYSIJA) ?></a> 
  1208. <?php 
  1209. // we cannot have it everywhere 
  1210. if (false && $data && (int) $data['email']['type'] === 2) { 
  1211. echo '<a id="save-reactivate" class="button-primary wysija" href="admin.php?page=wysija_campaigns&action=resume&id='.$data['email']['email_id'].'&_wpnonce='.$this->secure(array('action' => 'resume' , 'id' => $data['email']["email_id"]), true).'">'.__("Save and reactivate", WYSIJA).'</a>'; 
  1212. ?> 
  1213. <?php echo '<a href="admin.php?page=wysija_campaigns&action=edit&id=' . $data['email']['email_id'] . '">' . __('go back to Step 1', WYSIJA) . '</a>' ?> 
  1214. </p> 
  1215.  
  1216. <!-- BEGIN: Wysija Toolbar --> 
  1217. <script type="text/javascript" charset="utf-8"> 
  1218. wysijaAJAX.id = <?php echo (int) $_REQUEST['id'] ?>; 
  1219.  
  1220. function saveWYSIJA(callback) { 
  1221. wysijaAJAX.task = 'save_editor'; 
  1222. wysijaAJAX._wpnonce = wysijanonces.campaigns.save_editor; 
  1223. wysijaAJAX.wysijaData = Wysija.save(); 
  1224. WYSIJA_SYNC_AJAX({success: callback}); 
  1225.  
  1226. // trigger the save on these links/buttons (save, next step, view in browser, unsubscribe) 
  1227. $$('#wysija-do-save, #wysija-next-step, #wysija_viewbrowser a, #wysija_unsubscribe a').invoke('observe', 'click', function(e) { 
  1228. if (this.id === 'wysija-next-step') { 
  1229. e.preventDefault(); 
  1230. var id = this.id,  
  1231. href = this.href; 
  1232. var callback = function () { 
  1233. if (id === 'wysija-next-step') window.location.href = href 
  1234. }; 
  1235. else var callback = function() {}; 
  1236. saveWYSIJA(callback); 
  1237. return false; 
  1238. }); 
  1239.  
  1240. function switchThemeWYSIJA(event) { 
  1241. // get event target 
  1242. var target = (event.currentTarget) ? event.currentTarget : event.srcElement.parentElement; 
  1243.  
  1244. if(window.confirm("<?php _e('If you confirm the theme switch, it will override your header, footer, dividers and styles', WYSIJA) ?>")) { 
  1245. wysijaAJAX.task = 'switch_theme'; 
  1246. wysijaAJAX._wpnonce = wysijanonces.campaigns.switch_theme; 
  1247. wysijaAJAX.wysijaData = Object.toJSON(new Hash({theme: $(target).readAttribute('rel')})); 
  1248. wysijaAJAX.popTitle = "Switch theme"; 
  1249. WYSIJA_AJAX_POST({ 
  1250. 'success': function(response) { 
  1251. // set theme name 
  1252. $('wysija_widgets_settings').down('.theme').update(response.responseJSON.result.templates.theme); 
  1253.  
  1254. // set css 
  1255. if(response.responseJSON.result.styles.css != null) { 
  1256. // updateStyles(response.responseJSON.result.styles.css); 
  1257. Wysija.updateCSS(response.responseJSON.result.styles.css.strip()); 
  1258.  
  1259. // update styles form 
  1260. if(response.responseJSON.result.styles.form != null) { 
  1261. // refresh styles form 
  1262. $('wj_styles_form').innerHTML = response.responseJSON.result.styles.form; 
  1263. // setup color pickers 
  1264. setupColorPickers(); 
  1265.  
  1266. // setup apply styles on value changed 
  1267. setupStylesForm(); 
  1268.  
  1269. // apply styles 
  1270. applyStyles(); 
  1271.  
  1272. // set header 
  1273. if (response.responseJSON.result.templates.header != undefined) { 
  1274. $$('.' + Wysija.options.header)[0].replace(response.responseJSON.result.templates.header); 
  1275. // set footer 
  1276. if (response.responseJSON.result.templates.footer != undefined) { 
  1277. $$('.' + Wysija.options.footer)[0].replace(response.responseJSON.result.templates.footer); 
  1278. // set divider 
  1279. if (response.responseJSON.result.templates.divider != undefined) { 
  1280. Wysija.setDivider(response.responseJSON.result.templates.divider, response.responseJSON.result.templates.divider_options); 
  1281. Wysija.replaceDividers(); 
  1282.  
  1283. Wysija.init(); 
  1284. saveWYSIJA(); 
  1285. }); 
  1286. return false; 
  1287.  
  1288. function applyStyles() { 
  1289. wysijaAJAX.task = 'save_styles'; 
  1290. wysijaAJAX._wpnonce = wysijanonces.campaigns.save_styles; 
  1291. wysijaAJAX.wysijaStyles = Object.toJSON($('wj_styles_form').serialize(true)); 
  1292. wysijaAJAX.popTitle = "Save styles"; 
  1293. WYSIJA_AJAX_POST({ 
  1294. 'success': function(response) { 
  1295. // remove fixed height for each text block 
  1296. $$('.wysija_text').invoke('setStyle', {height: 'auto'}); 
  1297.  
  1298. // apply new styles 
  1299. Wysija.updateCSS(response.responseJSON.result.styles.strip()); 
  1300. }); 
  1301.  
  1302. return false; 
  1303.  
  1304. function setupStylesForm() { 
  1305. $$('#wj_styles_form select, #wj_styles_form input').invoke('observe', 'change', applyStyles); 
  1306.  
  1307. function setupColorPickers() { 
  1308. jQuery(function($) { 
  1309. $('.color').modcoder_excolor({ 
  1310. hue_bar: 1,  
  1311. border_color: '#969696',  
  1312. anim_speed: 'fast',  
  1313. round_corners: false,  
  1314. shadow_size: 2,  
  1315. shadow_color: '#f0f0f0',  
  1316. background_color: '#ececec',  
  1317. backlight: false,  
  1318. label_color: '#333333',  
  1319. effect: 'fade',  
  1320. show_input: false,  
  1321. z_index: 20000,  
  1322. hide_on_scroll: true,  
  1323. callback_on_init: function() { 
  1324. Wysija.locks.selectingColor = true; 
  1325. },  
  1326. callback_on_select: function(color, input) { 
  1327. Wysija.updateCSSColor(input, color); 
  1328. },  
  1329. callback_on_ok: function(color, color_has_changed) { 
  1330. if (color_has_changed === true) { 
  1331. // apply styles only if the color has changed 
  1332. applyStyles(); 
  1333. // unlock editor 
  1334. Wysija.locks.selectingColor = false; 
  1335. }); 
  1336. }); 
  1337.  
  1338. function saveIQS() { 
  1339. wysijaAJAX.task = 'save_IQS'; 
  1340. wysijaAJAX._wpnonce = wysijanonces.campaigns.save_IQS; 
  1341. wysijaAJAX.wysijaIMG = Object.toJSON(wysijaIMG); 
  1342. WYSIJA_AJAX_POST(); 
  1343.  
  1344. // prototype on load 
  1345. document.observe('dom:loaded', function() { 
  1346. setupStylesForm(); 
  1347.  
  1348. var konami = new Konami(); 
  1349. konami.code = function() { 
  1350. Wysija.flyToTheMoon(); 
  1351. konami.load(); 
  1352. }); 
  1353.  
  1354. // jquery on load 
  1355. jQuery(function($) { 
  1356. $(function() { 
  1357. setupColorPickers(); 
  1358. }); 
  1359. }); 
  1360. </script> 
  1361. <!-- END: Wysija Toolbar --> 
  1362. <div id="wysija-konami" > 
  1363. <div id="wysija-konami-overlay" style="display:none;width:100%; height:100%; position:fixed;top:0;left:0;background-color:#fff;z-index:99998;overflow:hidden;"> 
  1364. <img id="wysija-konami-bird" src="<?php echo WYSIJA_URL ?>img/wysija_bird.jpg" style="display:none;z-index:99999;position:absolute;top:100px;left:100px;" width="597" height="483" /> 
  1365. </div> 
  1366. </div> 
  1367.  
  1368. <div id="wysija-divider"> 
  1369.  
  1370. </div> 
  1371. <?php 
  1372.  
  1373. /** when newsletter has been sent let's see the feedback */ 
  1374.  
  1375. function editDetails($data = false) { 
  1376.  
  1377. $this->data = $data; 
  1378. $step = array(); 
  1379. $step['subject'] = array( 
  1380. 'type' => 'subject',  
  1381. 'label' => __('Subject line', WYSIJA),  
  1382. 'class' => 'validate[required]',  
  1383. 'desc' => __("Be creative! It's the first thing your subscribers see. Tempt them to open your email.", WYSIJA)); 
  1384.  
  1385. if ((int) $data['email']['type'] === 2) { 
  1386. $step['params'] = array( 
  1387. 'type' => 'frequencies',  
  1388. 'label' => __('When...', WYSIJA), 'class' => 'validate[required]',  
  1389. 'desc' => '',  
  1390. 'labeloff' => 1,  
  1391. 'rowclass' => 'automatic-nl'); 
  1392.  
  1393. $step['type'] = array( 
  1394. 'type' => 'type_nl',  
  1395. 'class' => 'validate[required]',  
  1396. 'labeloff' => 1,  
  1397. 'label' => __('What type of newsletter is this?', WYSIJA),  
  1398. 'rowclass' => 'hidden'); 
  1399.  
  1400. if (isset($data['email']["params"]['autonl']['event']) && $data['email']["params"]['autonl']['event'] == 'new-articles') { 
  1401. $step['subject']['desc'] = str_replace(array('[newsletter:number]', '[newsletter:total]', '[newsletter:post_title]'), array('<b>[newsletter:number]</b>', '<b>[newsletter:total]</b>', '<b>[newsletter:post_title]</b>'), __('Insert [newsletter:total] to show number of posts, [newsletter:post_title] to show the latest post\'s title & [newsletter:number] to display the issue number.', WYSIJA)); 
  1402.  
  1403. if ($this->data['lists']) { 
  1404. $step['lists'] = array( 
  1405. 'type' => 'lists',  
  1406. 'class' => 'validate[minCheckbox[1]] checkbox',  
  1407. 'label' => __('Lists', WYSIJA),  
  1408. 'labeloff' => 1,  
  1409. 'rowclass' => 'listcheckboxes',  
  1410. 'desc' => __('The subscriber list that will be used for this campaign.', WYSIJA)); 
  1411.  
  1412. $step['from_name'] = array( 
  1413. 'type' => 'fromname',  
  1414. 'class' => 'validate[required]',  
  1415. 'label' => __('Sender', WYSIJA),  
  1416. 'desc' => __('Name & email of yourself or your company.', WYSIJA)); 
  1417.  
  1418.  
  1419.  
  1420. $step['replyto_name'] = array( 
  1421. 'type' => 'fromname',  
  1422. 'class' => 'validate[required]',  
  1423. 'label' => __('Reply-to name & email', WYSIJA),  
  1424. 'desc' => __('When the subscribers hit "reply" this is who will receive their email.', WYSIJA)); 
  1425.  
  1426.  
  1427. $step = apply_filters('wysija_extend_step3', $step); 
  1428.  
  1429. //we schedule only the type 1 newsletter 
  1430. if ($data['email']['type'] == 1) { 
  1431. $step['scheduleit'] = array( 
  1432. 'type' => 'scheduleit',  
  1433. 'class' => '',  
  1434. 'label' => __('Schedule it', WYSIJA),  
  1435. 'desc' => ''); 
  1436.  
  1437. if ((int) $data['email']['sent_at'] === 0 && isset($data['autoresponder'])) { 
  1438. $step['ignore_subscribers'] = array( 
  1439. 'type' => 'checkbox',  
  1440. 'class' => '',  
  1441. 'label' => __('Ignore current subscribers', WYSIJA),  
  1442. 'desc' => __('Don\'t send to existing subscribers, only to future ones.', WYSIJA)); 
  1443. ?> 
  1444. <form name="step3" method="post" id="campaignstep3" action="" class="form-valid"> 
  1445.  
  1446. <table class="form-table"> 
  1447. <tbody> 
  1448. <?php 
  1449. echo $this->buildMyForm($step, $data, "email"); 
  1450. ?> 
  1451.  
  1452. </tbody> 
  1453. </table> 
  1454. <?php 
  1455. global $current_user; 
  1456. $emailuser = $current_user->data->user_email; 
  1457. ?> 
  1458.  
  1459. <p><input type="text" name="receiver-preview" id="preview-receiver" value="<?php echo $emailuser ?>" /> <a href="javascript:;" id="wj-send-preview" class="button wysija"><?php _e("Send preview", WYSIJA) ?></a></p> 
  1460.  
  1461. <p class="submit"> 
  1462. <?php $this->secure(array('action' => "savelast", 'id' => $_REQUEST['id'])); ?> 
  1463. <input type="hidden" name="wysija[email][email_id]" id="email_id" value="<?php echo esc_attr($data['email']['email_id']) ?>" /> 
  1464. <input type="hidden" name="wysija[campaign][campaign_id]" id="campaign_id" value="<?php echo esc_attr($data['email']['campaign_id']) ?>" /> 
  1465. <input type="hidden" value="savelast" name="action" /> 
  1466. <input type="hidden" value="" name="wj_redir" id="hid-redir" /> 
  1467. <?php 
  1468. if ((int) $this->data['email']['type'] == 2) { 
  1469. $sendNow = esc_attr(__('Activate now', WYSIJA)); 
  1470. $saveresumesend = esc_attr(__('Activate now', WYSIJA)); 
  1471. $buttonsave = esc_attr(__('Save as draft and close', WYSIJA)); 
  1472. $buttonsendlater = $buttonsave; 
  1473. } else { 
  1474.  
  1475. $sendNow = esc_attr(__('Send', WYSIJA)); 
  1476. $saveresumesend = esc_attr(__('Send', WYSIJA)); 
  1477. $buttonsave = esc_attr(__('Save & close', WYSIJA)); 
  1478. $buttonsendlater = esc_attr(__('Save as draft and close', WYSIJA)); 
  1479.  
  1480. if (in_array((int) $this->data['email']['status'], array(0, 4))) { 
  1481.  
  1482. if ($this->data['lists']) { 
  1483. ?> 
  1484. <input type="submit" value="<?php echo $sendNow ?>" id="submit-send" name="submit-send" class="button-primary wysija"/> 
  1485. <?php } 
  1486. ?> 
  1487. <input type="submit" value="<?php echo $buttonsendlater ?>" id="submit-draft" name="submit-draft" class="button wysija"/> 
  1488. <?php 
  1489. } else { 
  1490. ?> 
  1491.  
  1492. <input type="submit" value="<?php echo $saveresumesend ?>" id="submit-send" name="submit-resume" class="button-primary wysija"/> 
  1493. <input type="submit" value="<?php echo $buttonsave ?>" id="submit-draft" name="submit-pause" class="button wysija"/> 
  1494. <?php 
  1495. ?> 
  1496.  
  1497. <?php 
  1498. echo str_replace( 
  1499. array('[link]', '[/link]'), array('<a href="admin.php?page=wysija_campaigns&action=editTemplate&id=' . $data['email']['email_id'] . '" id="link-back-step2">', '</a>'), __("or simply [link]go back to design[/link].", WYSIJA) 
  1500. ); 
  1501. echo $this->immediatewarning; 
  1502. ?> 
  1503. </p> 
  1504. </form> 
  1505. <?php 
  1506.  
  1507. function fieldFormHTML_subject($key, $val, $model, $params) { 
  1508. $fieldHTML = ''; 
  1509. $field = $key; 
  1510.  
  1511.  
  1512. $formObj = WYSIJA::get("forms", "helper"); 
  1513. $fieldHTML = '<div id="titlediv"> 
  1514. <div id="titlewrap" style="width:70%;"> 
  1515. <input class="titlebox ' . $params['class'] . '" id="' . $key . '" name="wysija[email][subject]" size="30" type="text" autocomplete="off" value="' . esc_attr($val) . '" /> 
  1516. </div> 
  1517. </div>'; 
  1518.  
  1519.  
  1520. return $fieldHTML; 
  1521.  
  1522. function fieldFormHTML_frequencies($key, $val, $model, $params) { 
  1523. $fieldHTML = '<div class="frequencies">'; 
  1524. $field = $key; 
  1525. $id = $key; 
  1526. if (!$val) { 
  1527. $val = array( 
  1528. 'autonl' => 
  1529. array( 
  1530. 'event' => 'new-articles',  
  1531. 'day' => 'monday',  
  1532. 'time' => '00:00:00',  
  1533. 'when-article' => 'daily',  
  1534. 'when-subscribe' => 'daily',  
  1535. ); 
  1536. } elseif (is_string($val)) { 
  1537. $val = unserialize(base64_decode($val)); 
  1538.  
  1539.  
  1540. if (!isset($val['autonl'])) { 
  1541. $val = array( 
  1542. 'autonl' => 
  1543. array( 
  1544. 'event' => 'new-articles',  
  1545. 'day' => 'monday',  
  1546. 'time' => '00:00:00',  
  1547. 'when-article' => 'daily',  
  1548. 'when-subscribe' => 'daily',  
  1549. ); 
  1550.  
  1551. $formsHelp = WYSIJA::get('forms', 'helper'); 
  1552. foreach ($this->data['autonl']['fields'] as $fieldK => $field) { 
  1553. $myval = ''; 
  1554. $singleFieldHtml = ''; 
  1555.  
  1556. //dbg($field, 0); 
  1557. if (isset($field['extend'])) { 
  1558. $field = $this->data['autonl']['fields'][$field['extend']]; 
  1559. if (isset($val['autonl'][$fieldK])) 
  1560. $myval = $val['autonl'][$fieldK]; 
  1561.  
  1562. $classDDP = ''; 
  1563. if (isset($field['class'])) 
  1564. $classDDP = $field['class']; 
  1565.  
  1566. $dataArray = array('name' => 'wysija[email][params][autonl][' . $fieldK . ']', 'id' => $id . '-' . $fieldK, 'class' => $classDDP); 
  1567. if (isset($field['style'])) { 
  1568. $dataArray['style'] = $field['style']; 
  1569.  
  1570. $arrayFields = array('event'); 
  1571. if (!in_array($fieldK, $arrayFields)) 
  1572. $classDDP.='sub-event'; 
  1573. $arrayFields[] = 'when-article'; 
  1574. if (!in_array($fieldK, $arrayFields)) 
  1575. $classDDP.=' sub-when-article'; 
  1576. $dataArray['class'] = $classDDP; 
  1577.  
  1578. //by default we return a dropdown 
  1579. if (!isset($field['type'])) { 
  1580. $singleFieldHtml.=$formsHelp->dropdown( 
  1581. $dataArray, $field['values'], $myval); 
  1582. } else { 
  1583. $typee = $field['type']; 
  1584.  
  1585. if ($typee == 'checkbox') { 
  1586. $singleFieldHtml.=$formsHelp->$typee($dataArray, '', $myval); 
  1587. } else { 
  1588. $singleFieldHtml.=$formsHelp->$typee($dataArray, $myval); 
  1589.  
  1590. if (isset($field['label_before']) || isset($field['label_after'])) { 
  1591. $before = $after = ''; 
  1592. if (isset($field['label_before'])) 
  1593. $before = $field['label_before']; 
  1594. if (isset($field['label_after'])) 
  1595. $after = $field['label_after']; 
  1596. $singleFieldHtml = '<label id="' . $id . '-label-' . $fieldK . '" for="' . $id . '-' . $fieldK . '" class="' . $classDDP . '">' . $before . $singleFieldHtml . $after . '</label>'; 
  1597.  
  1598. $fieldHTML.=$singleFieldHtml; 
  1599.  
  1600.  
  1601.  
  1602. $fieldHTML .= '</div>'; 
  1603. return $fieldHTML; 
  1604.  
  1605. function local_time_is() { 
  1606. $helper_toolbox = WYSIJA::get('toolbox', 'helper'); 
  1607.  
  1608. return '<span class="local_time">' . sprintf(__('Local time is <code>%1$s</code>'), $helper_toolbox->site_current_time()) . '</span>'; 
  1609.  
  1610. function fieldFormHTML_type_nl($key, $val, $model, $params) { 
  1611. $fieldHTML = '<div class="list-radios">'; 
  1612. $field = $key; 
  1613. $valuefield = array(); 
  1614.  
  1615. $typesnl = array( 
  1616. '1' => array( 
  1617. 'type' => 'standard',  
  1618. 'label' => __('Standard newsletter', WYSIJA),  
  1619. 'default' => 1 
  1620. ),  
  1621. '2' => array( 
  1622. 'type' => 'automatic',  
  1623. 'label' => __('Automatic newsletter', WYSIJA),  
  1624. ); 
  1625.  
  1626. foreach ($typesnl as $typenl => $paramstnl) { 
  1627.  
  1628. $checked = ''; 
  1629. if (($val && (int) $val == (int) $typenl) || (!$val && isset($paramstnl['default']))) { 
  1630. $checked = ' checked="checked" '; 
  1631.  
  1632. $fieldHTML.='<label for="nl_type_' . $paramstnl['type'] . '">' . 
  1633. '<input class="radiotype-nl" id="nl_type_' . $paramstnl['type'] . '" type="radio" name="wysija[email][type]" value="' . $typenl . '" ' . $checked . ' />' 
  1634. . $paramstnl['label'] . '</label>'; 
  1635.  
  1636. $fieldHTML.='</div>'; 
  1637. return $fieldHTML; 
  1638.  
  1639. function fieldFormHTML_lists($key, $val, $model, $params) { 
  1640. $fieldHTML = '<div class="list-checkbox">'; 
  1641. $field = $key; 
  1642. $valuefield = array(); 
  1643.  
  1644. if (isset($this->data['campaign_list']) && $this->data['campaign_list']) { 
  1645. foreach ($this->data['campaign_list'] as $list) { 
  1646. $valuefield[$list['list_id']] = $list; 
  1647.  
  1648.  
  1649. $formObj = WYSIJA::get("forms", "helper"); 
  1650.  
  1651. usort( $this->data['lists'], array('WYSIJA_view_back_campaigns', 'sort_by_name' ) ); 
  1652.  
  1653. foreach ($this->data['lists'] as $list) { 
  1654.  
  1655. $checked = false; 
  1656. if (isset($valuefield[$list['list_id']])) 
  1657. $checked = true; 
  1658.  
  1659. $fieldHTML.= '<p><label for="' . $field . $list['list_id'] . '">'; 
  1660. $fieldHTML.=$formObj->checkbox(array('class' => $params['class'] . ' checklists', 'alt' => $list['name'], 'id' => $field . $list['list_id'], 'name' => "wysija[campaign_list][list_id][]"), $list['list_id'], $checked) . $list['name'] . ' (' . $list['count'] . ')'; 
  1661. $fieldHTML.='<input type="hidden" id="' . $field . $list['list_id'] . 'count" value="' . $list['count'] . '" />'; 
  1662. $fieldHTML.='</label></p>'; 
  1663.  
  1664. $fieldHTML.="</div>"; 
  1665. return $fieldHTML; 
  1666.  
  1667. function fieldFormHTML_scheduleit($key, $val, $model, $params) { 
  1668. $formObj = WYSIJA::get('forms', 'helper'); 
  1669.  
  1670. $valuescheduled = ''; 
  1671.  
  1672. if (isset($this->data['email']['params']['schedule']['isscheduled'])) 
  1673. $valuescheduled = $this->data['email']['params']['schedule']['isscheduled']; 
  1674. $data = $formObj->checkbox(array('class' => $params['class'], 'id' => $key, 'name' => 'wysija[email][params][schedule][isscheduled]'), true, $valuescheduled); 
  1675. $data .= $this->fieldFormHTML_datepicker('datepicker', $val, $model, $params); 
  1676.  
  1677. return $data; 
  1678.  
  1679. /** 
  1680. * @todo: move to top super class or heler 
  1681. */ 
  1682. function fieldFormHTML_datepicker($key, $val, $model, $params) { 
  1683. if ((int) $this->data['email']['type'] == 2) 
  1684. return; 
  1685.  
  1686. $fieldHTML = '<span id="schedule-area" class="schedule-row" >'; 
  1687. $field = $key; 
  1688. $valuefield = array(); 
  1689.  
  1690. $formObj = WYSIJA::get("forms", "helper"); 
  1691.  
  1692. $valuescheduled = $valuetime = ''; 
  1693. $valueday = date("Y/m/d"); 
  1694. if (isset($this->data['email']['params']['schedule']['day'])) { 
  1695. $valueday = $this->data['email']['params']['schedule']['day']; 
  1696. if (isset($this->data['email']['params']['schedule']['time'])) { 
  1697. $valuetime = $this->data['email']['params']['schedule']['time']; 
  1698. if (isset($this->data['email']['params']['schedule']['isscheduled'])) { 
  1699. $valuescheduled = $this->data['email']['params']['schedule']['isscheduled']; 
  1700.  
  1701. $fieldHTML.=$formObj->input(array('class' => $params['class'], 'id' => $field . '-day', 'name' => "wysija[email][params][schedule][day]", 'size' => 8), $valueday); 
  1702. $fieldHTML.=' @ '; 
  1703. $fieldHTML.=$formObj->dropdown( 
  1704. array( 
  1705. 'name' => 'wysija[email][params][schedule][time]',  
  1706. 'id' => $field.'-time' 
  1707. ),  
  1708. $this->data['autonl']['fields']['time']['values'],  
  1709. $valuetime 
  1710. ); 
  1711.  
  1712. $fieldHTML .= $this->local_time_is(); 
  1713. $fieldHTML.='</span>'; 
  1714. return $fieldHTML; 
  1715.  
  1716. function edit($data) { 
  1717. //$this->menuTop("edit"); 
  1718. $formid = 'wysija-' . $_REQUEST['action']; 
  1719. ?> 
  1720. <div id="wysistats"> 
  1721. <div id="wysistats1" class="left"> 
  1722. <div id="statscontainer"></div> 
  1723. <h3><?php _e(sprintf('%1$s emails received.', $data['user']['emails']), WYSIJA) ?></h3> 
  1724. </div> 
  1725. <div id="wysistats2" class="left"> 
  1726. <ul> 
  1727. <?php 
  1728. foreach ($data['charts']['stats'] as $stats) { 
  1729. echo "<li>" . $stats['name'] . ": " . $stats['number'] . "</li>"; 
  1730. echo "<li>" . __('Added', WYSIJA) . ":" . $this->fieldListHTML_created_at($data['user']['details']["created_at"]) . "</li>"; 
  1731. ?> 
  1732.  
  1733. </ul> 
  1734. </div> 
  1735. <div id="wysistats3" class="left"> 
  1736. <p class="title"><?php echo __(sprintf('Total of %1$d clicks:', count($data['clicks'])), WYSIJA); ?></p> 
  1737. <ol> 
  1738. <?php 
  1739. foreach ($data['clicks'] as $click) { 
  1740. echo "<li>" . $click['name'] . " : " . $click['url'] . "</li>"; 
  1741. ?> 
  1742.  
  1743. </ol> 
  1744. </div> 
  1745. <div class="clear"></div> 
  1746. </div> 
  1747.  
  1748. <?php 
  1749. $this->buttonsave = __('Save', WYSIJA); 
  1750. $this->add($data); 
  1751.  
  1752. function popup_image_data($data) { 
  1753. echo $this->messages(true); 
  1754. ?> 
  1755. <div class="popup_content addlink"> 
  1756. <form method="post" action="" class="image-data-form" id="image-data-form"> 
  1757. <p> 
  1758. <label for="url"><?php _e('Address:', WYSIJA) ?></label><br/> 
  1759. <input type="text" name="url" value="<?php echo (!empty($data['url'])) ? esc_attr($data['url']) : 'http://' ?>" id="url" /> 
  1760. </p> 
  1761. <p> 
  1762. <label for="alt"><?php _e('Alternative text:', WYSIJA) ?></label><br/> 
  1763. <input type="text" name="alt" value="<?php echo (!empty($data['alt'])) ? esc_attr($data['alt']) : '' ?>" id="alt" /> 
  1764. </p> 
  1765. <p class="notice"><?php _e('This text is displayed when email clients block images, which is most of the time.', WYSIJA) ?></p> 
  1766. <p class="submit_button"><input id="image-data-submit" class="button-primary" type="submit" name="submit" value="<?php _e('Save', WYSIJA) ?>" /></p> 
  1767. </form> 
  1768. </div> 
  1769. <?php 
  1770.  
  1771. function popup_themes($errors) { 
  1772. echo $this->messages(true); 
  1773. ?> 
  1774. <div id="overlay"><img id="loader" src="<?php echo WYSIJA_URL ?>img/wpspin_light.gif" /></div> 
  1775. <div class="popup_content themes"> 
  1776. <form enctype="multipart/form-data" method="post" action="" class="validate"> 
  1777. <div id="search-view" class="panel"> 
  1778. <?php 
  1779. if (isset($_REQUEST['reload']) && (int) $_REQUEST['reload'] === 1) { 
  1780. echo '<input type="hidden" id="themes-reload" name="themes-reload" value="1" />'; 
  1781. ?> 
  1782. <div class="clearfix"> 
  1783. <input type="button" id="sub-theme-box" name="submit" value="<?php echo esc_attr(__('Upload Theme (.zip)', WYSIJA)); ?>" class="button-secondary"/> 
  1784. <span id="filter-selection"></span> 
  1785.    
  1786. <span><?php echo str_replace(array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/knowledgebase/guide-to-creating-your-own-mailpoet-theme?utm_source=wpadmin&utm_campaign=theme%20guide" target="_blank">', '</a>'), __('[link]Guide[/link] to create your own theme.', WYSIJA)); ?></span> 
  1787. <div id="wj_paginator"> 
  1788. <a class="selected" href="javascript:;" data-type="free"><?php _e('Free', WYSIJA); ?></a> 
  1789. <a href="javascript:;" data-type="premium"><?php _e('Premium', WYSIJA); ?></a> 
  1790. </div> 
  1791. </div> 
  1792. <ul id="themes-list"></ul> 
  1793. </div> 
  1794. <div id="theme-view" class="panel" style="display:none;"></div> 
  1795. </form> 
  1796. <div id="theme-upload" class="panel"> 
  1797. <form enctype="multipart/form-data" method="post" action="" class="validate"> 
  1798. <div class="wrap actions"> 
  1799. <a class="button-secondary2 theme-view-back" href="javascript:;"><?php echo __("<< Back", WYSIJA) ?></a> 
  1800. </div> 
  1801. <div class="form"> 
  1802. <?php 
  1803. $secure = array('action' => "themeupload"); 
  1804. $this->secure($secure); 
  1805. ?> 
  1806. <p><input type="file" name="my-theme"/>( <?php 
  1807. $helperNumbers = WYSIJA::get('numbers', 'helper'); 
  1808. $data = $helperNumbers->get_max_file_upload(); 
  1809. $bytes = $data['maxmegas']; 
  1810.  
  1811. echo sprintf(__('total max upload file size : %1$s', WYSIJA), $bytes); ?> )</p> 
  1812. <p><label for="overwrite"><input type="checkbox" id="overwrite" name="overwriteexistingtheme" /><?php echo __("If a theme with the same name exists, overwrite it.", WYSIJA); ?></label></p> 
  1813. <p><input type="hidden" name="action" value="themeupload" /> 
  1814. <input type="submit" class="button-primary" name="submitter" value="<?php _e("Upload", WYSIJA) ?>" /></p> 
  1815. </div> 
  1816. </div> 
  1817. </form> 
  1818. </div> 
  1819. <?php 
  1820.  
  1821. function test_bounce() { 
  1822. exit; 
  1823.  
  1824. function themeupload() { 
  1825. $this->popup_themes(false); 
  1826.  
  1827. function popup_articles($data = array(), $errors = array()) { 
  1828. // get articles helper 
  1829. $helper_articles = WYSIJA::get('articles', 'helper'); 
  1830.  
  1831. echo $this->messages(true); 
  1832. ?> 
  1833. <div class="popup_content inline_form articles"> 
  1834. <form enctype="multipart/form-data" method="post" action="" id="articles-form"> 
  1835. <div id="basic"> 
  1836. <div class="clearfix"> 
  1837. <div class="filters-box"> 
  1838. <?php 
  1839. echo $helper_articles->field_select_post_type(array('value' => $data['params']['post_type'], 'label' => __('Filter by type', WYSIJA))); 
  1840. echo $helper_articles->field_select_terms(); 
  1841. echo $helper_articles->field_select_status(); 
  1842. ?> 
  1843. </div> 
  1844. <div class="search-box"> 
  1845. <input type="text" id="search" name="search" autocomplete="off" /> 
  1846. <input type="submit" id="search-submit" name="submit" value="<?php _e('Search', WYSIJA); ?>" /> 
  1847. </div> 
  1848. </div> 
  1849.  
  1850. <div id="results"></div> 
  1851. </div> 
  1852.  
  1853. <div id="advanced"> 
  1854. <?php echo $this->_post_display_options($data); ?> 
  1855. </div> 
  1856.  
  1857. <div class="submit-box"> 
  1858. <div id="loading-icon"></div> 
  1859. <div id="loading-message"></div> 
  1860. <a id="toggle-advanced" href="javascript:;"><?php _e('Display and insert options', WYSIJA); ?></a> 
  1861. <input id="insert-selection" class="button-primary" type="submit" name="insert" value="<?php _e('Insert selected', WYSIJA); ?>" /> 
  1862. <input id="back-selection" class="button-secondary" type="button" value="<?php _e('Back to selection', WYSIJA); ?>" /> 
  1863. </div> 
  1864. </form> 
  1865. </div> 
  1866. <?php 
  1867.  
  1868. private function _post_display_options($data) { 
  1869.  
  1870. $output = ''; 
  1871.  
  1872. // display option: excerpt / full post / title only 
  1873. $knowledgebase_url = str_replace( 
  1874. array('[link]', '[/link]'),  
  1875. array('<a href="http://support.mailpoet.com/knowledgebase/excerpts-in-wysija/?utm_source=wpadmin&utm_campaign=editor" target="_blank">', '</a>'),  
  1876. __('Which excerpt does it use? [link]Read more[/link]', WYSIJA) 
  1877. ); 
  1878.  
  1879. $output .= '<div class="block clearfix">'; 
  1880. $output .= ' <label>'.__('Display...', WYSIJA); 
  1881. $output .= ' <span class="label">'.$knowledgebase_url.'</span>'; 
  1882. $output .= ' </label>'; 
  1883. $output .= ' <label class="radio"><input type="radio" name="post_content" value="excerpt" '.(($data['params']['post_content'] === 'excerpt') ? 'checked="checked"' : '').' />'.__('excerpt', WYSIJA).'</label>'; 
  1884. $output .= ' <label class="radio"><input type="radio" name="post_content" value="full" '.(($data['params']['post_content'] === 'full') ? 'checked="checked"' : '').' />'.__('full post', WYSIJA).'</label>'; 
  1885. $output .= ' <label class="radio"><input type="radio" name="post_content" value="title" '.(($data['params']['post_content'] === 'title') ? 'checked="checked"' : '').' />'.__('title only', WYSIJA).'</label>'; 
  1886. $output .= '</div>'; 
  1887.  
  1888. // title format 
  1889. $output .= '<div class="block clearfix alternate">'; 
  1890. $output .= ' <label>'.__('Title format', WYSIJA).'</label>'; 
  1891. $output .= ' <label class="radio"><input type="radio" name="title_tag" value="h1" '.(($data['params']['title_tag'] === 'h1') ? 'checked="checked"' : '').' />'.__('heading 1', WYSIJA).'</label>'; 
  1892. $output .= ' <label class="radio"><input type="radio" name="title_tag" value="h2" '.(($data['params']['title_tag'] === 'h2') ? 'checked="checked"' : '').' />'.__('heading 2', WYSIJA).'</label>'; 
  1893. $output .= ' <label class="radio"><input type="radio" name="title_tag" value="h3" '.(($data['params']['title_tag'] === 'h3') ? 'checked="checked"' : '').' />'.__('heading 3', WYSIJA).'</label>'; 
  1894. $output .= ' <label id="title_tag_list" class="radio"><input type="radio" name="title_tag" value="list" '.(($data['params']['title_tag'] === 'list') ? 'checked="checked"' : '').' />'.__('show as list', WYSIJA).'</label>'; 
  1895. $output .= '</div>'; 
  1896.  
  1897. // title position 
  1898. $output .= '<div id="title_position_block" class="block clearfix">'; 
  1899. $output .= ' <label>'.__('Title position', WYSIJA).'</label>'; 
  1900. $output .= ' <label class="radio"><input type="radio" name="title_position" value="inside" '.(($data['params']['title_position'] === 'inside') ? 'checked="checked"' : '').' />'.__('in text block', WYSIJA).'</label>'; 
  1901. $output .= ' <label class="radio"><input type="radio" name="title_position" value="outside" '.(($data['params']['title_position'] === 'outside') ? 'checked="checked"' : '').' />'.__('above text block and image', WYSIJA).'</label>'; 
  1902. $output .= '</div>'; 
  1903.  
  1904. // title alignment 
  1905. $output .= '<div class="block clearfix alternate">'; 
  1906. $output .= ' <label>'.__('Title alignment', WYSIJA).'</label>'; 
  1907. $output .= ' <label class="radio"><input type="radio" name="title_alignment" value="left" '.(($data['params']['title_alignment'] === 'left') ? 'checked="checked"' : '').' />'.__('left', WYSIJA).'</label>'; 
  1908. $output .= ' <label class="radio"><input type="radio" name="title_alignment" value="center" '.(($data['params']['title_alignment'] === 'center') ? 'checked="checked"' : '').' />'.__('center', WYSIJA).'</label>'; 
  1909. $output .= ' <label class="radio"><input type="radio" name="title_alignment" value="right" '.(($data['params']['title_alignment'] === 'right') ? 'checked="checked"' : '').' />'.__('right', WYSIJA).'</label>'; 
  1910. $output .= '</div>'; 
  1911.  
  1912. // image alignment 
  1913. $output .= '<div id="image_block">'; 
  1914. $output .= ' <div class="block clearfix">'; 
  1915. $output .= ' <label>'.__('Image alignment', WYSIJA).'</label>'; 
  1916.  
  1917. $output .= ' <div class="group clearfix">'; 
  1918.  
  1919. // display alternate only when multiple posts are allowed 
  1920. if($data['autopost_type'] !== 'single') { 
  1921. $output .= ' <label class="radio"><input type="radio" name="image_alignment" value="alternate" '.(($data['params']['image_alignment'] === 'alternate') ? 'checked="checked"' : '').' />'.__('alternate left & right', WYSIJA).'</label>'; 
  1922. $output .= ' <label class="radio"><input type="radio" name="image_alignment" value="left" '.(($data['params']['image_alignment'] === 'left') ? 'checked="checked"' : '').' />'.__('left', WYSIJA).'</label>'; 
  1923. $output .= ' <label class="radio"><input type="radio" name="image_alignment" value="center" '.(($data['params']['image_alignment'] === 'center') ? 'checked="checked"' : '').' />'.__('center', WYSIJA).'</label>'; 
  1924. $output .= ' <label class="radio"><input type="radio" name="image_alignment" value="right" '.(($data['params']['image_alignment'] === 'right') ? 'checked="checked"' : '').' />'.__('right', WYSIJA).'</label>'; 
  1925. $output .= ' <label class="radio"><input type="radio" name="image_alignment" value="none" '.(($data['params']['image_alignment'] === 'none') ? 'checked="checked"' : '').' />'.__('no image', WYSIJA).'</label>'; 
  1926. $output .= ' </div>'; 
  1927.  
  1928. $output .= ' </div>'; 
  1929.  
  1930. // image width 
  1931. $output .= ' <div id="image_width_block" class="block clearfix">'; 
  1932. $output .= ' <input id="image_width" type="hidden" name="image_width" value="'.(int)$data['params']['image_width'].'" />'; 
  1933. $output .= ' <label>'.__('Image width', WYSIJA).'</label>'; 
  1934. $output .= ' <span id="image_width_slider">'; 
  1935. $output .= ' <span id="slider_handle"></span>'; 
  1936. $output .= ' </span>'; 
  1937. $output .= ' <span id="slider_info"><span>'.(int)$data['params']['image_width'].'</span> px</span>'; 
  1938. $output .= ' </div>'; 
  1939. $output .= '</div>'; 
  1940.  
  1941. // author options 
  1942. $output .= '<div id="author-block" class="block clearfix alternate">'; 
  1943. $output .= ' <label>'.__('Include author', WYSIJA).'</label>'; 
  1944. $output .= ' <div class="group">'; 
  1945. $output .= ' <p class="clearfix">'; 
  1946. $output .= ' <label class="radio"><input type="radio" name="author_show" value="no" '.(($data['params']['author_show'] === 'no') ? 'checked="checked"' : '').' />'.__('no', WYSIJA).'</label>'; 
  1947. $output .= ' <label class="radio"><input type="radio" name="author_show" value="above" '.(($data['params']['author_show'] === 'above') ? 'checked="checked"' : '').' />'.__('above content', WYSIJA).'</label>'; 
  1948. $output .= ' <label class="radio"><input type="radio" name="author_show" value="below" '.(($data['params']['author_show'] === 'below') ? 'checked="checked"' : '').' />'.__('below content', WYSIJA).'</label>'; 
  1949. $output .= ' </p>'; 
  1950. $output .= ' <p class="clearfix">'; 
  1951. $output .= ' <label>'.__('Preceded by:', WYSIJA).' <input type="text" name="author_label" value="'.stripslashes($data['params']['author_label']).'" /></label>'; 
  1952. $output .= ' </p>'; 
  1953. $output .= ' </div>'; 
  1954. $output .= '</div>'; 
  1955.  
  1956. // categories options 
  1957. $output .= '<div id="category-block" class="block clearfix">'; 
  1958. $output .= ' <label>'.__('Include categories', WYSIJA).'</label>'; 
  1959. $output .= ' <div class="group">'; 
  1960. $output .= ' <p class="clearfix">'; 
  1961. $output .= ' <label class="radio"><input type="radio" name="category_show" value="no" '.(($data['params']['category_show'] === 'no') ? 'checked="checked"' : '').' />'.__('no', WYSIJA).'</label>'; 
  1962. $output .= ' <label class="radio"><input type="radio" name="category_show" value="above" '.(($data['params']['category_show'] === 'above') ? 'checked="checked"' : '').' />'.__('above content', WYSIJA).'</label>'; 
  1963. $output .= ' <label class="radio"><input type="radio" name="category_show" value="below" '.(($data['params']['category_show'] === 'below') ? 'checked="checked"' : '').' />'.__('below content', WYSIJA).'</label>'; 
  1964. $output .= ' </p>'; 
  1965. $output .= ' <p class="clearfix">'; 
  1966. $output .= ' <label>'.__('Preceded by:', WYSIJA).' <input type="text" name="category_label" value="'.stripslashes($data['params']['category_label']).'" /></label>'; 
  1967. $output .= ' </p>'; 
  1968. $output .= ' </div>'; 
  1969. $output .= '</div>'; 
  1970.  
  1971. // read more 
  1972. $output .= '<div id="readmore-block" class="block clearfix">'; 
  1973. $output .= ' <label for="readmore">'.__('"Read more" text', WYSIJA).'</label>'; 
  1974. $output .= ' <input type="text" name="readmore" value="'.stripslashes($data['params']['readmore']).'" id="readmore" />'; 
  1975. $output .= '</div>'; 
  1976.  
  1977. // check if we allow mutiple posts within the ALC 
  1978. if($data['autopost_type'] === 'single') { 
  1979. // background color 
  1980. $output .= '<div id="bgcolor-block" class="block clearfix">'; 
  1981. $output .= ' <label>'.__('Background color', WYSIJA).'</label>'; 
  1982. $output .= ' <input class="color" type="text" name="bgcolor1" value="'.(isset($data['params']['bgcolor1']) ? $data['params']['bgcolor1'] : '').'" />'; 
  1983. $output .= '</div>'; 
  1984. } else { 
  1985. // batch insert options 
  1986. $output .= '<div class="block clearfix">'; 
  1987. $output .= ' <h2>'.__('Batch insert options', WYSIJA).'</h2>'; 
  1988. $output .= '</div>'; 
  1989.  
  1990. // sort by 
  1991. $output .= '<div id="sort-block" class="block clearfix">'; 
  1992. $output .= ' <label>'.__('Sort by', WYSIJA).'</label>'; 
  1993. $output .= ' <label class="radio"><input type="radio" name="sort_by" value="newest" '.(($data['params']['sort_by'] === 'newest') ? 'checked="checked"' : '').' />'.__('newest', WYSIJA).'</label>'; 
  1994. $output .= ' <label class="radio"><input type="radio" name="sort_by" value="oldest" '.(($data['params']['sort_by'] === 'oldest') ? 'checked="checked"' : '').' />'.__('oldest', WYSIJA).'</label>'; 
  1995. $output .= '</div>'; 
  1996.  
  1997. // show dividers 
  1998. $output .= '<div id="divider-block" class="block clearfix">'; 
  1999. $output .= ' <label>'.__('Show divider between posts', WYSIJA).'</label>'; 
  2000. $output .= ' <label class="radio"><input type="radio" name="show_divider" value="yes" '.(($data['params']['show_divider'] === 'yes') ? 'checked="checked"' : '').' />'.__('yes', WYSIJA).'</label>'; 
  2001. $output .= ' <label class="radio"><input type="radio" name="show_divider" value="no" '.(($data['params']['show_divider'] === 'no') ? 'checked="checked"' : '').' />'.__('no', WYSIJA).'</label>'; 
  2002. $output .= '</div>'; 
  2003.  
  2004. // background colors 
  2005. $output .= '<div id="bgcolor-block" class="block clearfix">'; 
  2006. $output .= ' <label>'.__('Background color with alternate', WYSIJA).'</label>'; 
  2007. $output .= ' <input class="color" type="text" name="bgcolor1" value="'.(isset($data['params']['bgcolor1']) ? $data['params']['bgcolor1'] : '').'" />'; 
  2008. $output .= ' <input class="color" type="text" name="bgcolor2" value="'.(isset($data['params']['bgcolor2']) ? $data['params']['bgcolor2'] : '').'" />'; 
  2009. $output .= '</div>'; 
  2010.  
  2011. return $output; 
  2012.  
  2013. function popup_dividers($data = array()) { 
  2014. echo $this->messages(true); 
  2015. ?> 
  2016.  
  2017. <div class="popup_content dividers"> 
  2018. <form enctype="multipart/form-data" method="post" action="" class="" id="dividers-form"> 
  2019. <ul class="dividers"> 
  2020. <?php 
  2021. foreach($data['dividers'] as $divider) { 
  2022. $selected = ($divider['src'] === $data['selected']['src']) ? ' class="selected"' : ''; 
  2023. ?> 
  2024. <li class="clearfix"><a href="javascript:;"<?php echo $selected ?>><img src="<?php echo $divider['src'] ?>" alt="" width="<?php echo $divider['width'] ?>" height="<?php echo $divider['height'] ?>" /></a></li> 
  2025. <?php 
  2026. ?> 
  2027. </ul> 
  2028. <input type="hidden" name="email_id" value="<?php echo $data['email']['email_id'] ?>" id="email_id" /> 
  2029. <input type="hidden" name="divider_src" value="<?php echo $data['selected']['src'] ?>" id="divider_src" /> 
  2030. <input type="hidden" name="divider_width" value="<?php echo $data['selected']['width'] ?>" id="divider_width" /> 
  2031. <input type="hidden" name="divider_height" value="<?php echo $data['selected']['height'] ?>" id="divider_height" /> 
  2032. <p class="submit_button"> 
  2033. <input type="submit" id="dividers-submit" class="button-primary" name="submit" value="<?php echo esc_attr(__('Done', WYSIJA)); ?>" /> 
  2034. </p> 
  2035. </form> 
  2036. </div> 
  2037.  
  2038.  
  2039. <?php 
  2040.  
  2041. function popup_autopost($data = array()) { 
  2042. echo $this->messages(true); 
  2043.  
  2044. $output = ''; 
  2045.  
  2046. // container 
  2047. $output .= '<div class="popup_content inline_form autopost">'; 
  2048.  
  2049. // form 
  2050. $output .= '<form enctype="multipart/form-data" method="post" action="" class="" id="autopost-form">'; 
  2051.  
  2052. // basic options 
  2053. $output .= '<div id="basic">'; 
  2054.  
  2055. $helper_articles = WYSIJA::get('articles', 'helper'); 
  2056. $output .= '<div class="block clearfix">'; 
  2057. $output .= ' <label>'.__('Post type', WYSIJA).'</label>'; 
  2058. $output .= $helper_articles->field_select_post_type( array( 'value' => $data['params']['post_type'] ) ); 
  2059. $output .= '</div>'; 
  2060.  
  2061. // post limit 
  2062. if($data['autopost_type'] === 'single') { 
  2063. $output .= '<input type="hidden" name="post_limit" value="1" />'; 
  2064. } else { 
  2065. $output .= '<div class="block clearfix">'; 
  2066. $output .= ' <label>'.__('Maximum of posts to show', WYSIJA).'</label>'; 
  2067. $output .= ' <select name="post_limit" id="post_limit">'; 
  2068. foreach($data['post_limits'] as $limit) { 
  2069. $output .= ' <option value="'.$limit.'" '.(($limit === (int)$data['params']['post_limit']) ? 'selected="selected"' : '').' >'.$limit.'</option>'; 
  2070. $output .= ' </select>'; 
  2071. $output .= '</div>'; 
  2072.  
  2073. // Get selected terms IDs 
  2074. $terms_selected = array_filter( ( isset( $data['params']['category_ids'] ) ? explode( ', ', trim( $data['params']['category_ids'] ) ) : array() ) ); 
  2075.  
  2076. // Create the init selection in to be in the Select2 format of results 
  2077. $_attr_init_selection = array(); 
  2078.  
  2079. // Only build if there are any selected terms 
  2080. if ( ! empty( $terms_selected ) ) { 
  2081. $taxonomies = get_taxonomies( array(), 'objects' ); 
  2082. $terms = get_terms( array_keys( $taxonomies ), array( 'include' => $terms_selected, 'hide_empty' => false ) ); 
  2083.  
  2084. foreach ( $terms as $term ) { 
  2085. $_attr_init_selection[] = array( 
  2086. 'id' => $term->term_id,  
  2087. 'text' => wp_kses( $taxonomies[$term->taxonomy]->labels->singular_name . ': ' . $term->name, array() ),  
  2088. ); 
  2089.  
  2090. // categories 
  2091. $output .= 
  2092. '<div class="block clearfix" id="categories_filters">' . 
  2093. '<label title="' . esc_attr__( 'And taxonomies as well...', WYSIJA ) . '">' . __( 'Categories and tags', WYSIJA ) . '</label>' . 
  2094. '<div class="group">' . 
  2095. '<p class="category_select clearfix">' . 
  2096. '<input data-placeholder="' . __( 'Select...', WYSIJA ) . '" name="category_ids" style="width: 300px" class="category_ids mailpoet-field-select2-terms" data-multiple="true" data-value=\'' . WJ_Utils::esc_json_attr( $_attr_init_selection ) . '\' value="' . esc_attr( implode( ', ', $terms_selected ) ) . '" type="hidden">' . 
  2097. '</p>' . 
  2098. '</div>' . 
  2099. '</div>'; 
  2100.  
  2101. // end - basic options 
  2102. $output .= '</div>'; 
  2103.  
  2104. // display options 
  2105. $output .= '<p><a id="toggle-advanced" href="javascript:;">'.__('Show display options', WYSIJA).'</a></p>'; 
  2106. $output .= '<div id="advanced">'; 
  2107. $output .= $this->_post_display_options($data); 
  2108. $output .= '</div>'; 
  2109.  
  2110. $output .= ' <p class="submit_button"><input type="submit" id="autopost-submit" class="button-primary" name="submit" value="'.__('Done', WYSIJA).'" /></p>'; 
  2111. $output .= '</form>'; 
  2112. $output .= '</div>'; 
  2113.  
  2114. echo $output; 
  2115.  
  2116. function popup_bookmarks($data = array()) { 
  2117. echo $this->messages(true); 
  2118. ?> 
  2119. <div class="popup_content inline_form bookmarks"> 
  2120. <form enctype="multipart/form-data" method="post" action="" class="" id="bookmarks-form"> 
  2121. <ul class="networks"> 
  2122. <?php 
  2123. $i = 0; 
  2124. foreach ($data['networks'] as $key => $network) { 
  2125. ?> 
  2126. <li class="clearfix"> 
  2127. <input type="hidden" name="bookmarks-<?php echo($key) ?>-position" value="<?php echo($i++) ?>" /> 
  2128. <label for="bookmarks-url-<?php echo($key) ?>"><?php echo($network['label']) ?></label><input type="text" name="bookmarks-<?php echo($key) ?>-url" placeholder="<?php echo $network['placeholder']; ?>" value="<?php echo htmlentities($network['url']) ?>" id="bookmarks-url-<?php echo($key) ?>" /> 
  2129. </li> 
  2130. <?php 
  2131. ?> 
  2132. </ul> 
  2133.  
  2134. <div class="sizes"> 
  2135. <span><?php _e('Size:', WYSIJA) ?></span> 
  2136. <a href="javascript:;" class="small<?php if ($data['size'] === 'small') echo ' selected' ?>" rel="small"><?php _e('small', WYSIJA) ?></a> 
  2137. <a href="javascript:;" class="medium<?php if ($data['size'] === 'medium') echo ' selected' ?>" rel="medium"><?php _e('medium', WYSIJA) ?></a> 
  2138. <input type="hidden" name="bookmarks-size" value="<?php echo $data['size'] ?>" id="bookmarks-size" /> 
  2139. </div> 
  2140.  
  2141. <ul class="icons"><!-- this will be loaded via ajax --></ul> 
  2142. <input type="hidden" name="bookmarks-iconset" value="" id="bookmarks-iconset" /> 
  2143. <input type="hidden" name="bookmarks-theme" value="<?php echo $data['theme'] ?>" id="bookmarks-theme" /> 
  2144.  
  2145. <p class="submit_button"> 
  2146. <input type="submit" id="bookmarks-submit" name="submit" value="<?php echo esc_attr(__("Done", WYSIJA)) ?>" class="button-primary"/> 
  2147. </p> 
  2148. </form> 
  2149.  
  2150. </div> 
  2151. <?php 
  2152.  
  2153. function popup_wysija_browse($errors) { 
  2154. echo $this->messages(true); 
  2155. ?><div id="overlay"><img id="loader" src="<?php echo WYSIJA_URL ?>img/wpspin_light.gif" /></div> 
  2156. <div class="popup_content media-browse"> 
  2157. <?php 
  2158. global $redir_tab, $type; 
  2159.  
  2160. $redir_tab = 'wysija_browse'; 
  2161. media_upload_header(); 
  2162. $post_id = intval($_REQUEST['post_id']); 
  2163. ?> 
  2164.  
  2165. <form enctype="multipart/form-data" method="post" action="" class="media-upload-form validate" id="wysija-browse-form"> 
  2166. <?php 
  2167. $secure = array('action' => "medias"); 
  2168. $this->secure($secure); 
  2169. ?> 
  2170.  
  2171. <div id="media-items" class="clearfix"><?php echo $this->_get_media_items($post_id, $errors); ?></div> 
  2172. </form> 
  2173. <?php $this->_alt_close(); ?> 
  2174. </div> 
  2175. <?php 
  2176.  
  2177. function _alt_close() { 
  2178. ?> 
  2179. <p class="submit_button"><input type="submit" id="close-pop-alt" value="<?php echo esc_attr(__("Done", WYSIJA)) ?>" name="submit-draft" class="button-primary wysija"/></p> 
  2180. <?php 
  2181.  
  2182. function __filterPostParent($query) { 
  2183. global $wp_query; 
  2184.  
  2185. return $query . ' AND post_parent!=' . (int) $_REQUEST['post_id'] . ' '; 
  2186.  
  2187. function popup_wp_browse($errors) { 
  2188. echo $this->messages(true); 
  2189. ?><div id="overlay"><img id="loader" src="<?php echo WYSIJA_URL ?>img/wpspin_light.gif" /></div> 
  2190. <div class="popup_content media-wp-browse"> 
  2191. <?php 
  2192. global $redir_tab, $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; 
  2193.  
  2194. $redir_tab = 'wp_browse'; 
  2195.  
  2196. media_upload_header(); 
  2197.  
  2198. $limit = 20; 
  2199.  
  2200. $_GET['paged'] = isset($_GET['paged']) ? intval($_GET['paged']) : 0; 
  2201. if ($_GET['paged'] < 1) 
  2202. $_GET['paged'] = 1; 
  2203. $start = ( $_GET['paged'] - 1 ) * $limit; 
  2204. if ($start < 1) 
  2205. $start = 0; 
  2206. add_filter('post_limits', create_function('$a', "return 'LIMIT $start, $limit';")); 
  2207. add_filter('posts_where_paged', array($this, '__filterPostParent')); 
  2208. //add_filter( 'posts_where_paged', create_function( '$a', "return ' AND post_parent!=1' " ) ); 
  2209.  
  2210. list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(array('post_mime_type' => array('image'))); 
  2211. ?> 
  2212.  
  2213. <form enctype="multipart/form-data" method="post" action="" class="media-upload-form validate" id="library-form"> 
  2214.  
  2215. <div class="tablenav"> 
  2216.  
  2217. <?php 
  2218. $page_links = paginate_links(array( 
  2219. 'base' => add_query_arg('paged', '%#%'),  
  2220. 'format' => '',  
  2221. 'prev_text' => __('«'),  
  2222. 'next_text' => __('»'),  
  2223. 'total' => ceil($wp_query->found_posts / $limit),  
  2224. 'current' => $_GET['paged'] 
  2225. )); 
  2226.  
  2227. if ($page_links) 
  2228. echo "<div class='tablenav-pages'>$page_links</div>"; 
  2229. ?> 
  2230. </div> 
  2231.  
  2232.  
  2233. <?php 
  2234. $secure = array('action' => "medias"); 
  2235. $this->secure($secure); 
  2236. ?> 
  2237.  
  2238. <div id="media-items" class="clearfix"><?php echo $this->_get_media_items(null, $errors, true); ?></div> 
  2239. </form> 
  2240.  
  2241. <?php $this->_alt_close(); ?> 
  2242. </div> 
  2243. <?php 
  2244.  
  2245. function popup_new_wp_upload($errors) { 
  2246. echo $this->messages(true); 
  2247. ?> 
  2248. <div id="overlay"><img id="loader" src="<?php echo WYSIJA_URL ?>img/wpspin_light.gif" /></div> 
  2249. <div class="popup_content media-wp-upload"> 
  2250. <?php 
  2251. global $redir_tab, $type, $tab; 
  2252.  
  2253. $redir_tab = 'new_wp_upload'; 
  2254.  
  2255. media_upload_header(); 
  2256.  
  2257. global $type, $tab, $pagenow, $is_IE, $is_opera; 
  2258.  
  2259. if (function_exists('_device_can_upload') && !_device_can_upload()) { 
  2260. echo '<p>' . __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="http://wordpress.org/extend/mobile/">native app for your device</a> instead.') . '</p>'; 
  2261. return; 
  2262.  
  2263. $upload_action_url = admin_url('async-upload.php'); 
  2264. $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; 
  2265. $_type = isset($type) ? $type : ''; 
  2266. $_tab = isset($tab) ? $tab : ''; 
  2267.  
  2268. $upload_size_unit = $max_upload_size = wp_max_upload_size(); 
  2269. $sizes = array('KB', 'MB', 'GB'); 
  2270.  
  2271. for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) { 
  2272. $upload_size_unit /= 1024; 
  2273.  
  2274. if ($u < 0) { 
  2275. $upload_size_unit = 0; 
  2276. $u = 0; 
  2277. } else { 
  2278. $upload_size_unit = (int) $upload_size_unit; 
  2279. ?> 
  2280. <script type="text/javascript">var post_id = <?php echo $post_id; ?>;</script> 
  2281. <div id="media-upload-notice"><?php 
  2282. if (isset($errors['upload_notice'])) 
  2283. echo $errors['upload_notice']; 
  2284. ?></div> 
  2285. <div id="media-upload-error"><?php 
  2286. if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) 
  2287. echo $errors['upload_error']->get_error_message(); 
  2288. ?></div> 
  2289. <?php 
  2290. // Check quota for this blog if multisite 
  2291. if (is_multisite() && !is_upload_space_available()) { 
  2292. echo '<p>' . sprintf(__('Sorry, you have filled your storage quota (%s MB).'), get_space_allowed()) . '</p>'; 
  2293. return; 
  2294.  
  2295. do_action('pre-upload-ui'); 
  2296.  
  2297. $post_params = array( 
  2298. "post_id" => $post_id,  
  2299. "_wpnonce" => wp_create_nonce('media-form'),  
  2300. "type" => $_type,  
  2301. "tab" => $_tab,  
  2302. "short" => "1",  
  2303. ); 
  2304.  
  2305. $post_params = apply_filters('upload_post_params', $post_params); // hook change! old name: 'swfupload_post_params' 
  2306.  
  2307. $plupload_init = array( 
  2308. 'runtimes' => 'html5, silverlight, flash, html4',  
  2309. 'browse_button' => 'plupload-browse-button',  
  2310. 'container' => 'plupload-upload-ui',  
  2311. 'drop_element' => 'drag-drop-area',  
  2312. 'file_data_name' => 'async-upload',  
  2313. 'multiple_queues' => true,  
  2314. 'max_file_size' => $max_upload_size . 'b',  
  2315. 'url' => $upload_action_url,  
  2316. 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),  
  2317. 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),  
  2318. 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => '*')),  
  2319. 'multipart' => true,  
  2320. 'urlstream_upload' => true,  
  2321. 'multipart_params' => $post_params 
  2322. ); 
  2323.  
  2324. $plupload_init = apply_filters('plupload_init', $plupload_init); 
  2325. ?> 
  2326.  
  2327. <script type="text/javascript"> 
  2328. <?php 
  2329. // Verify size is an int. If not return default value. 
  2330. $large_size_h = absint(get_option('large_size_h')); 
  2331. if (!$large_size_h) 
  2332. $large_size_h = 1024; 
  2333. $large_size_w = absint(get_option('large_size_w')); 
  2334. if (!$large_size_w) 
  2335. $large_size_w = 1024; 
  2336. ?> 
  2337. var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>,  
  2338. wpUploaderInit = <?php echo json_encode($plupload_init); ?>; 
  2339. </script> 
  2340.  
  2341. <div id="plupload-upload-ui" class="hide-if-no-js"> 
  2342. <?php do_action('pre-plupload-upload-ui'); // hook change, old name: 'pre-flash-upload-ui' ?> 
  2343. <div id="drag-drop-area"> 
  2344. <div class="drag-drop-inside"> 
  2345. <p class="drag-drop-info"><?php _e('Drop files here', WYSIJA); ?></p> 
  2346. <p><?php _ex('or', 'Uploader: Drop files here - or - Select Files', WYSIJA); ?></p> 
  2347. <p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files', WYSIJA); ?>" class="button" /></p> 
  2348. </div> 
  2349. </div> 
  2350. <?php do_action('post-plupload-upload-ui'); // hook change, old name: 'post-flash-upload-ui' ?> 
  2351. </div> 
  2352.  
  2353. <div id="html-upload-ui" class="hide-if-js"> 
  2354. <?php do_action('pre-html-upload-ui'); ?> 
  2355. <p id="async-upload-wrap" class="clearfix"> 
  2356. <label class="screen-reader-text" for="async-upload"><?php _e('Upload', WYSIJA); ?></label> 
  2357. <input type="file" name="async-upload" id="async-upload" /> 
  2358. <?php submit_button(__('Upload'), 'button', 'html-upload', false); ?> 
  2359. <a href="#" onclick="try { 
  2360. top.tb_remove(); 
  2361. } catch (e) { 
  2362. return false;"><?php _e('Cancel', WYSIJA); ?></a> 
  2363. </p> 
  2364. <?php do_action('post-html-upload-ui'); ?> 
  2365. </div> 
  2366.  
  2367. <p class="max-upload-size"><?php printf(__('Maximum upload file size: %d%s.', WYSIJA), esc_html($upload_size_unit), esc_html($sizes[$u])); ?></p> 
  2368. <?php if (($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024) { ?> 
  2369. <p class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.', WYSIJA); ?></p> 
  2370. <?php } 
  2371. ?> 
  2372. <div id="media-items" class="hide-if-no-js"></div> 
  2373. <?php do_action('post-upload-ui'); ?> 
  2374. </div> 
  2375. <?php 
  2376.  
  2377. function popup_wp_upload($errors) { 
  2378. global $redir_tab, $type, $tab; 
  2379.  
  2380. $redir_tab = 'wp_upload'; 
  2381.  
  2382. media_upload_header(); 
  2383. $flash_action_url = admin_url('async-upload.php'); 
  2384.  
  2385. // If Mac and mod_security, no Flash. :( 
  2386. $flash = true; 
  2387. /** 
  2388. if(false !== stripos($_SERVER['HTTP_USER_AGENT'], 'mac') && apache_mod_loaded('mod_security')) { 
  2389. $flash = false; 
  2390. } */ 
  2391.  
  2392. $flash = apply_filters('flash_uploader', $flash); 
  2393. $post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; 
  2394.  
  2395. $upload_size_unit = $max_upload_size = wp_max_upload_size(); 
  2396. $sizes = array('KB', 'MB', 'GB'); 
  2397. for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) 
  2398. $upload_size_unit /= 1024; 
  2399. if ($u < 0) { 
  2400. $upload_size_unit = 0; 
  2401. $u = 0; 
  2402. } else { 
  2403. $upload_size_unit = (int) $upload_size_unit; 
  2404. echo $this->messages(true); 
  2405. ?> 
  2406. <div class="updated"><ul><li><?php _e('Please update your WordPress to the latest version, in order to get the latest uploading system.', WYSIJA) ?></li></ul></div> 
  2407. <div id="overlay"><img id="loader" src="<?php echo WYSIJA_URL ?>img/wpspin_light.gif" /></div> 
  2408. <div class="popup_content media-wp-upload"> 
  2409. <script type="text/javascript"> 
  2410. //<![CDATA[ 
  2411. var uploaderMode = 0; 
  2412. jQuery(document).ready(function($) { 
  2413. uploaderMode = getUserSetting('uploader'); 
  2414. $('.upload-html-bypass a').click(function() { 
  2415. deleteUserSetting('uploader'); 
  2416. uploaderMode = 0; 
  2417. swfuploadPreLoad(); 
  2418. return false; 
  2419. }); 
  2420. $('.upload-flash-bypass a').click(function() { 
  2421. setUserSetting('uploader', '1'); 
  2422. uploaderMode = 1; 
  2423. swfuploadPreLoad(); 
  2424. return false; 
  2425. }); 
  2426. }); 
  2427. //]]> 
  2428. </script> 
  2429.  
  2430. <div id="media-upload-notice"> 
  2431. <?php if (isset($errors['upload_notice'])) { ?> 
  2432. <?php echo $errors['upload_notice']; ?> 
  2433. <?php } ?> 
  2434. </div> 
  2435. <div id="media-upload-error"> 
  2436. <?php if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) { ?> 
  2437. <?php echo $errors['upload_error']->get_error_message(); ?> 
  2438. <?php } ?> 
  2439. </div> 
  2440. <?php 
  2441. // Check quota for this blog if multisite 
  2442. if (is_multisite() && !is_upload_space_available()) { 
  2443. echo '<p>' . sprintf(__('Sorry, you have filled your storage quota (%s MB).'), get_space_allowed()) . '</p>'; 
  2444. return; 
  2445.  
  2446. do_action('pre-upload-ui'); 
  2447.  
  2448. if ($flash) : 
  2449. ?> 
  2450. <script type="text/javascript"> 
  2451. //<![CDATA[ 
  2452. var swfu; 
  2453. SWFUpload.onload = function() { 
  2454. var settings = { 
  2455. button_text: '<span class="button"><?php _e('Select Files', WYSIJA); ?><\/span>',  
  2456. button_text_style: '.button { text-align: center; font-weight: bold; font-family:"Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-size: 11px; text-shadow: 0 1px 0 #FFFFFF; color:#464646; }',  
  2457. button_height: "23",  
  2458. button_width: "132",  
  2459. button_text_top_padding: 3,  
  2460. button_image_url: '<?php echo includes_url('images/upload.png?ver=20100531'); ?>',  
  2461. button_placeholder_id: "flash-browse-button",  
  2462. upload_url: "<?php echo esc_attr($flash_action_url); ?>",  
  2463. flash_url: "<?php echo includes_url() . 'js/swfupload/swfupload.swf'; ?>",  
  2464. file_post_name: "async-upload",  
  2465. file_types: "<?php echo apply_filters('upload_file_glob', '*.*'); ?>",  
  2466. post_params: { 
  2467. "post_id": "<?php echo $post_id; ?>",  
  2468. "auth_cookie": "<?php echo (is_ssl() ? $_COOKIE[SECURE_AUTH_COOKIE] : $_COOKIE[AUTH_COOKIE]); ?>",  
  2469. "logged_in_cookie": "<?php echo $_COOKIE[LOGGED_IN_COOKIE]; ?>",  
  2470. "_wpnonce": "<?php echo wp_create_nonce('media-form'); ?>",  
  2471. "type": "<?php echo $type; ?>",  
  2472. "tab": "<?php echo $tab; ?>",  
  2473. "short": "1" 
  2474. },  
  2475. file_size_limit: "<?php echo $max_upload_size; ?>b",  
  2476. file_dialog_start_handler: fileDialogStart,  
  2477. file_queued_handler: fileQueued,  
  2478. upload_start_handler: uploadStart,  
  2479. upload_progress_handler: uploadProgress,  
  2480. upload_error_handler: uploadError,  
  2481. upload_success_handler: WYSIJAuploadSuccess,  
  2482. upload_complete_handler: WYSIJAuploadComplete,  
  2483. file_queue_error_handler: fileQueueError,  
  2484. file_dialog_complete_handler: fileDialogComplete,  
  2485. swfupload_pre_load_handler: swfuploadPreLoad,  
  2486. swfupload_load_failed_handler: swfuploadLoadFailed,  
  2487. custom_settings: { 
  2488. degraded_element_id: "html-upload-ui", // id of the element displayed when swfupload is unavailable 
  2489. swfupload_element_id: "flash-upload-ui" // id of the element displayed when swfupload is available 
  2490. },  
  2491. debug: false 
  2492. }; 
  2493. swfu = new SWFUpload(settings); 
  2494. }; 
  2495. //]]> 
  2496. </script> 
  2497.  
  2498. <div id="flash-upload-ui" class="hide-if-no-js"> 
  2499. <?php do_action('pre-flash-upload-ui'); ?> 
  2500.  
  2501. <div> 
  2502. <?php _e('Choose files to upload', WYSIJA); ?> 
  2503. <div id="flash-browse-button"></div> 
  2504. <span><input id="cancel-upload" disabled="disabled" onclick="cancelUpload()" type="button" value="<?php esc_attr_e('Cancel Upload', WYSIJA); ?>" class="button" /></span> 
  2505. </div> 
  2506. <p class="media-upload-size"><?php printf(__('Maximum upload file size: %d%s', WYSIJA), $upload_size_unit, $sizes[$u]); ?></p> 
  2507. <?php do_action('post-flash-upload-ui'); ?> 
  2508. </div> 
  2509. <?php endif; // $flash ?> 
  2510.  
  2511. <div id="html-upload-ui"> 
  2512. <?php do_action('pre-html-upload-ui'); ?> 
  2513. <p id="async-upload-wrap"> 
  2514. <label class="screen-reader-text" for="async-upload"><?php _e('Upload', WYSIJA); ?></label> 
  2515. <input type="file" name="async-upload" id="async-upload" /> <input type="submit" class="button" name="html-upload" value="<?php esc_attr_e('Upload', WYSIJA); ?>" /> <a href="#" onclick="try { 
  2516. top.tb_remove(); 
  2517. } catch (e) { 
  2518. return false;"><?php _e('Cancel', WYSIJA); ?></a> 
  2519. </p> 
  2520. <div class="clear"></div> 
  2521. <p class="media-upload-size"><?php printf(__('Maximum upload file size: %d%s', WYSIJA), $upload_size_unit, $sizes[$u]); ?></p> 
  2522. <?php if (is_lighttpd_before_150()): ?> 
  2523. <p><?php _e('If you want to use all capabilities of the uploader, like uploading multiple files at once, please upgrade to lighttpd 1.5.'); ?></p> 
  2524. <?php endif; ?> 
  2525. <?php do_action('post-html-upload-ui', $flash); ?> 
  2526. </div> 
  2527. <?php do_action('post-upload-ui'); ?> 
  2528. <div id="media-items" class="clearfix"></div> 
  2529. </div> 
  2530. <?php 
  2531.  
  2532. function _get_media_items($post_id, $errors, $wpimage = false) { 
  2533. $attachments = array(); 
  2534.  
  2535. if ($post_id) { 
  2536. $post = get_post($post_id); 
  2537. if ($post && $post->post_type == 'attachment') 
  2538. $attachments = array($post->ID => $post); 
  2539. else 
  2540. $attachments = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'ID', 'order' => 'DESC', 'post_mime_type' => 'image')); 
  2541. } else { 
  2542.  
  2543. // old weird code reverted as the pagination broke 
  2544. if (is_array($GLOBALS['wp_the_query']->posts)) { 
  2545. foreach ($GLOBALS['wp_the_query']->posts as $attachment) { 
  2546. $attachments[$attachment->ID] = $attachment; 
  2547. //TODO update the code so that we take care of the query ourselves without passing through WP get_posts() or get_children() 
  2548. //$attachments = get_children( array( 'post_type' => 'attachment', 'orderby' => 'ID', 'order' => 'DESC', 'post_mime_type'=>'image') ); 
  2549.  
  2550. $selectedImages=$this->_getSelectedImages(); 
  2551. $output = ''; 
  2552. $helper_image = WYSIJA::get('image', 'helper'); 
  2553. foreach ( (array) $attachments as $id => $attachment ) { 
  2554.  
  2555. if (!$post_id && $attachment->post_parent == $_REQUEST['post_id']) { 
  2556. continue; 
  2557. if ($attachment->post_status == 'trash') { 
  2558. continue; 
  2559. if ($attachment->post_mime_type == 'image/bmp') { 
  2560. continue; 
  2561. if (($id = intval($id)) && ($thumb_details = wp_get_attachment_image_src($id, 'thumbnail', true))) { 
  2562. $thumb_url = $thumb_details[0]; 
  2563. } else { 
  2564. $thumb_url = false; 
  2565.  
  2566. // Check if we have our image size, otherwise, use full image. 
  2567. if (($id = intval($id)) && ($wysija_sized_image = wp_get_attachment_image_src($id, 'wysija-newsletters-max', true))) { 
  2568. $full_url = $wysija_sized_image[0]; 
  2569. } else { 
  2570. $full_url = $attachment->guid; 
  2571.  
  2572. if ( ( $id = intval( $id ) )) $img_details = wp_get_attachment_image_src( $id, 'full', true ); 
  2573.  
  2574. $image_template = array( 
  2575. 'width'=> $img_details[1],  
  2576. 'height'=> $img_details[2],  
  2577. 'url'=> $full_url,  
  2578. ); 
  2579.  
  2580. if(empty($image_template['width']) || empty($image_template['height']) || (empty($image_template['width']) && empty($image_template['height']))) { 
  2581. $image_template = $helper_image->valid_image($image_template); 
  2582.  
  2583.  
  2584. $classname=""; 
  2585.  
  2586. if(isset($selectedImages["wp-".$attachment->ID])) $classname=" selected "; 
  2587.  
  2588. $output.='<div class="wysija-thumb image-'. esc_attr($attachment->ID.$classname).'">'; 
  2589. $output .= '<img title="'. esc_attr($attachment->post_title).'" alt="'. esc_attr($attachment->post_title).'" src="'.esc_url($thumb_url).'" class="thumbnail" />'; 
  2590. if(!$wpimage) $output.='<span class="delete-wrap"><span class="delete del-attachment">'.esc_html($attachment->ID).'</span></span>'; 
  2591. $output.='<span class="identifier">'. esc_html($attachment->ID).'</span> 
  2592. <span class="width">'.$image_template['width'].'</span> 
  2593. <span class="height">'.$image_template['height'].'</span> 
  2594. <span class="url">'.esc_url($full_url).'</span> 
  2595. <span class="thumb_url">'.esc_url($thumb_url).'</span></div>'; 
  2596. if (!$output) { 
  2597. if($wpimage === false) { 
  2598. $output = "<em>" . __('This tab will be filled with images from your current and previous newsletters.', WYSIJA) . "</em>"; 
  2599. } else { 
  2600. $output = "<em>" . __('This tab will be filled with images from your WordPress Posts.', WYSIJA) . "</em>"; 
  2601. return $output; 
  2602.  
  2603. function _getSelectedImages() { 
  2604. $modelEmail = WYSIJA::get("email", "model"); 
  2605. $email = $modelEmail->getOne(false, array("email_id" => $_REQUEST['emailId'])); 
  2606.  
  2607. if (!isset($email['params']['quickselection']) or empty($email['params']['quickselection'])) 
  2608. return array(); 
  2609. return $email['params']['quickselection']; 
  2610.  
  2611. function welcome_new($data) { 
  2612. ?> 
  2613. <div id="update-page" class="about-wrap mpoet-page"> 
  2614.  
  2615. <h1><?php echo sprintf(__('Welcome to %1$s', WYSIJA), '<span class="version">MailPoet '.WYSIJA::get_version())."</span>"; ?></h1> 
  2616.  
  2617. <div class="about-text"><?php echo $data['abouttext'] ?></div> 
  2618. <?php 
  2619. foreach ($data['sections'] as $section) { 
  2620.  
  2621. $link_hide = $class_added = ''; 
  2622. if (isset($section['hidelink'])) { 
  2623. $link_hide = ' <span class="ctaupdate">-</span> ' . $section['hidelink']; 
  2624. $class_added = ' removeme'; 
  2625.  
  2626.  
  2627. ?> 
  2628. <div class="changelog <?php echo $class_added ?>"> 
  2629. <h2><?php echo $section['title'] . $link_hide ?></h2> 
  2630.  
  2631. <div class="feature-section <?php echo $section['format'] ?>"> 
  2632. <?php 
  2633. switch ($section['format']) { 
  2634. case 'three-col': 
  2635. if(true) { 
  2636. foreach ($section['cols'] as $col) { 
  2637. ?> 
  2638. <div> 
  2639. <h4><?php echo $col['title'] ?></h4> 
  2640. <p><?php echo $col['content'] ?></p> 
  2641. </div> 
  2642. <?php 
  2643. }else{ 
  2644. $quick_html_helper = WYSIJA::get('quick_html', 'helper'); 
  2645. echo $quick_html_helper->three_arguments($section['cols']); 
  2646.  
  2647. break; 
  2648. case 'bullets': 
  2649. echo '<ul>'; 
  2650. foreach ($section['paragraphs'] as $line) { 
  2651. ?> 
  2652. <li><?php echo $line ?></li> 
  2653. <?php 
  2654. echo '</ul>'; 
  2655. break; 
  2656.  
  2657. default : 
  2658. foreach ($section['paragraphs'] as $line) { 
  2659. echo '<p>'.$line.'</p>'; 
  2660. ?> 
  2661. </div> 
  2662. </div> 
  2663. <?php 
  2664. ?> 
  2665.  
  2666. <a class="button-primary" href="admin.php?page=wysija_campaigns"><?php _e('Thanks! Now take me to MailPoet.', WYSIJA); ?></a> 
  2667.  
  2668. </div> 
  2669.  
  2670.  
  2671. <?php 
  2672.  
  2673. function whats_new($data) { 
  2674.  
  2675. $helper_readme = WYSIJA::get('readme', 'helper'); 
  2676. $helper_readme->scan(); 
  2677. $helper_licence = WYSIJA::get('licence', 'helper'); 
  2678. $model_config = WYSIJA::get('config', 'model'); 
  2679. $data = array(); 
  2680. // 
  2681.   
  2682. $installed_time = (int)$model_config->getValue('installed_time'); 
  2683. $usage = time() - $installed_time; 
  2684.  
  2685. $helper_toolbox = WYSIJA::get('toolbox', 'helper'); 
  2686. $usage_string = $helper_toolbox->duration_string($usage, true, 1); 
  2687.  
  2688. $onemonth = 3600*24*31; 
  2689. $twomonths = 3600*24*62; 
  2690. $year = 3600*24*365; 
  2691. if( $usage > $twomonths) { 
  2692. $data['abouttext'] = sprintf(__('You have been a MailPoet user for %s.', WYSIJA), '<strong>'.trim($usage_string).'</strong>'); 
  2693. if( $usage > $twomonths) { 
  2694. $data['abouttext'] .= '<br/>'.__( 'Wow! Thanks for being part of our community for so long.' , WYSIJA ) ; 
  2695.  
  2696. }else{ 
  2697. $data['abouttext'] = __('You updated! It\'s like having the next gadget, but better.', WYSIJA); 
  2698.  
  2699.  
  2700. // this is a flag to have a pretty clean update page where teh only call to action is our survey 
  2701. $show_survey = false; 
  2702.  
  2703. $is_multisite = is_multisite(); 
  2704. $is_network_admin = WYSIJA::current_user_can('manage_network'); 
  2705.  
  2706.  
  2707. if ($is_multisite) { 
  2708. if ($is_network_admin) { 
  2709. $model_config->save(array('ms_wysija_whats_new' => WYSIJA::get_version())); 
  2710. } else { 
  2711. $model_config->save(array('wysija_whats_new' => WYSIJA::get_version())); 
  2712.  
  2713. $sharing_data = $model_config->getValue('analytics'); 
  2714. /** if( empty( $sharing_data ) ) { 
  2715. $data['sections'][] = array( 
  2716. 'title' => __('One quick question...', WYSIJA),  
  2717.   
  2718. 'content' => '<div class="feature-section"><iframe frameborder="0" width="100%" height="370" scrolling="auto" allowtransparency="true" src="//mailpoet.polldaddy.com/s/what-s-new-sept-2015?iframe=1"><a href="//mailpoet.polldaddy.com/s/what-s-new-sept-2015">View Survey</a></iframe></div>'. 
  2719. '<div class="mpoet-update-subscribe" ><h4>'.__( 'Subscribe to our newsletters', WYSIJA ).'</h4><div class="mpoet-update-subscribe-left"> <p>'.__('We send a monthly newsletter with the following:', WYSIJA).'</p>' . 
  2720. '<ul>' . 
  2721. '<li>'.__('Important plugin updates', WYSIJA).'</li>' . 
  2722. '<li>'.__('Coupons', WYSIJA).'</li>' . 
  2723. '<li>'.__('Tips for you, or your customers', WYSIJA).'</li>' . 
  2724. '<li>'.__('What we*re working on', WYSIJA).'</li>' . 
  2725. '<li>'.__('News from us, the team', WYSIJA).'</li>' . 
  2726. '</ul> 
  2727. <p>View <a target="_blank" href="http://www.mailpoet.com/?wysija-page=1&controller=email&action=view&email_id=1181&wysijap=subscriptions-3">an example blog post email</a> and <a target="_blank" href="http://www.mailpoet.com/?wysija-page=1&controller=email&action=view&email_id=64&wysijap=subscriptions-2">an example newsletter</a>.</p> 
  2728. </div>' . 
  2729. '<div class="mpoet-update-subscribe-right">' . 
  2730.   
  2731. '<iframe width="380" scrolling="no" frameborder="0" src="http://www.mailpoet.com/?wysija-page=1&controller=subscribers&action=wysija_outter&wysija_form=5&external_site=1&wysijap=subscriptions-3" class="iframe-wysija" vspace="0" tabindex="0" style="position: static; top: 0pt; margin: 0px; border-style: none; height: 180px; left: 0pt; visibility: visible; background-color: #f1f1f1!important;" marginwidth="0" marginheight="0" hspace="0" allowtransparency="true" title="Subscription Wysija"></iframe> 
  2732. </div> 
  2733. <div style="clear:both;"></div>',  
  2734. 'format' => 'title-content',  
  2735. ); 
  2736. }*/ 
  2737.  
  2738.  
  2739.  
  2740. $msg = $model_config->getValue('ignore_msgs'); 
  2741. if ( !isset($msg['ctaupdate']) && $show_survey === false ) { 
  2742. $data['sections'][] = array( 
  2743. 'title' => __('Keep this plugin essentially free', WYSIJA),  
  2744. 'review' => array( 
  2745. 'title' => '1. ' . __('Love kittens?', WYSIJA) . ' ' . __('We love stars...', WYSIJA),  
  2746. 'content' => str_replace( 
  2747. array('[link]', '[/link]'), array('<a href="http://goo.gl/D52CBL" target="_blank" title="On wordpress.org">', '</a>'), __('Each time one of our users forgets to write a review, a kitten dies. It\'s sad and breaks our hearts. [link]Add your own review[/link] and save a kitten today.', WYSIJA)) 
  2748. ),  
  2749. 'follow' => array( 
  2750. 'title' => '2. ' . __('Follow us and don\'t miss anything!', WYSIJA),  
  2751. 'content' => $this->_get_social_buttons(false) 
  2752. ),  
  2753. 'hidelink' => '<a class="linkignore ctaupdate" href="javascript:;">' . __('Hide!', WYSIJA) . '</a>',  
  2754. 'format' => 'review-follow',  
  2755. ); 
  2756.  
  2757. /** if( $show_survey ) { 
  2758. $data['sections'][] = array( 
  2759. 'title' => 'Answer our survey and make your plugin better',  
  2760.   
  2761. 'content' => '<iframe frameborder="0" width="100%" height="600" scrolling="auto" allowtransparency="true" src="//mailpoet.polldaddy.com/s/what-s-new-sept-2015?iframe=1"><a href="//mailpoet.polldaddy.com/s/what-s-new-sept-2015">View Survey</a></iframe><hr/>',  
  2762. 'format' => 'title-content',  
  2763. ); 
  2764. }*/ 
  2765.  
  2766. if (isset($helper_readme->changelog[WYSIJA::get_version()])) { 
  2767. $data['sections'][] = array( 
  2768. 'title' => __('Change log', WYSIJA),  
  2769. 'format' => 'bullets',  
  2770. 'paragraphs' => $helper_readme->changelog[WYSIJA::get_version()] 
  2771. ); 
  2772.  
  2773. ?> 
  2774. <div id="update-page" class="about-wrap mpoet-page"> 
  2775.  
  2776. <h1><?php echo sprintf(__('You\'ve updated to %1$s', WYSIJA), '<span class="version">MailPoet '.WYSIJA::get_version())."</span>"; ?></h1> 
  2777.  
  2778. <div class="about-text"><?php echo $data['abouttext'] ?></div> 
  2779. <?php 
  2780. foreach ($data['sections'] as $section) { 
  2781.  
  2782. $link_hide = $class_added = ''; 
  2783. if (isset($section['hidelink'])) { 
  2784. $link_hide = ' <span class="ctaupdate">-</span> ' . $section['hidelink']; 
  2785. $class_added = ' removeme'; 
  2786.  
  2787.  
  2788. ?> 
  2789. <div class="changelog <?php echo $class_added ?>"> 
  2790. <h2><?php echo $section['title'] . $link_hide ?></h2> 
  2791.  
  2792. <div class="feature-section <?php echo $section['format'] ?>"> 
  2793. <?php 
  2794. switch ($section['format']) { 
  2795. case 'title-content': 
  2796. ?> 
  2797. <div> 
  2798. <?php echo $section['content'] ?> 
  2799. </div> 
  2800. <?php 
  2801. break; 
  2802. case 'three-col': 
  2803. if(isset($section['content'])) { 
  2804. foreach ($section['cols'] as $col) { 
  2805. ?> 
  2806. <div> 
  2807. <h4><?php echo $col['title'] ?></h4> 
  2808. <p><?php echo $col['content'] ?></p> 
  2809. </div> 
  2810. <?php 
  2811. }else{ 
  2812. $quick_html_helper = WYSIJA::get('quick_html', 'helper'); 
  2813. echo $quick_html_helper->three_arguments($section['cols']); 
  2814.  
  2815. break; 
  2816. case 'bullets': 
  2817. echo '<ul>'; 
  2818. foreach ($section['paragraphs'] as $line) { 
  2819. ?> 
  2820. <li><?php echo $line ?></li> 
  2821. <?php 
  2822. echo '</ul>'; 
  2823. break; 
  2824. case 'review-follow': 
  2825. $class_review_kitten = ' small'; 
  2826. $count_title = count(str_split($section['review']['title'])); 
  2827. $count_content = count(str_split($section['review']['content'])); 
  2828. if ($count_title > 40 || $count_content > 340) 
  2829. $class_review_kitten = ' medium'; 
  2830. if ($count_title > 50 || $count_content > 400) 
  2831. $class_review_kitten = ' large'; 
  2832.  
  2833. echo '<div id="review-follow">'; 
  2834.  
  2835. echo '<div class="review-left' . $class_review_kitten . '">'; 
  2836. echo '<div class="description"><h4>' . $section['review']['title'] . '</h4>'; 
  2837. echo '<p>' . $section['review']['content'] . '</p></div>'; 
  2838. echo '<a title="On wordpress.org" target="_blank" class="link-cat-review" href="http://goo.gl/P0r5Fc"> </a></div>'; 
  2839.  
  2840. echo '<div class="review-right">'; 
  2841. echo '</div>'; 
  2842.  
  2843. echo '<div class="subscribe-middle' . $class_review_kitten . '">'; 
  2844. echo '<div class="description" ><h4>' . $section['follow']['title'] . '</h4>'; 
  2845. echo '<div class="socials">' . $section['follow']['content'] . '</div></div>'; 
  2846. echo '</div>'; 
  2847.  
  2848.  
  2849. $class_name = 'follow-right'; 
  2850. if(version_compare(get_bloginfo('version'), '3.8')>= 0) { 
  2851. $class_name .= '38'; 
  2852. echo '<div class="'.$class_name.'">'; 
  2853. echo '</div>'; 
  2854. echo '</div>'; 
  2855. break; 
  2856.  
  2857. default : 
  2858. foreach ($section['paragraphs'] as $line) { 
  2859. ?> 
  2860. <p><?php echo $line ?></p> 
  2861. <?php 
  2862. ?> 
  2863. </div> 
  2864. </div> 
  2865. <?php 
  2866. $link_class = 'button-primary'; 
  2867. if($show_survey) { 
  2868. $link_class = 'button-secondary'; 
  2869. ?> 
  2870.  
  2871. <a class="<?php echo $link_class ?>" href="admin.php?page=wysija_campaigns"><?php _e('Thanks! Now take me to MailPoet.', WYSIJA); ?></a> 
  2872.  
  2873. </div> 
  2874.  
  2875.  
  2876. <?php 
  2877.  
  2878. /** 
  2879. * poll section, we inject one section in the $data object if a poll is available 
  2880. * @param array $data 
  2881. * @return array 
  2882. */ 
  2883. private function _inject_poll( $data ) { 
  2884. $polls_available = array( '7970424' ); // all polls' ids from polldaddy 
  2885. $display_poll = 0; // poll id to display 
  2886.  
  2887. $model_config = WYSIJA::get( 'config' , 'model' ); 
  2888. $polls_already_viewed = $model_config->getValue('viewed_polls'); 
  2889.  
  2890. // we go through all of the viewed polls in order to find one that has not been viewed yet 
  2891. if( !empty($polls_already_viewed) ) { 
  2892. foreach( $polls_available as $poll_id ) { 
  2893. if( !in_array( $poll_id , $polls_already_viewed )) { 
  2894. $display_poll = $poll_id; 
  2895. }else{ 
  2896. // no poll has been viewed yet, let's display the first one 
  2897. $display_poll = $polls_available[0]; 
  2898.  
  2899. // only if we found a poll which has not been viewed yet, will we display it 
  2900. if( $display_poll > 0 ) { 
  2901. $data['sections'][] = array( 
  2902. 'title' => __('Hey! We have a quick question for you:', WYSIJA),  
  2903. 'paragraphs' => array( 
  2904. 'line1' => '<script type="text/javascript" charset="utf-8" src="https://secure.polldaddy.com/p/'.$display_poll.'.js"></script> 
  2905. <noscript> 
  2906. <a href="https://polldaddy.com/poll/'.$display_poll.'/">'.__('Hey! We have a quick question for you:', WYSIJA).'</a> 
  2907. </noscript>' 
  2908. ),  
  2909. 'format' => 'paragraphs' 
  2910. ); 
  2911.  
  2912. $polls_already_viewed[] = $display_poll; 
  2913.  
  2914. // save the new array of viewed polls 
  2915. $model_config->save( array( 'viewed_polls' => $polls_already_viewed ) ); 
  2916.  
  2917. // returning the new data array 
  2918. return $data; 
  2919.  
  2920. private function _get_social_buttons($inline=true) { 
  2921.  
  2922. if($inline) { 
  2923. $class=' class="socials removeme"'; 
  2924. }else{ 
  2925. $class=' id="socials-block"'; 
  2926. $wysijaversion='<div '.$class.'> 
  2927. <div class="fb" > 
  2928. <div id="fb-root"></div> 
  2929. <script>(function(d, s, id) { 
  2930. var js, fjs = d.getElementsByTagName(s)[0]; 
  2931. if (d.getElementById(id)) return; 
  2932. js = d.createElement(s); js.id = id; 
  2933. js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; 
  2934. fjs.parentNode.insertBefore(js, fjs); 
  2935. }(document, \'script\', \'facebook-jssdk\'));</script> 
  2936. <div class="fb-like" data-href="http://www.facebook.com/mailpoetplugin" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div> 
  2937. <div class="twitter"> 
  2938. <a href="https://twitter.com/mail_poet" class="twitter-follow-button" data-show-count="true" data-show-screen-name="false">Follow us</a> 
  2939. <script>!function(d, s, id) {var js, fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)) {js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js, fjs);}}(document, "script", "twitter-wjs");</script> 
  2940. </div> 
  2941. <div class="gplus"> 
  2942. <!-- Place this tag in your head or just before your close body tag --> 
  2943. <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> 
  2944. <!-- Place this tag where you want the +1 button to render --> 
  2945. <g:plusone href="https://plus.google.com/104749849451537343615" size="medium"></g:plusone></div> 
  2946. '; 
  2947. if($inline) $wysijaversion.='<div id="hidesocials"> 
  2948. <a class="linkignore socialfoot" href="javascript:;">'.__('Hide!', WYSIJA).'</a> 
  2949. </div>'; 
  2950. $wysijaversion.= "<div style='clear:both;'></div></div><div style='clear:both;'></div>"; 
  2951. return $wysijaversion;