/lib/admin.php

  1. <?php 
  2. /** 
  3. * License: GPLv3 
  4. * License URI: http://www.gnu.org/licenses/gpl.txt 
  5. * Copyright 2012-2015 - Jean-Sebastien Morisset - http://surniaulula.com/ 
  6. */ 
  7.  
  8. if ( ! defined( 'ABSPATH' ) )  
  9. die( 'These aren\'t the droids you\'re looking for...' ); 
  10.  
  11. if ( ! class_exists( 'NgfbAdmin' ) ) { 
  12.  
  13. class NgfbAdmin { 
  14.  
  15. protected $p; 
  16. protected $menu_id; 
  17. protected $menu_name; 
  18. protected $menu_lib; 
  19. protected $pagehook; 
  20.  
  21. public static $is_suffix; 
  22. public static $readme_info = array(); 
  23.  
  24. public $form; 
  25. public $lang = array(); 
  26. public $submenu = array(); 
  27.  
  28. public function __construct( &$plugin ) { 
  29. $this->p =& $plugin; 
  30. if ( $this->p->debug->enabled ) 
  31. $this->p->debug->mark(); 
  32.  
  33. if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { 
  34. // nothing to do 
  35. } else { 
  36. load_plugin_textdomain( 'nextgen-facebook', false, 'nextgen-facebook/languages/' ); 
  37.  
  38. $this->set_objects(); 
  39. $this->pro_req_notices(); 
  40. $this->conflict_warnings(); 
  41.  
  42. add_action( 'admin_init', array( &$this, 'register_setting' ) ); 
  43. add_action( 'admin_menu', array( &$this, 'add_admin_menus' ), NGFB_ADD_MENU_PRIORITY ); 
  44. // add settings and users submenu items 
  45. add_action( 'admin_menu', array( &$this, 'add_admin_submenus' ), NGFB_ADD_SUBMENU_PRIORITY ); 
  46. add_action( 'activated_plugin', array( &$this, 'check_activated_plugin' ), 10, 2 ); 
  47. add_action( 'after_switch_theme', array( &$this, 'check_tmpl_head_elements' ) ); 
  48. add_action( 'upgrader_process_complete', array( &$this, 'check_tmpl_head_elements' ) ); 
  49.  
  50. add_filter( 'plugin_action_links', array( &$this, 'add_plugin_action_links' ), 10, 2 ); 
  51. add_filter( 'wp_redirect', array( &$this, 'wp_profile_updated_redirect' ), -100, 2 ); 
  52.  
  53. if ( is_multisite() ) { 
  54. add_action( 'network_admin_menu', array( &$this, 'add_network_admin_menus' ), NGFB_ADD_MENU_PRIORITY ); 
  55. add_action( 'network_admin_edit_'.NGFB_SITE_OPTIONS_NAME, array( &$this, 'save_site_options' ) ); 
  56. add_filter( 'network_admin_plugin_action_links', array( &$this, 'add_plugin_action_links' ), 10, 2 ); 
  57.  
  58. add_filter( 'get_user_option_wpseo_dismissed_conflicts',  
  59. array( &$this, 'dismiss_wpseo_notice' ), 10, 3 ); 
  60.  
  61.  
  62. // load all submenu classes into the $this->submenu array 
  63. // the id of each submenu item must be unique 
  64. private function set_objects() { 
  65. self::$is_suffix = ' '.( $this->p->check->aop( $this->p->cf['lca'],  
  66. true, $this->p->is_avail['aop'] ) ?  
  67. _x( 'Pro', 'package type', 'nextgen-facebook' ) : 
  68. _x( 'Free', 'package type', 'nextgen-facebook' ) ); 
  69.  
  70. $menu_libs = array(  
  71. 'submenu',  
  72. 'setting', // setting must be after submenu to extend submenu/advanced.php 
  73. 'profile',  
  74. ); 
  75.  
  76. if ( is_multisite() ) 
  77. $menu_libs[] = 'sitesubmenu'; 
  78.  
  79. foreach ( $menu_libs as $menu_lib ) { 
  80. foreach ( $this->p->cf['plugin'] as $ext => $info ) { 
  81. if ( isset( $info['lib'][$menu_lib] ) ) { 
  82. foreach ( $info['lib'][$menu_lib] as $menu_id => $menu_name ) { 
  83. if ( strpos( $menu_id, 'separator' ) !== false )  
  84. continue; 
  85. $classname = apply_filters( $ext.'_load_lib', false, $menu_lib.'/'.$menu_id ); 
  86. if ( $classname !== false && class_exists( $classname ) ) { 
  87. if ( ! empty( $info['text_domain'] ) ) 
  88. $menu_name = _x( $menu_name, 'lib file description', $info['text_domain'] ); 
  89. $this->submenu[$menu_id] = new $classname( $this->p, $menu_id, $menu_name, $menu_lib ); 
  90.  
  91. private function pro_req_notices() { 
  92. $lca = $this->p->cf['lca']; 
  93. if ( $this->p->is_avail['aop'] === true &&  
  94. empty( $this->p->options['plugin_'.$lca.'_tid'] ) &&  
  95. ( empty( $this->p->options['plugin_'.$lca.'_tid:is'] ) ||  
  96. $this->p->options['plugin_'.$lca.'_tid:is'] !== 'disabled' ) ) 
  97. $this->p->notice->nag( $this->p->msgs->get( 'notice-pro-tid-missing' ) ); 
  98.  
  99. $has_tid = false; 
  100. foreach ( $this->p->cf['plugin'] as $ext => $info ) { 
  101. if ( ! empty( $this->p->options['plugin_'.$ext.'_tid'] ) && 
  102. isset( $info['base'] ) && SucomUtil::active_plugins( $info['base'] ) ) { 
  103. $has_tid = true; 
  104. if ( ! $this->p->check->aop( $ext, false ) ) 
  105. $this->p->notice->err( $this->p->msgs->get( 'notice-pro-not-installed',  
  106. array( 'lca' => $ext ) ), true ); 
  107.  
  108. if ( $has_tid === true && ! $this->p->is_avail['util']['um'] ) { 
  109. if ( ! function_exists( 'get_plugins' ) ) 
  110. require_once( ABSPATH.'wp-admin/includes/plugin.php' ); 
  111. $installed_plugins = get_plugins(); 
  112. if ( ! empty( $this->p->cf['plugin']['ngfbum']['base'] ) && 
  113. is_array( $installed_plugins[$this->p->cf['plugin']['ngfbum']['base']] ) ) 
  114. $this->p->notice->nag( $this->p->msgs->get( 'notice-um-activate-extension' ), true ); 
  115. else $this->p->notice->nag( $this->p->msgs->get( 'notice-um-extension-required' ), true ); 
  116.  
  117. public function check_activated_plugin( $plugin = false, $sitewide = false ) { 
  118. $lca = $this->p->cf['lca']; 
  119. switch ( $plugin ) { 
  120. case $this->p->cf['plugin'][$lca.'um']['base']: 
  121. $this->p->notice->trunc( 'nag' ); 
  122. break; 
  123.  
  124. protected function set_form_property() { 
  125. $def_opts = $this->p->opt->get_defaults(); 
  126. $this->form = new SucomForm( $this->p, NGFB_OPTIONS_NAME, $this->p->options, $def_opts ); 
  127.  
  128. protected function &get_form_reference() { // returns a reference 
  129. return $this->form; 
  130.  
  131. public function register_setting() { 
  132. register_setting( $this->p->cf['lca'].'_setting',  
  133. NGFB_OPTIONS_NAME, array( &$this, 'registered_setting_sanitation' ) ); 
  134. }  
  135.  
  136. public function set_readme_info( $expire_secs = 86400 ) { 
  137. foreach ( array_keys( $this->p->cf['plugin'] ) as $ext ) { 
  138. if ( empty( self::$readme_info[$ext] ) ) 
  139. self::$readme_info[$ext] = $this->p->util->parse_readme( $ext, $expire_secs ); 
  140.  
  141. public function add_admin_submenus() { 
  142. foreach ( array( 'profile', 'setting' ) as $menu_lib ) { 
  143.  
  144. // match wordpress behavior (users page for admins, profile page for everyone else) 
  145. if ( $menu_lib === 'profile' && current_user_can( 'list_users' ) ) 
  146. $parent_slug = $this->p->cf['wp']['admin']['users']['page']; 
  147. else $parent_slug = $this->p->cf['wp']['admin'][$menu_lib]['page']; 
  148.  
  149. foreach ( $this->p->cf['*']['lib'][$menu_lib] as $menu_id => $menu_name ) { 
  150. if ( isset( $this->submenu[$menu_id] ) ) 
  151. $this->submenu[$menu_id]->add_submenu_page( $parent_slug ); 
  152. else $this->add_submenu_page( $parent_slug, $menu_id, $menu_name, $menu_lib ); 
  153.  
  154. public function add_network_admin_menus() { 
  155. $this->add_admin_menus( 'sitesubmenu' ); 
  156.  
  157. public function add_admin_menus( $menu_lib = '' ) { 
  158. $menu_lib = empty( $menu_lib ) ? 
  159. 'submenu' : $menu_lib; 
  160. $libs = $this->p->cf['*']['lib'][$menu_lib]; 
  161.  
  162. $this->menu_id = key( $libs ); 
  163. $this->menu_name = $libs[$this->menu_id]; 
  164. $this->menu_lib = $menu_lib; 
  165.  
  166. if ( isset( $this->submenu[$this->menu_id] ) ) { 
  167. $menu_slug = $this->p->cf['lca'].'-'.$this->menu_id; 
  168. $this->submenu[$this->menu_id]->add_menu_page( $menu_slug ); 
  169.  
  170. foreach ( $libs as $menu_id => $menu_name ) { 
  171. $parent_slug = $this->p->cf['lca'].'-'.$this->menu_id; 
  172. if ( isset( $this->submenu[$menu_id] ) ) 
  173. $this->submenu[$menu_id]->add_submenu_page( $parent_slug ); 
  174. else $this->add_submenu_page( $parent_slug, $menu_id, $menu_name, $menu_lib ); 
  175.  
  176. protected function add_menu_page( $menu_slug ) { 
  177. global $wp_version; 
  178. $lca = $this->p->cf['lca']; 
  179. $short = $this->p->cf['plugin'][$lca]['short']; 
  180.  
  181. // add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position ); 
  182. $this->pagehook = add_menu_page(  
  183. $short.self::$is_suffix.' — '.$this->menu_name,  
  184. $this->p->cf['menu'].self::$is_suffix,  
  185. ( isset( $this->p->cf['wp']['admin'][$this->menu_lib]['cap'] ) ? 
  186. $this->p->cf['wp']['admin'][$this->menu_lib]['cap'] : 
  187. 'manage_options' ), // fallback to manage_options capability 
  188. $menu_slug,  
  189. array( &$this, 'show_setting_page' ),  
  190. ( version_compare( $wp_version, 3.8, '<' ) ? null : 'dashicons-share' ),  
  191. NGFB_MENU_ORDER 
  192. ); 
  193. add_action( 'load-'.$this->pagehook, array( &$this, 'load_setting_page' ) ); 
  194.  
  195. protected function add_submenu_page( $parent_slug, $menu_id = '', $menu_name = '', $menu_lib = '' ) { 
  196. $lca = $this->p->cf['lca']; 
  197. $short = $this->p->cf['plugin'][$lca]['short']; 
  198. $menu_id = empty( $menu_id ) ? 
  199. $this->menu_id : $menu_id; 
  200. $menu_name = empty( $menu_name ) ? 
  201. $this->menu_name : $menu_name; 
  202. $menu_lib = empty( $menu_lib ) ? 
  203. $this->menu_lib : $menu_lib; 
  204.  
  205. if ( strpos( $menu_id, 'separator' ) !== false ) { 
  206. $menu_title = '<div style="z-index:999; 
  207. padding:2px 0; 
  208. margin:0; 
  209. cursor:default; 
  210. border-bottom:1px dotted; 
  211. color:#666;" onclick="return false;">'. 
  212. ( $menu_name === $this->p->cf['menu'] ?  
  213. $menu_name.self::$is_suffix : $menu_name ).'</div>'; 
  214. $menu_slug = ''; 
  215. $page_title = ''; 
  216. $function = ''; 
  217. } else { 
  218. // highlight the "extension plugins" part of the menu title 
  219. if ( strpos( $menu_id, 'licenses' ) !== false ) 
  220. $menu_title = preg_replace( '/^<span>/',  
  221. '<span style="color:#'.$this->p->cf['color'].';">', $menu_name ); 
  222. else $menu_title = $menu_name; 
  223.  
  224. $menu_slug = $lca.'-'.$menu_id; 
  225. $page_title = $short.self::$is_suffix.' — '.$menu_title; 
  226. $function = array( &$this, 'show_setting_page' ); 
  227.  
  228. // add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); 
  229. $this->pagehook = add_submenu_page( $parent_slug, $page_title, $menu_title,  
  230. ( isset( $this->p->cf['wp']['admin'][$menu_lib]['cap'] ) ? 
  231. $this->p->cf['wp']['admin'][$menu_lib]['cap'] : 
  232. 'manage_options' ), $menu_slug, $function ); // fallback to manage_options capability 
  233.  
  234. if ( $function ) 
  235. add_action( 'load-'.$this->pagehook, array( &$this, 'load_setting_page' ) ); 
  236.  
  237. // add links on the main plugins page 
  238. public function add_plugin_action_links( $links, $file ) { 
  239.  
  240. if ( ! isset( $this->p->cf['*']['base'][$file] ) ) 
  241. return $links; 
  242.  
  243. $ext = $this->p->cf['*']['base'][$file]; 
  244. $info = $this->p->cf['plugin'][$ext]; 
  245.  
  246. foreach ( $links as $num => $val ) 
  247. if ( strpos( $val, '>Edit<' ) !== false ) 
  248. unset ( $links[$num] ); 
  249.  
  250. if ( ! empty( $info['url']['faq'] ) ) 
  251. $links[] = '<a href="'.$info['url']['faq'].'">'. 
  252. _x( 'FAQ', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  253.  
  254. if ( ! empty( $info['url']['notes'] ) ) 
  255. $links[] = '<a href="'.$info['url']['notes'].'">'. 
  256. _x( 'Notes', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  257.  
  258. if ( ! empty( $info['url']['latest_zip'] ) ) 
  259. $links[] = '<a href="'.$info['url']['latest_zip'].'">'. 
  260. _x( 'Download Latest', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  261.  
  262. if ( ! empty( $info['url']['pro_support'] ) && 
  263. $this->p->check->aop( $ext, true, $this->p->is_avail['aop'] ) ) { 
  264. $links[] = '<a href="'.$info['url']['pro_support'].'">'. 
  265. _x( 'Pro Support', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  266. } else { 
  267. if ( ! empty( $info['url']['wp_support'] ) ) 
  268. $links[] = '<a href="'.$info['url']['wp_support'].'">'. 
  269. _x( 'Support Forum', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  270.  
  271. if ( ! empty( $info['url']['purchase'] ) ) { 
  272. if ( $this->p->check->aop( $ext, false, $this->p->is_avail['aop'] ) ) 
  273. $links[] = '<a href="'.$info['url']['purchase'].'">'. 
  274. _x( 'Purchase Pro License(s)', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  275. else $links[] = '<a href="'.$info['url']['purchase'].'">'. 
  276. _x( 'Purchase Pro Version', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  277.  
  278. return $links; 
  279.  
  280. // this method receives only a partial options array, so re-create a full one 
  281. // wordpress handles the actual saving of the options 
  282. public function registered_setting_sanitation( $opts ) { 
  283. $network = false; 
  284. if ( ! is_array( $opts ) ) { 
  285. add_settings_error( NGFB_OPTIONS_NAME, 'notarray', '<b>'.$this->p->cf['uca'].' Error</b> : '. 
  286. __( 'Submitted options are not an array.', 'nextgen-facebook' ), 'error' ); 
  287. return $opts; 
  288. // get default values, including css from default stylesheets 
  289. $def_opts = $this->p->opt->get_defaults(); 
  290. $opts = SucomUtil::restore_checkboxes( $opts ); 
  291. $opts = array_merge( $this->p->options, $opts ); 
  292. $this->p->notice->trunc(); // clear all messages before sanitation checks 
  293. $opts = $this->p->opt->sanitize( $opts, $def_opts, $network ); 
  294. $opts = apply_filters( $this->p->cf['lca'].'_save_options', $opts, NGFB_OPTIONS_NAME, $network ); 
  295. $clear_cache_link = wp_nonce_url( $this->p->util->get_admin_url( '?'.$this->p->cf['lca']. 
  296. '-action=clear_all_cache' ), self::get_nonce(), NGFB_NONCE ); 
  297. $this->p->notice->inf( __( 'Plugin settings have been saved.', 'nextgen-facebook' ).' '. 
  298. sprintf( __( 'Wait %1$d seconds for cache objects to expire or <a href="%2$s">%3$s</a> now.',  
  299. 'nextgen-facebook' ), $this->p->options['plugin_object_cache_exp'], $clear_cache_link,  
  300. _x( 'Clear All Cache(s)', 'submit button', 'nextgen-facebook' ) ), true ); 
  301. $this->check_tmpl_head_elements(); 
  302. return $opts; 
  303.  
  304. public function save_site_options() { 
  305. $network = true; 
  306.  
  307. $page = empty( $_POST['page'] ) ?  
  308. key( $this->p->cf['*']['lib']['sitesubmenu'] ) : 
  309. $_POST['page']; 
  310.  
  311. if ( empty( $_POST[ NGFB_NONCE ] ) ) { 
  312. if ( $this->p->debug->enabled ) 
  313. $this->p->debug->log( 'nonce token validation post field missing' ); 
  314. wp_redirect( $this->p->util->get_admin_url( $page ) ); 
  315. exit; 
  316. } elseif ( ! wp_verify_nonce( $_POST[ NGFB_NONCE ], self::get_nonce() ) ) { 
  317. $this->p->notice->err( __( 'Nonce token validation failed for network options (update ignored).',  
  318. 'nextgen-facebook' ), true ); 
  319. wp_redirect( $this->p->util->get_admin_url( $page ) ); 
  320. exit; 
  321. } elseif ( ! current_user_can( 'manage_network_options' ) ) { 
  322. $this->p->notice->err( __( 'Insufficient privileges to modify network options.',  
  323. 'nextgen-facebook' ), true ); 
  324. wp_redirect( $this->p->util->get_admin_url( $page ) ); 
  325. exit; 
  326.  
  327. $def_opts = $this->p->opt->get_site_defaults(); 
  328. $opts = empty( $_POST[NGFB_SITE_OPTIONS_NAME] ) ? $def_opts :  
  329. SucomUtil::restore_checkboxes( $_POST[NGFB_SITE_OPTIONS_NAME] ); 
  330. $opts = array_merge( $this->p->site_options, $opts ); 
  331. $this->p->notice->trunc(); // clear all messages before sanitation checks 
  332. $opts = $this->p->opt->sanitize( $opts, $def_opts, $network ); 
  333. $opts = apply_filters( $this->p->cf['lca'].'_save_site_options', $opts, $def_opts, $network ); 
  334. update_site_option( NGFB_SITE_OPTIONS_NAME, $opts ); 
  335. $this->p->notice->inf( __( 'Plugin settings have been saved.', 'nextgen-facebook' ), true ); 
  336. wp_redirect( $this->p->util->get_admin_url( $page ).'&settings-updated=true' ); 
  337. exit; // stop here 
  338.  
  339. public function load_single_page() { 
  340. wp_enqueue_script( 'postbox' ); 
  341. $this->p->admin->submenu[$this->menu_id]->add_meta_boxes(); 
  342.  
  343. public function load_setting_page() { 
  344. $lca = $this->p->cf['lca']; 
  345. $action_query = $lca.'-action'; 
  346. wp_enqueue_script( 'postbox' ); 
  347.  
  348. if ( ! empty( $_GET[$action_query] ) ) { 
  349. $action_name = SucomUtil::sanitize_hookname( $_GET[$action_query] ); 
  350. if ( empty( $_GET[ NGFB_NONCE ] ) ) { 
  351. if ( $this->p->debug->enabled ) 
  352. $this->p->debug->log( 'nonce token validation query field missing' ); 
  353. } elseif ( ! wp_verify_nonce( $_GET[ NGFB_NONCE ], self::get_nonce() ) ) { 
  354. $this->p->notice->err( __( 'Nonce token validation failed for action \"'.$action_name.'\".', 'nextgen-facebook' ) ); 
  355. } else { 
  356. $_SERVER['REQUEST_URI'] = remove_query_arg( array( $action_query, NGFB_NONCE ) ); 
  357. switch ( $action_name ) { 
  358. case 'check_for_updates':  
  359. if ( $this->p->is_avail['util']['um'] ) { 
  360. self::$readme_info = array(); 
  361. $ngfbum = NgfbUm::get_instance(); 
  362. $ngfbum->update->check_for_updates( null, true, false ); 
  363. } else { 
  364. $this->p->notice->err( sprintf( __( 'The <b>%s</b> extension is required to check for Pro version updates.',  
  365. 'nextgen-facebook' ), $this->p->cf['plugin'][$lca.'um']['name'] ) ); 
  366. break; 
  367.  
  368. case 'clear_all_cache':  
  369. $this->p->util->clear_all_cache(); 
  370. break; 
  371.  
  372. case 'clear_metabox_prefs':  
  373. $user_id = get_current_user_id(); 
  374. $user = get_userdata( $user_id ); 
  375. //$user_name = trim( $user->first_name.' '.$user->last_name ); 
  376. $user_name = $user->display_name; 
  377. NgfbUser::delete_metabox_prefs( $user_id ); 
  378. $this->p->notice->inf( sprintf( __( 'Metabox layout preferences for user ID #%d "%s" have been reset.',  
  379. 'nextgen-facebook' ), $user_id, $user_name ) ); 
  380. break; 
  381.  
  382. case 'clear_hidden_notices':  
  383. $user_id = get_current_user_id(); 
  384. $user = get_userdata( $user_id ); 
  385. //$user_name = trim( $user->first_name.' '.$user->last_name ); 
  386. $user_name = $user->display_name; 
  387. delete_user_option( $user_id, NGFB_DISMISS_NAME ); 
  388. $this->p->notice->inf( sprintf( __( 'Hidden notices for user ID #%d "%s" have been cleared.',  
  389. 'nextgen-facebook' ), $user_id, $user_name ) ); 
  390. break; 
  391.  
  392. case 'change_show_options':  
  393. if ( isset( $this->p->cf['form']['show_options'][$_GET['show-opts']] ) ) { 
  394. $this->p->notice->inf( sprintf( 'Option preference saved — viewing "%s" by default.',  
  395. $this->p->cf['form']['show_options'][$_GET['show-opts']] ) ); 
  396. NgfbUser::save_pref( array( 'show_opts' => $_GET['show-opts'] ) ); 
  397. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'show-opts' ) ); 
  398. break; 
  399.  
  400. case 'modify_tmpl_head_elements':  
  401. $this->modify_tmpl_head_elements(); 
  402. break; 
  403.  
  404. default:  
  405. do_action( $lca.'_load_setting_page_'.$action_name,  
  406. $this->pagehook, $this->menu_id, $this->menu_name, $this->menu_lib ); 
  407. break; 
  408.  
  409. // the plugin information metabox on all settings pages needs this 
  410. $this->p->admin->set_readme_info( $this->p->cf['feed_cache_exp'] ); 
  411.  
  412. // add child metaboxes first, since they contain the default reset_metabox_prefs() 
  413. $this->p->admin->submenu[ $this->menu_id ]->add_meta_boxes(); 
  414.  
  415. if ( empty( $this->p->options['plugin_'.$lca.'_tid'] ) ||  
  416. ! $this->p->check->aop( $lca, true, $this->p->is_avail['aop'] ) ) { 
  417.  
  418. add_meta_box( $this->pagehook.'_purchase',  
  419. _x( 'Pro / Power-User Version', 'metabox title (side)', 'nextgen-facebook' ),  
  420. array( &$this, 'show_metabox_purchase' ), $this->pagehook, 'side' ); 
  421.  
  422. $this->p->mods['util']['user']->reset_metabox_prefs( $this->pagehook,  
  423. array( 'purchase' ), null, 'side', true ); 
  424.  
  425. add_meta_box( $this->pagehook.'_help',  
  426. _x( 'Help and Support', 'metabox title (side)', 'nextgen-facebook' ),  
  427. array( &$this, 'show_metabox_help' ), $this->pagehook, 'side' ); 
  428.  
  429. if ( $this->menu_lib === 'submenu' ) { 
  430. add_meta_box( $this->pagehook.'_status_gpl',  
  431. _x( 'Standard Features', 'metabox title (side)', 'nextgen-facebook' ),  
  432. array( &$this, 'show_metabox_status_gpl' ), $this->pagehook, 'side' ); 
  433.  
  434. add_meta_box( $this->pagehook.'_status_pro',  
  435. _x( 'Pro Version Features', 'metabox title (side)', 'nextgen-facebook' ),  
  436. array( &$this, 'show_metabox_status_pro' ), $this->pagehook, 'side' ); 
  437.  
  438. if ( $this->menu_lib === 'submenu' || $this->menu_lib === 'sitesubmenu' ) { 
  439. add_meta_box( $this->pagehook.'_version_info',  
  440. _x( 'Version Information', 'metabox title (side)', 'nextgen-facebook' ),  
  441. array( &$this, 'show_metabox_version_info' ), $this->pagehook, 'side' ); 
  442.  
  443. protected function add_meta_boxes() { 
  444.  
  445. public function show_setting_page( $sidebar = true ) { 
  446.  
  447. if ( ! $this->is_setting() ) 
  448. settings_errors( NGFB_OPTIONS_NAME ); 
  449.  
  450. $this->set_form_property(); // set form for side boxes and show_form_content() 
  451.  
  452. if ( $this->p->debug->enabled ) { 
  453. $this->p->debug->show_html( print_r( $this->p->is_avail, true ), 'available features' ); 
  454. $this->p->debug->show_html( print_r( NgfbUtil::active_plugins(), true ), 'active plugins' ); 
  455. $this->p->debug->show_html( null, 'debug log' ); 
  456.  
  457. echo '<div class="wrap" id="'.$this->pagehook.'">'."\n"; 
  458. echo '<h1>'.$this->p->cf['plugin'][$this->p->cf['lca']]['short']. 
  459. self::$is_suffix.' – '.$this->menu_name.'</h1>'."\n"; 
  460.  
  461. if ( $sidebar === false ) { 
  462. echo '<div id="poststuff" class="metabox-holder">'."\n"; 
  463. echo '<div id="post-body">'."\n"; 
  464. echo '<div id="post-body-content">'."\n"; 
  465. } else { 
  466. echo '<div id="poststuff" class="metabox-holder has-right-sidebar">'."\n"; 
  467. echo '<div id="side-info-column" class="inner-sidebar">'."\n"; 
  468. do_meta_boxes( $this->pagehook, 'side', null ); 
  469. echo '</div><!-- .inner-sidebar -->'."\n"; 
  470. echo '<div id="post-body" class="has-sidebar">'."\n"; 
  471. echo '<div id="post-body-content" class="has-sidebar-content">'."\n"; 
  472.  
  473. $this->show_form_content(); 
  474. ?> 
  475. </div><!-- .post-body-content --> 
  476. </div><!-- .post-body --> 
  477. </div><!-- .metabox-holder --> 
  478. </div><!-- .wrap --> 
  479. <script type="text/javascript"> 
  480. //<![CDATA[ 
  481. jQuery(document).ready(  
  482. function($) { 
  483. // close postboxes that should be closed 
  484. $('.if-js-closed').removeClass('if-js-closed').addClass('closed'); 
  485. // postboxes setup 
  486. postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?>'); 
  487. ); 
  488. //]]> 
  489. </script> 
  490. <?php 
  491.  
  492. public function wp_profile_updated_redirect( $location, $status ) { 
  493. if ( strpos( $location, 'updated=' ) !== false &&  
  494. strpos( $location, 'wp_http_referer=' ) ) { 
  495.  
  496. // match wordpress behavior (users page for admins, profile page for everyone else) 
  497. $menu_lib = current_user_can( 'list_users' ) ? 'users' : 'profile'; 
  498. $parent_slug = $this->p->cf['wp']['admin'][$menu_lib]['page']; 
  499. $referer_match = '/'.$parent_slug.'?page='.$this->p->cf['lca'].'-'; 
  500. parse_str( parse_url( $location, PHP_URL_QUERY ), $parts ); 
  501.  
  502. if ( strpos( $parts['wp_http_referer'], $referer_match ) ) { 
  503. $this->p->notice->inf( __( 'Profile updated.' ), true ); 
  504. return add_query_arg( 'updated', true, $parts['wp_http_referer'] ); 
  505. return $location; 
  506.  
  507. protected function show_form_content() { 
  508.  
  509. $lca = $this->p->cf['lca']; 
  510.  
  511. if ( $this->menu_lib === 'profile' ) { 
  512.  
  513. $user_id = get_current_user_id(); 
  514. $profileuser = get_user_to_edit( $user_id ); 
  515. $current_color = get_user_option( 'admin_color', $user_id ); 
  516. if ( empty( $current_color ) ) 
  517. $current_color = 'fresh'; 
  518.  
  519. // match wordpress behavior (users page for admins, profile page for everyone else) 
  520. $admin_url = current_user_can( 'list_users' ) ?  
  521. $this->p->util->get_admin_url( $this->menu_id, null, 'users' ) : 
  522. $this->p->util->get_admin_url( $this->menu_id, null, $this->menu_lib ); 
  523.  
  524. echo '<form name="'.$lca.'" id="'.$lca.'_setting_form" action="user-edit.php" method="post">'."\n"; 
  525. echo '<input type="hidden" name="wp_http_referer" value="'.$admin_url.'" />'."\n"; 
  526. echo '<input type="hidden" name="action" value="update" />'."\n"; 
  527. echo '<input type="hidden" name="user_id" value="'.$user_id.'" />'."\n"; 
  528. echo '<input type="hidden" name="nickname" value="'.$profileuser->nickname.'" />'."\n"; 
  529. echo '<input type="hidden" name="email" value="'.$profileuser->user_email.'" />'."\n"; 
  530. echo '<input type="hidden" name="admin_color" value="'.$current_color.'" />'."\n"; 
  531. echo '<input type="hidden" name="rich_editing" value="'.$profileuser->rich_editing.'" />'."\n"; 
  532. echo '<input type="hidden" name="comment_shortcuts" value="'.$profileuser->comment_shortcuts.'" />'."\n"; 
  533. echo '<input type="hidden" name="admin_bar_front" value="'._get_admin_bar_pref( 'front', $user_id ).'" />'."\n"; 
  534.  
  535. wp_nonce_field( 'update-user_'.$user_id ); 
  536.  
  537. } elseif ( $this->menu_lib === 'setting' || $this->menu_lib === 'submenu' ) { 
  538.  
  539. echo '<form name="'.$lca.'" id="'.$lca.'_setting_form" action="options.php" method="post">'."\n"; 
  540.  
  541. settings_fields( $lca.'_setting' );  
  542.  
  543. } elseif ( $this->menu_lib === 'sitesubmenu' ) { 
  544.  
  545. echo '<form name="'.$lca.'" id="'.$lca.'_setting_form" action="edit.php?action='. 
  546. NGFB_SITE_OPTIONS_NAME.'" method="post">'."\n"; 
  547. echo '<input type="hidden" name="page" value="'.$this->menu_id.'" />'; 
  548.  
  549. } else return; 
  550.  
  551. wp_nonce_field( self::get_nonce(), NGFB_NONCE ); 
  552. wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); 
  553. wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); 
  554.  
  555. do_meta_boxes( $this->pagehook, 'normal', null );  
  556.  
  557. do_action( $this->p->cf['lca'].'_form_content_metaboxes_'. 
  558. SucomUtil::sanitize_hookname( $this->menu_id ), $this->pagehook ); 
  559.  
  560. switch ( $this->menu_id ) { 
  561. case 'readme': 
  562. case 'setup': 
  563. case 'sitereadme': 
  564. case 'sitesetup': 
  565. break; 
  566. default: 
  567. if ( $this->menu_lib === 'profile' ) 
  568. echo $this->get_submit_buttons( _x( 'Save All Profile Settings',  
  569. 'submit button', 'nextgen-facebook' ) ); 
  570. else echo $this->get_submit_buttons(); 
  571. break; 
  572. echo '</form>', "\n"; 
  573.  
  574. protected function get_submit_buttons( $submit_text = '', $class = 'submit-buttons' ) { 
  575. if ( empty( $submit_text ) )  
  576. $submit_text = _x( 'Save All Plugin Settings', 'submit button', 'nextgen-facebook' ); 
  577.  
  578. $show_opts_next = SucomUtil::next_key( NgfbUser::show_opts(), $this->p->cf['form']['show_options'] ); 
  579. $show_opts_text = sprintf( _x( 'View %s by Default', 'submit button', 'nextgen-facebook' ),  
  580. _x( $this->p->cf['form']['show_options'][$show_opts_next],  
  581. 'option value', 'nextgen-facebook' ) ); 
  582. $show_opts_url = $this->p->util->get_admin_url( '?'.$this->p->cf['lca']. 
  583. '-action=change_show_options&show-opts='.$show_opts_next ); 
  584.  
  585. $action_buttons = '<input type="submit" class="button-primary" value="'.$submit_text.'" />'. 
  586. $this->form->get_button( $show_opts_text, 'button-secondary button-highlight', null,  
  587. wp_nonce_url( $show_opts_url, self::get_nonce(), NGFB_NONCE ) ).'<br/>'; 
  588.  
  589. if ( $this->menu_lib === 'setting' || $this->menu_lib === 'submenu' ) 
  590. $action_buttons .= $this->form->get_button( _x( 'Clear All Cache(s)', 'submit button', 'nextgen-facebook' ),  
  591. 'button-secondary', null, wp_nonce_url( $this->p->util->get_admin_url( '?'.$this->p->cf['lca']. 
  592. '-action=clear_all_cache' ), self::get_nonce(), NGFB_NONCE ) ); 
  593.  
  594. if ( $this->menu_lib !== 'profile' ) // don't show on profile pages 
  595. $action_buttons .= $this->form->get_button( _x( 'Check for Pro Update(s)', 'submit button', 'nextgen-facebook' ),  
  596. 'button-secondary', null, wp_nonce_url( $this->p->util->get_admin_url( '?'.$this->p->cf['lca']. 
  597. '-action=check_for_updates' ), self::get_nonce(), NGFB_NONCE ), false,  
  598. ( $this->p->is_avail['util']['um'] ? false : true ) ); // disable button if um not available 
  599.  
  600. $action_buttons .= $this->form->get_button( _x( 'Reset Metabox Layout', 'submit button', 'nextgen-facebook' ),  
  601. 'button-secondary', null, wp_nonce_url( $this->p->util->get_admin_url( '?'.$this->p->cf['lca']. 
  602. '-action=clear_metabox_prefs' ), self::get_nonce(), NGFB_NONCE ) ); 
  603.  
  604. $action_buttons .= $this->form->get_button( _x( 'Reset Hidden Notices', 'submit button', 'nextgen-facebook' ),  
  605. 'button-secondary', null, wp_nonce_url( $this->p->util->get_admin_url( '?'.$this->p->cf['lca']. 
  606. '-action=clear_hidden_notices' ), self::get_nonce(), NGFB_NONCE ) ); 
  607.  
  608. return '<div class="'.$class.'">'.$action_buttons.'</div>'; 
  609.  
  610. public function show_metabox_version_info() { 
  611. echo '<table class="sucom-setting '.$this->p->cf['lca'].' side">'; 
  612. foreach ( $this->p->cf['plugin'] as $ext => $info ) { 
  613. if ( empty( $info['version'] ) ) // filter out extensions that are not active 
  614. continue; 
  615.  
  616. $stable_version = __( 'N/A', 'nextgen-facebook' ); 
  617. $latest_version = __( 'N/A', 'nextgen-facebook' ); 
  618. $installed_version = $info['version']; 
  619. $installed_style = ''; 
  620. $latest_notice = ''; 
  621. $changelog_url = $info['url']['changelog']; 
  622.  
  623. // the readme_info array is populated by set_readme_info(), which is called from load_setting_page() 
  624. if ( ! empty( self::$readme_info[$ext]['stable_tag'] ) ) { 
  625. $stable_version = self::$readme_info[$ext]['stable_tag']; 
  626. $upgrade_notice = self::$readme_info[$ext]['upgrade_notice']; 
  627. if ( is_array( $upgrade_notice ) ) { 
  628. reset( $upgrade_notice ); 
  629. $latest_version = key( $upgrade_notice ); 
  630. $latest_notice = $upgrade_notice[$latest_version]; 
  631. $installed_style = version_compare( $installed_version, $stable_version, '<' ) ? 
  632. 'style="background-color:#f00;"' :  
  633. 'style="background-color:#0f0;"'; 
  634.  
  635. echo '<tr><td colspan="2"><h4>'.$info['short'].' '. 
  636. ( $this->p->check->aop( $ext, true, $this->p->is_avail['aop'] ) ? 
  637. _x( 'Pro', 'package type', 'nextgen-facebook' ) : 
  638. _x( 'Free', 'package type', 'nextgen-facebook' ) ).'</h4></td></tr>'; 
  639. echo '<tr><th class="side">'._x( 'Installed',  
  640. 'plugin status label', 'nextgen-facebook' ).':</th> 
  641. <td class="side_version" '.$installed_style.'>'.$installed_version.'</td></tr>'; 
  642. echo '<tr><th class="side">'._x( 'Stable',  
  643. 'plugin status label', 'nextgen-facebook' ).':</th> 
  644. <td class="side_version">'.$stable_version.'</td></tr>'; 
  645. echo '<tr><th class="side">'._x( 'Latest',  
  646. 'plugin status label', 'nextgen-facebook' ).':</th> 
  647. <td class="side_version">'.$latest_version.'</td></tr>'; 
  648. echo '<tr><td colspan="2" id="latest_notice"><p>'.$latest_notice.'</p>'. 
  649. '<p><a href="'.$changelog_url.'" target="_blank">'. 
  650. sprintf( _x( 'View %s changelog...', 'following plugin status version numbers',  
  651. 'nextgen-facebook' ), $info['short'] ).'</a></p></td></tr>'; 
  652. echo '</table>'; 
  653.  
  654. public function show_metabox_status_gpl() { 
  655. $metabox = 'status'; 
  656. $plugin_count = 0; 
  657. foreach ( $this->p->cf['plugin'] as $ext => $info ) 
  658. if ( isset( $info['lib']['gpl'] ) ) 
  659. $plugin_count++; 
  660. echo '<table class="sucom-setting '.$this->p->cf['lca'].' side" 
  661. style="margin-bottom:10px;">'; 
  662. /** 
  663. * GPL version features 
  664. */ 
  665. foreach ( $this->p->cf['plugin'] as $ext => $info ) { 
  666. if ( ! isset( $info['lib']['gpl'] ) ) 
  667. continue; 
  668. if ( $ext === $this->p->cf['lca'] ) // features for this plugin 
  669. $features = array( 
  670. 'Author JSON-LD' => array(  
  671. 'status' => $this->p->options['schema_author_json'] ? 
  672. 'on' : 'rec',  
  673. ),  
  674. 'Debug Messages' => array( 
  675. 'classname' => 'SucomDebug',  
  676. ),  
  677. 'Non-Persistant Cache' => array( 
  678. 'status' => $this->p->is_avail['cache']['object'] ? 
  679. 'on' : 'rec',  
  680. ),  
  681. 'Open Graph / Rich Pin' => array(  
  682. 'status' => class_exists( $this->p->cf['lca'].'opengraph' ) ? 
  683. 'on' : 'rec',  
  684. ),  
  685. 'Publisher JSON-LD' => array( 
  686. 'status' => $this->p->options['schema_publisher_json'] ? 
  687. 'on' : 'rec',  
  688. ),  
  689. 'Transient Cache' => array( 
  690. 'status' => $this->p->is_avail['cache']['transient'] ? 
  691. 'on' : 'rec',  
  692. ),  
  693. 'Twitter Cards' => array(  
  694. 'status' => class_exists( $this->p->cf['lca'].'twittercard' ) ? 
  695. 'on' : 'rec',  
  696. ),  
  697. ); 
  698. else $features = array(); 
  699.  
  700. $features = apply_filters( $ext.'_'.$metabox.'_gpl_features', $features, $ext, $info ); 
  701.  
  702. if ( ! empty( $features ) ) { 
  703. if ( $plugin_count > 1 ) 
  704. echo '<tr><td><h4>'.$this->p->cf['plugin'][$ext]['short'].'</h4></td></tr>'; 
  705. $this->show_plugin_status( $features ); 
  706. echo '</table>'; 
  707.  
  708. public function show_metabox_status_pro() { 
  709. $metabox = 'status'; 
  710. $plugin_count = 0; 
  711. foreach ( $this->p->cf['plugin'] as $ext => $info ) 
  712. if ( isset( $info['lib']['pro'] ) ) 
  713. $plugin_count++; 
  714. echo '<table class="sucom-setting '.$this->p->cf['lca'].' side" 
  715. style="margin-bottom:10px;">'; 
  716. /** 
  717. * Pro version features 
  718. */ 
  719. foreach ( $this->p->cf['plugin'] as $ext => $info ) { 
  720. if ( ! isset( $info['lib']['pro'] ) ) 
  721. continue; 
  722. $features = array(); 
  723. $short = $this->p->cf['plugin'][$ext]['short']; 
  724. $short_pro = $short.' Pro'; 
  725. $aop = $this->p->check->aop( $ext, true, $this->p->is_avail['aop'] ); 
  726. foreach ( $info['lib']['pro'] as $sub => $libs ) { 
  727. if ( $sub === 'admin' )  
  728. continue; // skip status for admin menus and tabs 
  729. foreach ( $libs as $id => $name ) { 
  730. $off = $this->p->is_avail[$sub][$id] ? 'rec' : 'off'; 
  731. $features[$name] = array(  
  732. 'status' => class_exists( $ext.'pro'.$sub.$id ) ? 
  733. ( $aop ? 'on' : $off ) : $off,  
  734. 'tooltip' => sprintf( __( 'If the %1$s plugin is detected, %2$s will load additional '. 
  735. 'integration modules to provide enhanced support and features for %3$s.',  
  736. 'nextgen-facebook'), $name, $short_pro, $name ),  
  737. 'td_class' => $aop ? '' : 'blank',  
  738. ); 
  739. $features = apply_filters( $ext.'_'.$metabox.'_pro_features', $features, $ext, $info ); 
  740.  
  741. if ( ! empty( $features ) ) { 
  742. if ( $plugin_count > 1 ) 
  743. echo '<tr><td><h4>'.$this->p->cf['plugin'][$ext]['short'].'</h4></td></tr>'; 
  744. $this->show_plugin_status( $features ); 
  745. echo '</table>'; 
  746.  
  747. private function show_plugin_status( $features = array() ) { 
  748. $images = array(  
  749. 'on' => 'green-circle.png',  
  750. 'off' => 'gray-circle.png',  
  751. 'rec' => 'red-circle.png',  
  752. ); 
  753. uksort( $features, 'strcasecmp' ); 
  754. $first = key( $features ); 
  755. foreach ( $features as $name => $arr ) { 
  756. $td_class = empty( $arr['td_class'] ) ? 
  757. '' : ' '.$arr['td_class']; 
  758.  
  759. if ( array_key_exists( 'classname', $arr ) ) 
  760. $status = class_exists( $arr['classname'] ) ? 'on' : 'off'; 
  761. elseif ( array_key_exists( 'status', $arr ) ) 
  762. $status = $arr['status']; 
  763. else $status = ''; 
  764.  
  765. if ( ! empty( $status ) ) { 
  766. $tooltip_text = empty( $arr['tooltip'] ) ? 
  767. '' : $arr['tooltip']; 
  768. $tooltip_text = $this->p->msgs->get( 'tooltip-side-'.$name,  
  769. array( 'text' => $tooltip_text, 'class' => 'sucom_tooltip_side' ) ); 
  770.  
  771. echo '<tr><td class="side'.$td_class.'">'. 
  772. $tooltip_text.( $status == 'rec' ? '<strong>'.$name.'</strong>' : $name ). 
  773. '</td><td style="min-width:0;text-align:center;" class="'.$td_class.'"> 
  774. <img src="'.NGFB_URLPATH.'images/'.$images[$status]. 
  775. '" width="12" height="12" /></td></tr>'."\n"; 
  776.  
  777. public function show_metabox_purchase() { 
  778. $purchase_url = $this->p->cf['plugin'][$this->p->cf['lca']]['url']['purchase']; 
  779. echo '<table class="sucom-setting '.$this->p->cf['lca'].'" side><tr><td>'; 
  780. echo $this->p->msgs->get( 'side-purchase' ); 
  781. echo '<p class="centered">'; 
  782. echo $this->form->get_button( ( $this->p->is_avail['aop'] ?  
  783. _x( 'Purchase Pro License(s)', 'submit button', 'nextgen-facebook' ) : 
  784. _x( 'Purchase Pro Version', 'submit button', 'nextgen-facebook' ) ),  
  785. 'button-primary', null, $purchase_url, true ); 
  786. echo '</p></td></tr></table>'; 
  787.  
  788. public function show_metabox_help() { 
  789. echo '<table class="sucom-setting '.$this->p->cf['lca'].'" side><tr><td>'; 
  790. //echo $this->p->msgs->get( 'side-help' ); 
  791. $this->show_follow_icons(); 
  792. foreach ( $this->p->cf['plugin'] as $ext => $info ) { 
  793. if ( empty( $info['version'] ) ) // filter out extensions that are not installed 
  794. continue; 
  795.  
  796. $help_links = ''; 
  797. $aop = $this->p->check->aop( $ext, true, $this->p->is_avail['aop'] ); 
  798. if ( ! empty( $info['url']['faq'] ) ) { 
  799. $help_links .= '<li>'.sprintf( __( 'Review the <a href="%s" target="_blank">Frequently Asked Questions</a>',  
  800. 'nextgen-facebook' ), $info['url']['faq'] ); 
  801. if ( ! empty( $info['url']['notes'] ) ) 
  802. $help_links .= ' '.sprintf( __( 'and <a href="%s" target="_blank">Other Notes</a>',  
  803. 'nextgen-facebook' ), $info['url']['notes'] ); 
  804. $help_links .= '</li>'; 
  805. if ( ! empty( $info['url']['pro_support'] ) && $aop ) 
  806. $help_links .= '<li>'.sprintf( __( 'Open a <a href="%s" target="_blank">Support Ticket</a>',  
  807. 'nextgen-facebook' ), $info['url']['pro_support'] ).'</li>'; 
  808. elseif ( ! empty( $info['url']['wp_support'] ) ) 
  809. $help_links .= '<li>'.sprintf( __( 'Post in <a href="%s" target="_blank">Support Forum</a>',  
  810. 'nextgen-facebook' ), $info['url']['wp_support'] ).'</li>'; 
  811.  
  812. if ( ! empty( $help_links ) ) { 
  813. echo '<p><strong>'.sprintf( _x( '%s Support',  
  814. 'metabox title (side)', 'nextgen-facebook' ), $info['short'].self::$is_suffix ).'</strong></p>'; 
  815. echo '<ul>'.$help_links.'</ul>'; 
  816. echo '</td></tr></table>'; 
  817.  
  818. protected function show_follow_icons() { 
  819. echo '<div class="follow_icons">'; 
  820. $img_size = $this->p->cf['follow']['size']; 
  821. foreach ( $this->p->cf['follow']['src'] as $img_rel => $url ) 
  822. echo '<a href="'.$url.'" target="_blank"><img src="'.NGFB_URLPATH.$img_rel.'"  
  823. width="'.$img_size.'" height="'.$img_size.'" border="0" /></a> '; 
  824. echo '</div>'; 
  825.  
  826. public static function get_nonce() { 
  827. return ( defined( 'NONCE_KEY' ) ? NONCE_KEY : '' ).plugin_basename( __FILE__ ); 
  828.  
  829. private function is_profile( $menu_id = false ) { 
  830. return $this->is_lib( 'profile', $menu_id ); 
  831.  
  832. private function is_setting( $menu_id = false ) { 
  833. return $this->is_lib( 'setting', $menu_id ); 
  834.  
  835. private function is_submenu( $menu_id = false ) { 
  836. return $this->is_lib( 'submenu', $menu_id ); 
  837.  
  838. private function is_sitesubmenu( $menu_id = false ) { 
  839. return $this->is_lib( 'sitesubmenu', $menu_id ); 
  840.  
  841. private function is_lib( $lib_name, $menu_id = false ) { 
  842. if ( $menu_id === false ) 
  843. $menu_id = $this->menu_id; 
  844. return isset( $this->p->cf['*']['lib'][$lib_name][$menu_id] ) ? true : false; 
  845.  
  846. public function licenses_metabox_content( $network = false ) { 
  847. echo '<table class="sucom-setting '.$this->p->cf['lca'].' licenses-metabox" 
  848. style="padding-bottom:10px">'."\n"; 
  849. echo '<tr><td colspan="'.( $network ? 5 : 4 ).'">'. 
  850. $this->p->msgs->get( 'info-plugin-tid'. 
  851. ( $network ? '-network' : '' ) ).'</td></tr>'."\n"; 
  852.  
  853. $num = 0; 
  854. $total = count( $this->p->cf['plugin'] ); 
  855. foreach ( $this->p->cf['plugin'] as $ext => $info ) { 
  856. $num++; 
  857. $links = ''; 
  858. $img_href = ''; 
  859. $view_text = _x( 'View Plugin Details', 'plugin action link', 'nextgen-facebook' ); 
  860.  
  861. if ( ! empty( $info['slug'] ) &&  
  862. ( empty( $info['url']['latest_zip'] ) || 
  863. $this->p->is_avail['util']['um'] ) ) { 
  864.  
  865. $img_href = add_query_arg( array( 
  866. 'tab' => 'plugin-information',  
  867. 'plugin' => $info['slug'],  
  868. 'TB_iframe' => 'true',  
  869. 'width' => 600,  
  870. 'height' => 550 
  871. ), get_admin_url( null, 'plugin-install.php' ) ); 
  872.  
  873. // check to see if plugin is installed or not 
  874. if ( is_dir( WP_PLUGIN_DIR.'/'.$info['slug'] ) ) { 
  875. $update_plugins = get_site_transient('update_plugins'); 
  876. if ( isset( $update_plugins->response ) ) { 
  877. foreach ( (array) $update_plugins->response as $file => $plugin ) { 
  878. if ( $plugin->slug === $info['slug'] ) { 
  879. $view_text = '<font color="red">'._x( 'View Plugin Details + Update',  
  880. 'plugin action link', 'nextgen-facebook' ).'</font>'; 
  881. break; 
  882. } else $view_text = _x( 'View Plugin Details + Install', 'plugin action link', 'nextgen-facebook' ); 
  883.  
  884. $links .= ' | <a href="'.$img_href.'" class="thickbox">'.$view_text.'</a>'; 
  885.  
  886. } elseif ( ! empty( $info['url']['download'] ) ) { 
  887. $img_href = $info['url']['download']; 
  888. $links .= ' | <a href="'.$img_href.'" target="_blank">'._x( 'Plugin Description Page',  
  889. 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  890.  
  891. if ( ! empty( $info['url']['latest_zip'] ) ) 
  892. $links .= ' | <a href="'.$info['url']['latest_zip'].'">'._x( 'Download Latest Version',  
  893. 'plugin action link', 'nextgen-facebook' ).'</a> (ZIP)'; 
  894.  
  895. if ( ! empty( $info['url']['purchase'] ) ) { 
  896. if ( $this->p->cf['lca'] === $ext ||  
  897. $this->p->check->aop( $this->p->cf['lca'], false, $this->p->is_avail['aop'] ) ) 
  898. $links .= ' | <a href="'.$info['url']['purchase'].'" target="_blank">'. 
  899. _x( 'Purchase Pro License(s)', 'plugin action link', 'nextgen-facebook' ).'</a>'; 
  900. else $links .= ' | <em>'._x( 'Purchase Pro License(s)', 'plugin action link', 'nextgen-facebook' ).'</em>'; 
  901.  
  902. if ( ! empty( $info['img']['icon_small'] ) ) 
  903. $img_src = 'src="'.$info['img']['icon_small'].'"'; 
  904. else $img_src = 'src="data:image/gif;base64, R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="'; 
  905.  
  906. if ( ! empty( $info['img']['icon_medium'] ) ) 
  907. $img_src .= ' srcset="'.$info['img']['icon_medium'].' 256w"'; 
  908.  
  909. // logo image 
  910. echo '<tr><td style="width:148px; padding:10px;" rowspan="3" valign="top" align="left">'."\n"; 
  911. if ( ! empty( $img_href ) )  
  912. echo '<a href="'.$img_href.'"'.( strpos( $img_href, 'TB_iframe' ) ? 
  913. ' class="thickbox"' : ' target="_blank"' ).'>'; 
  914. echo '<img '.$img_src.' width="128" height="128">'; 
  915. if ( ! empty( $img_href ) )  
  916. echo '</a>'; 
  917. echo '</td>'."\n"; 
  918.  
  919. // plugin name 
  920. echo '<td colspan="'.( $network ? 4 : 3 ).'" style="padding:10px 0 0 0;"> 
  921. <p><strong>'.$info['name'].'</strong></p>'; 
  922.  
  923. if ( ! empty( $info['desc'] ) ) 
  924. echo '<p>'._x( $info['desc'], 'plugin description', 'nextgen-facebook' ).'</p>'; 
  925.  
  926. if ( ! empty( $links ) ) 
  927. echo '<p>'.trim( $links, ' |' ).'</p>'; 
  928.  
  929. echo '</td></tr>'."\n"; 
  930.  
  931. if ( $network ) { 
  932. if ( ! empty( $info['update_auth'] ) ||  
  933. ! empty( $this->p->options['plugin_'.$ext.'_tid'] ) ) { 
  934.  
  935. if ( $this->p->cf['lca'] === $ext ||  
  936. $this->p->check->aop( $this->p->cf['lca'],  
  937. true, $this->p->is_avail['aop'] ) ) { 
  938.  
  939. echo '<tr>'.$this->p->util->get_th( _x( 'Pro Authentication ID',  
  940. 'option label', 'nextgen-facebook' ), 'medium nowrap' ). 
  941. '<td class="tid">'.$this->form->get_input( 'plugin_'.$ext.'_tid', 'tid mono' ).'</td>'. 
  942. $this->p->admin->get_site_use( $this->form, true, 'plugin_'.$ext.'_tid' ); 
  943. } else { 
  944. echo '<tr>'.$this->p->util->get_th( _x( 'Pro Authentication ID',  
  945. 'option label', 'nextgen-facebook' ), 'medium nowrap' ). 
  946. '<td class="blank">'.( empty( $this->p->options['plugin_'.$ext.'_tid'] ) ? 
  947. $this->form->get_no_input( 'plugin_'.$ext.'_tid', 'tid mono' ) : 
  948. $this->form->get_input( 'plugin_'.$ext.'_tid', 'tid mono' ) ). 
  949. '</td><td colspan="2">'.( $this->p->check->aop( $this->p->cf['lca'],  
  950. true, $this->p->is_avail['aop'] ) ? 
  951. '' : $this->p->msgs->get( 'pro-option-msg' ) ).'</td></tr>'."\n"; 
  952. } else echo '<tr><td> </td><td> </td><td> </td><td> </td></tr>'."\n"; 
  953. } else { 
  954. if ( ! empty( $info['update_auth'] ) ||  
  955. ! empty( $this->p->options['plugin_'.$ext.'_tid'] ) ) { 
  956.  
  957. if ( $this->p->cf['lca'] === $ext ||  
  958. $this->p->check->aop( $this->p->cf['lca'],  
  959. true, $this->p->is_avail['aop'] ) ) { 
  960.  
  961. $qty_used = class_exists( 'SucomUpdate' ) ? 
  962. SucomUpdate::get_option( $ext, 'qty_used' ) : false; 
  963.  
  964. echo '<tr>'.$this->p->util->get_th( _x( 'Pro Authentication ID',  
  965. 'option label', 'nextgen-facebook' ), 'medium nowrap' ). 
  966. '<td class="tid">'.$this->form->get_input( 'plugin_'.$ext.'_tid', 'tid mono' ). 
  967. '</td><td><p>'.( empty( $qty_used ) ?  
  968. '' : $qty_used.' Licenses Assigned' ).'</p></td></tr>'."\n"; 
  969. } else { 
  970. echo '<tr>'.$this->p->util->get_th( _x( 'Pro Authentication ID',  
  971. 'option label', 'nextgen-facebook' ), 'medium nowrap' ). 
  972. '<td class="blank">'.( empty( $this->p->options['plugin_'.$ext.'_tid'] ) ? 
  973. $this->form->get_no_input( 'plugin_'.$ext.'_tid', 'tid mono' ) : 
  974. $this->form->get_input( 'plugin_'.$ext.'_tid', 'tid mono' ) ). 
  975. '</td><td>'.( $this->p->check->aop( $this->p->cf['lca'],  
  976. true, $this->p->is_avail['aop'] ) ?  
  977. '' : $this->p->msgs->get( 'pro-option-msg' ) ).'</td></tr>'."\n"; 
  978. } else echo '<tr><td> </td><td> </td><td> </tr>'."\n"; 
  979.  
  980. echo '<tr><td'.( $num < $total ? ' style="border-bottom:1px dotted #ddd;"' : '' ). 
  981. ' colspan="'.( $network ? 4 : 3 ).'"> </td></tr>'."\n"; 
  982. echo '</table>'."\n"; 
  983.  
  984. public function conflict_warnings() { 
  985. if ( ! is_admin() ) // just in case 
  986. return; 
  987.  
  988. $lca = $this->p->cf['lca']; 
  989. $base = $this->p->cf['plugin'][$lca]['base']; 
  990. $short = $this->p->cf['plugin'][$lca]['short']; 
  991. $short_pro = $short.' Pro'; 
  992. $purchase_url = $this->p->cf['plugin'][$lca]['url']['purchase']; 
  993. $err_pre = __( 'Plugin conflict detected', 'nextgen-facebook' ) . ' - '; 
  994. $log_pre = 'plugin conflict detected - '; // don't translate the debug  
  995.  
  996. // PHP 
  997. if ( empty( $this->p->is_avail['curl'] ) ) { 
  998. if ( ! empty( $this->p->options['plugin_shortener'] ) &&  
  999. $this->p->options['plugin_shortener'] !== 'none' ) { 
  1000.  
  1001. if ( $this->p->debug->enabled ) 
  1002. $this->p->debug->log( 'url shortening is enabled but curl function is missing' ); 
  1003. $this->p->notice->err( sprintf( __( 'URL shortening has been enabled, but PHP\'s <a href="%s" target="_blank">Client URL Library</a> (cURL) is missing.', 'nextgen-facebook' ), 'http://ca3.php.net/curl' ).' '.__( 'Please contact your hosting provider to have the missing cURL library files installed.', 'nextgen-facebook' ) ); 
  1004. } elseif ( ! empty( $this->p->options['plugin_file_cache_exp'] ) ) { 
  1005. if ( $this->p->debug->enabled ) 
  1006. $this->p->debug->log( 'file caching is enabled but curl function is missing' ); 
  1007. $this->p->notice->err( sprintf( __( 'The file caching feature has been enabled but PHP\'s <a href="%s" target="_blank">Client URL Library</a> (cURL) is missing.', 'nextgen-facebook' ), 'http://ca3.php.net/curl' ).' '.__( 'Please contact your hosting provider to have the missing library installed.', 'nextgen-facebook' ) ); 
  1008. if ( empty( $this->p->is_avail['mbstring'] ) ) { 
  1009. if ( $this->p->debug->enabled ) 
  1010. $this->p->debug->log( 'php mbstring extension is missing' ); 
  1011. $this->p->notice->err( sprintf( __( 'PHP\'s <a href="%s" target="_blank">Multibyte String</a> extension is missing.', 'nextgen-facebook' ), 'http://php.net/manual/en/book.mbstring.php' ).' '.__( 'Please contact your hosting provider to have the missing extension installed.', 'nextgen-facebook' ) ); 
  1012.  
  1013. // Yoast SEO 
  1014. if ( $this->p->is_avail['seo']['wpseo'] ) { 
  1015. $opts = get_option( 'wpseo_social' ); 
  1016. if ( ! empty( $opts['opengraph'] ) ) { 
  1017. if ( $this->p->debug->enabled ) 
  1018. $this->p->debug->log( $log_pre.'wpseo opengraph meta data option is enabled' ); 
  1019. $this->p->notice->err( $err_pre.sprintf( __( 'Please uncheck the \'<em>Add Open Graph meta data</em>\' option under the <a href="%s">Yoast SEO / Social / Facebook</a> settings tab.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=wpseo_social#top#facebook' ) ) ); 
  1020. if ( ! empty( $opts['twitter'] ) ) { 
  1021. if ( $this->p->debug->enabled ) 
  1022. $this->p->debug->log( $log_pre.'wpseo twitter meta data option is enabled' ); 
  1023. $this->p->notice->err( $err_pre.sprintf( __( 'Please uncheck the \'<em>Add Twitter card meta data</em>\' option under the <a href="%s">Yoast SEO / Social / Twitter</a> settings tab.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=wpseo_social#top#twitterbox' ) ) ); 
  1024. if ( ! empty( $opts['googleplus'] ) ) { 
  1025. if ( $this->p->debug->enabled ) 
  1026. $this->p->debug->log( $log_pre.'wpseo googleplus meta data option is enabled' ); 
  1027. $this->p->notice->err( $err_pre.sprintf( __( 'Please uncheck the \'<em>Add Google+ specific post meta data</em>\' option under the <a href="%s">Yoast SEO / Social / Google+</a> settings tab.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=wpseo_social#top#google' ) ) ); 
  1028. if ( ! empty( $opts['plus-publisher'] ) ) { 
  1029. if ( $this->p->debug->enabled ) 
  1030. $this->p->debug->log( $log_pre.'wpseo google plus publisher option is defined' ); 
  1031. $this->p->notice->err( $err_pre.sprintf( __( 'Please remove the \'<em>Google Publisher Page</em>\' value entered under the <a href="%s">Yoast SEO / Social / Google+</a> settings tab.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=wpseo_social#top#google' ) ) ); 
  1032.  
  1033. // SEO Ultimate 
  1034. if ( $this->p->is_avail['seo']['seou'] === true ) { 
  1035. $opts = get_option( 'seo_ultimate' ); 
  1036. if ( ! empty( $opts['modules'] ) && is_array( $opts['modules'] ) ) { 
  1037. if ( array_key_exists( 'opengraph', $opts['modules'] ) && $opts['modules']['opengraph'] !== -10 ) { 
  1038. if ( $this->p->debug->enabled ) 
  1039. $this->p->debug->log( $log_pre.'seo ultimate opengraph module is enabled' ); 
  1040. $this->p->notice->err( $err_pre.sprintf( __( 'Please disable the \'<em>Open Graph Integrator</em>\' module in the <a href="%s">SEO Ultimate Module Manager</a>.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=seo' ) ) ); 
  1041.  
  1042. // All in One SEO Pack 
  1043. if ( $this->p->is_avail['seo']['aioseop'] === true ) { 
  1044. $opts = get_option( 'aioseop_options' ); 
  1045. if ( ! empty( $opts['modules']['aiosp_feature_manager_options']['aiosp_feature_manager_enable_opengraph'] ) ) { 
  1046. if ( $this->p->debug->enabled ) 
  1047. $this->p->debug->log( $log_pre.'aioseop social meta fetaure is enabled' ); 
  1048. $this->p->notice->err( $err_pre.sprintf( __( 'Please deactivate the \'<em>Social Meta</em>\' feature in the <a href="%s">All in One SEO Pack Feature Manager</a>.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=all-in-one-seo-pack/aioseop_feature_manager.php' ) ) ); 
  1049. if ( array_key_exists( 'aiosp_google_disable_profile', $opts ) && empty( $opts['aiosp_google_disable_profile'] ) ) { 
  1050. if ( $this->p->debug->enabled ) 
  1051. $this->p->debug->log( $log_pre.'aioseop google plus profile is enabled' ); 
  1052. $this->p->notice->err( $err_pre.sprintf( __( 'Please check the \'<em>Disable Google Plus Profile</em>\' option in the <a href="%s">All in One SEO Pack Plugin Options</a>.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=all-in-one-seo-pack/aioseop_class.php' ) ) ); 
  1053.  
  1054. // JetPack Photon 
  1055. if ( $this->p->is_avail['media']['photon'] === true &&  
  1056. ! $this->p->check->aop( $this->p->cf['lca'], true, $this->p->is_avail['aop'] ) ) { 
  1057.  
  1058. if ( $this->p->debug->enabled ) 
  1059. $this->p->debug->log( $log_pre.'jetpack photon is enabled' ); 
  1060. $this->p->notice->err( $err_pre.'<strong>'.__( 'JetPack\'s Photon module purposefully cripples the WordPress image size functions.', 'nextgen-facebook' ).'</strong> '.sprintf( __( 'Please <a href="%s">deactivate the JetPack Photon module</a> or deactivate the %s Free plugin.', 'nextgen-facebook' ), get_admin_url( null, 'admin.php?page=jetpack' ), $short ).' '.sprintf( __( 'You may also upgrade to the <a href="%1$s">%2$s version</a> which includes an <a href="%3$s">integration module for JetPack Photon</a> to re-enable image size functions specifically for %4$s images.', 'nextgen-facebook' ), $purchase_url, $short_pro, 'http://surniaulula.com/codex/plugins/nextgen-facebook/notes/modules/jetpack-photon/', $short ) ); 
  1061.  
  1062. public function check_tmpl_head_elements() { 
  1063. if ( $this->p->debug->enabled ) 
  1064. $this->p->debug->mark(); 
  1065.  
  1066. // only check if using the default filter name 
  1067. if ( empty( $this->p->options['plugin_head_attr_filter_name'] ) || 
  1068. $this->p->options['plugin_head_attr_filter_name'] !== 'head_attributes' ) 
  1069. return; 
  1070.  
  1071. $headers = glob( get_stylesheet_directory().'/header*.php' ); 
  1072. foreach ( $headers as $file ) { 
  1073. if ( ( $html = SucomUtil::get_stripped_php( $file ) ) === false ) 
  1074. continue; 
  1075.  
  1076. if ( strpos( $html, '<head>' ) !== false ) { 
  1077. $this->p->notice->err( $this->p->msgs->get( 'notice-header-tmpl-no-head-attr' ),  
  1078. true, true, 'notice-header-tmpl-no-head-attr', false ); 
  1079. break; 
  1080.  
  1081. public function modify_tmpl_head_elements() { 
  1082. $headers = glob( get_stylesheet_directory().'/header*.php' ); 
  1083. foreach ( $headers as $file ) { 
  1084. $base = basename( $file ); 
  1085. $backup = $file.'~backup-'.date( 'Ymd-His' ); 
  1086.  
  1087. // double check in case of reloads etc. 
  1088. if ( ( $html = SucomUtil::get_stripped_php( $file ) ) === false || 
  1089. strpos( $html, '<head>' ) === false ) { 
  1090. $this->p->notice->err( sprintf( __( '<head> element not found in %s.',  
  1091. 'nextgen-facebook' ), $file ), true ); 
  1092. continue; 
  1093.  
  1094. // make a backup of the original 
  1095. if ( ! copy( $file, $backup ) ) { 
  1096. $this->p->notice->err( sprintf( __( 'Error copying %1$s to %2$s.',  
  1097. 'nextgen-facebook' ), 'header.php', $backup ), true ); 
  1098. continue; 
  1099.  
  1100. $php = file_get_contents( $file ); 
  1101. $php = str_replace( '<head>', '<head <?php do_action( \'add_head_attributes\' ); ?>>', $php ); 
  1102.  
  1103. if ( ! $fh = @fopen( $file, 'wb' ) ) { 
  1104. $this->p->notice->err( sprintf( __( 'Failed to open file %s for writing.',  
  1105. 'nextgen-facebook' ), $file ), true ); 
  1106. continue; 
  1107.  
  1108. if ( fwrite( $fh, $php ) ) { 
  1109. fclose( $fh ); 
  1110. $this->p->notice->inf( sprintf( __( 'The %1$s template has been successfully updated and saved. A backup copy of the original template is available in %2$s.', 'nextgen-facebook' ), $base, $backup ), true ); 
  1111. $this->p->notice->trunc_id( 'notice-header-tmpl-no-head-attr' ); // just in case 
  1112.  
  1113. // dismiss an incorrect yoast seo conflict notification 
  1114. public function dismiss_wpseo_notice( $dismissed, $opt_name, $user_obj ) { 
  1115. $lca = $this->p->cf['lca']; 
  1116. $base = $this->p->cf['plugin'][$lca]['base']; 
  1117. if ( ! is_array( $dismissed['open_graph'] ) || 
  1118. ! in_array( $base, $dismissed['open_graph'] ) ) 
  1119. $dismissed['open_graph'][] = $base; 
  1120. return $dismissed; 
  1121.  
  1122. public function get_site_use( &$form, $network = false, $name ) { 
  1123. if ( $network !== true ) 
  1124. return ''; 
  1125. return $this->p->util->get_th( _x( 'Site Use',  
  1126. 'option label (very short)', 'nextgen-facebook' ), 'site_use' ). 
  1127. ( $this->p->check->aop( $this->p->cf['lca'], true, $this->p->is_avail['aop'] ) ? 
  1128. '<td>'.$form->get_select( $name.':use', $this->p->cf['form']['site_option_use'], 'site_use' ).'</td>' : 
  1129. '<td class="site_use blank">'.$form->get_select( $name.':use',  
  1130. $this->p->cf['form']['site_option_use'], 'site_use', null, true, true ).'</td>' ); 
  1131.  
  1132. ?> 
.