WYSIJA_help_back

Class managing the admin vital part to integrate wordpress.

Defined (1)

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

/helpers/back.php  
  1. class WYSIJA_help_back extends WYSIJA_help{ 
  2.  
  3. function __construct() { 
  4. parent::__construct(); 
  5. //check that the application has been installed properly 
  6. $config=WYSIJA::get('config', 'model'); 
  7.  
  8. define('WYSIJA_DBG', (int)$config->getValue('debug_new')); 
  9. //by default do not show the errors until we get into the debug file 
  10. if(!defined('WP_DEBUG') || !WP_DEBUG) { 
  11. error_reporting(0); 
  12. ini_set('display_errors', '0'); 
  13.  
  14. add_filter('admin_footer_text', array(&$this, 'admin_footer_text')); 
  15. add_filter('update_footer', array(&$this, 'update_footer'), 15); 
  16.  
  17. //the controller is backend is it from our pages or from wordpress? 
  18. //are we pluging-in to wordpress interfaces or doing entirely our own page? 
  19. if(isset($_GET['page']) && substr($_GET['page'], 0, 7)=='wysija_') { 
  20. define('WYSIJA_ITF', TRUE); 
  21. $this->controller=WYSIJA::get(str_replace('wysija_', '', $_GET['page']), 'controller'); 
  22. }else{//check if we are pluging in wordpress interface 
  23. define('WYSIJA_ITF', FALSE); 
  24.  
  25. if( WYSIJA_DBG>0 ) include_once(WYSIJA_INC.'debug.php'); 
  26.  
  27. if(!function_exists('dbg')) { 
  28. function dbg($mixed, $exit=true) {} 
  29.  
  30.  
  31. //we set up the important hooks for backend: menus js css etc 
  32. if(defined('DOING_AJAX')) { 
  33. //difference between frontend and backend 
  34.  
  35. add_action( 'after_setup_theme', array($this, 'ajax_setup') ); 
  36.  
  37. }else{ 
  38. if(WYSIJA_ITF) { 
  39. add_action('admin_init', array( $this , 'verify_capability'), 1); 
  40. add_action('admin_init', array($this->controller, 'main')); 
  41. add_action('after_setup_theme', array($this, 'resolveConflicts')); 
  42. //this is a fix for qtranslate as we were loading translatable string quite early 
  43.  
  44.  
  45. //somehow if we add caps to one role the user with that role doesnt get its caps updated ... 
  46. add_action('after_setup_theme', array('WYSIJA', 'update_user_caps'), 11); 
  47. add_action('admin_menu', array($this, 'define_translated_strings'), 98); 
  48. add_action('admin_menu', array($this, 'add_menus'), 99); 
  49. add_action('admin_enqueue_scripts', array($this, 'add_js'), 10, 1); 
  50.  
  51.  
  52. //add specific page script 
  53. add_action('admin_head-post-new.php', array($this, 'addCodeToPagePost')); 
  54. add_action('admin_head-post.php', array($this, 'addCodeToPagePost')); 
  55.  
  56. //make sure that admin and super admin always have the highest access 
  57. $wptools = WYSIJA::get('wp_tools', 'helper'); 
  58. $wptools->set_default_rolecaps(); 
  59.  
  60. // Hook the warning function for premium. 
  61. add_action( 'admin_init', array(&$this, 'warn_action_on_premium') ); 
  62.  
  63. //if the comment form option is activated then we add an approval action 
  64. if($config->getValue('commentform')) { 
  65. add_action('wp_set_comment_status', array($this, 'comment_approved'), 60, 2); 
  66.  
  67. private function _set_ajax_nonces() { 
  68. if( isset( $_GET['page'] ) && substr( $_GET['page'] , 0 , 7 ) == 'wysija_' ) { 
  69.  
  70. $ajax_nonces = array( 
  71. 'campaigns' => array( 
  72. 'switch_theme' => WYSIJA_view::secure(array( 
  73. 'controller' => 'wysija_campaigns',  
  74. 'action' => 'switch_theme' 
  75. ), true),  
  76. 'save_editor' => WYSIJA_view::secure(array( 
  77. 'controller' => 'wysija_campaigns',  
  78. 'action' => 'save_editor' 
  79. ), true),  
  80. 'save_styles' => WYSIJA_view::secure(array( 
  81. 'controller' => 'wysija_campaigns',  
  82. 'action' => 'save_styles' 
  83. ), true),  
  84. 'deleteimg' => WYSIJA_view::secure(array( 
  85. 'controller' => 'wysija_campaigns',  
  86. 'action' => 'deleteimg' 
  87. ), true),  
  88. 'deleteTheme' => WYSIJA_view::secure(array( 
  89. 'controller' => 'wysija_campaigns',  
  90. 'action' => 'deleteTheme' 
  91. ), true),  
  92. 'save_IQS' => WYSIJA_view::secure(array( 
  93. 'controller' => 'wysija_campaigns',  
  94. 'action' => 'save_IQS' 
  95. ), true),  
  96. 'send_preview' => WYSIJA_view::secure(array( 
  97. 'controller' => 'wysija_campaigns',  
  98. 'action' => 'send_preview' 
  99. ), true),  
  100. 'send_spamtest' => WYSIJA_view::secure(array( 
  101. 'controller' => 'wysija_campaigns',  
  102. 'action' => 'send_spamtest' 
  103. ), true),  
  104. 'insert_articles' => WYSIJA_view::secure(array( 
  105. 'controller' => 'wysija_campaigns',  
  106. 'action' => 'insert_articles' 
  107. ), true),  
  108. 'set_divider' => WYSIJA_view::secure(array( 
  109. 'controller' => 'wysija_campaigns',  
  110. 'action' => 'set_divider' 
  111. ), true),  
  112. 'generate_social_bookmarks' => WYSIJA_view::secure(array( 
  113. 'controller' => 'wysija_campaigns',  
  114. 'action' => 'generate_social_bookmarks' 
  115. ), true),  
  116. 'install_theme' => WYSIJA_view::secure(array( 
  117. 'controller' => 'wysija_campaigns',  
  118. 'action' => 'install_theme' 
  119. ), true),  
  120. 'setDefaultTheme' => WYSIJA_view::secure(array( 
  121. 'controller' => 'wysija_campaigns',  
  122. 'action' => 'setDefaultTheme' 
  123. ), true),  
  124. 'deleteTheme' => WYSIJA_view::secure(array( 
  125. 'controller' => 'wysija_campaigns',  
  126. 'action' => 'deleteTheme' 
  127. ), true),  
  128. 'save_poll' => WYSIJA_view::secure(array( 
  129. 'controller' => 'wysija_campaigns',  
  130. 'action' => 'save_poll' 
  131. ), true),  
  132. 'sub_delete_image' => WYSIJA_view::secure(array( 
  133. 'controller' => 'wysija_campaigns',  
  134. 'action' => 'sub_delete_image',  
  135. ), true),  
  136.  
  137. ),  
  138. 'config' => array( 
  139. 'send_test_mail' => WYSIJA_view::secure(array( 
  140. 'controller' => 'wysija_config',  
  141. 'action' => 'send_test_mail' 
  142. ), true),  
  143. 'send_test_mail_ms' => WYSIJA_view::secure(array( 
  144. 'controller' => 'wysija_config',  
  145. 'action' => 'send_test_mail_ms' 
  146. ), true),  
  147. 'bounce_process' => WYSIJA_view::secure(array( 
  148. 'controller' => 'wysija_config',  
  149. 'action' => 'bounce_process' 
  150. ), true),  
  151. 'share_analytics' => WYSIJA_view::secure(array( 
  152. 'controller' => 'wysija_config',  
  153. 'action' => 'share_analytics' 
  154. ), true),  
  155. 'wysija_form_manage_field' => WYSIJA_view::secure(array( 
  156. 'controller' => 'wysija_config',  
  157. 'action' => 'wysija_form_manage_field' 
  158. ), true),  
  159. 'form_field_delete' => WYSIJA_view::secure(array( 
  160. 'controller' => 'wysija_config',  
  161. 'action' => 'form_field_delete' 
  162. ), true),  
  163. 'form_name_save' => WYSIJA_view::secure(array( 
  164. 'controller' => 'wysija_config',  
  165. 'action' => 'form_name_save' 
  166. ), true),  
  167. 'form_save' => WYSIJA_view::secure(array( 
  168. 'controller' => 'wysija_config',  
  169. 'action' => 'form_save' 
  170. ), true),  
  171. 'validate' => WYSIJA_view::secure(array( 
  172. 'controller' => 'wysija_config',  
  173. 'action' => 'validate' 
  174. ), true),  
  175. 'linkignore' => WYSIJA_view::secure(array( 
  176. 'controller' => 'wysija_config',  
  177. 'action' => 'linkignore' 
  178. ), true),  
  179. ); 
  180.  
  181. }else{ 
  182. $ajax_nonces = array(); 
  183.  
  184. wp_localize_script('wysija-admin', 'wysijanonces', $ajax_nonces); 
  185.  
  186. /** 
  187. * On any of the administration pages related to MailPoet, if the user 
  188. * has the key and doesn't have the premium plugin active a warning will 
  189. * be displayed. 
  190. * @return null 
  191. */ 
  192. public function warn_action_on_premium() { 
  193. $mdl_config=WYSIJA::get('config', 'model'); 
  194.  
  195. if($mdl_config->getValue('premium_key') && !WYSIJA::is_plugin_active(WJ_Upgrade::$plugins[1])) { 
  196. if( file_exists( WPMU_PLUGIN_DIR . DIRECTORY_SEPARATOR . WJ_Upgrade::$plugins[1] ) || file_exists( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . WJ_Upgrade::$plugins[1] ) ) { 
  197. //send a message to the user so that he activates the premium plugin or try to fetch it directly. 
  198. $this->notice('<p>'.__('You need to activate the MailPoet Premium plugin.', WYSIJA).' <a data-warn="' . esc_attr__( "Confirm activating the MailPoet Premium Plugin?", WYSIJA ) . '" class="button-primary" title="' . esc_attr__( "Activate MailPoet Premium Version", WYSIJA ) . '" href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode(WJ_Upgrade::$plugins[1]) . '&plugin_status=all', 'activate-plugin_' . WJ_Upgrade::$plugins[1]) . '">'.__('Activate now', WYSIJA).'</a></p>'); 
  199. } else { 
  200.  
  201. $args = array( 
  202. 'page' => 'wysija_config',  
  203. 'action' => 'packager-switch',  
  204. '_mp_action' => 'install',  
  205. '_wpnonce' => wp_create_nonce('packager-switch'),  
  206. ); 
  207. if (WYSIJA::is_beta()) 
  208. $args["stable"] = 1; 
  209.  
  210. $link = esc_attr(add_query_arg($args, admin_url('admin.php'))); 
  211.  
  212. //send a message to the user so that he gets the premium plugin or try to fetch it directly. 
  213. $this->notice('<p>'.__('Congrats, your Premium license is active. One last step...', WYSIJA).' <a data-warn="' . esc_attr__( "Confirm installing the MailPoet Premium Plugin?", WYSIJA ) . '" id="install-wjp" class="button-primary" title="' . esc_attr__( "Installing MailPoet Premium Version", WYSIJA ) . '" href="' . esc_url($link) . '">'.__('Download the Premium plugin.', WYSIJA).'</a></p>'); 
  214.  
  215. return null; 
  216.  
  217. function comment_approved($cid, $comment_status) { 
  218. //if the comment is approved and the meta wysija_comment_subscribe appears, then we have one subscriber more to add 
  219. $metaresult=get_comment_meta($cid, 'wysija_comment_subscribe', true); 
  220.  
  221. if($comment_status=='approve' && get_comment_meta($cid, 'wysija_comment_subscribe', true)) { 
  222. $mConfig=WYSIJA::get('config', 'model'); 
  223. $comment = get_comment($cid); 
  224. $userHelper=WYSIJA::get('user', 'helper'); 
  225. $data=array('user'=>array('email'=>$comment->comment_author_email, 'firstname'=>$comment->comment_author), 'user_list'=>array('list_ids'=>$mConfig->getValue('commentform_lists'))); 
  226. $userHelper->addSubscriber($data); 
  227.  
  228. function ajax_setup() { 
  229. if(!isset($_REQUEST['adminurl']) && !is_user_logged_in()) add_action('wp_ajax_nopriv_wysija_ajax', array($this, 'ajax')); 
  230. else add_action('wp_ajax_wysija_ajax', array($this, 'ajax')); 
  231.  
  232.  
  233. /** 
  234. * let's fix all the conflicts that we may have 
  235. */ 
  236. function resolveConflicts() { 
  237.  
  238. // check conflicting themes 
  239. $possibleConflictiveThemes = $this->controller->get_conflictive_plugins(true); 
  240.  
  241. $conflictingTheme = null; 
  242. $currentTheme = strtolower(function_exists( 'wp_get_theme' ) ? wp_get_theme() : get_current_theme()); 
  243. foreach($possibleConflictiveThemes as $keyTheme => $conflictTheme) { 
  244. if($keyTheme === $currentTheme) { 
  245. $conflictingTheme = $keyTheme; 
  246.  
  247. // if the current theme is known to make troubles, let's resolve this 
  248. if($conflictingTheme !== null) { 
  249. $helperConflicts = WYSIJA::get('conflicts', 'helper'); 
  250. $helperConflicts->resolve(array($possibleConflictiveThemes[$conflictingTheme])); 
  251.  
  252. // check conflicting plugins 
  253. $possibleConflictivePlugins=$this->controller->get_conflictive_plugins(); 
  254.  
  255. $conflictingPlugins=array(); 
  256. foreach($possibleConflictivePlugins as $keyPlg => $conflictPlug) { 
  257. if(WYSIJA::is_plugin_active($conflictPlug['file'])) { 
  258. //plugin is activated 
  259. $conflictingPlugins[$keyPlg]=$conflictPlug; 
  260.  
  261. if($conflictingPlugins) { 
  262. $helperConflicts=WYSIJA::get('conflicts', 'helper'); 
  263. $helperConflicts->resolve($conflictingPlugins); 
  264.  
  265. /** 
  266. * this function will check the role of the user executing the action, if it's called from another 
  267. * WordPress admin page than page.php for instance admin-post.php 
  268. * @return boolean 
  269. */ 
  270. function verify_capability() { 
  271. if( isset( $_GET['page'] ) && substr( $_GET['page'] , 0 , 7 ) == 'wysija_' ) { 
  272.  
  273. switch( $_GET['page'] ) { 
  274. case 'wysija_campaigns': 
  275. $role_needed = 'wysija_newsletters'; 
  276. break; 
  277. case 'wysija_subscribers': 
  278. $role_needed = 'wysija_subscribers'; 
  279. break; 
  280. case 'wysija_config': 
  281. $role_needed = 'wysija_config'; 
  282. break; 
  283. case 'wysija_statistics': 
  284. $role_needed = 'wysija_stats_dashboard'; 
  285. break; 
  286. default: 
  287. $role_needed = 'switch_themes'; 
  288.  
  289. if( current_user_can( $role_needed ) ) { 
  290. return true; 
  291. } else{ 
  292. die( 'You are not allowed here.' ); 
  293.  
  294. }else{ 
  295. // this is not a wysija interface/action we can let it pass 
  296. return true; 
  297.  
  298. /** 
  299. * translatable strings need to be not loaded to early, this is why we put them ina separate function 
  300. * @global type $wysija_installing 
  301. */ 
  302. function define_translated_strings() { 
  303. $config = WYSIJA::get('config', 'model'); 
  304. $linkcontent = __("It doesn't always work the way we want it to, doesn't it? We have a [link]dedicated support website[/link] with documentation and a ticketing system.", WYSIJA); 
  305. $finds = array('[link]', '[/link]'); 
  306. $replace = array('<a target="_blank" href="http://support.mailpoet.com" title="support.mailpoet.com">', '</a>'); 
  307. $truelinkhelp = '<p>'.str_replace($finds, $replace, $linkcontent).'</p>'; 
  308. $truelinkhelp .= '<p>'.__('MailPoet Version: ', WYSIJA).'<strong>'.WYSIJA::get_version().'</strong></p>'; 
  309.  
  310. $this->menus=array( 
  311. 'campaigns'=>array('title'=>'MailPoet'),  
  312. 'subscribers'=>array('title'=>__('Subscribers', WYSIJA)), // if the key "subscribers" is changed, please change in the filter "wysija_menus" as well. 
  313. 'config'=>array('title'=>__('Settings', WYSIJA)),  
  314. 'premium'=>array('title'=>__('Premium', WYSIJA)) 
  315. ); 
  316. $this->menus = apply_filters('wysija_menus', $this->menus); 
  317. $this->menuHelp = $truelinkhelp; 
  318. if($config->getValue('queue_sends_slow')) { 
  319. $msg=$config->getValue('ignore_msgs'); 
  320. if(!isset($msg['queuesendsslow'])) { 
  321. $this->notice( 
  322. __('Tired of waiting more than 48h to send your emails?', WYSIJA).' '. str_replace(array('[link]', '[/link]'), array('<a href="http://docs.mailpoet.com/article/48-wp-cron-batch-emails-sending-frequency" target="_blank">', '</a>'), __('[link]Find out[/link] how you can improve this.', WYSIJA)). 
  323. ' <a class="linkignore queuesendsslow" href="javascript:;">'.__('Hide!', WYSIJA).'</a>'); 
  324.  
  325. if(WYSIJA_ITF) { 
  326. global $wysija_installing; 
  327. if( !$config->getValue('sending_emails_ok')) { 
  328. $msg=$config->getValue('ignore_msgs'); 
  329.  
  330. $urlsendingmethod='admin.php?page=wysija_config#tab-sendingmethod'; 
  331. if($_REQUEST['page'] === 'wysija_config') { 
  332. $urlsendingmethod='#tab-sendingmethod'; 
  333.  
  334.  
  335.  
  336. function add_menus() { 
  337. global $menu, $submenu;// WordPress globals be careful there 
  338. $count=0; 
  339.  
  340. //anti conflicting menus code to make sure that another plugin is not at the same level as us 
  341. $position=50; 
  342. $positionplus1=$position+1; 
  343.  
  344. while(isset($menu[$position]) || isset($menu[$positionplus1])) { 
  345. $position++; 
  346. $positionplus1=$position+1; 
  347. //check that there is no menu at our level neither at ourlevel+1 because that will make us disappear in some case :/ 
  348. if(!isset($menu[$position]) && isset($menu[$positionplus1])) { 
  349. $position=$position+2; 
  350.  
  351. global $wysija_installing; 
  352. foreach($this->menus as $action=> $menutemp) { 
  353. $actionFull='wysija_'.$action; 
  354. if (!isset($menutemp['subtitle'])) 
  355. $menutemp['subtitle'] = $menutemp['title']; 
  356. if ($action == 'campaigns') 
  357. $roleformenu = 'wysija_newsletters'; 
  358. elseif ($action == 'subscribers') 
  359. $roleformenu = 'wysija_subscribers'; 
  360. elseif ($action == 'statistics') 
  361. $roleformenu = 'wysija_stats_dashboard'; 
  362. else 
  363. $roleformenu = 'wysija_config'; 
  364.  
  365. if($wysija_installing===true) { 
  366. if($count==0) { 
  367. $parentmenu=$actionFull; 
  368. $hookname = add_menu_page( 
  369. $menutemp['title'],  
  370. $menutemp['subtitle'],  
  371. $roleformenu,  
  372. $actionFull,  
  373. array($this->controller, 'errorInstall'),  
  374. WYSIJA_EDITOR_IMG.'menu-icon.png',  
  375. $position 
  376. ); 
  377. }else{ 
  378. if($count==0) { 
  379. $parentmenu = $actionFull; 
  380. $hookname = add_menu_page( 
  381. $menutemp['title'],  
  382. $menutemp['subtitle'],  
  383. $roleformenu,  
  384. $actionFull ,  
  385. array($this->controller, 'render'),  
  386. WYSIJA_EDITOR_IMG.'menu-icon.png',  
  387. $position 
  388. ); 
  389. }else{ 
  390. $hookname=add_submenu_page($parentmenu, $menutemp['title'], $menutemp['subtitle'], $roleformenu, $actionFull , array($this->controller, 'render')); 
  391.  
  392. //manage wp help tab 
  393. if(WYSIJA_ITF) { 
  394. //wp3.3 
  395. if(version_compare(get_bloginfo('version'), '3.3.0')>= 0) { 
  396. add_action('load-'.$hookname, array($this, 'add_help_tab')); 
  397. }else{ 
  398. //wp3.0 
  399. add_contextual_help($hookname, $this->menuHelp); 
  400. $count++; 
  401.  
  402. // Correct the text of submenu, in case there is only 1 submenu is enabled 
  403. if(isset($submenu[$parentmenu])) { 
  404. switch ($submenu[$parentmenu][0][2]) { 
  405. case 'wysija_subscribers': 
  406. $textmenu=__('Subscribers', WYSIJA); 
  407. break; 
  408.  
  409. case 'wysija_statistics': 
  410. $textmenu=__('Statistics', WYSIJA); 
  411. break; 
  412.  
  413. case 'wysija_config': 
  414. $textmenu=__('Settings', WYSIJA); 
  415. break; 
  416.  
  417. case 'wysija_campaigns': 
  418. default: 
  419. $textmenu=__('Newsletters', WYSIJA); 
  420. break; 
  421. $submenu[$parentmenu][0][0]=$submenu[$parentmenu][0][3]=$textmenu; 
  422.  
  423. function add_help_tab($params) { 
  424. $screen = get_current_screen(); 
  425.  
  426. if(method_exists($screen, "add_help_tab")) { 
  427. $screen->add_help_tab(array( 
  428. 'id' => 'wysija_help_tab',  
  429. 'title' => __('Get Help!', WYSIJA),  
  430. 'content'=> $this->menuHelp)); 
  431. $tabfunc=true; 
  432.  
  433. function add_js($hook) { 
  434. //needed in all the wordpress admin pages including wysija's ones 
  435.  
  436. $jstrans=array(); 
  437. wp_register_script('wysija-charts', 'https://www.google.com/jsapi', array( 'jquery' ), true); 
  438. wp_register_script('wysija-admin-list', WYSIJA_URL.'js/admin-listing.js', array( 'jquery' ), true, WYSIJA::get_version()); 
  439. wp_register_script('wysija-base-script-64', WYSIJA_URL.'js/base-script-64.js', array( 'jquery' ), true, WYSIJA::get_version()); 
  440.  
  441.  
  442. wp_enqueue_style('wysija-admin-css-widget', WYSIJA_URL.'css/admin-widget.css', array(), WYSIJA::get_version()); 
  443.  
  444. // If Cron enabled sending, send Mixpanel data and reset flag. 
  445. $model_config = WYSIJA::get('config', 'model'); 
  446. if ($model_config->getValue('send_analytics_now') == 1) { 
  447. $analytics = new WJ_Analytics(); 
  448. $analytics->generate_data(); 
  449. $analytics->send(); 
  450. // Reset sending flag. 
  451. $model_config->save(array('send_analytics_now' => 0)); 
  452.  
  453.  
  454. //we are in wysija's admin interface 
  455. if(WYSIJA_ITF) { 
  456. wp_enqueue_style('wysija-admin-css-global', WYSIJA_URL.'css/admin-global.css', array(), WYSIJA::get_version()); 
  457. wp_enqueue_script('wysija-admin-js-global', WYSIJA_URL.'js/admin-wysija-global.js', array(), WYSIJA::get_version()); 
  458. $pagename=str_replace('wysija_', '', $_REQUEST['page']); 
  459. $backloader=WYSIJA::get('backloader', 'helper'); 
  460. $backloader->init( $this->controller ); 
  461.  
  462. //$this->controller->jsTrans["ignoremsg"]=__('Are you sure you want to ignore this message?.', WYSIJA); 
  463. $jstrans=$this->controller->jsTrans; 
  464. //if(!in_array('wysija-admin-ajax-proto', $this->controller->js)) $this->controller->js[]='wysija-admin-ajax'; 
  465.  
  466. $jstrans['gopremium']=__('Go Premium!', WYSIJA); 
  467.  
  468. //enqueue all the scripts that have been declared in the controller 
  469. $backloader->parse_js( $this->controller, $pagename, WYSIJA_URL ); 
  470.  
  471. //this will load automatically existing scripts and stylesheets based on the page and action parameters 
  472. $backloader->load_assets($pagename, WYSIJA_DIR, WYSIJA_URL, $this->controller); 
  473.  
  474. //add some translation 
  475. $backloader->localize( $pagename, WYSIJA_DIR, WYSIJA_URL, $this->controller ); 
  476.  
  477. // add rtl support 
  478. if ( is_rtl() ) { 
  479. wp_enqueue_style('wysija-admin-rtl', WYSIJA_URL.'css/rtl.css', array(), WYSIJA::get_version()); 
  480. $this->_set_ajax_nonces(); 
  481. $jstrans['newsletters']=__('Newsletters', WYSIJA); 
  482. $jstrans['urlpremium']='admin.php?page=wysija_config#tab-premium'; 
  483. $jstrans['premium_activating'] = __('Checking license', WYSIJA); 
  484. if(isset($_REQUEST['page']) && $_REQUEST['page']=='wysija_config') { 
  485. $jstrans['urlpremium']='#tab-premium'; 
  486. wp_localize_script('wysija-admin', 'wysijatrans', $jstrans); 
  487.  
  488.  
  489. /** 
  490. * code only executed in the page or post in admin 
  491. */ 
  492. function addCodeToPagePost() { 
  493.  
  494. //code to add external buttons to the tmce only if the user has the rights to add the forms 
  495. if(get_user_option('rich_editing') == 'true') { 
  496. add_filter("mce_external_plugins", array($this, "addRichPlugin")); 
  497. add_filter('mce_buttons', array($this, 'addRichButton1'), 999); 
  498. $myStyleUrl = "../../plugins/wysija-newsletters/css/tmce/style.css"; 
  499. add_editor_style($myStyleUrl); 
  500. //add_filter('tiny_mce_before_init', array($this, 'TMCEinnercss'), 12 ); 
  501. wp_enqueue_style('custom_TMCE_admin_css', WYSIJA_URL.'css/tmce/panelbtns.css'); 
  502. wp_print_styles('custom_TMCE_admin_css'); 
  503.  
  504.  
  505. function addRichPlugin($plugin_array) { 
  506. global $wp_version; 
  507.  
  508. if ( version_compare( $wp_version, '3.9', '<' ) ) { 
  509. $suffix = ''; 
  510. } else { 
  511. $suffix = '_39'; 
  512.  
  513. $plugin_array['wysija_register'] = WYSIJA_URL.'mce/wysija_register/editor_plugin'.$suffix.'.js'; 
  514.  
  515. return $plugin_array; 
  516.  
  517. function addRichButton1($buttons) { 
  518. $newButtons=array(); 
  519. foreach($buttons as $value) $newButtons[]=$value; 
  520. array_push($newButtons, '|', 'wysija_register'); 
  521. return $newButtons; 
  522.  
  523. function admin_footer_text($text) { 
  524. $screen = get_current_screen(); 
  525. if (strpos($screen->base, 'wysija')===false) 
  526. return $text; 
  527.  
  528. return 
  529. "<a target='_blank' href='http://support.mailpoet.com/feedback/?utm_source=wpadmin&utm_campaign=contact_footer'>" . __( 'Contact Support', WYSIJA ) . "</a>" . 
  530. " | " . 
  531. str_replace( 
  532. array('[stars]', '[link]', '[/link]'),  
  533. array('<a target="_blank" href="http://clicky.me/wp-reviews" >★★★★★</a>', '<a target="_blank" href="http://clicky.me/wp-reviews" >', '</a>'),  
  534. __('Add your [stars] on [link]wordpress.org[/link] and keep this plugin essentially free.', WYSIJA) 
  535. ) . 
  536. ""; 
  537.  
  538. function update_footer($text) { 
  539. $screen = get_current_screen(); 
  540. if (strpos($screen->base, 'wysija')===false) 
  541. return $text; 
  542.  
  543. $version_link = esc_url(add_query_arg( 
  544. array( 
  545. 'page' => 'wysija_campaigns',  
  546. 'action' => 'whats_new',  
  547. ),  
  548. admin_url('admin.php') 
  549. )); 
  550.  
  551. $version_string = "</p>" . 
  552. "<p class='alignright'>" . 
  553. __("MailPoet Version", WYSIJA) . ": <a href='{$version_link}'>" . esc_attr(WYSIJA::get_version()) . "</a>"; 
  554.  
  555. $version_string = apply_filters('mailpoet_back_footer', $version_string); 
  556. return $version_string; 
  557.